In comments about my first successful plot made with Python, I stated that were I going to change horses, it would be to Julia.
FWIW, while shutting down for the night, I did discover Julia has an interface to Python matplotlib. Were I going to swap paths now, it would be to Julia. Designed for parallel processing and about as fast as C or FORTRAN (all 3 about 10x faster than Python). Then I still could learn the same plotting library…
Late last night I was just reading about concurrent languages while waiting to fall asleep. As I’m interested in cluster computing, all things concurrent and parallel are interesting. Then, for Climate Models, that’s an interest too. For this reason I’d started looking at what language choices there were.
Turns out it is a lot…
This article lists concurrent and parallel programming languages, categorizing them by a defining paradigm. A concurrent programming language is defined as one which uses the concept of simultaneously executing processes or threads of execution as a means of structuring a program. A parallel language is able to express programs that are executable on more than one processor. Both types are listed, as concurrency is a useful tool in expressing parallelism, but it is not necessary. In both cases, the features must be part of the language syntax and not an extension such as a library.
The following categories aim to capture the main, defining feature of the languages contained, but they are not necessarily orthogonal.
1 Actor model
2 Coordination languages
3 Dataflow programming
4 Distributed computing
5 Event-driven and hardware description
6 Functional programming
7 Logic programming
10 Object-oriented programming
11 Partitioned global address space (PGAS)
12 Message passing
12.1 CSP based
Then follows a list of about 98 languages and 8 frameworks (like OpenCL and OpenMP). This is, IMHO, one of the plagues of modern computer science. At every turn somebody just feels compelled to “make their own language” and another one sprouts. It is impossible to even keep up with the names of them all, and just finding a good one takes too much work (and only then do you get to start the learning curve).
FWIW, I’d seen some YouTube Videos on Julia, and I’m attracted to it. Not enough to actually write anything in it yet ;-) But at least it didn’t do anything obviously stupid at first blush. From the list of 98, the one’s I’m vaguely interested in would be:
Partitioned global address space (PGAS)
High Performance Fortran
Unified Parallel C
Main article: Communicating sequential processes
These application programming interfaces support parallelism in host languages.
OpenMP for C, C++, and Fortran (shared memory and attached GPUs)
But that is STILL too long a list to adequately examine and evaluate given all the rest I’m doing. So I’ll likely limit my FORTRAN interest to Coarray Fortran (as that is part of the language spec. now) and then some of the OpenXX stuff. Then, as time permits, a bit more looking over of the “new” “hot” “trendy” languages of Go and Julia. In particular, Julia interests me as it seems well designed for speed. That takes care and attention, which usually shows up in the rest of a language too.
I’ve bolded the bits that got my attention.
Julia is a high-level general-purpose dynamic programming language that was originally designed to address the needs of high-performance numerical analysis and computational science, without the typical need of separate compilation to be fast, also usable for client and server web use, low-level systems programming or as a specification language.
Distinctive aspects of Julia’s design include a type system with parametric polymorphism and types in a fully dynamic programming language and multiple dispatch as its core programming paradigm. It allows concurrent, parallel and distributed computing, and direct calling of C and Fortran libraries without glue code.
Julia is garbage-collected, uses eager evaluation and includes efficient libraries for floating-point calculations, linear algebra, random number generation, and regular expression matching. Many libraries are available, and some of them (e.g. for fast Fourier transforms) were previously bundled with Julia.
Julia has attracted some high-profile clients, from investment manager BlackRock, which uses it for time-series analytics, to the British insurer Aviva, which uses it for risk calculations. In 2015, the Federal Reserve Bank of New York used Julia to make models of the US economy, noting that the language made model estimation “about 10 times faster” than its previous MATLAB implementation. Julia’s co-founders established Julia Computing in 2015 to provide paid support, training, and consulting services to clients, though Julia itself remains free to use. At the 2017 JuliaCon conference, Jeffrey Regier, Keno Fischer and others announced that the Celeste project used Julia to achieve “peak performance of 1.54 petaFLOPS using 1.3 million threads” on 9300 Knights Landing (KNL) nodes of the Cori (Cray XC40) supercomputer (the 5th fastest in the world at the time; by November 2017 was 8th fastest). Julia thus joins C, C++, and Fortran as high-level languages in which petaFLOPS computations have been achieved.
I really like it when a language is able to keep up with the leaders in speed… As I’m running on dinky hardware, all the speed I can get matters. I won’t go into the whole language feature set and details, but a couple of important bits:
According to the official website, the main features of the language are:
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-typed languages like C
A built-in package manager
Lisp-like macros and other metaprogramming facilities
Call Python functions: use the PyCall package[a]
Call C functions directly: no wrappers or special APIs
Powerful shell-like abilities to manage other processes
Designed for parallel and distributed computing
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
So built for speed and multiprocessing, yet can use libraries that already exist as needed / desired. Nice. It plays well with others…
Use with other languages
Julia’s ccall keyword is used to call C-exported or Fortran shared library functions individually.
Julia has Unicode 11.0 support, with UTF-8 used for strings (by default) and for Julia source code, meaning also allowing as an option common math symbols for many operators, such as ∈ for the in operator.
Julia has packages supporting markup languages such as HTML (and also for HTTP), XML, JSON and BSON, and for databases and web use in general.
Julia’s core is implemented in Julia, C (and the LLVM dependency is in C++), assembly and its parser in Scheme (“FemtoLisp”). The LLVM compiler infrastructure project is used as the back end for generation of 64-bit or 32-bit optimized machine code depending on the platform Julia runs on. With some exceptions (e.g., PCRE), the standard library is implemented in Julia itself. The most notable aspect of Julia’s implementation is its speed, which is often within a factor of two relative to fully optimized C code (and thus often an order of magnitude faster than Python or R), Development of Julia began in 2009 and an open-source version was publicized in February 2012.
Works in many environments. Though the wiki claims that for the first v6 R.Pi types you need to compile it from sources, but it’s a built in on some other later v7 & v8 boards.
Current and future platforms
While Julia uses JIT (MCJIT from LLVM) – Julia generates native machine code directly, before a function is first run (not bytecodes that are run on a virtual machine (VM) or translated as the bytecode is running, as with, e.g., Java; the JVM or Dalvik in Android).
Julia has four support tiers, and currently supports all x86-64 processors, that are 64-bit (and is more optimized for the latest generations) and most IA-32 (“x86”) processors, i.e. in 32-bit mode (all x86 CPUs except for the very old from the pre-Pentium 4-era); and supports more in lower tiers, e.g. tier 2: “fully supports ARMv8 (AArch64) processors, and supports ARMv7 and ARMv6 (AArch32) with some caveats.” Other platforms (other than those mainstream CPUs; or non-mainstream operating systems), have tier 2 or 3 support (or tier 4 if not known to build), or “External” support (meaning in a package), e.g. for GPUs.
At least some platforms may need to be compiled from source code (e.g. the original Raspberry Pi), with options changed, while the download page has otherwise executables (and the source) available. Julia has been “successfully built” on several ARM platforms, up to e.g. “ARMv8 Data Center & Cloud Processors”, such as Cavium ThunderX (first ARM with 48 cores). ARM v7 (32-bit) has tier 2 support and binaries (first to get after x86), while ARM v8 (64-bit) and PowerPC (64-bit) have “Community” support and PTX (64-bit) (meaning Nvidia’s CUDA on GPUs) has “External” support.
Julia is now supported in Raspbian while support is better for newer (e.g.) ARMv7 Pis; the Julia support is promoted by the Raspberry Pi Foundation.
There’s even a bunch of folks using it ;-)
The easiest way to install Julia is by downloading the 32-bit (ARMv7-a hard float) prebuilt binary from the JuliaLang website.
An older version of Julia (0.6) is also available via apt in Raspbian, we hope to update this to the latest version in the near future.
Instructions can be found over here
Jupyter will need to be installed manually, as the automatic Conda installer does not work on the ARM architecture. Generally, runningsudo apt install libzmq3-dev sudo pip3 install jupyter
at the shell should work. Then it should be sufficient to do
at the Julia REPL.
The JuliaBerry org provides several Raspberry Pi-specific packages:
PiGPIO.jl: managing external hardware using GPIO pins.
PiCraft.jl: manipulating Minecraft on the Raspberry Pi from Julia
SenseHat.jl: interacting with the Sense HAT.
So it is on my “short list” for making the Pi Cluster “go” well. My experiments with FORTRAN on the Pi have so far been disappointing in that the parallel code runs about the same speed as the inline. I’ve not investigated why. I was going to just swap over to Coarray FORTRAN but it was not yet ready to run on the Pi… So hopefully the Julia folks have cared more and have it running well and efficiently.
At their site, they point out the graphical abilities.
Data Visualization and Plotting
Data visualization has a complicated history. Plotting software makes trade-offs between features and simplicity, speed and beauty, and a static and dynamic interface. Some packages make a display and never change it, while others make updates in real-time.
Plots.jl is a visualization interface and toolset. It provides a common API across various backends, like GR.jl, PyPlot.jl, and PlotlyJS.jl. Users who prefer a more grammar of graphics style API might like the pure Julia Gadfly.jl plotting package. For those who do not wish to leave the comfort of the terminal, there is also UnicodePlots.jl.
So lots of choices… at a time when I already have too many choices ;-) There’s also an SQL interface package. So, in theory, it has everything I want, right? Well… As a new language it is possible it will change fast and I’m not keen on that. Also, the user base and “clue postings” are limited. All the stuff that comes with being an early adopter. As I’m already an early adopter on my OS choice (Devuan) I’d rather some bits of the stack were more staid and proven. So I’m sticking with Python for now as it is the most widely used for what I’m interested in doing.
Still, at some point, I may get enough “play time” to play with Julia and data plotting. It’s a low priority “play time” thing, though. Work time will continue going into Python & matplotlib learning. Not wasted as Julia can also do the matplotlib stuff ;-)
Note this bit:
Julia has been downloaded over 4 million times and the Julia community has registered over 2,400 Julia packages for community use. These include various mathematical libraries, data manipulation tools, and packages for general purpose computing. In addition to these, you can easily use libraries from Python, R, C/Fortran, C++, and Java. If you do not find what you are looking for, ask on Discourse, or even better, contribute!
So while it is a young language, they look to have taken time to assure they are a compatible language.
The Julia community seems to also be somewhat integrated with the Python community, so I expect many things to be in common, and what I learn in the Python context to easily apply.
IJulia is a Julia-language backend combined with the Jupyter interactive environment (also used by IPython). This combination allows you to interact with the Julia language using Jupyter/IPython’s powerful graphical notebook, which combines code, formatted text, math, and multimedia in a single document. It also works with JupyterLab, a Jupyter-based integrated development environment for notebooks and code.
(IJulia notebooks can also be re-used in other Julia code via the NBInclude package.)
And there’s a way to get into MySQL databases (thought julia includes DataFrames and a JuliaDB)
Were I the “trendy new language” sort, I’d likely be all over Julia as my language choice for what I’m doing. Being more from the “What has already been used 100 times so it isn’t buggy and has lots of ‘how to’ pages” sort, I’ve chosen to do my first round on MySQL / Python. I intend to continue on that path as long as it moves well. (So far it has. Despite Debian requiring a half dozen different things be installed – something the Windows and Mac install don’t require, btw – I was able to get my first graph made in about 2 elapsed days, or about 1 real day ;-)
Julia is on my very short list of likely languages to learn and use in the future. Especially given the speed and parallel / concurrent design of it, for doing big computes on small iron, that is a very attractive set of features.
Well, enough about Julia. Time for me to get back to the matplotlib mine and make a more interesting graph from the CSV data, then figure out how to use the MySQL database effectively.