I would ask a question regarding compilers, specifically how they work. I would believe that compilers would always compile to the same machine code for code that is written differently syntactically but does the same thing. Is this true? Does functionally similar code get compiled to the same result regardless of syntactical differences?
for example:
int number = 2;
would compile to the same thing as:
int number;
number = 2;
or that
while True:
would be the same as (i’m using python here as an example):
while 1:
I am particularly interested in the .net compilers and interpreters. does the JIT compiler compile “in time” to the same thing every time? Do interpreters like the Python interpreter “interpret” the code code exactly the same every time?
thanks!
would compile to the same thing as:
Probably but not certainly. NB in many languages the declaration doesn’t generate any code at all.
or that for
would be the same as:
Certainly not! Different semantics!
NB this is not an ‘efficiency’ consideration.
Now you seem to be asking a completely different question. The same source code is always compiled the same way, modulo JIT effects, and interpreted the same way. Computers are deterministic.