archive/zip | ||
cmd | ||
docs | ||
examples | ||
help | ||
internal | ||
io/fs | ||
lib | ||
math | ||
os | ||
scan | ||
scripts | ||
testdata | ||
.gitignore | ||
adverbs.go | ||
adverbspecial.go | ||
amend.go | ||
amendspecial.go | ||
apply.go | ||
arithd.go | ||
arithm.go | ||
arrays.go | ||
ast.go | ||
benchs_test.go | ||
CHANGES.md | ||
cmpsearch.go | ||
compiler.go | ||
context.go | ||
context_test.go | ||
Credits.md | ||
csv.go | ||
dicts.go | ||
encdec.go | ||
errors.go | ||
fills.go | ||
flip.go | ||
fns.go | ||
functions.go | ||
fuzz_test.go | ||
go.mod | ||
group.go | ||
join.go | ||
json.go | ||
less.go | ||
LICENSE | ||
math.go | ||
norm.go | ||
opcode.go | ||
parser.go | ||
parsev.go | ||
radix.go | ||
radix_test.go | ||
rand.go | ||
README.md | ||
refcount.go | ||
regexp.go | ||
rt.go | ||
sfns.go | ||
sort.go | ||
stringer.go | ||
strings.go | ||
time.go | ||
TODO | ||
utf8.go | ||
utils.go | ||
valstring.go | ||
value.go | ||
variadics.go | ||
vm.go |
Goal
Goal is an embeddable array programming language with a bytecode interpreter, written in Go. The command line intepreter can execute scripts or run in interactive mode. Goal shines the most in common scripting tasks, like handling columnar data or text processing. It is also suitable for exploratory programming.
Install
To install the command line interpreter, you only need to have the go compiler installed (Go 1.22 or later required). There are no extra dependencies.
You can then build the intepreter with:
go build ./cmd/goal
You should now have a working goal
executable in the current directory. Use
the --help
option for command-line usage.
Running goal
without arguments opens the REPL. For a better experience using
the REPL with the usual keyboard shortcuts, you can install the readline
wrapper rlwrap
program and then use instead rlwrap goal
. The rlwrap
program is available as a package on most systems.
Links
- Documentation (tutorials, help, FAQ).
- REPL help copy in text format.
- Try Goal on the Browser.
- Changelog of changes between releases.
- Go API docs: pkg.go.dev, godocs.io.
Examples
Aside from the examples found in the documentation, there are various places with code written in Goal:
- The examples directory contains AoC solutions and a few other short scripts.
- The lib directory contains various library utilities. You might want
to add it to the
GOALLIB
environment variable to simplify import paths. - The testdata/scripts directory contains various example
scripts used in regression testing; they come along an expected result after
a
/RESULT:
comment. - The scripts directory contains a few code generation scripts.
Here's how a Goal script looks like:
/ Handle command-line arguments: script name + optional file.
(2<#ARGS)and:error"USAGE: goal wordstats.goal [file]"
/ Read STDIN or filename given by last argument; lowercase everything.
src:_ 'read?[1=#ARGS;STDIN;*|ARGS]
/ Get all words (Unicode letters + dashes).
words:rx/[\p{L}-]+/[src;-1]
/ Print number of words; number of distinct words; five most frequent words.
say(#words;#dw:?words;5@!>dw!=%words)
See the tutorial for detailed explanations on a similar example with syntax highlighting!
Tooling
- ari: interactive programming environment built on top of Goal with a dedicated SQL mode (by @semperos).
- goal2html: html markup generation for Goal source.
- vim-goal : vim files for Goal.
Community
- Array programming : several matrix chat rooms about array languages, including a general one.
- ngnk matrix chat : a chat room about K and K-like languages.
Contribute
User testing and bug reports are welcome! Feel free to open an issue, send a pull request, or send a patch by email.
See the implementation notes to get started about the internals. You might want to check problems.md and old issues before submitting a new issue.