Voyaging Mind

Curious coding and more.

Why Dart

This is one of those posts that I have been meaning to write for about a month or so but every time I hit the keyboard and write, it turns into a long post that wanderers all over the place.

Here’s with another stab at it.

The question I want to answer is why did I choose to code in Dart for the next year as part of my year long publish more challenge? When I came up with the idea for this year long challenge I didn’t know Dart and was actually learning Scala.

Once I set the goal I wanted to improve my chances of success so took a hard look at what could get in the way. Switching programming languages is something that costs time and productivity. I do enjoy learning new programming languages and life is meant to be fun. More precisely I enjoy learning, programming languages are low hanging fruit. The restriction to one language also has its appeal as it may free time to learn other topics. At least I will become productive in the chosen language.

The Criteria for choosing the language were simple:

  • Must deploy to wanted targets that interest me.
  • Be Relaxing.

The reasoning for first one is pretty obvious. The two targets I am most concerned about are Android and the Web. A bonus point if I can do desktop as well.

The prime candidates where C++, Java, Scala, Dart, JavaScript(JS) and TypeScript(TS). At the time of writing Dart, JS and TS didn’t have a great android story but can be embeded in a WebView component in an Android application with a few lines of Java.

Java is the great for cross platform targeting, with routes to pretty much every platform as does C++.

The second item on the list, that is relaxing, is an odd one. Let me illustrate with a little aside.

The No Stress Beach.

I have three children, each of which are all different in character. One loves woodlands, one loves beaches and the other likes both but doesn’t admit it. They are slightly more complicated than that but this fact is the relevant one for the story.

The beach loving child was feeling stressed with school and life in general. He is a quirky character but sometimes get stressed about little things.

One Sunday afternoon I decide to try something different and the two of us head to a beach. We have a new camping stove we want to try out.

The beach is a new on to us. One of those interesting beaches consisting predominatly of stones and rocks with patches of sand. After making Hot Chocolate/Coffee on the stove he roams around this almost deserted beach with me keeping an eye on him but mostly giving him his space.

After about an hour he comes bounding up to me and says “I am going to call this the No Stress beach” and then runs off to throw some more stones at waves.

I want the programming language I am using to invoke that emotion in me. Coding in it should feel great and complexity should come from the project rather than the language. Above all it should be fun and relaxing to use. Programming languages can have barriers that can add resistance to using late at night. I am trying to avoid these barries for the sake of productivity.

Looking at the whole eco system, build systems IDEs, libraries and how they are installed lets you appreciate productivity is more than language features. There will always be trade offs. The goal was to choose one that has the least chance of distracting me with build systems or obscure intricacies in a corner of the language. The less deeps dives the better.

I find C++ is actually a fairly nice language to code in but build systems can be a pain especially if you want to take it to the web or android. My brain, late at night, does not want to be dealing with build systems. C++ build systems are getting better so perhaps next time. The other negative for C++ is iteration times as sometimes C++ can take a while to compile.

Java has great tooling but to get cross platform in the sense of android and the web you have to restrict yourself to Java 6 or 7 and honestly coding in it not great as I like lambda functions. I like lambda functions even C++ has lambda functions.

Scala I like but knew learning it to a reasonable level would take a while as it is a large language, not a battle I wanted to undertake during this year long challenge. It also runs the risk of being one of those languages I enjoy playing around to try and get a perfect solutions to problems and that is not the goal of the challenge. A secondary concern was code could end up looking quite different to Java/C#/C++/JS and if I post code in the blog I would prefer it to be understandable to those not versed in the language

Honestly I can’t remember why I discounted TypeScript. Typescript is growing into a nice productive language with some good tooling.

JavaScript is a language I like but struggle to keep up with the build systems and which library to use. I also struggle to find a good open source dev environment that doesn’t take ages to set up. I am pretty sure coding in it would be nice as JS6 add a lot of goodness. It got discounted as I didn’t want to spend the time on finding an IDE and understanding a build system.

In the end I was left with Dart. It seemed to be ticking all the boxes. Easy to learn, typed when you need it. Nice deployment. Good IDE support in IntelliJ, Atom or Visual Studio Code editor. The language is unsurprising or, in a complementary, way quite boring. I did not expect the language to tick all the boxes when I started to think about what language to use.

At the moment Atom is my editor of choice and have so far not had any complaints about Dart or Atom. I actually find it hard to write about Dart as it seems work in ways I would expect. I guess the is the mark of a good design. There appears to be very few complicated obscure corners to distract me with fascinating, productivity draining complexity.

Dart is also evolving with a much better mobile experience on the way with ahead of time compiling. This didn’t figured in my decision but adds to the fun of spending a year with Dart.


comments powered by Disqus