by delt0r » Thu Apr 19, 2012 2:19 pm
If your coding java for the first time from C++ you probably will have performance issues. Not because java is slow, but because java is not C++. So you can't write like C++ really. Otherwise there is no better way to learn other than by doing. As a rule of thumb you should be about within a factor of 2 of C/C++ code performance wise for "general algorithms" or general computation. In my cases i in fact have better performance than C/C++ code it replaces. But that is a bit of effort. For some raw, but fairly simple number crunching like small matrix multiples or small FFTs, then C/asm is going to be much faster.
Unfortunately I think that C++ to java is quite a change really. Just think that every object is by reference/pointer and that every method is virtual, with no multiple inheritance. Also generics are *not* templates, so don't expect that stuff to work the way you want. Method call overhead is very low (recursion can be faster than loops) and short lived objects are also pretty efficient speed wise with the JIT.
Ok so that was more or less OT. meh is pretty quite here right now anyways.
It was like that when I got here.