Geodynamists usually do at least a bit of programming, but in many cases a lot of programming, although that might just be my academic bubble. Most of that programming is done in programming languages that have been around at least since the 80’s (Fortran, C and C++) or early 90’s (Python). These programming languages have of course evolved considerably over time, but new languages keep popping up if you know where to look. For example on this obscure website called Wikipedia.
Why would you want to learn a new programming language, you may ask? Well, different programming languages are good at different things, so being familiar with multiple languages is like having multiple tools in your toolbox. The languages mentioned above are all great choices for a lot of different applications, and they have been extensively used in our community. All these programming languages also have their own issues which only got discovered by long term usage in large projects. Although these older languages are trying to resolve some of these issues in new releases, they have to remain compatible with older code. There are some new and upcoming languages that try to address several of these issues by starting from scratch. Each in their own way. So here are three relatively new programming languages definitely worth a look in your journey to model nature, build post processing scripts or create an amazing app for outreach!
Before I list the programming languages though, I may need to clarify the following concepts:
1. memory usage and garbage collection
2. parallel computing and memory sharing
3. package managers
1. Memory and garbage collection
All variables in your application need to be stored in memory. Often the amount of memory needed can only be determined when a program is running. This means memory needs to be allocated when the variable is needed and freed when it is no longer needed. In languages like C++, where the programmer needs to do that themselves, it turns out that in real world applications it is very easy to forget this and very hard to find these types of mistakes. Therefore many languages tell you not to bother with managing this and use a garbage collector to automatically clean up after you (see this page for a nice visual explanation of how they work). This is extremely convenient, but has a performance cost. On top of that, it is usually hard to predict when it is going to do this expensive clean-up, so it may not be ideal for applications that need a high and stable performance (for example the Discord servers).
2. Parallel computing and memory
Conceptually, parallel computing can be divided in two types: shared memory and distributed memory. In the shared memory case, all the memory can be accessed by all processors. This is a very efficient way of communication between the processors in a program, but there are many dangers, such as two processors trying to write to the same variable at the same time. In the distributed memory case, processors only have access to their own piece of memory. This model is usually used in large clusters, since processors cannot always share memory in these cases. The most-used library to facilitate this is called MPI.
3. Package managers
Good package managers allow you to quickly find and install libraries that adds functionality not included in the core language. When you are used to C++, a good package manager feels incredible! Luckily all the languages below have a good package manager included.
The three new languages to try out
So here are these “new” kids in town. I will not go into too much detail since it is a long post already, but I hope there is enough to get you to try them out!
Julia is a garbage collecting just-in-time compiled programming language designed for data science and scientific computing. Julia for example has some very nice linear algebra functionality built in. It also comes with its own implementation for both shared and distributed memory computing, although MPI packages are also available. The language looks a bit like python, so if you are used to python it will feel familiar. Besides the great math functionality, it also has some nice plotting packages. Julia is built on the same foundation as Clang (LLVM), which means you should be able to compile and run it on all systems that support LLVM, which are a lot.
Rust is a compiled programming language designed as a very safe and fast general purpose language. I am a bit of a fan of this language myself, since it allows for the same speed and predictability (no garbage collection) as C++, but is by design much safer (especially in parallel). The compiler will tell you when you are doing something that is not safe enough and is generally very helpful in telling you how to fix it. So that is one less thing to worry about. It is like Julia built on LLVM, so you can run it on the same machines as Julia. Since its design is much more general purpose than Julia’s, the math functions are not as nice as those I have seen in Julia, but you can use a package that allows you to use NumPy directly or a package that has a Rust implementation called ndarray. The Rust community has been growing a lot over the years and apparently they are happy, because Rust has been voted the most loved programming language since 2016 on stackoverflow.
I mostly knew Go as a server language, in which it has its origins, but it turns out it can actually do much more. Go, also referred to as Golang, is designed around the idea that it needs to be simple to write and fast to run. It uses garbage collection and has great support for shared memory parallelism (like the others) and can use MPI. It may not be the first choice for making your next big geodynamic code, but it could be ideal for smaller applications or an interactive website to show off your awesome research!
So go forth and program!