Re: Interesting article by Joel Spolsky: The Perils of JavaSchools



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.

.



Relevant Pages

  • Re: Interesting article by Joel Spolsky: The Perils of JavaSchools
    ... Sounds like recursion to me. ... special purpose language - maybe they are not needed. ... >> This corresponds best to my second example of iteration. ... I am not wild about Java, ...
    (comp.programming)
  • Re: Python or PHP?
    ... If you want to program in a normal language, ... Not in Python or Perl, ... > I doubt if any Perl programmer in the given context would have any ... Why do you think in Java one can call the gc ...
    (comp.lang.python)
  • Re: Learning perl - for experienced programmers
    ... public interface of the language or application. ... The javadoc utility produces a Java API of your code. ... programmer to document his code. ... "The industry" selects, usually, the best tools at hand for any ...
    (comp.lang.perl.misc)
  • Re: Interesting article by Joel Spolsky: The Perils of JavaSchools
    ... > recursion to define an ordered set, that does not imply (as you imply ... programming in something like Java. ... >>> abandon Java in favour of a toy language that is limited to them and no ...
    (comp.programming)
  • Re: Ruby vs Java vs c++
    ... my feeling is that i hate BLOATED sluggish programs (like some Java ... speaking to one my programmer friends who is a top level Java ... such as Java or Ruby. ... However, the heavy math, graphics, database queries and other computational finance applications will be easier for you if you use a language not in your list -- R. R has a lot of computational finance libraries already. ...
    (comp.lang.ruby)