Rob Hawkes on HTML5, Mozilla and games

Mozilla technical evangelist Rob Hawkes is the author of Foundation HTML5 Canvas for Games and Development. He fields your questions on new devices, game controllers and native-to-JS tools

@PaulAdamDavis What other devices do you hope web technologies will come to work with, and what could be achieved?
Rob Hawkes: Oooh, good question! I suppose the first thing I'm excited about seeing is the Boot to Gecko [now Firefox OS] device we're working on at Mozilla. It's basically a phone built with HTML5 and JavaScript, allowing you to rewrite the actual phone operating system with no more than the technology you normally build a website with.

Aside from that, I'm mostly interested in seeing decent support for HTML5 and JavaScript on TVs, set-top boxes and consoles. There is a splattering of support right now but the browsers are poor and the performance isn't amazing. I'm just excited for the day when I can plug a gamepad directly into my TV and play games without needing a console.

What this all means is that we'll soon be able to have a truly cross-device technology stack (HTML and JavaScript). I'm fascinated about that prospect and what it will enable developers to do.

@tomstuttdesign What do you see as your biggest triumph?
RH: This is a hard one. I suppose getting the job at Mozilla is my proudest moment – it's definitely the pinnacle of my life so far. But then again, writing the Foundation HTML5 Canvas book was a pretty amazing experience. And getting through university while writing the book and getting the job at Mozilla and still achieving a First was a big moment for me.

The reason why is the same for all of them really: they're the visible outcome of years of hard work. I've been playing with web technologies since I was 12 (13 years ago) and things are only now beginning to pay dividends. The one thing I've learnt is that you shouldn't aim for or expect these triumphs (as nice as they are), you should just do what you love doing. Anything else is a bonus.

@andrewjbaker2 Tools (Emscripten/Mandreel) for converting C/C++ to JS are emerging: what possibilities do they bring?
RH: There has definitely been a big push with these kind of native-to-JS tools, and also tools that simply let you code in one codebase and port it to all the platforms you require (such as Google Web Toolkit).

The possibility that these tools bring are that it's now easier than ever to bring native technologies and projects to the web, without the need for plug-ins. Instead of having to rewrite everything from scratch, tools like Emscripten allow developers to port existing native code to extremely well-written, fast JavaScript.

We're already starting to see some games being ported using these tools, and we're also seeing native libraries and toolkits being brought to JavaScript by being pushed through Emscripten (such as Box2D, the physics engine behind Angry Birds).

I think these tools will prove key in pushing the web beyond the browser.

@xBlackScorpx Are you thinking about using JS Frameworks such as CAAT, Crafty or three.js for your next projects?
RH: Up until now I've been writing my latest projects (mostly game-related) from scratch, mainly because I wanted to learn how things work. If I do a WebGL project I'll definitely use three.js though, and I am still looking for a game engine that would allow me to quickly and easily hack something together without getting in the way or making things difficult if I want to extend things.

@blove01_WEB Should beginning web devs start with HTML5? Most books assume prior (X)HTML knowledge: any HTML5 for pure beginners?
RH: It's important to point out that HTML5 is no different to HTMLapart from having a few new DOM elements and JavaScript APIs to play with. But to answer your question, any new dev should start off learning the latest and greatest. In my opinion, there is no point learning HTML4 elements and then getting caught out with elements that have changed or have been removed in HTML5.

There are many books that outline the key new additions to HTML5, my favourites being Jeremy Keith's HTML5 for Web Designers and Introducing HTML5 by Bruce Lawson and Remy Sharp.

@alexolivier You're doing a lot with game controllers inside of FF … can you really see this taking off? Do we all need to buy gamepads?
RH: The JavaScript Gamepad API is a really interesting addition to the browser. I can definitely see this being big when the web platform gets better on the console and TV. We shouldn't expect desktop users to have a gamepad, or to buy one, but we can expect console and TV users to have a gamepad or to at least be open to purchasing one.

@aerotwist What do think is the biggest challenge game developers face when making an HTML5 game?
RH: I don't think there is a consistent challenge for all game developers but there are definitely a few that often come up. The first being performance and many game developers feeling that it is lacking in browsers right now. I definitely don't think the situation is as bad as some make out but we can certainly make some improvements. In fact, at Mozilla we have an initiative focused specifically on speeding up the JavaScript engine.

Another big challenge is that there are a lack of large, proven distribution and monetisation platforms for HTML5 games. Right now we have options such as the Chrome Web Store, Facebook and a few smaller outlets. In the near future we'll also see the addition of the Mozilla Marketplace and its open APIs for the creation of your own web distribution system. I'm hoping that will help make things better.

@MikeRogers0 What is the best approach for building HTML5 games for mobiles/touchscreen devices?
RH: Right now, the approach for building HTML5 games for mobile is relatively similar to the process for developing for the desktop. The main differences are that you need to take into consideration that there will be lots of thumbs and stuff covering the screen when the game is played, as well as the performance constraints.

One of the main mistakes people make is to build the same game on the desktop and mobile, without taking into consideration that the experience will be entirely different. Just because HTML5 works on mobile and desktop doesn't mean that you have to make exactly the same game for both. For example, the game experience on desktop could be much richer and immersive, yet the mobile experience could be the same game but played in a slightly different, less intense way that is more suitable to the platform.

@twostepmedia Why exactly do you think HTML5 is being used as a vehicle for marketing execs when they talk about CSS, JavaScript, etc?
RH: This one is relatively obvious, in my opinion at least. I reckon HTML5 has been picked up by the marketing folk because it's quite simply easier to say one word than it is to say a dozen (HTML5, JavaScript, CSS3 and so on). The fact that HTML5 was picked is likely due to HTML being a term that most people in the industry can relate to, even people outside the industry will probably know what HTML means more than JavaScript.

I'm guilty of this myself, I often use the term HTML5 when I'm describing the entire stack of web technologies. The reason I do this is because I simply don't have the time or energy to sit and type HTML5, JavaScript, and CSS3 every time.

The main thing issue here is less about the use of a single term and more about the misuse of that term. For example, things get bad when people don't fully understand what HTML5 is – I've seen people assume that it's a defined product (like Flash) and that it will be completed and released at some point.

Buzzwords are fine (and encouraged); lack of understanding is not.

@missrachilli You come across as someone who is very passionate about our industry how do you keep yourself motivated and try and inspire others to be as passionate as you?
RH: I think coming across as passionate is totally accidental: it's just a byproduct of my excitement about everything. The motivation side of things is actually relatively easy – you just need to keep yourself involved in the things that you're interested in. Even if you don't do enough of that stuff at work, try to find time every so often to learn that new technology that caught your eye. And remember, it's completely possible to get over-passionate about something and burn yourself out – I've done that a couple times in the past few years. The easy way to avoid that is to take a break from certain technologies and projects to let that excitement and desire to build up again.

As for inspiring others, the main thing is to talk about what you're learning and playing with. If you really care about something and it excites you then it's likely that people will be happy to listen to you talk about it. Most of the stuff I hear about nowadays is via someone else talking about it.