5 ms·
The key to really getting Haskell is learning to build a dialogue with the compiler. Sure, the type errors are intimidating at first -- they pack a lot of infor
by chongli 13y ago
The key to really getting Haskell is learning to build a dialogue with the compiler. Sure, the type errors are intimidating at first -- they pack a lot of information and use precise technical terms -- but once you figure one or two of them out you quickly begin to recognize the patterns. After that, you begin to feel comfortable correcting the type errors and subsequently feel confident about your program when it passes the type checker.
After a certain point in your progression, you realize that you can make certain type errors deliberately so that the type checker will tell you what types it's expecting. This is when it all clicks! The type checker is a tool that lets you query for information about your program. It's an immense aid to reasoning and a powerful sanity check against your assumptions. This is a capability that less strictly/statically typed languages lack and it can lead to a lot of surprises and guesswork.
- Kiro 13y agoI hope you realize we're talking about kids who has no prior interest in programming. I don't think teaching them to build a dialogue with the compiler is a key to anything in this case.
- chongli 13y agoI'm just speaking from my own experience teaching myself and subsequently teaching a friend. In the case of my friend, Haskell is his first programming language and he was absolutely delighted when he discovered that the compiler is an entity with which you communicate and that its communications help you understand its context.
- tikhonj 13y agoAu contraire: an interactive system with immediate feedback is perfectly didactic. Haskell isn't quite there yet--the error messages are somewhat cryptic and the interactivity isn't quite polished yet--but it's on the right track. Certainly further along in this vein than any other language I know! Some new features like deferred type errors and type holes are going to really help with this. Especially once editors start taking full advantage of this. I think that this is the future of programming: not writing a program and then debugging it, and not even just working in a repl, but being actively guided by your tools seamlessly as you write your code. Having a dialog with the compiler.
- pavelludiq 13y agoIf you want an interactive system, clojure or common lisp will be much better choices. Part of the reason I haven't gotten into haskell is because as you said, it "isn't quite there yet". Common Lisp has the added quality that an error trows you into the debugger, and that it makes errors much less punishing. If there is one lesson I've learned from gaming is that hard games don't repel the players if errors are easy to recover from and you aren't psychologically punished for them. Haskell isn't exactly a shining example of that, despite it's other great qualities. You want to make the teaching material challenging, not punishing(a great example of this is the game super meat boy). Not to mention the traditional argument for lisp as a teaching language: the extremely simple syntax. For somebody who hasn't seen code before, lisp would look just as weird as any other language, so the unfamiliarity argument doesn't hold much water. Prefix notation isn't at all difficult to learn, (+ 1 2) would be just as weird as dividing using / or multiplying with *, and using % for modulo division. You just tell the students that this is how you write math with a keyboard(a white lie at worst:). I'm currently working on a "try ruby" like tutorial to interactively teach FP using racket to college students, as my last year project.
- kazagistar 13y ago> The type checker is a tool that lets you query for information about your program. It's an immense aid to reasoning and a powerful sanity check against your assumptions. Sure. But it is a slower feedback cycle then a good IDE (which tells you what it is expecting as you type it). Also, the same can be said about an interpreter: you can try things, and when they fail, it lets you know what it was expecting.
- joeyh 13y agoThere are several projects that make the haskell type checker run on the fly (more or less) as code is entered in an editor. ghc-mod is one; hdevtools is another; FP complete has a web based haskell editor with on the fly type checking too.
- gnuvince 13y agoI recently installed ghc-mod [1] and configured it in Emacs; red squiggly lines appear when I have an error. [1] http://www.mew.org/~kazu/proj/ghc-mod/en/ http://www.mew.org/~kazu/proj/ghc-mod/en/
- kazagistar 13y agoWell, thats a start at least. Check as you type is only the tip of the iceberg, though, in creating a tighter programmer/compiler feedback loop. Detecting and listing all the possible choices for you to type automatically is something else... a good IDE can know which functions are valid in the current location, what values are valid parameters for those functions, and can list and auto-complete them.