Hello World in Julia

Hello World in Julie Featured Image

As always, welcome back to another edition of Hello World in Every Language. Today, we’re looking to play around with Hello World in Julia, a numerical analysis language which first appeared in 2012.

Table of Contents

Julia Background

Despite being a relatively new language, Julia has a Wikipedia pageOpens in a new tab.. As a result, I won’t have to dig too much to learn about the language.

At any rate, Julia is a computational science language which fills a niche similar to Python and R. In fact, like Python, Julia can be used for general-purpose programming.

One of Julia’s interesting features is multiple dispatch, something that is lacking in Python. Roughly speaking, multiple dispatch allows a user to define multiple functions with the same name but different combinations of arguments.

In addition, Julia is capable of calling C and Python functions directly. Personally, I think that’s a fun little feature considering Julia is compiled at runtime. So, it gets C-like performance as well—perfect for numerical analysis.

Finally, Julia has metaprogramming features, so the language can be modified as needed by the user. If Julia ever takes off, we can probably expect several different dialects of it to emerge.

Hello World in Julia

With the background out of the way, let’s get right into our implementation of Hello World in Julia:

println("Hello, World!")

And unsurprisingly, that’s it! We can implement Hello World in Julia in a single line.

Despite how easy the print functionality seems in Julia, there’s actually a lot going on. First of all, println makes a call to print with an added newline character.

The print function handles any sort of IO, so we could theoretically pass our string to any IO stream. In this case, we leave the default standard output.

Regardless, print makes a call to a function named show. At that point, I’m not sure what happens, but I suspect there’s some C-level call to printf. If you know, let me know in the comments.

How to Run the Solution

With our solution ready, we probably want to run it. Perhaps the easiest thing to do would be to take advantage of Julia’s online editor. Unfortunately, it appears sign up is required to use it, but it’s great for running some code snippets.

Alternatively, we can download the latest version of JuliaOpens in a new tab.. While we’re at it, we should probably get a copy of the Hello World in Julia solutionOpens in a new tab.. With everything read to go, navigate the command line to the folder containing the solution. Then, run the following:

julia hello-world.jl

That should execute the script. Don’t be afraid to leverage the Julia documentation if you get stuck.

Sample Programs in Every Language

Well, thanks again for sticking around. I’m having a lot of fun with these new languages, so I’ll probably keep the trend going for a few days.

If you liked this article, don’t forget to share it. Also, feel free to recommend future languages in the comments. See you next time!

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