I’m presently studying functional programming for the first time using Haskell. This is the type of thing one gets to do when being unemployed - study a topic of intellectual interest that absolutely had not come up in my daily life as an MLE, nor as a pentester.
My interest in Haskell is probably similar to yours having clicked on this article. You’ve heard things. Once you program in a pure functional language for long enough, the way you solve problems change. This insight, once acquired, effects the rest of the long tail of your software career. Your brain gets bigger. The sky gets bluer. Activities you used to love once again provide pleasure.
The people who love it claim to really love it. Other people say it’s a purely academic language not used by people who write serious software. But the success of pandoc and xmonad suggest the truth is somewhere inbetween. Also, Gwern’s Blog uses it and I would like to imitate Gwern’s blog. And so I wanted to take the time to study it seriously, and writing that up for you, dear reader, is my way of holding you accountable.
I’ve tried writing Haskell before. Or, that is, I’ve tried reading the book Learn You a Haskell For Great Good probably three times, getting through chapter two or so each time before bouncing off of it. I definitely heard the words that Haskell was statically typed, lazily evaluated, and without side effects multiple times. Thankfully, I was writing Java for a college class at the time, so I actually knew what it meant to be statically typed. The others, eh, not so much.
But the main reason for learning Haskell isn’t really about the practicalities. It’s about trying to understand the near religious devotion fans of the language have to it. As an ml engineer/pentester, my daily driver is python. Its been python, it’ll probably always be python 1.That said, I don’t like python. I don’t really care about python either way. I like the dynamic type system when I’m writing scripts for a small project, I hate trying to maintain a large codebase in it, but I usually work at startups or as a consultant so you can graph my dissatisfaction falling the longer I work on any given problem with it and usually it just doesn’t matter. It solves my problem and its ecosystem is so unbearably large that I very infrequently have to write any code that isn’t super specific to my business/design/security/research problem. So I tolerate it.
Haskell writers love it, though. There is a whole bonafide cult around it. And if you’re anything like me, you probably believe that love is overblown. It’s mostly just dudes talking on the internet and it is much more likely that someone being loud about a programming language online doesn’t write very much software and is just into getting into cultural arguments than it is that they actually care about the language. I can’t prove that’s not the case, but I can tell you a compelling anecdote about one such acolyte, which is worth whatever \(n=1\) can be.
The Guy I talked to who loved Haskell (and it changed his life (not clickbait))
In college I spent a lot of time thinking about starting a startup. The curious thing about being an undergrad who wants to start a startup is you’re sort of a worshipper in want of a deity. You don’t have a whole lot of technical expertise yet2 but you want to be all in on some particular problem. My pet problem for that semester was the tooling for collaborative scientific research.
Fresh off a bioinformatics summer internship where I’d been the only programmer in a wet lab, I was appalled at the state of project management. People were passing Microsoft Word files around, for God’s sake. They didn’t even know about git. Tracking changes was difficult, tracking down data was difficult, etcetera. All problems we’d solved in software3. So, I decided my business would be about creating modern research management software built on top of git that would introduce the 21st century to all sorts of research endeavors. Cool!4
I googled around trying to see if anyone had ever tried a business like this before. It turns out that someone had - and not only had they, they had been in the same Florida area as me! I found their website, which seemed to be defunct. Articles I found online suggested they’d been started only a year or two prior. These struck me as bad signs, but with the rose-colored glasses of new-endeavor-mania upon you the red flags, as they say, just look like flags.
I figured I would get ahold of one of the founders who had worked on the project. There was only one whose email still seemed to be active, but the easiest way to reach out to him seemed to be Google Plus5. I messaged him on the spot. It was maybe midnight, so I didn’t expect to hear anything back that night, if I ever heard anything back at all. My message was basically some variation of:
“I wanna do what you guys did at X. It seems like it didn’t work out for you. Can you maybe provide some advice as to what you would’ve done differently, and what big assumptions you made that didn’t end up being true?”
He responded almost immediately. Super nice guy. He explained that the company had been built on top of a fork of Gitlab, tuned towards researchers. He explained that the initial response from academics had been really solid, and they were in talks with a variety of universities when they dissolved. That, it turned out, had been the problem. The buying cycle for the average university was just too long. They died waiting for a handful of checks that would’ve sustained them for at least another year, all because they misunderstood the spending cycles and timelines of their biggest potential customers.
“Damn, dude,” I typed back, “That’s a bummer. Anything you would do differently?”
Again, I wasn’t expecting an answer. That didn’t occur to me as a “do differently” problem, that seemed closer to an “I accidentally got really excited about an industry not conducive to bootstrapped product startups” problem. Also, it’d been a year, not many people would want to really dig into their failure with some random guy on the internet. But I got an answer. It basically went:
“Instead of using Gitlab, I would’ve rewritten the backend in Haskell. It’s just so much more fun to write, and the code is basically bug-free.”
That didn’t seem like it would’ve made a real difference in whether the startup would’ve succeeded though. It actually sounds like it would’ve made it worse, since your time to build a prototype is higher (porting all that rails of Gitlab to Haskell), meaning you’d find out about your customers timelines for payments later. I hesitantly inquired as to whether this would actually effect what was important about the failure.
“No, but it would’ve been more rewarding. It failed anyway, but I would’ve had a better time.”
Ah. Kinda nihilistic but still weirdly romantic about Haskell. What was he doing next?
“After falling in love with Haskell, I decided to go back to school for pure mathematics.”
I thanked him for his time, closed my laptop, and spent the next decade thinking about that conversation. Haskell had honest-to-goodness changed that dude’s life. He had been the kind of person, like me, who wanted to do whatever was necessary to solve practical technical problems, and it had changed him to someone who clearly saw some actual beauty in solving a particular class of problems a particular way. I just don’t see a lot of startup people going back to school as pure math people. Do you know pure math people? I know pure math people. I’ve worked with pure math people. Convincing them to be practical was almost as difficult as them convincing me of the bone-deep beauty of a particular problem solving approach that had zero to do with shipping software.
I spent the next ten years mostly working in startups and consultancies. Throughout, I would think about functional programming once in a while. If I did it enough, would I also start to find writing code beautiful enough to just do it for its own sake, unrelated to the problems I was solving or the dollars I was getting paid to do it?
Almost definitely not. My interest is in making autonomous hackers, which turns out to be a mostly very applied problem. But, I hope to learn enough about it that I can empathize with the guy who went from startups to pure math 6. Probably it’s just a language with some nice features that’ll bend my brain a bit. But we’ll find out!
Resources
I’ll be using the following resources for Haskell.
Books
- Haskell Programming from first principles: I’ve heard this book had a lot of exercises. I never learn anything without exercises, so purely from a pedagogical perspective this experiment has no hope of success without them.
- Learn Haskell by building a blog generator: This one is free and involves building some actual software. I love doing exercises to get the gist, but the other thing that frustrates me is getting to the end of a textbook and not really knowing what the right way to structure a project would be if I started one. I’m hoping this book moves me in that direction.
Software
- Hakyll: I’ve used Jekyll based blog builders forever. That said, I only knew as much ruby as I needed to edit metasploit modules. I’m hoping to more fully understand this software.
- Pandoc: I was sort of shocked to find out pandoc was written in Haskell. Honestly, my brain just combined the fact that pandas is in python, all the document rendering in python has used pandoc, and it starting with a p to decide it was written in python. Stolen valor. Anyway, they’ve also got some starter issues, and closing a few tickets would prove some non-trivial Haskell knowledge I think.
- Gwern’s Blog Builder Thing: I really like the look of Gwern’s blog, so I hope to be able to understand the static site builder, which is written in Hakyll, to build something with similar readability and sidenote support.
Footnotes
If we get a statically typed language to express deep learning computations in in such a way that doesn’t provoke madness before the singularity and has the same tier of ecosystem, then I’ll use that. But we don’t have one yet.↩︎
I didn’t, anyway. If you’re one of those really smart college students who’s been programming since you were ten or whatever, move along. I was eating Denny’s in diners with my buds at 3am and reading too many comic books.↩︎
Again, I was literally like twenty years old at the time. I didn’t solve any of those problems. Nor, will I say, did I understand the solutions to those problems yet. Time helps.↩︎
As I recall I also had it in my head that the ability to comment on nicely rendered html of a paper that had git tracking on it, if sufficiently aesthetically beautiful, would immediately ensure the business was profitable for a million years. A natural consequence of this is that the modern journal mafia would fall apart, research would be free, and we would be able to autonomously track retracted papers and follow their citations in a big graph that would allow us to be more discerning around reading papers that referenced retracted work. These were all very related problems in my mind. Heady stuff.↩︎
At time of publishing, this probably sounds fairly fantastical. I assure you that even when it happened, 2014 or so, it was fairly fantastical.↩︎
Also, if you end up reading this, I would love to talk to you again. Like, interview you ideally. If you were responsible for technical execution on a research management startup built on a gitlab fork circa 2012-2015ish and you remember Google Plus, you’re probably that person↩︎