[Haskell-beginners] Re: Is Haskell for me?
Rafael Gustavo da Cunha Pereira Pinto
RafaelGCPP.Linux at gmail.com
Fri Nov 6 13:08:32 EST 2009
WARNING: THIS IS A VERY LONG REPLY
Luis,
If you are in a hurry skip to the point where I give advices ;-)
----------------------------------------SKIP IF YOU LIKE
TO----------------------------------------------------
I'll ask some more questions!! :-P
- Nothing beats Assembly in speed.
Why isn't everyone programming in Assembly??
- Python gives me the flexibility for fast prototyping, because it easily
connects to C and Java libraries
Why isn't every enterprise service bus (ESB) implementation written in
Python??
- Ruby has Rails!! One of most successful MVC frameworks ever.
Why isn't every system written in Ruby on Rails?
Basically, what I am trying to say is that even though Haskell is not
blazing fast, it can be made fast enough for you, given you use the right
algorithms and optimizations.
For this to happen, you must first understand, the functional paradigm, the
language and how the compiler optimizes your code.
For the rest of your questions:
- Is Haskell able to read (also write to a point) data from databases in a
fast and reliable way? (MySql or PostgreSQL)
Yes, there is a lot of ways. Look at Hackage
(HackageDB)<http://hackage.haskell.org/packages/hackage.html>for
database related packages
- how could I program something like this in Haskell:
.. generate random population
.. for each one of the population:
.. for time period 1 to ten million:
.. evaluate method 1, 2, 3, 4, 5, 6, ....
..evaluate fitness of each one
.. generate new population based on results of previous generation
It seems relatively intuitive for me to program this in an imperative
language. But what about in Haskell?
It looks rather imperative to me, either. You can implement imperative
things on the IO and State monads, but I would really suggest you rethink
the algorithm.
- Is Haskell suitable to process data like this in a fast way
(aproximate to C++?)
How fast, again, depends on the algorithm.
Haskell programs look like a collection of mathematical functions.
One could write a program like a composition of functions:
main= count . words . readfile
and then define functions individually...
- In order for Haskell to be fast, coding is done in a 'natural' way
or with use of special hidden details of the language?
The natural way makes you code right, but you have to think every step you
do, since a badly organized recursion, or the excess of lazyness can make
your program hog on memory and/or go dead slow.
- Although I always liked math, I no longer have the knowledge I used
to have several years ago. Is this important to help program in this
funcional language?
The math needed in your first steps is not hard.
After you started learning Haskell you will most certainly step on Monads.
These might require some abstract algebra, if you want to understand what's
behind the curtains.
Refrain yourself from trying to understand them using math and take a look
on Philip Wadler's "Monads for functional
programming"<http://homepages.inf.ed.ac.uk/wadler/papers/marktoberdorf/baastad.pdf>
- Are there graphical packages available to plot results or is it easy
to connect it to a Python (or C) library?
Hackage is the way to go.
- Is code easily reusable in different future projects? Since it has
no objects... how can it be done?
Like all other languages, it all depends on YOU.
Haskell has no objects, but it has polymorphic functions, which are just as
powerful.
It also has type classes, which are almost like C++ object classes, but
completely different. Type classes can restrict or increase polymorphism,
depending on how you use them.
There are also MANY extensions implemented on GHC that expand the type
system to its limit.
---------------------------------------- END OF SKIP
BLOCK----------------------------------------------------
Is Haskell for you? I can't answer, but I can give some advice:
1) If you are in a hurry, go for what you know (C++, Java, Python,
Assembly...)
2) If you really want to dig in, dig in. Learning Haskell is a wonderful
experience and can dramatically change your way of programming. Think of a
mind altering experience!!!
3) Even though it is hard to write great programs at first, in the end it is
very rewarding. As your programming style improves, you'll see how elegant
algorithms are implemented in functional programming.
I still consider myself a beginner, but I can assure you Haskell is a great
language for functional programming.
Best regards,
Rafael Gustavo da Cunha Pereira Pinto
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20091106/82db49e7/attachment-0001.html
More information about the Beginners
mailing list