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

(Edit: I just noticed (yes, I am slow) that you were probably referring to code written by a human for educational purposes. Sorry for the misunderstanding)

> One thing is reading assembly language written by a human, another thing is reading assembly language generated by a compiler. Compilers are insane, especially when you turn on optimizations.

In my experience, it's the opposite. Compiler-generated code has a very homogeneous global structure that is easy to understand even if the compiler does complex stuff on instruction level. Human-written code does things that force me to be permanently on my guard concerning the control flow and the meaning of data, and I am not even talking about code (like malware) designed intentionally to be confusing. Examples from computer games:

- Calling a function X and directly wanting to jump to another function Y afterwards by first pushing the address of Y on the stack, then call X. Sometimes combined with a jump into the middle of another function.

- Manipulating stack frames, accessing local variables of the caller function, etc.

- Using the same location in memory to store completely different data types (imagine a C program using unions everywhere, even for a simple counter variable)

- Organising data on bit level

- Something extremely popular in older games: Collection types with non-uniform elements. Imagine a kind of array or list where some elements are 4 bytes long and some are 6 bytes.



Something extremely popular in older games: Collection types with non-uniform elements. Imagine a kind of array or list where some elements are 4 bytes long and some are 6 bytes.

There's this really funny reaction from the audience when Mike Acton suggests writing different types of scene graph nodes to a void* to avoid unnecessary padding which would pollute the data cache. One of the Q&A questions at the end utters its distaste for it cause it's using void instead of proper types.

It's the objectively better solution in terms of performance, but it's just too yuck for many people.

https://www.youtube.com/watch?v=rX0ItVEVjHc


There is no plan for human as long as it works.




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

Search: