Category Archive: Tutorials

Jan
21
2012

Why Dart Types Are Optional and Unsound. Part 2

Before we start: Code used in this article

We continue with the guys at Dart, in this short article will show the code that we use later in the following article, it’s some guys with a small hierarchy and some variables:


class Mammal {}

class Cow extends Mammal { String moo() => 'moo!'; }

class Pig extends Mammal { String oink() => 'oink!'; }

Mammal mammal = new Mammal();

Cow cow = new Cow();

Pig pig = new Pig();

Fuente: Dartlang

Permanent link to this article: http://www.dartexperience.com/en/2012/01/21/%c2%bfpor-que-los-tipos-en-dart-son-opcionales-y-poco-solidos-parte-2/

Jan
16
2012

Why Dart Types Are Optional and Unsound. Part 1

Dart uses types in a way that might seem strange. Most popular languages that offer a type system use it very differently. If you’re familiar with types in Java, Haskell, Scala, or any statically typed language, you may wonder why on earth Dart makes the choices that it does.

Background: Dart is a dynamically typed language, and proud of it

Dart types are dynamic, as in LISP, Smalltalk, Python, and JavaScript. Users of languages ​​that also use dynamic typing, especially for programming JavaScript web certainlyunderstand the reason for this. If you prefer static typing in this article are not going to try to convince that it is better. For now we assume that Dart is a dynamically typed language.

In a dynamically typed language, any variable may be bound to a value of any type. Each value carries a tag identifying its type (or at least we can think of the implementation that way).

Dart adds some static typing, but it maintains the goal to have programmers take full advantage of its dynamic typing. The static type heuristics will not restrict them. (We talk about “type heuristics” because you really don’t want to think of it as a “type system”, not even an unsound type system.) So we want the static type checking to be optimistic: assume code is valid unless we can be statically sure it isn’t. This goal drives many of Dart’s decisions.

Source: Dartlang

Permanent link to this article: http://www.dartexperience.com/en/2012/01/16/%c2%bfpor-que-los-tipos-de-dart-son-opcionales-y-poco-solidos-parte-1-background-dart-es-un-lenguaje-con-tipos-dinamicos-y-orgulloso-de-serlo/