Re: Scheme as a religion



"H." <hbe123@xxxxxxxxx> wrote:
The general concensus I get is that it is widely admired by
academics who seem to thoroughly enjoy criticizing the limitations of
other languages while extolling the virtues of Scheme, and not so
widely respected by and sometimes scoffed at those in the industry who
use commercial languages like C++ and Java.

It is also admired by some in industry who feel constrained by commercial languages like C++ and Java. As it happens, the latter group are the smartest people. ;)


I am torn somewhere in between the extremes, but the purpose of this
post is that there are some evangelical aspecs of Scheme that I don't
get, in that the concepts don't seem so novel to me. Of course, that
could be a function of the year (2005); if the concepts presented in
Scheme were once new, they aren't anymore.

That's true of some of the concepts in Scheme, but not all of them. Even some of the concepts which have since been adopted by other languages haven't always been properly implemented -- closures in Python are one example, and the arbitrary limitations on recursion in many languages is another. This seriously limits the usefulness of these features. There's no single mainstream language that implements all of Scheme's most useful features in a non-broken way.


To me, Scheme seems difficult to grok on first reading (or even second,
or third) comprehend by it's rule of relying so much on single
parenthesis. (Yes, I think the LISP nickname of "Lots of Irritating
Single Parenthesis" fits). It seems to me that there are scripting
languages that are easier to read and write that teach many of the same
concepts.

They may teach some of the some concepts, but they also miss some very important ones. That's a problem if you're really trying to learn underlying principles rather than just to become an average coder.


For instance, two of the concepts taught in Scheme are first-class
objects and recursion. Both of these are present in JavaScript

By first-class objects, I'm guessing you mean first-class procedures. Javascript does have those, although their power is hampered by some other restrictions of Javascript, so they aren't as nearly as useful as they might otherwise be.


One such restriction is recursion, which is severely limited in most Javascript implementations, to the point where it can't be used for many of the most useful recursive algorithms. For example, you can't do recursive processing of even fairly small structures in most Javascript implementations, simply because you run into stack limits. (One exception to this is the Rhino implementation of Javascript that's been modified to support continuations, but that's not standard and only runs on the JVM.)

Another important feature missing from Javascript are proper lexically-scoped (i.e. block-scoped) local variables.

A big part of Scheme's power is the combination of first-class procedures, the related nested lexical scoping for variables, and recursion that's not arbitrarily restricted. These features are all characteristics of lambda calculus, and are shared by the functional language family, including ML and Haskell. None of the mainstream languages support this full functional feature set, which is a pity, because it's an important and powerful integrated set of capabilities that isn't really at odds with imperative languages.

This functional foundation is only one of the powerful aspects of Scheme -- others include macros and first-class continuations, which again may be found in various diluted forms in other languages, but not in any single mainstream language. While these features might not be taught in introductory courses, it helps that Scheme scales from a simple introductory subset to something much more powerful that supports constructions that are essentially impossible to express in mainstream languages. Scheme is a language for the expression of computational ideas, which remains as useful at the PhD level as it is in first year. The same isn't true of Javascript. ;)

which I
personally find much easier to use, because there are () and {}
available, each used for a different purposes

That's a little like saying you find the Qwerty keyboard easier to use than Dvorak -- it's a matter of familiarity. Many people (including me) have switched from languages with C-style syntaxes to Scheme/Lisp. Once you have some experience with it, the s-expression syntax is no more difficult to use, and actually has many unique advantages.


and explicit keywords
like "return" that specify what gets returned from a function, as
opposed to Scheme's implicit model (things get returned for being
listed last, but not always).

There's a reason for that difference, which is that Scheme is mostly expression-oriented, as opposed to statement-oriented. The "return" statement in Javascript and other imperative languages is actually a goto-like jumping statement which interrupts the flow of execution (unless it is the last statement in a function, of course). You can do the same sort of jumping in Scheme using the call/cc function, if you need to, but Scheme will teach you that such jumping is unnecessary, and could be described as overkill. Again, the issue here of one of learning the difference between what Scheme is doing, vs. what the imperative languages do, and learning how to read Scheme.


Also, Scheme sometimes uses what I
consider "trick notation" to call a fuction/procedure, in that if you
add an extra set of parens around something, you call it as well as
define it, whereas in JavaScript the notation is more explicit with far
less room for confusion.

Not sure exactly what you're referring to. But for an example of this sort of difference, compare this Scheme:


  ((lambda (x) (+ x 1)) 5)

to this equivalent Javascript:

  (function (x) { return x+1; })(5);

If one of these is clearly trickier than the other, I'd say it's the Javascript, and that's not for want of experience. Heavy use of anonymous functions in Javascript is not as convenient as in Scheme. A demonstration of this can be seen if you try writing what's known as "continuation-passing-style" (CPS) code in Javascript -- it's known as a difficult to read style, but it's even more difficult to read in Javascript than it is in Scheme, because of return statements and the way in which anonymous functions are written in Javascript.

As a last note: not to evangelicize JavaScript either, there clearly
some areas for which JavaScript does not teach the same metaphors.

Right, another problem with most scripting languages is that they tend to provide certain predefined high-level data structures, which don't have well-defined performance characteristics and don't support efficiently defining other kinds of structures.


The
only way to create linked lists, for instance, is to create your own
linked list data structures, whereas in Scheme, the whole weird car,
cdr, cadr terms can prepare the student for linked lists. But as to why
beginning programming students have to be exposed to terms like car,
cdr, cddar, caaddr, etc, I don't get that either. Please don't tell me
that those names are in the least way transparent or aid in
understanding. The nomenclature alone is a stumbling block to the
powerful concepts for which they stand.

Most modern teaching texts use names like 'first' and 'rest' instead of car and cdr. All that is needed to achieve that renaming are simple definitions like "(define first car)".


However, note that the compound names like caaddr are actually concise path specifiers for navigating a tree. As an exercise, come up with some other way to do this, and compare this for transparency etc. to car, cdr and their derivatives. I suspect that a strong reason that the car & cdr names have survived is that ultimately, changing their names doesn't buy you much.

In short, the impression that religion is involved is misleading. Or put it this way: any worshipping that might take place has a solid technical justification, even if that isn't apparent from a superficial comparison to more common languages.

Anton
.



Relevant Pages

  • Re: Scheme as a religion
    ... Only fifty years ago the idea of a programming language was ... programming languages and their implementations. ... similar to lisp in general and Scheme in particular --- what you ... Think about the literature and history hints I've given you ...
    (comp.lang.scheme)
  • Re: Scheme as a religion
    ... I'm a newcomer to Scheme. ... I started programming early, on Apple's Hypercard because my family had ... brand new C# had a consistency that I found lacked in other languages ... instance you can have lists of functions, or list of list of functions, ...
    (comp.lang.scheme)
  • Re: Scheme as a religion
    ... two of the concepts taught in Scheme are first-class ... Both of these are present in JavaScript which I ... and there's no tail recursion. ... languages are in the same league as Scheme as functional languages. ...
    (comp.lang.scheme)
  • no value in Scheme
    ... I can't honestly tell anybody to use advanced programming languages. ... It wouldn't be so bad if Scheme were industry standard, ... with the crappy inelegant C++ shit I already had to start with? ... entire computer industry is complete shit. ...
    (comp.lang.scheme)
  • Scheme as a religion
    ... As an avoid computer science student who hopes to attend to UC Berkeley ... other languages while extolling the virtues of Scheme, ... use commercial languages like C++ and Java. ... Both of these are present in JavaScript which I ...
    (comp.lang.scheme)