Ada Outperforms Assembly: A Case Study
seas.gwu.edu
seas.gwu.edu
From the article it describes the ADA programmer as: "This developer had very limited Ada experience, having written only one Ada program, consisting of approximately 5000 lines of code, while working for a previous employer."
One of the key points of the article is that the code produced by the inexperienced ADA developer beat the experienced Assembly developer. I think a lot of people will struggle with this (because they think "well, logically the code gets turned into assembly anyway when it is compiled, so a sufficiently advanced assembly programmer _must_ be at least as good as a compiler), but the same claims (high level languages beating assembly) have been floating around for years.
In this case study at least, jumping straight to assembly (for size/performance reasons) turned out to be a premature optimisation of the sort we should avoid.
The Ada compiler was written for that processor. That could make a big difference. For example, starting every function on a mod 16 boundary can be a big win on some architectures.
A smart compiler can remember and apply a number of optimizations far greater than I would be able to remember. The weirder the processor, the better. A really smart development tool could even benchmark variations to find the best one.
My 6502 assembly code was much better than what the Aztec C compiler could spit, but the 6502 was a sweet processor to program. DSPs (as GPUs, BTW) are anything but sweet.
And, BTW, I wouldn't try to hand tune assembly code with a modern x86 even if my life depended on it.
Writing fast modern x86 assembly is often way easier than for most any other CPU because instruction ordering generally doesn't matter much as a result of OOE (outside of Atom, at least). This basically lets you BS together a function without thinking too hard about anything other than the individual instructions.
It's trivial to beat the performance of typical C code by a factor of 10-20 in many situations, particularly in the case of DSP functions, as per the topic.
Some typical cases (measured in cycles):
8x8 iDCT, 16-bit input to 8-bit output:
add8x8_idct8_c: 779
add8x8_idct8_sse2: 56
6-tap interpolation filter, 8-bit input, 16-bit intermediate, 8-bit output:
hpel_filter_c: 13093
hpel_filter_ssse3: 1770
Bilinear downscaling filter, 8-bit input, 8-bit output:
lowres_init_c: 16308
lowres_init_ssse3: 672
4 SAD comparison operations on 16x16 8-bit pixel blocks, unaligned input:
sad_x4_16x16_c: 1873
sad_x4_16x16_sse2: 95
Variance on 16x16 block, 8-bit input:
var_16x16_c: 536
var_16x16_sse2: 59Rick James, now at Yahoo, was the king of assembly. He wrote a character move library that was faster than the character move hardware, $100K add-on. He kept getting poached from my projects, because, even at CDC, there weren't many as good as he was.
Then there is the productivity issue. The HLC programmer can produce 10x the number of instructions more than the assembly programmer.
But anyone who programmed CDC supercomputers gets some serious geek points for that.
To make a programming analogy, a DSP is like a domain specific language. It is more efficient and easier to use when used in that domain.
The professor who wrote the Ada 95 book would give us cash as we found logical or typographical errors in the book.
Not sure if there are any other universities that push Ada so hard in intro classes. Perhaps this has changed now.
Any recent GWU compsci people care to comment?
Ultimately I felt it was not such a fair deal for the students. Over 50% of grad CS WVU students were non-US, so they would never get to work on these Defense related stuff due to sec-clearance. Ada was also touted as a successful example of design-by-committee, which I found quite nauseating.
Are there currently any decent developer jobs in WV? I would love to move to the Greebrier County area.
Montani Semper Liberi
EDIT: Reconsidering. Ada pushes you toward the waterfall development process which can be dangerous for newbs to internalize.
Would you recommend it to others?
I initially wrote out a very long description of GW before I realized you had attended. So shortened considerably:
I went to grad school at U of Michigan and have come to the conclusion that most colleges/universities are basically the same. For such an important decision with such wide-ranging consequences, where you go to school is relatively hard to screw up. Undergraduate education is mostly foolish and cult-like behavior--Go Blue!--in a pretty setting where you can find an education and lifelong friends if you look for them. When people recommend a school they are usually recommending the cult. I went to Freshman orientation on my 18th birthday. I had been away from home a week and living down the street from the State Department and the White House when the Pentagon went boom. GW was my training ground for adulthood. The experience is so integral to who I am, to recommend it feels a bit odd.
It was before Thurston had an ethernet network. All of the other dorms seemed to have direct fiber and media converters.
1300 people in a 9 story building. Especially fun, when a block from the dorm, somebody ran over a fire hydrant, and the water supply had to be shut off for several blocks, including Thurston (there were no tank toilets). 8 hours of clogged toilets on every single floor, including the public bathrooms and study lounges.
...or the false fire alarms, where all 1300 students evacuate from only two sets of stairwells.
...or when facilities management decides it is warm enough to enable air conditioning.
Good memories. I have more, but this is enough for now.
Why do you say that? We use ada with spiral development.
The language is amazing. Most of my errors are related to copy-paste oversights (Message_1 instead of Message_2). The typing is very elegant.
Also, Java stole Ada's way of handling exceptions. Instead of try catch you have begin/exception.
It's a shame so few people use Ada. They recently converted GNAT (a free Ada compiler and a very good one) to work with lego mindstorms. It's still big in safety critical areas (transport systems - the trains in europe run ada and lots of avionics code is in ada, the medical field and if I hear correctly banks sometimes use it as well).
It takes longer to get it to compile but having no array indexing errors is so worth it.
EDIT: That said, the last thing I expected to see scanning the HN headlines today was something from gwu.edu :-P
IS this the book you guys used?
We wrote program in language X and then rewrote it in language Y, so Y is better language than X, because our program is much better after rewrite.
The article highlighted common sub-expression elimination too, which again can be done manually. But (and this is the crux IMHO) writing optimal code continuously at this level is mentally tiring (leading to bugs) and often gives brittle unmaintainable code. A compiler never needs to worry about this as it generates fresh code every time rather than maintaining the code from the last build. But a human will learn to avoid brittle code and hence won't be able to take advantage of the possible optimisations.