[Oberon] Oberon-07, recursion and type extension

John R. Strohm strohm at airmail.net
Mon Sep 5 13:03:54 CEST 2016


The fundamental fact is that some algorithms are far more concisely and understandably expressed in recursive form, while some algorithms are easier to express and understand in iterative form.

Quicksort was very, very difficult for its inventor to express and explain iteratively.  Expressed recursively, it is almost trivial.  (Yes, you ARE expected to have at least a nodding familiarity with Quicksort.)

Linear search, on the other hand, is more clearly expressed iteratively.  So are many (most?) numerical algorithms.  Binary search is pretty easy to express either way; the recursive formulation is interesting in that it is tail-recursive.

The object of the exercise is to express algorithms clearly and concisely, so that the reader may determine quickly whether the algorithm is in fact correct, and the compiler may generate reasonable code for the algorithm.  If the expression of the algorithm in the compiler's input language is big and messy, the odds are that the generated object code will be similarly big and messy.

--- noreply at z505.com wrote:

From: Lars <noreply at z505.com>
To: ETH Oberon and related systems <oberon at lists.inf.ethz.ch>
Subject: Re: [Oberon] Oberon-07, recursion and type extension
Date: Mon, 5 Sep 2016 03:48:01 -0600

I've always wondered if recursion, is a trick, and overrated (i.e. lisp)
and should be avoided, or embraced. It is certainly powerful but creates,
I find, confusing code. Dijkstra was skeptical of recursion at times, and
proud of it at other times.

I for one don't find all the tricks up Haskell or Lisps sleeve when using
recursion to be more readable code, than say, non recursive code that
avoids recursion as if it is a nasty trick...

I'm wondering, if recursion is highly over rated and should be used in
moderation, rather than embracing it like in functional languages... Maybe
super intelligent humans (clever) can understand all sorts of recursive
mind games, but should bone simple dumb readable programs contain
recursion riddled throughout the code everywhere? Or should it be avoided
and used in moderation?

I don't mean to claim the original poster of this email thread was abusing
recursion and riddling it throughout his code, as it was only a small
example. Rather I wanted to start a small discussion of people's opinion
on recursion and why everyone thinks it is so great when in fact often it
seems like a clever trick. It is certainly a different way of thinking
about a problem, but for humans, with our brain size.. is it worth abusing
recursion? Functional languages do not consider it abuse, but should it be
considered abuse?
--
Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems
https://lists.inf.ethz.ch/mailman/listinfo/oberon




More information about the Oberon mailing list