

C for speed: Techniques To Transform Your Turtle Code - helwr
http://www.atarimagazines.com/startv5n6/c_for_speed.html

======
RiderOfGiraffes
From 1991. Compiler technology has moved on since then and almost all of these
transformations are done automatically for you. Hence the guideline now is to
write your code to be readable.

Having said that, it's interesting to see what people worried about in 1991,
and worrying that people needed to be told these things.

I was there - I remember it well.

~~~
angstrom
Ironically, what really matters is limiting heap fragmentation and memory
allocation. Not nearly that exciting or tricky.

~~~
neilc
Optimizing to improve cache behavior can still be fairly tricky / counter-
intuitive.

------
bbulkow
I hope this was added as a peculiar historical artifact from 1991, not a
statement of how to best write code today. These tricks don't work with GCC
4.1+ and i86_64.

For example, in the loop section, the good trick now is to make your code
accessible by the GCC vectorizer. If you turn on -fdump-tree-vect-details in
GCC, you will see - for every loop - the weighting factors applied and what
might have blocked the vectorizer's operation. Vectorized computing existed in
1991 - heck, 1969 - but was not commodity like today.

------
1amzave
I dunno...even being from 1991, I had actually assumed this was intended as
humor. Those are all simple enough (if not entirely trivial) optimizations
that it doesn't take a particularly heroic compiler to perform them, even
twenty years ago I'd guess.

Frankly, I got a good laugh out of it (that I thought was intended by the
author).

~~~
loumf
I was thinking something similar. I took a compiler course in college in 1990
and we were required to implement a couple of these optimizations (common sub-
expressions, constant calculations). So I assume that they were considered
easy.

------
chipsy
You can still use many of these techniques if you're programming a dynamic
language like Python and don't want to add the dependency of a C extension
yet. I've unrolled loops, reordered assignments, etc., to good effect.

------
abalashov
-1 for sloppy, unreadable code and poor presentation.

