Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question

closed as off-topic by MichaelT, Snowman, Kilian Foth, durron597, Dan Pichelman Sep 30 '15 at 15:30

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions about what language, technology, or project one should take up next are off topic on Programmers, as they can only attract subjective opinions for answers. There are too many individual factors behind the question to create answers that will have lasting value. You may be able to get help in The Whiteboard, our chat room." – MichaelT, Snowman, Kilian Foth, durron597, Dan Pichelman
If this question can be reworded to fit the rules in the help center, please edit the question.

I highly recommend SciPy - it is free, looks like Matlab (but is Python), and takes only a few lines to get it done!… – Job Feb 20 '11 at 1:51
MATLAB. Numerical solution of systems of differential equations is a solved problem, and has been for quite some time. If your objective is to crunch your numbers, use the tools that have been developed over the last several decades to do just that. Don't reinvent the wheel, no matter how much fun it might be. You will save yourself a lot of time and aggravation. – John R. Strohm Jan 9 '14 at 14:59
up vote 10 down vote accepted

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.

share|improve this answer

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.

share|improve this answer

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.

share|improve this answer
Thanks for the answer. I've since resorted to J and loving it. OCaml is a close second for me. – Eelvex Jan 9 '14 at 19:44

I liked OCaml, at least until I looked at multi-threaded programming.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.