I got interested in Julia programming language quite recently, primarily because of a project involving image processing and machine learning. The language is still evolving, but already has a rich set of features and a good collection of external libraries covering many areas. One of the highlights of the language is its highly optimised code generation, thus paving way for faster execution.
The first thing that caught my attention was Julia’s support for Multimethods, inspired by Lisp. You may want to watch this video.
In October 2015, I had written a post on Multimethods in Lisp (it might be a good idea to read that article before continuing). Recall that a multimethod is a method that is selected based on the runtime types of all of its arguments (not just the first argument).
My development platform is Windows 10. Atom is my IDE with Juno plug-in.
So how easy is it to implement that example in Julia? Here is the hierarchy from the earlier example:
Interestingly, Julia does not allow deriving from a concrete class. (I do not support this decision, but without getting into a debate on this, let us move on.) So I had to make Planet an abstract class for the code to work.
The implementation is otherwise pretty straightforward:
You can download the code here.
Watch out for more on Julia in future articles!
Recent Comments