Possible solution to template bloat problem?

Ramon spam at thanks.no
Tue Aug 20 11:25:59 PDT 2013


Thank you very much, H. S. Teoh

That was an excellent post, very helpful and constructive. Thank 
you!

I'm, btw. not opposed to templates and I see perfectly well that 
a compiler is in a better position to handle them than an editor.
I also agree that sometimes I will gladly use templates rather 
than real generics.

My main point wasn't anti-D (although I still don't like to 
advertise generics when actually delivering templates and 
mechanisms to implement generics oneself) but a completely 
different one:

Sometimes I just want (or feel needing) to go fully OO and, at 
the same time, have the compiler take care of the nitty gritties. 
This, in fact, is a rather humble position; I have learned in 
many years that, no matter how smart we are, we introduce bugs 
and problems into our code because we are humans. I've learned 
the hard way that there are things computers simply do better and 
more diligently than we humans.

And there is another point.

Nowadays, we happily use gigantesque GUI systems, we gladly put 3 
config parameters into an XML file and we happily consider 600k 
lines sorce code adequate for, say, an audio player based on some 
insane gobject system ...

On the other hand we do have serious qualms to increase program 
size by, say, 5% in an application that typically runs on a 4 
core processor with 8GB RAM. This strikes me as ... uh ... 
strange.

And we *do get* something, possibly something vital, for those 5% 
code size increase, namely code that is easier to understand and 
to maintain, easier to extend and less buggy.

I'm not sure that Prof. Meyers no compromises attitude is always 
good. After all, life is a series of trade offs and compromises. 
I am, however, pretty sure that template systems tend to be messy 
and complicated - and therefore bound to be error prone.

25 years ago I would have defended any weirdness; the harder and 
stranger the better. Meanwhile I have learned that readability 
often is considerably more important than ease of writing and 
that some compromises seem cheap but turn out to be very 
expensive later on.

Last but not least, there are hundred (thousands?) of more or 
less compromise type languages out there. That wasn't what I was 
looking for.

Thanks to your friendly, patient and constructive answer I'm 
feeling that while D isn't perfect it's quite close to it and, 
more importantly, it at least offers  guys like me what I 
consider important, if at a price. So what.

So, again: Thank you very much - Ramon


More information about the Digitalmars-d mailing list