Goal, an embeddable scripting array language.
Find a file
2024-10-31 15:49:44 +00:00
archive/zip archives/zip: add zip.write[s;fs] 2024-10-28 11:21:59 +00:00
cmd a few lint tweaks & consistency renamings 2024-10-30 09:02:53 +00:00
docs update random number generator: use math/rand/v2 2024-10-27 16:49:54 +00:00
examples ignore trailing spaces in multi-line /…\ comments 2024-10-29 08:08:26 +00:00
help update random number generator: use math/rand/v2 2024-10-27 16:49:54 +00:00
internal new internal osutil and fsutil packages 2024-10-06 07:35:12 +00:00
io/fs a few lint tweaks & consistency renamings 2024-10-30 09:02:53 +00:00
lib lib/os.goal: simplify GOALLIB computation using ' 2024-10-24 16:01:57 +00:00
math improve comment 2024-10-13 11:57:48 +00:00
os os package: improve a few doc comments 2024-10-31 15:35:07 +00:00
scan scanner: more accurate column in GetLineCol 2024-10-31 11:52:13 +00:00
scripts update random number generator: use math/rand/v2 2024-10-27 16:49:54 +00:00
testdata fix parsing edge-case with .. and number literals 2024-10-29 16:01:39 +00:00
.gitignore minor cmd/wasm updates 2024-10-23 15:16:38 +00:00
adverbs.go make V.Apply into a variadic function and remove redundant V.Apply2 2024-10-31 07:30:43 +00:00
adverbspecial.go use Go's 1.22 range over integer 2024-10-30 16:27:57 +00:00
amend.go make V.Apply into a variadic function and remove redundant V.Apply2 2024-10-31 07:30:43 +00:00
amendspecial.go Tetradic amend performance improvements 2024-09-23 14:58:24 +00:00
apply.go make V.Apply behave as . for empty list of args 2024-10-31 07:36:39 +00:00
arithd.go add “path glob match” form s%s 2024-08-16 10:22:42 +00:00
arithm.go make round preserve integer types, like _ and uc 2024-10-13 15:32:26 +00:00
arrays.go Go API: move LessT method to new OrderedBV interface 2024-10-04 11:31:39 +00:00
ast.go minor check tweak and comment 2024-07-27 15:38:36 +00:00
benchs_test.go make V.Apply into a variadic function and remove redundant V.Apply2 2024-10-31 07:30:43 +00:00
CHANGES.md update version for release 2024-10-31 15:49:44 +00:00
cmpsearch.go use Go's 1.22 range over integer 2024-10-30 16:27:57 +00:00
compiler.go a few lint tweaks & consistency renamings 2024-10-30 09:02:53 +00:00
context.go update version for release 2024-10-31 15:49:44 +00:00
context_test.go add String method on V meaning Sprint(nil, true) 2024-10-31 09:12:49 +00:00
Credits.md minor updates to match the FAQ 2024-08-25 07:36:54 +00:00
csv.go use Go's 1.22 range over integer 2024-10-30 16:27:57 +00:00
dicts.go use Go's 1.22 range over integer 2024-10-30 16:27:57 +00:00
encdec.go use Go's 1.22 range over integer 2024-10-30 16:27:57 +00:00
errors.go panic and error testing improvements 2024-07-27 15:04:04 +00:00
fills.go proto->fill (same terminology as the FAQ) 2024-07-27 07:40:02 +00:00
flip.go use Go's 1.22 range over integer 2024-10-30 16:27:57 +00:00
fns.go make toAIFunc error-style consistent with toIFunc 2024-10-21 08:14:13 +00:00
functions.go improve alignment in comment 2024-07-26 15:23:04 +00:00
fuzz_test.go fix go vet complaint in fuzzing test 2024-07-25 07:01:58 +00:00
go.mod update random number generator: use math/rand/v2 2024-10-27 16:49:54 +00:00
group.go make toAIFunc error-style consistent with toIFunc 2024-10-21 08:14:13 +00:00
join.go use Go's 1.22 range over integer 2024-10-30 16:27:57 +00:00
json.go use Go's 1.22 range over integer 2024-10-30 16:27:57 +00:00
less.go use Go's 1.22 range over integer 2024-10-30 16:27:57 +00:00
LICENSE add LICENSE 2022-12-26 10:21:43 +00:00
math.go make exp and log dyads accepting base as left arg 2024-10-11 07:50:01 +00:00
norm.go testing & minor refactorings 2024-07-27 11:13:35 +00:00
opcode.go opcode debug info: check for invalid opcodes, so that tests can catch similar mistakes in the future 2024-10-08 17:00:26 +00:00
parser.go a few lint tweaks & consistency renamings 2024-10-30 09:02:53 +00:00
parsev.go refactor: some x.kind == val* -> x.Is* 2024-09-23 08:33:12 +00:00
radix.go use Go's 1.22 range over integer 2024-10-30 16:27:57 +00:00
radix_test.go use Go's 1.22 range over integer 2024-10-30 16:27:57 +00:00
rand.go update random number generator: use math/rand/v2 2024-10-27 16:49:54 +00:00
README.md README: more prose tweaks 2024-10-30 07:30:00 +00:00
refcount.go misspellings 2024-07-27 07:19:18 +00:00
regexp.go a few renamings 2024-10-30 09:08:47 +00:00
rt.go rework and improve rt.get forms 2024-10-06 06:44:27 +00:00
sfns.go use Go's 1.22 range over integer 2024-10-30 16:27:57 +00:00
sort.go use Go's 1.22 range over integer 2024-10-30 16:27:57 +00:00
stringer.go optimize tail calls with special variable o 2024-10-07 09:56:16 +00:00
strings.go use Go's 1.22 range over integer 2024-10-30 16:27:57 +00:00
time.go use Go's 1.22 range over integer 2024-10-30 16:27:57 +00:00
TODO os package: improve error message when using handle of incorrect mode in operation 2024-10-21 07:50:43 +00:00
utf8.go improve "too many arguments" kind of error message 2024-07-19 17:19:02 +00:00
utils.go use Go's 1.22 range over integer 2024-10-30 16:27:57 +00:00
valstring.go add String method on V meaning Sprint(nil, true) 2024-10-31 09:12:49 +00:00
value.go a few comment and prose small updates 2024-10-27 09:28:07 +00:00
variadics.go make V.Apply into a variadic function and remove redundant V.Apply2 2024-10-31 07:30:43 +00:00
vm.go tail calls: small simplification 2024-10-07 16:10:42 +00:00

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

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

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.