

Learn Dart in 15 Minutes - tosh
http://learnxinyminutes.com/docs/dart/

======
lumpysnake
This has got to be the worst learn x in y minutes that I've ever read.
Whitespaces, anyone? Every example is compacted and very hard to read.
Comments should document each line instead of a huge wall of text before the
function.

Naming everything ExampleX is very difficult to see what is being talked about
in this particular function.

I'm lucky to know enough about Dart already, because this is a very bad
representation of it, IMO.

~~~
L8D
Perhaps you could contribute to the file via a PR instead of ranting at a post
on a news aggregator? If people like you did then the open source community
would be a better place.

~~~
crazypyro
"Make a pull request" is not a proper way to respond to valid criticism of
open source projects. Is it not obvious how fallacious that argument is?

------
spankalee
There's an error in the section on literals. Literals used outside of classes
do not have to be const. Not sure where that notion came from, but this is
totally valid:

    
    
        var l = [];
    

Also, the example of looping over characters in a String using substring is
very odd and expensive. Generally, if you want to iterate over a list of
single-character Strings, you'd use String.split():

    
    
        for (var c in str.split('')) {}
    

split('') is necessary to be unicode safe. There's also String.codeUnits and
String.runes (an iterable of code-points).

------
fnbr
I love Dart, I think it's a great language. I hope that Google will start
supporting it natively in Chrome.

~~~
pjmlp
They are. Check "In Development" section.

[http://www.chromestatus.com/features/6682831673622528](http://www.chromestatus.com/features/6682831673622528)

So in a few months we will have Google's VbScript available in Chrome.

~~~
spankalee
The VBScript comparison dig is as old as it is wrong.

VBScript was IE only, because VBScript didn't compile to JavaScript. Dart
compiles to JavaScript and runs on IE, Safari, Chrome, Firefox and Opera.
VBScript didn't have a specification accepted by any standards organizations,
Dart is ratified as ECMA 408. VBScript is not open source, Dart is.

The fact that Dart has been used in production years before any VM in a
browser should show how different they are.

~~~
pjmlp
> Dart compiles to JavaScript

Not all language features can be represented in JavaScript.

Besides, all the languages that compile to JavaScript just add complexity
layers to the already complex model of HTML/CSS/JavaScript.

And I bet there is a VbScript to JavaScript somewhere out there.

> Dart is ratified as ECMA 408. VBScript is not open source, Dart is.

Standards by themselves don't foster adoption.

Eiffel, Ada, Modula-2, Extended Pascal, Common Lisp, Smalltalk, ... have
ISO/ANSI standards.

In the 60 - 90's being open source wasn't a requirement for multiple
implementations for programming languages.

~~~
syntern
Context: I'm using Dart for app development for two years now.

> Not all language features can be represented in JavaScript.

I could not name one (except the dart:io stuff, which is not supported in the
JS world). Could you please elaborate?

> Besides, all the languages that compile to JavaScript just add complexity
> layers to the already complex model of HTML/CSS/JavaScript.

I've found the same, but Dart is a surprising exception. If you are not using
any fancy framework (e.g. Angular.Dart), you will be just fine with the close-
to-the-browser approach of the language and APIs.

~~~
azakai
The main example is that Dart's basic numeric types can't be represented in
JavaScript. Dart VM integers are bignums, while dart2js numbers are IEEE754
doubles.

~~~
beavis2
That's for performance because I guess the majority of users would probably
not notice the difference.

They _can_ be represented in JS, but not natively.

~~~
azakai
Yes, the decision to make numeric types incompatible between the VM and
dart2js was due to speed concerns.

------
Tloewald
One of the examples reminded me of some xml/html trivia I picked up a few
years back -- attributes do not need to have double-quotes. (Yes, in practice
you can leave out quotes altogether if the attribute has no spaces because
browsers are tolerant, but the _spec_ allows for single or double quotes, so
if you're going to parse markup you need to allow for both.)

It occurred to me that HTML5 might have tightened up this rule, but it remains
as before:

[http://www.w3.org/TR/html-
markup/syntax.html#attribute](http://www.w3.org/TR/html-
markup/syntax.html#attribute)

~~~
cygx
Note that XML attribute values _do_ need to be quoted, so this is only true
for HTML and not XHTML.

------
MisterBastahrd
It seems to me that the majority of the time learning any new language is not
the syntax itself, but memorizing function names and parameter order. Has
there ever been an effort to design a family of languages which use the same
function names and order of parameters for the same operation so that
switching between them would be a matter of learning basic syntax?

------
phpnode
This seems rather odd from example 14:

    
    
        // Boolean expressions need to resolve to either true or false, as no
        // implicit conversions are supported.
    
    

I'm sure they have good reason for this, does anyone know of the rationale? I
think I'd miss patterns like `if (arr.length) { ... }`

~~~
berns
I think this is wrong or at least misleading. According to the Ecma standard:

    
    
      Boolean conversion maps any object o into a boolean. Boolean conversion is defined by the function application
      (bool v){
        assert(v != null);
        return identical(v, true);
      }(o)

~~~
dragonwriter
Reading your quote from the ECMA standard, "no implicit conversions are
supported" may be wrong but at the same time _not_ generally misleading. That
is, that function errors on null values and returns false for anything that
isn't identical to true, so while it _does_ provide a conversion to boolean
from any non-null value, anything that isn't exactly a boolean "true" (unless
I misunderstand what "identical" does) is going to return false on conversion.
This is consistent with other writings on booleans in Dart [1]. So it appears
that Dart _has_ implicit boolean conversions, but it converts everything that
is not the single "true" value to false, so using an expression that never can
evaluate exactly to boolean true in a conditional (unless you _mean_ it to be
a wordy way to create unreachable code) is never something you want to do.

[1] [http://blog.sethladd.com/2012/02/booleans-in-
dart.html](http://blog.sethladd.com/2012/02/booleans-in-dart.html) "The only
value that is true is the boolean value true. [...] In a boolean context,
everything that is not true is converted to false."

------
adrianlmm
I like Dart, but Polymer code converted to JavaScript doesn't work on IE11,
just Chrome.

------
chrionsr
looks cool!

