02.24.07

A Few Helpful Pointers

Posted in Coding, Rants, Writing at 8:11 am

First, and possibly more interesting than the drivel below…

Inconsequential Update: 12 scenes left, with a current word count somewhere around 83,500 words or so. Odds are good that I won’t be doing much gaming this weekend in an effort to ride out this writing streak… But trust me. If I start banging my head against a wall, I’ll be sure to let you all know.

With that taken care of: I’ll probably start talking a little bit more about my coding work, especially as I continue my quest to learn more than just web-based technologies. Thus, the new tag for the posts. Those of you not inclined to that sort of thing, feel free to skip these– they’re going to get WAY nerdy WAY fast.

So, as I may have mentioned, I’m playing around a bit with a couple RAD tools. In particular, I’m looking at Microsoft’s XNA framework for C#/Windows/XB360 applications games, and Apple’s XCode suite/Cocoa framework for OS X development using Objective-C. Now, I’ve never been terribly adroit with C or C++ to begin with. I wrote some of it in college, fouling up a perfectly good traffic light simulator (remind me, if I haven’t ever recounted that story, to get it on bits one of these days), but to be perfectly honest it’s all Greek to me. Or, at least, it was for a while. Now it’s closer to, I dunno, Baronh, meaning I can barely read the f%$#ing code. Both C# and Obj-C take different tacks towards twisting C to their own purposes. Naturally, they both go in completely opposite directions.

You would think, actually, that C#, being a Microsoft product, would be pretty arcane and archaic. It’s not really the case, actually. C# has some quirks; but where it quirks, it tends to favor a more lax approach to coding. Everything is type-safe at compile time, variables are strongly typed (and well-enforced), and pointers are abstracted away. Inheritance and polymorphism is done through interfaces well, and the Visual Studio IDE is very helpful in telling you what you can and can’t do with an object. In about three hours of playing with it, I managed to get an animated mouse pointer on-screen, transparency effects, and the beginnings of a sprite-tile engine together. If XNA had an easy-to-use visual design studio, or at the very least better documentation on how to create, adjust, and use textures for 2D games, I could probably have cut that down considerably.

Contrast this to Objective-C. Objective-C is basically S&M For C. Yeah, you get a very nice visual interface builder, but unless you know the safeword you’re going to be on your knees, in tears, begging for mercy. The concept of “type-safe” is gone here. Everything is pointers; even the goddamn POINTERS are pointers. The language is weakly typed and nothing is checked until run-time. You don’t call an object’s methods directly; instead you send it a message. Your message is then returned by a large burly postman in leather and chains who crashes your program telling you that you didn’t do something right. He won’t tell you what, but he will pop up a whole shitload of assembly language in the hopes that maybe you’ll have an aneurysm and give up. XCode won’t tell you that you’re doing something dumb until you try to build your program. And the syntax! Good freaking Lord, the syntax! It’s like someone printed out the code, ran it through a weed-whacker, and then scanned it back in backwards and on fire. In two hours of work I had a very pretty interface that crashed whenever I touched anything because I couldn’t figure out how to make a string literal.

Anyway, despite what it sounds like, I’m about equally matched on both setups. XNA is easy to work with and the language is a snap for anyone coming from Java or even PHP (to a certain extent). The drawback is that it takes a little bit more work before you get something that looks good– or, in fact, ‘looks’ at all. Cocoa is insanely easy to make really nice interfaces with, up to and including tables with built-in sorting, tabbed stuff, and the like. Of course, the problem is that the underlying language isn’t exactly clear on how to accomplish certain things, and it’s tricky to tie objects and interface elements together unless you know exactly what you’re looking for. I probably won’t be doing concurrent development with them– I really want to try to get the Obj-C project I started done first, as it’s sort of a GTD tool– but I will try to produce something for both of them.

But not this weekend. This weekend is writing for Incon, and only for Incon. So, yeah, sorry to leave you with an abrupt ending here, but I gotta get back to work on that.