I think that the answer was YES, and not an interpreted language will work 99.99% faster than the same algorithm under a virtual machine. That said (working a lot on image processing in both java and c / C ++, where memory and time mattered). I think you should try to optimize your code first, here are my tips:
- Try to find the bottleneck of your code using the profiler. Many things that we sometimes omit can be appeased by such tools (such as type casting, unnecessary creation of objects, the most important functions that should be optimized at the beginning). The profiler should be your friend.
Then (just a few examples that I could see for raytracing):
- Replace tan / sin / cos with lookup tables (if possible) or approximate functions
- Try to process the data on each array, not on the sample
- Try using multiple threads.
- ...
Now these things are โgoodโ, but if speed is really important to you, I would not suggest using c or C ++ (even if I could), but more likely to focus on OpenCL. This is perhaps the best tool available and best suited to create a ray engine. Imagine that you are not talking about an improvement of 30%, but more likely 10'000% (100 times faster). Here is the java interface: http://jogamp.org/jocl/www/ Good luck :-)
source share