Verbosity in D

TTK Ciar ttk at ciar.org
Mon Aug 8 00:40:11 UTC 2022


On Monday, 8 August 2022 at 00:11:33 UTC, pascal111 wrote:
> I don't have specific code but it was a general notice. Take 
> Python as in example, the same program in Python doesn't cost 
> much code as D code, and of course by putting in accounts that 
> that I assume that there are some special tasks D can do, while 
> Python can't do.

There is definitely a spectrum of programming language practical 
expressiveness (the opposite of verbosity), with the dynamic 
languages (python, perl, ruby) on the "most expressive" end, and 
static languages (C, C++, Java) on the "most verbose" end.

D is somewhere in the middle of that spectrum, much more 
expressive than C but not as expressive as python.

The trade-off is much better run-time performance and lower 
memory overhead compared to the dynamic languages.

I've been writing C, Perl and Python for a living for a while, 
following the common practice of writing a solution in Perl or 
Python first, for shortest possible development time, and then 
rewriting performance-intensive bits in C when more performance 
is needed.

The appeal of D, to me, is that it gives me something akin to the 
same approach with just one language.  I can write very concise, 
expressive D when performance doesn't matter, and then write more 
verbose C-like D when I need C-like performance, all in the same 
source file, with the same language.

Having a sane and useful threading model is an added bonus.  
Neither python nor perl nor nodejs have useful threads, whereas D 
gives us real, concurrent threads with a fraction of the 
boilerplate -- 
https://tour.dlang.org/tour/en/multithreading/synchronization-sharing

On the other hand, I've noticed that D's idiomatic brevity can be 
diluted by the extremely verbose function names used in the 
standard library.  Sure, foreach loops can be just as concise as 
python's -- foreach(i; arr) -- but then you end up getting carpal 
tunnel syndrome anyway from typing out  
"AllImplicitConversionTargets" or "filterBidirectional" or 
"levenshteinDistanceAndPath".

My impression is that brevity is more important to the language 
developers than it is to the phobos developers.


More information about the Digitalmars-d-learn mailing list