Thoughts on Javascript, Dart and Web development

If nothing else comes up I will embed Javascript as the scripting language for Wizards’ Duel. Javascript is easy, well-known and, most importantly, well supported. In my mind scripting should be kept simple and familiar, so Javascript fits the bill perfectly. However I, like many others if you give credit to the web, don’t like Javascript very much.

javascript-and-the-good-parts

I have experimented with Javascript in the past and I wanted to see if there was a better alternative for larger scale projects, thus learning about Dart and TypeScript. My last experiment, of which you can read in my previous post, was made in Dart in a few hours and it was mostly a joyous departure from my previous attempt at web development.

I am actually a fan of dynamically typed languages, and duck typing in particular is great. Of course it is even better when you can choose what type system you prefer, thus Dart was made to be “optionally typed”, meaning that you can use type annotations to make explicit what you plan to do with a certain variable or object (everything is an object in Dart, but it doesn’t force you to have everything inside classes like C# and Java, another thing that I love) but you are not forced to do it or even use the typed variable in a specific way: the Dart editor will just alert you that it may be an error but it won’t stop you from “compiling” to Javascript.

Dart duck typing

Duck typing in Card Quest. Here location is the current “card” (class LocationCard), but it can also be an enemy (class EnemyCard). I could have mangled the inheritance a bit, use mixin or whatever, but it was just too easy to consider it an enemy and be done with it since I knew that only in that case this particular method was going to be called. The Dart IDE was gracious enough to warn me without making me going crazy and lose my plane. Just don’t try this at home!

I understand the concerns about type safety but I think that the certain choices aren’t black or white, but they depend on the nature on the project. For the short Card Quest, something that I mostly wrote while waiting at the airport, productivity beat all other considerations. For a while, at the very beginning, I was thinking of developing Wizards’ Duel for the web, but I was not confident enough in Javascript and my capability to use it for a project of this size, Flash seems to be in the declining end of the technology curve and I just couldn’t make Haxe to work. Meanwhile other considerations were leading me to want a more reliable platform than the web. I thought about using D but finally settled on C# for the support.

Web development is the big thing today and may be a big part of the future of game development, but the current language of the web may be a limiting factor. New solutions like Dart are being created to make it easier, scalable and more productive: big companies like Google have already started to make their move. Depending on your project you may decide that Javascript, even if using jQuery or some Javascript engine, may not be good enough for you. In this case you may want to give Dart a try, it is not perfect but I found that it does its work. Now, if only Google would improve that Dart Editor IDE…

Thanks for reading.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s