Not so long ago I was told by a senior academic that, these days, VM-based code
ID: 655502 • Letter: N
Question
Not so long ago I was told by a senior academic that, these days, VM-based code could run nearly as fast as compiled code, but my own experience is that compiled code runs several orders of time faster.
This is based on code attempting to do the same thing (processing a very large XML file) - in the case of the VM-based code (Groovy) I guess my code would complete in about two years (correct) whereas the C/C++ based alternative took about three hours.
The algorithms were not quite the same - but that was because using C/C++ allowed me to manipulate the memory at a byte level using pointers. The Groovy code was easier to write as the language was much more expressive, but the price paid was slow execution.
I don't claim to be the world's greatest coder so I would willingly accept that my code could have been improved: but what is the general view?
Explanation / Answer
Actually, Google published a paper around two years ago about this topic which describes what you have noticed here. C++ programs allow typically more optimizations than programs written in languages like Java/Scala/Go (or in your case Groovy), which gives more opportunities to make them faster - but for the price of increased programming effort.
Said that, a speed factor of >5000 is to my experience very unusual. A factor between 2 to 20 is what I have noticed in the past (depending on the problem and the "other language" to be compared with C++). Such a factor indicates that there is a good chance of optimizing your Groovy program by at least one or two orders of magnitude without changing the language. www.stackoverflow.com would be the place to discuss certain optimization issues (provided you are willing to post some core parts of your code there).
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.