On the future of DIP1000

Walter Bright via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Fri Aug 26 22:57:25 PDT 2016


On 8/26/2016 9:53 PM, Bill Hicks wrote:
> On Wednesday, 24 August 2016 at 15:30:34 UTC, Martin Nowak wrote:
>>  we want memory safe code w/o the GC.
>>
>> -Martin
>
> Rust has had that since day one.  Funny how not too long ago D core was mocking
> Rust,

We've never mocked Rust's safety features, although I have posted that they are 
too complex for D and desire a simpler system.


> but now they're trying to be more like it.

We've had proposals for more safety annotation in D for at least 10 years (from 
Bartosz Milewski), but they've always been more complex than I wanted. DIP1000 
is a much simpler scheme.


> I bet in a few years we'll see hygienic macro system in D.

I seriously doubt it (they've been proposed many times). I haven't studied 
Rust's macro system, but others I've seen (expression templates, user defined 
syntax, CPP, macro assemblers, etc.) are very powerful, but ultimately 
off-putting because it makes code very hard to understand.

For example, Microsoft put a very powerful macro system in their assembler, 
MASM. Programmers went to town with it, each programmer essentially inventing 
their own language that was undocumented and unreadable to anyone else. A 
Microsoft programmer related to me that once he was given the job of updating a 
large assembler program that someone no longer there had written in their own 
invented macro language.

He got it updated and fixed in short order. Surprised, his manager asked him how 
he figured out how it worked, as everyone else who tried had failed.
My friend said he didn't even attempt to figure it out. He assembled it, and ran 
the result through a disassembler (our very own OBJ2ASM) which made it nice, 
readable, and fixable.

An earlier incarnation of myself had also succumbed to the siren song of 
inventing my own assembler language via macros. Over time, I gradually stopped 
using it and reverted to writing vanilla, understandable assembler.

I've seen the story repeated with CPP macros and expression templates, and I've 
heard similar accounts about other macro systems.

Making macros hygienic doesn't fix it.

P.S. I still from time to time use OBJ2ASM to figure out what someone's wretched 
ASM file is doing, like I'll run CPP by itself to see what some miserable CPP 
abuse is actually generating. I've also been gradually removing all CPP use from 
my own C++ code (the dmd back end).

A macro system is like putting a 2000 HP motor in a car. It's sure exciting, but 
ultimately you just don't want it in a daily driver, or anyplace other than the 
track, because it'll kill you.



More information about the Digitalmars-d-announce mailing list