0% found this document useful (0 votes)
7 views

julia_introduction

The Julia programming language is designed for high-performance scientific computing, addressing the need for a flexible and efficient environment for both prototyping and deploying applications. Developed by Jeff Bezanson and others starting in 2009, Julia has evolved through multiple versions, with significant features including a dynamic type system, multiple dispatch, and seamless interfacing with other languages. It offers a robust package management system and is well-suited for both statistical analysis and linear algebra, making it a versatile tool for developers.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

julia_introduction

The Julia programming language is designed for high-performance scientific computing, addressing the need for a flexible and efficient environment for both prototyping and deploying applications. Developed by Jeff Bezanson and others starting in 2009, Julia has evolved through multiple versions, with significant features including a dynamic type system, multiple dispatch, and seamless interfacing with other languages. It offers a robust package management system and is well-suited for both statistical analysis and linear algebra, making it a versatile tool for developers.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

Whatis JuliaProgrammingLanguage?

One of the facts about scientific programming is that it requires high performance flexible
dynamic programming language. Unfortunately, to a great extent, the domain experts
have moved to slower dynamic programming languages. There can be many good reasons for
using such dynamic programming languages and, in fact, their use cannot be diminished
as well. On the flip side, what can we expect from modern language design and compiler
techniques? Some of the expectations are as follows:

• It should eradicate the performance trade-off.


• It should provide the domain experts a single environment that is productive
enough for prototyping.
• It should provide the domain experts a single environment that is efficient enough for
deploying performance-intensive applications.

The Julia programming language fulfills these expectations. It is a general purpose high-
performance flexible programming language which can be used to write any application.
It is well-suited for scientific and numerical computing.
HistoryofJulia
Let us see the history of Julia programming language in the following points:
• Jeff Bezanson, Stefan Karpinski, Viral B. Shah, and Alan Edelman has started to work on Julia in
2009.
• The developer’s team of above four has launched a website on 14th February 2012. This website
had a blog post primarily explaining the mission of Julia programming language.
• Later in April 2012, Stefan Karpinski, in an interview with a magazine named InfoWorld,
gave the name “Julia” for their programming language.
• In 2014, the annual academic conference named ‘The JuliaCon’ for Julia; users and developers

has been started and since then it was regularly held every year.
• In August 2014, Julia Version 0.3 was released for use.
• In October 2015, Julia Version 0.4 was released for use.
• In October 2016, Julia Version 0.5 was released for use.
• In June 2017 Julia Version 0.6 was released for use.
• Julia Version 0.7 and Version 1.0 were both released on the same date 8th August 2018. Among
them Julia version 0.7 was particularly useful for testing packages as well as for the users who
wants to upgrade to version 1.0.
• Julia versions 1.0.x are the oldest versions which are still supported.
• In January 2019, Julia Version 1.1 was released for use.
• In August 2019, Julia Version 1.2 was released for use.
• In November 2019, Julia Version 1.3 was released for use.
• In March 2020, Julia Version 1.4 was released for use.
• In August 2020, Julia Version 1.5 was released for use.
FeaturesofJulia
Following are some of the features and capabilities offered by Julia:

• Julia provides us unobtrusive yet a powerful and dynamic type system.


• With the help of multiple dispatch, the user can define function behavior across
many combinations of arguments.
• It has powerful shell that makes Julia able to manage other processes easily.
• The user can cam call C function without any wrappers or any special APIs.
• Julia provides an efficient support for Unicode.
• It also provides its users the Lisp-like macros as well as other metaprogramming
processes.

• It provides lightweight green threading, i.e., coroutines.


• It is well-suited for parallelism and distributed computation.
• The coding done in Julia is fast because there is no need of vectorization of code
for performance.
• It can efficiently interface with other programming languages such as Python, R,
and Java. For example, it can interface with Python using PyCall, with R using
RCall, and with Java using JavaCall.
The Scope of Julia
Jeff Bezanson, Stefan Karpinski, Viral B. Shah, and Alan Edelman, the core designers
and developers of Julia, have made it clear that Julia was explicitly designed to
bridge the following gap in the existing software toolset in the technical computing
discipline:
Prototyping: Prototyping is one such problem in technical computing discipline that
needs a high-level and flexible programming language so that the developer should
not worry about the low-level details of computation and the programming language
itself.
Performance: The actual computation needs maximum performance. The
production version of a programming language should be often written in
“Fortran” or “C” programming language.
Speed: Another important issue in technical domain is the speed. Before Julia,
the programmers need to have mastery on both high-level programming (for writing
code in Matlab, R, or, Python for prototyping) and low-level programming (writing
performance-
Comparisonwithotherlanguages
MATLAB:
• The syntax of Julia is similar to MATLAB, however it is a much general purpose language when compared to
MATLAB.
• Although most of the names of functions in Julia resemble OCTAVE (the open source version of MATLAB),
the computations are extremely different.
• In the field of linear algebra, Julia has equally powerful capabilities as that of MATLAB, but it will not
give its users the same license fee issues.
• In comparison to OCTAVE, Julia is much faster as well. MATLAB.Jl is the package with the help of which
Julia provides an interface to MATLAB.

Python:
• Julia compiles the Python-like code into machine code that gives the programmer same performance as C
programming language.
• If we compare the performance of Julia and Python, Julia is ahead with a factor of 10 to 30 times.
• With the help of PyCall package, we can call Python functions in Julia.

R:
• As we know, in statistical domain, R is one of the best development languages, but with a performance
increase of a factor of 10 to 1,000 times, Julia is as usable as R in statistical domain.
• MATLAB is not a fit for doing statistics and R is not a fit for doing linear algebra, but Julia is perfect for
doing both statistics and linear algebra.
• Julia’s type system with R, the Juia has much richer type system.
InstallingJulia
Let us see how we can install Julia on various platforms:

Linux and FreeBSD installation


The command set given below can be used to download the latest version of Julia
programming language into a directory, let’s say Julia-1.5.1:
wget https://julialang-s3.julialang.org/bin/linux/x64/1.5/julia-1.5.1-linux-
x86_64.tar.gz
tar zxvf julia-1.5.1-linux-x86_64.tar.gz

Once installed, we can do any of the following to run Julia:


• Use Julia’s full path, <Julia directory>/bin/Julia to invoke Julia executable. Here
<Julia directory> refers to the directory where Julia is installed on your computer.

• You can also create a symbolic link to Julia programming language. The link should be inside a folder which
is on your system PATH.

• You can add Julia’s bin folder with full path to system PATH environment variable by editing the
~/.bashrc or ~/.bash_profile file. It can be done by opening the file in any of the editors and adding
the line given below:

export PATH="$PATH:/path/to/<Julia directory>/bin"


Windows installation
Once you downloaded the installer as per your windows specifications, run the installer. It is
recommended to note down the installation directory which looks like
C:\Users\Ga\AppData\Local\Programs\Julia1.5.1.

To invoke Julia programming language by simply typing Julia in cmd, we must add Julia executable
directory to system PATH. You need to follow the following steps according to your windows
specifications:

On Windows 10
• First open Run by using the shortcut Windows key + R.
• Now, type rundll32 sysdm.cpl, EditEnvironmentVariables and press enter.
• We will now find the row with “Path” under “User Variable” or “System Variable”.
• Now click on edit button to get the “Edit environment variable” UI.
• Now, click on “New” and paste in the directory address we have noted while installation
(C:\Users\Ga\AppData\Local\Programs\Julia1.5.1\bin).

• Finally click OK and Julia is ready to be run from command line by typing Julia.
Building Julia from source
To build Julia from source rather than binaries, we need to follow the below given steps.
Here we will be outlining the procedure for Ubuntu OS.

• Download the source code from GitHub at https://github.com/JuliaLang/julia.


• Compile it and you will get the latest version. It will not give us the stable version.
• If you do not have git installed, use the following command to install the same:

sudo apt-get -f install git

Using the following command, clone the Julia sources:

git clone git://github.com/JuliaLang/julia.git


Julia’sworkingenvironment
REPL (read-eval-print loop) is the working environment of Julia. With the help of this shell we can interact with
Julia’s JIT (Just in Time) compiler to test and run our code. We can also copy and paste our code into .jl
extension, for example, first.jl. Another option is to use a text editor or IDE. Let us have a look at REPL below:
Packages
Almost all the standard libraries in Julia are written in Julia itself but the rest of the Julia’s code ecosystem
can be found in Packages which are Git repositories. Some important points about Julia packages are
given below:
• Packages provide reusable functionality that can be easily used by other Julia projects.

• Julia has built-in package manager named pkg.jl for package installation.
• The package manager handles installation, removal, and updates of packages.
• The package manager works only if the packages are in REPL.
Installing packages
Step 1: First open the Julia command line.
Step 2: Now open the Julia package management environment by pressing, ]. You will get the following
console:
Adding a package
For adding a package in Julia environment, we need to use add command with the name of the package. For
example, we will be adding the package named Graphs which is uses for working with graphs in Julia.
Removing a package
For removing a package from Julia, we need to use rm command with the name of the of
the package. For example, we will be removing the package named Graphs as follows:
Julia Programming

To update a Julia package, either you can use update command, which will update all the
Julia packages, or you can use up command along with the name of the package, which
will update specific package.
Testing a package
Use test command to test a Julia package. For example, below we have tested JSON
package:
InstallingIJulia
To install IJulia, use add IJulia command in Julia package environment. We need to make sure that
you have preinstalled Anaconda on your machine. Once it gets installed, open Jupyter notebook and
choose Julia1.5.1 as follows:
Now you will be able to write Julia programs using IJulia as follows:
If you have added Julia to your path, the same script can be saved in a file say hello.jl
and can be run by typing Julia hello.jl at command prompt. Alternatively the same can
also be run from Julia REPL by typing include(“hello.jl”). This command will evaluate all
valid expressions and return the last output.
Variables
What can be the simplest definition of a computer program? The simplest one may be that a computer
program is a series of instructions to be executed on a variety of data.

Here the data can be the name of a person, place, the house number of a person, or even a list of things you
have made. In computer programming, when we need to label such information, we give it a name (say
A) and call it a variable. In this sense, we can say that a variable is a box containing data.

Let us see how we can assign data to a variable. It is quite simple, just type it. For example,

student_name = “Ram”
roll_no = 15
marks_math = 9.5

Here, the first variable i.e. student_name contains a string, the second variable i.e.
roll_no contains a number, and the third variable i.e. marks_math contains a floating-
point number. We see, unlike other programming languages such as C++, Python, etc.,
Comments
Writing comments in Julia is quite same as Python. Based on the usage, comments are of
two types:

Single Line Comments


In Julia, the single line comments start with the symbol of # (hashtag) and it lasts till
the end of that line. Given below is the code snippet showing single line comment:

Example

julia> #This is an example to demonstrate the single lined comments.


julia> #Print the given name

Multi-line Comments
In Julia, the multi-line comment is a piece of text, like single line comment, but it is
enclosed in a delimiter #= on the start of the comment and enclosed in a delimiter =# on
the end of the comment. Example
julia> #= This is an example to demonstrate the multi-line comments that tells
us about tutorialspoint.com. At this website you can browse the best resource
for Online Education.=#

You might also like