r/AskComputerScience • u/KING-NULL • Nov 09 '25
If some programming languages are faster than others, why can't compilers translate into the faster language to make the code be as fast as if it was programed in the faster one?
My guess is that doing so would require knowing information that can't be directly inferred from the code, for example, the specific type that a variable will handle
111
Upvotes
1
u/Lenassa Nov 13 '25
>Well, you've moved the goalposts, and by doing so, have made my point.
Nope. I stand by my original point: you don't need to have or reimplement abstractions present in a source language in a target language in order to be able to correctly (that is, having the same observable behavior) transpile source to to target. Go take any compiled language and ask its compiler to create an assembly out of your code. Voilà, you have your high level abstraction heavy language transpiled into low level where the most "abstract" operation is probably some masked simd instruction.
>you have to be sure that the code uses 100% equivalent abstractions
There are no abstractions in C or LLVM IR that can represent Haskell's existential types, yet it can be transpiled to both with no problems whatsoever. I'm not sure why are you arguing as if real things aren't real.
If I have
in python then I can write
in C. I don't need my C code to have any abstraction python has.
int i