Programming languages v Mathematica/Matlab

  • Context: MATLAB 
  • Thread starter Thread starter wanfife
  • Start date Start date
  • Tags Tags
    Programming
Click For Summary

Discussion Overview

The discussion revolves around the advantages and disadvantages of using programming languages like Java, C, and C++ for scientific calculations and modeling compared to using software like Mathematica and Matlab. It encompasses aspects of performance, ease of use, and specific functionalities relevant to scientific computing.

Discussion Character

  • Debate/contested

Main Points Raised

  • Some participants argue that compiled languages such as C, C++, or Fortran offer significant speed advantages for applications involving large data sets and intensive calculations.
  • Others note that while compiled languages are faster, they may not express mathematical concepts as easily as Mathematica or Matlab.
  • One participant highlights that Mathematica has extensive libraries and infrastructure for tasks like parallel processing, which can be beneficial.
  • There is mention of the availability of compilers for languages like Matlab and Python, suggesting that these languages can also achieve improved performance under certain conditions.
  • A participant shares a personal experience regarding floating point errors encountered while using Matlab for a high-dimensional ODE, implying that this could necessitate a switch to C++ for better reliability.
  • Another participant emphasizes that the speed improvement from using a compiled language can be substantial, potentially making it hundreds to thousands of times faster than Mathematica for computation-heavy tasks.

Areas of Agreement / Disagreement

Participants generally agree on the speed advantages of compiled languages for intensive calculations, but there is no consensus on the overall superiority of one approach over the other, as various factors such as ease of use and specific application needs are also considered.

Contextual Notes

Some limitations mentioned include the potential for floating point errors in Matlab and the complexity of compiling code in Matlab compared to other languages. The discussion also reflects varying levels of familiarity with the programming languages and tools mentioned.

wanfife
Messages
1
Reaction score
0
Can anyone give me a quick answer to this question:

For scientific calculations, modelling, producing graphs etc, what advantage is there to coding in Java, C, C++ , as opposed to just using much simpler programs like Mathematica or Matlab?

Thanks!
 
Physics news on Phys.org
The advantage would be speed. The disadvantage would be that the language is not really fine tuned to express mathematical concepts easily.

Also Mathematica has a huge amount of libraries that are already proven to be accurate and there is a lot of infrastructure in place to do things like parallel processing.
 
If your application needs to work with large sets of data and do lots of calculations, it will probably run faster if written in a compiled language such as C, C++, or Fortran. If it is written in an interpreted language such as Java, python, Mathematica, or Matlab, it will probably run quite a bit more slowly.
 
note that in the case of matlab/python (at least, not familiar with others) there are compilers available. I thought python actually was a hybrid (i.e. if you run a function and then don't make changes, it will stay compiled; the first run, however, is interpreted and compiled on the fly). Matlab you have to go through a bit of trouble to get things compiled.

Matlab's greatest advantage is the way it handles matrices and arrays, which is very handy to digital signal processing and linear algebra operations (though, when I vectorized my 200+ dimension ODE, I got floating point errors in my hyperbolic cosine function that made my solutions blow up to INF, so the if statements were the only way I could make it work so far; I might as well have used C++ for this).
 
Just a comment, since I had this same question at some point. As already said, the main reason to use a compiled language such as C or C++ is for speed. My comment is that the speed improvement can be very substantial; a compiled language like C can run 100's to 1000's of times faster than something like Mathematica on calculation intensive code.
 

Similar threads

  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
6
Views
4K
  • · Replies 22 ·
Replies
22
Views
4K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 23 ·
Replies
23
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
Replies
86
Views
3K
  • · Replies 7 ·
Replies
7
Views
7K