News for hackers. Stuff that matters.
Re:Why Is C Faster Than Java (2009) by hashmash on Monday December 27, 2021 @12:27AM (#29699615)
> a language x written in language y cannot by definition be faster than language y

A C compiler can be written in Java. Therefore, by "definition", Java is faster than C.

Re:Why Is C Faster Than Java (2009) by silisili on Monday December 27, 2021 @12:30AM (#29699639)
Not correct... because Java could not run that C code.

Whereas Java written in C could run Java code.

Re:Why Is C Faster Than Java (2009) by BenoitP on Monday December 27, 2021 @02:36AM (#29700356)
Java can run C/C++: https://github.com/oracle/graal/tree/master/sulong

What's your point?

Re:Why Is C Faster Than Java (2009) by silisili on Monday December 27, 2021 @02:43AM (#29700387)
Ok. So you're positing that a giant heavy runtime, written in C++, via a library, can then run C++ code faster than...C++? Good luck.
Re:Why Is C Faster Than Java (2009) by BenoitP on Monday December 27, 2021 @05:17AM (#29701195)
It actually really runs slower as is it first an interpreter, and the compiler is yet to be optimized to GCC levels; but is has a great compiler infrastructure that could eventually JIT to faster code (it being a runtime compilation, that has statistics, and Graal being capable of partial evaluation)

I was merely pointing at a hole in your argument: the language of the compiler has absolutely no influence in the quality of it's output (again: the JVM compiles to assembly, not to C++).

A compiler written in brainfuck could write code that is more performant than gcc does.

The language does have an influence on compilation speed, though. But that matter in your argument?

Re:Why Is C Faster Than Java (2009) by kaba0 on Monday December 27, 2021 @06:46AM (#29701678)
Actually that can indeed be possible — have a look at Futamura projections.

Also, there are AOT compilers that can make use of profile information.

Re:Why Is C Faster Than Java (2009) by hashmash on Monday December 27, 2021 @12:34AM (#29699667)
That's not the statement you made. A safer statement would be, "a simple interpreter for language x, implemented in language y, cannot be faster than language y".
Re:Why Is C Faster Than Java (2009) by silisili on Monday December 27, 2021 @12:38AM (#29699701)
My statement is that language speed comparisons are stupid, but if you're willing to make one, you cannot beat the language you're written in. That's like saying Shakespeare writes better stories than...English.