Felix Codes

Babble programming language

This is mostly of interest to programming language enthusiasts.

Babble is a toy programming language with Lisp-like syntax and dynamic types. It's based on the architecture described in the articles Tiny scripting engines for everyone and Scripting without scripting, with important improvements such as quoted strings, making it actually usable. While Babble looks like a Lisp or Scheme, it works more like a modern, friendly programming language (influenced by Janet and Hy, with a few ideas from NewLisp).

It's implemented as a naive AST interpreter, with a minimal number of new types; in particular, it doesn't have symbols, keywords or pairs.

Special thanks to Blubberquark, jtiai and imallett for feedback and suggestions.


As of 20 March 2023, there a native implementation in Nim. Python prototypes are still included with the source code:

This software is open source under the MIT License; see in the source code.


Quick start

Try the following lines, either at the Babble prompt or in a file:

; Semicolons at the start of a line make it into a comment.
; Whitespace doesn't matter outside of quoted strings.
(print "Hello, world!\n")
(println '2 + 3 =' (+ 2 3))
(function double (n) (* $n 2))
(var m 5) (println (double $m))
(var a [5 6 7]) (a 2)
(if (< 1 2) "Math holds true!" "Reality is broken.")
; There's (if), (when) and (cond) that work like in most dialects.
; The JS version has (alert), (confirm) and (prompt), but not (load) or (quit).

Notes for Lisp users:


(println "Hello, world!")
(apply $println "Hello, world!")

A dollar sign sigil denotes variable lookup. Internally, $a is expanded to (get a). Otherwise a is just a literal string (with the exception shown above). As a consequence, this works too, it's just kinda silly:

('print' 'Hello, world\n')

For a literal list, use square brackets: [a b c]. They're expanded to (quote a b c).


A quick informal benchmark mixing list access and arithmetic suggests that Babble is roughly 20x slower than Python and 30x slower than Tcl, even accounting for startup times.

Babble appears to run correctly under -d:danger, which should improve performance, but that's not enabled in default builds. More testing is needed.


More generally, Babble needs a proper lexer and parser, not an improvisation.