I thought I’d share my latest project: Roo. Roo is an object-orientated dynamically-typed interpreted scripting language written entirely in Xojo. The syntax is a mix between Python (indentation control block scoping, etc) and Ruby (everything is an object). The project is open source and I’ve prioritised code readability over performance so people can try to learn how a programming language is made. The lexer, parser and interpreter are all hand written from scratch in Xojo. It currently supports the following:
Variables (Text, Numbers, Booleans, arrays)
Functions (with/without parameters) and closures
Loops (let…do…until and while)
if…elif…else constructs and the ternary operator
Classes (including static methods, inheritance and method overloading)
It’s a command line tool so just either compile it from source or download one of the prepared binaries from the releases page. It can either be used as a REPL in a Terminal (interpreting things line by line as you enter them) or it can execute a script (text file with the .roo extension) by passing it as an argument.
I’d really appreciate any feedback. Happy to answer any questions on it.
There’s nothing in our EULA that prohibits creating a language with Xojo. What would be prohibited would be if you provided a runtime or other ability to distribute a stand alone application that didn’t rely on the user having a Xojo license. That’s where you’d run afoul of our EULA.
@Geoff Perlman: I have binaries for the interpreter in the GitHub repo. Is that allowed? The interpreter only executes scripts and can’t create standalone applications. Plus I wouldn’t recommend using Roo for anything too demanding - the code is executed by walking the AST after all so don’t expect break neck speeds
Just pushed a big update to Roo to GitHub. Many, many changes, most significantly you can now include any number of files in a script using the require statement. This makes the creation of third party libraries possible. I’ll be looking to flesh this out over the next couple of point releases. I’m also looking at making it easier to install, probably using Homebrew on macOS and Linuxbrew on Linux.
It’s now possible to easily install Roo and keep it updated using the brilliant Homebrew package manager on macOS. Once Homebrew is installed, you can install Roo quickly with the following terminal commands:
brew tap roolang/homebrew-roo
brew install roo
I’m going to start working on supporting quick Linux installation with either apt or Linuxbrew. After that, I’ll tackle Windows with Scoop.
I don’t seem to be able to edit the original post but I’ve changed the GitHub homepage and releases page away from my personal GitHub account and to the language’s own GitHub account. The new details are as below:
Garry I’ve converted this to run as a desktop app in a window for evaluation. OK its slow as it walks the AST tree as someone pointed out earlier, but highly instructive for someone needing an interpreter - I had started on my own but you’ve caused me to ditch it and start afresh.
My coding time is unfortunately highly constrained between a day job and a 3-year old at home.
[quote=371240:@Nicholas Loveday]Garry I’ve converted this to run as a desktop app in a window for evaluation. OK its slow as it walks the AST tree as someone pointed out earlier, but highly instructive for someone needing an interpreter - I had started on my own but you’ve caused me to ditch it and start afresh.
My coding time is unfortunately highly constrained between a day job and a 3-year old at home.[/quote]
Glad you’re finding it instructive. I totally hear you vis a vis a kids! I’m just trying to nail down the language syntax at the moment and get the interpreter fully baked before I look to optimise it. Once I’ve optimised the interpreter I’m going to make a start on a bytecode VM (like Java) for it - again written in Xojo.
If you could help with packaging it for Chocolatey that would be great! The interpreter expects the folder packages to be in the same folder as the executable roo. This is easily achieved with Homebrew as roo is symlinked into the user’s path. Not sure if that’s how Chocolatey works. If not, I could alter the expected path for packages from within the interpreter.
Additionally, weird characters are no longer printed to the console on Windows. This was due to Roo trying to colourise the output of errors but this doesnt seem to be supported on Windows (a Shell limitation). Colouring continues to work fine on macOS and Linux.
Right, I think I’ve got package management sorted. It’s now a doddle to install Roo on macOS, Linux (64-bit) and Windows (64-bit) using Homebrew, Snaps and Scoop. Full instructions are provided in the README. I recommend uninstalling Roo and using these package managers to keep up to date as it makes things a lot easier.
Release 1.2.1 is out. In addition to adding Array.find(obj as Object) and Array.insert!(index as Integer, obj as Object) methods, I’ve laid the foundations for supporting built-in modules. This will allow me to namespace internally which means I can soon add native file system manipulation. Currently you can see these native modules in action with Roo.version() and Maths.PI.
If you’ve installed Roo with one of the packages managers described in the README then updating to the latest version is as easy as: