What is your favorite D feature?

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Wed Jun 21 18:13:43 PDT 2017


On Thu, Jun 22, 2017 at 12:48:25AM +0000, Seb via Digitalmars-d wrote:
> Hi,
> 
> I am currently trying to modernize the D code example roulette on the
> dlang.org front page [1]. Hence, I would love to hear about your
> favorite feature(s) in D.
>
> Ideas:
> - favorite language construct
> - favorite code sample
> - "only possible in D"

Slices!  And preferably in an example where it beats C performance by
not needing to duplicate strings everywhere.

Built-in unittests... ddoc'd unittests!  Though it's hard to think of an
example showing this off that's short enough to work for the roulette.

Sane template syntax. Template alias parameters. Manipulation of
template argument lists.

UFCS.

Compile-time introspection + UDAs.  Loop over a struct defining a set of
program configuration parameters, and generate code for parsing
command-line arguments that fills in the struct based on field
definitions.  (You could just transform the struct members into getopt
arguments, as implementing this from scratch could be a bear... and ugly
to look at. :-D)

std.process making it dead easy to invoke an external program, capture
its output, all without the ugliness of manually dealing with fork(),
execv(), and waitpid().


> Before you ask, yes - I want to add a couple of cool examples to
> dlang.org
[...]

You could search for "your code here" in the forum -- that used to be
the instructions on submitting code examples back before the website was
revamped, and IIRC there have been a handful of suggestions, though
AFAIK none was ever actually added to the roulette.


T

-- 
Those who don't understand Unix are condemned to reinvent it, poorly.


More information about the Digitalmars-d mailing list