views:

134

answers:

6

I have recently begun working at a company wherein there are very few (2-3) programmers and many more engineers. As a result, the default language of choice has become VB.net. I look at some of the math-intensive portions of the programs that have been written thus far and I'm certain that these portions could be improved considerably if written in a lower level language.

The idea has already been proposed for me to possibly learn a new language to begin improving these sections of math-intensive code. Now my question: what language would be best to learn to actually implement this idea? I'm only a third year Computer Science student, and all of my classes thus far have been strictly Java. Although, the next classes I'll be taking will be in C++ and perl. As a result, I really only know Java and VB.net to the extent that I can claim proficiency in those languages (I've worked a lot in C as well, but not enough to claim proficiency). Would I be looking at a C-based language such as C or C++ to learn or possibly something else?

The math intensive portions are generally vectors and matrices, with the end result of rendering in a 3-dimensional manner.

+3  A: 

Large calculations on sets of data sounds like a job for F# or another functional language - especially if you would like to run the calculations in parallel. I mention F# specifically since you are already on the .NET platform - so it might be easier to transition to another .NET language, in terms of systems and environment. It will also make it easy for you to continue using VB .NET in some parts of the application (GUI perhaps, since F# isn't really suited for that), while developing new parts in F#. Take a look here.

driis
+1  A: 

If you're already intending to learn C++, you could go for C++/CLI as the backend language. It's a first-class .NET citizen, and will easily mix with your VB.Net code, yet has the full power of C++.

Anthony Williams
+5  A: 

There's an enormous amount of mathematical code written in Python. See this list. You can call Python from .NET via Iron Python (and sometimes Ironclad).

If the engineers in your company know Matlab, they'll like Python because the Python numerical libraries have followed Matlab.

The NumPy library has APIs for working with matrices and vectors. The library is very efficient because it implemented using highly-optimized LAPACK code. That makes the NumPy code more efficient than C code that you're likely to write yourself.

(The LAPACK/BLAS people are amazing. They can take something that looks completely straight forward, like a matrix-vector product, and somehow make it five times faster.)

If you're dealing with large matrices, make sure to use LAPACK directly or use something like NumPy that uses LAPACK. If your matrices are small, rolling your own routines may be efficient enough. Even so, the LAPACK routines are robust and very well tested and so I'd go with them unless there's a good reason not to.

John D. Cook
Thanks John and Duffy for the links to LAPACK. It's an interesting looking package that I'll I'm definitely looking into.
AndyPerfect
If the engineers in your company regularly use Matlab they'll hate Python. The features that make Python attractive are usually matters of complete indifference to engineers, and Python just doesn't provide the integrated-out-of-the-box experience that Matlab does. Like Python, Matlab uses extremely fast numerical libraries, generally implementations of the same ones.
High Performance Mark
+4  A: 

I'd focus less on the language and more on using existing, proven libraries. You'll want to look at stuff like LAPACK and ports to other languages. This is the wellspring, written in Fortan, tested and optimized within an inch of its life.

Java linear algebra libraries to think about are JAMA and maybe Apache Commons Math.

duffymo
A: 

I'm certain that these portions could be improved considerably if written in a lower level language.

You don't say what sort of improvement you have in mind. If your goal is to make these portions of the code easier to read and maintain, you might want to look at Haskell or at APL:

  • Haskell has a very powerful overloading notation ("type classes") that makes it possible to write the code the way you would write the math. There's a good optimizing compiler and good support for parallel computation and multicore. With good libraries for matrix computation, it might be a good solution for your engineers.

  • APL was designed from the ground up to support array and matrix computations. When I was in school it was used very heavily by civil engineers and structural engineers. But it's even more of a niche language than Haskell is, and some people find the notation off-putting and difficult to learn.

Norman Ramsey
My apologies for not being clearer. readability and maintenance isn't really an issue, although it would be nice to not have to try to understand what that 300 character-long equation is actually doing :)
AndyPerfect
+1  A: 

I'm certain that these portions could be improved considerably if written in a lower level language

In what ways ? Faster to execute ? More reliable ? Faster to develop ?

Consider Matlab.

High Performance Mark
Does Matlab code have the capability of being able to be executed during runtime of another program?
AndyPerfect
It certainly does. The Mathworks publish products to make integration of Matlab with C/C++, Fortran, Java and .Net languages relatively easy, either to call Matlab from X or to call X from Matlab.
High Performance Mark