<< Blog Index

What Amazes You?
April 19, 2020

I don’t remember the question exactly, but during an interview I was basically asked what impressed me. My response wasn’t that great at the time, but after some thought, I think the x86 processor might be a good pick as something which really stands out to me as a marvel of engineering. Some ten years ago, I wrote a handful of x86 assembly just for the hell of it, including a 3D renderer for DOS. Why DOS? Because WHY NOT? I had a desire for suffering. I learned something pretty cool though!

People say that it’s not worth it to write assembly code directly because compilers are so good at optimizing code and producing assembly themselves, but I don’t think that’s true. I mean, I do think that it’s entirely a waste of good time to write assembly code for x86. That’s not something that will ever be practical unless you’re doing some weird kernel shit that needs specific instructions, but as for the compiler doing a better job than a human? Arguably false. I’ve seen some grangey code spit out by a compiler. Compilers have probably improved a lot since I was testing that, but they are still constrained by a handful of language semantics. The assembly coder is not constrained; they have full power over defining exactly what they want of the processor. A computer can’t do that; the computer is just translating. Compare that to a computer translating from one language to another (it’s horrible).

However, here’s where the x86 processor steps in. There are so many pipelines and optimizations in its core, that it essentially DOES NOT MATTER if you try and write the program instructions by hand. It doesn’t matter how you order instructions or how you carefully access memory. It will run at nearly the same speed! This hardware chip is somehow capable of translating its machine instructions into simply ‘work that needs to be done,’ pipelining it all into an efficient execution sequence rather than just dumbly taking the easy route (like processors of yore) which is executing the instructions directly as they are written (and stalling for memory access etc.).

It must have taken a shitload of engineering to have all this implemented at the hardware level, a lot of work from many brilliant minds working together for decades. Yeah, you could say that amazes me.

<< Blog Index