Comments ↓
Brat is a little language for people who don't like to be told what to do.
Brat is a little toy language that just doesn't care.
It won't admit it, but it is not even out of infancy. Not even a toddler yet. But it can already run methods and create objects and has arrays and hashes and numbers and that sort of stuff, so it thinks quite highly of itself.
Brat uses a PEG parser written using TreeTop, a Ruby parser generator. The Brat code is then converted into Neko, compiled to Neko bytecode, and then run on the Neko VM.
Brat is flexible enough that you can get by with a very small core and write any functionality that most languages use keywords for. For example, you can write and use a while loop like so:
#Loops until the block returns false
while = { block |
true? block, { while ->block }
}
n = 1
while {
p n
n = n + 1
n < 10
}
If you would rather have your conditions be separated out, you could define it this way instead:
#Loops until condition is false
while = { condition, block |
true? condition, { block; while ->condition, ->block }
}
n = 1
while { n < 10 }, { p n; n = n + 1 }
Features
- Compiles to the Neko VM the way Python compiles to its bytecode
- Parser is in Ruby
- Typeless, and pretty much classless
- Everything is object, except functions
- And functions are closures, which can be attached to objects to make methods
- Objects use a prototyping system and are completely open (plus, you can clone or inherit, your choice)
- Tail calls are optimized to make infinite loops faster (and more inifinite)
- Interactive shell just like the big boys
- Built in hash tables and dynamic arrays
- Arbitrary precision numbers
- Very flexible unary and binary operators
Last updated 08/11/09
