A fun and pragmatic embedded scripting language written for Go projects. Import it as a library or try out the Tamarin REPL.
Documentation is available at cloudcmds.github.io/tamarin.
The Quick Start in the documentation is where you should head to get started.
If you use Homebrew, you can install the Tamarin CLI as follows:
brew tap cloudcmds/tamarin
brew install tamarin
Having done that, just run tamarin
to start the CLI or tamarin -h
to see
usage information.
Please visit the Github discussions page to share thoughts and questions.
- Familiar syntax inspired by Go, Typescript, and Python
- Growing standard library which generally wraps the Go stdlib
- Includes higher level libraries that are beyond the Go stdlib
- Currently libraries include:
json
,math
,rand
,strings
,time
,uuid
,strconv
,pgx
- Built-in types include:
set
,map
,list
,result
, and more - Functions are values; closures are supported
- Cancel evaluation using Go contexts
- Library may be imported using the
import
keyword - Easy HTTP requests via the
fetch
built-in function - Pipeline expressions to create processing chains
- Error handling inspired by Rust, using a Result type
- String templates similar to Python's f-strings
See docs/Features.md.
A Tamarin VSCode extension is already available which currently only offers syntax highlighting.
You can also make use of the Tamarin TextMate grammar.
Work in progress. See assorted.tm.
🎉 This project is just getting started. Tamarin is intended to be a community project and you can lend a hand in many different ways.
- Please ask questions and share ideas in Github discussions
- Share Tamarin on any social channels that may appreciate it
- Let us know about any usage of Tamarin that we can celebrate
- Leave us a star us on Github
- File I/O was intentionally omitted for now
- No concurrency support yet
- No user-defined types yet
A single value may be passed between successive calls using pipe expressions.
array := ["gophers", "are", "burrowing", "rodents"]
sentence := array | strings.join(" ") | strings.to_upper
print(sentence)
Output:
GOPHERS ARE BURROWING RODENTS
The intent is that if any call in the pipeline returns a Result
object, that
object is unwrapped before providing it to the next call (or the pipeline aborts
if the Result is an error). This is not yet implemented.
There are two categories of errors in Tamarin. Severe errors which indicate a programming mistake
create *object.Error
errors that abort evaluation immediately. These are similar to Go panics.
Operations that may fail return an *object.Result
object that contains either an Ok
value or
an Err
value. This is inspired by Rust's Result type.
Result
objects proxy to the Ok
value in certain situations, to keep adhoc scripting concise.
is_err
: returnstrue
if the Result contains an erroris_ok
: returnstrue
if the Result contains the successful operation valueunwrap
: returns the ok value if present and errors otherwiseunwrap_or
: returns the ok value if present and the default value otherwiseexpect
: returns the ok value if present or raises an error with the given message
Other method calls on the Result
object proxy to calls on the ok value (or
raise an error).
Altogether this means programmers have reliable tools for handling errors as
values without requiring try: catch
style exceptions. In quick scripts, you
can rely on Result
method proxying if you want, while in situations requiring
robustness you can use the Result
methods to check for and unwrap errors.
- Thorsten Ball and his book Writing an Interpreter in Go.
- Steve Kemp and the work in github.com/skx/monkey.
See more information in CREDITS.
Released under the MIT License. Copyright Curtis Myzie / github.com/myzie.