Halifax Friday Hack and Back to Basics
Oct 31, 2009 08:26

Part of the reason I haven't been posting to this blog in a while is that I have been moving my business and life from Toronto to Halifax. Coincidentally, frequent collaborator Paul Doerwald has moved Liquid Media out to Halifax around the same time as well.

Inspired by the example of Unspace's Rails Pub Nite, Krispy's Toronto Developer Lunch, and Google's 20% Time idea, Paul has organized the Halifax Friday Afternoon Hack.

Every Friday around noon, anybody who is interested meets up at The Hub and we go a nearby restaurant for lunch. Then we return to the Hub and spend the afternoon working on our own interesting projects.

Some people are working on Adhearsion implementations, others are building iPhone applications, and others are playing with the Twitter API.

Me, I'm going back to BASIC:

Usborne-Hayes: Write Your Own Adventure Programs For Your Microcomputer

While clearing out my Toronto apartment, I found an old book from 1983: "Write Your Own Adventure Programs For Your Microcomputer". It was part of a series of colourful computer books by Usborne press. The early 80s were an era when every home computer came with BASIC, and you could buy magazines and books with short program listings in them that you could type in. I had enjoyed Usborne's books of short programs, so I remember looking forward to trying this one. It turned out that my 12-year-old brain couldn't quite handle the complexity of this program (200 lines of code on 5 pages, with lots of data statements and $tring management), but I liked the pictures and so put it aside for later. It somehow managed to not get thrown away in the intervening 26 years or so, and was rediscovered in a box just a few weeks ago.

So my first Friday Afternoon Hack event is to finally type in this program, and rediscover the world of programming in the early 80s, when an average machine would have 16 KILObytes of RAM, would store programs on audiotape, and often had cheap plastic or membrane keyboards.

I tried finding an Apple ][ emulator for my Snow Leopard MacBook Pro (62,000 times the RAM of an Apple IIe, and running at 2,400 times the speed on two processors) but had trouble getting everything set up to run BASIC properly. Instead, I found a nifty JavaScript-based BASIC interpreter that seems to work pretty well.

It's a bit surreal to type in 80s-vintage Apple II BASIC using EMACS and TextWrangler, and then copy-and-paste it into a browser window to see how it runs. It's more surreal to be figuring out code from a quarter century ago.

The program makes a good exercise. It's more sophisticated than the simple "1-6 randomizer with a win or lose message" Russian Roulette games I used to type in. It has a small vocabulary of verbs and nouns, multiple data sets, and a request/response event loop.

The book is well written as well: it covers how to plan out the locations and objects for an adventure game, explains how arrays and event loops work, and how to handle a vocabulary - all in full colour with little cartoon ghosts pointing out the interesting bits.

Here's what the first page of the code listing looks like:

BASIC Adventure game listing page 1

Some impressions:

  • Line numbers. Wow, what a crappy way to have to write code. The standard approach is to increment the line count by 10 on every line, so that you have some space to insert code without having to renumber every following line. Sections of code were often offset by 1000 or 10000 so that they could be kept separate. Often if you did have to insert large amounts of code, you would have to use...

  • Goto and Gosub. This is the reason that you have to have line numbers. When you only have 1k or 16k of RAM, there isn't really the space to have named functions or named code sections, so to be able to jump around inside your code, you need to refer to the numbers. It's pretty easy to see why goto is considered harmful.

  • Data statements. It's a tiny program in a low-resource environment, so there's no separation of code and data. All of the application data is entered in a collection of DATA statements and FOR loops which populate (single-dimension only!) arrays. Get any of the DATA statements wrong, and nothing will work.

  • No compile step and an instant runtime. Probably the best aspect of BASIC that helped build a generation of programmers - you can type something in, type RUN, and instantly see the result. This almost makes up for the non-descriptive error messages.

My plan for the next few Friday Afternoon Hacks is to get this program working in BASIC, and then rewrite it in as many different languages / environments as I can: Ruby, EMACS LISP, Objective C / Cocoa / iPhone, Erlang, Haskell, JavaScript, SmallTalk, C, Java, etc. extending it in interesting ways. It would be interesting to compare the size and performance of the code in different languages - not to mention the memory footprint.

If nothing else, I can finally finish what I started when I was 12. Remember, it's never too late to have a happy childhood!

Quote from Wil Shipley
Aug 31, 2009 08:33
Other Blog Posts
My Expanded Twitter Thread about BurgerWeek 2021 This Is Nowhere: The Server Side Building a React Native App Without Tears - Part 3 Building a React Native App Without Tears - Part 2 Building a React Native App Without Tears (Mostly) This Is Nowhere: The Memento Edition This Is Nowhere: Aspects of Accessibility Presentations About NowHere This Is Nowhere: Head-First Into React Native This Is Nowhere: Bloomsday Halifax This Is Nowhere: Why an HTML/JavaScript Single-Page App With GPS Is A Bad Idea This Is Nowhere: GPS and Wayfinding and More UX This Is Nowhere: The Single-Button UX This Is Nowhere: Don’t Just Stand There! This Is Nowhere: Finding My Duck Finding Burgers Fast: My DIY Halifax Burger Week Site "This is Nowhere" at PodCamp Halifax 2018 The Diary Diaries: Fixing Remembary's Facebook Connection Special Leap Day Edition of "Some Weird Things About Time" What's Up With Remembary Can't get pg_dump To Work Now That Heroku Has Upgraded Postgresql to 9.4? The Best Thing I Ever Did To Promote My App If You Build It, They WON'T Come #deployaday, My Big Hairy Plan for 2015 Extracting Plain Text from an NSAttributedString My Year of "Hits" Part 2: Remembary Rolling My Year of "Hits" Part 1: Remembary Rises (and Stumbles) Handy Little Test Method to Check for Translations in Rails Apps My Suddenly Slow-Waking MacBook Air Indie App PR: Keeping Control of Your Tone A Quick Note on 'clone' in Rails 3.2 My eBook Apps 2: iOS, JavaScript, and Ruby My eBook Apps 1: Introduction Quick Tip: No Sound on Mountain Lion My Upcoming Talk at PodcampHFX 2012: My Year of "Hits" starshipsstarthere.ca: Building at the Speed of Funny Screencast Tips Remembary's Cool New Picture Support Indie App PR 2: Keeping On Top Of User Feedback Indie App PR 1: How to Handle an App Disaster Giles Bowkett Diary Project 2 Remembary Video Congratulations! Welcome to Your Nightmare! How My iPad App Remembary Took Off Why You Should Have an App in the App Store (Even If You Probably Won't Make Any Money) PodCampHFX Remembary Presentation - Part 3 How I Used MailChimp Autoresponders to Promote Remembary PodCampHFX Remembary Presentation Part 2 PodCampHFX Remembary Presentation Part 1 Why AdWords Ads Don't Work for iPad Apps Remembary is Sponsoring PodcampHFX Why Can't I Resize my Views in Interface Builder? Momento and Remembary Concerning Remembary iPad-Friendly eBooks of Gracian's Art of Worldly Wisdom Project Report: PTOS2 A Quick Note on Encryption We're all LUsers Thoughts on HAML Friday Afternoon Hack - Getting Beyond the Basics Halifax Friday Hack and Back to Basics Quote from Wil Shipley FutureRuby Make Web Not War Busy Week I: Toronto Ruby Job Fair Employment.nil - the Toronto Ruby Job Fair Code Count: Ruby on Rails vs. C#/ASP.NET A Brief Note on Twitter The Hub Halifax and Mobile Tech for Social Change Deep Thoughts on Microsoft From The Accordion Guy The Two Kinds of Defensive Programming Presentation - Fixing Careerious: From C#/.NET to Ruby on Rails Enterprise! Presenting at Ruby on Rails Project Night - May 7th New Name and New Look for Careerious/Clearfit FutureRuby and More From Unspace Health Tips for Programmers This tables meme won't die Careerious - Ruby and Rails vs. C#/.NET Yeah I Use Tables For Layout, So Sue Me The Different Kinds of Done Giles Bowkett's RubyFringe presentation OfficeTime: Great Time-Tracking App for OS X Back With A New Look Non-DRY Feed torontorb Keeping Your Sanity With The Command Design Pattern shindigital Is All Grown Up! (according to the spambots) Startup Stars? I'm so bored! The Magic Words for RMagick Jennifer from Operations You see? Naming is HARD Business Software as Process Documentation Deployment note: 'execve failed' Steve Jobs on Market Research Why Canada Is Better for Entrepreneurs "Program first and blog second" Toronto Tech Collage The MacBook Air Is A Roadster RubyFringe! Quote of the Week: Steve Yegge Starting Up: Cards Great design tool: browsershots.org Starting Up: The Logo Quotes Of The Day: Hedge Fund Interview TSOT Ruby / Rails Presentation Night - Part 1 Moneyworks: Accounting Software for Canadians on OS X Starting Up: The Name Nice logo, but why is your site so bland? Welcome to shindigital.com