Technology behind project tales

I have a long history of programming all kinds of projects with all kinds of programming languages. I started with C a long time ago (to be totally accurate my first was probably logo on C64) later progressed to Java and have created projects with languages like Erlang, Haskell, OCaml, Clojure and of course JavaScript.

Javascript was an ugly mess some years ago. It’s quite a surprise how mature it feels now – there are package managers with dependency management, suprisingly capable server environment (node.js) and best of all, canvas that comes with HTML5 is the last piece of puzzle that allows you create games on browser – the ultimate runtime that everyone uses. And node has quite a large ecosystem of libraries with npm, although you have to do some work to test and read about the libraries you would like to use as it seems that there are quite a large amount of low quality libraries for some reason.

So for this project, javascript just felt right. It feels great to use the same code on client and server, the V8 runtime that node.js uses is quite fast nowadays (it’s still 2-3x slower than java but that is quite great actually) and node.js which is my choice for a server can handle quite a large amount of players.

The server and client code is custom made (with some node of course), I have been doing some client/server programming before this (including some really large projects) and node with is quite a pleasant environment to work with. I don’t have many other dependencies yet but that might change of course. If you are interested, here is my current full stack:

express (for serving pages, with ejs templates)
Pako for de/compression

That’s it! All the code dependecies are listed above.

There are downsides too with Node.js of course, one that is both good and bad is its asynchronous nature. It’s very easy to write code as you don’t have to care about multithreading but at some points (one example would be when I want to store some stuff in compressed format and I would rather do the compression in background) the lack of proper multitasking feels like I’m missing something. Yes, there are webworker libraries and some threading libraries but they are long way from what I’m used to with other languages (especially with Erlang). However as node matures I assume there will be better implementations of webworkers or background processing.

Lacking multithreading is not as bad is it sounds as it’s quite easy to run a cluster of node processes so that each node process handles separate areas of the game. But I’m not at this point yet, now I want to see how well one single node process scales..

I wouldn’t have thought that I say this but programming in Javascript actually feels quite good 🙂

Leave a Reply

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