čtvrtek 4. září 2014

The 3 main reasons why I love Dart

Dart is a new language from Google which is object oriented with optional types. People are often asking me why I am so interested in Dart. So I have decided to write blog post about the three best highlights in Dart according to me.



1. Dart is open source and has lots of libraries

Dart SDK contains lots of libraries which can help you to write amazing apps. Do you want to work with JSON, play with HTML or try Web Sockets? No problem. Everything and more is included, just try it.

There is also big community around Dart, people are writing open source libraries to extend possibilities of language and libraries in SDK which can be easily downloaded in your project using pub.

I definitely recommend to follow Dartisans community on Google+. There is lots of interesting posts from the people about language, libraries etc.

2. Dart is really fast

When people are asking me about the reason why they should use Dart I am showing them this. It is awesome.

Source: https://www.dartlang.org/performance/

3. Dart is easy to learn

If you have ever seen Java, Dart is in some way similar BUT better than Java. You can learn it really fast and you will love it. Some small examples:


Do you remember constructor in Java? This is Dart

class Person {
  String firstName;
  String lastName;
  int age;

  Person(this.firstName, this.lastName);
}

void main() {                          
  Person person = new Person("Jana", "Moudrá");
}

Private attributes + getter and setter in one line

class Person {
  String _firstName;
  String _lastName;
  int _age;

  Person(this._firstName, this._lastName);

  int get age => _age;
      set age(int age) => _age = age;
}

Futures!

HttpRequest.getString('shapes.json')            
  .then((String jsonString) {                   
    print(jsonString);
  })
  .catchError((error) {
    print(error);
  });

And what do YOU love on Dart?