Dart And Other Programming Languages
I wasn’t new to Dart programming language and in the past year, I was writing Flutter apps with Dart.
I started writing Flutter apps with searches like “How to do X in flutter?” and “How to do Y in Dart?”. I never had a complete book or documentation about Dart or Flutter.
In my previous post, I said that for technical book of May, I chose “Dart apperentice” book. I finished reading the book and it is time to share what I’ve learned from this book.
What is Dart
Based on the definition on Dart’s website: “Dart is a client-optimized language for fast apps on any platform.”
This is Dart from its application’s point of view. If I want to define Dart from programming view, it is “An object-oriented programming language with syntax like C and Java, that can compile to native code or Javascript.” It is also free and open-source and is backed by Google.
Combining these two definitions gives us a good idea of the nature of this programming language.
It’s syntax is very similar to C and Java languages. If you are familiar with them, you won’t have problem reading and understanding programs in Dart. If you have familiar with Java, you will see lots of similarities here. Dart is object-oriented, class based, garbage collected programming language. It supports interfaces, abstract classes, inheritance, generics, enums and many other features that are very similar to Java. Dart is focused on writing client applications for Android, iOS, web, Windows, Linux and macOS. Currently, most of Dart developers are using this language to create applications with Flutter framework. It doesn’t mean that we can not use Dart for other purposes.
About Dart features
- It’s a compiled, type-safe language (like Java) and a scripting language (like JavaScript) at the same time. It uses bests of both worlds.
- Unlike Java and Javascript, it is null safe, like Kotlin.
- Unlike Java, Dart has no primitive types and everything is Object in Dart.
- Like Javascript and Kotlin, Dart supports functional programming.
- Dart is compiled to native code and has better performance than Java, Kotlin.
- Like Java and Kotlin, Dart is type-safe. Dart uses a combination of static type checking and runtime checks for type safety.
- Dart code is normally shorter than equal Java code and is comparable with Javascript and Kotlin.
- Unlike Java, Dart does not support multi-threading.
- Dart has no fixed-size arrays. Just use the List data type wherever you would use an array.
- Dart has
dynamic
typing. dynamic types are one of the dynamic inbuilt dart data types that can store any type of value, you can reassign with a different type than the declared type value. (for more on Dart dynamic type visit here.)
Here I want to make a little comparison between Dart and some other programming languages that I am familiar with. This is not a feature by feature comparison. This comparison is entirely based on my personal opinion.
Dart vs. Java
Dart syntax is similar to Java syntaxt, so it is quick and easy to learn. If you know Java, you can skip lots of topics when you try to learn Dart. Java is essentially build for server-side and Dart is build for client-side. They are belong to two different worlds. If you are an Android developer that is still using Java, Dart and Flutter are your best friends!
Dart vs. Kotlin
I think that Dart creators had an eye on Kotlin! kotlin was created to breathe new life into the old Java language. Darts is based on solid Java and take on a modern look from Kotlin. If you already know about Kotlin, you will see that it is very similar to kotlin in ideas and syntax. Kotlin and Dart are both multiplatform languages and share a very modern features and syntax.
Dart vs. Javascript
The main competitor of Dart is Javascript. They fight in the same battle field: client-side development. They both target web and mobile. The winner of the most used language competition is JavaScript and the winner of the speed and performance competition is Dart. If Javascript has React and React-Native for web and mobile development, Dart has flutter! If we expand the competition to the desktops, Dart and Flutter are definitly winners because Flutter supports Windows, Linux and macOS development in addition.
We can continue these and compare Dart with other programming languages. I think that the best candidates would be C#, TypeScript and Swift.