r/learnjava • u/IIwarrierII • Nov 03 '20
Why is c faster than java?
If I were to make the same thing in java would it now be as fast ?
58
Upvotes
r/learnjava • u/IIwarrierII • Nov 03 '20
If I were to make the same thing in java would it now be as fast ?
79
u/gtrley Nov 03 '20
Whoops thought i replied but made a whole new thread
Edit: pasted response below :)
Faster than python since you're running a pre-compiled program vs interpreted as you go, but C is going to be compiled specifically for the platform you run it on, where Java is more half-compiled, then the JVM does final translations to the platform
This is why Java is "write once run anywhere" and C is not. I.e. if i wanted to run a C program on say, a linux machine, then later decide I want to run it on windows, I would need to recompile it, where with Java I compile a .class file and I can run that on any system with a JVM