Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

SICP or HTDP?

Name: Anonymous 2010-03-27 11:46

A non-programmer wants to learn. Which do I show them: SICP or HTDP? Or does trying to teach them SICP in MirandaHaskell (for the syntax & pattern matching) make more sense?

Name: Anonymous 2010-03-27 18:36

>>11
Hey cool, let's try it out!

import System( getArgs )

mysum term [] = 0
mysum term (x:xs) = (term x) + (mysum term xs)

main = do
  [arg] <- getArgs
  putStrLn $ show $ mysum id [1..read arg]


~ $ ghc test.hs
~ $ ./a.out 10
55
~ $ ./a.out 10000
50005000
~ $ ./a.out 1000000
Stack space overflow: current size 8388608 bytes.
Use `+RTS -Ksize -RTS' to increase it.


Meanwhile in Scheme:

> (sum values (iota 1000001))
500000500000


What are you going to tell the student? ``Oh, Haskell is lazily evaluated so the stack and memory use is practically impossible to figure out and will trip you up in even the simplest cases.''?
The Haskell code resembles a mathematical function definition, but it doesn't clearly describe the algorithm i.e. the steps taken to arrive at the result. Pattern matching is another cause of this.
But I'm sure you're a fan of Wadler's ``Why Calculating is Better than Scheming'' and believe that adding lots of magic and syntactic puke will help people learn fundamental CS concepts.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List