3 ms·
Ask HN: 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.
- serf 4y agoI 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.
- gregjor 4y agoMost 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.
- skydhash 4y agoPython got me into programming. I found about 3D and Blender after I got my first computer. While researching tutorials, I come across a book about creating games with the Blender Game Engine. I got interested, and installed Python on my PC. There was a tutorial section inside the help file, and you could test everything inside the IDLE app (Even GUI programming with Tkinter). No need to download anything else, which was a huge boost as I did not have proper internet at home. Python is straightforward to get started with. More so than JavaScript because, you do not need to learn 3 languages and can do quite interesting stuff without learning a lot of stuff at once. C is also easy to teach, but all hell breaks loose when you got to pointers.
- bananarchist 4y agoThe 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!)
- gregjor 4y agoI agree that starting with Javascript makes sense, everyone has it in their browser. But because JS only runs in the browser you quickly run out of interesting things you can do with it unless you want to throw yourself on the node/npm bonfire, which is sure to scare off beginners. Haskell makes you think in terms of functions from the beginning (as your example illustrates). I'm sure we agree that functions represent a powerful and important core concept, but that style does not have the obviousness of "print a + b" for most people. Even children understand doing things step-by-step, in order. Most adults don't get the concept of functions right off unless they come from a mathematics background. I don't miss BASIC (my first language as a teenager) in terms of programming languages, but I do miss having such a simple and usable tool available. I have tried to get all three of my kids interested in programming, with Python, Javascript, PHP, and none of them got hooked like I did at their age, when all I had was timeshared BASIC over a teletype. I can see their eyes glaze over as I explain how to install and start up Python and get it to do something -- the same look I get when they want to cook but not do any prep or reading recipes. My son fell into some programming backwards by learning enough Lua to customize Minecraft. But the social/play aspects of modern computer games have, I think, turned kids away from learning programming. If you experience computers through sophisticated games from childhood, as my kids have, getting Python to print your name or add two numbers seems unimpressive.
- wmf 4y agoI 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.
- amichail 4y agoWhile recursion may seem magical at first, it is not that important in day to day programming in languages like Python/Java. In any case, a Python assignment could require the use of recursion for the purpose of teaching recursion.
- Jtsummers 4y agoLazy evaluation works in a manner similar to generators in languages like Python. Deferring execution until it's actually asked for by enclosing the unexecuted bit in a "thunk" (Haskell term, in particular, but not the origin). Thunks can be simulated in eager languages using closures, coroutines, and continuations (among other approaches). If you've ever used futures and promises that are computed only when asked for, then you've seen lazy evaluation in an eager language. Java's Stream API makes use of lazy evaluation for the same reasons Python uses generators, deferring expensive or memory consuming actions until needed.
- yuppie_scum 4y agoWouldn’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?
- mrkeen 4y agoYes, and also its compiler could check for common mistakes and nonsense, and even produce binaries!
- jim-jim-jim 4y agoMaybe 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.