Getting Started

Installing Red locally

Here is a step by step guide of how to install Red locally:
  1. Download the correct Red console binary version for your computer (takes only a couple of seconds). Save it into a suitable folder.
  2. For Windows users, run it by double-clicking on the downloaded file. The GUI-console will automatically open.
  3. 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.
Done! No installer, no setup, no dependencies(*)! What, that's all? Yes, there was a time when software used to be done right, that's what we aim at bringing back. ;-)

(*) 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:
    >> view [text "Hello World!"]
Now try something more sophisticated:
    >> 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
            ]
        ]
    ]
Yes, GUI programming can be that easy! See more about GUI capabilities in this GUI release post and have a look into the View reference documentation.


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
    > hello
4. 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.red
Cross-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:

Happy coding/hacking and have fun...that's the whole point! ;-)


Fork me on GitHub