HACKER Q&A
📣 amichail

Is it a mistake to introduce programming via Haskell instead of Python?


If experienced programmers find Haskell difficult, one can only imagine what beginning programmers must think of it.


  👤 wmf Accepted Answer ✓
I took an intro CS class in Haskell so I can answer this from experience. For simple functions Haskell is similar to algebra and quite easy to learn. Haskell also forces you to understand recursion instead of punting and writing iterative code. I started to find it challenging when getting into concepts that require lazy evaluation like infinite lists; we were never taught, and I still don't know, how this kind of code is executed. And of course since no real language uses lazy evaluation that knowledge wouldn't have been useful to me long-term anyway.

👤 gregjor
Most people learn programming so they can eventually get employed as programmers. Learning Haskell, or any niche language, may impart some deeper understanding of programming, but it won't get most people any closer to employment.

Don't underestimate the value of immediate success and gratification. Almost anyone can get "Hello, world" to work in Python (and I could name several other similarly "easy" languages), from installing Python to seeing something work, no matter how trivial. Getting to the same point and understanding how the code you wrote works with Haskell or Lisp presents a bigger hill to climb, which will discourage people. I have taught and tutored teenagers and college students in programming, and I've seen them get discouraged right away because they don't feel like they succeed in small ways.

All evidence from decades of programming indicates that most people understand procedural languages and style more readily than they "get" OOP or functional languages. Once someone understands the basics of writing any useful code and feels comfortable with things like control flow, variables, functions, data structures they can expand their skills with object-oriented and functional programming. I don't think those make good starting points, though. By analogy, children learn to read very simple books with pictures, because we want to teach them how to read anything. They can get to Shakespeare and technical books later, once they feel confident reading simpler books.


👤 bananarchist
The solutions to side effects that Haskell introduces are high minded concepts that take time to understand, especially as they are traditionally introduced. But no programmer coming to Haskell has issues with

addTwoNumbers a b = a + b

You can get quite far into programming concepts with just pure functions and the IO monad, the latter of which doesn't need to be understood for the purposes of printing output/scanning input. When you get into file manipulation and network calls it gets harder to avoid the tough topics, certainly, but that's also true of Python as this is when you get into async programming (and thus many pitfalls of mutability) and context blocks (monads by any other name).

With that said the only programming language beginners should work with is JavaScript because you have access to its interpreter anywhere you have a web browser (even without an internet connection!)


👤 jim-jim-jim
Maybe Haskell's okay if it's a uni course for sharp, motivated kids. Probably not a good idea for the general population, as much as it pains me to admit it. Learners need tight feedback loops that will actually run mistakes. Laziness, IO, and type strictness (I remember getting flustered by simple division) make Haskell an awkward fit for this interactive style of learning.

Python is shit though. I agree with the commenter who suggests the JS interpreter in one's browser.


👤 serf
I think experienced programmers find languages like Haskell difficult not because of an implicit difficulty, but because they may not match paradigms that are popular in universities and commonplace work environments.

That said, I think Python has a lot of conveniences that make an early level programmer become effective much quicker than most other languages; these conveniences may translate well to teaching.


👤 yuppie_scum
Wouldn’t it be nice if all your code was written in a language that literally every cheap entry level CS grad on earth can jump right in and handle with low ramp up?