Julia takes a page from Go, adds composable multi-threading feature
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 parallelism. Golang 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
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.
For now, this feature is in beta testing.
Get acquainted with Julia
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
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.