BLOG
BLOG
  • Design
  • Data
  • Discernment

We believe in AI and every day we innovate to make it better than yesterday. We believe in helping others to benefit from the wonders of AI and also in extending a hand to guide them to step their journey to adapt with future.

Know more

Our solutions in action for customers

DOWNLOAD

Featured Post

MENU

  • Visit Accubits Website.
  • Artificial Intelligence
  • Blockchain
  • Cloud Computing
  • Entertainment
  • Fintech

Getting started with Julia language – Part 1

  • by Adarsh M S on Mon Sep 7

In the this article, we’ll discuss how to get started with Julia programming language. 

Whenever a new programming language makes an appearance, we have to ask ourselves whether learning it is worth it or not. This is what happened when Julia programming language was first released. However, over the years, Julia proved itself to be faster and more powerful than many other languages out there.

I’ve conducted a benchmarking and performance analysis of Julia against Python. The results were pretty amazing. If you’re interested to see the benchmarking results, check out this article I recently published : Julia vs Python: Choosing the best with benchmarking & performance analysis

Today, Julia is one of the top 50 languages in the Tiobe index. In order to help you learn more about Julia, I’m going to publish a series of articles that deal with everything you need to know about it. This article will help you understand what sets Julia apart from other languages. We will also cover the environment setup on Ubuntu 20.04.

What is Julia?

Julia is a free, open-source programming language which can be used to write any kind of application. It is very easy to use, which makes it well suited for those with low technical expertise. The language allows anyone to easily create and share programs that others will be able to use for free and improve upon.

Julia uses multiple dispatch as a paradigm, making it easy to express many object-oriented and functional programming patterns. It provides asynchronous I/O, debugging, logging, profiling, a package manager, and more. Julia also uses the JIT (Just in Time) — compiler which generates native machine code. The JIT compiler provides stability via multiple dispatches, which makes it easy to compile the code into an efficient one.

Julia supports multiple tools, editors (Vim, Emacs, etc) as well as IDEs (Juno, Microsoft Visual Studio, etc). While it is a general-purpose language and can be used to write any application, many of its features are well-suited for numerical analysis and computational science.

Julia was also inducted into the “petaflop club” which was achieved by a Julia application called Celeste. The Celeste team achieved peak performance of 1.54 petaflops using 1.3 million threads on 9,300 Knights Landing (KNL) nodes of the Cori supercomputer at NERSC.

Work on Julia was started in 2009 by MIT researchers Jeff Bezanson, Stefan Karpinski, Viral B. Shah, and Alan Edelman. Julia was envisioned as an open-source (i.e., free) computing language that was both fast and worked at a high level. In 2012, the computer language made its debut to the public and has since climbed up the ranks as one of the world’s most popular programming languages, to the point that many programmers now see it as a potential rival to Python, a stalwart language

Why Julia language?

The idea of Julia was born when its creators realized that even though computationally expensive tasks like scientific and numerical computing required high performance, domain experts usually went with slower, more dynamic languages for daily programming. Julia’s creators wanted to leverage modern language design and compiler techniques for a single environment that’s powerful enough for prototyping but also has the efficiency for performance-intensive applications.

Some of the key points that make Julia stand out from other programming languages include-

  • Julia has multiple dispatch. One of the most powerful aspects of Julia is its multiple dispatch paradigm which proved to be one of the most polymorphic, extensible, and composable type systems out there.
  • Julia is compiled, not interpreted. For faster runtime performance, Julia is just-in-time (JIT) compiled using the LLVM compiler framework. At its best, Julia can approach or match the speed of C.
  • Julia is interactive. Julia includes a REPL (read-eval-print loop), or interactive command line, similar to what Python offers. Quick one-off scripts and commands can be punched right in.
  • Julia has a straightforward syntax. Julia’s syntax is similar to Python’s — terse, but also expressive and powerful.
  • Julia combines the benefits of dynamic typing and static typing.
  • Julia has foreign function interfaces. Julia can interface directly with external libraries written in C/Fortran, C++, Python, R, Java, and many other languages.
  • Julia supports metaprogramming. Julia programs can generate other Julia programs, and even modify their own code, in a way that is reminiscent of languages like Lisp.

Limitations of Julia language

Although Julia is a very powerful programming language, it does have a few limitations that include-

  • Compiler latency: Compiler latency has been one of the high priority issues in Julia. It is a lot slower when compared to other languages like Python(~27x slower) or C( ~187x slower).
  • Static compilation support: Of Course, Julia can be compiled. Unlike the language C which is compiled before execution, Julia is compiled at runtime. Thus Julia provides poor support for static compilation.
  • Array optimizations: To get good performance, Julia users have to use manually in-place operations to get high performance array code.
  • Incomplete notations: Many codes in Julia have incomplete notations. For eg. N-d array.

Julia environment setup

Now that we have a more thorough understanding about Julia, it is time to dive into the installation of the language on your OS. The following sections will teach you how to install Julia on Ubuntu (version 20.04). 

Installing Julia binary

Julia offers portable binary distributions for windows, MacOS, Linux and Free BSD. You can download the binary distribution for your OS from here. Julia offers at most four active branches, namely master, unstable, stable, and LTS.

Apart from binaries, Julia also provides docker images and JuliaPro (by Julia Computing), which includes Julia and the Juno IDE, along with access to a curated set of packages for plotting, optimization, machine learning, databases and much more. You have to follow a registration process to download JuliaPro.

I would suggest you download binaries from either the stable or LTS (If you don’t want to update often) branch or go for JuliaPro. Note: For installation on non-linux distributions, follow this link: click here/

  • Step 1: Download your binary of choice (LTS binary is used here)
wget https://julialang-s3.julialang.org/bin/linux/x64/1.0/julia-1.0.5-linux-x86_64.tar.gz
  • Step 2: Extract the tarball to a preferred location
tar -C /path/to/juliadir -xvzf julia-1.0.5-linux-x86_64.tar.gz
  • Step 3: Now add Julia to your system path. Let’s do that by adding Julia bin path to the end of your ~/.bashrc or ~/.bash_profile.
nano ~/.bashrc
export PATH=”$PATH:/path/to/juliadir/bin”
  • Step 4: For the changes to take effect let’s source the file.
source ~/.bashrc

All done. Now let’s see if you can invoke Julia’s REP. Type the following in your terminal- 

julia

If all the steps were followed correctly, you should now see a screen similar to below:

getting started with julia language

Setting up IDE for Julia (optional)

Note: You can skip this part if you’ve installed JuliaPro, since it includes Juno IDE (an IDE based on Atom).

Julia supports various editors like VSCode, Atom, Emacs, Sublime, Vim, Notepad++ and IDEs like IntelliJ.

Atom

If Atom is not installed in your system, follow the instructions given at https://atom.io/

Head over to the package installation settings and search for uber-juno and click the install button. Once installed, try opening the REPL with Juno > Open REPL or Ctrl-J Ctrl-O (Cmd-J Cmd-O on macOS), and then press Enter in the REPL to start a Julia session.

VSCode

If VSCode is not installed in your system, follow the instructions given at https://code.visualstudio.com/

Inside VS Code, go to the extensions view either by executing the View: Show Extensions command (click View->Command Palette…) or by clicking on the extension icon on the left side of the VS Code window.

In the extensions view, simply search for the term julia in the marketplace search box, then select the Julia extension and click the install button.

You might have to restart VS Code after this step.

If the extension does not find your Julia installation automatically, or if you want to use a different Julia installation than the default one, you can set the julia.executablePath to the full path of Julia executable that the extension should use. In that case the extension will always use that version of Julia. To do this, follow the below steps:

  • execute the Preferences: Open User Settings command (you can also access it via the menu File->Preferences->Settings),
  • And then make sure your user settings include the julia.executablePath setting and update the full path to your Julia executable.

Note: If steps for an IDE of your choice is not listed here, follow the above specified official links corresponding to your IDE.

That’s it. We’ve covered how to install Julia. In the next article, we’ll discuss familiarize with Julia’s REPL, packages and basic I/O. 

Related Articles

  • Generative AI in Banking and Financial Services
    By
    Sathesh Sriskandarajah
  • Transforming Predictive Policing: The Power of Language Models in Crime Prevention
    By
    Abhimanue
  • The Disruptive Impact of AI and Blockchain on BFSI
    By
    Nick
  • What is LLMOps? Large Language Models’ Ops, Architecture & Recommended tools
    By
    Aharsh

ASK AUTHOR

Adarsh M S

Technology enthusiast with an urge to explore into vast areas of advancing technologies. Experienced in domains like Computer Vision, ... Read more

Ask A Question
Error
Cancel
Send

Categories

View articles by categories

  • General

Subscribe now to get our latest posts

  • facebook
  • linkedin
  • twitter
  • youtube
All Rights Reserved. Accubits Technologies Inc