Hacker News new | past | comments | ask | show | jobs | submit login

As I'm reading through the tutorial, it seems to me that it doesn't even have optional static typing. The tutorial claims:

> Types can help you write and maintain your code, but they don't change how Dart programs behave.

That, in my opinion, is not a type system, it's a documentation system. Writing

  String a = 1;
should crash the program/produce a runtime error in a language with (optional) static type system. In Dart, in only produces a compile time warning.



    void doSomething(String a) {
        // Do something 1
    }

    void doSomething(Integer a) {
        // Do something 2
    }

    doSomething("1");
    doSomething(1);
That's the sort of thing they mean by types don't change how programs behave. You can't easily change or remove the type system because it's tightly coupled with method resolution. If you have an optional type system, the evaluation semantics of the language cannot depend on the type system because you don't want the program to do something different if you are/are not using the type system.

The fact that type errors are only manifested as warnings is a (perhaps odd) design decision, but it doesn't stop them being type errors. They could just as easily made them errors, and String a = 1 would give a compile time error.

Hopefully they'll be a 'warnings as errors' flag for those of us more used to type errors being compile errors.


I like it. It still gives dynamic types like Javascript, but catches a huge class of errors immediately upon compilation. It's exactly what I wish Javascript had.


Yeah, those aren't types, they're merely annotations.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: