Monthly Archives: May 2015

A friendly reminder to start thinking about ECMAScript 6

I must admit I have quite a love-hate relationship with JavaScript. Some days I’m enjoying its ridiculous flexibility while other days I am annoyed by its tolerance for any silly mistake I may make. Although JavaScript has some serious design warts, the ECMAScript 6 standard is here to improve upon the language. I welcome the new features and I am glad to hear that the standard will be finalized sometime this summer of 2015.

As you may know, it will be sometime before everyone will able to write straight up ES6 but luckily we have transpilers like Babel and Traceur to compile ES6 code into ES5.1 (the current standard JavaScript derives from). This is really exciting as you can write code using almost all of the new ES6 features today and it will still work on all browsers. These transpilers are pretty great and I think we’ll be using them for a while until ES6 gets spread around. Therefore, I encourage anyone hoping to improve their JS code base to consider giving ES6 a try. I use Babel personally, along with Gulp as my build system. It’s seriously sweet and it allows me to write more expressive code than I could in ES5.1.

Okay, so if I haven’t convinced you to check out ES6 yet then I’ll overview some of my favorite new features. I won’t go over every single one, just my personal favorites. A better overview of the many new features in ES6 can be found here.

Classes (Syntax Sugar)

This probably many people’s favorite addition to the standard and it is mine as well. ES6 introduces a new syntax for creating classes, basically a blueprint for object instances. Now don’t worry, this is just syntax sugar. You still have the flexibility and efficiency of prototypes, this new syntax just comes in handy when you just want to make a dang class!

Here’s an example:

ECMAScript 5.1

ECMAScript 6

 

I think the standard did a great job with the class syntax sugar. It’s very simple and the syntax is thankfully not too verbose. This should make many code bases more expressive.

Fat arrow functions

Another great feature is the new arrow function. JavaScript these days is always dealing with callbacks and anonymous functions everywhere. The fat arrow is here to save some key strokes and keep the code looking pretty. Now this isn’t just syntax sugar though, an arrow function has a lexical this. In other words, it captures the this of the context of which the arrow function was created in. This should hopefully save a few headaches of dealing with this and we should see less var self = this; in code bases.

Example:

 

let and const (Block scoping and Constants)

This is also a great addition to the language. Traditionally you would create a new variable in JavaScript with the var keyword. The variable will then be scoped to the function. let, however, creates a variable in block scope. This is neat because now we can bust out variables in if statements or loops without worrying about them being modified by something outside of the code block. I also find let allows for much more readable code than var. It’s worth noting that let is NOT hoisted to the top of the function, unlike variables created by the var keyword.

Additionally, we have the const keyword. This will make a constant value that cannot be changed. That’s pretty sweet and should give us programmers less headaches.

 

Conclusion

ECMAScript 6 turned out to be a great revision for JavaScript and we can all start developing in it today using transpilers. Many large websites have already started using it, so it sounds to me it’s ready for prime time. At the very least, get some time in the weekend and try it out for yourself!

Updates – Stellar Alien/Combat – Licensing Expo 2015

If you haven’t heard the stellar news, Stellar Alien was recently updated on Google Play and the Amazon App Store. This was a much needed update as there are tons of new and juicy improvements to the overall game. Finally, iOS devices should (hopefully) be receiving this same update in the next week as it is awaiting review from Apple to be updated on the App Store.

A tale of debugging an annoying launch crash.

It took sometime to get the game ready for iOS because it was crashing on launch and it was only crashing on iOS devices – not Android. So this was a frustrating problem to debug but, luckily I reviewed the crash logs and the cause of the crash was because I messed something up in Ludei’s Cloud Compiler. The app was compiled to include Facebook Integration and while I had provided a Facebook App ID for Android, I did not do the same for iOS. Ouch! And that caused me weeks of misery trying to determine what was causing the crash. I don’t think the application should crash due to the absence of an App ID, so I hope Ludei finds a better way to indicate such an error rather than the application crashing. CocoonJS continues to get better with each version and Ludei’s customer support is fantastic. I suspect inconveniences like this will cease as the platform continues to mature.

Stellar Combat still exists

In other news, I am still hacking on Stellar Combat but it is indeed a difficult beast to tame. Network programming is difficult.  I’m not sure how well I developed the client code. I’m fairly confident in the server code base, for I have not had to touch that code in months (I say if you haven’t had to touch code in a while to fix bugs/improvements, it’s probably decent code). In contrast to the client code, which I have refactored multiple times and continue to struggle to get right. This project is starting to get to the point where I ask “Is JavaScript right for this?”. But that’s a fine question to ask really. It means this is challenging me as a programmer and that’s interesting.

Licensing Expo 2015 – I’ve got a booth!

expo

Finally, much of my time recently has been occupied by the upcoming Licensing Expo 2015 in Las Vegas, Nevada. Yup, Starbli’s got a booth there. V193, write it down! I’m going to be there, and so will Starbli and all of his friends. It’s really exciting because I am hoping to expand Stellar Alien, its world, and all of its characters into different forms. A grand effort was put into developing every character’s personality in Stellar Alien, and making its massive universe super cool and unique. I’ve got an insane bucket list of the kind of things I’d like to license Stellar Alien to. If you’re attending the Licensing Expo 2015, come by the booth, say “Hi”, and check out all the neat stuff that will be there. T shirts, tablet giveaways, animated shorts for Stellar Alien, and other new info on the amazing universe that Stellar Alien is set in. Can’t wait to attend!