I rewrote the math game that I posted a week or so ago, in javascript. The javascript version runs in any reasonably up to date web browser, which has several advantages:

  1. It avoids the deployment hassles described in my previous post.
  2. An end user can run the game simply by going to a web page and clicking the ‘Start’ button — no local installation is required. This is important, I think. Many users are quite hesitant to install programs from sources that are not big companies like Microsoft or Apple. For Windows users the risk is more theoretical than real, in my opinion, assuming they have Microsoft Security Essentials installed and working, and assuming they aren’t installing programs from links on Estonian porn sites. But whatever one may think of the risk, it’s a fact that the harder you make it for a user to try a program, the less likely they are to do it.
  3. The updating problem goes away — all the developer has to do to fix a bug is fix the code on the server. The program gets reloaded every time the user reloads the page, so updating is automatic.
  4. It makes the program accessible to a much wider range of devices. The VB.NET version from my previous post can only run in a .NET environment, which, as a practical matter, means Windows. (Yes, I know, Mono, etc., I’m a big fan, but realistically, for most users, .NET means Windows.) Whereas javascript will run on any device that supports a browser — Windows, Apple, Linux, Android, tablets, phones, and whatever next year’s new must-have platform is.
  5. It’s better suited for apps that need to interact with a server.

There are also a few disadvantages:

  1. It’s more work to program, at least the way I did it. Visual Studio has a very good drag-and-drop form editor, so laying out the GUI only takes a few minutes at most. I assume there must be similar tools for laying out HTML5 GUI’s (I will be looking for a good one), but I didn’t use any, I did it the hard way. Not being well practiced on css weirdnesses, it took a fair bit of trial and error and looking things up.
  2. It’s javascript. I haven’t written very much javascript code, so I assume — hope — it will grow on me. But so far, javascript strikes me as a remarkably ugly language that seems go out of its way to make things harder to do (for the programmer) than they need to be. It also results in code that seems harder to read than, say, Python or Ruby — harder to grasp what’s going on with a quick skim. But lots of good programmers seem to like it, so we’ll give it a chance.
  3. It lacks the easy availability of specialized GUI widgets. With Visual Studio, pretty much anything you could possibly want in a GUI is right there in the toolbox, just drag, drop, resize, maybe write an event handler, and done. Even complicated things like TreeView objects, DataGrid controls — all ready to go. I assume such things are available for javascript / html5 GUI’s, but certainly not as conveniently, and, I’d hazard a guess, unlikely to be as glitch-free.

Rewriting the math drill program in javascript took quite a bit more time than it took me to write the original in Visual Basic. I didn’t include the “Leader Board” feature in the javascript version because I’m planning to add that as a server-side feature so that the game can be accessed from different devices by different players. Getting the original VB version of the game to that point took perhaps two hours. I probably spent more like eight hours on the javascript version, but again, that’s partly because I haven’t written much javascript in the past, so I still have quite a bit to learn, especially on the jQuery stuff.

I still haven’t found any acceptable way to embed a javascript app in a WordPress post. Apparently there are plugins that will allow it, but for now I’ll just put the app on another page and link to it (click here). To see the code, just “view source” in your browser (control-U in most browsers), or click here for a text file containing the html, the javascript, and the css.

Leave a Reply

Your email address will not be published. Required fields are marked *