Hacker News new | past | comments | ask | show | jobs | submit login

Because you're writing code for a computer and sometimes it's expected that you actually care about what the computer is doing with your code.



Again, would you say the same thing about registers versus stack allocation (or heap allocation)?

"The CPU handles it differently" isn't by itself a legitimate argument against abstraction.


This code is converting a bunch of bytes into an integer by bit shifting. So it's specific to the binary representation of ints in your language, and how types of various sizes and signedness interact.

Note that this doesn't depend on your CPU, but rather on how integers and their byte representations are specified in the language.

I think it's quite reasonable to expect the programmer to know what that means assuming they are writing bitfiddling code like this.


None of that argues against abstraction. It's perfectly reasonable to want to write code that uses left bitshift and works on unsigned and signed 8, 16, 32, and 64 bit integers.




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

Search: