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
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.
Well, according to the website, 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.
Hello World in Wren
At any rate, let’s get right to our implementation of Hello World in Wren:
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 class. 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 users on the Wren website.
Alternatively, you can use the online Wren editor. 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!
The ACT/SAT discourse is back, and I found a pretty cool article debunking many of the common arguments for them.
The Sample Programs repository is in its fourth Hacktoberfest. Are you interested in making a contribution?