Re: Interesting article by Joel Spolsky: The Perils of JavaSchools
- From: "wooks" <wookiz@xxxxxxxxxxx>
- Date: 8 Jan 2006 03:06:06 -0800
My original reply doesn't seem to have appeared on Google so posting
again.
Gerry Quinn wrote:
> In article <1136550849.114794.145020@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
> wookiz@xxxxxxxxxxx says...
> > Gerry Quinn wrote:
>
> > > It's ironic to see the somewhat trivial concepts of pointers and
> > > recursion feted as challenging, purely on the basis that certain
> > > programmers are unfamiliar with their use. [And surely Java supports
> > > recursion as well as any language?]
>
> > Misses the point.
>
> > Most Java(any imperative language) programmers will instinctively opt
> > for an iterative solution and will only use recursion when they are
> > forced to.
>
> If that's the point, it's not a very good one.
It's an excellent one.
> A language that allows
> you to pick appropriate solutions is better than one that forces you
> into unsuitable ones.
>
Lists are recursively defined structures. Therefore recursion is the
most suitable and appropriate solution for problems that involve lists
and structures that derive from lists (arrays, stacks etc). The
languages you are referring to are the ones that allow you to pick
unsuitable and inappropriate solutions that depend on hacks like y=y+1
(it's obviously not true, makes no sense to a lay person and is a
mathematical abomination). Like I said these iterative solutions don't
scale with increasingly complex data structure. Ask an average Java
programmer to parse an arbitrarily nested regular expression and watch
him lose the plot.
> (Actually I would expect many beginning programmers will be over-
> excited by the concept of recursion, and will use it in inappropriate
> circumstances.)
>
Then you better define inappropriate because recursion is the
appropriate technique for any recursively defined data structure. If
your solution accurately models the data structure then it will scale
elegantly as the data structure gets more complicated. Methinks you are
thinking premature optimisation.
Put a child at the bottom of stairs and ask him to climb them. Give a
lecturer a pile of papers to mark. Give a clerk a stack of invoices to
process.The solution to all these problems is naturally recursive
Base case - no mor steps, invoices, papers to mark. Stop
Mark 1st paper/Climb first step/Process first invoice.
Recurse with the rest of papers/steps/invoices.
The only people who think that the appropriate and suitable way to
approach this task by counting the number of steps, invoices, papers,
processing one, incrementing a counter and then comparing that counter
to a total are computer programmers implementing dumbed down hacks.
> > Iterative solutions don't scale well to increasingly complex data
> > structures. In those situations your imperative programmer takes a lot
> > longer to produce buggier, less concise solutions, because they are not
> > practised in recursive techniques.
>
> Then the solution is to practice the techniques, but there's no need to
> abandon Java in favour of a toy language that is limited to them and no
> other.
>
To me a toy language is one that doesn't support higher order
functions.
You are confusing popularity with capability and power!! Just because
Java gives you 3 different ways of writing loops in addition to
recursion do you think that makes it more powerful. The main reasons
why imperative programming languages are in more widespread use have
nothing to do with them being better suited for "real work", or being
"serious languages". It's because they are accessible to the
mathematically unsophisticated which is a description that probably
applies to the majority of people employed as programmers today which
goes back to the dumbing down point that Spolsky is making.
> > > Then comes the extolling of functional languages such as Lisp, which
> > > have more advocates than useful programs written in them. It expands
> > > the brain and makes you a better person, or so we're told. I've heard
> > > colonic irrigation does the same.
>
> > Misses the point again.
> > The ability to think recursively is an important skill for a programmer
> > and indeed problem solvers at large.
>
> Yes, it's very useful. And you can learn it from Java, or Basic for
> that matter.
>
The whole point Spolsky is making is that teaching people in Java means
that the odds are they won't practice these techniques in the first
place because Java offers them solutions that enable them to work
around having to think recursively. For simple problems they can get
away with it. It breaks down when the have to parse an arbitrarily
nested formula or regular expression. There is no guarantee that a Java
programmer possesses this mental capability (and the odds are that they
don't), OTOH you are guaranteed it with a Lisp/Haskell/Scheme/ML
programmer.
.
- Follow-Ups:
- Re: Interesting article by Joel Spolsky: The Perils of JavaSchools
- From: Richard Harter
- Re: Interesting article by Joel Spolsky: The Perils of JavaSchools
- From: Willem
- Re: Interesting article by Joel Spolsky: The Perils of JavaSchools
- References:
- Interesting article by Joel Spolsky: The Perils of JavaSchools
- From: Casey Hawthorne
- Re: Interesting article by Joel Spolsky: The Perils of JavaSchools
- From: Gerry Quinn
- Re: Interesting article by Joel Spolsky: The Perils of JavaSchools
- From: wooks
- Re: Interesting article by Joel Spolsky: The Perils of JavaSchools
- From: Gerry Quinn
- Interesting article by Joel Spolsky: The Perils of JavaSchools
- Prev by Date: Re: Interesting article by Joel Spolsky: The Perils of JavaSchools
- Next by Date: Re: Interesting article by Joel Spolsky: The Perils of JavaSchools
- Previous by thread: Re: Interesting article by Joel Spolsky: The Perils of JavaSchools
- Next by thread: Re: Interesting article by Joel Spolsky: The Perils of JavaSchools
- Index(es):
Relevant Pages
|