12 ms·
Teenage Haskell
- codygman 12y agoThis is awesome! I might have to contribute to codeworld, it seems like a really worthwhile project.
- MarcScott 12y agoMy brother (a Haskell programmer) and I (a teacher of high school CS) have talked about this often. He's postulated that teaching Haskell to kids with no programming experience would be an interesting experiment. Their lack of preconceptions regarding programming might make Haskell much easier for them to pick up, than it would for a student with experience in another language. What would be more interesting however, would be to teach a student Haskell first, and then introduce a language such as Python. Would they think Python was stupid or would they be grateful that all of a sudden they could use a for loop?
- seanmcdirmid 12y ago> Their lack of preconceptions regarding programming might make Haskell much easier for them to pick up, than it would for a student with experience in another language. Or traumatize them forever away from the field of programming. > Would they think Python was stupid or would they be grateful that all of a sudden they could use a for loop? I would love to know the answer to this, regardless of my own biases. But Haskell really does require discipline to use, and the kids would probably appreciate the more lax nature of Python.
- MarcScott 12y agoIt's an experiment that I'll never run. CS exam requirements are geared towards OO languages. Students have to analyse and write pseudocode using traditional programming constructs.
- seanmcdirmid 12y agoWhat are CS exam requirements? Are they standardized? I went through the American system, and never had any of my tests biased to OOP (except of course, a Smalltalk chapter in one PL zoo class). Object thinking is easier to wrap one's head around than mathematical formal thinking, but that's just because the former uses the brain's innate linguistic hardware (we learn to talk without much effort) while the latter requires training and practice.
- gamegoblin 12y agoPerhaps the commenter is referring to the AP computer science class, which I think is pretty OO based? In my experience at least.
- MarcScott 12y agoI teach in the UK. Here's the spec for one of our GCSE courses. http://www.aqa.org.uk/subjects/ict-and-computer-science/gcse/computer-science-4512 http://www.aqa.org.uk/subjects/ict-and-computer-science/gcse...
- ucarion 12y agoThe current AP standards focus a lot on OOP. Here's the latest course description: http://media.collegeboard.com/digitalServices/pdf/ap/ap-computer-science-a-course-description-2014.pdf http://media.collegeboard.com/digitalServices/pdf/ap/ap-comp...
- pjmlp 12y agoIn which countries? Just had a look at the curriculum of the Portuguese university I graduated from, a couple of decades ago and they still teach OOP, FP, LP across multiple languages.
- mpweiher 12y agoAt the TU-Berlin, our intro courses were held in FP languages, and we were indoctrinated as to the incomparable superiority of the approach...and could see for ourselves how the reality diverged from the hype. That was a good 20 years ago, but I just ran into a current student who told me that's still the case, and they still hate it as much as we did.
- klrr 12y agoI'm a teen I guess. Haskell as a first language worked great for me, and I happened to write a game and a few scripts in Python two months ago so I think I can answer your question. So, what made learning Haskell a good experience I think was mainly the strong type system. You could basically even early on use functions you barely knew what its name meant solely based on its type signature. It also made the progress of writing a program very nice, you write it and then it fails, you go back and try fix it, and when it compiles it usually worked. There are some things to keep in mind though. Wild recursion is really the GOTO of functional languages, it's important to teach how to use the generalized folds and traversals early on. Secondly it is important to have simple analogies to concepts such as functors, monoids and monads etc. If you make sure to not care about these strange names then you can go pretty far by just trying to make the type signatures stick together, and it's not important for a beginner to grasp these directly either. Python was quite smooth to learn coming from Haskell, the syntax is similar and it simply felt like programming in Haskell's do-blocks. It was very easy to get quickly going, I managed to write a little script talking to a JSON API almost directly after reading the official tutorial. I also digged a little bit into the realm of OOP, I wrote a simple game using Kivy. It felt quite nice actually, I could get some code re-use, although it was harder to get that (as newbie) than in Haskell. EDIT: Something like typed Racket might been even better when I think about it, since Racket got a lot of resources for complete beginners. Then you get the benefit of easy to use syntax too, although syntax is probably not the biggest problem when starting out. For the record I usually recommend Python or Racket when people ask me where to start, because in the end I don't think it matter much what language you go with first, just make sure not to limit the paradigm of languages you learn afterwards.
- codygman 12y agoThanks for sharing your experiences! I've always been curious about this.
- Dewie 12y ago> Or traumatize them forever away from the field of programming. The same can be said about using Python et al as the first programming language. How many people quit an introductory course to programming because they didn't like (say) the style of programming in Python, but could get an interest in it if the language being taught was some FP one (or maybe a logic programming language, etc.)? It's kind of hard to tell, because students who get turned away from an introductory course on programming probably aren't going to look up (or even know about) "programming paradigms" and see whether there are alternatives. Granted, how long would these people survive in the job market if they were able to be "traumatized" by some imperative language? There are certainly more imperative language jobs (or, they tend more to imperative style than FP style) in the job market, it seems. But even if they wouldn't like working as a programmer, they can still use it as a hobby if they like.
- seanmcdirmid 12y agoNon-math will always be more accessible than math. Unless you are teaching a bunch of mathematicians, then perhaps they would prefer the formal FP approach. Python is nice because you don't need to know about category Rory to get started.
- judk 12y agoThis has been done with Scheme and works really well. But Haskell really is too complex.
- seanmcdirmid 12y agoScheme is quite simple compared to Haskell or even ML. Yet even MIT moved from Scheme to Python.
- MichaelGG 12y agoDid they have pure intentions in that move? I thought it was more out of popularity than any good metric.
- seanmcdirmid 12y agoWho knows, everyone has their own opinion about it. Perhaps it was just too many parentheses for students to deal with.
- judk 12y agoMIT switched to Python because they believe modern basic CS is about controlling complex systems (web APIs, robot APIs) not walking through the history of CS from scratch and bare metal.
- fractallyte 12y agoHere are a couple of quotes from 'Realm of Racket', just to expand on your statement: 'All members of this [ALGOL] family are made from more or less the same material and for the same kind of programmers - those who love the machine more than the problem.' Contrast with Lisp: 'a language that would help programmers solve problems without forcing them to think about the elements of a machine.' So it really depends on one's interpretation of 'Computer Science', and the choice of what to prioritize from the subject: engineering or ideas.
- username223 12y ago> Would they think Python was stupid or would they be grateful that all of a sudden they could use a for loop? They would probably be at least as mystified by infinite loops as Python programmers are by space leaks.
- thinkpad20 12y agoThere are infinite loops in Haskell too. (And space leaks in python)
- username223 12y agoAre any of the space leaks available without explicit syntax, e.g. genexps? GHC is smart, but only smart enough to mostly hide your misunderstandings about what it can do with your code.
- seanmcdirmid 12y agoA space leak is simply pinning memory unintentionally, which definitely happens in most garbage collected languages. Perhaps Python programmers would be baffled by time leaks instead :)
- Quiark 12y agoThat's what my university did (Masaryk University Brno). It taught Haskell in the first semester. I, already programming in other stuff, was delighted to see a new interesting thing. Other students who already did some coding (PHP usually) reacted more like W.T.F. I'd this. I can't tell about the total newbs but in the end, only 30-40% passed. But that was mostly caused by their laziness because when they repeated the class and realized that they have to put in some work, the success was much better.
- seanmcdirmid 12y agoIf your class has a 30-40% pass rate! you have to blame it more than just on laziness. Actually, I thought laziness was a virtue in Haskell.
- Figs 12y agoDoesn't the University of Edinburgh teach Haskell to first year students? I've heard that from a few people at least. Not sure what their classes are like though.
- Swayworn 12y agoIf you're curious: https://www.youtube.com/playlist?list=PLtRG9GLtNcHBv4cuh2w1cz5VsgY6adoc3 https://www.youtube.com/playlist?list=PLtRG9GLtNcHBv4cuh2w1c...
- ics 12y agoI think it's pretty great. I didn't start programming until relatively late, but the more I study Haskell the more it feels like [an evolved form of] what I imagined programming to be when I was just a kid– busy syntax and all. Admittedly my misconceptions (I'll call them that because had I begun programming as a kid it probably would've been in Smalltalk, HyperCard, or C depending on where I was at the time) are one of the things that scared me away from exploring that path, but I one of the key factors would most certainly have been the tooling. The OP came up in my news feeds earlier today and I took a look at codeworld for the first time. Had that existed while being shown something like Haskell as a kid, I think I would've come back for more.
- tluyben2 12y agoI learnt (somewhere around 15 years ago) Haskell as 6th programming language and I remember finding it very confusing while my friends who had never programmed before didn't have as much issues with it. The second language they got taught was Java and after Haskell they very much disliked it. All of them (of course...) ended up as Java programmers in boring banking (etc) projects, but I do remember how they liked Haskell over it. Now, Java isn't exactly Python...
- quesebifurcan 12y ago> Would they think Python was stupid or would they be grateful that all of a sudden they could use a for loop? Interesting question. My first language was (Common) Lisp. Not sure if it was a good or bad choice (wasn't a choice really, more of a coincidence), or if those terms even apply. Anyway, I'm fairly certain it took me much longer than necessary to get my first projects done (hint: some of them were never finished). I spent a lot of time trying to express my ideas in a functional style -- avoiding the loop macro, avoiding side-effects whenever possible etc. Slowly but surely drifting away from the actual problems I had set out to solve. The feeling I got when I discovered Python is very accurately described in that xkcd comic which pops up in your browser when you type "import antigravity" in the interpreter. Then again, if Lisp was a detour on the path to becoming an "efficient and productive programmer", it was certainly a deeply interesting one which left me hungry for more -- I'm learning Haskell now (who isn't?) and am enjoying it immensely.
- Chattered 12y agoSpeaking as your brother, the thing that tipped me onto the preconceptions thing was the odd student who, with no prior programming experience, declared "oh, I get it. It's just maths!" I was the TA on the Edinburgh Haskell course over a couple of years, and took the attitude that, whether the students are any good at maths, they've at least seen it before, and so it was something I could use to bootstrap their understanding of the code they wrote. The Edinburgh course is very nicely paced. Students aren't thrown in at the deep-end. In the first tutorial we had them composing pictures along similar lines to that shown in the OP. By the third tutorial, they're using their repertoire of maps, filters and folds to do basic web scraping. The most advanced stuff we assess them on is writing recursive functions on recursive data-types, like a function that takes a simple mathematical expression and evaluates it. Come the final exam, they can pretend they'd never heard the word "monad."
- dmmalam 12y agoThey actually do this at Imperial College, London for computer science. Programming 1 is 100% haskell [1]. The idea is to have a level playing field for all students as many may have had prior experience in imperative languages. [1] http://www3.imperial.ac.uk/computing/teaching/courses/120_1 http://www3.imperial.ac.uk/computing/teaching/courses/120_1
- p1esk 12y agoI never tried Haskell, or 'functional programming". To be honest, I don't even know what functional programming is. Can someone explain how is it different from Python or C (the only two languages I did little coding with)?
- MarcScott 12y agohttp://learnyouahaskell.com http://learnyouahaskell.com
- cdsmith 12y agoBasically, the difference is that in a functional programming language, words like "variable" and "function" have the same meaning they do in mathematics. In C or Python, a "variable" is a storage location in which you can place different values at different times. This is completely different from mathematics, where "x" doesn't equal something different just because you progress to the next step of computation. (But "x" might refer to something different in a different context, such as when evaluating a function with a different argument; that's the sense in which it varies.) Similarly, in mathematics, there's no such thing as a function that returns something different each time you evaluate it, or that gives one result on Wednesday but a different result on Friday, or that even gives no result at all but causes letters to appear on a nearby computer screen. Yet in C or Python, all of these things are called functions. At first, it might seem surprising that you can do much programming without the C or Python version of functions and variables. But: 1. You can do more than you think without reassigning variables or using functions that aren't "real" functions in the sense of mathematics, and 2. Of course, in the end, all languages - including functional languages - do have a way to create boxes to store values over time, or to perform actions that make things appear on computer screens. It's just that in a functional language, these things are not the basic bread and butter tools of programming to the extent that they are in C or Python. So you have variables and functions (in the mathematical sense), and you also have other things that act like storage locations and actions, but you only use the latter when you have a real need for them. That's the general character of the difference. There is, of course, a lot of detail that I am leaving out in a response on a web site. The reason people were speculating about whether this would work better with people not yet accustomed to programming is that it's often thought that experience in an imperative language (like C or Python) leads you to naturally try to do things with actions and storage locations, even when it's not necessary... and then it can get frustrating and confusing to work in a language where most things are actually not done that way. There's a theory that says if you maybe learned the functional way first, you wouldn't find it as frustrating. I'm of two minds about that. I spent a year teaching Haskell with this system (I'm the Chris Smith mentioned in the article), and I found that it's partly true that students don't get as frustrated... sometimes. But there are other cases where students naturally fall into trying to do things in imperative ways, despite not having past experience in a programming language. I actually think, computer programming aside, that this is one of the things that trip up kids in math classes. So it's not just programming languages where this comes up: a lot of teachers present math as step-by-step processes, as well. Essentially, they introduce imperative programming without the computer. This is what happens when teachers tell students that parentheses are about what to do "first", instead of about which sub-expressions are meaningful on their own. Partly, I think this is just how the human mind works, too, and it's an inherent tendency that we have to overcome to really "get" algebra and other mathematics in a deeper sense than knowing how to do specific problems. It's still frustrating, then, for kids to adapt to having to describe processes using equations and expressions, which at their core do not list things to do, but instead describe and state facts about relationships between quantities. I still think it's an important skill to learn. Indeed, I'm a lot more interested in teaching that kind of reasoning than I am about teaching computer programming. That's why I made changes in the new CodeWorld (the site discussed in this article) that are designed to deliberately thwart students who try to think of their programs as sequences of actions, and encourage those who think in terms of compositional expressions.
- tzs 12y agoHow did Sam get his name into his sheep picture? I don't see any functions that draw text among the seven functions the kids had at that point, and the text doesn't look like it was built by just drawing rectangles and circles.
- chowells 12y agoIf you go to the site, you'll find a link to the docs in it. They're not complete, but they do at least list the functions available. One of them renders text as a Picture.
- Kiro 12y ago(&) :: Picture -> Picture -> Picture Can someone explain this line?
- m0g 12y agoIt's a type declaration saying that the & operator takes two Picture as arguments and returns a picture. So, if "a" and "b" are pictures "a & b" is typechecking. To be more precise, if you account for currying, it says that the & operator takes a Picture and returns a Picture -> Picture function. This function can then be applied to a Picture to yield a Picture. It's as I explained above but with an intermediate step.
- arianvanp 12y agoHow about http://elm-lang.org/ http://elm-lang.org/ ? It is very similar to haskell but a bit less daunting and all its libraries are focussed on building inbrowser games. Sounds like something kids would love. Now that i am brainstorming anyway. Something like http://scratch.mit.edu http://scratch.mit.edu would be so much nicer if it were a functional language! Instead of confusing blocks that maintain state every block is just a standalone welldefined function and combining blocks is just functional composition and application! I think it would be reaallt easy for a kid to digest mentally: blocks have inputs and outputs, thats it. Does anybody know if there are projects tjat accomplish this?
- seanmcdirmid 12y agoElm is this weird language that is really good at visual demos but is not anything interesting as far as language goes (if you want Haskell, just use Haskell, if you want FRP, there are plenty of libs for that, if you need pseudo FRP on web, then elm makes sense). Scratch would be impossible to use as a functional language, especially for the logo-style turtle procedural behavior they are aiming at.
- Velox 12y agoAt the University of Edinburgh, the first programming class we do in first year is an introduction to functional programming, which uses Haskell as the main language (it helps that Phil Wadler is the lecturer). Lots of students take to it much more easily than Java which is taught in the following semester. It definitely seems that viewing Haskell as a "hard" language is a product of an imperative programming education.
- emsy 12y agoCause I'm just a teenage haskell baby, use monads for a type named Maybe read papers on lambda calculus with me Ooohoo Hoo Hooooooo
- estebanrules 12y agoAnother great resource to learn functional programming. Thanks.
- superuser2 12y agoAt UChicago, there are two introductory sequences. The Honors course, intended for students who are already comfortable programming, is taught entirely in Haskell. Here's what it looks like: http://brick.cs.uchicago.edu/Courses/CMSC-16100/2013/lectures.php http://brick.cs.uchicago.edu/Courses/CMSC-16100/2013/lecture... The normal introductory CS course is taught in Scheme. Actually teaching - even acknowledging the existence of - functional programming was a major reason I chose that department.