There’s a new REBOL like programming language in town. It’s called Red, it’s BSD licensed and contrary to REBOL and Boron, Red is a compiled language. The Syllable project is proud to announce that Red programs now run on Syllable Desktop. Here is a screenshot from a demo program. Syllable is the third Red target platform, after Windows and Linux.
Red was introduced at the REBOL & Boron conference in the Netherlands in February by its creator Nenad Rakocevic from Paris, previously of Cheyenne fame. The project is less than half a year old and has been public for a mere three months, but the first phase of the language, the design and implementation of the Red/System dialect is already nearing completion. It will be presented at the Cht’i RUG 2011 in Lille, France. If you are in time for the conference, you can follow it live on Twitter.
Red’s name hints at its goal to offer a reduced REBOL dialect that is suitable for compilation, while still being as much like REBOL as possible. The new language is currently being bootstrapped in an ingenious way. The demo program is not written in Red yet, but in Red/System, yet another REBOL like dialect. Red/System is a low level language comparable to C, with similar capabilities. It will be used in the next phase to implement the higher level Red language.
Red was ported to Syllable in a collaboration with the REBOL community. Syllable Desktop has its own in-kernel ELF loader. Red has its own ELF executable format emitter. At first they didn’t match, because both try to be lean and don’t implement the full ELF specification. Syllable always generates its own program executables as Position Independent Code, as if they were shared libraries. As such, Syllable expects all binaries to have section headers. Red’s backend doesn’t support PIC yet and didn’t strictly need section headers. Andreas Bolka implemented them for Syllable and for the coming PIC implementation in Red. He also implemented proper address alignment, which Syllable requires more strictly than the GNU loader on Linux. Finally, the starting address of the generated binaries was moved to Syllable’s user address space, and an embedded kernel syscall was adapted.
Red/System already has several interesting properties. It is a complete compiler toolchain, including a native code generator and a static linker. It is tiny and does not need the huge GCC or even the GNU linker. The LLVM JIT compiler infrastructure was considered, but also deemed unsuitable due to its bloat. The compiler is currently written in REBOL 2, which means it must be run on one of the REBOL 2 platforms: Linux, FreeBSD, OpenBSD, Mac or Windows. However, Red/System can trivially be used as a cross-compiler, so Syllable programs can now be cross-developed from those platforms. Once the Red language is implemented, the compiler will be ported from REBOL to Red. It will then also run on Syllable itself, and it will be possible to use Syllable to cross-develop for other Red platforms. Eventually, a JIT compiler will be added, opening even more possibilities with dynamic compilation.
The goal of the compiler is to reach performance on par with the best JavaScript JIT compilers. Currently, only an x86 code generator is implemented, but the design is prepared for multiple backends. Many different ones are possible. ARM and x64 are the primary bare metal targets. Further, it is a specific goal to be able to target Red at embedded platforms and virtual machine platforms such as the JVM, Dalvik and .Net.
Maybe when the Amiga port gets released I will care.
As always with open source projects, it will happen faster if you contribute the port you want.
Just because they started out with x86 doesn’t mean you can’t port it to PPC later on.
Yes REBOL 3 works on PPC Amigas. No it doesn’t work on all Amiga-likes.
…to spend a paragraph at the top of the article describing what REBOL is, what it’s good for, and why anyone would want a compiled version of it?
The article is about Red, not about REBOL. Red already has considerable documentation, which is linked. If you want to know about REBOL, it’s easy to find.
Red is additional linked to REBOL, because the current Red is written in REBOL and need the interpreter of it.
I’ve followed Rebol for quite a while (although I’ve only played around with it a bit). Good to see that there are open-source workalikes of it coming along now.
Rebol looks like the kind of language that could be reasonably straightforward to implement using a bootstrap approach. Define what a “word” is and build things up from there. It reminds me a bit of Forth (not that I’ve used that much either… )
Exactly. One of the inspirations for REBOL was Forth, and the REBOL 2 interpreter is a Forth-like engine. (REBOL 1 had a Scheme-like engine. REBOL 3 is probably somewhere inbetween.)
Why did they consider the LLVM JIT instead of the static compilation process? At the beginning of the article didn’t they say that Red is aiming to be statically compilable?
I must question the optimization capabilities of the toolchain when they reinvent the wheel only to have to reinvent every single spoke on the wheel.
LLVM JIT wasn’t considered instead of the static compilation, it was considered period. The article and the Red roadmap explain that after the static compiler, a JIT compiler will be added early next year. This is needed to implement more REBOL features, because REBOL is an inherently dynamic language.
In such projects, there’s always the dilemma of using existing projects or rolling your own. This could be called reinventing wheels, but that assumes that you would be happy with wooden donkey cart wheels on your new electric car.
REBOL is designed as a meta-language, a tool for others to develop languages with. This makes it especially suitable to bootstrap Red with. When evaluating what LLVM brings to the table in addition to that, it was apparent that it didn’t justify the overhead. The current Red/System compiler, code generator and linker are implemented in a total of around 3000 lines. The compressed distribution package including a runtime and a test suite is currently around 100 KB. Compare that to LLVM and GCC and you’ll see why they weren’t needed.
Here’s the author’s take:
<a href=”http://groups.google.com/group/red-lang/browse_thread/thread/eeca0a…