Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Maybe it's just me, but I honestly don't know what this is doing near the HN top. It's more or less literal translation from C.


Possibly because it illustrates that using assembly isn't necessarily the insane scary idea that it first seems to many (like me), even to those that should know better because they have used it in the past (like me).


No, a literal translation is what you get when you write a http server in C and inspect what assembly code it produces for x86.64. Since this assembly code is nowhere close to that output it is not a literal translation.


Only if you use a completley naive compiler, any level of optimisation moves from being a literal translation


No, any correct translation a c compiler produces is, by definition, a literal translation.


No, that simply means that they are semantically equivilant, which is very different to a literal translation. To quote an online dictionary [0], "2. Word for word; verbatim: a literal translation.". Optimisation in compilers is certainly not word for word.

Take a simple problem like the FizzBuzz problem, write it as the simple obvious branching style. Now compile it with GCC or Clang (with -O3) and you end up with lookup table (or at least I did a few months back. Semantically equivalent but not literal "word for word" translation.

[0] http://www.thefreedictionary.com/literal


You are missing that there exists many more than one literal translation for a particular C program to asm. Using your logic a compiler could not produce a literal translation of any program unless its output to 100% matched that of all other compiles for the same program.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: