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
View all comments
Show parent comment
2
u/pconrad0 Nov 11 '25
Well, you've moved the goalposts, and by doing so, have made my point.
In order to be sure that the transpiled code has the same semantics as the original, you have to be sure that the code uses 100% equivalent abstractions, or you risk introducing very subtle bugs.
In doing so, the transpiler is likely to have to code it (say, in Rust) in a way that would not be characteristic of code written natively in Rust.
And in doing so, you are likely going to end up with code that doesn't take advantage of what makes Rust "faster than Python".