Erik Engheim
3 min readMar 11, 2021

--

Ok I wrote an article to spell out how I figured out what different things mean in the Fortran code. I figured more people might be interested in that.

I wanted to show that what you see in Fortran is still being recycled in a variety of languages still in use today. But if one is only looking at curly braces langauges it may look odd indeed. Anyway here is the analysis: https://erik-engheim.medium.com/fortran-code-guessing-game-5be584b7400a

I had a quick look at Armadillo, but I don't actually see why I would want to use it? It is still a lot easier to write numerical code using Julia.

C++ is not a very good numerical language IMHO. It has quite a weak type system with respect to numbers.

A language like Julia gives you a rich type hierarchy from numbers, so I can say e.g. that this input should be a signed or unsigned number without specifying e.g. the bit size. Or I could say it is a floating point number without specifying the precision.

C++ also does way too much implicit type conversions that blow up in your face. The promotion rules are typically hardwires and arcane. In Julia at least promotion rules for numbers can be defined by you.

You can add your own number types and define the promotion rules. If you are uncertain about how the rules work, then you can quickly step through the promotion code in the REPL, to see how it works. This is accessible right at your fingertips.

Working with arrays, ranges, slices etc is usually really clumsy in C++. At some point we had to use C++ to get good enough performance. But there is not need to put up with C++ anymore.

Most likely you will be able to write higher performance code in Julia. It is crazy how well the JIT can optimize a lot of stuff in ways which is just impossible to do for an ahead-of-time compiler that C++ uses.

And the advantage of Julia is that it uses a method JIT so you can actually look at what code would be generated per function call. I got better access to low level details in Julia than in C++. Pouring over assembly code for a whole translation unit sucks in C++. In Julia I regularly look at produced assembly code. It is supe reasy to do and convenient as you can just do it per function.

Not only that but you can look at all the steps taken towards assembly code. You can look at lowered code. Type annoted code, LLVM byte code or native assembly code. It is all there.

Thus you have the advantage of being able to program in a very high level langauge but never really have to worry about how the code gets translated to machine code. Because it is so easy to lookup whenever you need it, you quickly develop an intitution for what the Julia JIT is capable of doing and what it cannot do.

I have a much better grasp of this in Julia than I ever did in C/C++, depsite spending far more years programming C++.

--

--

Erik Engheim
Erik Engheim

Written by Erik Engheim

Geek dad, living in Oslo, Norway with passion for UX, Julia programming, science, teaching, reading and writing.

Responses (1)