On Sep 6, 2009, at 9:05 PM, David Leimbach wrote:
On Sun, Sep 6, 2009 at 10:08 AM, Eris Discordia <eris.discor...@gmail.com
> wrote:
In this respect rating the "expressive power of C versus LISP" depends
very much on the problem domain under discussion.
Of course. I pointed out in my first post on the thread that "[...]
for a person of my (low) caliber, LISP is neither suited to the
family of problems I encounter nor suited to the machines I solve
them on." I cannot exclude other machines and other problems but can
talk from what little I have personally experienced.
I would like to see Haskell fill C's niche [...]
Is it as readily comprehensible to newcomers as C? Are there texts
out there that can welcome a real beginner in programming and help
him become productive, on a personal level at least, as rapidly as
good C textbooks--you know the classic example--do? Is there a
coherent mental model of small computers--not necessarily what you
or I deem to be a small computer--that Haskell fits well and can be
taught to learners? I imagine those will be indispensable for any
language to replace existing languages, much more so in case of C.
According to the designer of F# (another functional programming
language that takes it's syntax from O'Caml as well as Haskell and
even Python), one of the best experiences he'd had was working with
a high school student who was able to modify a solar system
simulation written in F# with no prior programming experience.
(from http://www.computerworld.com.au/article/271034/)
There's books on F# out there, and F# for Scientists.
http://www.ffconsultancy.com/products/fsharp_for_scientists/index.html
There's books on multimedia programming in Haskell out there that
also attempt to show programming to newcomers, but I'm not sure any
of them really assume no prior programming experience.
I think people learning C get one view of the computer that folks
learning assembly really learn to appreciate :-). Folks learning
Haskell learn another mental model of programming as well.
My personal belief is that learning new languages makes one think
about the languages they are used to in a new light, and can make
them better programmers overall.
As you mentioned beginners books for Haskell I couldn't resist
plugging Graham Huttons excellent beginners book "Programming in
Haskell":
http://www.cs.nott.ac.uk/~gmh/book.html
It is based on 10 years of teaching a first year undergraduate course
and is certainly accessible I believe. I've taught an undergraduate
course myself using it.
There is also the this book which complements Graham's quite well:
http://www.realworldhaskell.org/blog/
I agree with David in that it is asking the wrong question as to
whether there is a model of a computer that fits with Haskell. Haskell
is based on a different model of computation. Conceptually, Haskell
programs are executed by rewriting expressions not by manipulating
memory in a machine.
A trivial example:
Here's a function to append a list onto a list:
append :: [a] -> [a] -> [a]
append [] ys = ys
append (x:xs) ys = x:append xs ys
and here we run it (on paper, no machine required :) ) on a some lists
by applying the above rules where the match:
Note: [1,2] is syntactic sugar for (1:(2:[]))
append [1,2] [3,4]
= { apply first pattern match equation }
1 : append [2] [3,4]
= { apply first pattern match equation }
1 : 2 : append [] [3,4]
= { apply second pattern match equation }
1 : 2 : [3,4]
= { just syntactic sugar }
[1,2,3,4]
I wouldn't be as bold as to suggest that Haskell should replace C but
certainly it is a nice language to use in my opinion. Does it explain
how a computer works? No. Does it explain 'computation'? Yes.