Code example on www.d-programming-language.org?

Daniel Gibson metalcaedes at gmail.com
Mon Apr 4 18:17:06 PDT 2011


Am 05.04.2011 02:52, schrieb spir:
> On 04/04/2011 11:02 PM, bearophile wrote:
>> Andrei:
>>
>>> We have a rather aged code example on www.d-programming-language.org.
>>> What would you think would be a good replacement? The ideal snippet
>>> would make a compelling tour of the language's and stdlib's most
>>> important features while at the same time being simple and concise.
>>
>> If you try to cram most features in a simple small program you end
>> with something that looks like a little Christmas tree. I don't think
>> this is a good advertisement for D.
>>
>> On the rosettacode.org site there are many ways to implement the D
>> solutions. The C solutions are often not much general, and too much
>> low level. The C++ solutions are often over-engineered,
>> over-generalized, and sometimes not easy to understand. The Go
>> solutions are sometimes too much simple. A good D solution is quite
>> short and to the point, simple, at the level required to solve the
>> task, not too much slow, not too much optimized, very easy to read,
>> easy to understand, not too much specific but not even too much
>> generalized. Sometimes solutions in other languages are tagged as
>> derived from the Python and D solutions, this means the D code was
>> readable enough, this is how very publicly visible D code has to be.
>> Readability first, generality but not too much of it, low level when
>> necessary, high level when possible. It's a matter of style. People
>> run away from C++ because sometimes it has an image of a messy and
>> over-engineered language. I suggest to avoid this trap in D c
> ode that everyone sees.
> 
> Very well stated. The one example to find (one only, for the home page)
> is thus one piece of code shows clearly shows the *differential*
> advantage(s) of D over well known programming languages. Else, it's
> useless.
> 
> Denis

Maybe it's sufficient to show just *some* cool features/differences in
the greeter example.
I'd suggest:
 * slicing (could also show that arrays have a length)
 * some easy template-stuff
  - we allow types as parameters (of course), but also values
  - static if
 * scope guards
 * maybe closures (delegates)?
 * /what else?/

Cheers,
- Daniel


More information about the Digitalmars-d mailing list