1. Dart uses only one falsify
Looking at this post, you will easily see the point. The values: false, null, undefined, “”, 0, NaN will evaluate to false. Means you can write things like this:
In Dart there is only one thing which is false. It is false itself. Of course you need to rewrite to this:
Using 6 falsifying expressions is well, let’s say you need to learn about it.
2. Dart can work with types, if you want it
3. You need a framework to work proper with DOM
Isn’t it nice? Thanks heaven we have got jQuery (and friends) to help us out of this. But… should it really be necessary to use a framework when simply selecting from the DOM? Not today.
Dart has looked at jQuery and has stripped it down to 2 methods:
4. Classes and Interfaces
Honestly, some of the developers I have worked with have invested a long time to understand the “mainstream” patterns. Not everybody is a geek. Using a non-mainstream programmin language in a mainstream environment leads to the center of ultimate chaos.
Guess not everybody reads Dr. Rauschmayers blog. It would be so easy if.
Dart does know classes and therefore does now the “extends” keyword. Pretty damn simple.
6. Global namespace
In Dart you develop in “library” scope. Means, you have a keyword “library” and only what is public is visible outside of it. In addition, every Dart script executes as its own Isolate. Means, it has a fresh state, without the mess of other scripts around. With Dart you should still think about visibility and libraries, but its way easier and for sure you don’t need a book teaching it to you. Instead, just think about “Separation of concerns” and you are in the game.
7. Dart knows concurrency
Dart knows Isolates. These are little beasts similar like in Erlang. They can communicate to each other. If one fails, another Isolate can simply restart it again. Isn’t that cool? And of course this makes Dart very nice for server side programming too. Yes, I have heard of Node.js. But that is not my point. Dart can do that magic out of the box.
You can extend Object or the Array.prototype which is pretty nice.
Or you do the following for arrays:
And you can even do that for objects:
Of course you can filter with hasOwnProperty.
Finally you should look into your frameworks docs if they offer something like forEach. jQuery does.
Life can be so easy. You iterate here over a list of elements.
9. Weirdness intializing arrays
This one is borrowed. Look at this:
a1 is an array with 5 elements: [1,2,3,4,5]
a2 is an array with 5 elements to: [undefined,undefined,undefined,undefined,undefined]
Dart is much more cleaner. An array is basically a List and therefore has this interface.
Again, a1 contains 5 different elements. a2 contains space for 5 elements.
In addition you get nice features like “removeRange” or support for sorting. Check out Seths blog.
10. undefined and null
It seems null can be replaced by undefined in pretty much scenarios.
This is sick.
Dart does only know one null.