r/AskComputerScience • • 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

90 comments sorted by

View all comments

Show parent comment

1

u/tobiasvl Nov 10 '25

Ok then, give me a script in python (aka not more than a few hundred lines) and I'll give you the rust

Anyone can rewrite a small Python script in Rust. You don't need AI for that. I guess we're not allowed to import any Python libraries either?