[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Functional Paradigm popularity and Maths (Was: XML as a transition to s-expr)

> -----Original Message-----
> From: owner-ll1-discuss@ai.mit.edu
> [mailto:owner-ll1-discuss@ai.mit.edu]On Behalf Of Michael Vanier
> Sent: Wed 19 December 2001 01:33
> To: paul@prescod.net
> Cc: ll1-discuss@ai.mit.edu
> Subject: Re: XML as a transition to s-expr
> So IMO the problem is having to learn a new programming paradigm.  All
> evidence suggests to me that programmers are *incredibly* resistant to
> learning new programming paradigms.  Sure, there are the weirdos like me
> (and most of us on this list) who enjoy that sort of thing, but to most
> people it's about as appealing as skydiving without a parachute ("You mean
> all the tricks I've spent years learning are completely useless?  Screw
> this!").  Even OO took, oh, twenty years to become mainstream, and OO is
> much less of a mental stretch than functional programming.

I was fortunate enough to go to do a course with a compulsory "Programming
Language Concepts and Paradigms" module.  I mention it so you can judge and
weigh my comments appropriately... (below)  I don't think it's that
functional programming is a mental stretch so much that it's simply out
of reach of a lot of people.  To try a metaphor - have you never known
people who were good with figures who just didn't understand calculus?

> Why is functional programming so hard for people?  I think it has something
> to do with the fact that people believe that programming fundamentally is a
> process of do-this-then-do-that-then-do-something-else, whereas functional
> programming is much more declarative.  Instead of telling the computer what
> steps it has to go through in computing a factorial, you tell it what a
> factorial IS: it's the product of an integer with the factorial of the next
> lower integer, unless the integer is zero in which case the result is one.
> This takes time to get used to.  Also, almost everyone in intro CS classes
> has done some imperative programming before, and once that mindset is
> established it's very hard to dislodge.  They know how to compute
> factorials one way, so why should they bother learning a different way to
> compute them?  Isn't the only important thing to get the right answer?
> Finally, concepts like recursion and functions-as-data are very foreign to
> students who haven't seen them or missed them in other languages.  So
> functional programming to most students means a whole lot more work for no
> obvious benefit.  Telling them that functional programs are higher level
> and easier to verify formally and debug doesn't help either, since none of
> them have written large enough programs to realize what a bitch debugging
> imperative programs really is, or how much benefit can be gained from
> working at a higher conceptual level.
> Mike

Noone on this list seems to mention the fact that any non-crippled
programming language will let you solve the same set of problems
(i.e. NP-complete vs. the opposite).
Once adept with a language I believe most programmers will stick with it, not
because they're happy with it, but because the only reason to change is due to
encountering a problem they do not know how to solve.  They're well aware the
problem can be solved with their current toolset, and therefore switching
language is the same as admitting defeat (no, this probably isn't your mindset
as everyone on this list has an interest in other languages... but you're NOT
average programmers.)

The point with functional programming languages, formal proofs and *right*
answers is that that isn't what most programmers are trying to do (shock?)
I'd wager more than my wife's worth that programmers who favour the functional
paradigm are significantly more gifted at maths than the general
programming populace.  I'm not in a position to provide stats or set up
control groups - which is why I mention the wager intead of speaking as
though I know the facts.

There are a lot of coders out there producing code such as:
(no explanation necessary):

    case 0: return '0';
    case 1: return '1';
    case 2: return '2';
    case 9: return '9';

These are the people you have to pitch to if you want your language to be
popular.  They aren't gifted; they aren't even people you'd want to write the
software you run every day.  But, they've no doubt written parts of it, and
you run it.

Functional languages simply aren't popular because it's too easy to prove the
programmer is wrong.  There's no job security or comfort-zone in an
environment where you can be proved to be wrong again, and again, and again.
I'm not sure how to argue this case strongly; the point that keeps popping
into my mind is that it's easier to write code to scrape through system tests
in an imperative language than it is in a functional language.  There's the
ambigous and argumentative word 'easy' slipping in there.  It just seems that
in imperative/procedural programming there is more opportunity to be 'half
right', and that this provides a greater opportunity for the average or
below-average programmer to achieve something.

I think an interesting and possibly unrelated question may be:

If you could take a virgin programmer (of unknown mathematical ability),
    which programming paradigm would you teach them first?  And, why?

Is it easier to move from procedural to object to functional, or from
funcional to object and possibly never touch procedural at all?  (I find
it hard to think of a general answer without thinking of my own personal
experience.  I'm hoping some of the lecturers and professors may have
some better insight than I.)  I know this is more of a general question
than a lightweight-specific question, but there are a few names on this
list I'd be interested to hear the answers from.

Ash Searle