The problem with programming: my adventure in BASIC with Petit Computer for DS
Code warrior
Have you ever dreamed of playing your own game? I know I have. But while I've dabbled with a few user-friendly game makers, I've never dug too deep into the coding side of things.
In fact, my one stab at programming ended in a slammed fist on my keyboard, a few ill-chosen words, and some tears. It's something I've subsequently tried to avoid ever since.
But with the release of Petit Computer on DSiWare, I took it upon myself to at have another crack of the whip, and see if I can knock together something simple.
The final result was spectacular, even if the end product wasn't exactly mind-blowing.
With Petit Computer downloaded from the eShop, and fired up on my 3DS, I began sifting through the programming language. It's based on something called BASIC, which is supposedly a very straightforward form of coding that many kids learn in school.
However, I had no idea where to begin. Heading to the internet, I began rooting around for guides on BASIC.
It's at this early point that I realised why so few people know anything about coding: the people writing guides for it are almost universally terrible at writing.
I found umpteen guides that promised to be for "complete beginners", that then went on to assume I knew what an "array" was, for example. Many featured mistakes and confusing structures, and most were incomplete or had no useful way to search for the answers I was looking for.
Forums were no use either as, even though most communities seemed friendly enough, the thought of wading in and asking the very simple questions I had - such "how do I make words appear on the screen" - seemed inappropriate for the high-level discussions going on.
At one point I considered splashing some cash and purchasing a book to help me - surely a professional writer had written a walkthrough for novices.
Yet even the online retailers were useless. When searching for a "basic guide to programming", the stores I searched returned results for every "Dummies Guide" for the various programming languages, except the one I was looking for.
It was only after my cry for help on Twitter that a chap called Ken Barnes stepped up to help me out.
Providing me an easily comprehensible guide via email on getting started with BASIC, I poured over his notes until I had (what I thought to be) a firm grasp of the fundamentals.
What I didn't expect though was that, like a real language (such as French of Spanish), BASIC has different dialects. This is to say that Petit Computer's take on BASIC isn't the same as other forms of the same language. The PC-based Just BASIC, for example, offers the same functionality, but will use different lines of code to achieve the same results.
This means that a lot of my learning had to be very hands-on: working out which bits of Ken's advice worked, and which didn't but could be adapted to fit with Petit Computer's nuances. I found this approach - of having a helping hand when needed, but getting stuck in and experimenting - worked best.
The problem with Petit Computer's interface though is that it puts you off experimenting. The keyboard on the touchscreen of the DS is small, meaning that you'll accidentally tap incorrect letters and symbols occasionally. The top screen is also not a high enough resolution to display lots of text at once, ensuring you scroll up and down your code constantly.
The tutorials included are extremely limited, and written in Engrish. Additionally, you can't edit code while reading the help pages, forcing you to bounce between help screens and editing.
Perhaps most detrimental to this though is what happens after you compile all of your code and attempt to run the program. If a single character is out of place you'll end up with a syntax error. This means that the program could not understand what you wanted to achieve with that line of code.
Unfortunately for beginners just starting out, what you actually got wrong and, more importantly, what you can do to correct it, is never explained satisfactorily. At one point I was told that a line included the command "GOTO" and that this was incorrect. I spent half an hour fiddling about with it until I could get it working, no thanks to the software.
When you overcome the obstacles though, Petit Computer is a remarkably powerful bit of kit.
The beauty of its complexity is that it allows you to do very clever things with it. It's still BASIC, and not nearly as sophisticated as something like C or Python, but experienced hands will be able to make any kind of software they like.
Once you know the commands you can use in Petit Computer, you can also get them into your program very quickly, as the keyboard displays shortcuts for words you have begun typing. Staying on the example of "GOTO", all you need type is "G" before Petit Computer provides you a shortcut to include the text "GOTO".
All the time I was using the software, I was thinking back to my time with Demon's Souls on the PlayStation 3. It struck me that Petit Computer - and indeed programming in general - is an ultra hardcore activity for a very few. It punishes you at every opportunity, with very little explanation as to what you did wrong, and if you don't like that, then tough.
The persistent will return to it time and again, until eventually they figure out the coding issue that stands in their way. Once solved, should they come back to the same problem, it's effortless to assail and you breeze through its implementation, wondering why anyone could find programming that line of code a problem at all.
So then, do you want to play what I made? Just point your Petit Computer QR code scanners at this.
As you'll see, it's a very small example of how to make a text adventure, complete with text descriptions, choices, different results for the choices you make, and an end goal. It's extremely simple stuff, but represents hours of research, learning, coding, and play testing.
When you play it, you might be unimpressed by its text-only stylings, its 20 second play time, and the bug that ensures that, should you input a command it doesn't recognise, the game completely falls apart.
For me though, I'm massively proud.
There's a distinct sense of satisfaction in getting code to work properly. It's infuriating to start out, the task of learning parts of this language and implementing it into a working product is daunting, but when you see something you've made running, it's an absolute joy.
A massive thank you to Ken Barnes for his crucial guidance, and to the Petit Computer Wiki for additional information.