Experiment #2

In my first experiment, I tried teaching some category theory from a programmer’s point of view over on Google+, but the platform wasn’t right for the content: posts got reordered whenever someone commented on them, and people didn’t have time or were too shy to engage at the rate I was hoping for.  In this experiment, I’ll try it in a blog format and focus on the one programming language everyone on the internet has access to: JavaScript.

Since the category of computably enumerable sets and partial computable functions is—ahem—functional, choosing an imperative, dynamically-typed language might seem strange.  Dynamic typing, though, can be seen as a tagged union of all possible types, so by using contracts we can split them up again.  It also offers benefits like being able to say “the type of prime natural numbers” that we aren’t usually able to express statically.

As for the statefulness of JavaScript, I’ll start with the functional part and show how it avoids all kinds of problems with testing code—so you ought to be programming functionally anyway—and then (eventually) show how the standard object model JavaScript uses can be seen as a state monad on the functional part.

I’d like to do some videos as part of this, too: drawing commuting diagrams beautifully is still difficult on the web.  (If you know otherwise, please tell me how!)

So, welcome!  Please ask questions—it’s what keeps me motivated, and everyone else who doesn’t understand will thank you for it.


2 Comments to “Experiment #2”

  1. Have you tried d3 for diagramming?

    • @Ben Ford, WordPress.com blogs don’t allow me to run arbitrary JavaScript, so d3 (while impressive) doesn’t look like it’ll help me here. I’m looking into writing a Caja plugin for WordPress and hoping it becomes popular enough for them to include it among those they run on their site so that people can use jQuery, d3, and other such libraries without exposing WordPress to the hazards of third-party scripting.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: