Worse is better?

via Digitalmars-d digitalmars-d at puremagic.com
Tue Oct 14 00:25:56 PDT 2014


On Tuesday, 14 October 2014 at 01:36:08 UTC, Dicebot wrote:
> Templates are absolutely critical for any new system level 
> programming language for me to even consider it. I had my share 
> of pain emulating those in plain C and don't want to ever do it 
> again.

But maybe you don't really do low level programming then? In 
which areas of low level programming are templates critical? I 
have trouble finding examples where I have used it or seen it 
used for anything non-trivial in performant code.

In theory it is nice to write double/float/fixed-point functions 
once, but in reality you often need to change the algorithms or 
the implementation when moving from double to float if you care 
about performance.

Similarily for datastructures. You can often reduce the number of 
data structure collections needed to implement an algorithm by 
creating a special one that targets the dominant access patterns 
and operations of the algorithm. Or significantly improve memory 
handling. Or significantly improve cache performance.

In fact, when I think about it, you loose a lot when going from 
machine language to a programming language in the first place. 
When coding on a CISC like 68000 (that allows "high level 
assembly") you would structure the data, lookup tables and memory 
address space in a way to fit the problem and the instruction set 
to get performance and tight code.


More information about the Digitalmars-d mailing list