0

Write better code - play games

Posted by Chris on Saturday, March 14, 2009
I recently spent some time learning how to write code for Microchip's PIC microcontrollers. It's pretty nerdy (especially when you have to understand bit-masking to decipher their datasheets) and quite a complicated process. I jumped straight in with both feet, bypassing the high-level compilers out there which convert C and even BASIC into hex files, and stared writing in assembly.
FatBob

Crazy I know, but I'm just a wacky kind of guy. 
Seriously, check out my tie, it's got cartoon characters on it and everything.

PIC micros actually have very few instructions - just 35 commands.
On the face of it, they should be quite easy to use. But they're not.
Writing code for them should be quite simple too, but it's not. The reason it's so complicated is because you have to work within such a tight framework. You get a handful of commands, a few kilobytes of memory (4kb if you're lucky, most likely two) and you have to load variables in and out of the maths register, manually, to do even the simplest of things.

Writing code for a PIC micro can be frustratingly difficult because you can only do one of a handful of things at any one time. But this doesn't mean it can't be fun.
After all, when playing any type of game, at any one time, there are a finite number of things you can do: 
For example, check, fold or raise (poker)
Move a token or play a card (monopoly)
Roll the dice or make a suggestion (cluedo)

Yet the fun behind any game is exactly because of the rules you're bound by. And people still love to play games - in fact, the more creative you can be, within the rules of the game, the more enjoyable it can be (try sticking the ball up your jumper in a game of rugby, there's nothing in the rules says you can't).
The same is true of doing uber-nerdy stuff, like writing code.
The more creative you can be, within the confines of the limits of the language you're working in, the more impressive the results will be.

So next time you're faced with learning a new language, don't moan about what it can't do, and complain about your lack of resources. Try looking for what it doesn't stop you doing - and then the only thing limiting you will be your imagination!

0 Comments

Post a Comment

whos.amung.us

Copyright © 2009 .Nerd Club All rights reserved. Theme by Laptop Geek. | Bloggerized by FalconHive Supported by Blogger Templates.