News for hackers. Stuff that matters.
Re:Teenage Haskell by MarcScott on Friday June 27, 2014 @09:48PM (#7957158)
My 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?

Re:Teenage Haskell by tluyben2 on Saturday June 28, 2014 @03:21AM (#7957686)
I 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...
Re:Teenage Haskell by seanmcdirmid on Friday June 27, 2014 @09:52PM (#7957162)
> 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.

Re:Teenage Haskell by klrr on Saturday June 28, 2014 @05:27AM (#7957825)
I'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.

Re:Teenage Haskell by codygman on Saturday June 28, 2014 @05:41AM (#7957851)
Thanks for sharing your experiences! I've always been curious about this.
Re:Teenage Haskell by MarcScott on Friday June 27, 2014 @10:09PM (#7957193)
It'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.
Re:Teenage Haskell by fractallyte on Saturday June 28, 2014 @04:50AM (#7957786)
Here's a relevant comment I made just yesterday: https://news.ycombinator.com/item?id=7956162

In short, Scheme (Racket) is regarded as a superior beginner's language because of its simplicity, together with the ability to explore various paradigms (including OO).

Beginners in Scheme subsequently did better with Java than those who started solely with Java.

I think there's a deep lesson in that...

Re:Teenage Haskell by seanmcdirmid on Saturday June 28, 2014 @05:22AM (#7957816)
But scheme/racket is really not that far off from java compared to Haskell. I've never had a hard time working with it, even though I've never learned it formally (ok, two weeks of LISP a long time ago). Racket never felt weird, and many of its API are OO in everything but name, it's like C# with the same amount of FP abstractions (list comprehensions), and maybe some macros and continuations if you want to do something advanced.

But Haskell really is functional programming, there is no way to accidentally create an easy to use OO-style library. And then there are the monads....

Re:Teenage Haskell by steveklabnik on Saturday June 28, 2014 @12:03PM (#7958507)
Monads are pretty simple if you aren't pre-emptively primed with "monads are really hard."

I remember the day I sat down, worked through some examples, and grokked monads. I said, "That's it?"

That's not to say that they can't be hard to learn. I just don't think that they're _inherently_ hard to learn, and I think that they're sufficiently different enough from 'more traditional' CS concepts that said other concepts can hamper your ability to learn them. I suggest http://homepages.inf.ed.ac.uk/wadler/papers/marktoberdorf/ba... if you're still trying to figure them out.

Fun story: one time I had to suddenly explain monads to an English professor, because she overheard me say the word and said, "wait, Leibnitz?"

Re:Teenage Haskell by mpweiher on Saturday June 28, 2014 @03:45AM (#7957715)
At 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.

Re:Teenage Haskell by 59nadir on Saturday June 28, 2014 @04:26AM (#7957764)
Seems like your university is doing it wrong. While I do believe that the principles used in FP languages are vastly superior I don't think this is really a matter of debate. The advantages are obvious and if you didn't realize it you probably weren't taught well enough.

On topic:

I sometimes wonder if the wins from FP languages are lost on the people not already scarred by the pitfalls of imperative programming. I wonder the same about someone starting with Python instead of something more wordy and cumbersome. I don't think you really can appreciate the ease of use if you haven't already written tons of boilerplate or type information because the compiler is stupid.

At the same time you don't know the price of the ease you're getting, so there is a warped perspective on both the ease of programming and the performance of languages.

Haskell, I think, exists in a sort of middle ground where it's actually really fast but extremely expressive. Maybe someone uninitiated in programming won't have as many problems formulating functional solutions to problems in Haskell too.

Re:Teenage Haskell by mpweiher on Saturday June 28, 2014 @04:43AM (#7957779)
That's exactly the kind of hair-raising and mindless (in the truest sense of the word) nonsense we were presented with: "the superiority of FP is not a matter for debate".

The reality was that the tools were slower and buggier than others, the programs different (and slower) but no simpler and the bugs different but stilly just as buggy.

When presented so mindlessly and categorically, any claims of superiority instantly lose credibility. When reality is taken into account, even more so.

Re:Teenage Haskell by 59nadir on Saturday June 28, 2014 @04:54AM (#7957795)
The principles used in FP are actual principles you could employ in imperative languages... and people do, because they are obviously good. It's a matter of there actually being principles instead of the alternative; nothing.

This aside, you seem to be talking about the languages themselves, so let's go ahead:

> the tools were slower

Which tools are these? I don't see this as a systematic failure of FP languages.

Which language were you presented with? Did they explain what you're trading your speed of execution for?

I'm asking these questions because it doesn't really seem like you got it and this supposedly being 20 years later it seems like you're purposefully not getting it. In these discussions I find that a lot of people believe FP proponents to be very unpragmatic, but I find that in most cases, such as this one, there is little to no concession made on the "other side".

Most FP languages are not suitable for performance sensitive tasks and most people will admit this. For most other tasks, though, they're just going to allow you to work faster and get to where you're going with less hassle.

I would like to point out that I'm not saying FP languages are just better overall or that an FP language is always the best choice, but I am saying that the principles they employ and teach undeniably are the best. The alternative isn't as much a principle as it is a lack of principle. Flipping individual switches and modifying memory is just not caring.

Re:Teenage Haskell by mpweiher on Saturday June 28, 2014 @05:28AM (#7957828)
Wow, the arrogance and ignorance is just incredible, just the way I remember. :-) Someone who doesn't buy into your highly constrained world-view must obviously be ignorant.

"doesn't seem like you got it" ... "purposefully not getting it" ... "principles [..] undeniably the best".

No, you like those principles best, and that's about the most you can say. We don't even have solid criteria with which to make that call, never mind there being any type of consensus as to which is "best" (except within specific communities, but with each community having a different consensus and the most closed-minded of these communities usually the most sure of themselves).

Just to head off more ignorant comments: I aced those courses, as well as a few more including the elective "foundations of FP" and did my oral exam on Backus's FP calculus, which inspired me to come up with Higher Order Messaging: http://en.wikipedia.org/wiki/Higher_order_message

I also did some courses on algebraic specification and graph grammars (related to category theory), as well as formal specification with Z (yes, aced those as well). While useful in certain very constrained areas, these techniques trade making the smaller problem better (spec -> code) for making the larger problem ( actual problem -> spec ) infinitely worse.

Of course, functional techniques are a part of my toolbox, as they should be for any professional. However, if they were the only contents or even the majority of my toolbox, I couldn't do what I do and have been doing for the last quarter century.

Re:Teenage Haskell by timruffles on Saturday June 28, 2014 @08:05AM (#7958003)
Bravo! I doubt programmers will escape their quest for the 'right answer' to questions with context specific answers - but it's nice to see someone with the credentials making it clear that we should try.
Re:Teenage Haskell by coldtea on Saturday June 28, 2014 @05:59AM (#7957876)
>It's a matter of there actually being principles instead of the alternative; nothing.

BS principles are not better than no principles.

Or principles that tie your hand around your back for that matter. And functional principles do that for a lot of cases, with respect to performance, memory impact etc.

Functional languages are not some kind of 2x or 10x multiplier of a programmers abilities. In fact most of the things that made LISP interesting have been ported since ages in modern non-functional languages, from GC to closures, and even macros.

>Most FP languages are not suitable for performance sensitive tasks and most people will admit this. For most other tasks, though, they're just going to allow you to work faster and get to where you're going with less hassle.

Not the case in the real world.

For one, this BS idea forgets all about ecosystems and libraries. Python will let you work faster and get where you're going with less hassle. Functional languages that have 1/10 the libraries available, and in various stages of abandonment because of lack of programmers will not.

>The alternative isn't as much a principle as it is a lack of principle.

Really? For one, what all "FP languages" do when they run, is "flip individual switches and modify memory". The way they model the program is just an abstraction (and a leaky one) from what happens in the machine.

Second, I thought the Church-Turing thesis shows that lambda calculus is equivalent to the Turing machine way, for one.

Third, where did you get the idea that non-FP languages don't have principles? Smalltalk, for one, sure has tons of unifying principles behind it. Prolog. Erlang.

And if Algol was good enough for Dijkstra, modern, 10-times better algol derivatives are good enough for me. Especially if they also have adopted tons of functional paradigms, which you can get to opt to use when it makes sense for your design, and not have them forced upon you.

Re:Teenage Haskell by wz1000 on Saturday June 28, 2014 @08:03AM (#7957999)
Python is an amazing language. I have been using it to do all my automation and scripting work for a long time. However, Python programs almost always feel like they were held together with string.

I recently have been putting a lot of time into learning Haskell and it is amazing. The type system gives me so much confidence, and I have now reached a stage where writing Haskell programs is as concise and fast as writing Python programs, with a lot less bugs and a lot more extensiblity. The thing is that defaults matter. With Python, sure you can achieve a lot of this stability by using a lot of assertions, but who want's to do all that work to write a simple script. With Python, I used to have write once code that I would use for a task and chuck away. With Haskell and its abstractions, I reuse almost all of my code. I have completely replaced Python with Haskell as the programming language I use to do my daily work.

Sure, Haskell is very different from conventional programming languages and initially hard to learn since we all just want to change state. However, personally this style was surprisingly easy to internalize. Instead of modifing data, you are passing it through a series of pipes, transformers and filters to get your final result. It is very easy to reason this kind of code, though with laziness, Haskell makes it hard to reason about its exact performance.

> Really? For one, what all "FP languages" do when they run, is "flip individual switches and modify memory". The way they model the program is just an abstraction (and a leaky one) from what happens in the machine.

Well, all Python programs manage pointers in the end, and flip individual switches and modify memory, so functions and objects and all of that jazz are just leaky abstractions. We should all go back to assembly, or even better, flipping switches.

I believe the IO Monad to be a wonderful abstraction for what happens inside the machine. Monads are wonderful abstractions in general, and first learning how normal monads like the list, State and Maybe monads work is an amazing experience, but realizing how IO is just a special case of the State monad is mind blowing.

> Second, I thought the Church-Turing thesis shows that lambda calculus is equivalent to the Turing machine way, for one.

Yes they are equivalent just as Brainfuck is equivalent to Python, or C to Java, or Fortran to Smalltalk. These are all Turing Complete languages, so obviously they are equivalent!

> And if Algol was good enough for Dijkstra, modern, 10-times better algol derivatives are good enough for me. Especially if they also have adopted tons of functional paradigms, which you can get to opt to use when it makes sense for your design, and not have them forced upon you.

If assembly was good enough for Knuth, why are we not using that? x86 is good enough for me. Why are Algol derivatives forcing me to use the imperative style of code? Why can't I use a modern functional language and and use imperative, unsafe, statefull code when it makes sense for my design?

The problem is that defaults matter, and separating unsafe and safe code has a lot of advantages. Also, IMHO functional code is just easier to read and much cleaner. Instead of writing step by step instructions to the computer, we tell it what to do in a more declarative manner, because the lower abstractions can easily be separated out. Eg:- the canonical quicksort in Haskell [0]

[0] http://www.haskell.org/haskellwiki/Introduction#Quicksort_in...

Re:Teenage Haskell by mpweiher on Sunday June 29, 2014 @03:39AM (#7960606)
The problem with the "canonical" Haskell Quicksort implementation is that it is utter tosh.

The whole point of Quicksort is being a fast and in-place sort. That's its entire reason for being (the name kinda gives it away). An algorithm that's slow and not in place is not Quicksort and not "the essence" of Quicksort either. It's some other sort ("Slowsort"?) loosely inspired by a cursory reading of Qicksort and not understanding what Quicksort is about and why it is "quick".

The whole thing is somewhat typical though: "We have discovered that the essence of <well-known-thing> is <completely-different-thing>". No, you have discovered a mapping function from <well-known-thing> to <completely-different-thing> That's not the same as "the essence".

Re:Teenage Haskell by seanmcdirmid on Saturday June 28, 2014 @05:31AM (#7957837)
> While I do believe that the principles used in FP languages are vastly superior I don't think this is really a matter of debate. The advantages are obvious and if you didn't realize it you probably weren't taught well enough.

No, there are plenty of people who will debate this, programming languages academics even. There is a vocal FP crowd that fawns over elegance, but there are plenty of other people who are more pragmatic about it.

> I sometimes wonder if the wins from FP languages are lost on the people not already scarred by the pitfalls of imperative programming.

Pity the poor programmers who get things done, write huge beautiful systems, all without worshiping lambdas? And by taking shortcuts ala side effects as a way to making things easier.

> Maybe someone uninitiated in programming won't have as many problems formulating functional solutions to problems in Haskell too.

It depends on how much math they have behind them. You take a mathemegician, sure, but a high schooler who is still having trouble with pre-calc?

Re:Teenage Haskell by mpweiher on Saturday June 28, 2014 @05:51AM (#7957865)
> It depends on how much math they have behind them.

Very much so, and also depends very much on the problem at hand. Yes, compilers and yet another RB-Tree implementation can be great in FP. Most real-world problems aren't that. In fact, most real world problems I have encountered (and see) tend to be massively about manipulating state. Often they do little else than shuffle data around.

I sometimes think "computers" are misnamed, because they do so little actual "computation". "Data around-shufflers" might be more appropriate.

Re:Teenage Haskell by DasIch on Saturday June 28, 2014 @08:57AM (#7958072)
As a student of the TU Berlin myself, I feel that this has to be taken with a large grain of salt. In the first semester you learn one functional programming language, after that it's Java, C and MIPS Assembler.

The functional programming language is Opal, a language developed at the TU Berlin, it has barely any documentation, a compiler that only works on Linux and OS X, that is if it works because it has quite a few bugs, it further comes with a REPL that sometimes produces failures the compiler doesn't and tooling is non-existant.

So as a new CS student you have to learn using Linux and setup a development environment by yourself with barely any documentation to go on. You then continue learning only the very basics of programming such as what functions are, if statements, recursion, big O complexity, a little bit of parsing and though it's called differently: monads. At the end of the semester you then develop a renderer for a regular subset of HTML that includes only <html>, <head>, <body>, <title> and <p style="text-align: {left, right, center, justify};">.

On top of that the language has a couple of weird features: Every function can be used as any kind of operator if the number of arguments fits. This means that the parser has often problems figuring out precedence rules and you end up adding parenthesis around every expression just to be on the safe side.

Number literals also don't exist. There is a pre-defined set of functions which don't take an argument and produce a number such a 1-12 or so, n^10 for a few n, and a couple of 2^n for a few n. All other numbers have to be explicitly converted from strings. In practice this means you do the latter all the time so 1 turns into ("1"!).

Furthermore variables are defined by name and type. You can have two variables called foo in the same scope, if they have a different type and depending on how foo is used (Opal has type inference) one of the variables is chosen.

The prior feature is effectively necessary because Opal also doesn't have polymorphic functions. It has polymorphic "Structures". A Structure is file you can import, within that file you can define a set of variables that are polymorphic, the types of which are defined by however is importing it either explicitly or implicitly through type inference.

This is pretty much like how you might use the pre-processor in C to achieve polymorphism.

Have I mentioned by the way that a Structure is actually just a header like in C? In the Structure you only define the types of the API, the implementation is in a different file.

So a functions like map requires writing two separate files. Luckily it's in the stdlib.

Overall these features are fine, if everything works nicely but if you have an error somewhere, the compiler can emit massive difficult to understand errors, not unlike what a C++ compiler might produce for code that uses templates heavily.

The language and the choice to use that language is heavily critized by pretty much all students, functional programming however is not. In fact pretty much everyone would prefer if Haskell (which is the functional programming language closest to Opal) were used. The only reason it's not, is that the current prof for that class lead the team who developed the language.

Re:Teenage Haskell by mpweiher on Saturday June 28, 2014 @09:24AM (#7958138)
We were lucky in that Opal wasn't ready yet. :-P But we were horrified by what we heard about it.

So we were spared that particular disaster, which was and is sold using the same "unquestionable superiority" rhetoric. Instead we dealt with Hope. As in "I Hope it will finish in the next 15 minutes". "It" being a 10-30 line program. Usually it didn't, instead producing a largish coredump.

Our Sun 3-50 diskless workstations didn't help, but hey, Turbo Pascal could compile + execute a hundred lines of code in a second or two on the Z80 card in my Apple II+, a computer with several orders of magnitude less CPU/memory than those Suns.

Later we also used another language, I think it was Miranda. That introduced us to the joys of type inference. Magical when it works, completely inscrutable when it doesn't, especially since you don't get feedback on the cases that do work.

The big problem here is not that the tools were buggy and the languages less than fully thought out, that is fine, if presented that way. The problem is the complete disconnect between rhetoric ("perfection", "everything else is steaming pile of manure") and reality (sort of the opposite).

In the meantime, tools have certainly improved a lot (ghc/ghci on my MacBook Pro are quite tolerable), but the disconnect between rhetoric and reality is still there, because everything else has also improved.

Consider Opal itself: an FP language (so one of the domains FP is actually good at) in active development for more than a quarter of a century by teams using magical, all-conquering, flawless-marvels-of-correctness-producing FP unicorn-technology by teams of programmers that are experts in said technology. And it is, quite frankly, a steaming pile of manure.

EDIT: Hope: http://en.wikipedia.org/wiki/Hope_(programming_language)

Re:Teenage Haskell by DasIch on Saturday June 28, 2014 @05:51PM (#7959451)
Well you have to take into account the amount of effort, time and manpower spend on different languages and (in-)directly on different paradigms.

FP hasn't been given as much attention as imperative programming languages, especially not when it comes to the important last step of language development, which turns ideas that are nice in theory into tools that are actually convenient to use.

Java is a good example for how much that matters. The language is inelegant and makes it impossible to express yourself concisely nevertheless the tooling is incredibly good, so good that it makes up for quite a few surprises.

A FP IDE that for example shows you inferred types and type errors while you are writing the code, would already help a lot as it could much better visualize the problem, than a compiler that has to describe an error purely with text.

FP languages are not perfect, no language is but they have the potential to be much more powerful in lot of ways than imperative languages. Lisp is a good example for this although it's also a good example that such power can corrupt people to use macros in awful ways.

In any case when it comes to the rhetoric especially from professors, you have to take into account that they have spent their entire life specializing on what they are doing. Of course they are excited by what they are doing and even if they aren't they have a good reason to lie to themselves consciously or not because the alternative is acknowledging they wasted their life on bullshit. They are biased and that's ok, you just have to be aware of it.

Re:Teenage Haskell by mpweiher on Saturday June 28, 2014 @07:01PM (#7959662)
Your make some good points, but I don't quite buy them.

Turbo Pascal for example was written by a single guy, Anders Hejlsberg, in about 2 years for several platforms in assembly language, and included an integrated (though primitive) text editor/IDE.

Smalltalk was taken from ST-72 to ST-80 in 8 years, with small teams that also had to invent/implement complete VMs, operating systems, bitmap graphics engines, GUI framework(s) and sophisticated IDEs. You write that it would be nice to have an FP IDE so it could give you better feedback (or were you talking about an existing FP IDE). These guys built the live IDE (even better than types for direct feedback) in a fraction of the time. Does OPAL still compile to C? Does it still use Tk?

Think about Ruby, Python, etc.

I could go on (the VPRI stuff is also amazing), but I think you get the idea: it seems that not only can you be a productive member of society without FP, it sure looks like people can be a lot more productive without FP than with it.

Java is not really a good example of anything. Certainly not of an OOPL: "Java is the most distressing thing to happen to computing since MS-DOS." "If the pros at Sun had had a chance to fix Java, the world would be a much more pleasant place. This is not secret knowledge. It’s just secret to this pop culture." — Alan Kay (who coined the term "object oriented")

I don't quite get why you see LISP as an example for the power of FP, it is a multi-paradigm language with some functional elements, and most of its power comes, AFAIK, from its meta-system.

And HOFs like map or fold have been in other languages since the dawn of time, they're certainly in Smalltalk.

In terms of rhetoric, Peter Pepper might seem like an outlier, but as far as I can tell he is not. You can see it in this very thread: if you don't buy the self-evident awesomeness, it must be because "you didn't understand" and "refuse to understand", it cannot possibly be because you legitimately have a different point of view.

Another example. I watched the following talk by Simon Peyton Jones on data parallel Haskell:

https://www.youtube.com/watch?v=NWSZ4c9yqW8

Interesting stuff. But he has to go and say it: "this is only possible in a pure FP language like Haskell". Hand raised in the auditorium. "Actually, this sort of thing is pretty common in the HPC community, in FORTRAN [under some specific name]". And of course he can't just shut up and read up on things he obviously doesn't know about, he has to retort: "well, that means that it is nothing but a variant of Haskell at this point". Ouch! And finally, at the end of the talk he gives some numbers. It turns out that this amazing thing that's only possible in Haskell needs 6 cores to match the performance of a single core C program. 6:1. That's absolutely pathetic, especially when compared to what the HPC FORTRAN guys are doing. So maybe he shouldn't be lecturing them, they know this stuff a lot better then he does.

Now don't get me wrong, the talk was interesting and thought provoking, but the mismatch between grandness of the rhetoric and the paucity of the results was its usual epically proportioned self.

Re:Teenage Haskell by seanmcdirmid on Friday June 27, 2014 @10:33PM (#7957245)
What 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.

Re:Teenage Haskell by MarcScott on Friday June 27, 2014 @10:45PM (#7957266)
I 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...
Re:Teenage Haskell by gamegoblin on Friday June 27, 2014 @10:37PM (#7957253)
Perhaps the commenter is referring to the AP computer science class, which I think is pretty OO based? In my experience at least.
Re:Teenage Haskell by ucarion on Saturday June 28, 2014 @12:28AM (#7957415)
The current AP standards focus a lot on OOP.

Here's the latest course description: http://media.collegeboard.com/digitalServices/pdf/ap/ap-comp...

Re:Teenage Haskell by pjmlp on Saturday June 28, 2014 @02:41AM (#7957631)
In 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.

Re:Teenage Haskell by Dewie on Saturday June 28, 2014 @06:12AM (#7957897)
> 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.

Re:Teenage Haskell by seanmcdirmid on Saturday June 28, 2014 @10:30AM (#7958286)
Non-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.
Re:Teenage Haskell by Chattered on Saturday June 28, 2014 @12:22PM (#7958554)
Speaking 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."

Re:Teenage Haskell by quesebifurcan on Saturday June 28, 2014 @05:08AM (#7957805)
> 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.

Re:Teenage Haskell by ics on Saturday June 28, 2014 @01:15AM (#7957494)
I 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.
Re:Teenage Haskell by Quiark on Friday June 27, 2014 @11:47PM (#7957353)
That'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.
Re:Teenage Haskell by seanmcdirmid on Saturday June 28, 2014 @01:28AM (#7957520)
If 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.
Re:Teenage Haskell by dmmalam on Saturday June 28, 2014 @12:56PM (#7958650)
They 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

Re:Teenage Haskell by username223 on Friday June 27, 2014 @11:11PM (#7957317)
> 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.

Re:Teenage Haskell by thinkpad20 on Friday June 27, 2014 @11:15PM (#7957324)
There are infinite loops in Haskell too. (And space leaks in python)
Re:Teenage Haskell by username223 on Saturday June 28, 2014 @12:16AM (#7957390)
Are 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.
Re:Teenage Haskell by seanmcdirmid on Saturday June 28, 2014 @05:40AM (#7957849)
A 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 :)

Re:Teenage Haskell by Figs on Saturday June 28, 2014 @12:09AM (#7957375)
Doesn'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.
Re:Teenage Haskell by Swayworn on Saturday June 28, 2014 @09:01AM (#7958081)
Re:Teenage Haskell by judk on Friday June 27, 2014 @10:01PM (#7957177)
This has been done with Scheme and works really well. But Haskell really is too complex.
Re:Teenage Haskell by codygman on Saturday June 28, 2014 @12:09AM (#7957377)
What about Haskell is too complex?

If you go through A Gentle Introduction to Haskell[0] I think you'll see it's a pretty simple language. There aren't that many parts of core Haskell to learn about.

Perhaps the abstractions such as Monad and Functor are more complex, but they don't seem anymore complex than some of the design patterns used to accomplish what they're used for.

0: http://www.haskell.org/tutorial/

Re:Teenage Haskell by cdsmith on Saturday June 28, 2014 @05:30AM (#7957836)
It's worth mentioning that the tool this blog post is about defines a simplified version of Haskell's standard library. In particular, there are no type classes exported from Prelude, much less monads or functors. In the end, it's not really any more complex than Scheme, except for syntax.

Now, true, the syntax is much more complicated than Scheme. You can operators and precedence and all that. But while definitely complex, it is mostly consistent with math notation. I tried to teach with Scheme first (following www.bootstrapworld.org) before I created this, and I found the change in syntax from what they are used to can be a real obstacle for children. This is also consistent with the comment about MIT moving to Python, which similarly has much more complex but familiar syntax.

Re:Teenage Haskell by gizmo686 on Saturday June 28, 2014 @12:27AM (#7957411)
Monad and Functor are abstract, not complex. One of the things that is easy to forget once you know something is that the complex and concrete thing is often easier to understand than the simple and abstract thing. Of course, eventually you begin to consider the abstract thing to be concrete.
Re:Teenage Haskell by cousin_it on Saturday June 28, 2014 @07:42AM (#7957978)
If you just stick to the idea of type classes, then yeah, it is simple and abstract, even for constructor classes like Functor and Monad. But the reality of type classes in Haskell is not as simple, I think. Defaulting rules, "deriving", Paterson conditions, instance coherence, functional dependencies, etc.
Re:Teenage Haskell by seanmcdirmid on Friday June 27, 2014 @10:35PM (#7957249)
Scheme is quite simple compared to Haskell or even ML. Yet even MIT moved from Scheme to Python.
Re:Teenage Haskell by MichaelGG on Friday June 27, 2014 @10:53PM (#7957287)
Did they have pure intentions in that move? I thought it was more out of popularity than any good metric.
Re:Teenage Haskell by thinkpad20 on Friday June 27, 2014 @11:22PM (#7957332)
The first time I learned programming it was Scheme, and I didn't care for it - the syntax was confusing and it felt more like magical incantations than giving the machine instructions. I didn't touch programming again for several years, but when I did it was python. I found it was much more interesting, in part because of my state of mind but also because I could see the computer responding to what I told it to do and I liked being "in control" of the machine rather than the other way around (which FP can sometimes feel like). I love functional programming now and I write a lot of Haskell, but I think there's real value to starting out with an imperative language to get that "interacting with the machine" feel. It also makes it easier IMO to learn about computational complexity, systems, etc. That, and python has a ton of great libraries, an intuitive syntax, and a lot of flexibility, so I'm not surprised they've adopted it.
Re:Teenage Haskell by seanmcdirmid on Friday June 27, 2014 @11:08PM (#7957312)
Who knows, everyone has their own opinion about it. Perhaps it was just too many parentheses for students to deal with.
Re:Teenage Haskell by judk on Saturday June 28, 2014 @01:51AM (#7957553)
MIT 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.
Re:Teenage Haskell by fractallyte on Saturday June 28, 2014 @04:43AM (#7957780)
Here 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.

Re:Teenage Haskell by andreasvc on Saturday June 28, 2014 @05:28AM (#7957826)
That is an incredibly condescending way of arguing. On the other side of the coin you could claim that imperative programming is more practical, concerned with the actual steps needed to solve a problem, instead of an ideal, indirect formulation. Imagine having to explain someone how to bake an apple pie without being able to state any specific steps how to do it but instead describing the pie as some set of interrelationships of the ingredients. (That is probably not a fair characterization of FP, but it's at the same level as "[imperative programmars] love the machine").
Re:Teenage Haskell by fractallyte on Saturday June 28, 2014 @06:30AM (#7957914)
Actually, I would point out that Lisp is not limited to any single paradigm...

But something else you wrote brought to mind this rather interesting statement from - of all places! - the introduction to Michael Barnsley's famous book, 'Fractals Everywhere':

'In deterministic geometry, structures are defined, communicated, and analysed, with the aid of elementary transformations such as affine transformations, scalings, rotations, and congruences. A fractal set generally contains infinitely many points whose organization is so complicated that it is not possible to describe the set by specifying directly where each point in it lies. Instead, the set may be defined by "the relations between the pieces." It is rather like describing the solar system by quoting the law of gravitation and stating the initial conditions. Everything follows from that. It appears always to be better to describe in terms of relationships.'

Re:Teenage Haskell by andreasvc on Saturday June 28, 2014 @11:16AM (#7958385)
I have no idea how your reply relates to my comment. I wouldn't claim that Lisp is limited to a single paradigm, nor do I see how fractals are related to the discussion at hand.
Re:Teenage Haskell by fractallyte on Saturday June 28, 2014 @11:42AM (#7958453)
The point is that Lisp can be imperative too. But, because the language was not constructed according to the underlying physical architecture, it's not bound by the limitations of ALGOL-like languages.

So, rather than condescending, I find this interesting: these are two dissimilar approaches to solving problems.

Your comment about baking an apple pie 'without being able to state any specific steps how to do it but instead describing the pie as some set of interrelationships of the ingredients' was also an excellent statement of the differences between these points of view.

Barnsley's perspective was that relationships may indeed be a better way to describe structures. His concern was fractals, but perhaps the analogy extends to the logical structures that comprise a program.

Re:Teenage Haskell by andreasvc on Saturday June 28, 2014 @05:24PM (#7959394)
What are the "limitations of ALGOL-like languages"? As Turing-complete languages, they probably do not have actual limitations, rather, they suggest a style of programming which may be more or less applicable to particular problems. Functional programming, depending on how pure it is, does have limitations, notably avoiding mutable state.

You can claim that it's interesting that there are these two approaches, but the quotation you gave was definitely condescending, because it flatly states that one approach is better than the other, despite the widespread success of the latter. The argument that it's good to abstract as much as possible from the machine is interesting, but to me it is by no means obvious.

I don't really see the relation with fractals. Although it is an interesting quotation, the relation of fractals to real world phenomena is often very dubious.

Re:Teenage Haskell by marcosdumay on Saturday June 28, 2014 @09:09AM (#7958100)
> without being able to state any specific steps how to do it

All functional languages can express a sequence of steps. More yet, on most of them you can later decide to transform the sequence, instead of just generating code from it.

Re:Teenage Haskell by seanmcdirmid on Saturday June 28, 2014 @10:23AM (#7958266)
As can be done in a procedural language also (and a technique that I use often).
Re:Teenage Haskell by JacksonGariety on Friday June 27, 2014 @11:37PM (#7957347)
SICP is still the bible, even through Python has become the "practical" language that's also quite simplistic.