Accidentally in Code

Posts Tagged ‘programming

Tonight, I ran my first workshop in Wave. It was nice to have a space to discuss things, and unlike in a chat client it’s easy to indicate what you’re replying to. What I did was create a slide deck and make it available the day before. Then on the day, I was available to trouble shoot. The slide deck was fairly comprehensive (see it here) so I encouraged people to work through it at their own pace, whilst I clarified and helped with issues that arose.

Screenshot below shows mutiple threads of conversation happening simultaniously:

Multiple Conversations

Multiple Conversations

It’s also really easy to drag and drop screenshots, so that can help me see where people are at, and what could be going wrong.

Drag and Drop Screenshots

Drag and Drop Screenshots

Wave has nice indentations (kind of like we indent in Java!) that show a diversion:

Indentation shows the flow of the conversation

Indentation shows the flow of the conversation

Finally, trying to schedule when everyone can make the next session can be difficult – but Widgets sure make it easier!

Widgets help with scheduling

Widgets help with scheduling

So, all in all, wish Wave was faster but I think it was a success. Hopefully as people build up more knowledge they’ll discuss amongst themselves more. We will leave this wave going as people work their way through the rest of the slides (and I can help if necessary) and move to a new wave for the next session.

I’ll keep you posted about when that will be – and will put the slides up here soon!

Thanks to everyone who participated.

Tomorrow I’m running an introduction to Java via Wave. Because I’ve had a degree of interest from non-complete beginners in learning Processing, I’ve split the content so that one session will be Java: Building Blocks which will teach the very basics of Java but does not introduce Processing, and the other session will be An Introduction to Processing.

Java: Building Blocks covers the very very basics of Java – writing your first program, primitive types, conditions, and loops. At the end, we should be able to make a simple Hangman game using a framework I will provide.

An Introduction to Processing will cover getting started with Processing and be suitable for beginners who have gone through Java: Building Blocks but hopefully won’t be too dull for more advanced programmers. It will take you through creating your first little Java applet in Processing.

I’m taking suggestions for Topics, but things I’m contemplating are:

  • Java: Next Steps – covering arrays, multidimensional arrays, Objects, more on functions (passing arguments etc). Finishing with a TicTacToe or Pacman game (I have frameworks for both of these).
  • Test Driven Development and Exceptions – throwing and handling exceptions, writing code to pass test cases. Working on a Blackjack game.
  • Creating games in Processing – detecting key presses etc.
  • New Since Java 5 – Generics, enum, for each, etc.

Slides for Java: Building Blocks can be found below. As ever, I really welcome feedback!

So far this is the best new name I have for my blog. I’m still brainstorming, but this is a story I want to tell and now is as good a time as any.

I wrote, a while ago, about how I don’t have Imposter Syndrome any more. Perhaps it would have been better to say, I mostly don’t have impostor syndrome. Sometimes I don’t feel geeky enough. I don’t subscribe to xkcd (although I do appreciate the ones that I see), and I’ve never watched Star Wars or Star Trek, don’t understand the distinction, and I’m not particularly interested to either. I don’t drink Red Bull and stay up all night coding.

The nerdiest thing I ever did was get fed up with Windows when I was 16 and wiped it off my hard-drive, replacing it with RedHat. Only I was at boarding school, with no internet connection, and couldn’t download all the necessary drivers. So my dad took it in to PC World, they fixed it, and I put up with Windows until I eventually got my first Mac nearly 3 years later.

I learned HTML at 13 or 14, but didn’t learn to code until I was 16 (when I learned C in school). Then I went to University to study Chemistry, I wasn’t sure exactly what I wanted to do but I liked making stuff go fizz and occasionally burst into flames. My DOS (director of studies) put me in Computer Science as an elective, and I took the mandatory math course.

Part way through my first semester, I went to him and said “I hate Computer Science”. I was frustrated by being taught programming through slides, not doing (I still don’t think this works well, especially not for beginners), and weirded out by all the boys who didn’t seem to wash regularly. I was also completely mystified by “Object Orientated Programming”, having learned procedurally. I could explain it beautifully, but the concept just made no sense to me. I remember a professor commenting in my third year that Computer Science had changed because you couldn’t expect everyone coming in to have taught themselves a good chunk of what they needed to know anymore – because there were non-geeks. Non-geeks like me.

My DOS bribed me to stay in CS for another semester, promising he’d get me into Economics the following year. Anyway, it turned out Chemistry didn’t have enough explosions for me and I ended up still in CS, and Economic History rather than Economics (another story altogether, and not such a happy one… Economic History is all the boring bits of History and all the non-math-sy bits of Economics. It’s very dull). I guess at some point I started to like it, and then to love it. I wrapped my head around OO, discovered Recursion and Functional Programming (which I really liked) and met people who, if rather more nerdy than me, were at least clean. I interned at a wonderful company which gave me so much more confidence in terms of my ability, and I graduated with a good 2:1.

I wanted to be a programmer, but I wasn’t sure where, or what kind, and I wasn’t yet ready to settle down, wasn’t sure if I wanted to go to grad school or not, so I took off. I worked in the US, trained in martial arts in China, hung out in Europe for a while, qualified as a ski instructor in Canada, worked for a bit in the UK and then went back to the US to work, ended up here in Canada at uOttawa. I’d realized I wanted to know more stuff and as only banks seemed to be hiring (oh, the irony!) it was a good time to go back to school.

In the US I worked as a programming instructor, and after the second summer they recruited me to develop the programming curriculum. It also lead to the opportunity to work in China, last summer. In the UK, I worked to transform the zillions of spreadsheets a department was using to organize themselves into a database, that was easier to update and maintain and easier to extract information out of.

The job in the UK really hit it home to me how we as programmers often don’t really understand how “normal people” use computers, which ultimately means that we don’t always know who our users are. People who don’t realize what a little know-how can do, and how if you represent your data the right way it can be a goldmine of information, with little effort. It’s now something that I try to consider, and it influences my research and general attitude to users.

I read this article the other day – don’t let your strengths become weaknesses. It’s fascinating, because it explores this idea of how your weaknesses have corresponding strengths. So if my weaknesses that I’ve been talking about here are:

  • Lack of confidence
  • Not feeling enough of a geek

My corresponding strength are:

  • Lack of confidence -> Patience as an instructor: I remember what it’s like to be confused so it’s easier for me to be patient when my students get confused. When they make an endless loop, I find it funny rather than frustrating.
  • Not feeling enough of a geek -> empathy with end users, and a better understanding of people for whom computers are a facilitator, not the be-all-and-end-all, or even the most important thing. An interest in how computers can be useful to regular users, rather than just technologically or programmatically more advanced.

So an accident? Yes! A happy one? Yes! And if I don’t always quite feel like I belong, that’s not necessarily a bad thing – it can lead to other opportunities.

Update: This will take place on Wednesday 18th and Friday 20th November, 7-9pm. Let me know if you’re interested.

I’m thinking to run a session on this tomorrow, with discussion going on via Wave. Will start at 10 or 11am EST and run for 2 hours, with another 2 hours in the afternoon.

Let me know if you’re interested. I know it’s short notice, so I may push back depending on when people want to do it, but this will happen in the next week or so.

What you’ll need:

  • a Google Wave account
  • Java SDK
  • Eclipse
  • Processing, free download – we won’t be using the IDE that comes with it, but try and locate core.jar

I’ll assume your computer savvy enough to install Java and Eclipse by yourself as this could take up a lot of time in the session.

What we’ll cover:

  • Your first program – “Hello World”
  • Simple types (building blocks)
  • What Object Oriented programming means
  • Getting started with processing, displaying stuff
  • Conditions
  • Loops
  • Global vs. Local variables

This is loosely based on the teaching I’ve done and I have a lot of resources that I’ve created that I’ll share. I have enough to do a whole series of these online workshops, if there’s demand. As it gets cold and nasty outside this could be a good opportunity to learn to code if you’re interested in doing so.

CA assignment 3 is now out, and in class today we were looking at the stuff we needed for question 2 (which is ex. 7.1 in the textbook). It’s to manually solve the isomorphism for the two graphs below:

Petersen Graph

Petersen Graph

So I start sketching this out, and then it occurs to me that – ooh, I could easily write some code to validate it for me after I’ve worked it out.

And then it occurs to me that all I’m doing is trying permutations of “abcdefghij” (where the position in the string is the number they’re trying to replace). And if I used Haskell and the handy “permutations” method I could just code it in a brute force manner, and it would solve it for me.

So of course that’s what I did. This is a programmer thing, I think. We work out how to automate things and then we automate them. Yes, it probably took me longer to write the code than it would have to solve the thing manually. I was quite shocked that it ended up being over 60 lines (including white-space, but still… this is Haskell) although I did include my data (the edges) and methods to validate them. I think it could be done with less code, my Haskell is a little rusty.

I find programming much more satisfying than drawing the graph countless times until you get the right answer. Also, my code is purring away now generating all the valid permutations.

In case you’re interested… here are the first 20:





















This week I’ve spent a lot of time debugging other people’s code, and we had some fun bugs in class too. This was my favorite bug (I refused to fix it, but she worked out how). I’ve helped people in C, VB, and Maple – none of which are my favorite languages (I didn’t know Maple at all), and don’t have the great debugging capabilities of Java in Eclipse. As a result, I’ve come up with some tips for beginner programmers as a result of the common errors I’ve seen.

  1. Don’t take your code not running personally. Your code (or your instructor) is not out to get you! Debugging requires calm and rational thinking, the more you get upset that your code isn’t working, the less able you’ll be to fix it.
  2. Google is your friend. Lots of people learning to code have had the exact same problems you’ve had, if you can search you’ll often find potential solutions (just be careful – they may not be good, or exactly what you’re looking for). Online is also where you may be able to find that function you need.
  3. Read error messages. I’m losing track of the number of times that someone calls me over to look at a program, shows me how a compilation error pops up and then hits enter before I can read it. Read the error messages! Even if you can’t fix them yet, once you’ve learned what they mean you’ll know what to look for and be better able to fix them in the future.
  4. What are you declaring and why? Think about your variables – what to you need? What do they do? The type of the variable (String/Integer/Boolean etc) is important.
  5. Frame your problem in terms of behavior. If someone frames their problem well, I know exactly what kind of bug I’m looking for. Explain it briefly, then let me look at the code.
  6. Print statements! So useful to see what’s going on inside in the code. Don’t be afraid to use them – you can always delete them later.
  7. Small things can cause big problems. My friend spent hours trying to fix something in her code yesterday – the problem? She was using assignment equals (=) rather than logical equals (==) in an if statement (you can do this in C). Small distinctions can be really important – pay attention to them.
  8. Turn the monitor off. A blank text-editor filling your screen can distract you from the problem itself. Writing code should be the last step in solving the problem – not the first. Turn off the monitor, think about the problem, and break it down into it’s component parts. Then code it in the parts (but don’t be afraid to break them down again if necessary).
  9. The computer will do exactly what you tell it to do, in exactly the order you tell it. A lot of people forget this, but it’s so important. When the computer is not behaving the way you want it to, reflect on this. It’s important to be clear on what you want to happen first, or what you want to repeat (or don’t want to repeat) in a loop, for example.
  10. If you’re lucky enough to have a TA or friend willing to help you – take advantage of that!

Anything I’ve missed? Let me know!

This December, the University of Ottawa is holding some events to get children (7-10) interested in Engineering and Computer Science. I got the email and was inspired, because this is something I do.

My full CV is on my LinkedIn, but suffice to say the past 3 summers I’ve been teaching programming to kids. 2007 in St Paul (Minnesota), 2008 in St Paul and Seattle, and this past summer in Shanghai. I’ve also worked on the Java curriculum that was taught across the US (and that I taught in Shanghai). I’ve done this rather than take better paid jobs, or internships, and I’m not 100% sure why. But here’s why I think I do it…

Programming is seen as boring, 1’s and 0’s. It’s not as exciting as making a website, or a video game. But – talented programmers are how the applications we use to make websites and video games are made in the first place. When we use an application, we’re limited by what the application designer thought we would want. But when we code, we’re limited by the speed of our computer, the size of the memory… and our own imagination. Bear in mind, the first two limitations get less limiting by the 18 months (says Moore’s law).

I find that really inspiring. And, if I take that mindset and look at the things I do, day to day, hardware designers and programmers have changed everything. Here’s some of what I’m interested in: usability, search engines, social networking, programming as art… OK, computers have been about for a while, but if I were 10 years older? I never would have made it in Computer Science. It would have been too much about the hardware, for me. There’s a long story as to how I wound up in CS, but the short story is – it was kind of an accident. But there was enough there that I liked to keep me at it, and I doubt that would have been the case 10 years earlier. And now – I love it. I love to code, I love what I do. Seriously, I’ll talk about it to anyone who’ll listen. I’m excited to explain it to people who aren’t techies, because I’m excited that we’re finally getting there – where the stuff programmers create in their darkened basements is something real people use, and could even understand if we would just take the time to explain it to them without using obscure acronyms and unexplained concepts. I’m excited by the fact we don’t need to live in darkened basements anymore, too.

So, my theory in teaching is – learning to code, the constructs, thinking logically… can be pretty dull. But what we can create is really exciting. So I focus less on constructs, more on possibility. I talk about Open Source, and the browser wars, extreme programming, and I create stuff. And I make sure that every child I teach has the option to go home with something graphical. This year, we used processing and it was awesome. We made fractals, block breaker, snake (like the game on the Nokia phones), tetris, and a game the student called “dodgeball” (I’ll put these all up when I get my website done). And this was on top of the “frameworks” I’d created in the curriculum – hangman, noughts and crosses, blackjack, and Pacman, which were done using Swing. Frameworks mean the GUI was done for the student, and they fill in the Logic.

So, back to the presentation. I’ve uploaded the slides here, so please take a look (and let me know what you think – first draft). It’s supposed to last an hour to an hour and a half.

My Presentation centers around 3 Themes: Art, Life, and Programming.

Theme 1: ART

Art is no longer just paintings, or sculptures, or even photographs. Technology has given us new mediums to create with, and new means to distribute. Code is like a paintbrush, and the internet is the worlds biggest art gallery.


  • The Twitter “Fail Whale” – an example of how a popular web service can make an image iconic. The “Fail Whale” now has it’s own range of memorabilia – have a look here.
  • We Tell Stories – a digital literature project. 6 authors, 6 stories, each given a new form using the internet. You can follow the story of 21 steps through Google Maps, but my personal favorite is Fairy Tales where you can control how the story goes.
  • One and Other – an installation, or “living monument”. For 100 days, one person every hour spends their time at the top of the plinth doing whatever they want. Broadcast over the internet, it’s attracted millions of page views and hits from around the world.
  • New Yorker cover in May drawn using the iPhone application Brushes.
  • PostSecret – a community mail art project. People send in post cards of their secrets, which are then posted on a blog each week. A mix of old and new technology. Running since 2005, the 5th book is shortly to be released and thousands of secrets have been posted online.
  • Pixel City – a YouTube video of the creation of an entirely computer generated city.
  • I Want You To Want Me – an interactive installation at the Museum of Modern Art, New York created by Sep Kamvar and Jonathan Harris. It pulls data from dating sites, and displays it in different ways. Visually stunning, and profound it “explores the search for love and self in the world of online dating”.

These tools are recent.

Fractal – Art, or Math? Or both?

Theme 2: LIFE

Inventions that have changed humanity: the printing press, electricity, the combustion engine, fire…

Computers and the Internet are another such invention, and we’re living through the period of change. Who knows what 2010 was like? Parents upbringing would be unrecognizable to the way we live now.

In the West, people aged 30 and under are the first generation to grow up with the internet being “normal”, and everywhere. This gives us a significant advantage in the 21st century. However, less than 24 people in every 100 worldwide have access to the internet, which was only invented in 1989. Much information – medical records are a good example, is not yet digital.

Blogging is a new medium, the Blogger service was launched in 1999, and bought by Google in 2003. Services like this made it possible for not techies to “blog” (previously, blogs were just websites which required more knowledge to create). The concept of sharing your every day life in public, as it happened was new. Now, Blogging is also used as a way to communicate with your customers – important announcements are made on the company blog (Google is a great example of this).

Blogging may have been the start of the concept of “ambient intimacy”, where people stay connected by following each others lives on the internet, rather than through active communication. It’s also something that newspapers see as a threat to their business model.

Newspapers: Prediction, the paper version will be obsolete, and soon. Why? Because the way we live is changing, because their business model has been undermined by services like CraigsList. Because the world will be different in 5 years than it is now, and a lot different from how it was 10 years ago.

What’s Next? Google Wave, the Apple tablet computer, table computing, house-cleaning robots… and other things we haven’t imagined yet.


People used to program using 1’s and 0’s. A card with holes punched into it, that you’d insert into a computer (when it was your turn) and wait for the result to come out the other end. We’ve come a long way since then, and can code visually using things like Alice (upcoming 3.0 release uses The Sims) and the Warcraft World editor. Often, though, we use something in between such as C#, Haskell, or Java.

Remember the fractal? It’s Java – created using Processing.


  • Technology has changed our lives considerably relatively recently
  • New and impressive “hardware”
  • Creative and innovating programming
  • More to come!
  • Technologists – hardware designers, programmers – are at the center of what we will achieve next

Final Thoughts

  • Look around – changes are happening rapidly
  • In 15 years, you could be talking about what’s happened in your lifetime
  • Be inspired! Human innovation is INCREDIBLE!
  • Push boundaries! Be limited only by your imagination.
  • Experiment!