The past, present, and future of optimization

I have a relative ("Dan") who used to earn a living optimizing code in the late 70s and early 80s. Around then, a new-fangled high-level language named "C" was starting to catch on, but companies didn't like all the wasted cycles in C programs due to the under-optimized assembly code that their C compilers were writing.

So Dan would go through and hand-optimize the assembly code to get rid of those wasted cycles and squeeze out every possible lick of performance. He earned quite a decent living at it, until the mid 1980s when the work dried up.

Did his work dry up because machines had grown so fast that companies didn't care about wasted cycles anymore? No, they were just as stingy about their computer resources as they used to be. The reason why the work dried up was because the compilers eventually got so good that the amount of tuning Dan could do was no longer worth the cost.

Today, you can write assembly language that's faster than C, but you really have to know what you're doing if you want to gain much speed — C compilers today are pretty smart. Nowadays, you might drop down to assembly for a really tight loop, where every machine cycle counts, but writing an entire program in assembly is — shall we say — no longer mainstream. 🙂

There's an obvious parallel with Dan's job today: saving machine cycles by rewriting code in very high-level languages like Python and Ruby in faster, lower-level languages.

Certainly, there's still a place for this kind of optimization today. But how long will this still be the general case? It's already true that you have to know what you're doing to beat C# or Java with C/C++. Yes, C and C++ are still faster than C# and Java when you know what you're doing. But simply writing in those languages doesn't guarantee that your code'll be faster (and for simplicity's sake, I'll leave out considerations of automatically versus manually managed memory).

When JIT compiling becomes a reality for Python, it might become true for this language as well. Then we might see ever-diminishing returns on rewriting Python code in lower-level languages.

"Bare metal" programming used to mean assembly language — now it mostly means C. I for one can't wait for the day when "dropping down to the bare metal" means writing Python code!

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>