August 30, 2016
On Tuesday, 30 August 2016 at 13:34:05 UTC, Adam D. Ruppe wrote:
> On Tuesday, 30 August 2016 at 11:29:45 UTC, John Burton wrote:
>> As I said not really a complaint ... But it d make me think d was too high level a language with too much 'magic' . Other people will have different opinions
>
> Indeed, I'm not a fan of that example either...
>
> but we could turn this weakness into a strength: have two side-by-side implementations and emphasize that the same language handles both styles.

another way is to fulfill the FAQ page with questions and answers from the forum so newbies could first read the page before thinking and asking what others thought and asked before))) but then the FAQ page must reside as a link in the header, e.g. between "Learn" and "Documentation" and forum must state: "first look at FAQ then ask question" like the way on StackOverflow.com
August 30, 2016
On Tuesday, 30 August 2016 at 13:42:21 UTC, eugene wrote:
> i think it will lead to something like: "Why do they have different examples for the same thing?"

<h1>D is multi paradigm:</h1>
<code> C style example </code>
<code> functional style example </code>

<p>With D, your existing expertise carries over from C while opening doors to new stuff.</p>

<hr>


<h1>D is whatever</h1>
<code> example reinforces header </code>

<p>Explanation here. <a href="federalnetwork">Would you like to know more?</a></p>



that's how I'd do it, the code and surrounding text reinforce each other.
August 30, 2016
On 08/30/2016 01:50 PM, John Burrton wrote:
> This is why the example on the front page put me off for a long time :-
> 
>     stdin
>         .byLineCopy
>         .array
>         .sort!((a, b) => a > b) // descending order
>         .each!writeln;
> 
> It makes the language look like some weird high level functional language where you don't ask how it works and you shouldn't care how it maps to the machine instructions and memory.

On a related point I think it is important to emphasize that such pipelines are cool not because they look high-level but also because with decent inlinining compiler (LDC/GDC) they generate as efficient code as for hand written C style implementation based on loop.

There are plenty of languages that allow similar kind of high level programming but it usually comes with considerable overhead, contrary to D.

Though this specific is not very good as it requires lot of allocation by the algorithm used. My favorite short snippet I commonly use when evangelizing D is splitting stdin by whitespaces:

void main ( )
{
    import std.stdio, std.algorithm, std.uni;

    stdin
        .byLine // note that no byLineCopy is needed here
        .map!(line => line.splitter!isWhite)
        .joiner
        .each!writeln;
}

It is 100% Unicode correct, does not allocate any memory garbage and does exactly what told to do while being orders of magnitude more readable than any C style loop version one can come up with.



August 30, 2016
On 08/30/2016 03:56 AM, Markus wrote:
> On Monday, 29 August 2016 at 14:31:50 UTC, eugene wrote:
>> On Monday, 29 August 2016 at 12:11:34 UTC, Markus wrote:
>>> Take a look on this discussion thread and you know WHY D IS NOT SO
>>> POPULAR.
>>>
>>> The community discusses technical details and compares D to C++, but
>>> there is no clear mission statement, there is no vision statement...
>>>
>>
>>
>> Hello,
>> the url https://dlang.org/overview.html states that "It's a practical
>> language for practical programmers", i think this is the vision
>> statement)))
>
> Take a look on https://dlang.org/ : "D is a systems programming language
> with C-like syntax..."
>
> The overview-page http://dlang.org/overview.html has two main sections
> which compares D with C++.

I think we'd do good to avoid explicit comparison with specific languages, within reason. Focusing on what makes D unique and interesting across _all_ languages on the landscape is a much more fertile approach.


Andrei
August 30, 2016
On 08/30/2016 06:50 AM, John Burrton wrote:
> This is why the example on the front page put me off for a long time :-
>
>     stdin
>         .byLineCopy
>         .array
>         .sort!((a, b) => a > b) // descending order
>         .each!writeln;

Sadly if this doesn't float your boat you're unlikely to enjoy most of what D has to offer. -- Andrei

August 30, 2016
On 08/30/2016 10:04 AM, Adam D. Ruppe wrote:
> <code> C style example </code>
> <code> functional style example </code>

That doesn't sounds like a good idea. -- Andrei

August 30, 2016
On Tuesday, 30 August 2016 at 14:11:56 UTC, Andrei Alexandrescu wrote:
> Sadly if this doesn't float your boat you're unlikely to enjoy most of what D has to offer. -- Andrei

This might be the most wrong statement you have ever said on this forum.

D's biggest appeal to me is that it *doesn't* force me to use whatever bizarre style is popular this month. It is multiparadigm out of the box, and flexible enough to adapt to new paradigms as they happen.
August 30, 2016
On Tuesday, 30 August 2016 at 14:11:56 UTC, Andrei Alexandrescu wrote:
> On 08/30/2016 06:50 AM, John Burrton wrote:
>> This is why the example on the front page put me off for a long time :-
>>
>>     stdin
>>         .byLineCopy
>>         .array
>>         .sort!((a, b) => a > b) // descending order
>>         .each!writeln;
>
> Sadly if this doesn't float your boat you're unlikely to enjoy most of what D has to offer. -- Andrei

That particular bit of code doesn't really ring "pragmatic", just "clever". Honestly the front page examples are just scary.

    // Round floating point numbers
    import std.algorithm, std.conv, std.functional,
           std.math, std.regex, std.stdio;

    alias round = pipe!(to!real, std.math.round, to!string);
    static reFloatingPoint = ctRegex!`[0-9]+\.[0-9]+`;

    void main()
    {
        // Replace anything that looks like a real
        // number with the rounded equivalent.
        stdin
            .byLine
            .map!(l => l.replaceAll!(c => c.hit.round)
                                    (reFloatingPoint))
            .each!writeln;
    }

A clever and impractical piece of program that is hard to read for most programmers.

August 30, 2016
On Tuesday, 30 August 2016 at 14:11:56 UTC, Andrei Alexandrescu wrote:
> On 08/30/2016 06:50 AM, John Burrton wrote:
>> This is why the example on the front page put me off for a long time :-
>>
>>     stdin
>>         .byLineCopy
>>         .array
>>         .sort!((a, b) => a > b) // descending order
>>         .each!writeln;
>
> Sadly if this doesn't float your boat you're unlikely to enjoy most of what D has to offer. -- Andrei

I tried hard not to be misunderstood.

My problem isn't with this *code*. I think the fact that you can do this in D and it's still in general likely to be close or equal to the efficiency of a handwritten loop is awesome and a great reason to use the language. I WANT to write code like this.

This is a problem with my perception. That such code was necessarily going to be slow and bloated compared with C loops. Which of course isn't true in D but I've seen that promise so many times before that I took a look and thought, nice... but not the language I want.

I wonder how many other people did the same.

Anyway I'll shut up now, I don't want any of this to sound like a criticism. If anything it was my mistake, but one that the example lead me to, wrongly :)


August 30, 2016
On 08/30/2016 10:19 AM, Adam D. Ruppe wrote:
> On Tuesday, 30 August 2016 at 14:11:56 UTC, Andrei Alexandrescu wrote:
>> Sadly if this doesn't float your boat you're unlikely to enjoy most of
>> what D has to offer. -- Andrei
>
> This might be the most wrong statement you have ever said on this forum.

I'm sure I said much worse! :o) -- Andrei