Fork me on GitHub

March 16, 2011

Having fun with Red/System

A week after the first alpha release of Red/System compiler for Windows, we now have a working Linux/ELF support, thanks to Andreas help in deciphering the ELF format. Currently only syscalls are available, the dynamic library linking part is pending, it should be added before the end of March. The following Red/System "hello world" script:

Red/System [
Purpose: "hello world script"
]

print "Hello World!"

compiles to a 162 bytes ELF binary, while a similar C code would produce a 5-6KB binary using Gcc...pretty good, no?

I must admit that supporting ELF wasn't in my short-term roadmap, but I changed my mind after seeing that a large part of people following Red project are Linux users. I think it was a good move as Linux users are also often hackers, so more inclined to contribute to an open source project like Red.

I was also impressed, yesterday, when I saw Kaj de Vos publishing a 0MQ mapping for Red/System (running only on Windows or Wine currently, as it needs dynamic linking). Even at this early stage, he managed to wrap 0MQ's main features. You can get his script from here (requires a libzmq.dll file that can be obtained from here, just put it in the same folder as the compiled binary). Here's the result after compiling and running the server and client versions:

The client sends 10 "Hello" messages to the server that replies to each of them with "World". Oh, did I mention that client.exe and server.exe files size is 3KB? :-)

I hope that people already playing with Red/System enjoy it as much as I did writing it.

3 comments:

  1. I added your feed to my Google Reader, because I'm quite interested in Rebol-derived languages. But as a related question, if languages like Red and Boron are both Rebol-inspired, do they somehow benefit from each other's development as well?

    ReplyDelete
  2. Thanks for joining!

    Boron is an interpreter while Red relies on several compilers (static and JIT), so I'm not sure they will have much to share from there internal design or implementation.

    OTOH, bindings to OS features and external libraries are something that can be shared to some extent between Boron and Red (as long as the binding licensing is compatible, Boron being LGPL while Red is BSD).

    ReplyDelete
  3. Bindings are not so easy to make in Boron as in Red. In Red, bindings are written straight in Red/System. In Boron, you have to write them in C and add them in several places inside the interpreter source code as new Boron functions, because there's no special interface defined for bindings.

    ReplyDelete