Why are homepage examples too complicated?

Chris via Digitalmars-d digitalmars-d at puremagic.com
Tue Oct 18 04:14:22 PDT 2016


On Tuesday, 18 October 2016 at 10:04:35 UTC, Benjiro wrote:

>
> The issue is, that in order to understand the example, you are 
> already required to have a knowledge of the language.
>
> I can only use myself as a example. Only started to really use 
> D a few days ago because i have a specific project. I instantly 
> look for the methods that interest me, totally bypassing half 
> the manual. The ! looked like a operator and not a template.
>
> To show you how much a nice example flow matters: a month or 3 
> ago ( because of this future project ) i started to look at 
> several languages: Go, Nim, Haxe, etc...
>
[snip]

The example on the start page even says what it's doing and 
anyone familiar with Javascript, Ruby (and now even Java), among 
other languages, will more or less understand it:

`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;
}
`
People are increasingly looking for this type of thing. I for my 
part would be delighted to find one liners like that. Javascript 
also has `map` and `filter`, which was a good addition to the 
language.

If you want basic code and step by step examples, go to "Learn", 
which is what I do when I look at other languages. "Getting 
started", "Learn", "Tutorial", whatever.

Although the first impression counts, I don't wholly subscribe to 
the "2 seconds" attention span thing. If you're seriously 
interested in finding a good tool (i.e. a programming language) 
for your purposes, then you have to invest more than a few 
minutes anyway, regardless. As to Nim and Haxe, you have to spend 
some time on the respective pages to get to useful stuff (like 
language features etc.) - as on any other homepage, so I don't 
see your point there.

Also, as I've already said, people might look for stuff like 
`stdin.byLine...` and if they don't find it may think "Just 
another C-clone, boring". I bet you a pint that people would post 
here complaining that we didn't show them stuff like `map!(a => 
).filter...` on the start page.

tl;dr: You have to invest time in learning how to use a new tool 
anyway. The example on the start page should not be the main 
argument for or against a language.


More information about the Digitalmars-d mailing list