This is the second article in the ‘Getting started with Julia language’ series. In the previous article, we discussed the strengths and limitations of Julia. We also covered the environment setup of Julia on Ubuntu 20.04. Now that you have a basic idea about the language and how to set it up, it’s time to dive into Julia programming language – REPL, packages and basic I/O.
Julia comes with a full-featured REPL (read-eval-print loop) interactive command line built into Julia’s executable. Not only does it allow Julia statements to be evaluated quickly and easily, but it also has a searchable history, tab completion, many helpful keyboard shortcuts, and special help and shell modes. The REPL can be started by simply calling julia from your command line.
Benchmarking and performance analysis of Julia Vs Python
To exit the session, just type exit() and hit enter or use keyboard shortcut ctrl + D.
The REPL has 4 main modes of operation:
Julia offers a built-in package manager known as Pkg which handles operations like installing, updating, removing packages. Pkg can be accessed from REPL by typing ] in a newline.
To exit the package manager, use the keyboard shortcut Ctrl + C.
Use the add keyword to install the required packages.
(v1.0) pkg> add JSON StaticArrays
This installs packages JSON and StaticArrays
Use the update keyword to update desired packages
(v1.0) pkg> update JSON
If you want to update all packages, then simply use the update keyword without any package names.
(v1.0) pkg> update
Use rm keyword to remove packages
(v1.0) pkg> rm JSON
In Julia, data from the standard input stream(STDIN) can be read using readline or readlines
In Julia, data can be sent to the standard output stream(STDOUT) using either print or println
This is all that you need to know about Julia’s REPL, packages and basic I/O. In the next article, we will look into the variables and types in Julia.