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 page, 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 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.
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 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!
Recent Posts
It's a special day when I cover a Java topic. In this one, we're talking about Enums, and the problem(s) they are intended to solve.
Chances are, if you're reading this article, you've written some Python code and you're wondering how to automate the testing process. Lucky for you, this article covers the concept of unit testing...