Why you should learn Julia, as a beginner / first-time programmer

Logan Kilpatrick
Dev Genius
Published in
8 min readDec 10, 2021

--

Photo by Dayne Topkin on Unsplash

Much has been written in the last few years about the Julia Programming Language and who can benefit from it. One of the common misconceptions I hope to dispel in this post is that “Julia is not a good language to learn programming with”. Here are a few ideas that I will go into more detail on, to convince you that Julia is an ideal language for those early in their programming journey:

  • Intuitive Syntax 😌
  • Julia REPL 📖 🖨
  • Package Ecosystem 📦
  • Learning Resources 🎓
  • Job Opportunities 🧑‍💻

If you aren’t familiar with Julia, it is a high-level and dynamic language built for technical computing. It has simple syntax like Python but runs as fast as C / C++.

Intuitive Syntax

When I first started programming, I used C++ which was quite difficult to get a handle on. In today’s day and age, I would guess that most people are starting their journey with Python. Let’s look at some basic syntax and see Julia in action. Really quickly, before we dive in, you will want to download Julia:

Now that you have Julia up and running, we can start with some basic examples:

julia> print("Hello world")Hello worldjulia> 10+10 # basic math20

Okay, that seems simple enough. What about defining a function? For those who might not be familiar, functions are just blocks of code that are chained together:

julia> function myFunc()           print("This is what a function looks like")       endjulia> myFunc() # here we call the function we defined aboveThis is what a function looks like # and here we see the output 

To define a function in Julia, we use the function keyword. As you will notice above, we do not use {} nor an : on the function definition line (which is what you do in Python). Julia does enforce the paradigm of using the end keyword, which I find very helpful when writing deeply nested code (stay tuned for an example).

1-based indexing 🥇

People often remark that they are surprised Julia has 1 based indexing given how prevalent zero-based indexing is. Here’s a quick example:

julia> numbers = [10, 22, 7, 94]4-element Vector{Int64}:1022794
julia> numbers[1]10julia> numbers[4]94

Simply put, when you reference an item in an iterable (array, list, etc), you start counting from 1. If you are new to programming, you might be thinking:

“Well of course I would start counting at 1, that is how I have been counting my whole life”.

To me, this is the most compelling reason for 1-based indexing. Having a first-time computer science student show up on day 3 and telling them that in certain contexts you have to start counting at zero instead of 1 does not make sense to me. I know this is a rather touchy topic for those with a deep passion for zero-based indexing, so we can move on to another syntax.

Conditionals and Loops 🔂

If you have seen other programming languages before, Julia does not have any wacky syntax for conditionals:

Image by Author

In the above image, you can get a basic idea of what an if statments looks like to use end keywords in nested code. I like the end keyword so much that why I write python code, I tend to add comments with # end in the places where they should be to make it visually easier to depict the end of code blocks.

Let’s check out a basic example of a for loop:

julia> words = ["Julia", "is", "a", "great", "language"]5-element Vector{String}:"Julia""is""a""great""language"
julia> for word in words
print(" ", word) # each iteration of the loop, it prints one more work endJulia is a great language # output

You now have a basic idea of some of the common syntax you will see when using Julia. We will look at more examples later on in this post. If you want to see some more basic examples, check out the video below:

The Julia REPL (Read Evaluate Print Loop) 🖨

In all of the examples above, we have been running code in the REPL. The Julia REPL is very powerful and can be helpful for quick prototyping and testing code.

Image by Author

The other way you would run Julia code is by creating a .jl file and running it by typing Julia some/path/to/the/file.jl or using an IDE like VS Code. Before we move on, I want to give a few quick hints about the Julia REPL and its usage.

Shell Mode 🐚

You can run terminal commands right in the Julia REPL by typing ;. It will open up shell mode which allows you to do things like:

shell> pwd/Users/logankilpatrickshell>

Pkg Mode 📦

Package mode allows you to manage the packages in your active environment. If you want to add some package, it is as simple as typing ] to enter pkg mode and then :

(@v1.7) pkg> add Plots

where plots is the name of the package you want to add. We will go into more about the package manager later on!

Help Mode 🆘

This is a helpful feature that can save you a lot of time trying to find the right functions to use. If you type a ? into the REPL you will get the help prompt. You can just press enter/return without typing anything for a quick look into the functionality.

help?> sinsearch: sin sinh sind sinc sinpi sincos sincosd sincospi asin using isinf asinhsin(x)Compute sine of x, where x is in radians.See also [sind], [sinpi], [sincos], [cis].(full output omitted for space reasons)

Here we can see the docstring (documentation) for the sin function without leaving the REPL.

The Package Ecosystem 📦

There are two main points I want to make concerning Julia packages. First, the actual mechanics of managing and working with packages is so simple. Second, there is a high fidelity of packages already in existence (with more being registered every day) that cover most needs.

In the previous section, we showed how to add a package. Let me highlight some other package manager tips. Remember, you can enter the package manager via the REPL by typing ] :

(@v1.7) pkg> stStatus `~/.julia/environments/v1.7/Project.toml`[587475ba] Flux v0.12.8[add582a8] MLJ v0.16.11(@v1.7) pkg> statusStatus `~/.julia/environments/v1.7/Project.toml`[587475ba] Flux v0.12.8[add582a8] MLJ v0.16.11

The status or st (shorthand) the command will allow you to see all packages installed in your current environment. I currently have two, MLJ and Flux. You can also see each package's version which tends to be very helpful. If I wanted to remove a package, I can do:

(@v1.7) pkg> remove MLJUpdating `~/.julia/environments/v1.7/Project.toml`[add582a8] - MLJ v0.16.11

The remove the command also has a shorthand, rm . If you type st again, you will see the package is gone. These are the main commands you will use in day-to-day development. After you install a package, to use it, you do:

julia> using Flux

where Flux is the name of the package I want to load in. For more details on working with packages, check out the below video:

Learning Resources 🎓 📑

There are so many different ways to learn Julia. You could read a book, watch videos, do practice problems, and more! We have compiled a pretty exhaustive list at: https://julialang.org/learning/

One of my favorite resources is Julia Academy:

If you have never programmed before, we have got you covered. The “Julia for Nervous Beginners” course is an excellent intro to computing with Julia:

If you want to learn with the support of expert Julia mentors for free, check out:

If you want to pick up Julia by reading a book, my personal favorite is:

All of this is to say there are a lot of Julia resources out there. Especially for beginners, you will find plenty of different learning pathways regardless of how you learn best!

Job Opportunities 🧑‍💻

Generally, everyone wants / needs a job. Programming in general is one of the coolest jobs to have. It is practically magic! But what makes learning Julia such an important skill to have?

Image by Author

The image above shows some quotes from recruiters on what they expect new grads to bring into the workforce when they get hired. The reality is that companies want new knowledge and a fresh perspective. I can’t think of a more compelling language to learn in that capacity. There are also lots of cool companies building their business around Julia:

These are just a few examples of the companies using and hiring Julia developers. There is also a constant stream of inquiries in the #jobs channel on the Julia Slack.

Closing thoughts 💭

There really has never been a better time to learn Julia and join the community. There are so many cool things happening and lots of amazing resources being created. One thing that I have not mentioned so far but is always worth mentioning is the Julia community itself. In my experience, they are extremely welcoming and helpful for those joining the language ecosystem. Please drop by Slack or Discourse if you run into any issues on your journey.

Thanks for reading! Feel free to ping me on Twitter if you have any questions/feedback: https://twitter.com/OfficialLoganK

--

--