Live data from Hacker News

Teenage Haskell

twdkz.wordpress.com

11–20 of 93 posts

Re: Teenage Haskell

#11
How 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.

Re: Teenage Haskell

#12

Earlier quoted context omitted.

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.

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 req…

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

#14
post #5

Earlier quoted context omitted.

This has been done with Scheme and works really well. But Haskell really is too complex.

Scheme is quite simple compared to Haskell or even ML. Yet even MIT moved from Scheme to Python.

Did they have pure intentions in that move? I thought it was more out of popularity than any good metric.

Re: Teenage Haskell

#15
post #7

I 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)?

Basically, 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.

Re: Teenage Haskell

#16
post #7

I 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)?

While a comment is probably not the right place for this, the essence IMO of FP is higher order functions (HOF). Being able to pass a function to another function, is key. And yes, even C can do this, it's just cumbersome.

From that key idea of HOF, other stuff arises, like the lean towards immutability. Which gives rise to things like recursion.

This is why functional programming in non-FP languages gets cumbersome. While they can "do" FP, all the other things you want aren't supported or require a ton of effort. Whereas in an FP language, those other things (immutability, recursion, pure functions, etc.) are treated better.

FWIW I've written a series (looking at C# specifically) on my blog http://www.atrevido.net/blog/2007/08/12/Practical+Functional...

But I think the blog may be messed up and it was written nearly 7 years ago when I was far less experienced with FP. There's probably far better intros out there.

Re: Teenage Haskell

#17

Earlier quoted context omitted.

Scheme is quite simple compared to Haskell or even ML. Yet even MIT moved from Scheme to Python.

Did they have pure intentions in that move? I thought it was more out of popularity than any good metric.

Who knows, everyone has their own opinion about it. Perhaps it was just too many parentheses for students to deal with.

Re: Teenage Haskell

#18
post #7

I 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)?

The wikipedia article [1] is a decent introduction. Functional programming is loosely-defined as a style of programming that involves using some subset of:

* Higher-order functions

* Pure functions / referential transparency

* Immutability

* A powerful type system

* A declarative style (expression-based)

(Some of the above concepts are closely related, and some people may feel there are other important ones I left out)

A functional programming language is loosely-defined as a language which makes programming in the above style possible, feasible, or easy.

[1] http://en.wikipedia.org/wiki/Functional_programming

Re: Teenage Haskell

#19

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 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

#20

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 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.

There are infinite loops in Haskell too. (And space leaks in python)
Post reply on HN