Growl
Growl is a concatenative, stack-based programming language written in C, inspired by Forth and Factor.
Growl sports what I call command syntax, a small but expressive syntax sugar: any word ending in : collects everything up to the next semicolon as its arguments before emitting the call:
if: x 0 >
["positive" println]
["negative" println];
\ De-sugars into:
x 0 > ["positive" println] ["negative" println] if
This allows for control flow combinators to feel like control flow and read in a natural order.
Internally, Growl is implemented with a stack-based virtual machine and a single-pass bytecode compiler with tail-call optimization. The runtime has a pseudo-generational garbage collector: a nursery implementing Cheney’s algorithm, and a tenured region which uses a simple bump allocator, for objects whose lifetime is static throughout the program (like compiled quotations or interned constants.)
Growl is still a work-in-progress, but you can find the source code in my Git forge.
\ Fizzbuzz in Growl
load "std.grr"
def divisor? { % 0 = }
def fizzbuzz? { [3 divisor?] [5 divisor?] bi or }
def fizz { when: 3 divisor? ["Fizz" print]; }
def buzz { when: 5 divisor? ["Buzz" print]; }
def fizzbuzz1 {
if: dup fizzbuzz?
[[fizz] keep buzz "\n" print]
[.];
}
def fizzbuzz {
0 swap
times: [1 + [fizzbuzz1] keep];
drop
}
30 fizzbuzz