Thursday, 9 August 2012

A flight simulator

Okay, I've been digging through my old books and lamenting the loss of a few I threw away due to running out of space. Of those I threw away a few years ago were these:

  • A book on 80286 assembly language - Oh, how powerful was that processor! Search as I might I can't find it anywhere, although I know I bought my copy from Farnell (well, actually my father did, which means I was early teens).
  • Ralf Brown's PC Interrupts - This was essential to any DOS coder, this was jam packed with data. But as a big book with no current use it had to go. Here is a pic below of the front cover

Anyway, enough reminiscing. I did have a point!

Anyway, where were we?

I came across this book while looking through the bookcase:

Now, this is intriguing, but it's hard going. It covers rendering all the way up to polygons on a pixel by pixel basis - there was no blitting or 3D graphics cards back then! Also, there is great swathes of C++ code, hugely verbose but undoubtedly extremely fast for the time.

So, I've been having some thoughts. I really fancy the idea of doing my own flight simulator, maybe using the book as inspiration and stimulation. I do actually rather like the idea of being retro and doing pixel blitting, Bresenham's algorithm et al.

I don't want to use some old style imperative language though, I want to use something modern and functional (preferably).

Language Choice

So, what languages could I choose and what are the pros and cons?

Language Positives Negatives
ClojureJVM libraries, Java2D, Concurrency, funPoor debugging, slow?
F#Great IDE, performance, syntaxMono VM is slow, IDE is Windows only
HaskellPerformance, native binaryIs a pure language a good idea for such a stateful project?
O'CamlPerformance, native binarySingle threaded
ScalaGood compiler, performance, Java2D, JVM libraries, very similar to original C++Too similar to the original C++?!!

Now, what about some more fun languages to do this in? Here are some scripting choices, although they do have a performance hit of course.

Language Positives Negatives
PythonPygame, librariesNot functional
RubyNice syntax, librariesNot functional

Now, if I want something quickly then I suspect Ruby is the way to go as I'm more familiar with the syntax than python (despite it being better supported for this sort of thing).

I think Haskell might be too much of a challenge, and I think Scala will be too easy. I'm also thinking that as it's effectively a 'game' type application that a natively compiled languages might be best - although I'm quite aware that both O'Caml and Haskell have a VM.

Okay, I've make a decision - O'Caml it is. It natively compiles, it's fast and I like the syntax. I'm not overly familiar with the libraries so it'll be a fun exercise. Also, it's a functional language but I can if I feel naughty use mutable variables (or even OO).