What is the right level of abstractions for D?
Joakim via Digitalmars-d
digitalmars-d at puremagic.com
Wed Oct 26 23:22:03 PDT 2016
I noticed that Richard Gabriel, one of the designers of Common
Lisp, is on the committee for the new <Programming> conference
that Andrei mentioned here, so I went back and checked out his
website again: http://dreamsongs.com. I mentioned his famous
"Worse is better" essay here a couple years ago:
http://forum.dlang.org/thread/wpyswlvwhmhoutqdwcmo@forum.dlang.org
He has an out-of-print 1996 book of essays up on his site, called
Patterns of Software. I started reading it, pretty good so far.
Here is a snippet worth thinking about from pages 19-20:
"Abstractions must be carefully and expertly designed, especially
when reuse or compression is intended. However, because
abstractions are designed in a partic-
ular context and for a particular purpose, it is hard to design
them while antici- pating all purposes and forgetting all
purposes, which is the hallmark of the well- designed
abstractions.
This implies that abstractions are best designed by experts.
Worse, average programmers are not well-equipped to design
abstractions that have universal usage, even though the
programming languages used by average programmers and the
programming language texts and courses average programmers read
and attend to learn their trade emphasize the importance of doing
exactly that. Although the designers of the programming language
and the authors of texts and course instructors can probably
design abstractions well, the intended audience of the
language—average programmers—cannot and are therefore left out.
That is, languages that encourage abstraction lead to less
habitable software, because its expected inhabitants—average
programmers working on code years after the original designers
have disappeared—are not easily able to grasp, modify, and grow
the abstraction-laden code they must work on.
Not everyone is a poet, but most anybody can write usable
documentation for small programs—we don’t expect poets to do this
work. Yet we seem to expect that the equivalent of poets will use
high-level programming languages, because only program-poets are
able to use them. In light of this observation, is it any wonder
that abstraction-poor languages like C are by far the most
popular and that abstraction-rich ones like Lisp and Smalltalk
are niche languages?"
Of course, this completely ignores the fact that the abstractions
are not costless, ie Smalltalk will usually be much slower than
C, but he does mention C++ and its attempt at much lower-cost
abstractions in an earlier chapter.
This is something D people have to think heavily about, as the
market for programming languages has split into at least three
groups since he wrote that more than two decades ago:
1. low-level compiled languages like C++, D, Rust, and Swift,
meant for performance and usually experts who want to squeeze it
out
2. mid-level bytecode languages like Java and C#, meant for the
vast middle of day-to-day programmers to crank out libraries and
apps that perform reasonably well
3. high-level "scripting" languages like Ruby and Python, meant
for those who don't care too much for performance but just want
to get working code
I think D is positioned somewhere between 1 and 2, though closer
to 1. However, there is sometimes talk of using D for all three,
though perhaps that is only meant as an added benefit for people
already using it for 1 or 2, ie those who already know the
language better.
I have the impression that the recent @nogc and C++ push means
that a concerted effort is being made to go more after 1. Some
thought needs to be put into which of those groups D is going
after and whether it's possible to go after more than one of
those groups today.
More information about the Digitalmars-d
mailing list