Skip to main content

Learning by Doing

I’ve always considered myself someone who learns much, much better by doing than by reading. This was reinforced to me yesterday, when I took one of our CS314H Data Structures projects and rewrote it entirely in Clojure.

For me, the hard part is finding something to do. I’ve been eyeing Clojure as a fun and elegant programming language from what seems like the past four or five months. I downloaded the thing, played at the REPL every chance I got, and read the amazing book Clojure For the Brave and True probably four times. I still didn’t feel like I had a grasp on the language basics.

Yesterday, I decided to dive in cold. I installed the Cursive Clojure plugin for IntelliJ IDEA, set up a Leiningen project, and opened up the Java program to the side.

The RandomWriter program is something that takes an input text, and does a Markov-like analysis over it. That is, it picks a seed of some length (that the user decides), then builds a mapping of every possible character following that seed in the original text. Then it selects a candidate using a weighted random selection. This process repeats until enough text has been generated (also user-decided).

In short, I learned a ton of stuff that reading boring docs and the book wouldn’t have taught me. I learned how to use reductions and drop-whiled, and I even reimplemented frequencies because I wasn’t aware it existed. I used transients, slurp, spit, the ->> macro, and even memoize..

Long story short, I need to stop reading and start doing sooner.