Installing Red locally
- Download the correct Red console binary version for your computer (takes only a couple of seconds). Save it into a suitable folder.
- For Windows users, run it by double-clicking on the downloaded file. The GUI-console will automatically open.
- For Linux/OSX users, you need to open a terminal app to be able to run Red. Once you have opened the terminal app, change to the directory in which you saved Red. Now do a: chmod u+x <red-binary> which will make sure that Red can be run on your computer. After that simply run Red using ./<red-binary>. This will open the Red console.
(*) We have a temporary dependency on libcurl3 for Linux platform, so in case it is not installed or if you are running a 64-bit Linux, please check extra instructions from our download page.
First steps with Red
A simple Hello World would look like:
>> print "Hello World!" Hello World!
If you are running Red from Windows, you can also use the built-in GUI system and make a more appealing HelloWorld:
Now try something more sophisticated:>> view [text "Hello World!"]
>> view [name: field button "Hi" [print ["Hi" name/text]]]
A more sophisticate example that retrieves the last commits from the Red Github repo and displays their log messages in a scrollable list:
>> view [ text-list data collect [ foreach event load https://api.github.com/repos/red/red/commits [ keep event/commit/message ] ] ]
Generating a standalone executable
You can also compile your Red programs and get a single binary with no dependencies. Download the Red toolchain binary for your platform and save it in your working folder under the name `redc` (`redc.exe` under Windows). Here is how to use it:
1. In a code or text editor, write the following Hello World program:
Red [Title: "Simple hello world script"] print "Hello World!"2. Save it under the name: hello.red
3. From a terminal (works from DOS too), type:
$ redc -c hello.red $ ./hello or from DOS: > redc -c hello.red > hello4. After about a minute (first compilation generates libRedRT), you should see the Hello World! output.
5. Want to cross-compile to another supported platform?
$ redc -t Windows hello.red $ redc -t Darwin hello.red $ redc -t Linux-ARM hello.redCross-compilation done right: checked! ;-)
Here is a list of currently supported platforms:
MSDOS : Windows, x86, console (+ GUI) applications Windows : Windows, x86, GUI applications WindowsXP : Windows, x86, GUI applications, no touch API Linux : GNU/Linux, x86 Linux-ARM : GNU/Linux, ARMv5, armel (soft-float) RPi : GNU/Linux, ARMv5, armhf (hard-float) Darwin : macOS Intel, console-only applications macOS : macOS Intel, applications bundles Syllable : Syllable OS, x86 FreeBSD : FreeBSD, x86 Android : Android, ARMv5 Android-x86 : Android, x86
Compiling a GUI "Hello World"
Save the following code in hello-gui.red file:
Red [Needs: 'View] view [text "Hello World!"]Compile and run it the same way as the first hello.red script (just replace the filename with hello-gui.red). Notice that compiled GUI apps requires a Needs: 'View declaration in the Red header block. This tells the compiler to import the View module, which contains all the GUI supporting code.
Going further...
You can now continue your journey discovering all the great features of Red through the following links:
- A user-friendly introduction to Red (including some history).
- Learning about Red core concepts using the Rebol documentation (mirror).
- A introduction to Parse DSL with an example of creating a simple DSL.
- Chatting with the Red community and asking questions to the Red contributors.
- Explore the red/red repository on Github and have a look at the source code.
- Try some of the samples in red/code.
- Install the Visual Studio Code IDE with the Red extension.
Happy coding/hacking and have fun...that's the whole point! ;-)