June 22, 2017
	"friendship ".writeln = ((_) => "is"~_)(" magic");


	"friendship ".writeln = ((_) => "is"~_)(" magic");

just couldn't resist the temptaion, sorry.
June 22, 2017
On Thursday, 22 June 2017 at 00:48:25 UTC, Seb 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"
>
> Before you ask, yes - I want to add a couple of cool examples to dlang.org (and yep the roulette rotation is currently broken [2]).
>
> [1] https://github.com/dlang/dlang.org/pulls?q=is%3Apr+is%3Aopen+label%3A%22Frontpage+example%22
> [2] https://github.com/dlang/dlang.org/pull/1757

These: https://p0nce.github.io/d-idioms/
June 22, 2017
On Thursday, 22 June 2017 at 00:48:25 UTC, Seb 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"
>
> Before you ask, yes - I want to add a couple of cool examples to dlang.org (and yep the roulette rotation is currently broken [2]).
>
> [1] https://github.com/dlang/dlang.org/pulls?q=is%3Apr+is%3Aopen+label%3A%22Frontpage+example%22
> [2] https://github.com/dlang/dlang.org/pull/1757

Being a GC enabled systems programming language, following the footsteps of Mesa/Cedar and Modula-3.
June 22, 2017
Lack of verbosity.

Clear concise code, thanks to the automatic initialization of class members, native strings/arrays/maps/slices, UFCS, declaration-order independence, etc.

class TOTO
{
    bool IsCool;
    int Age;
    TUTU[] Tutus;
    TOTO[string] Totos;

    void Foo( TUTU tutu )
    {
        Tutus ~= tutu;
        Totos[ tutu.Name ] = tutu.Toto;
    }
}

class TUTU
{
    string Name;
    TOTO Toto;

    this( string name )
    {
        Name = name;
        Toto = new TOTO;
    }
}

void Bar(
    ref TOTO toto
    )
{
    toto.IsCool = !toto.IsCool;
}

void main()
{
    TUTU tutu;
    TOTO toto;

    tutu = new TUTU( "tutu" );

    toto = new TOTO;
    toto.Foo( tutu );
    toto.Bar();
}

Absolutely no syntactic noise !!!

This is often overlooked, while D easily beats all its direct competitors (C++, Java, C#, etc) on that point.

Just try to implement the same code as simply in C++ and you will be convinced that this is D's strongest feature...

And this is also what makes D feel like a super-powered JavaScript when I use it :)

June 22, 2017
On Thursday, 22 June 2017 at 06:27:11 UTC, Ecstatic Coder wrote:
> Absolutely no syntactic noise !!!
>
> This is often overlooked, while D easily beats all its direct competitors (C++, Java, C#, etc) on that point.
>
> Just try to implement the same code as simply in C++ and you will be convinced that this is D's strongest feature...
>
> And this is also what makes D feel like a super-powered JavaScript when I use it :)


Thanks a lot, but I was looking for small snippets (< 10 LoC) than could be used to show the awesomeness of D at the roulette on https://dlang.org
Any chance you could make your point a bit conciser? :)
June 22, 2017
On Thursday, 22 June 2017 at 06:02:54 UTC, bauss wrote:
> On Thursday, 22 June 2017 at 00:48:25 UTC, Seb 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"
>>
>> Before you ask, yes - I want to add a couple of cool examples to dlang.org (and yep the roulette rotation is currently broken [2]).
>>
>> [1] https://github.com/dlang/dlang.org/pulls?q=is%3Apr+is%3Aopen+label%3A%22Frontpage+example%22
>> [2] https://github.com/dlang/dlang.org/pull/1757
>
> These: https://p0nce.github.io/d-idioms/

Hehe, I know about p0nce's great work, but I was asking for _your_ favorite D code snippets ;-)
Is there any idiom that you like in particular or think it's a good "show-off"?
June 22, 2017
On Thursday, 22 June 2017 at 06:08:07 UTC, Paulo Pinto wrote:
> On Thursday, 22 June 2017 at 00:48:25 UTC, Seb 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"
>>
>> Before you ask, yes - I want to add a couple of cool examples to dlang.org (and yep the roulette rotation is currently broken [2]).
>>
>> [1] https://github.com/dlang/dlang.org/pulls?q=is%3Apr+is%3Aopen+label%3A%22Frontpage+example%22
>> [2] https://github.com/dlang/dlang.org/pull/1757
>
> Being a GC enabled systems programming language, following the footsteps of Mesa/Cedar and Modula-3.

Yes :)
... but how do we turn this into an example snippet with < 10 LoC?
(I should have been a bit clear on what I was looking for, sorry).
June 22, 2017
On Thursday, 22 June 2017 at 01:00:42 UTC, Mike wrote:
> Beginning with most favorite:
>  - CTFE
>  - static if - If you don't consider that part of CTFE
>  - Template Mixins
>  - Templates - Pretty much goes along with the top 2
>  - String Mixins
>  - Unit Tests
>
> DIP1000 may make that list too, if I ever get around to trying it out.

Nice list, but I was actually looking for more concise, actionable snippets or idea(s) for such.
I should have made this clearer. Sorry.
For some I have already submitted PRs - the other are still missing a good "WoW" snippet. Ideas?

>  - CTFE

-> https://github.com/dlang/dlang.org/pull/1758


>  - static if - If you don't consider that part of CTFE

Do you know a more concise example than my commonPrefix one from the Tour?
https://tour.dlang.org/tour/en/gems/traits

>  - Template Mixins
TBD
>  - Templates - Pretty much goes along with the top 2
TBD
>  - String Mixins

-> https://github.com/dlang/dlang.org/pull/1762

>  - Unit Tests
TBD
June 22, 2017
On Thursday, 22 June 2017 at 07:10:14 UTC, Seb wrote:

> Nice list, but I was actually looking for more concise, actionable snippets or idea(s) for such.

There are some real gems in this DConf Talk: https://www.youtube.com/watch?v=yMNMV9JlkcQ

I started enumerating them on the Wiki here (https://wiki.dlang.org/Tutorials#Design_Patterns) but alas it's still incomplete.

Mike
June 22, 2017
On Thursday, 22 June 2017 at 00:48:25 UTC, Seb 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"
>
> Before you ask, yes - I want to add a couple of cool examples to dlang.org (and yep the roulette rotation is currently broken [2]).
>
> [1] https://github.com/dlang/dlang.org/pulls?q=is%3Apr+is%3Aopen+label%3A%22Frontpage+example%22
> [2] https://github.com/dlang/dlang.org/pull/1757

H. S. Teoh calendar: https://wiki.dlang.org/Component_programming_with_ranges

/**
 * Formats a year.
 * Parameters:
 *  year = Year to display calendar for.
 *  monthsPerRow = How many months to fit into a row in the output.
 * Returns: A range of strings representing the formatted year.
 */
auto formatYear(int year, int monthsPerRow)
{
    enum colSpacing = 1;
    return
        datesInYear(year) // Start by generating all dates for the given year
        .byMonth() // Group them by month
        .chunks(monthsPerRow) // Group the months into horizontal rows
        // Format each row
        .map!(r =>
                r.formatMonths() // By formatting each month
                 .array() // Storing each month's formatting in a row buffer
                 // Horizontally pasting each respective month's lines together
                 .pasteBlocks(colSpacing)
                 .join("\n"))
        // Insert a blank line between each row
        .join("\n\n");
}