Julia Get Started
A script is a Julia program saved in a text file. Running the file makes the computer follow the instructions inside it.
A saved file runs as a program
Save this line in a file named hello.jl. Run it by typing julia hello.jl in the terminal.
println("Saved and running")Statements run in order
This file holds two statements. The top statement runs first.
println("Line one")
println("Line two")A script can print a number
A saved script prints numbers in the same way as text. Each value appears on its own line here.
println(100)
println(200)Example
println("Starting")
println("Working")
println("Finished")Key points
- Script: a Julia program saved in a text file.
- Terminal: a window where you type commands for the computer.
- Extension: a Julia script name ends in .jl, such as hello.jl.
- Run command: typing julia and the file name in the terminal runs the script.
- Statement: one instruction in a program.
- Order: statements in a script run from top to bottom.
In this example, the script holds three statements in a file. The first statement prints Starting. The second prints Working, and the third prints Finished, in the same order as the file.
Try it Yourself
Edit the code, then press Run.
Running is simulated · JuliaHub
Exercise
How do you run a script saved in a file named hello.jl?