Looking at the title you might be wondering what Dart is ?, to answer in a single line, Dart is a programming language created by Google for client Development. Dart is Object-Oriented, garbage-collected language which has a C-style syntax and it is majorly used for Cross-platform development. It first appeared in 2011, but in the last few years it has gained a lot of popularity and it is used for Flutter which is a framework developed by Google for developing Cross-platform applications. Besides that it is also one of most loved languages in StackOverflow’s 2021 Developer survey .
But why should you learn Dart? There are 4 main reasons to learn Dart, let’s take a look at each one of them.
1. Multiplatform:
Dart is a statically typed language which means that the type of variables is known at compile time. But Dart can also exhibit type inference because of which the type of variables is figured out at runtime. If you are from a Java background you will be aware about JVM(Java Virtual Machine) and JIT(just-in-time) compilation. Similarly Dart also uses Dart VM (Dart Virtual Machine) and JIT for compiling code to Native platforms which includes mobile and desktop apps. Dart offers a development time compiler (dartdevc) as well as a production time compiler (dartprod) for web projects (dart2js). Dart is translated into JavaScript by both compilers. Because of this Dart is multiplatform.
2. Flutter:
The most important reason to learn Dart is because it is used by Flutter. Flutter is Google’s UI development kit for developing beautiful applications with a single codebase. How is it possible ?I'll explain. To develop Android apps code has to be written in Kotlin/Java and for IOS in Swift. But in Flutter code is written in Dart and it is compiled to native code i.e. Android and IOS. Dart code is also compiled to JavaScript. So the same application developed using Flutter can run on Android, IOS and Web with a single codebase. That’s why you should learn Dart to learn to have a strong foundation for Flutter.
3. Null safety:
While developing applications one major problem is Null or Null pointer exceptions because of which the entire app crashes. Well, Dart has a solution for this; Sound null safety . Sound null safety means that values can’t be null unless you explicitly mention it can be, because of this null exceptions which might occur at runtime are detected and resolved at compile time, and thus it protects your code from crashing. Moreover this is not only true for variables but also for function parameters, return expressions and generics.
4. Object-Oriented:
When it comes to modern and developing high level applications, Object Oriented Programming is the best approach. Like C++, Java, Kotlin, etc. Dart is also an Object-Oriented Programming Language. It follows the 4 principles of OOPs viz. Abstraction, Encapsulation, Inheritance, Polymorphism. Everything in Dart is an Object including variables, functions, etc. Because of OOPs your code becomes modular, flexible, reusable and easy to debug.
So, this was all about What is Dart ? and Why you should learn Dart. If you are from a C++ or Java background you can learn Dart easily. But even if you are from another background or non-programmer or a beginner you can still learn Dart. In the upcoming post I’ll be sharing the Best and Free resources to learn Dart.
Thank you for reading this post till the end. If you like the post please give it a like, drop your suggestions in the comments. And don’t forget to share the post with your friends.