In general, automatic conversions from one language to another will not be an improvement. Different languages ββhave different idioms that affect performance.
The simplest example is looping and variable creation. In the Java GC world, creating objects with new ones is almost free, and they are just as easily immersed in oblivion. In C ++, memory allocation (generally speaking) is expensive:
// Sample java code for ( int i = 0; i < 10000000; ++i ) { String str = new String( "hi" ); // new is free, GC is almost free for young objects }
Direct conversion to C ++ will lead to poor performance (using TR1 shared_ptr as a memory handler instead of GC):
for ( int i = 0; i < 10000000; ++i ) { std::shared_ptr< std::string > str( new std::string( "hi" ) ); }
An equivalent loop written in C ++ will look like this:
for ( int i = 0; i < 10000000; ++i ) { std::string str( "hi" ); }
A direct translation from one language to another usually ends with the worst of both worlds and it is more difficult to maintain the code.
source share