Hello World in Wren

Hello World in Wren Featured Image

Welcome back to yet another edition of the Hello World in Every Language series. Today, we’re starting a trend of looking at newer open-source languages. Up first, we’re going to implement Hello World in Wren, a scripting language project launched in 2014.

Table of Contents

Wren Background

Last time we covered a relatively a relatively new language called Elm, but it still managed to have a Wikipedia page. Our language today, Wren, does not. As a result, I had to do a bit of digging to learn about this language.

According to the GitHub pageOpens in a new tab., Wren is a new scripting language. Of course, there are plenty of those including Python, Lua, and JavaScript. So, what makes Wren different?

Well, according to the websiteOpens in a new tab., Wren was created as an object-oriented game scripting language. Apparently, Lua is the go-to for game scripting currently, but it’s class system is pretty unnatural. Thus, Wren was born!

In addition to filling the object-oriented game scripting niche, Wren has some pretty sweet support for concurrency through a feature called fibers. Fibers are lightweight threads which eliminate random context switching. In other words, fibers generally only switch when they are told to—much like coroutines.

Finally, Wren is incredibly fast for a scripting language. In fact, the website shares some benchmarks which demonstrate it outperforming Python, Lua, and JavaScript. Game developers should be pretty happy about this.

Hello World in Wren

At any rate, let’s get right to our implementation of Hello World in Wren:

System.print("Hello, World!")

And, that’s it! Personally, I’m getting hints of Java and Python here just in terms of syntax.

At any rate, let’s break it down. Obviously, we only have one line, but it’s at least a little more interesting than most scripting languages.

For starters, we have the built-in System classOpens in a new tab.. This class comes with the core module along with a few other goodies like String, Sequence, Fiber, and Bool.

Now, one of the functions of System is print. Obviously, print writes text to standard output. But, I find Wren’s print functionality particularly interesting because it’s similar to Java. In fact, it accepts any object as input. If the input is not a String, print will convert it to a String using the toString functionality, a method available to all objects.

So, basically we call the static method print of the System class which prints the input to the user. How cool is that?

How to Run the Solution

Normally, at this point, I would share an example of how to run the solution on your machine. Unfortunately, Wren is rather new and a little clunky to get running. That said, I won’t leave you hanging, There are some directions for Mac and Linux usersOpens in a new tab. on the Wren website.

Alternatively, you can use the online Wren editorOpens in a new tab.. Just copy the code from above into the editor and hit run.

Sample Programs in Every Language

Well, that’s all I have for Hello World in Wren. Let me know if I did a nice job covering the language and providing a solution.

As always, feel free to give the article a share. If there are any languages you want to see in the future, let me know in the comments. Thanks!

Sample Programs in Every Language (44 Articles)—Series Navigation

For 100 Days of Code, I’ve decided to implement a few sample programs in as many languages as possible. Each implementation details a brief history of the language and a description of the code.

The plan for the series is to explore the major general-purpose language like Java, Python, C, C++, and C#. From there, we’ll take a look at some sample programs in web development languages like Ruby, PHP, and JavaScript. As we continue, we’ll cover proprietary languages like Swift and Objective-C. Eventually, we’ll start to tackle less popular languages like Rust, x86, and Verilog. Finally, we’ll play around with some of the esoteric languages like Brainf*ck and LOLCODE.

Who knows? Maybe the Sample Programs in Every Language series will become so popular it’ll never end. To help this series grow, consider sharing it on social media with your friends. Or, if you have a language you want to see, drop your suggestion in the comments.

Jeremy Grifski

Jeremy grew up in a small town where he enjoyed playing soccer and video games, practicing taekwondo, and trading Pokémon cards. Once out of the nest, he pursued a Bachelors in Computer Engineering with a minor in Game Design. After college, he spent about two years writing software for a major engineering company. Then, he earned a master's in Computer Science and Engineering. Today, he pursues a PhD in Engineering Education in order to ultimately land a teaching gig. In his spare time, Jeremy enjoys spending time with his wife and kid, playing Overwatch 2, Lethal Company, and Baldur's Gate 3, reading manga, watching Penguins hockey, and traveling the world.

Recent Posts