I'm currently using C and some FORTRAN to solve numerically systems of differential equations.
I'm a bit fed up with both of these languages but I need to have some (rather) efficient code... I'm thinking of switching to OCaml.
Is it worth it?
Software Engineering Stack Exchange is a question and answer site for professionals, academics, and students working within the systems development life cycle. It only takes a minute to sign up.
Sign up to join this communityI'm currently using C and some FORTRAN to solve numerically systems of differential equations.
I'm a bit fed up with both of these languages but I need to have some (rather) efficient code... I'm thinking of switching to OCaml.
Is it worth it?
The people at Jane Street Capital sure think so. They gave a talk at CMU in 2009 about using OCaml.
The only drawback I can think of is that matrices aren't first class citizens.
First of all, I want to make the unusual statement that for numerical computations, high-level languages are much more useful in the long run than low-level languages. Let me loosely quote a researcher from Fraunhofer Institut working in numerical simulations used in weather forecasts.
In the last decade, CPUs became 1000 times faster while algorithms became 1000*1000 faster. This means, that today's algorithms running on yesterday's CPUs will beat yesterday's algorithms running on today's CPUs by a factor of 1000.
Obviously, there is much more parameters to take into account as CPU speed and algorithms, like disks or RAM, but that statement helps us to undestand that, if you choose a low-level language, you focus on the wrong factor (1000 instead of 1000*1000).
Of course, given any specific numerical algorithm one can expect C or Fortran to beat OCaml or Common Lisp by a (actually not that) large factor. But if you are actually interested in numerical problems and are willing to improve algorithms, you should then pick a high-level language that will allow you to express your ideas at a high level and to easily improve algorithms.
As a side note, if you consider writing numerical code in OCaml, you should definitely know about how OCaml pass parameters to functions, inline functions and unbox floats. All of this is detailed in Xavier Leroy's notes.
To to solve numerically systems of differential equations
you'll need first of all proper libraries. So a mandatory check is: does a programming language x
support them.
Personally I like to write code higher level than C
or Fortran
, thus I have used Matlab
, Octave
, numpy\scipy
.