D Programmer Jobs at Sociomantic Labs

H. S. Teoh hsteoh at quickfur.ath.cx
Tue Nov 5 10:23:15 PST 2013


On Tue, Nov 05, 2013 at 11:05:40AM +0100, Chris wrote:
[...]
> If someone doesn't know assembly, this book might help "Write Great
> Code, Volume 2: Thinking Low-Level, Writing High-Level".
> 
> http://www.amazon.com/Write-Great-Code-Volume-High-Level-ebook/dp/B008Z6ASGC/ref=sr_1_2?ie=UTF8&qid=1383644591&sr=8-2&keywords=thinking+low+level
> 
> At least one can get an idea of what's going on under the hood. My
> old man was programming with assembly for a while and told me that
> the suicide rate among assembly programmers was quite high.

I'm not surprised. Assembly programs tend to explode in complexity
exponentially as code size increases. You can only go so far before the
whole thing becomes unmanageably complex, at which point the only way to
continue is to start fixing calling conventions, naming conventions,
data structure storage formats, etc., i.e., reinvent C.


> He also told me about the rule of diminishing returns*. If with well
> written C program you can get 90% of assembly's performance, leave
> it at that. If you wanna get the remaining 10% and use assembly
> instead, the cost of it may not be worth the returns.
[...]

Well yes. My point was not to force students to write *all* their code
in assembly, but to give them some experience in writing small(!)
assembly programs so that they get a taste of how the machine actually
works under the hood. Once they have that down, I'd move straight on to
a nice high-level language like D, because in 90% of the code you write,
you don't *need* the kind of performance direct assembly coding gives
you.

That's why GCC has inline assembly extensions, and D has built-in asm
blocks: for the most part, you just write in high-level D, but for the
few bits of performance-critical code, you have the option of directly
writing in assembly.

Writing *everything* in assembly is a big waste of time, because 90% of
your code isn't part of the performance bottleneck, so you're just
making yourself suffer the tedium of assembly coding for basically zero
benefit. By writing the non-critical parts of the code in a high-level
language, you get huge savings on your development cost, but in the 10%
of the code where performance actually matters, writing in assembly can
win you huge performance gains.

The same argument goes for the GC: 90% of applications out there don't
*need* manual fine-tuning of manual memory management; you can save so
much development time (and debugging effort!) just by using the GC
instead. It's only the 10% of applications that absolutely need
performance guarantees, where you actually need to worry about manual
memory management.


T

-- 
People tell me I'm stubborn, but I refuse to accept it!


More information about the Digitalmars-d mailing list