Posts tagged computer science

Posted 6 months ago

Count on it

I want to write books that teach kids how computers work at their most fundamental level.

Perhaps the most fundamental concept in computing is how integers are represented and used as a code for the processor. Before somebody can understand that they need to be familiar with the concept of numerical place value in binary. Generally K-12 curricula don’t convey enough about why binary (and hexadecimal) are so useful and fundamental to our digital world. That’s why I have a plan to improve how kids are educated about numbers.

Pretend you’re a young child who doesn’t yet understand much about numbers. Now imagine you’re sitting at a desk. A rectangular area on the desk’s surface in front of you and you see a pile of blocks outside the taped area. You also notice some speakers and a monitor which prominently displays 0000.

You move several of the smallest blocks into the taped area. Suddenly the monitor changes to 0004 and you hear the speakers say “four”.

Surprised by the change you decide to move the blocks back out of the taped area.

“Wow, it’s back to 0000 again! And it said ‘zero’.”

You add the blocks you just removed. In response the monitor goes back to 0004 and you again hear “four”.

You repeat the process a few times and decide the monitor and speakers reflect something about the blocks inside the taped area. But what exactly?

The taped area has no blocks and 0000 illuminates from the monitor. Unsure what to think you decide to move small blocks into the taped area one at a time.

0001 (one)
0002 (two)
0003 (three)
0004 (four)

Your memory stirs. “Oh, that’s the one I saw before.”

0005 (five)

You recall your parents saying the same words as they touch each of your fingers.

0006 (six)

“That symbol changes every time I move a block. Will it change if I take away some blocks?”

0005 (five)

“Five, yeah, I just saw that one!”

0004 (four)

“I remember four too.”

After more experimentation it would be clear that these symbols and sounds map to the real world concept of quantity. Even better, the relationship between the three is continuously reinforced.

Now suppose all the blocks are taken away and replaced with rods.

0040 (forty)
0000 (zero)
0040 (forty)
0000 (zero)
0010 (ten)
0020 (twenty)
0030 (thirty)
0040 (forty)
0050 (fifty)
0060 (sixty)
0050 (fifty)
0040 (forty)

Doing the same thing with the rods results in different sounds, but the symbol changes are remarkably similar. In fact, they’re the same changes except that the position of the symbol that changes is different.

You’re given a rod’s length of unitary blocks back. Soon you realize that either adding all those unitary blocks or adding a single rod results in the same feedback from the monitor and speakers. From what you can tell this is true regardless of how many rods are already in the taped area. Eventually you conclude that a rod and ten unitary blocks represent the same quantity.

Place value in the base 10 numbers would become intuitive with enough experimentation. This system is flexible enough to work with other bases, including binary.

Going from that point to explaining how a 32-bit ‘word’ gets processed by a CPU isn’t that hard.

Posted 8 months ago

How does biology explain the low numbers of women in computer science? Hint: it doesn’t.

It comes up a lot in discussions of women in computer science, women who write code, women in open source. Eventually, someone brings up the fact that women score slightly lower on math tests. Clearly, they claim, this biological inferiority must explain why there are fewer women in math heavy fields.

It sounds like a compelling reason, and it gets a lot of play. Except, you know what? It’s a lie.

I’m a mathematician. I’ve looked at those numbers, I’ve read some papers. The research into biologically-linked ability is fascinating, but it simply isn’t significant enough to explain the huge gender gap we see in the real world. I used to do this presentation on the back of a napkin for people who tried to spout this misconception to my face, and I finally put it online:

How does biology explain the low numbers of women in CS? Hint: it doesn’t.

(Source: daysofrage)

Posted 12 months ago

The Implementation of Functional Programming Languages

While I was running with my coworker today he got me interested in the implementation details of functional languages.  In particular, he described how functional programs can be thought of as a graph of nodes and edges.  The program is executed by taking this graph through several reductions until only a single node remains.

Might as well take a look at Simon Peyton Jones’ explanation of the G-machine.