Question:
How hard is it to learn JAVA for a C veteran?
Goose R
2010-09-13 04:01:49 UTC
What about MATLAB, C++ FORTRAN, Python, VB, etc.?

I am an exclusive C programmer, major field of programming is numerical analysis, e.g. matrix handling, ODE PDE etc.

But since C is our department's prescribed language. I have very little experience with MATLAB and Python, and none with JAVA.

I know that many languages have built-in matrix functions that are absent in C, so why should I bother write twenty for-loops in C when I can do it with 5loops in MATLAB?

We would save so much more time if we were told to write in higher level languages instead of C, anyway just my personal opinion::)
Four answers:
Vincent G
2010-09-13 10:02:55 UTC
Because, if you are doing numerical analysis, some balance has to be made between the time to develop a program (done optimally only once) and the time taken to run the program (which may occur hundred if not thousand of times).

It is up to you at the potential users to decide if writing twenty for-loops in C is a worthwhile investment that will lead to shorter execution time.

And if you need matrix function, you can try to find a library that does what you want, or write your own functions that would could reuse in other programs from now on.



Matlab is a proprietary system/environment. That has its own inherent limitations.

C++ is likely to cost you some performance relative to C, as it comes with its own array of enhancements that can burden the optimizer and prevent it from making the code faster.

Fortran is still the fastest language, with the possible exception of assembly and machine language. That is partly because its syntax is even more restricted than that of C. If numerical efficiency is your #1 priority, Fortran remains the best choice.

Python is a very powerful language from the expressibility point of view. You can develop a program in no times flat, but you will need a calendar to check progress for a very large computation, instead of a clock for compiled languages like C.

For VB, you will have something that compares with C++.



If your department has already settled on C, why would you want to implement an environment that could save you a little programming time, but put a burden on usage cycle time?

Java is good if you do not know where the program will run (the virtual machine makes the code portable) but you do have a premium to pay for running the emulation layer. It is good when the computer is more powerful than needed and spends most of its time waiting for user input. If you do not have computer reserve power, stick with a compiled language.



Java should be relatively easy to learn as the syntax is pretty close to that of C. It is the small differences (you may be too comfortable with your present ways and enter C syntax instead of Java without realizing it) that would annoy you.
Chris C
2010-09-13 13:11:51 UTC
Matlab comes with built-in matrix operations that aren't part of the C/C++ standard.



Personally, I enjoy programming in C/C++. The primary difference between C/C++ and Java are: memory management is taken care of by Java automatically. The caveat to that is that Java has a garbage collection process that you may have to give a little push if you're running an extremely tight "timing" type of application.

As for C++, I use it to perform all allocation/deallocation of internal variables in the constructor and destructor of the class. And also find using the STL (Standard Template Library) is very beneficial when writing something like a Matrix class.

After all, creating a matrix of any type would be simple:

Matrix myFloatMatrix;

Matrix myDoubleMatrix;   // This would provide more precision



And you could override the standard operations (i.e. +,-,*,/,[],=) to do things like this:

Matrix myDoubleMatrix, mySecondDoubleMatrix, myResultMatrix;

myDoubleMatrix[0][0] = 5.0;

myDoubleMatrix[0][1] = 1700.456008;

myDoubleMatrix[3][0] = 35.9;

myResultMatrix = myDoubleMatrix * mySecondDoubleMatrix;

or the same thing could be written like this if you defined the template to override the * and = operations properly:

myResultMatrix = myDoubleMatrix;

myResultMatrix *= mySecondDoubleMatrix;



I wouldn't worry about FORTRAN, only because I have been coding for 20+ years now and have only converted COBOL and FORTRAN into C/C++.

VB is more limited to use in Windows, which is one of the reasons that I enjoy standard C/C++. And once you start creating libraries like the Matrix library, you'll have it for use in any other application you want either as a library, or the code as part of the new project.

Code reuse is the major benefit of any language, as one could imagine.
Chris P
2010-09-14 11:28:51 UTC
It will actually be very easy for you. You would have to get your mind around using objects, but other than that it wouldn't be a problem. I began studying computer languages in college this year, and I started with C#. It was a challenge, since I had to learn from scratch. The next quarter, I took JAVA, and picked right up on it from what I learned in C#. Of course there are going to be new concepts to learn, but you won't have a problem with it if I didn't.
2010-09-13 11:28:45 UTC
With JAVA, as with any other object oriented language, your main efford will be to learn the object structures that are available to enhance your performance. The language in itself it's quite simple.



My opinion is the higher the language the better, because computer time is much less expensive than programmers time.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...