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

Share
  • July 24, 2019

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.

The post Julia takes a page from Go, adds composable multi-threading feature appeared first on JAXenter.

Source : JAXenter