in reply to Re^13: World's shortest intro to function programming
in thread Thread on Joel on software forum : "I hate Perl programmers."
However, and here's the reason I will want to browse the book before purchasing rather buying on lineGo to your nearest public library. If they don't have it, ask them to do an interlibrary loan. You'll get to browse it for a month before you decide if you want to buy a copy.
For example, the treatment of the trivial, but strongly indicative example of the unix wc program. (Which I had to type in because it doesn't come as part of the source file distribution with the book)I don't remember any word counting problem in the book. So I grabbed my copy off the shelf and looked in the index. No luck. I skimmed it quickly. No luck. I can't even think what chapter it would be in. Maybe it doesn't come as part of the source for the book because it not in there? I don't know.
Compile and I get a (500kb!) executable.Yeah, its a high level language. The current compilers statically link everything in the runtime into one executable. Just for comparison, my version of perl clocks in at over 1MB.
wc.hs:9:8: Parse error in pattern Hmmm. Informative!It's that 2D syntax thing biting you again. You need to indent the "name <- getLine" line in to match up with everything else...
wc = do putStr ( "Filename; " ) name <- getLine contents <- readFile name let ( cc, w, lc ) = wcf( 0, 0, 0 ) contents putStrLn ( "The file:" ++ name ++ " has " ) putStrLn ( show cc ++ " chars " ) putStrLn ( show w ++ " words " ) putStrLn ( show lc ++ " lines." )
So, skip the prompt, and try and get the argument from the command line. Scan the library docs. System looks promising. But there is nothing that looks like it gives me access to the commmand line?getArgs
And that's the problem. All the demos are the same. They concentrate on (laborious formal) examination of Haskell's strengths and completely skip over all the messy edge cases.I think the assumption is that the books provides a high-level overview of the concepts necessary and its up to the user to provide the nitty-gritty details which are important to them.
All languages have their strengths and weaknesses.Yeah, Haskell isn't Perl. They live in different niches of the programming language eco-system. If you're looking for a better lanugage to bang out one-off scripts in 15 minutes, Haskell isn't what you're looking for. Before I discovered functional programming, I always thought there must be a better way of creating programs then I was currently doing. When I saw the light of FP, I realized that it went a long way towards making programming work the way I thought it should. I could now make good looking programs that weren't brittle. And they looked beautiful. Learning FP made me a better Perl programmer too. But I'm not going to tell you that FP is the one true way for everybody. If imperative curly brace Algol descended languages suit you fine, stick with them. Different strokes for different folks.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^15: World's shortest intro to function programming
by BrowserUk (Patriarch) on Jun 20, 2005 at 19:38 UTC | |
by Anonymous Monk on Jun 20, 2005 at 20:07 UTC | |
by Anonymous Monk on Jun 20, 2005 at 20:49 UTC | |
by kelan (Deacon) on Jun 21, 2005 at 14:44 UTC | |
by BrowserUk (Patriarch) on Jun 21, 2005 at 20:17 UTC |