Super-dee-duper D features

Walter Bright newshound at digitalmars.com
Wed Feb 14 11:12:09 PST 2007


Nicolai Waniek wrote:
> The main problem I have with mixins/templates and so on is that it
> enables a programmer to change the "look and feel" of the language
> completely. What is bad about it? That if you're working in a team
> someone has a "great idea" and invents his own MyDSL. So what? Everyone
> else has to "learn" this new DSL. So they spend time on something they
> would've better spent on coding something else, or fixing bugs... I
> worked in a team of about 8 persons bugfixing a project with
> approximately 1.000.000 LoC. The former programmers just seemed to not
> know how to code (and we programmed using Delphi!!! a language most
> people like to tell you: "oh, that's a language that shows you how to
> work structured" - that's totally bullshit!).
> So on one hand, we had to improve the software as it was used by just
> too many companies to completely rewrite it - on the other hand we had
> to bugfix it with a syntax that even didn't look like Pascal. Now what?
> If we had someone "just for the sake of it" implementing something with
> his MyDSL, i would've probably killed him!

I hear you. I also find most uses C++ templates are put to to be 
incomprehensible - either from programmers showing off, or from working 
around the severe limitations of C++ templates.

Another big part of the problem is that templates are just hard to read 
and understand. If they were as easy to deal with as regular functions, 
then that difficulty would (I hope) melt away. This is what we're 
working towards.

I agree with you on another level - programmers showing off their 
understanding of the language by some need to use every feature of the 
language, MAKING SIMPLE THINGS COMPLICATED. To me, *real* programming 
skill is expressing complicated things in a simple manner.

One of my (unfavorite) examples of the making simple things complicated 
is the simple linked list concept:
	struct Foo
	{	Foo *next;
		...
	}
voila, a linked list. But nooo, for some reason (just for the sake of 
it? <g>), this has to be made complicated, with templates, macros, 
iterators, akk. There's a place for iterators, but they are overused.

My general feeling is that if one feels impelled to generate an 
incomprehensible tangle of templates:

1) one has found the wrong solution to the problem
2) there's a serious deficiency in the language (the C++ attempts to 
implement tuples is a canonical example).

Back in the 80's, C programmers discovered they could turn C code into 
Pascal with:
	#define BEGIN {
	#define END }
and went to town with that. It was belatedly discovered that this was a 
terrible idea. People can abuse mixins and DSLs in D, there's not much I 
can do to prevent it other than hope that soon a general consensus will 
emerge that overuse of it is also a bad idea.

Java went a different route, by disallowing all that stuff completely, 
but they inevitably threw the good out with the bad. Now, those features 
are, one by one, being added to Java anyway.

P.S. I've tried pretty hard to design operator overloading in D to 
prevent the abuses of it often seen in C++. I'm cautiously optimistic in 
this being successful.



More information about the Digitalmars-d mailing list