Show Xojo: Roo - A programming language written in Xojo

Hi everyone.

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)
  • Modules

It’s extensively documented over at (GitHub).

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.

Very cool - will check it out.

Very cool indeed. Just make sure that this is not going against the Xojo EULA.

Yes, I don’t think it is allowed to make another language with Xojo.

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 :slight_smile:

regarding the EULA, you can make anything with Xojo, just a word in the about box “made with xojo” is needed if it is a programming tool.

Ooh very cool.

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.

Feedback welcome as always!

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:

Homepage
Releases

Pretty impressive Garry!

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 need any pointers, happy to help out.

Also note the updated URL.

[quote=371179:@Garry Pettet]…
I’m going to start working on supporting quick Linux installation with either apt or Linuxbrew. After that, I’ll tackle Windows with Scoop.[/quote]

you can use Chocolatey as package manager in Windows, I use it, may be I could upload it for you.

It’s interesting the Project, you have thinking about async operations? it would be really nice.

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.

Thanks. async is on the agenda but I want to nail down the base language syntax first. Then add IO operations, then async.

Version 1.1.9 is out!

In addition to some new Array methods, this now adds support for installing Roo not only with Homebrew on macOS but also with Scoop on Windows.

Installing on Windows is now as easy as typing this in the Powershell or Command Prompt:

scoop install https://raw.githubusercontent.com/roolang/scoop-roo/master/roo.json

and on macOS in the Terminal:

brew tap roolang/homebrew-roo brew install roo

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 doesn’t 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:

macOS

brew update brew upgrade

Linux (64-bit)

sudo snap refresh roo

Windows

scoop update scoop update roo