[Haskell-beginners] Haskell as a useful practical 'tool' for intelligent non-programmers
es at ertes.de
Sun Apr 29 20:43:54 CEST 2012
actually I did not want to participate in this discussion, but as I have
experience teaching many programming languages to many different sorts
of people, I feel obligated to share my observations.
To someone marginally skilled at logical thinking Haskell appears to be
the first choice as the first programming language. I'm offering two
experiences as a reference:
* I had to teach C++ to a math student. The language was very hard to
grasp, because as someone with math skills you practically have to
go back to stone age. Instead of writing equations and
relationships you have to imagine yourself sitting before a large
array of little slips of paper and manipulate them arithmetically to
reach the goal you want. Remember that the array is your memory.
You don't have a brain in C++. This was about the most difficult
part and the whole thing turned out to be a very frustrating
endeavor, because you basically have to temporarily forget what you
learned in university.
* A friend of mine with no technical and no math background wanted to
learn programming. I decided to go with Haskell, because it would
be an interesting experiment.
The experiment turned out to be very successful. As someone with no
technical skills you can pick up Haskell simply by logical thinking.
For example I never explained laziness. She developed an intuition
for it all by herself. She dealed with infinite lists like it was a
totally natural thing to have in a computer. I never explained a
lot about types, only that types must match when applying a
function. Except for "no instance for X"-style type class-related
problems the type errors made total sense to her.
At the same time I gave workshops for a group of technically skilled
people, who had a much harder time grasping Haskell. Their
knowledge of how computers work stymied them.
While many people claim that following a recipe is the natural way of
human thinking, it is surprising what a difficult time people have
passing instructions to the machine properly. My conclusion from this
and my teaching experience is that humans are good at /following/
recipes but very bad at /making/ them.
Humans think in relationships, but can't memorize a lot of them, but
exactly this is necessary for imperative programming. Functional
programming allows you to view everything in isolation and focus on
individual parts of your code without paying attention to the rest.
Furthermore imperative language compilers don't know anything about the
relationships in your code, so they can't help you a lot. Compilers for
a purely functional language on the other hand keep all relationships
and derive the recipe from them. GHC compiles to a G-machine, which
basically follows an implicit recipe extracted from the functional
relationships. Hence you express relationships and the compiler writes
the corresponding recipe. This is much easier for the human mind to
follow, because you can view everything in isolation. While
object-oriented programming languages try to emulate this (poorly) by
splitting your imperative program into isolated pieces, a purely
functional language takes this idea to its conclusion and enforces it as
a first class language feature.
This might be a reason why people programming in an imperative language
use most of their time for debugging instead of productively writing
code. A type system helps, but is very limited in its abilities,
because the programmer never gets the opportunity to express
relationships. I'm willing to subscribe to this reasoning any time.
With this experience in mind my opinion is that a purely functional
language is the natural choice for every beginning programmer, before
you screw up your mind with an imperative language like Perl, Python or
Ruby. Haskell is not a mathematical language. It is a natural
language. And /not/ knowing how the machine works actually comes as an
advantage for understanding it.
nightmare = unsafePerformIO (getWrongWife >>= sex)
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 836 bytes
Desc: not available
More information about the Beginners