Fractal Errata

Some of the particularly sharp/anal ones amongst you might have noticed that while the technique for generating fractal lanscapes I previously described works (and works well), it’s not 100% correct. Specifically, the fact that it uses the the same scaling factor for nodes created by the diamond and square steps isn’t quite right.

Why is this? Because they generate nodes which adhere to different levels of detail, that’s why. Lets go back to that last diagram for the post which described the algorithm:

Diamand step (left) and square step (right).

Now while you’ll note that both steps add nodes that can be addressed using fractions with two as their denominator, the distance of the nodes created by the diamond step to their parents is greater than those created by the square step.

The nodes created by the square step are orthogonal to their parents, so the distance between them is proportional to a half, which as luck would have it has the same as the denominator as the fractions used to address the node. How convenient!

The nodes created by the diagonal step, on the other hand, are diagonal to their parents. This means that the distance to their parents is the pythagorean root of this same distance, so in this specific case:

sqrt(½*½+½*½) = sqrt(¼+¼) = sqrt(½) = something

Once again, the key fraction used to work this out has the same denominator as those used to address the node in the landscape. Thus, if d is equal to the denominator we’re using to address a node, the basic scaling factor used to offset a new node from its parents would be the following:

if (diamond step) range = [-sqrt(1/d*1/d*2), sqrt(1/d*1/d*2)]

else range = [-1/d, 1/d]

As I said before, this won’t make a lot of difference, but it will be more correct and that’s important to some people. Myself included.

For comparison purposes this is the effect this change has on the example landscape I’ve been using:

The original scaling method.
The updated scaling method.

There’s some difference visible, but not a huge amount. Mostly, it’s just increased the range the data are occupying and expanded the bell curve accordingly. Hence, more high points and more low points, but the land is the same basic shape.

Advertisements

Now In Eye Popping 3D!

It took a little bit of fighting with bugs that weren’t showing up in the 2D view, and a bit of time to figure out what was going on with the lighting system in JME, but I finally got the 3D display of the fractal landscapes working.

The first stage was just displaying each node as a discrete point so I could see that each was in about the right place. It looks a little bit like this:

 

Fractal landscape as points (click for bigger).

 

I did this by simply piping the spatial coordinates and colour information of each node into a pair of standard Java FloatBuffers, passing these to a JME Point class (which should really be called PointSet, in my opinion) and attaching this to the root display node of my JME application. The colouring scheme is the same as the one used for the 2D display. Some things don’t look quite right, largely due to the fact that I’ve just drawn the “underwater” points as blue, rather than adding any actual “water.” Don’t fret, it’s on the todo list.

That said, the landscape looks about right. All the points seem to be in their correct location. As a quick implementation note, I’m defining the (x, y, z) coordinates of the scene in the following way:

x = east

y = altitude

z = -north

With some scaling factors used to map the values from the [0,1] range used to address them to slightly more real world like dimensions.

The next stage was to display the landscape in wireframe to make sure the connections I’ll be using create a more solid looking polygon based display are all working correctly. Why not just go directly to polygons? You can see the the detail better in the wireframe display, making debugging much easier. I’ll definitely be using it again later.

This time, instead of piping each and every node into the vertex array, only the nodes at the highest level of detail are used. These are the nodes generated during the final “square stage” of the fractal algorithm, for those of you playing at home. Each draws a triangle (consisting of three separate lines) into the vertex buffer for each pair of parents it has in the landscape. The result looks something like this:

 

Fractal landscape as lines (click for bigger).

 

Everything seems to be in good order there, I think. One or two things don’t look quite right, particularly the beaches, but the tessellation and coverage of the polygons looks right. Here’s a closer in look at some of the polygons so you can see what the tessellation scheme actually produces:

 

Polygon tessellation (click for bigger).

 

You can (hopefully) see that each of the “active” nodes sits at the centre of a diamond formed from the shape of its parents, so it’s the points with four lines branching from them (rather than eight) which are actually being used to draw the scene.

Next: polygons. Again, only the nodes at the highest level of detail are used. This time, each inserts itself into the vertex buffer, then adds its parents if they’re not in there already. Each node remembers its postion in the vertex buffer, and these indices are then used to draw the actual polygons. These are declared by passing the indices in sets of three into a standard Java IntBuffer. The buffers are then passed to one of JME TriMesh geometry classes and displayed, like this:

 

Fractal landscape as polygons (click for bigger).

 

Again, the beaches don’t look quite right, but otherwise I’m reasonably pleased. I still need to add the actual water and improve the form of the landscape itself (and about a million other things), but in terms of display this is looking pretty good. Except for one thing: I’m using far more detail than I need to. Let me illustrate this with a slightly more extreme example. The pictures I’ve posed so far were generated using seven iterations of the diamond square algorithm. Here’s what happens when I use ten iterations (remember, the number of points increases exponentially):

 

MOAR POLYGONS! (click for bigger)

 

On the bright side the beaches look better, but that’s a lot of polygons. Far more then we actually need to display. 1579008 polygons, in fact. We need to reduce that somewhat, if we’re going to make things more complicated and maintain a reasonable frame rate (I’m getting about 60fps with this view at the moment). You can see the problem more clearly if I show you the same view using lines rather than polygons:

 

MOAR LINES! (click for bigger)

 

You can just about see the individual triangles up close, but further away the lines just mush together. I think we can afford to reduce the level of detail as we get further away, don’t you?

Well, I’ll get right on that, then…

Some Random Landscapes

I don’t have any 3D views of the fractal landscapes I’ve been making to show you yet, as I’m still working through the different implementation options. I did get a little distracted with the 2D views of the landscape this morning, though, and play with the colouring scheme.

First of all, let’s start again with the example landscape used in yesterday’s post, only with slightly more sober colours and a bar on the right showing how the height values map to actual colours:

Fractal coastlines.

Now that looks reasonably neat already, in a “my first atlas” kind of way, but clearly there’s a lot of information missing. We can see this if I plot the height values in monochrome, giving the landscape a more “plasma cloud” appearence:

Plasma cloud landscape.

Now we can see the extra information, but we’ve lost a lot of the sense that what we’re looking at is a landscape. It looks more like a cloud. We can get some of that back by combining the two approaches and using different shades of blue and green:

Shaded landscape.

Now this looks a lot better. I think the water looks quite reasonable using this scheme, but the landscape is a bit… homogenous. Is every part of the land covered in grass? How boring!

We can make things a bit more interesting by adding a thin band of “sand” around the coast, and some “mountainy” colours (and snow!) higher up, like so:

More in depth colouring scheme.

Now this looks better, the sand in particular. The mountains look okay, but not quite right. Something’s a little off. That’s not what mountains actually look like. We also don’t have any rivers or above sea level lakes. These are problems I’m going to look at later, after I get a reasonable 3D display system working. In the mean time, though, here are a couple more 2D landscapes for your viewing pleasure:

A bit more snow and an inland sea.
Yet another coastal region.

You’re Speaking My Landscape, Baby.

No, that isn’t a typo… but yes, it is a bad play on words. That’s the bad news. The good news: finally! A Clockwork Aphid implementation post!

If you’re building something which relates in some way to virtual worlds, then the first thing you’re going to need is a virtual world. This gives you two options:

  1. Use a ready made one;
  2. Roll your own.

Option 1 is a possibility, and one that I’m going to come back to, but for now let’s think about option 2. So then, when building a virtual world the first thing you need is the lanscape. Once again you have two options, and let me just cut this short and say that I’m taking the second one. I did used to be a bit of a CAD ninja in a previous job, but I’m not a 3D modeller and I have no desire to build the landscape by hand.

So I’m going to generate one procedurally. As to what that means exactly, if you don’t already know… well I’m hoping that will become obvious as I go along.

Traditional Fractal Landscape Generation

There are several ways of generating a landscape. A pretty good one (and one I’m quite familiar with, thanks to a certain first year computer science assignment) is the fractal method. It goes something like this:

Start off with a square grid of floating point numbers, the length of whose sides are a power of two plus one. I’m going to use a 5*5 (2*2 + 1) grid for the purposes of this explanation.

Set the four corners to have the value 0.5 (the centre point of the range I’ll be using), thus:

Fractal Landscape Step One
Grid based starting point.

Now, we’re going to generate the landscape by repeatedly subdividing this and introducing fractal randomness (random fractility?) using the diamond square algorithm. First the diamond step, which in this iteration will the set the value of the central cell based on the value of the four corners:

The first diamond step.

To do this we take the average of the four corners (which I calculate to be 0.5 in this case, because I did maths at school) and adding a small randomly generated offset, which has been scaled according to the size of the subdivision we’re making. How exactly you do this varies between implementations, but a good simple way of doing it is use a random number in the range [-0.25,0.25] at this stage and half this at each subsequent iteration. So, on this occasion let’s say I roll the dice and come up with 0.23. This now leaves us with:

Result of the first diamond step.

Next, we have the square step, will set the cells in the centre of each of the sides. Once again we take the averages of other cells as starting point, this time in the following pattern:

The first square step.

Now we generate more random numbers in the same range and use them to offset the average values, giving us this:

Result of the first square step.

That completes an iteration of the algorithm. Next we half the size of the range to [-0.125,0.125] and start again with the diamond step:

The second diamond step.

…and so on until you’ve filled your grid. I think you get the general idea. I’ve left out one potentially important factor here and that’s “roughness,” which is an extra control you can use to adjust the appearance of the landscape. I’m going to come back to that in a later post, because (hopefully) I have a little more that I want to say about it. I need to play with it some more first, though.

Once you’ve finished here you can do a couple of different things if you want to actually look at your creation. The simplest is to pick a threshold value and call this “sea level,” then draw the grid as an image with pixels set to blue below the threshold and green above it:

Generated fractal landscape.

This was obviously generated with a slightly larger grid (513*513), but as you can see it creates quite reasonable coastlines. You can do slightly fancier things with it, such as more in depth colouring schemes and 3D display. For 3D, the simplest method is to use each cell as a vertex in your 3D space and tessellate the grid into triangles like this:

Simple grid based tessellation.

You can then do a couple of fancy things to remove the triangles you don’t need, either based on the amount of detail they actually add or their distance from the user (level of detail).

This system works quite well, but tends to produce quite regular landscapes, without of the variation we’re used to or the things generated by rivers, differing geology, coastal erosion, glaciation and other forces which affect the landscape of the real world. Additionally, because the data is stored in a height map, there are some things it’s just not capable of displaying, such as shear cliffs, overhangs, and cave systems. The grid structure is also very efficient, but quite inflexible.

How I’m Doing it

Needless to say that’s not exactly how I’m doing it. Of course there’s generally very little sense in reinventing the wheel, but sometimes it’s fun to try.

I’m not doing too much differently with the actual algorithm, but I am using a slightly different data representation. Rather than a grid, I’m using discrete nodes. So you start off with something like this:

Node based starting point.

Which then is transformed like this to generate the actual landscape:

Adding further nodes.

..and so on.

What you you can’t see from the diagrams is that I’m using fractions to address the individual nodes. So, for instance, the node in the centre is (1/2,1/2) and the node on the centre right is (1/1, 1/2). This means I don’t need to worry about how many nodes I have in the landscape, and the adress of each never has to change. The next set of nodes will be addressed using fractions with 4 as the denominator, then 8, 16 and so on. Before looking up a node you first reduce its coordinates down to a lowest common denominator (which is a factor of 2) and then pull it out of the correct layer. I’m currently using maps as sparse arrays to store the data in a structure which looks like this:

Map<int, Map<int, Map<int, LandscapeNode>

If you’re thinking that this isn’t possible in Java, you’re half right. I’m actually using one of these. The first int addresses the denominator, then the east numerator, then the north numerator. I’ve looked at another couple of strategies for hashing the three ints together to locate a unique node but this one seems to work the best in terms of speed and memory usage. I might look at other options later, but nor yet.

This is a much more flexible representation, which removes some of the limitations of the grid. I can keep adding more detail to my heart’s content (up to a point) and I don’t have do it in a regular fashion. i.e. the native level of detail doesn’t have to be the same across the entire map. More remote areas can have less detail, for instance. By the same token, I can keep the entire “landscape” in memory, but flexibly pull individual nodes in or out depending on where the user actually is in the world, saving memory. This also potentially gives me the following:

  1. The possibility to decouple the geometry of the landscape from the topography of the representation;
  2. A “native” way of implementing different levels of detail;
  3. A natural tessellation strategy based on connecting a node to its parents (maybe you spotted it);
  4. Enough data to allow the landscape to be modified to produce more dramatic features across different levels of detail;
  5. The processes for the above should be very parallelisable.

There are still a couple of things I’m working on (3D display for a start), as I’ve been obsessing over how to organise the data structures I’m using. Hopefully I’ll be back tomorrow with some 3D views.

If you’re interested in the code you can find it here. If what you found at the end of that link didn’t make any sense to you, then you’re probably not a programmer (or you’re still learning). If you still want a look drop me a comment and I’ll see what I can do.

Disclaimer: As far as I’m aware I didn’t steel this from anybody, but I don’t claim it’s completely original, either.

 

Language Post Mortem and Some Other Notes

A couple nuggets of knowledge came out of my “You’re Speaking My Language, Baby” series of posts, so I though I’d just take a quick moment to talk about them.

The first two are perhaps the most obvious by far. Firstly: if you actually write blog posts, people are more likely to read your blog. Funny that, huh? While my post on installing Celtx on the Acer Aspire one is still my most popular by some margin (probably because it actually provides some utility), I actually had my highest numbers of hits per day during the last week. Secondly: I get less hits over the weekend. Lax working habits for the win!

What’s also interesting is the relative popularity of the individual parts of the series. Most popular first, it goes like this:

  1. Introduction
  2. C++
  3. Conclusion
  4. Java
  5. Objective-C

Now, my number of hits still isn’t exactly stellar, so this is a fairly small sample size, but it’s still quite interesting. People seem to be far more interested in reading about C++ than any of the other languages. In general, readers tend to want to know what it is I’m actually talking about, and what conclusion I come to, but when it comes to specifics, C++ gets the most interest. Is this a recommendation of the language, or the oposite, though? People could be reading what I say about it because they think it’s the sensible option… or because the folly of the language makes them seethe with rage. Hard to say. Perhaps I’ll look for some metrics of programming language popularity online.

In one of those curious events the internet throws up, the writer of a blog I read on a regular basis also just started to work on a project of a potentially similar nature, and started off with some musings on which programming language to use. I’m talking about Shamus Young in his Twenty Sided blog (I should really add it to my blog roll). Interestingly, and slightly comically, he came came to an equal and oposite conclusion to my own. He didn’t consider Objective-C (not out loud, anyway), but decided that Java was the language to use if he wanted to produce something with commercial viability, but C++ was the language to use if he wanted to do some prototyping.

I’m still scratching my head at this in some ways. I don’t care how much experience you have in C++, you’re still likely to program faster in almost any language other than C. But in other ways it makes perfect sense. He has about a decade’s worth of experience with C++ (likewise I have about ten years worth of Java under my belt), but only limited exposure to Java. He’s looking at building a complete game, so he’s being influenced by games like Minecraft (which I will be talking about more later) which were successfully developed by an individual (in Java, as I understand it). If you’re making something a bit niche and you don’t have massive amounts of resources, then having a game which can be effortlessly ported to every major operating system is a good thing.  You want to expand you potential audience as much as possible. Also, if your target demographic slants towards the nerd side of the spectrum then you don’t want count out Linux, nor OSX (which gets more nerd love than you might expect). Having your game be able to run out of a browser doesn’t hurt, either.

I’m not (at this point) looking at building a complete game, but a piece of technology which could potentially be used by multiple games, though. Something of the order of a physics engine. Middleware is the term I seem to hear used. Thus Java (which I have more experience with) is my prototyping language, but C++ makes sense as an eventual target.

I’ve been holding back on what I’m actually doing, but I essentially outed myself when I said it was similar to what Shamus is. So: I’m doing something connected to procedural content generation. I’ll explain more about what that means as I go along.

In other news I have two weeks off work. Seems I haven’t used the vast majority of my holidays this year and taking the entire month of December off is not considered to be ideal. Thus: I have two weeks to do with as I please. So long as what I please doesn’t cost too much or inconvenience my girlfriend. I may visit my parents or even some of my friends down south. I’ll also spend quite a bit of time sitting in coffee shops with a book and a note pad. Coffee shops are good places to think, I find. Just the right amount of bussle. I’m also going to crack on with Clockwork Aphid. I’m tinkering with some implementation details at the moment, but I plan on writing about what I have so far as well. I’m also hoping to make the Heston Blumenthal chilli con carne I mentioned in a previous post, but there are complications. Firstly, he’s quite specific about the types of chilli powder you should use and some only seem to be available from the good ol’ USA. They’re on order, so hopefully they’ll arrive fairly soon. Secondly, there’s clearly a mistake in the recipe, unless Heston want me to boil a pan of water and prepare a bowl of ice water for purely ornamental purposes. This isn’t completely outside the bounds of reason.

More updates soon. Look to the skies!

You’re Speaking my Language, Baby. Part 5: Conclusion.

Author’s note: As this post started out HUGE, it’s been split into parts. You’ll find the introduction here, my comments on Java here, my comments on C++ here, and my comments on Objective-C here.

So… what’s the conclusion? It mostly comes back to the fact that I’m doing this mainly for fun (though you may have trouble believing it). That being the case I’m going to start working in Java. In fact I already have started working in Java, and I’ve already written the first bits of code. I’ll talk about and make them available soon.

I just can’t ignore the sheer applicability of C++, though, much as I may dislike it as a language. Most game developers are going to have the majority of their legacy code written in C++ and that creates a lot of momentum. Games are among the more demanding things most people do with their computers, so they generally try to squeeze every last drop of performance out of the system they’re running on. C++ does have the potential to provide a performance advantage over Java (even if you might end up loosing that to your AI system when you starting having to use Lua to script behaviours). Another one of the reasons for this project was to create a bit of work which might act sort of like a portfolio piece. So, once the project has reached an early, but functional, stage of development I’m going to re-implement it in C++ and then see how I feel about the two different implementations before continuing. It’s not impossible that I’ll end up keeping both, but more than likely I’ll kill one and just stick with the other.

By a process of elimination you might have realised that I’m now counting Objective-C out. This is true, but I have another side project I may end up using it on. One which lends itself quite well to being either an iPhone/iPad app or a website. Or all three. Objective-C is clearly quite applicable to the first two, and surprisingly applicable to the last, if you go the Objective-C -> MacRuby -> Ruby on Rails route.

That was the plan, at least, until I went ahead and did something silly. I have more than a passing interest in programming language design and so found myself reading about other programming languages. Stupidly, I found a couple which have enough merit that I really can’t count them out.

The first of these is D, which is designed to fix a lot of the problems with C++ whilst maintaining its advantages. It seems to succeed at this quite well, so far as I can tell. It also seems to have direct access to a lot of things built directly for C/C++.

Then we have Scala and Fantom, which use the Java virtual machine as their runtime. Both seem capable of achieving the same level of performance as Java itself, but take away some of the legacy cruft which Java has been unable to shake, whilst adding extra useful features. Scala I’m only just starting to learn about, but people seem to like it a lot. Fantom, I think, might be perilously close to being the perfect programming language by many metrics, though. Don’t take my word for it, have a read about it. I dare you not to be impressed (assuming, of course, that you are the sort of person who gets impressed with these sort of things). It adds some very cool extensions and has direct support for some very useful things, such as allowing both dynamic and static typing under the developer’s control.

Both Scala and Fantom can transparently use libraries written in Java, though Fantom can also deploy to both .net and javascript (for web development).

All three of the these languages are interesting enough for me for to not count them out entirely, so I might also try a port to one or more of them.

As always, comments are welcome, so please feel free to try and convince me of the error of my ways. Keep it civil, though, I know how excited programming language discussions seem to make some people.

You’re Speaking my Language, Baby. Part 4: Objective-C.

Author’s note: As this post started out HUGE, it’s been split into parts. You’ll find the introduction here, my comments on Java here, and my comments on C++ here.

The last language I’m considering is Objective-C. I know this language the least of three. To make matters worse, while Java and C++ share a similar syntax, Objective-C is completely different in places. That being said, it’s semantically very similar to Java (more so than C++) and people who know it well speak very highly of it. i.e. it does not appear to be anywhere near as broken as C++. The language itself has some dynamic capability built in, but also has all of the additional dynamic options available to C++ (more on that later) and an excellent Ruby implementation which sits directly on top of the Objective-C runtime (MacRuby).

In general, Objective-C should be faster than Java, but not as fast as C++. It doesn’t use a virtual machine, but it does have a minimal run time which is used to implement the more dynamic message passing paradigm it uses in place of standard message calls between objects. It also has optional garbage collection, allowing you to make a choice between stability and performance when you need to (i.e. you can get the code working and worry about the memory allocation later). It’s also able to leverage all of the power of both the LLVM back end and the newer Clang front end, which C++ currently can’t.

While there aren’t a lot of directly relevant tools available for Objective-C itself, it is able to directly use any code or library written in either C or C++. No problems there, then.

It’s the last metric which is the kick in the teeth fot Objective-C, though. In short: no one really uses it unless they’re programming for an Apple platform. As a result, unless you’re programming specifically for either OSX or iOS you’ll loose out on a lot of frameworks. Objective-C is a first class language in the Gnu Compiler Collection (GCC), so it can be deployed easily enough under Linux (minus a lot of the good frameworks). This is not the case under windows, however, where there doesn’t seem to be any good deployment options. I have no problem ignoring Windows, but directly precluding it would appear to be somewhat foolhardy when building a piece of technology related to computer games. It wouldn’t be too much of a problem if I was only doing this as an academic exercise, but I actually have delusions of people using it.

That’s the last of the languages I’m considering. Look for my conclusion (and possibly a bit of a twist) tomorrow (here).

You’re Speaking my Language, Baby. Part 3: C++.

Author’s note: As this post started out HUGE, it’s been split into parts. You’ll find the introduction here, and my comments on Java here.

The second language I’m considering is C++. This is the language that I use the most at my day job. It’s also the language that’s used to build the vast majority of computer games and one hell of a lot of commercial software. I’m not as familiar with it as I am with Java, but I know it well enough to be productive with it. I’m also familiar enough with it to know how horribly broken it is in many respects. One of the major design goals of Java (among other more modern programming languages) was to fix the problems with C++. It also has no dynamic capabilities what-so-ever, but it’s possible to paper over this by using a minimal dynamic runtime such as Lua for scripting.

All things being equal, C++ is the fastest of the three languages. It is also the one you’re most likely to write bad code in, though, so there’s a bit of a trade off here.

As I mentioned, most games are programmed using C++. As a result, there is a veritable shit load of graphics engine options. I would probably tend towards using the open sourceOgre3D rendering engine (or something similar), but it’s worth baring in mind that I could easily switch to using, say, the Quake 3 engine (open sourced by id) if I wanted to. I could also port the project to using a commercial graphics engine if I had the desire to do such a thing.

The measure of applicability to other parties is definitely a point in favour of C++. Code written in C++ would be the easiest of the three for deployment as part of a larger project, as that project is most likely to be written in C++. In terms of acting as a developer showcase C++ has the edge as well, as it’s the language a lot of companies ask for code samples in.

Looks for my comments on the last language I’m considering tomorrow (here).

You’re Speaking my Language, Baby. Part 2: Java.

Author’s note: As this post started out HUGE, it’s been split into parts. You’ll find the introduction here.

The first language I’m considering is Java. This is by far the language I’m most comfortable and proficient with. It was used for about 90% of my Bachelors degree, I wrote the entire codebase of my PhD using it, and it gets used here and there in my day job. I’m comfortable with Java, and find it to be quite a pleasant language to program in. Big tick on the question regarding my ability to use it, then. Java has some modest dynamic capabilities built in, but it also has a lot of small options for using higher level languages for the scripting, the cleanest of which is possibly Groovy.

Java has a bad reputation performance wise, but this largely isn’t true any more. It does run using a virtual machine, but is compiled to native code at run time. It’s a lot easier to write good code using Java than the other languages I’m considering, and that can help with performance a lot, but in general Java has the potential to be the slowest of the three, all things being equal.

Tools are actually not a problem. There are a lot of high quality graphics engines available for Java, with the Java Monkey Engine (JME) being my favourite. A physics add-on is available in the form of JMEPhysics, with the next version slated to have a physics engine baked in. Raw OpenGL is also an option with LWJGL, should I want it. Likewise, I suspect that the Red Dwarf Server is likely meet my communication needs.

The applicability of Java to other interested parties is an interesting question. A lot of software gets written in Java. A LOT. But the vast majority of it is not games. Largely, I think this is because it’s perceived to be lacking in the performance department. It’s also a little harder to protect you code when you’re writing in Java, too. The previously mentioned JME has the support of a commercial games company, though, so clearly there is interest. Computers are getting faster at quite a rate, so performance has the potential to be less of a concern, especially if the project you’re working on has the whiff of a server side application about it. When it comes to server side code, I think Java is definitely winning the race. Frankly, I have a bit of trouble calling this one either way.

One language down, two to go. Look for the next post tomorrow (here), should you be interested in such things.

You’re Speaking my Language, Baby. Part 1: Introduction.

Author’s note: This post started out HUGE, so I’ve split it up. Look for the other parts over the next couple of days.

If you’re about to start on a programming project of some sort (and I am), then the first choice you have to make is the main programming language you’re going to use. Now, if you’re carrying out this project on your employers time they probably have very specific views about that. I’m not doing this project on company time, though, so the world is my oyster, figuratively speaking. There are, at a rough guess, shit loads of programming languages out there. There’s a reasonably good list to be found here, though it is missing a couple of the weird ones. While constructing the project using a language which uses LOL cat type speech for syntax, or takes its input in the form of abstract art would be an excellent mental challenge, I’m sure, that’s just not what I’m looking for.

I’m also, right off the bat, going to eliminate a couple of other classes of language. First of all: no functional programming languages. I have no patience for learning a new programming paradigm, expecially one which up until now has shown limited application outside academia. No Haskell, no CAML and absolutely no Prolog.

I’m also not considering high level dynamically typed languages, so no Python and no Ruby. For that matter, no Groovy or Lua either. You can program very quickly in them, but I’m not prepared to take the performance hit which comes with them. Python might be very popular, but I think it actively encourages bad programming practice and I want no part of that. It’s an excellent hobbyest language, but that isn’t what I’m looking for.

Lastly: I’m not looking at anything based on Microsoft’s .Net platform, and that includes Mono.

The questions I’m going to be asking of the languages I am considering are the following:

  • How well  can I use it?
  • Generally, speaking, how good is the performance?
  • What tools are available? Specifically, does it have access to the libraries I’ll need to build the project. These are mostly ones relating to 3D graphics, inter-computer (client-server) communication and (possibly) physics. There are probably a couple of other things I haven’t thought of yet.
  • How relevant is it to others? That is, if I write the project in this language will it be useful to other interested parties?

I considered three languages and I’ll tackle them one at a time in future posts, starting here.