Dart Vs JavaScript

The first thing I would like to bring to your attention is that both these languages have a valid claim at being pretty amazing tools at the hands of any seasoned developer. Each has its strengths over the other, similarities notwithstanding. 

I’ve personally had time using both languages having been a JavaScript die-hard and NodeJs fanatic for almost 2yrs now and a dart enthusiast for the best part of the last two or three months. My thoughts though have seen a rapid and unforeseen shift recently since the onset of my using dart and the Flutter framework over recent times. What follows from this point onwards isn’t me trying to coax you into the dart-side and neither am I downplaying the awesomeness of JavaScript as a language but rather my wish is to take you on a journey that will hopefully open you up to a whole new style of cross-platform web and mobile app development and the world of possibilities opened up to us by the Flutter-Dart environment. 

Let’s take a moment and understand what exactly both of them are in more definitive terms.

What is JavaScript?

JavaScript is a scripting language with object-oriented capabilities used mainly on the web. It started off as a client-side language but ever since the introduction of NodeJs, all that changed and now JavaScript can be used to run both client-side and server-side scripts, which is pretty cool if you ask me. This is one of the reasons why it has gone on to become the most used programming language in the world as we speak. This was further aided by Facebook when they rolled out React Native, a JavaScript framework for making cross-platform mobile applications.

The list of frameworks and libraries built in JavaScript just goes on and on from here. This makes life easier for web and mobile app developers alike because of the variety of tools at their disposal.

The sheer magnitude of JavaScript’s online community, the vast resources at your disposal as a learner, the reliable documentation and general “you will never walk alone” atmosphere that comes with it is more than enough reason to feel at home as a JavaScript developer.

Before going any further though, let’s take a look at dart for a few moments and gain a better understanding about it as well.

Flutter-Dart

What is Dart?

Dart is an object-oriented language that is optimized for building UI. It runs on the dart VM using the dart SDK and is remarkably fast on all devices as it compiles to machine code for every platform. It was initially used internally by Google to make web and mobile applications with its existence really getting public notice when Google rolled out Flutter in 2018. Now everyone who wanted to use Flutter had to learn dart to begin with. This might seem off-putting at first but from my own experience I have to say, dart isn’t that hard to pick up especially if you have a history with any other programming language like Java or JavaScript. 

Now that we have a slight understanding of what both are and a rough idea of their capabilities, let’s take a look at why I find flutter-dart such a prospective venture, so much so that I had to write a blog about it.

And so without much further ado, we begin:

Reasons Why I choose Dart over JavaScript.

1. Speed.

On average dart is twice as fast as JavaScript on every platform. This isn’t an estimate or absurd exaggeration seeing as there is data to back up this statement on experiments and analysises you can find free on the web. 

Dart’s incredible numbers are made possible by the fact that it compiles down to machine code for each respective platform, as had been mentioned earlier, making its apps run smoothly and its animations very fluid.

2. Animations.

I had mentioned something about animations in the last section and I have to say that there’s so much to be added under it. First of all, in the JavaScript world, animations are done hand-in-hand with CSS which has its own learning curve especially when trying to execute more complex animations.

This hustle is completely unheard of with flutter as it has a vast plethora of animation widgets which can be used to easily implement complex animations which you probably would have had to jump through hoops to replicate in Js and CSS.

The resources at your disposal get even richer with prebuilt animations in Flutter are boosted with the use of libraries like Rive and Flare which come packed with even more tools to build more user-friendly UI designs.

3. Robust syntax.

Darthas some very fun incorporations into its syntax that make using fun altogether. If you enjoy JavaScript’s syntactic sugar like spread operators, object literals and so on, you’ll find all and more of these features implemented in dart. The best way to experience the beauty of dart as a language is however not from a blogger’s post but by getting down to the code yourself. I almost guarantee you’ll be fascinated by how many subtle tweaks it has within it that make it such a potent tool.

4. Widgets!! Widgets!! Widgets!!

I can’t get enough of these little bundles of pure magic. Before I get carried away, let me explain what these are. For those of us who have done some React or Angular, you can think of widgets as components. And as it is commonly said in the flutter world, everything is a widget.

From text, to style, to your animations, inputs, images, you name it. Everything is a widget. A flutter app is basically an assortment of nested widgets. The concept of nesting should settle well with anyone who has done HTML. The philosophy is largely similar, you can have a row widget with multiple container widgets each of which would carry an image widget, for example.

5. Code reusability. 

Flutter and the dart VM make code reusability so easy I don’t think there’s any other ecosystem that makes it this easy. 

You can define a single widget that can be reused in multiple pages of your application with incomparable ease. You think I’m kidding? Try it.

6. The pub.

Not the one at the other side of town that you go to on weekends hoping nobody you know notices you, no. In this context, pub is dart’s package manager. In that light it can be compared to npm for JavaScript.

Being a relatively new platform in the market, pub doesn’t yet boast the big numbers of packages that npm does, it’s community only being but a fraction of that of JavaScript. 

Nevertheless, pub boasts some good stuff like it’s package rating that gives every package a rating from 0-100 depending on a number of factors like the quality of code, how often it is upgraded, reviews by other developers and so on.

Something else to note about it is that downloading dependencies to your project can be done without even opening up the console. Sounds ludicrous right? Build your first project and see it for yourself.

7. Future secure.

While most people would generally keep away from relatively new languages and technologies sighting, among other things, the possibility that it may be short-lived, this is a case that I find inapplicable to flutter-dart.

If you wonder why I’m so confident about this fact, let me first point out that even JavaScript, as big a community it may boast at present, was once ‘the new kid on the block’ too. At some point people might have thought twice about investing their time with it as much as you are right now about dart. Secondly, flutter-dart is a project by Google which brings some level of confidence seeing as you wouldn’t expect them to do away with it any time soon. On the contrary, the team working around this project are working towards making flutter-dart even better. So if you ask me, learning flutter and dart isn’t a question of if but of when.

Best sooner rather than later I guess.

Conclusion.

While it might be said that I have downplayed JavaScript’s capabilities, it can also be said that I have barely even scratched the surface when it comes to the many things that make flutter and dart such a prospect going forward.

To wrap things up I’d like to say that JavaScript has had a very long stay at the top of the food chain, something that might change a few years from now. And I won’t be surprised if dart takes that place someday.

I hope this read has at the very least made you curious enough about dart to actually go and write your first program. If so, I’ll attach a list of resources I myself found useful along the way. 

I will be writing about flutter on its own in my next publication, feel free to leave a comment highlighting areas you would like me to cover at length. 

Until next time.

Useful resources:

  1. Official Dart documentation.
  2. Official Flutter documentation.
  3. Flutter YouTube channel.
  4. The Net Ninja Flutter course on YouTube.
  5. Traversy Media Flutter crash course on YouTube.
The force will be with you.

8 thoughts on “Dart Vs JavaScript

  1. I liked your argument. Nice piece. Maybe might try it out someday. But thanks. Dart doesn’t sound bad. 😁 And thank you for sharing these pieces. Very informative.

    Like

Leave a reply to Joseph Ndung'u Mac Cancel reply

Design a site like this with WordPress.com
Get started