I like dlang but i don't like dub

Ali Çehreli acehreli at yahoo.com
Sun Mar 20 14:51:38 UTC 2022


On 3/20/22 05:27, Adam D Ruppe wrote:

 > So if it just coincidentally happens to be the same code, I'd actually
 > rather copy/paste it than import it.

This is very interesting because it is so much against common 
guidelines. I first read about such copy/paste in a book (my guess is 
John Lakos's Large Scale C++ Software Design book because my next 
example below is from that book.) The author was saying exactly the same 
thing: Yes, copy/paste is bad but dependencies are bad as well.

I was surprised by John Lakos's decision to use external header guards. 
In addition to the following common include guard idiom:

// This is foo.h
#ifndef INCLUDED_FOO_H_
#define INCLUDED_FOO_H_
// ...
#endif // INCLUDED_FOO_H_

He would do the same in the including modules as well:

// This is bar.c
#ifndef INCLUDED_FOO_H_
#include "foo.h"
#endif
// ...

Such a crazy idea and it is completely against the DRY principle! 
However, according to his measurements on hardware and file systems at 
that time, he was saving a lot of build time. (File system's reading the 
file many times to determine that it has already been included was too 
expensive. Instead, he was determining it from the very include guard 
macro himself.)

Those were the first examples when I started to learn that it was 
possible to go against common guidelines.

I admire people like you and John Lakos who don't follow guidelines 
blindly. I started to realize the power of engineering very late. 
Engineering almost by definition should break guidelines.

Ali



More information about the Digitalmars-d-learn mailing list