• LOGIN
  • No products in the cart.

Julia Tutorial

Julia is a high-performance dynamic programming language for scientific and technical computing. It combines the simplicity of Python with a more sophisticated compiler and many small enhancements that make the platform simpler to use and better suitable for numerical computation. To get started, I suggest Julia Box for convenient access to Julia from your browser. If you care about interfacing native code, seem at “Calling C and Python”. Julia is generally used through research scientists and engineers, In addition to them, it is additionally utilized through financial analysts, quants and data scientists. The developers of Julia language made sure that the products developed make Julia an easily usable, deployable, and scalable.

TOPICS ON JULIA

INTRODUCTION TO JULIA LANGUAGE

WHY JULIA

FEATURES

JULIA PACKAGES

METAPROGRAMMING

PERFORMANCES

ADVANTAGES

INTRODUCTION TO JULIA LANGUAGE

It is an open-source, high-performance, high-level, dynamic programming language that is used in scientific computing. It is predominantly used for data analysis and information computations which is similar to the R programming language. Julia is built particularly for its speed and applications using it have experienced faster running instances when compared with Python or R. It offers support in performing tough tasks such as cloud computing and parallelism which are considered as essential to function big data analytics.

WHY JULIA

Julia solves a trade-off that has long existed in programming: fast coding vs. fast execution.

On the one hand, Julia lets in you to code in a dynamic language like Python, R or Matlab, allowing for fast interaction with your program and exceptional expressive power

On the other hand, with minimal effort programs written in Julia can run almost as fast as C While it is still young, Julia permits you to easily interface your code with all the major programming languages for this reason reusing their big set of libraries when these are not already being ported into Julia.

Julia has its roots in the domain of scientific, high performances computing, however, it is turning into more and more mature as a common purpose programming language.

FEATURES OF JULIA

The following aspects make Julia a famous programming language:

  • Julia makes use of dynamic typing, resembles scripting, and has exact help for interactive use.
  • Julia helps high-level syntax which makes it an efficient language for programmers.
  • Julia provides a rich language of descriptive data types.
  • Julia helps multiple dispatches which makes it easy to collect object-oriented and useful programming code patterns. As Julia is an open-source, all source code is publicly viewable on GitHub.

Julia Training

 JULIA PACKAGES

These are some of the favored applications used by way of Julia developers:

  • Interact.jl: Interactive widgets such as dropdowns, sliders and checkboxes to easily implement Julia code.
  • Generic Linear Algebra: used to prolong linear algebra functionality.
  • Colors.jl: this is a color manipulation utility for Julia.
  • UnicodePlots.jl: scientific plotting primarily based on Unicode to work in the terminal.
  • Nemo: computer algebra package.
  • Revise: update function definitions automatically in a running Julia session
  • BenchmarkTools: a benchmarking framework.
  • OhMyREPL.jl: bracket highlighting, syntax highlighting and rainbow brackets.
  • StaticArrays: a framework that presents statically sized arrays.

METAPROGRAMMING

Julia represents its very own code as a data structure accessible from the language itself. Since code is represented through objects that can be created and manipulated from within the language, it is viable for a program to radically change and generate its own code, which is to create powerful macros (the term “metaprogramming” refers to the opportunity to write code that writes codes that are then evaluated).

Note the difference between C or C++ macros. There, macros work performing textual manipulation and substitution before any actual parsing or interpretation occurs.

In Julia, macros works when the code has been already parsed and organized in a syntax tree, and consequently the semantic is a whole lot richer and permits for much more powerful manipulations.

PERFORMANCES (PARALLELISATION, DEBUGGING, PROFILING..)

Julia is relatively fast when working with any data, however when the JIT compiler is in a position to infer the specific type of an object. Julia runs with the same order of magnitude of C.

As an example, here is how a typical loop-based function compare with the same function written using different programming languages (to be fair: these other programming languages can significantly enhance the way they compute this function, e.g. the use of vectorized code)

CODE PARALLELISATION

Julia offers core functionality to parallelize code using processes. These can be even in distinct machines, where the connection is realized through SSH. Threads instead are constrained to the same CPU but, contrary to processes, share the same memory. A high-level API for multithreading has been introducing in Julia 1.3

Parallelization using multiple processes

This notebook suggests how to use quite a few functions to facilitate code parallelism:

Parallelisation the use of multiple threads

Here is an instance on how to use the new @spawn macro in Julia >= 1.3threads on a function that produces something, saving the outcomes to a vector where order doesn’t count and the computational method of any record is independent of those of any other record.

DEBUGGING

Some different common operations regarding introspection and debugging:

1 Retrieve function signatures: methods (myfunction)

2 Discover which particular technique is used (within the several available, as Julia supports multiple-dispatch aka polymorfism): @which myfunction(myargs)

3 Discover which fields are part of an object: field names(myobj)

4 Discover which type (loosely a “class” in OO languages) an object instance is: typeof(a)

5 Get more facts about an object: dump(myobj)

PROFILING

Profiling is the “art” of discovering bottlenecks in the code. An easy way to time a part of the code is to simply type @time myFunc(args) (but be certain you ran that function at least once, or you will measure compile time rather than run-time) or @benchmark myFunc(args). For more enormous coverage, Julia comes with a built-in statistical profile, that is, it runs every x milliseconds and memorizes in which line of code the program is at that moment.

Using this sampling method, at a price of losing some precision, profiling can be very efficient, in phrases of very small overheads compared to run the code normally.

1 Profile a function: Profile.@profile myfunct() (best after the function has been already ran once for JIT-compilation).

2 Print the profiling results: Profile.print() (number of samples in corresponding line and all downstream code; file name:line number; function name;)

3 Explore a chart of the name graph with profiled data: ProfileView.view() (from package ProfileView).

4 Clear profile data: Profile.clear()

Julia course

ADVANTAGES OF JULIA

  1. Julia was once designed for numerical and scientific computation. It’s not surprising that Julia has numerous elements for such situations of use:
  2. Faster through default. JIT compilation and JIT type declarations suggest it can frequently beat “pure”, Python. With the means of external libraries, optimizations with tools such as Python, third party JIT compilers python can be made faster, however, Julia was designed to be faster right out from the gate.
  3. A mathematical friendly syntax. The users of computing languages and environments such as Matlab, R, Mathematical, and Octave are the focused audience for Julia. Julia’s syntax for arithmetic operations looks similar to the way arithmetic formulation is written outside the computing world, which makes it seem less difficult for nonprogrammers to choose upon.
  4. Automated memory management. Like Python, Julia does not load the user with the specifics of allocating and freeing memory, and it affords some measure of control over garbage collection. The thought is that if you change to Julia, you do not lose one of Python’s common conveniences.

June 12, 2020
GoLogica Technologies Private Limited. All rights reserved 2024.