Why isn't Haskell mainstream?---A newbie's view 
Author Message
 Why isn't Haskell mainstream?---A newbie's view

Hello all,

First of all, I've chosen this subject to be provocative not to be
offensive.  I post this because I sincerely wish Haskell would be
mainstream and because I think a newbie's view may be of help.

I'm a newbie, who is very much interested in functional programming
and is about to try out Haskell.  I'm much experienced in programming
in imperative languages including C++, fortran, Perl, Ruby, and
Bourne shell.  I've read a couple of online introductory materials on
Haskell and come to like it very much.

To me, the problem of Haskell is the presentation.  The tutorials I've
read first talk about Haskell's elegance and power by showing examples
such as the binary tree, function composition, and list manipulation.
I'm quite impressed with the elegance and power of Haskell.  *BUT*,
when I try to write a program in Haskell for my real job, I get
stuck.  I don't know how to open a file, read a line, extract
blank-separated fields from the line, pattern-match each field,
and produce output to another file.  I don't know how to access the
command line options from within the program.  I don't know how to
write to the screen and get the user's input from the terminal.
I don't know how to read a binary file, treat each byte separately,
and-ing, or-ing, and not-ing the bit pattern.  I don't know what
library is available for regular expressions, mathematics (sin,
exp, value of pi, random numbers, etc.), networking, file and
directory manipulation, ...  It's not normal for me not to know how to
write to the standard output after reading three online tutorials!
You would say, buy a textbook.  Right.  But, the reviews of textbooks
at http://www.*-*-*.com/ ;doesn't indicate which book to buy to find
out those things.  On the contrary, I've got an impression that those
books exclusively talk about the academic side of the language, except
for Paul Hudak's book, which I'm not sure is what I'm looking for
because I'm not interested in multimedia.  (I've ordered that book
anyway, without any other option...)

I know such things as opening a file are not the point of Haskell, but
without such components, you can't write a working program.  So, in my
opinion, such mandatory parts should be taught first.  Then, the pupil
would learn the core Haskell by writing working programs.

In short, Haskell is presented as academic.  In my humble opinion,
examples should be shown for everyday programs.  If you don't see what
I'm talking about, I recommend you read the Perl book ("Programming Perl"
by Larry Wall, et al., O'Reilly) or the Ruby pickaxe book
("Programming Ruby: A Pragmatic Programmer's Guide" by D. Thomas &
A. Hunt, Addison-Wesley).

Ryo



Sat, 24 Sep 2005 21:49:33 GMT  
 Why isn't Haskell mainstream?---A newbie's view
On 8 Apr 2003 06:49:33 -0700

Quote:

> In short, Haskell is presented as academic.  In my humble opinion,
> examples should be shown for everyday programs.  If you don't see
> what I'm talking about, I recommend you read the Perl book
> ("Programming Perl" by Larry Wall, et al., O'Reilly) or the Ruby
> pickaxe book ("Programming Ruby: A Pragmatic Programmer's Guide" by
> D. Thomas & A. Hunt, Addison-Wesley).

Another example of what I believe you are talking about, a little
closer to home:

http://web.access.net.au/felixadv/files/output/book/

Benjamin



Sat, 24 Sep 2005 22:12:25 GMT  
 Why isn't Haskell mainstream?---A newbie's view

[...]

Quote:
> In short, Haskell is presented as academic. In my humble opinion,
> examples should be shown for everyday programs.

You might be interested in reading Simon Peyton Jones' article
"Tackling the awkward squad: monadic input/output, concurrency,
exceptions, and foreign-language calls in Haskell" which talks
precisely about that kind of stuff. It's available there:

http://www.research.microsoft.com/Users/simonpj/Papers/marktoberdorf/

That said, I agree with your main point.

Michel.



Sat, 24 Sep 2005 23:17:42 GMT  
 Why isn't Haskell mainstream?---A newbie's view
I completely agree, and fully sympathise with you.

On part of your complaint, there are two schools of thought about
teaching "IO" in Haskell.  One is to treat it as an advanced topic,
right at the end.  To my mind this is insane.  The other is to teach
it right from the word go, but without ramming monads down the young
innocents' throats (till later).  There are precious few teachers in
this school.  One (the only) textbook along these lines is the one by
Paul Hudak you mention, called "The Haskell School of Expression".  I
have however heard it described as "too difficult".

My (uncharitable) suspicion is that the reason IO is treated as an
"advanced" topic is that the academics don't understand it themselves.

As for where to find the interesting libraries, the first thing to
suggest is to read about the standard libraries on the Haskell
web-page
http://haskell.org/definition/.  
Not everything interesting is there, but there are some pointers at
http://haskell.org/libraries/.  And then there's google.

I'm afraid it's not really on a plate.

Peter Hancock



Sun, 25 Sep 2005 01:31:19 GMT  
 Why isn't Haskell mainstream?---A newbie's view

Quote:

> To me, the problem of Haskell is the presentation.  The tutorials I've
> read first talk about Haskell's elegance and power by showing examples
> such as the binary tree, function composition, and list manipulation.
> I'm quite impressed with the elegance and power of Haskell.  *BUT*,
> when I try to write a program in Haskell for my real job, I get
> stuck.  I don't know how to open a file, read a line, extract
> blank-separated fields from the line, pattern-match each field,
> and produce output to another file.  I don't know how to access the
> command line options from within the program.  I don't know how to
> write to the screen and get the user's input from the terminal.
> I don't know how to read a binary file, treat each byte separately,
> and-ing, or-ing, and not-ing the bit pattern.  I don't know what
> library is available for regular expressions, mathematics (sin,
> exp, value of pi, random numbers, etc.), networking, file and
> directory manipulation, ...  It's not normal for me not to know how to
> write to the standard output after reading three online tutorials!

RTFM. All of this information is available at <http://www.haskell.org/ghc/>,
assuming you are using GHC -- the reason why it's not in textbooks is that
it's mostly implementation-specific. Besides, it doesn't have much to do
with the essentials of Haskell, except perhaps for the basic idea of
monadic I/O, which is IMO poorly presented in all the Haskell books I've seen
-- but you can learn that easily enough by looking at some example code.

--
Kirsten Chevalier * Often in error, never in doubt
"I'm getting further from the things I thought I knew, but I'm getting closer
to the truth."--Trout Fishing in America
http://www.cs.berkeley.edu/~krc/



Sun, 25 Sep 2005 05:44:39 GMT  
 Why isn't Haskell mainstream?---A newbie's view

I'll let others discuss the philosophical part, and just answer your
specific (if rhetoric) questions, for the benefit of future
generations googling for answers:

Quote:
> I'm quite impressed with the elegance and power of Haskell.  *BUT*,
> when I try to write a program in Haskell for my real job, I get
> stuck.  
> I don't know how to open a file,

This is IO, you need to use the IO monad.  Do NOT at this point try to
grok what a monad is, or why this is one, just accept it as a fact.
Then, structure your programs' main functions as:

        module Main where
        :
        main :: IO ()
        main = do
                <var> <- <action>
                let <var> = <expression>
                <action>
                :

Where <action> is an IO action, and <expression>s are pure.

Specifically you can do:

        main = do
            cs <- readFile "myFile"  -- the contents of myFile is in cs
            :

Quote:
> read a line,

        main = do
            cs <- readFile "myFile"
            let ls = lines cs     -- ls is a list of lines (strings)

Quote:
> extract blank-separated fields from the line,

        main = do
            cs <- readFile "myFile"
            let ls = lines cs
            let ws = words (head cs) -- list of words in the first line

Quote:
> pattern-match each field,

Not quite sure what you want.  Given a function (predicate) p, e.g

        p :: String -> Bool
        p (x:xs) = (x == 'a')

You can easily do:

        main = do
            cs <- readFile "myFile"
            let ls = lines cs
            let ws = words (head ls)
            let as = filter p ws -- words starting with a

Quote:
> and produce output to another file.  

            writeFile "myOtherFile" (unwords as)

Quote:
> I don't know how to access the command line options from within the
> program.

        import System
        :
        main = do
            args <- getArgs
            cs <- readFile (args!!0)
            let ls = lines cs
            let ws = words (head ls)
            let as = filter p ws -- words starting with a
            writeFile (args!!1) (unwords as)

Quote:
> I don't know how to
> write to the screen [..] user's input [..] read a binary file [..]
> and-ing, or-ing, and not-ing the bit pattern [..]
> regular expressions, mathematics [..] networking, file and
> directory manipulation, ...

I'm going to leave these, since they are either more vaguely defined,
have many different possible solutions, or are easy to look up in the
documentation.  What I included above should suffice to get you
started, I think.

-kzm
--
If I haven't seen further, it is by standing in the footprints of giants



Sun, 25 Sep 2005 14:51:31 GMT  
 Why isn't Haskell mainstream?---A newbie's view
http://pleac.sourceforge.net/ may help you, even if the haskell version
is not fully developped and commented (no offense intended).

sL



Sun, 25 Sep 2005 15:26:06 GMT  
 Why isn't Haskell mainstream?---A newbie's view
To be realistic, there isn't lots of example code available in Haskell
for mainstream tasks like file I/O, networking, and user interface
programming because Haskell isn't a good language for doing these
kinds of things.  It's far easier to perform such tasks in imperative
object-oriented languages like C++, Java, C#, and Python, so that's
what people do.  In Haskell, you have to resort to monads which lead
to explicit plumbing of state that is far more difficult to understand
than the sequential imperative model.

Most of the example code for Haskell deals with sorting, searching,
functional parsers, lambda evaluators, and other similar functional
recursive algorithms because Haskell is a great language for doing
that sort of thing, clearly more natural than mainstream languages
like C++ and Java.

So programmers flock to mainstream languages for performing primarily
mainstream tasks, and to functional-recursive languages for performing
primarily functional-recursive tasks, and the example code for all of
these languages just tends to reflect what the languages are best at.



Sun, 25 Sep 2005 15:37:37 GMT  
 Why isn't Haskell mainstream?---A newbie's view
: To be realistic, there isn't lots of example code available in Haskell
: for mainstream tasks like file I/O, networking, and user interface
: programming because Haskell isn't a good language for doing these
: kinds of things.

If only there were a better one. :(

: It's far easier to perform such tasks in imperative object-oriented
: languages like C++, Java, C#, and Python, so that's what people do.
: In Haskell, you have to resort to monads which lead to explicit
: plumbing of state

I find that the implicit handling of state tends to create method-call
and inheritance spaghetti junctions (particularly when calling one or
more sequence/state-dependant libraries) that make sequencing things
much harder in those languages than in Haskell, which is a serious
problem when they tend to force sequence/state-dependence onto parts
of the code that have no reason to be subjected to it.

: In Haskell, you have to resort to monads which lead to explicit
: plumbing of state that is far more difficult to understand than
: the sequential imperative model.

Is it? Or is it just because we tend to explain it in type-theoretical
terms? What if we had a compiler option that would require all
functions of IO type to have names beginning with "io", and told
beginning programmers that IO functions had to use do,<-,return,
and non-IO functions couldn't call IO functions directly? Would they
find it any harder to learn to _use_ monadic IO than they do to learn
to do IO in (say) Java? Of course, to use the full power that makes
Haskell superior to Java, they will eventually have to learn the type
system, and of course they will develop bad habits if they don't have
the fear of monads making them avoid the use of IO types wherever
possible, but will they learn the _practise_ of doing IO in Haskell
as easily as they learn it in another language, however hard it
might be to explain the theory behind it to a beginner?

: So programmers flock to mainstream languages for performing primarily
: mainstream tasks, and to functional-recursive languages for performing
: primarily functional-recursive tasks, and the example code for all of
: these languages just tends to reflect what the languages are best at.

Or does it reflect the sort of people who are using the languages,
(computer scientists vs. random programmers) or does it indeed reflect
the fact that performing a complex IO-related task seems like a big
achievement to a C++ programmer, while a Haskell programmer thinks it
is a piece of cake and too trivial to have the scope to show off the
power of a language?

-Greg



Sun, 25 Sep 2005 16:35:59 GMT  
 Why isn't Haskell mainstream?---A newbie's view

Quote:

> It's far easier to perform such tasks in imperative
> object-oriented languages like C++, Java, C#, and Python, so that's
> what people do.  In Haskell, you have to resort to monads which lead
> to explicit plumbing of state that is far more difficult to understand
> than the sequential imperative model.

Hmm..I don't know if many Haskellers would agree with that.
My experience is that even imperative programming in Haskell far
less painful than imperative programming in C or C++ (never
used Java). You've still got all the benefits of lightweight
syntax, not having to declare variables, static type security,
garbage collection (OK, Java has that), first class functions,
first class mutable variables (IORefs) if you need them..

Quote:
> Most of the example code for Haskell deals with sorting, searching,
> functional parsers, lambda evaluators, and other similar functional
> recursive algorithms because Haskell is a great language for doing
> that sort of thing, clearly more natural than mainstream languages
> like C++ and Java.

Yep, but I would assert that it's more natural than mainstream
imperative languages for IO too.

Regards
--
Adrian Hey



Sun, 25 Sep 2005 16:42:13 GMT  
 Why isn't Haskell mainstream?---A newbie's view

Quote:

> To be realistic, there isn't lots of example code available in Haskell
> for mainstream tasks like file I/O, networking, and user interface
> programming because Haskell isn't a good language for doing these
> kinds of things.  It's far easier to perform such tasks in imperative
> object-oriented languages like C++, Java, C#, and Python, so that's
> what people do.  In Haskell, you have to resort to monads which lead
> to explicit plumbing of state that is far more difficult to understand
> than the sequential imperative model.

I think Haskell has very nive and very understandable support for all
these stuff. In fact, Haskell excells at e.g. parsing a files.
I don't just mean more advanced parser generators and librararies,
but you have a very simple but powerful tools for everyday use.
E.g., you can easily derive input and output functions for user
defined datatypes with one single function without additional work.
I have not seen this great feature in any other language yet.

I agree very much with Ryo that Haskells lacks a a newby oriented
introduction and nice reference. The Haskell Programmer would
really need a comprehensive reference a la Ruby's Pickaxe book.



Sun, 25 Sep 2005 17:37:20 GMT  
 Why isn't Haskell mainstream?---A newbie's view
    TS> To be realistic, there isn't lots of
    TS> example code available in Haskell
    TS> for mainstream tasks like file I/O,
    TS> networking, and user interface programming

Give me, please, some links to this code ?
For example, some realization of SMTP client ?

Bye, WBR !



Sun, 25 Sep 2005 17:49:39 GMT  
 Why isn't Haskell mainstream?---A newbie's view
Folks,
are you really attached to the idea of

Eine Sprache, eine Kirche, ein Fahrzeug?

Recently I've heard about a new contraption called F16, or
The Fighting Falcon. It would be very nice if this could be
a mainstream vehicle, and some people suggest that it is MUCH
better than anything else around. Easy to use, ergonomic, full
of semantic power, and relatively easy to maintain.

Unfortunately, it is - from my humble perspective - rather
useless.

I would like for example to jump into my F16, and go to the
nearest boulangerie to buy a baguette (I am Polish, but I am
not ready to boycott French baguettes yet). But, no, I can't.
I am still using my old bicycle, since the startup of F16 is
too long, and my wife protests.

I wanted to go on holidays with all my family, including my
mother, but I couldn't squeeze 5 persons in my F16, so I had
to use my old decaying Seat Toledo. Perhaps if the instruction
were written in a less academic style, and explain in a humane
way how to do it, e.g., how to reuse the space occupied by
some bombs and to attach my mother instead, I would be more
happy.

I discovered then that going fishing in a F16 is very difficult,
it simply won't float as I would like to see it, and anyway
all the fish run away from it.

And it makes a hell of noise...
And, even if the basic version is free, nobody can guarantee that
tomorrow Microsoft doesn't order to stop its distribution...

===

To finish once and for good with that myth that F16 *should* be
the mainstream vehicle. Sorry, but it has been designed with
some particular purpose. Many vehicles are universal, they can
move on sand or shoot some [..censored..], but that are not so
well designed to produce Web pages. English is extremely versatile,
but if there are social reasons to communicate in Afghana, Farsi
or Aramaic, then it is easier to learn that language than try
to convert some millions people to English (of course, the ideal
solution is intermediate. You don't learn anything, and you choose
some - just a theoretical model, nothing to do with the reality -

well, you choose some former thief condemned to 22 years of prison
for criminal bankrupcy, but who can be programmed in English and
can convert to Hassemblah'er your programs, and you make out of him
a hero who who will rule those English unspeaking people on your
behalf).

Jerzy Karczmarczuk
Caen, France



Sun, 25 Sep 2005 19:02:33 GMT  
 
 [ 217 post ]  Go to page: [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15]

 Relevant Pages 

1. Why isn't Haskell mainstream?

2. Why isn't Haskell mainstream?

3. Why Isn't Lisp a Mainstream Language?

4. Why Isn't Lisp a Mainstream Language?

5. WHY ISN'T LISP A MAINSTREAM LANGUAGE

6. But Smalltalk isn't mainstream - response

7. Why JIT's may get more mainstream [was: Method lookup]

8. Why aren't functional languages mainstream?

9. Why isn't Eiffel as widely used as C++

10. Why isn't Eiffel as widely as C++ (or Smalltalk)

11. Why Forth isn't popular...

12. Why Forth isn't popular...

 

 
Powered by phpBB® Forum Software