Julia for n00bs | Tutorial 01x01 | Hello, World!
Sep 15, 2020 14:00 · 3408 words · 16 minute read
Hello, friend. internet dial-up sound Welcome to julia for talented amateurs where i give tutorials about the julia programming language for hobbyists and enthusiasts. I am your host the dabbling doggo. “I dabble.” This series contains 13 tutorials divided into three parts. Part 1 will cover the basics of coding with julia. You’ll learn how to download julia onto your local machine, set up a programming environment, and start coding. Part 1 will focus on practical coding and not so much on theory.
00:35 - Part 2 will cover some intermediate concepts of computer science. We’ll also take a look under the hood of julia to see how it works and what makes it special. Part 3 is a final project to wrap everything up. New tutorials will be posted on Tuesdays. These tutorials are for beginners who have no programming background. I am assuming that julia is your very first programming language so there are no knowledge prerequisites. However, you will need access to a computer with an internet connection… and by computer i mean a laptop or a desktop running Windows, macOS, or Linux. Sorry, no smartphones or tablets. If you are an experienced programmer, you are certainly welcome, but I suspect that my tutorials may be too slow for you. julia is a relatively new computer programming language. It’s been under development for about 10 years but version 1.
0 was only released in 2018, so for the 01:28 - general public, it’s only been around for the past couple of years. The early adopters of julia are members of the scientific and academic communities. “Nerd!” Fans of the language proclaim that it’s the language of the future since julia is easy to learn and is designed to be both flexible and fast. Critics of the language appear to be more skeptical. Since the language is still relatively young, it’s difficult to predict whether julia will become a mainstream language or will remain a smaller language geared to those in data intensive fields. I am not a computer scientist. I am not a data scientist. I am not a mathematician.
I do not have a 02:06 - PhD and i am not affiliated with Julia Computing. I am a self-taught hobbyist who has always wanted to learn a computer programming language, but didn’t know where to begin. julia is my very first programming language. I first heard about julia in 2018 when version 1.0 was released. When I heard about it, I put it on my bucket list and resolved to learn it in 2019. Well, 2019 came and went and I never looked at it. I put it on my new year’s resolution list for 2020 and, like the rest of the world, I found myself stuck at home earlier this year. I took advantage of that time to teach myself julia by watching YouTube videos and by reading documents online. I learned julia for free without paying any money for textbooks or by signing up for any paid online courses. Unfortunately, most of the free resources online assume that you already know how to program in a different language, so the claim that julia is easy to learn really should come with a caveat stating that julia is easy to learn…
once 03:04 - you’ve already learned another language. As a way of saying “Thank you” to everyone who, so generously made their knowledge available for free on the internet, I decided to start this YouTube channel to help people like me who are new to programming and are looking to learn julia, but don’t know where to begin. It took me about six months to learn julia, but i don’t think that had anything to do with julia itself. I suspect it would have taken me about that long with any language since I was starting from scratch and had to dig around for free resources. The good news is, if i can learn it, so can you.
03:35 - “You can do it!” My tutorial series is primarily based on the 2016 MIT class called Intro to Computer Science and Programming taught by Dr. Ana Bell and Dr. Eric Grimson and uploaded onto the MIT OpenCourseWare YouTube channel. Their lectures are taught using python, which is a different computer programming language, but the concepts they share have provided me with a background to computer science and computational thinking that I lacked. My second primary source is the 2018 Intro to Julia tutorial presented by Dr. Jane Herriman and uploaded to The Julia Programming Language YouTube channel. Dr.
Herriman’s video is must-see-TV, which serves as a gateway to julia for many 04:16 - new users. Her video was my first julia video. If you are an experienced programmer, I suggest that you watch Dr. Herriman’s video first, as it may be all you need to get started with julia. However, for those of you who do not have a programming background, stick to my tutorials since i will be covering everything that a beginner needs. Links to both lecture series are provided in the description below. Alright, enough talk. Let’s do some work.
We’re going to install julia 04:44 - and then we’re going to install a text editor that we will use as our programming environment to access julia for the rest of the tutorials. So first we’re going to install julia. So open up your browser. Do a Google search for julia, and, for me, it’s the first one that comes up. So go to julialang.org Go ahead and bookmark this page and then, go to the documentation tab and then, go ahead and bookmark that as well. We’ll be referring to this later. And then, go back to the home page and that green button, where it says download Version 1.5.1, hit that. Then scroll down until you see your operating system.
05:44 - I’m going to be using Windows, the 64-bit installer. If you want to know what the difference is between an installer and the portable version, the portable one is if you’re gonna be putting it onto a USB stick, which I don’t have any experience with so I can’t speak to that but I’m going to be using the 64-bit installer, which will load it onto my local machine. So hit that and then it’ll just take a few seconds to download. And then, once it downloads, you can hit to execute. And then, you should see a window pop up and be sure you note this…the location of where it’s being saved to.
06:35 - You’re going to need that information later. I’m going to copy that. Hit next, and that’s fine, hit next. That should only take a few seconds, depending on your system. And then, we’re just going to hit Finish. So you should see an icon that showed up for julia which is a shortcut for what they call the REPL. So if you double-click on that you see a screen that comes up, and on my screen it’s really small, so i’m going to make this a bit bigger. If you go to the top bar and do a right-click, you can find the Properties where you can make adjustments.
07:41 - I’m going to select the large cursor size and I’m going to hit a larger font so I can see it, but you pick whatever you’re comfortable with. Those are my settings. And then, type in, where i see where you see the cursor, type in println, open and close parentheses, and then hit two quotation marks in between there and type in Hello comma World! and hit Enter. You should see a Hello, World! print out. And then, the next line hit 1 plus 1. Hit Enter and you see the number 2 print out. So just a quick comment about this environment that we’re in… So this is called a REPL, which I don’t know if you’ve ever heard that expression, but it stands for Read, Eval, Print, Loop.
08:38 - So I personally think it has a kind of a cool retro look to it. You may not think so, but I… I personally like it. It tells you a couple helpful information. It says what version of julia you’re running, which in our case is Version 1.5.1. It also tells you a couple of helpful websites, which you should have already bookmarked. So for the documentation, it tells you where you can find the documentation. It also tells you where the official website is for julia: julialang.org It also provides some helpful inline resource, so if you type in a question mark where the prompt is, a Help Screen will come out and you can type in, like, “println”, if you want to know what you just did. It just prints out some useful information for you right there so you don’t have to go to the documentation. One more thing I’ll point out. If you hit the close bracket, you’ll see a Package Prompt come up which is for the Package Manager. I’m going to cover that later in this course so you don’t need to worry about it. For now, just backspace to get out of it. That’s about it.
So, what’s the deal with Hello World? 10:04 - Hello World is generally the first line of code that everyone learns regardless of the language. There’s also something known as Time to Hello World, which is an indication of how easy or how hard a programming language may maybe to learn. In julia, it’s pretty simple, right? It only took us a few minutes to download julia and type in “Hello, World!”, so that should be a good sign. So why don’t we get out of the REPL. All you have to do is type in exit and do an open and close parentheses. Don’t forget the parentheses. Hit Enter and then the REPL should disappear from your screen and that’s it! So now, you have julia downloaded onto your machine and you have a REPL installed.
So now 10:49 - you’re ready to move on to the next step. The next thing we’re going to do is install atom. atom is a free and open-source text editor developed by GitHub that can be used for multiple programming languages, not just julia. First we’ll install atom and then we’ll install the julia extension called juno. Open up your browser again and do a Google search for atom. a-t-o-m. For me, it’s the first one that comes up is atom.io. Go ahead and click on that and the atom website should auto-detect your system. So for me, it’s detecting a Windows 64-bit. So go ahead and download that and you should see a download here in the corner. elevator music Okay, so once that’s done downloading, go ahead and execute that. elevator music Once it’s done executing, it should bring up this welcome screen.
11:54 - We’re not quite ready to use this yet, so don’t touch anything. We actually have to load juno first. Go ahead and open up your browser again. Go back to Google and type in atom, a-t-o-m, uber, u-b-e-r, dash juno and go ahead, select uber-juno for atom. This is the official installer for juno. And then, go ahead and click that green install button. Click “Open Atom”. On the right-hand side of atom now you should see something called uber-juno. Go ahead and click that blue install button. elevator music When you see this message come up where it says, “Open juno specific panes on startup?”, click “Yes”. We are almost ready…bear with me for a few more minutes.
13:06 - Once that’s done, you want to go to the Settings tab, you’ll see a bunch of tabs open, go to the one mark Settings. You actually have to go back to Packages and then look for the “julia-client”. Click Settings for that and then here under Settings there’s this black box where it says julia path. This is where you need to load in the path that julia used to install the files onto your local machine. So for me, this is the one I copied as I was installing, but what atom’s looking for is not just this.
It’s actually looking for the 13:56 - actual julia executable file. So for me julia installed another folder called bin and then the actual file is julia.exe file is in that folder. So if you’re using a Windows machine, it should be exactly the same you just need to enter bin backslash julia dot exe. I don’t have Mac so I can’t confirm what it’s like, but it should be something similar. But this is the part that’s important. atom is looking for the actual location of the julia executable file on your local machine. So once that’s done, just click outside the box.
14:37 - And then the rest, we’re just going to clean up the user interface a little bit. So all these open…open folders, we don’t need anymore. So this Telemetry Consent, click “No”. This Welcome, uncheck this Welcome Box and “X” out of that. Close that. The juno release notes, you can close that out. This Welcome Guide, you can “X” out of that. Now a few more things to point out… Under the Settings tab, there’s something called Themes. You can click on Themes and this is where you can customize it for your needs. If you don’t like this dark theme you can pick one the lighter themes. So you see what that looks like…I’m just gonna stick with the default settings, which is the One Dark, but that’s where you can change the settings to suit your personal preferences. And then go to Core and then scroll down until you see something called “Open Empty Editor on Start”. Uncheck that box. And then, go to the Settings for Packages and then go back to the julia-client where we are just at…
Click on the Settings there and scroll 16:06 - down until you see UI Options, and scroll down until you get to the Layout Options. And where it says “REPL”, select “Center”, “No Split”. That’s fine. And then “Workspace”, click “Right”, “No Split”. Same thing with “Documentation Browser”. Click “Right” and “No Split”. “Plot Pane”, same thing, click “Right”, “No Split”. All these settings are saved automatically. There’s no save button. And then go back to Packages and then scroll all the way down until you see GitHub, g-i-t-h-u-b…this GitHub. And then, hit “Disable.” And that’s it for now.
Once you’ve done all that you can “X” out 17:16 - of atom to close it down. We’re just going to relaunch it to see how our settings changed everything. You should have an icon, a shortcut, on your desktop for atom, so double-click on that. And what you should have is something that looks similar to this, where the REPL is on the left-hand side of the screen and you have a…more panels on the right-hand side of the screen for your Workspace, your Documentation, your Plot Pane…
which we’ll get into later, but for now, click anywhere in the 17:52 - REPL and hit Enter and it should load up a bunch of files, so this should just take a few minutes… elevator music Okay, so now what you should see is something that looks like the REPL that we originally saw when you downloaded julia for the first time. The font on my screen is really small so I’m going to show you how to adjust the size of this font type in repeat, r-e-p-e-a-t, open parenthesis, open quotes, type the letter x, close quote, comma, space, 90, close parenthesis and hit Enter. And what that did was just…it just printed the letter “x” 90 times. So if you go under View and say Increase Font it should just increase the size of everything. If everything disappears just click on the REPL and it should reappear.
So, View, 19:00 - Increased Font, click on the REPL. View, Increase Font, click on the REPL. I know that’s kind of tedious, but you can repeat this process until it’s a font size that is comfortable for you on your monitor. So this I might have to do a few times because I want it a little bigger so you can see it in the tutorials. hold music Okay, so that looks about right for my monitor. Hopefully you can see it in the tutorials.
Now we’re just going to test to see if 19:36 - everything is working. So like we did in the REPL, type in println(), quotes, Hello, comma, World! and then you should see “Hello, World!” pop-up if everything is working right. Type in 1 plus 1 and then 2 should show up. Hit the question mark, and then your Help Screen should show up. And type in “println” and hit Enter and then the Help Screen comes up. It just describes what the println function does.
20:12 - And the other things to mention, that I didn’t mention in the REPL is, if you hit the Up Arrow, it brings up the last entry that you had, so if you keep pressing the Up Arrow, it’ll just keep showing you the last thing you typed in. If you hit the Down Arrow it takes you to the next one so that’s kind of convenient. You can scroll up and down from your last entries. And the other thing i want to show you is on the right-hand side. I’m going to skip this Workspace for now. Under Documentation, Under the Search Bar, you can type in “println”.
20:48 - Hit Enter and it’s going to show every single command that’s in julia that has the word println or related to it, so it’s a little more information than what’s showing up in the inline help. So that’s a useful resource. And then go back to the REPL. You click anywhere in the REPL to get to your cursor, then hit exit, open and close parentheses. Hit Enter, and you’ll notice that it doesn’t shut down everything like the REPL did when we did it the first time. What it does is, it just opens up a new session of julia. So to get out of atom, all you need to do is hit the “X” to X out of it.
21:33 - And that’s it! Just a note about atom. atom was developed by GitHub, but back in 2018, Microsoft acquired GitHub and work on atom seems to have stopped, so new users are now encouraged to use a Microsoft product called VS Code. juno was developed by members of the julia community as an extension for atom and now that work on atom has stopped work on juno has stopped as well. Users of juno are now being encouraged to migrate to the julia extension for VS Code. So why am i teaching this tutorial using atom and juno and not VS Code and julia? I’ve tried VS Code and the julia extension and I personally do not like it.
Despite the developers’ claims, my 22:17 - personal opinion is that atom and juno is still a better tool to learn julia. I think VS Code and julia may be fine for experienced programmers, but atom and juno offers more tools for beginners, so I’m going to continue teaching with atom and juno. That’s it for today! If you got this far, congratulations on successfully installing julia, atom and juno! “I’m proud of you son.” Today, I shared the course overview and and we installed julia, atom and juno. Next week, I will lay out the foundations of computer science and then I’ll get into the basics of using julia.
If you enjoyed this video, please give it a thumbs up. For more wholesome julia tutorials, please be sure to Subscribe and hit that Bell. If you have any questions please post them in the comments below or send me an email at julia4ta at gmail dot com. I will be uploading a video every Sunday to answer any questions that may come up. Feel free to spread the word by sharing this video, since I’m sure you’ll all agree that this is the finest tutorial on all of YouTube. “Worst. Tutorial. Ever.” .