No Image
No Image
No Image
Blitzmax and OOP Print E-mail
Friday, 24 November 2006

When I first encountered BASIC, every line of code had to be numbered. So you would have something like

10 FOR I = 1 TO 10 STEP 1
20 PRINT I
30 NEXT I

This linear approach was very limiting. If you wanted to insert code into the above FOR loop, that code would have to be less than 10 lines long in order to fit. You could work around this using GOTO commands or increasing the distance between line numbers (e.g. using 100 instead of 10 and 200 instead of 20) - but the problem always remained.

This kind of BASIC is ancient history. It's the way I was doing things in 1981. Nonetheless, this history had left an imprint upon my psyche, leading me to suppose that BASIC (given its origins) could never be truly object oriented. It could be clumsily simulated, rather than natively embraced.

When I first saw BlitzMax's user-defined Type Object system, which is the heart of Blitzmax OOP (object oriented programming), I was thus dubious. As I step into my current project, however, I am noticing an interesting thing occurring. My new Blitzmax code is actually simpler and more tightly object oriented than my C++ had ever been!

Now I'm the first to admit that this is more because of my idiosyncrasies, than any inherent deficiency in C++. When I shifted from C to C++, the similarity of the languages enabled me to carry on many old procedural habits into my C++ code. I excused these, saying to myself that these old methods ran faster - but deep down I doubted this excuse, and the reality was that I'd never properly sat down and attempted C++ in complete isolation from C. If you were to look at my game code, you'd thus see an eclectic mix of old and new coding styles - that certainly work - but actually are clumsy, needlessly repetitious and bloated compared to a pure OOP style.

What has happened with my switch to Blitzmax is that I have been forced to "unlearn" my previous C experience. I can't cheat and rely on old knowledge, since in this arena, it doesn't apply. This has been extremely refreshing - and indeed rewarding. Strangely I am even enjoying the bare-bones IDE that comes with Blitzmax, simply because it is a completely different environment in which to work. Everything is new, everything is fresh, and my code is reflecting this.

Suddenly I'm using OOP inheritance and polymorphism everywhere, to produce (fairly!) clean and (comparatively!) small code modules. Freed from the tyranny of platform dependence, I no longer fret over the obscure ways Microsoft APIs often use to implement what should be simple and straightforward procedures. In short, far from being a pseudo OOP language, Blitzmax has actually revolutionized my coding style, making it far more object oriented AND increased my productivity. Which is just wonderful!

 
< Prev   Next >
No Image
No Image No Image No Image
No Image
© 2009 Gibbon Games
No Image