Here's looking at you, kid

Chris via Digitalmars-d digitalmars-d at puremagic.com
Fri Nov 20 03:59:47 PST 2015


On Friday, 20 November 2015 at 11:44:02 UTC, Chris wrote:
> On Friday, 20 November 2015 at 08:51:13 UTC, Warwick wrote:

This example makes no sense to a programming novice:

// Sort lines
import std.stdio;
import std.array;
import std.algorithm;

void main()
{
     stdin
         .byLine(KeepTerminator.yes)
         .map!(a => a.idup)
         .array
         .sort
         .copy(
             stdout.lockingTextWriter());
}

But programming novices are taught programming in a bad way. A 
lot of programming books are full of "step by step" code which 
doesn't make sense in the real world and only spoils people for 
the rest of their programming life.

I think the most important thing is to teach people the concepts 
behind D. Not just 'writeln("Hello, world!");' and be happy code.

The example above illustrates chained programming with ranges and 
components. A > B > C = D!. This is what we have to explain 
first. People will expect "Hello, world!", but if we want people 
to use D, we'll have to teach the concepts as well, and explain 
why D has those concepts. This is the hardest bit. People prefer 
rules to explanations.


More information about the Digitalmars-d mailing list