Hello World in Red

Published on 20 April 2018 (Updated: 15 May 2023)

Welcome to the Hello World in Red page! Here, you'll find the source code for this program as well as a description of how the program works.

Current Solution

Red [Title: "Hello World in Red"]

print "Hello, World!"

Hello World in Red was written by:

This article was written by:

If you see anything you'd like to change or update, please consider contributing.

How to Implement the Solution

Let's get right to our implementation of Hello World in Red.

Honestly, this is about the weirdest syntax I've ever seen, so I really had to dig into the docs.

According to Helpin'Red, the first line in our solution is the header, and it's absolutely necessary for all scripts. The header is composed of two parts: the Red keyword and the block..

Now, every script will have the Red keyword. As for the block, well, that will vary per script. Honestly, the information in that block is largely optional, but it can be used to declare script information such as a title, a description, a version, and an author. In this case, I simply gave the script a title.

In addition to arbitrary information, the first block can also be used to import libraries. For example, we could have implemented Hello World in Red as a GUI:

Red [needs: 'view]

view [
  text "Hello, World!"
]

Here, we use the header block to import the graphics view library. Then, we use that library to display a window containing "Hello, World!"

At any rate, the last line in our original implementation clearly prints "Hello, World!" to the user. We've seen this plenty of times already so no need to dig into it.

How to Run the Solution

If we're looking to run this solution, perhaps the easiest way to do so is to download the latest Red toolchain. Of course, we'll also want to grab a copy of the Hello World script from GitHub.

Now, drop both of those files in the same folder and run the following:

red hello-world.red

If you're a Windows user, you may need to call the executable directly.

In addition, we can compile our script using the following command:

red -c hello-world.red

At this point, I would usually share some online editor you could use to test code, but Red doesn't appear to have one. If one exists, let me know in the comments.