Tuesday, March 10, 2009

The Ramblings Begin

Since this is my first post and I assume no one knows who I am, so a little introduction seems necessary. I am Sean Chapel a professional game programmer. I've been a programmer for about a decade now and have been creating games for about 3-4 year with the last two years being a professional. I've programmed for Windows, Mac, Linux, Nintendo DS and the iPhone. That should be enough of an introduction to know where I am coming from. For my first post I figured I would take something older from my site that will lead me into my new series of posts.


The Search for Something New

Originally posted on December 14, 2008.


Ever since I became familiar with programming in C/C++ I've been searching for a new language and unfortunately nothing has stood out as a "replacement". Among the languages I've learned or looked at are Ruby, C#, Obj-C, Java, OCaml, F# and Scheme/Lisp. I really like the idea of functional languages, they offer a lot of power and are aimed more at how to do things rather than dealing with syntax or language features. Of the language I've messed with Ruby, OCaml, Obj-C and C# stood out for various reasons.

Before I go into deal about the languages perhaps I should tell what I want to do with programming. Being a professional/(and hobbist) game developer (recently released "My Japanese Coach" and "My Chinese Coach" for the DS) I am looking for something for game development. Requirements are that it allows some sort of 3d API(OpenGL?), 3d Sound API (OpenAL?), Windowing, input and be fast enough for decent game without too much hacking. The most important thing I value is that the language is cross-platform (Win/Lin/Mac), the reason being is that I use all three and it increases my target audience.


Ruby

Ruby I knew was going to be slow from reading about it and I was right but it's a good little language. I ended up using gosu which was nice but awkward at times. I liked Ruby quite a bit besides it's sometime odd syntax and even ended up making a meteors clone in it (only took 2 hours :) ). The short development time was mostly due to Ruby having a lot of functionality in little code, the big core library was nice as well. Ruby was also easy to follow and learn. I will consider Ruby in the future for scripting but as far as games goes it was just too slow unless I was to use the foreign function interface with C libs for most of the code which defeats the purpose.


OCaml

OCaml I had heard quite a bit about and that it had roughly the speed of C/C++. OCaml defiantly has some odd syntax and it does turn me off but it was easy to learn and follow. For OCaml I used ocamlgl and ocamlsdl, they worked well on windows and Linux but getting ocamlsdl to play nicely with OS X was a pain because of the way SDL works (read more in my OCaml articles). The biggest thing about OCaml for me was that it was my first real functional language but also allowed imperative style. I caught on to functional programming quite quick and really liked it but I ended up using imperative programming more as game programming requires a lot of state and data manipulation. One of the things that I liked and later came to dislike is that you didn't have to give types to things because they were statically typed by inference. The problem that OCaml has is that it differentiates number types int/float/etc , so if you were going to add an int to a float you would have to cast the int to a float then use the special float addition operator "+." . In the end I still sort of like OCaml despite it's short comings but I didn't really see anything special about it and the lack of true threads makes it not very future proof.


C#

Everyone has heard of C# and I've used it for a lot of things myself before considering it as a game programming language. The syntax is nice although can be quite wordy at times. I tried using the TAO libraries and also XNA. TAO was nice but hard to setup on the mac (I'm seeing a trend here :) ), it was also just a straight port to C# with little to no syntactical sugar. Nothing really special with TAO but then again it's just a wrapper for some C libs. XNA was a new world for me as I haven't done any directx programming before. Just looking at C++ games in DirectX is enough to make any programmer barf. I'm not saying DirectX isn't powerful but all that com cruft is quite off putting. More on topic, XNA was easy to use and get things going and the content pipeline was quite nice. The biggest thing about XNA that put me off is the lack of control. In XNA you inherit from a GameApplication class which is monolithic and you ended up passing graphic device reference to everything, not my idea of well planned out or nice to use. In the end I still like C# but it's lack of decent cross-platform ability is what keeps me from using it. I know some will say that there is mono but mono is slower and it's not easy to distribute on the mac nor easy to setup all the libs on any platform.


Obj-C

Currently I am using Obj-C at work on iPhone games. Obj-C is my opinion is the C++ of mac development, everyone uses it and is though of as the standard. Obj-C isn't bad, it reminded me a lot of C++ and it's libraries are quite extensive. It has some odd syntax and it took me awhile to overcome that but it's not bad to me anymore. One of the things that bothers me is that the libraries while there is a lot of them they aren't easy to remember. I'm constantly looking up NSString and NSDictionary to remember what the name of a function is exactly and I've been working with Obj-C exclusively for about fours months at work. Luckily XCode's built in documentation view is quite nice, if it wasn't for that then I would be very frustated with Obj-C. Obj-C fails in the way that it is not cross-platform. Obj-C will compile with gcc on windows and Linux however all the libraries even including the string class are OS X only. There is an alternative called GNUStep but it's not quite the same and is lacking a lot of functionality that is on the OS X platform. Obj-C seem to me like a alternative version of C++ with some nice things added and others taken away.


So.. Nothing has Changed

So while I use Obj-C at work, I am still using C++ at home for my hobby work. SFML, DevIl, OpenGL, OpenAL and wxWidgets are my preferred libraries and are all easy to use and cross-platform without hassle. I would really like to find a new language to replace C++ as there are a lot of things that I'd like to see changed about it and functional programming still interests me. In conclusion I haven't found anything to replace C++ for my hobby development but I've learned quite a few languages and while I may not use them for game development I'm sure I will come back to some of them for something else later on.

I realize that this posting might make some people want to point out that I didn't try XXX or I'm giving something an unfair rap. This is probably true and feel free to point it out but I don't think you will change my opinions too much.

No comments:

Post a Comment