For reference, let's look at Java. Many would think that Java has a "strong
type system" and that its types prevent, as you say, invalid arguments.
However, it's easy to write a Java program that will compile just fine, yet
fail at runtime. In your words, it will allow running code with invalid
arguments. Here's an example:

This code will compile, yet fail at runtime. (Yes, I could have used
generics to help a bit, but they aren't mandatory)

I will assert that even with something like Java's type system, which
creates barriers and hoops for developers, one can still write incorrect
code. In fact, any time you have to cast, you are trying to express
something your type system can't express.

So, what if a language has a new perspective on static types? What if a
language used static types as annotations, which helped you without getting
in your way? Your tools still give you warnings and errors, yet your
programs will run without burdensome ceremony.

There is a direct tradeoff between constraining type systems that disallow
any ever possible error (which is also probably impossible), and developer
productivity. Remember that Dart is trying to appeal to a wide array of
developers, from JavaScript developers that deal only in functions and have
never seen a type, to Java/C# developers that love their tools, static
types, and structure. Dart is optimizing for developer productivity
without sacrificing structure or tooling. Its optional types help you when
you need them, but don't create unnecessary barriers.

I personally felt more free once I realized that no mainstream language
actually had a perfect type system. A combination of tool support, static
analysis, checked mode assertions, and unit tests can allow me to feel just
as safe, yet more productive.

In which I port a snazzy little JavaScript audio web app to Dart, discover a bug, and high-five type annotations. Here's what I learned.

[As it says in the header of this blog, I'm a seasoned Dart developer. However, I certainly don't write Dart every day (I wish!). Don't interpret this post as "Hi, I'm new to Dart". Instead, interpret this post as "I'm applying what I've been documenting."]

This post analyzes two versions of the same app, both the original (JavaScript) version and the Dart version. The original version is a proxy for any small JavaScript app, there's nothing particularly special about the original version, which is why it made for a good example.

Warning: We expect the Dart libraries to undergo potentially sweeping changes before Dart goes to alpha. This document is relevant as of 2011-12-22.

Intro

Dart is a "batteries included" effort to help app developers build modern web apps. An important "battery" is the bundled core Dart libraries, providing common and rich functionality. Dart is building a solution for large, complex web apps, and providing well tested, integrated, and common libraries is key to helping a web app developer be more productive out of the box.

The Collection libraries are a crucial set of APIs that Dart developers get for free. Much more than simple arrays and maps, the Collection library includes standard ways to filter, iterate, inspect, compose, and sort your data. This post specifically looks at List<E>, Dart's ordered, indexable collection of objects.