Talk on what a systems programming language needs to replace C
russel at winder.org.uk
Thu Sep 5 10:06:03 UTC 2019
On Wed, 2019-09-04 at 16:13 -0700, Walter Bright via Digitalmars-d wrote:
> On 9/3/2019 3:37 PM, Laeeth Isharc wrote:
> > But is it unfair to say D is missing an AST that's pleasant to work with?
> > I'm not sure whether it would be better to construct a parse tree or AST
> > for
> > this purpose but eg with DPP my personal sense is it would be useful to
> > have a
> > way to generate D code at a more abstract level than strings.
> > Anyway if you could translate C to D it surely wouldn't hurt.
> This is essentially what AST macros are, a feature that has been repeatedly
> proposed for D. I've blocked it each time.
> The trouble is, it is incredibly powerful. People find themselves unable to
> resist its siren call, and use it to invent their own language. They never
> bother to document this language. It winds up balkanizing the underlying
> language so they cannot share code or even talk to each other.
This didn't happen in Groovy. AST macros were added, and new language
capabilities ensued and all in all it was agreed that Groovy was better for
AST macros and that they should have been added earlier.
> This doesn't happen overnight, it takes a few years. And then it's too late.
> Some examples:
> 1. Lisp macros
There is not just one Lisp. SBCL, CLisp, and Clojure do things differently but
all do things really rather well.
> 2. Macro assemblers
> 3. C macro preprocessor
> 4. C++ expression templates
5. Groovy AST macros.
> (3) is a bit of an interesting case. The C macros are very limited in
> capability, but that barely slowed down the rush to build crazy
> with it and embed them everywhere.
> I've fallen into this trap myself with both (2) and (3). It took 10+ years
> experience to finally realize what a bad idea it was, as it is an enemy of
> writing understandable, maintainable, reusable, and encapsulated code.
As are almost all programming language features. The lesson from Groovy was to
actively avoid doing stupid things and to trust programmers not to f### things
up. Which they didn't.
> You don't hear much about C++ expression templates these days. For a few
> they were quite the darling, until the scope of the horror became apparent.
> Think of it like when the devil says you can have anything you want. It
> great for a while, but nothing good comes from it.
Dr Russel Winder t: +44 20 7585 2200
41 Buckmaster Road m: +44 7770 465 077
London SW11 1EN, UK w: www.russel.org.uk
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 833 bytes
Desc: This is a digitally signed message part
More information about the Digitalmars-d