Why Dart is the Language to Learn of 2018
Having last week started learning the Dart Programming language, and more specifically AngularDart and Flutter and found it to be one of the most useful languages i have been exposed to in a while, I was surprised today when I found an article from Codementor proclaiming it to be the worst programming language to learn for 2018, ranking worse than languages such as Objective-C which has been largely superseded by Swift for its main user-base of iOS App developers.
While the article does have a disclaimer stating they are not “ disparaging the usefulness of these languages or questioning their worth”, they also decided to use the click-bait approved title “Worst Programming Languages to Learn in 2018” and so I thought it important to try to counter bad advice with good, and state why Dart might actually be the programming language you DO want to learn in 2018.
Why Learn Dart
Easy to Learn
To give you a few examples of how easy Dart is to use for web applications, here is how you deserialize a JSON string and get a key by name (e.g. a key called key)
Map d = JSON.decode(jsonString);
var value = d["key"]
Or how to access the localstorage:
A Natively Compiled Shared Codebase
While other frameworks allow you to share portions of a code base on different platforms, Dart takes this to an entirely new level.
Firstly, by allowing you to write a single app that can be used on both Android and iOS and also compiled natively to both, Flutter (the Dart mobile apps framework) has already proven itself to me to be a very useful framework for rapid mobile applications development and in most cases this would be enough for me to consider using Dart instead of other frameworks such as Xamarin.
However where Dart really tips the scale in its favor is by further allowing the sharing of code between not only mobile applications for different platforms, but for web and other dart applications as well, allowing me to share the majority of the non-UI or platform specific code with other dart frameworks such as AngularDart.
While admittedly Flutter is still lacking in a few features (e.g. no NFC functionality) and won’t allow you to create native UI components, for a lot of use cases this won’t matter and allows for massive increases in your ability to push out new features across all clients simultaneously, a game changing feature especially true for small or single developer teams such as myself and/or those testing new features to gauge uptake and engagement.
The first project I started working on was an AngularDart single-page application. As I have quite a bit of previous experience with Angular (using Typescript/JS) I already knew about the general architecture of Angular projects and AngularDart had very few difference.
However despite the similarities i found working with Dart to be much more productive than Angular (using Typescript) and the differences it did have had made very obviously improvements to this. As an example, rather than creating ngModules and for app sections and routing, AngularDart instead allows you to declare everything as a component and include the routing details as an attribute to the class, making for a much more organized structure. Another major improvement is Dart removes a lot of the kinks (or features, depending on if you’re a fan of functional languages) of binding and scoping that you’d have with call back functions are not treated as static functions but aware of their scope, eliminating the need to bind call back functions to the correct “this”.
By the end of my first week with Dart I had redeveloped the skeleton of my web app which had taken me about the same time to do using standard angular in typescript despite not having to learn a new language or about the differences in the framework as I did while learning AngularDart.
While my experience with Flutter was more limited, I was also surprised as to just how easy and quick it is to quickly create a layout and add functionality to an app. The layout is all created in the code itself, creating a series of “widgets” (in Flutter everything is a widget), each of which can have child widgets. I found that in the time it might take me to just create the layout for a normal android app, I would be able to create both the layout and limited functionality in Flutter.
Compiles AOT and JIT
While unfortunately not available for AngularDart (which compiles to JS and is till a bit slow to reload), Flutter, the mobile app development framework can compile both ahead of time (used for building the app to work natively) and just-in-time (used during development and local testing). This is a God send. When developing a mobile app, changes are seen almost instantly. No recompiling, no waiting for the app to be reloading, just save and see the changes.
It is for those reasons mentioned above, among others, that I find Dart to be one of the most useful languages and why I will most likely be using it for all my front-end applications. It’s easy to use, had an almost non-existent learning curve, and found it to be a much better language to compile to JS from than Typescript. I recommend everyone have a look at it before they start their next angular or mobile project and think most people will be pleasantly surprised as to how much more productive they can be.