Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Well done to the author on this project. A beautiful architecture and code base with not an "object" in sight. Projects such as this demonstrate how complex interactive applications can be built without pervasive mutable state. Pure functions are everywhere, which makes it much easier to reason about, test and reuse this code


Thank you! Using a pure functional programming language in a game project has been suprisingly easy. I find an event driven, completely asynchoronus architecture well suited for a simulation game such as Liikennematto. Some events are big (a road tile was placed - this will update the tilemap as well as the road network graph), and some are small (UI events). Everything boils down to how an event will transform the game state.

Though many games have been built with Elm, I've had to implement lots of "game engine" code myself. For example, the collision system, physics (acceleration etc.), and path finding are custom code. It's worth mentioning that this is my fist gamedev project, and I've had to read up a quite a bit on the topic. Still the difficult was not in Elm itself, but in math and data structures, as it would be on any language.

Elm's lack of runtime exceptions and mutable state makes any game quite robust. Most of the bugs in Liikennematto have been of omissions (forgot to update something) and in math formulas. 3rd party Elm libraries are often excellent with great docs and have helped along the way.

Lastly Elm is quite performant (pure functions can be inlined and easily optimized) and I can create a single .js file that contains the game code, UI and the assets (which are still SVG in Elm). The whole game is still about 1 megabyte minimized! I think that's amazing, despite not shipping the runtime enviroment (the browser).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: