Wednesday, December 3, 2014

Javascript - Retro is in vogue

8 months experience (which you might say more, given the OT that was put in) using Angular.js apparently is enough to make you a guru in development shops that are new to it, as that is now my role at a local gig in Portland. They've decided to transition me to full time from contracting, so I must be doing something right.

Javascript hasn't changed much since I learned bits and pieces of it years ago. It started getting pretty fancy when jQuery was hot, but now that we have full MVC(ish) stacks in Javascript, I must say doing client side development is pretty awesome. Is it without problems? Of course not, but as a JS developer I get to live the dream of a thick but universal client that runs on any device that matters, but keep the server away from buffering giant HTML files and having to handle flow through a series of dynamically generated web pages. Now I get to think in terms of web applications. No more redirects here.

Javascript still has many blemishes. 'use strict' helps a lot, but there's still many gotchas. I've come to stop hating Coffeescript, even though it still feels pretentious. I recommend it now to teams, but if it doesn't stick, no skin off my back. As I learn more about Javascript and its quirks, I want to start turning more and more flags off the jshint settings.

My most recent personal project has been to take my Roid Miner game (formerly Star Skirmish) and convert it to full-on Javascript. My familiarity with Angular, Node, and friends had given me affordances I didn't have when working purely in Unity. It also made me turn up my nose to a lot of the hoops I felt I was jumping through in Unity. A recent update of Unity caused me to lose all of my data in my Scriptable Objects which I had labored intensely to make good editors for. Combine this with some prior experiences where Unity simply lost data while making changes to objects, and this distrust made me decide to abandon Unity's serialization in favor of something I could trust, and something I could easily publish in a web-friendly fashion. As a result I replaced large portions of the editor with an Angular app in a short amount of time. At the end of that road I still wasn't happy. In my prior job doing educational/impact game development, we started using Angular in an embedded browser inside of Unity to do the UI, and it was amazingly awesome. HTML, CSS, and Javascript all have their problems, but at this point everyone knows them. Making game UI using a web stack is pretty easy and flexible, it turns out - and the best part is you don't have to write some poor approximation of html/css to accomplish it.

After some consideration, I decided to abandon Unity altogether and start picking up Three.js. I'm still very far away from something useful with it, and there's a ton of stuff I'd have to write just to catch up to Unity's capabilities, but the cool part is I've already embedded Three.js in my existing Angular game editor. The game and the editor can kind of be one in the same if I choose it, and I think that's what I'll do. I loved the talk by Bret Victor and I always wanted Unity to do some cool live-updating stuff. Unity just doesn't have good hooks for that kind of thing, but with this editor I'm free to build that up as I wish. I have a lot of work to do just to get back where I was, but this is an exciting time.

Hopefully I can start making some more posts. Some technical, some not. I'd love to get back to doing a weekly post.