Red is a new programming language strongly inspired by REBOL, but with a broader field of usage thanks to its native-code compiler, from system programming to high-level scripting, while providing modern support for concurrency and multi-core CPUs.
The language is in its early bootstrap phase, once complete it will be self-hosted. The Red software stack also contains another language, Red/System, which is a low-level dialect of Red. It is a limited C-level language with a Red look'n feel, required to build Red's runtime library and be the target language of Red's compiler. More information at red-lang.org.
The compiler and linker are currently written in REBOL and can produce Windows, Linux, Syllable, Android and Mac OS X executables. So, for now, a REBOL/Core binary is required to compile Red and Red/System programs. Please follow the instructions for installing the compiler tool-chain:
-
Clone this git repository or download an archive (
ZIP
button above or from tagged packages). -
Download a REBOL interpreter suitable for your OS: Windows, Linux, Mac OS X, FreeBSD, OpenBSD, Solaris
-
Extract the
rebol
binary, put it in root folder, that's all! -
Let's test it: run
./rebol
, you'll see a>>
prompt appear. Windows users need to double-click on therebol.exe
file to run it. -
From the REBOL console type:
>> do/args %red.r "%red/tests/hello.red"
The compilation process should finish with a ...output file size
message. The resulting binary is in the working folder. Windows users need to open a DOS console and run hello.exe
from there.
-
To see the intermediary Red/System code generated by the compiler, use:
>> do/args %red.r "-v 1 %red/tests/hello.red"
Command-line options:
-d : switches into debug mode.
-o <file> : outputs executable to given path and/or filename.
-t <target> : cross-compiles to another target (see table below).
-v <level> : sets verbose mode. 1-3 are for Red only, above for Red/System.
Important: Red will be distributed as a binary to end users and the effect of:
red script.red
will be to compile and run it from memory directly. So the -o option will become mandatory in the future for generating an executable without running it. During the bootstrap stage, it is complex to support that feature, but anyway, we will implement it as soon as possible.
-
From the REBOL console type:
>> do/args %red.r "%red/tests/console.red"
-
From Unix, just type
console
from prompt, Windows users need to open a DOS console and runconsole.exe
from there, or just click on the executable from Explorer (but you will miss the error messages then). Once the console launched, you should see a banner and a prompt:-=== Red Console alpha version ===- (only Latin-1 input supported) red>>
-
You can use it to test rapidly some Red code:
red>> 1 + 2 == 3 red>> inc: func [n][n + 1] == func [n][n + 1] red>> inc 123 == 124
-
From the REBOL console type:
>> change-dir %red-system/
-
Type:
do/args %rsc.r "%tests/hello.reds"
, the compilation process should finish with a...output file size
message. -
The resulting binary is in
red-system/builds/
, go try it! Windows users need to open a DOS console and runhello.exe
from there.
The %rsc.r
script is only a wrapper script around the compiler, for testing purpose. It accepts a -v <integer!>
option for verbose logs. Try it with:
>> do/args %rsc.r "-v 5 %tests/hello.reds"
Cross-compilation is easily achieved by using a -t
command line option followed by a target ID. This command-line option works for both Red and Red/System compilers.
Currently supported targets are:
Target ID | Description |
---|---|
MSDOS | Windows, x86, console-only applications |
Windows | Windows, x86, native applications |
Linux | GNU/Linux, x86 |
Linux-ARM | GNU/Linux, ARMv5 |
Darwin | Mac OS X Intel, console-only applications |
Syllable | Syllable OS, x86 |
Android | Android, ARMv5 |
For example, from Windows, to emit Linux executables:
>> do/args %rsc.r "-t Linux %tests/hello.reds"
From Linux, to emit Windows console executables:
>> do/args %rsc.r "-t MSDOS %tests/hello.reds"
Some anti-virus programs are a bit too sensitive and can wrongly report an alert on some binaries generated by Red, if that happens to you, please fill a ticket here, so we can report the false positive.
Both Red and Red/System are published under BSD license, runtime is under BSL license. BSL is a bit more permissive license than BSD, more suitable for the runtime parts.