Lately I’ve been having a lot of discussions with people about Computer Science education. Everyone I’ve spoken with is passionate and excited about broadening the reach of CS education, which is really exciting to me: it’s exactly what I want to help with. One thing I’ve been frustrated by, from time to time, is not having a common understanding of what Computer Science education is. I’m not going to say I have the one true definition, but I thought I’d document my thoughts on it so that folks know what my perspective is.

One boon for marketing CS education is that everyone has an amazing supercomputer in their pocket, which can (and often does) run amazing programs; immersive games, augmented reality planetariums, music instruments, social media, and on and on. Being able to say to someone “I can teach you how to make these things and more – only limited by your imagination” is a great lure. It’s also misleading, and here’s where my analogy comes in. I think a smartphone and all of its apps are a lot like a phenomenal Ship in a Bottle. Offering to teach someone how to make an App is a lot like teaching someone how to make a ship in a bottle, without teaching them how to make a ship outside of a bottle first. Sure it’s possible, but it’s missing out on a number of opportunities:

First, you’ll never be able to make better looking ships in a bottle than you can outside of a bottle. If you want to innovate – make new, cool things that have never been seen before – you should experiment making those things outside of a bottle first, then once you’re happy with them, figure out how to get them assembled inside of a bottle.

Second, to have any chance of getting a novice shipbuilder to make anything they’ll consider acceptable inside of a bottle, you’ll have to give them a lot of parts pre-made, already in a form that can be put in a bottle. After your lesson, if they want to reproduce the experience at home, they’ll have to start with the same parts, which are essentially ship in a bottle kits. If those kits aren’t available, they’ll have to figure out how to back-fill the knowledge to construct them.

Third, and this is where the analogy stretches its limits, if bottle technology changes, the kits immediately become obsolete, and only folks who know how to build these things from scratch will have any chance of keeping up with technology.

For me, the notion of building a ship in a bottle is very much like getting a program to run on any computer, not just a smart phone. Taking a high-level idea of a game, an application, a musical instrument, and turning it into the 1’s and 0’s of the machine code for a specific computer, is a lot like building a ship in a bottle. Computers are crazy time-and-space dilating machines that require processes be expressed in very specific ways (the machine code), and when they are, those processes run at almost-unimaginable speed.

Teaching someone “game coding” using a high-level framework is akin to giving them a Ship in a Bottle Kit, and maybe even a bottle with a hinged bottom. After the class, if you give them a real bottle and raw materials, (no framework), they won’t be able to reproduce that experience.

I’m not saying these experiences are bad at all. In fact, I think they’re great for giving students a sense of “here’s where we’re headed,” and “cool stuff is possible.” But if the only focus is on using kits, students will be fundamentally unprepared for the world where computers, operating systems and languages change with a 3-5 year cycle.

So, what am I advocating?

Teaching someone how to build a ship outside of a bottle includes:

Teaching them about how all computers work, all the way from gates, through logic and memory, up to machine code,

teaching them about decomposing big problems into smaller steps, and assembling those steps into solutions, and doing so in the context of actually solving problems,

An example I particularly like is Google’s CS Unplugged, which is an extreme example of learning about computer science concepts outside of the bottle of computers. Their activity with a Binary Sorting Network can be done on a playground with chalk, and blows kids’ minds when they come out sorted, regardless of what order they start with.

Systems like MIT’s Scratch might seem too much like a ship in a bottle kit in my analogy, but in my (admittedly limited) experience, once a student gets Scratch, they understand programming in a fundamental way. Scratch turns syntax – the icky, in-the-way stuff about programming – into a puzzle-assembly problem, so the students can focus on what they want to express. Later, when they are ready for textual-based programming, the syntax of those languages, when laid out with discipline, actually looks a lot like the similar Scratch program. Brilliant design on their part. The key to making this work is to keep the students exploring, make sure they keep learning from cool projects they like on the website, until they can pretty much create anything they want.

When teaching programming, I wholeheartedly recommend (when possible) teaching more than one language in a short duration. When I took Intro to CS at UC Berkeley (in 1984!), they taught us Scheme and C in the same year. Some folks thought that was nuts, or was an indication of the crazy limitations of

. Looking back on the experience, I think it was really clever: I learned the things that are fundamentally the same between the two, and also the things that are way better in one than the other. Choice of language is a choice of tool, and Mr. Natural’s “get the right tool for the job” was drilled in to me by my hippie dad from an early age.

While it’s totally okay to teach “writing Apps”, or “coding webpages”, it’s important to realize and advertise the limitations (and strengths) of these approaches. Knowing how to “code a webpage” was a lucrative skill in 1999, but quickly became irrelevant as Web technologies advanced. Similarly, we’re way past the time when simply writing an App and uploading it to Apple or Google is the road to a career. The role of teaching these things is to give an early glimpse at what’s at the end of the journey of a CS education. The peril of only using those approaches is that you’re on a never-ending treadmill of needing to take the next class when a new framework or web technology takes over, making your previous skills irrelevant. To stand the test of time, classes like this should include fundamentals of usability and visual design, not just HTML, CSS and Javascript. On the games side, spend some time investigating what makes an activity fun, not just how to animate sprites using frameworks. Bonus points, on the games side, would be to include learning principles of physics, using a physics simulation framework.

One quote that resonates with me, often misattributed to Edsger Dijkstra, is “computer science is no more about computers than astronomy is about telescopes.” I think this quote may have been mis-used to try to push CS into Math departments, and is at odds with the accurate observation that the pre-eminent professional society dedicated to CS is named The Association for Computing Machinery. I think it’s safe to say that CS is something new: we spend too much time arguing about whether it’s a science, a branch of mathematics, an engineering discipline, or a vocational discipline – it’s all of those things. If you leave any aspect out, you’re missing out on something. Combining them isn’t easy, but if we manage to do it, we’ll be totally surprised at the kinds of things future generations will be building in these amazing bottles.

I’ve got a lot more to say on the subject of CS education, and even about the analogy (compilers are like CNC machines-in-a-bottle), but I’ll stop here for now.

Addenda: less than a week after writing this, I received the latest issue of CACM, and in it was a nice piece titled “Misconceptions About Computer Science.” I think there’s a lot of overlap in philosophy, and I’ve also got some stuff to learn from the authors who have been thinking about these issues for longer than I have, but I was encouraged.

As part of the book about cryptography, math and programming I’m writing, I’m encouraging readers to assemble their own paper Enigma machine. Since it’s pretty involved, I thought I’d write an illustrated blog post about doing it. I’m going to start with a summary of the context of the Enigma – and as a summary, I’ll gloss over some likely-important stuff, and also probably get some things a bit wrong. Corrections are welcome, of course. So, here we go!

Thinking back to World War II, the German military was kicking butt all over Europe, and their submarines were causing all sorts of mayhem in the Atlantic. They were able to securely communicate across vast distances by sending radio messages that were encrypted with an Enigma machine. This meant that the Allies could hear their messages, but couldn’t understand them, because they didn’t have the key used to decode them. Polish mathematicians cracked the Enigma code in 1932, taking advantage of a subtle misconfiguration of how the Germans used the machines. By 1938, Germany fixed this flaw, and was able to send secure communications again.

One of the first things Turing did at Bletchley Park was to create a model of the Enigma machine using comic strips. Our paper Enigma, from Franklin Heath (a security firm in the UK), was inspired by his work. The first thing you’ll need is the PDF of the paper Enigma. Since paper in the US isn’t the same shape as in the UK (A4), I had good luck printing it on legal sized paper (11×14 inches). The kit is designed to be wrapped around a cardboard tube that is 75mm in diameter. It turns out a Pringles potato chip can has this diameter (they’re called “crisp tubes” in Britain). I didn’t want to buy Pringles, so I used a cereal box. Here’s my setup before assembly:

Cardboard usually has a way it “likes” to be curled, and one that it resists (creases rather than curls). For this box, the preferred curl is horizontal. So I cut off the tabs at the top and bottom of the box, and curled it by hand a few times, to get the cardboard roughly in the right shape:

Then cut out two of the strips (I chose the input/output strip and the Reflector B), and carefully tape them into bands, put the bands on both ends of the tube, and let it expand, like this:

At this point, I put little tabs of tape inside the tube to help it hold its diameter, and fiddled with it until the bands were able to slide, but also didn’t have any slack. I tacked down the tube with a little tape, and pulled off the bands, then added a full-tube-length of packing tape to the outside-seam, like this:

Finally, wrap the three “rotor” bands around the tube, and tape them, again checking that they can slide around the tube, without being too tight. With the three bands on, add the Input/Output and Reflector B band to the outside-ends of the tubes. Align the grey bars on these bands, and tape them to the tube: they stay put while the rotors move. When you’re done, from left to right, you’ll have the Reflector, Rotor I, Rotor II, Rotor III, then the I/O band. It should look something like this:

Using your paper Enigma

(borrowing heavily from the Franklin Heath wiki – I will rewrite this with my own examples once the book chapter is done)

You can test your basic Enigma now. The “rotor position” part of the key is the letters between the grey bars. In the setup above, the rotor key is FAN. The next aspect of the machine is that each time you encode a character, you first “advance” the rotor, by carefully twisting its band towards you by one letter. Let’s pretend that the key was FAM, and we rotated the right band to make the rotor position FAN. After doing that, take the letter you’re encoding, and locate it on the I/O band on the right, and trace the lines from right to left. In this case, it’s nearly a straight line: A -> N -> A -> G at this point, we’re at the “reflector”, so trace the line on the reflector to see where it leads. It should be W. From there, trace the line back to the I/O band. When I did this, I got W -> I -> S -> K. K is the encrypted version of A. To encrypt the next character, you advance the right ring towards you and repeat the procedure.

With what you know so far, you should be able to decrypt the following message, with the rotors initially set at A B C:

A E F A E J X X B N X Y J T Y

If you get that, the rest of the Enigma is just minor tweaks to that process. We’ll go through each of them, because you need to do them all in order to decrypt real Enigma messages (which we’ll do at the end).

Advancing the Rotors

As you advance the right-most ring, eventually you’ll come back to the original configuration. If the Enigma did nothing else, it would be not too different from the Vigenère cipher – not a bad cipher (it was used during the Civil War) – but definitely not strong enough to protect against the codebreakers of the 1900’s. The next (and primary) advance of the Enigma machines was its rotor stepping process. When you are about to advance a band, look at whether the letters are grey in the line between the grey bars on the reflector and I/O bands, and

if the letter on the middle rotor is shaded grey, turn all three rotors one step towards you,

otherwise, if the letter on the right-hand rotor is shaded grey, turn the middle and right-hand rotors one step towards you,

otherwise, turn just the right-hand rotor one step towards you (this is the normal action).

Double-stepping

One tweak to the above procedure (which is, so far, just like a car’s odometer), is that if, after you follow the above procedure, the middle rotor’s grey bar enters the start position, then all three rotors step again. I’m not sure if this is critical to the strength of the Enigma, but doing so is critical to compatibility with real Enigma machines.

You can test whether you understand this part by starting in position B F C, and decoding
R Z F O G F Y H P L

Rings – changing the turnover points

The next-to-last feature of the Enigma is that which rotor positions trigger turnover could be adjusted. In the real machine, this was done by removing the rotor and moving a pin from one position to another. In our paper Enigma, it’s done by sliding rings over each of the rotors. Each ring covers up the letters underneath it, and its position determines a different configuration of the machine (is part of the message key). Ring positions are described by the position of the ring’s letter A with respect to the letter it covers. Position 1 means that the ring’s A covers the rotor’s letter A, 2 means A covers B, etc. For convenience, here’s a list of which ring letter A needs to cover for each ring setting.

Lately I’ve been focusing my efforts on teaching. One thing I’m working on is writing a book about cryptography, math and programming that is targeted at high school-aged students. One of my motivators is equity, so I’m licensing it under a creative commons license, and the source code to the book is here, on github.

Another motivator is enthusiasm – I like to convey my enthusiasm for the material to the students I’m working with. One way to do that is to tap into things they’re already enthusiastic about. For the book, it’s the innate fascination we all have about secret codes.

For this blog post, I’ve got a tidbit about graph theory that is motivated by many folks’ fascination with Pokemon Go. Pokemon Go players do a few different things: they walk around their town collecting items at Pokestops, which are associated with landmarks in the real world:

(image credit: Business Insider)

Some of those items are Pokeballs, which are used to capture the Pokemon creatures that also wander around town. You can evolve and power up the Pokemon you catch to make them more powerful. The reason you care about your Pokemon’s power is that in addition to Pokemon and Pokestops, there are Gymnasiums, which are also associated with real-world landmarks, but instead of having items, they’re places where Pokemon can battle each other. I’ll skip past the part about teams because that’s not relevant, but the part that is relevant is that a Gymnasium can have up to ten different Pokemon in it, and when you battle, you can choose six of your Pokemon collection to fight against the ones in the Gymnasium. The question is: “how do you choose which Pokemon to battle?”

It’s a good question because the designers of the game created complex varieties of Pokemon (e.g., Fire, Grass, Electric, Poison, etc), and a complex hierarchy of strengths and weaknesses among them. So, for example, it’s easy to remember that if you’re going up against a Fire-type Pokemon, that a Water-type Pokemon has a strong advantage. On the other hand, Fire has an advantage against Grass and Ice. It’s a lot like rock-paper-scissors, but with over a dozen types instead of just three. Even more complex than the Big Bang Theory’s rock-paper-scissors-lizard-Spock.

In computer science, the above diagram is called a graph. It’s not the same as the graphs we draw of functions, so it’s kind of a confusing name, but you get used to it. These kinds of graphs have nodes and edges. If the edges have arrows, it’s called a directional graph (digraph for short). What this graph tells us is that an arrow from one node to another means that the node “beats” the one it points to.

We’d like a similar diagram for Pokemon Go. It’s subtly different: instead of a simple “Fire beats grass” relationship, we have “Fire is unusually strong against grass”. Even so, this is important information. With a simple cheatsheet like this, we could go up to any Gymnasium with a decent collection of Pokemon, and do serious damage. Also, we could learn which Pokemon we should add to a Gymnasium to make it stronger. So, how to do this?

I started by Googling for “Pokemon Go rock paper scissors” to get a list of the strengths and weaknesses of Pokemon creature types. This list seemed good for my purposes. I don’t know how accurate or authoritative it is, but that’s not as important as what I did with the information. What I could have done is use an art program to draw the graph. The drawback of this approach is that it is very “brittle”, meaning if I want a different layout I have a lot of work to do, or if the data is wrong, I have do a tedious search through the diagram.

What I did instead is use a tool that is designed to take a definition of a graph as its input, and to create pretty drawings of them. The tool I used is called graphviz, and it’s quite powerful and configurable.

The input to graphviz is called a “dot” file (the filenames end in .dot). Here’s my conversion of the above Pokemon database into a dot file:

It’s really simple: to say that Dark Pokemon are strong against Ghost Pokemon I wrote “Dark -> Ghost” and so on. Then I loaded this file into graphviz (with and without the “#” in front of layout), I got these two images:

Pokemon Go battle strength graph

Same graph, circular layout

If you look closely you’ll see they have the same set of relationships, they only differ in how they’re laid out. Pretty cool, huh? So if you encounter a Gymnasium that has a Nidoking (ground/poison), Rapidash (fire), Snorlax (normal) and Gyrados (flying/water) you can use this chart, and know that you could choose a Water, Water, Fighting and Electric Pokemon to defeat them. Note that some Pokemon, like Nidoking, have two types, so you want to choose an opponent that is strong against one or both types, but is not weak against either. In this case, water fills the bill. Water works against fire, then you see that the only thing good against normal is Fighting, and finally electric against flying/water.

A nice follow-on activity, now that we have this graph, is to optimize sequences of Pokemon in Gyms so that it’s as hard as possible to defeat them. You’ll note that our above example had two water-type weaknesses in a row – you’d want to avoid that. After that, you’d like to find, given a set of Pokemon, which ones you can safely trade away, because their strengths are subsumed (dominated in CS-speak) by other Pokemon. And so on — there’s a lot of meat in this graph!

Thanks to a pointer from our neighbor (hi, Sten!), I decided to try to install MITE on my Mac.

It turns out the very good instructions in the MITE zipfile are very much Windows-specific. If you try to follow them as best you can on a mac, it’s probably not going to work.

Here are the Windows instructions: (interspersed with my MacOS translations)

Step 1 = Paste this folder into .minecraft versions folder if you have not already done so =

open Terminal and type

cd ~/Library/Application\ Support/minecraft

Step 2 = Copy 1.6.4.jar to this folder =

cd 1.6.4-MITE
cp ../1.6.4/1.6.4.jar original.zip

Step 3 = Rename it to 1.6.4-MITE.jar =

skip this step

Step 4 = Open 1.6.4-MITE.jar using WinZip or 7Zip =

First, in terminal type “open .” to fire up the Finder in this folder
In Finder, double-click on “original.zip” – it will create a folder called “original”

Step 5 = Delete META_INF folder inside =

In Finder, open your “original” folder, and delete the META_INF folder in there

Step 6 = Copy contents of class Files folder into 1.6.4-MITE.jar =

This is the key place where Windows and the Mac differ. If you drag the contents of “class Files” to the “original” folder, it will clobber important files. Instead, open the “class Files” folder in Finder, select all of its contents (first click on a.class, then press Cmd-a to select all), then drag those files to the “original” folder. It will ask if you want to keep or replace. IMPORTANT: hold down the Option key, and the “Skip” button turns into “Keep Both”. Select that.

This procedure does the important interleaving, then create the new, modified jar file with these commands (you have to have the “JDK” installed):

this is right, except drag it to “~/Library/Application Support/minecraft/resourcepacks”

Step 8 = Run the Minecraft launcher and edit your profile to use 1.6.4-MITE version =

Step 9 = Play Minecraft and select the MITE Resource Pack =

Yay – it should work!

The error message I kept getting when I followed the windows instructions was:

java.lang.NoClassDefFoundError: net/minecraft/client/main/Main

It was that error that lead me down the path of the solution. I checked the contents of my improperly-created jar file with the command

jar tf 1.6.4-MITE.jar

and saw that indeed there was no “net/minecraft/client/main/Main” entry. From there, I saw that the directory path in the “original” directory was deleted with the drag-and drop operation, and remembered the “tar” command solution to interleaving-copies (and then, thanks to Google, found the way to do this in Finder).

I hope this helps someone else install (the excellent-but-very difficult) MITE mod to minecraft. Apologies for the built-in dependencies on knowledge of “Terminal”, and assuming you’ve installed the JDK. It’s very possible you could avoid those dependencies, but this was my way of fixing the problem.

In our math club this afternoon, since it’s π day, I’m going to try to lead an activity where we write a program (on the Raspberry Pi, of course) that computes π. The idea I thought of (but we’ll see what the students think of as well) is to use the Monte Carlo method – guess random points (with uniform distribution) in a 2r x 2r square, and compute whether they’re “inCircle” or not (whether the distance from the center of the square <= r). Then use algebra to solve for the unknown quantity π in the formula

π r2 / 4r2 = inCircle / totalPoints

In my little Python program that does this, it pretty quickly gets to 3.14, but doesn’t get much further. Since these are 4th – 8th graders, I thought I should focus on techniques that have an intuition behind them, so Ramanujan’s fancy equations are out of the question. I’d be keen to hear other suggestions!More

My previous post (3 years ago!) mentioned that discountdomainregistry was a bit wonky. Turns out they were circling the drain, and about 2 years ago were bought by web.com. For some reason my “mecodegoodsomeday.com” domain didn’t come along with my other ones, and I had a difficult time convincing them I was the owner of the account, which interfered with my ability to renew the domain until…da da dum, a domain squatter (from Japan, of all places) registered my domain, and won’t let me have it back. The web.com folks in charge of the snafu apologized to me, but didn’t make it better. I’m bummed out.