Professional Documents
Culture Documents
on
Scientific Computation with Julia
In partial fulfillment of requirements for the degree of
Bachelor of Technology
In
Computer Science and Engineering
SUBMITTED BY:
Lokesh Sharma
14522
First and foremost I would like to thank Ms. Garima Sharma and our institute for
providing me the platform and means to conduct research on this topic. While preparing this
topic the insightful articles by developers especially Evan Miller proved invaluable in my
research. They helped me understand whats lacking in todays scientific computation field
and made me aware of its various challenges. I would like to thank ARS Technica
magazine whose brilliant articles helped me understand the modern trends in scientific
community. I feel immense gratitude towards my classmates and online community of
developers who help me along the way.
1
Page Index
Abstract 4
1. Introduction 5
2. Background 5
3. Scientific Computation 6
4. Julia 7
4.1. Features 8
5. Conclusion 11
2
Figure Index
3
Abstract
So far FORTRAN, C/C++, MATLAB and Python have been used to fulfil the needs of
scientific computing. But with the rising need of huge amount of data to be readily
computed, these languages are falling short to serve todays need. Distributed computing is
on the rise but these languages do not readily support them. Further, on has to make a
compromise between between readability and performance because theres no language
that provides both of them at the same time.
Now, Julia is a relatively new programming language which has become popular in the
scientific community in a very short time because of its great features. Julia provides
distributed parallel execution, numerical accuracy, and an extensive mathematical
function library. It is faster than other scripting languages, allowing one to have the rapid
4
Scientific Computation with Julia
1. INTRODUCTION
From a long time scientific computation community is looking for a language that is easy to
learn and use and at the same time has efficiency of C. Julia is such a language which
fulfills all requirements of todays scientific computation needs. Julia is a high-level,
high-performance dynamic programming language for numerical computing. It provides a
sophisticated compiler, distributed parallel execution, numerical accuracy, and an extensive
mathematical function library.
2. BACKGROUND
Todays scientific computation community is faced with many challenges. One of them is
the two language problem. Within a application where we want efficiency, we are usually
forced to write that code in low level language like C because it is fast where for the code
which is very complex we often employ use of a high level language which is easy to learn
and use. This gives rise to the two language problem. Evan Miller, a renowned statistician
beautifully puts it by saying that Normally I use one language to make something work,
and a second language to make it fast, and a third language to make it scream.[1] This
leads to problem for new developers as well as existing ones because working with two
languages isnt easy as the code gets more bulky and complex.
Another prominent problem is that developers have no choice but to code in languages
like Fortran and C to make their code efficient.[2] As you know these languages are
statically typed and hence converting mathematical formulas and algorithms to equivalent
code is much harder and often only professional developers are able to do so. This prevent
mainstream users and pioneers of the scientific computation world to contribute in the
software, hence making development slow and inefficient. Below is an image of Fortran
code. You can notice how hard it is to recognize what this code does. This code only
divides two numbers and you can imagine if this code is hard to understand what would
happen when one has to understand a complex algorithm written in the same language.
5
Fig 1. Code to divide 2 numbers in Fortran
3. Scientific Computation
Computation is any type of calculation that follows a well-defined model understood and
expressed as an algorithm. And Scientific Computation is a rapidly growing
6
multidisciplinary field that uses advanced computing capabilities to understand and solve
complex problems.
Data Science, Artificial Intelligence, Machine Learning, Computer Vision, Simulation
& Modelling are some of the examples of scientific computation. Computational science
fuses three distinct elements:
Algorithms (numerical and non-numerical) and modeling and simulation software
developed to solve science (e.g., biological, physical, and social), engineering, and
humanities problems
Computer and information science that develops and optimizes the advanced
system hardware, software, networking, and data management components needed
to solve computationally demanding problems
The computing infrastructure that supports both the science and engineering
problem solving and the developmental computer and information science
In practical use, it is typically the application of computer simulation and other forms
of computation from numerical analysis and theoretical computer science to solve problems
in various scientific disciplines.
The field is different from theory and laboratory experiment which are the traditional
forms of science and engineering. The scientific computing approach is to gain
understanding, mainly through the analysis of mathematical models implemented on
computers.
Scientists and engineers develop computer programs, application software, that model
systems being studied and run these programs with various sets of input parameters. In
some cases, these models require massive amounts of calculations (usually floating-point)
and are often executed on supercomputers or distributed computing platforms.
Numerical analysis is an important underpinning for techniques used in computational
science.
4. Julia
The Julia programming language fills the role of a perfect scientific computing language
having all the features the community is thriving for years to find in a single language all at
7
once. It is flexible dynamically typed language with performance comparable to traditional
statically typed languages.
4.1. Features
Following is a summary of features of the language:
Multiple dispatch: providing ability to define function behavior across many
combinations of argument types
Dynamic type system: types for documentation, optimization, and dispatch
Good performance, approaching that of statically-compiled languages like C
Built-in package manager
Lisp-like macros and other metaprogramming facilities
Call Python functions: use the PyCall package
Call C functions directly: no wrappers or special APIs
Powerful shell-like capabilities for managing other processes
Designed for parallelism and distributed computation
Coroutines: lightweight green threading
User-defined types are as fast and compact as built-ins
Automatic generation of efficient, specialized code for different argument types
Elegant and extensible conversions and promotions for numeric and other types
Efficient support for Unicode, including but not limited to UTF-8
MIT licensed: free and open source
8
Fig 2. Benchmark times relative to C (smaller is better, C performance = 1.0)
9
Above is example of implementation of belief propagation algorithm (used for
message passing in probability graphical models) in both C and Julia. It is quite evident
from looking at the Julia code what it is doing. It is transforming a vector with matrix A and
then normalizing it repeatedly. It would take a lot more effort to understand what the
equivalent C code is accomplishing.
Julia does not impose any particular style of parallelism on the user. Instead, it
provides a number of key building blocks for distributed computation, making it
flexible enough to support a number of styles of parallelism, and allowing users to
add more. The following simple example demonstrates how to count the number of
heads in a large number of coin tosses in parallel.
This computation is automatically distributed across all available compute nodes, and the
result, reduced by summation (+), is returned at the calling node.
Certainly it goes without saying how beneficial a free and open source software is.
Unlike Matlab which is paid, Julia is free and open source meaning anyone can use
and modify it. The core of the Julia implementation is licensed under the MIT
license. Various libraries used by the Julia environment include their own licenses
such as the GPL, LGPL, and BSD (therefore the environment, which consists of the
language, user interfaces, and libraries, is under the GPL). The language can be
built as a shared library, so users can combine Julia with their own C/Fortran code
or proprietary third-party libraries. Furthermore, Julia makes it simple to call
10
external functions in C and Fortran shared libraries, without writing any wrapper
code or even recompiling existing code.
5. Conclusion
A number of courses based on Differential Equations and Linear Algebra are now
being taught in Julia at MIT, USA. It also has found place in few courses provided at IIT
Indore.[3] Julia is further expected to become 2 or 3 times more fast than C in its future
releases. It is certain that with the advent of Julia, the field of scientific computation will
evolve faster than ever. It is proving a boon for mainstream scientists who require
computation to perform their tasks as this language provides the ease of scripting language
while not compromising the speed at the same time.
11
Bibliography
12