Wishful Coding

Didn't you ever wish your
computer understood you?

Comparing cars to planes

I was thinking about two of my favourite programming languages. While I think that the one is a better language, I keep coming back to the other for a lot of tasks.

The car

Cars get you very quickly to your short to medium distance destination. They are quick to start up and quick to turn around.

Cars are firmly rooted in the ground environment. They give you access to a lot of infrastructure, but you’ll have to deal with all the road signs and crossings(accidental complexity).

Cars are kind of awkward for going really fast, or really far. There are JIT cars and touring frameworks, but they only get you so far.

The plane

Planes on the other hand, are a lot faster and full of advanced technology. Flying is also super fun.

But planes have a slow startup time. You have to submit a flight plan, warm the engine, and wait for the runway to clear, before you can fly.

The controls of a plane are slightly more difficult than the car, but there aren’t any obstacles(Not easy, but simple).

Planes live in this dual world. They can drive on the ground and use the infrastructure, but it’s really kind of awkward to drive your plane.

The in-air infrastructure is mind-blowing, but sometimes you need to land to get stuff done.

Conclusion

Like most people, I take the car more often than the plane. But for long journeys, the plane is definitely superior.

How I learned to program in 10 years

Inspired by a blog post from Julia Evans with an identical title, here is how I learned to program.

Unlike Julia, I learned most of my programming from my own hacks and projects. I feel like the jobs I had where plateaus in my learning curve rather than spikes.

I must have stared somewhere mid-’00, before which I was raised without much technology in my life. I did not watch TV, smartphones where not invented yet, and I did not have my own computer.

I’m really fuzzy about the timeline, but several different things happened, seemingly independently of each other. I did not consider myself a programmer during any of this.

My brother likes to take apart computers, so we kind of grew into the system administrators of our tiny school, recombining and configuring donated hardware into usable computers.

Back when Game Maker was still owned by Mark Overmars, I made a lot of silly games with friends. Later we also used an RPG thing called Elysium, which ceased to exist.

This got me in touch with a guy who wanted to make a clone in Java. This lead me to read Head First Java, to date the only programming book I read extensively, including all the exercises.

I always played with LEGO, but at some point I got a LEGO RCX for my birthday, and built a lot of robots with it. Like Game Maker, it was programmed by dragging blocks around.

A guy at my school taught me and a friend some Basic. Nothing much came of this.

I did a course in web development. I learned HTML and a tiny bit of CSS, but not how to use classes and ID’s, so for a while, I would just style tag names, and use frames for layout.

Later a woman at my school who was a web designer taught me and the same friend proper HTML and CSS and introduced us to PHP.

So at this point in time I know some Java and PHP. What follows is a period where I teach myself a lot of things, do a lot of crazy hacks, and get more serious about programming.

I learned JS, Python, and Clojure by reading things on the web, and just building random stuff with it.

I used to have a folder of projects and ideas. But this was before I knew version control, and before Github. At some point I tried moving the whole thing into SVN, but I messed it up. This whole folder and its ~50 projects is lost in time.

It contained crazy things like a site that was only text. The background was a PHP-generated text image, the borders where text images, the text was text. They where only distinguished by color. I also had a memo app when local storage was new. And a HTML editor with a circular context menu.

The only thing that remains form this era is my first blog. This is your only chance to see code I wrote in 2009.

I did an internship with Oblivion, where I did some CSS and HTML prototypes. Then I did an internship with Eight media where I did Django projects.

I also started doing my first paid jobs for this designer at the school. Followed by Wordpress websites for other people.

Now we are getting to “recent history” where I know dates and stuff is on Github. By this time I was doing freelance webdev an knew several programming languages quite well.

So far, I did not have many peers. All of my friends that where interested in technology moved on to television, photography, theatre, and other things.

This changed radically in 2012, when I went to Hacker School, where I learned a ton of things and met a ton of people who where interested in the same kind of things as me. Amongst many other things, I learned C and Haskell.

After Hacker School I started living on my own and tried having a job at Silk where I did some Haskell and JS things. This did not work out very well, so I went back to freelancing.

Around this time I got a LEGO NXT. This time I programmed it using Not Exactly C. I also learned how to make NXT sensors using PICAXE. Later, when Arduino became a thing, I moved my hardware hacking to that platform.

In 2013 I did some freelance work for Freenom, who then hired me to do Python stuff. I worked there for over a year.

This brings me to today. I quit Freenom to see some more of the world. Visit far places, take on odd projects, find weird jobs. Help in this area is highly appreciated.

Catch 'em All

Isn’t it frustrating that some of the Pokemon in the first generation Game Boy games are exclusive to one of the games? There is no way to get Oddish in Blue and no way to get Bellsprout in Red.

The intended solution is to trade Pokemon with friends to get the missing ones. There are even Pokemon like Graveler that only evolve when traded.

Sadly, not a whole lot of people own a Game Boy, a Pokemon game, and a link cable. So I decided to get creative and trade Pokemon with my Arduino.

Needed parts:

  • 1 x Game Boy (Color and Advanced work too)
  • 2 x Pokemon cartridge (Red and Blue)
  • 1 x Arduino board
  • 1 x Link connector

The Game Boy communicates over what is essentially a 5v SPI bus that can act both as a master and a slave. At 8KHz it is slow enough to bit-bang, so it works on any 3 GPIO pins.

I salvaged a connector from a GBA wireless adapter, and hooked it up to 3 Arduino pins with 1KΩ series resistors to be sure. Because both ends can in theory drive the clock line, I don’t want to short them out.

 ___________
|  6  4  2  |
 \_5__3__1_/   (at cable) 

Connect to the Arduino as follows:

  1. DNC
  2. Serial Out
  3. Serial In
  4. DNC
  5. Serial clock
  6. Ground

I read through the Pokemon disassembly in my previous post, so I won’t go into too much detail about the data transferred. Here is the data structure that contains the Pokemon, if you are interested.

Long story short, I emulated the protocol on the Arduino, acting as a slave. So go Check out the code, and finally catch ‘em all.

The Arduino has one Pokemon stored in its EEPROM, which it will trade with you. So even if you have one cartridge, you can trade Graveler with the Arduino and then trade it back to get a Golem.

If you have two cartridges, you can trade a Pokemon with the Arduino, swap the cartridge, and trade it back.

No Pokemon where harmed in the making of this program. Or, not that many anyway. One Weedle turned into Slowpoke and then into Missingno. Several other Pokemon are now nicknamed Pidgey, but are otherwise doing fine.

I think it’s now complete, allowing multiple trades in one session, including canceling trades. Don’t forget to reset the Arduino when you reset the Game Boy, or bad things will happen.