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!

Advertisements

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).

Web Frameworks, Desktop Application and My Newly Melted Brain

Let’s get the preliminaries out of the way: Hello, long time no see, how have you been? Etc…

So, whilst writing up my PhD (experiments finally finished!) and working three days a week (going fully full time at the end of September!) I have a fair bit on my plate at the moment. So obviously I’ve also started cooking up a side project…

I don’t want to talk too much about what it actually is (mostly because I don’t know how “open” I want it to be yet), but it’s definitely going to require a web service. It might also require a fully fledged website (lets call this the spotify model), or it might just use a desktop application which connects to the service when it needs to (lets call this the iTunes model). Then again it might have both, with the desktop application providing some extra functionality which is hard to do over the web or in the browser. I think there’s also scope for a mobile application, so lets throw iPhone and (what the hell) Android into the pot as well.

I had a bit of a poke around with some web development frameworks first, since this is probably the bit I know least about.

One of the first solutions I came across was Django, which is based on the python language. It looks good, through I have some issues with its handling of “one to many” relationships. Python is a language I have limited experience with, but it gets a lot of love, and people are putting a lot of work into into making it better. It also has good integration with native libraries. So that’s nice. It’s also named after Monty Python, which only raises my opinion of it.

I’ll essentially skip over TurboGears and Web2Py, two other python based frameworks I did some reading about. Django seems like the best choice out the python based frameworks I’ve looked at.

Soon afterwards I discovered Grails which is based on the very cool groovy dynamic language. Groovy, as well as being fun to say, is implemented directly on top of Java, by far the language I’m most comfortable with. The are a lot of existing Java libraries, and groovy has perfect integration with them. Groovy and grails have some serious weight behind them, also.

One framework I hadn’t really considered was Ruby on Rails, which is in many ways the daddy here. This is mostly because I dismissed Ruby as a language out of hand. It looks mental. For reasons I’ll come to in a minute, I’ve re-evaluated this desision, and will be having a good long look at it. On the one hand it’s been around a good long while, so has had the oportunity to become more refined. On the other hand, it was the first of its kind, which means it might also be stuck with some bad early design desicions. It’s the original, this might not make it the best. I don’t know yet.

In order to build this… thing, I’ll need data representation, I’ll need algorithms for processing this data, and I’ll need ways of displaying it. I’d rather not have to deal with multiple implementations in different languages, particularly with the algorithms.

Problem.

If I want to make desktop applications, python is a possibility. It has good bindings to GTK and QT for linux, and Cocoa for OSX (there’s probably also something which will work on windows, and at some point I’ll probably have to care about this). Java will work anywhere, but it’s quite difficult to make a desktop application with Java which won’t look like crap. My priority in this area is going to be OSX, and Java does not measure up here. I had not considered Ruby, until I came across MacRuby, which is a very interesting idea. It’s not a bridge or a set of bindings, you see, it sits right on top of the objective-c runtime. All of a sudden, Ruby and Rails are a contender.

In the mobile space, things get shitty. iPhone requires objective-c, Android requires Java. Bugger.

So here’s where I am: I think groovy is a better language than python (and probably ruby), and I think grails is a better framework than django (I’ll get back to you regarding rails)… but I’m not sure I want Java hanging around my neck when it comes to building a desktop application. I might also need some serious grunt in the algorithm stakes, and I’m not sure I want to do that in a scripting language. Yes, I need to be able to implement it quickly, but I also need it to run quickly. I’m not sure I want to do that in either C or C++. Java would be good for this (and yes, it’s plenty fast). Objective-c is an option I haven’t discounted.

The search continues… any thoughts?