Hello World in Racket

Published on 25 July 2019 (Updated: 02 May 2020)

Hello World in Racket

In this article, we’ll take a look at Hello World in Racket!

How to Implement the Solution

Alright, let’s go ahead and dig into our implementation of Hello World in Racket:

#lang racket/base
"Hello, World!"

Up first, we have this peculiar line that looks kind of like a comment in Python or an import in C. As it turns out, the lang line specifies the language used by the interpreter. In fact, I already mentioned that there’s a module which provides syntax for static typing in Racket.

In this case, the language we have chosen is racket/base. This only provides us the core Racket functionality. As an alternative, we could have easily specified racket alone.

Finally, we have our print line. To be honest, we could have used the print functionality:

#lang racket/base
(print "Hello, World!)

However, I wanted to show that you can implement Hello World without the mess of parentheses. That’s because Racket automatically prints constants. If we had a slightly more complicated expression:

#lang racket
+ 2 2

We would see the three constants returned to us in their stack order:


We would need parentheses to actually evaluate this expression.

How to Run the Solution

At any rate, I think we’re done here. If we want to try to run the solution, we can plug some of this code into an online Racket interpreter.

Alternatively, we can download the latest version of Racket and get a copy of the solution. Assuming Racket is now in the path, we can just run the following to execute Hello World in Racket:

racket hello-world.rkt

And, that’s it. If successful, the “Hello, World!” string should print to the console.

Further Reading