geek stuff 31 Aug 2006 11:15 am

Rebuttal to “Why Learning Haskell/Python makes you a worse programmer”

This post is a response to the blog post by Luke Plant titled Why learning Haskell/Python makes you a worse programmer. Now, in the interest of disclosure and keeping things civil, I actually do like this guy’s blog and particularly enjoyed his post A Django website that took (a lot) more than 20 minutes, and I think he’s shown himself to be quite a competent programmer in the other posts of his that I’ve read. That said, I heartily disagree with his contention that learning Haskell or Python makes you a worse programmer, and here’s why.

To the non-geek-inclined readers of this blog who have made it this far, here is a quick summary of the point/counterpoint. Python and Haskell are somewhat-lesser-used programming languages (read: tools), and his contention is that even though these tools are much better at getting more jobs accomplished it makes it more difficult to get the job done with more popular but inferior tools (in his case, the programming language C# which he is forced to use at work). With license for a little hyperbole, it’s kind of like saying that one shouldn’t learn how to use a Swiss army knife because it makes building things with just a hammer more difficult.

Now for a blow-by-blow. The first argument Mr. Plant raises in his blog entry is that it’s basically a letdown that he can’t use Python or Haskell in his work, because they more accurately reflect how he thinks about the problem at hand. A few choice nuggets from that portion of his entry:

It’s very common for me to notice that using either of these languages I could decrease a chunk of code by a factor of 2-5, and not rare to see a factor of 10-20 in certain parts of the code base.

Further, my experience with Haskell means that I now see potential bugs everywhere in imperative code.

Just reading those two things makes me think he’d be arguing the opposite point of view. At least in the latter one, he’s already improving his coding as a result of knowing Haskell, even though the first quote presents more of a “What if…” scenario that may never happen (since he must use C# at work). But, here’s where I think things start to go wrong:

The net result of these things is to make me very depressed and demoralised. I feel like a human compiler, translating the Haskell or Python in my head into a language which is a whole level lower.

Aha, we’ve found the problem and really it’s not an uncommon one at all. I mean, different programming languages are, after all, different languages. Perhaps often even more so than spoken/written languages. So as anyone who knows multiple languages (of any kind) probably realizes, we often treat the new language as something that we just have to translate to, often word-for-word. But, the new language might have constructions/tenses/idioms that don’t make sense in the original language. However, since we’re unfamiliar with them we tend to avoid them for a while at first. Eventually we adopt them into our understanding of the language and then we can even begin to use them effectively. Once you develop a sufficiently deep understanding of the new langauge, you may even find yourself “thinking in” that language (I’ve done so with Spanish, it’s very interesting). Now, while you may be able to make the smooth transition between the two languages, you’re no longer treating them as two dialects of the same language, you’re recognizing them as the separate languages they really are.

Keeping that in mind, let’s push forward to the second point Luke makes, and that is “using functional style obfuscates your code when using other languages.” (Translation for the non-programmers: literal translation gives messy results) Well, yeah, this shouldn’t surprise anyone, especially anyone who has tried to use Babelfish to translate anything semi-complicated. The tool that Mr. Plant is using (C#) has limited (and relatively new) functional language constructs, and the language wasn’t initially designed with them in mind so they don’t have the nice syntax that Python and Haskell have for dealing with them. As a result, trying to literally translate from Python or Haskell into C#, you get a mess. I mean, yes, it works but it’s ugly and awkward. Much like someone who doesn’t understand English well (but speaks another language fine) might be said to be speaking “broken English”, he is effectively writing “broken C#”. He apparently hasn’t learned to compartmentalize the two languages into different portions of his programmer brain, and is still trying to treat these programming languages as different dialects of some superlanguage (or maybe metalanguage) which all programming languages derive from. Now, in a sense, all programming languages are the same in that they can all quantifiably produce the same results, but lets not confuse Turing completeness with equivalence. Programming is, after all, a process and not a result — it’s not just making sure that you get there, it’s the path that you take to get there.

So, to conclude, it’s not learning Haskell/Python that will make one a worse programmer, it’s trying to shoehorn one language into another that will. Recognizing when is the right time to use certain idioms for certain language is a skill that takes time to develop but should eventually come along.

9 Responses to “Rebuttal to “Why Learning Haskell/Python makes you a worse programmer””

  1. on 31 Aug 2006 at 1:15 pm 1.Greg said …

    “Just reading those two things makes me think he’d be arguing the opposite point of view.”

    He IS arguing the opposite point of view. I guess it was a little too subtle for you. You seemed to react to his title, and not the substance of his article. He brings up up a good point; how do we reconcile the functional programming style with the industry standard tools many of us are forced to work with on a daily basis? Or is the only benefit for now us being more aware of the mistakes we are likely to make in OOP languages?

  2. on 31 Aug 2006 at 1:39 pm 2.Luke Plant said …

    Thank you Greg, saved me saying it :-) . In future I’ll make it clearer when I’m not being entirely serious, coming out of nowhere posts like that can be confusing.

  3. on 31 Aug 2006 at 1:45 pm 3.Dave said …

    As Greg said, I think you *soundly* missed the point.

    It *is* hard to go back to conventional programming languages (LFTM) after using an LFSP… *very* hard. Once you realize the expressiveness of a decent language, being shoehorned into something like Java (especially) or C# (3.0 will fix some issues, but the syntax… *shudder*) feels like taking a *huge* step backwards.

    He’s not really saying it will make you a worse programmer. Der.

  4. on 31 Aug 2006 at 1:47 pm 4.ddipaolo said …

    Well, that was easy!

    I guess to address Greg’s questions, I’d say:

    1) You don’t have to “reconcile” anything, you use the tools as they are meant to be used. Use C#’s functional support in “the C# way” (I believe one of the comments on Luke’s blog entry had a good example). Same thing goes for any idiom and any language.

    2) Yes, I think that’s the main benefit of knowing multiple languages and the paradigms associated with them. It may not teach you One True Way to solve problems in all languages, but it will open your eyes to new avenues of attack.

  5. on 31 Aug 2006 at 1:52 pm 5.Dave said …

    I still think you’re missing the point.

    Support for things that are easy in languages like Lisp, Ruby, etc. are hard and ugly in languages in C#, Java, etc. Even if you *do* it the “best way possible” in the less-expressive language it’s often more trouble than it’s worth, and the syntactic noise surrounding your solution drowns out any underlying elegance.

    This is what makes it difficult to work in “normal” languages once you’ve been exposed to languages where powerful idioms are much easier to express.

  6. on 31 Aug 2006 at 2:15 pm 6.ddipaolo said …

    To Dave’s first post: “he’s not really saying it will make you a worse programmer” — then why the sensational title? I mean, he literally is saying that, actually.

    To the second post: yes, I agree that even the appropriate/optimal solution in C#/Java often makes for a verbose nasty mess when compared to other languages. I’m simply addressing the contention in the title.

    And just because you know it can be done more easily in another language doesn’t mean it should be any more difficult to do it in the less-expressive language. More exasperating, perhaps, but not more difficult.

  7. on 31 Aug 2006 at 2:42 pm 7.Dave said …

    IMNSHO, If there’s more typing, more syntactic noise, less clarity, etc. then it’s more difficult by definition. Wading through muck is harder than walking on water.

    Why the sensational title? I don’t know, but probably so people would read the article? Juuuuust a guess ;)

  8. on 01 Sep 2006 at 3:03 am 8.wx said …

    haha, you just didn’t get it

  9. on 02 Sep 2006 at 9:58 am 9.MaryT said …

    As someone totally out of the loop regarding programming languages, I just want to comment on what a nice job you did in making this post interesting and accessible to non-techies. As an amateur linguist and full-time lover of languages, I think some of the points you made are applicable to interpersonal communication as well. Maybe oldsters don’t like “CU L8R” and such as that, but if we compartmentalize it as “The Language of Pizza-faced teens,” I doubt it will offend so much. But seriously, great post!