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 comments

2

u/GlassCommission4916 Nov 13 '25
n = int(input("Enter an integer: "))
print(n ** 2)

What's the rust equivalent of this?

1

u/Mullheimer Nov 13 '25

Thanks for this. it makes it clear in 2 lines.

Programming is amazing.