days
-4
-5
hours
0
-4
minutes
-5
-3
seconds
-5
-9
search
Unraveling the threads

Julia takes a page from Go, adds composable multi-threading feature

Sarah Schlothauer
julia
© Shutterstock / lifework

The Julia programming language introduced composable multi-threaded parallelism. Let’s take a look under the hood and see where this language is headed, and what it includes. It may not be the most popular language, but attendees of JuliaCon in Baltimore are showing off its specific uses and creations made with the language.

Have you met Julia? According to the GitHub README, “Julia is a high-level, high-performance dynamic language for technical computing.” While it may not take the prize for the most popular language, it has some impressive features and functions for technical computing. According to the latest RedMonk language ranking, Julia is the 33rd most popular programming language.

An announcement on July 23, 2019 introduced composable multi-threaded parallelismGolang users might take an interest since Go uses composable parallelism.

Meanwhile, JuliaCon wraps up in Baltimore, Maryland, hosting talks about its use cases and tutorials. (Just a few examples of the offerings: a plotting library written entirely in Julia, smart home functions on the Raspberry Pi and Julialang, and how Julia helped a speaker generate figures for a textbook.)

Composable multi-threaded parallelism

Let’s take a look at the new feature:

From the announcement:

“In this paradigm, any piece of a program can be marked for execution in parallel, and a “task” will be started to run that code automatically on an available thread. A dynamic scheduler handles all the decisions and details for you. Here’s an example of parallel code you can now write in Julia:

import Base.Threads.@spawn

function fib(n::Int)
    if n < 2
        return n
    end
    t = @spawn fib(n - 2)
    return fib(n - 1) + fetch(t)
end

SEE ALSO: How to keep your software-defined infrastructure from catching a ‘cold’

The model is portable, free from low-level details, nestable, and composable. With it, users will not have to explicitly start and stop threads, or even know how many processors or threads there currently are. It frees up CPUs from threads.

This feature is inspired by parallel programming systems such as Clik and the Intel Threading Building Blocks library.

For now, this feature is in beta testing.

Get acquainted with Julia

Check out Julia on GitHub. The current stable release is v1.1.1.

SEE ALSO: The role of artificial intelligence in improving data security

The documentation lists a few reasons to use the language over comparable alternatives:

Free and open source (MIT licensed)
User-defined types are as fast and compact as built-ins
No need to vectorize code for performance; devectorized code is fast
Designed for parallelism and distributed computation
Lightweight “green” threading (coroutines)
Unobtrusive yet powerful type system
Elegant and extensible conversions and promotions for numeric and other types
Efficient support for Unicode, including but not limited to UTF-8
Call C functions directly (no wrappers or special APIs needed)
Powerful shell-like capabilities for managing other processes
Lisp-like macros and other metaprogramming facilities

Julia runs in the terminal via a built-in command line, in the browser on Juliabox with Jupyter notebook interface, using Docker, or by using JuliaPro.

Newcomers to the language should make sure they have the required build tools and libraries. The language also automatically installs external libraries, including LVVM, FEmtoLisp, OpenLibm, LAPACK, and more.

Full documentation for the current stable build available here.

Author
Sarah Schlothauer

Sarah Schlothauer

All Posts by Sarah Schlothauer

Sarah Schlothauer is an assistant editor for JAXenter.com. She received her Bachelor's degree from Monmouth University and is currently enrolled at Goethe University in Frankfurt, Germany where she is working on her Masters. She lives in Frankfurt with her husband and cat.

Leave a Reply

2 Comments on "Julia takes a page from Go, adds composable multi-threading feature"

avatar
400
  Subscribe  
Notify of
Amin
Guest

So is this new feature compiled or it is dynamically interpreted?

Amin
Guest

For using Julia you don’t need any 3rd party tools. They are already available in the binaries. Those are for someone that wants to build from the source!