[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: s-exprs + prototypes
Mike Vanier wrote:
> Your comment brings up a question that has been nagging at the
> back of my head for a while: are some language paradigms "more
> general" than others? If so, which are the "most general"?
> For instance, I *feel* as if the lisp/scheme language paradigm
> (essentially untyped lambda calculus) is "more general" than
> the single-dispatch OO paradigm at the heart of Smalltalk, but
> obviously both are equally powerful in a strict sense (you can
> write mappings between each of them and the other).
The generality I was referring to has to do with the degree to which a
language dictates aspects of a program design. If a language is designed,
for example, such that all values are objects which respond to messages via
a single-dispatch mechanism, then program designs that might benefit from
some other approach may not as easily or practically expressible in that
Of course, for any given program design, it's quite feasible and usually
easy to come up with an equivalent design that suits the paradigm of the
language being used - but then the language is dictating aspects of the
design of the program. All languages do this to some extent, but if a
language requires you to express everything in terms of class-based objects,
or prototype-based objects, that's less general than a language which makes
fewer assumptions about what types of objects (or other construct) you want
to use, and how they should work.
Another way to put this is in terms of the atomicity of core, independent
constructs in a language. To use the current example, all useful languages
have some notion equivalent to a function. In some OO languages, though,
functions are inextricably bound up with larger packages of functionality,
i.e. objects, which include a collection of functions. There's an internal
notion of a function in these languages, i.e. a named behavior which
operates on a set of arguments, but that internal construct can't be used,
independently of objects, by a user of the language. Also, these languages
dictate the way in which the collections of functions can be accessed, e.g.
via single-dispatch. There's a set of assumptions and decisions about how
programs should be written, related to which the language user has little or
no choice, and that's less general than a language in which fewer such
assumptions are made.
None of this necessarily says anything about the expressivity or power of a
language, though. A language that's less general in the sense I've
described may still be capable of expressing the solution to a given problem
as concisely as a more general language - perhaps even more concisely,
depending on how you frame the comparison (for example, the more general
language might require some extensions to achieve a concise solution, which
the more specific language might not need).
The effect of the generality I'm describing is on certain types of choices
the language offers the programmer. A programmer may decide that he is
comfortable expressing all problems in terms of class-based objects, or
prototype-based objects, and thus won't feel anything has been lost. Having
a single design philosophy in a language can be quite desirable: it imposes
a kind of uniformity on programs, and provides a design framework in which
programmers can follow paradigm-driven rules. These can be great
characteristics for LFMs to have, but individual programmers who want
something more LFSP-like may also choose to live within the constraints of a
single paradigm because of the benefits they perceive in it. I think many
Smalltalk programmers fit this description.
There's no reason why languages can't offer good support for specific
paradigms as a layer or library above the core language, though. Lisp does
this with CLOS, for example. That gives you the best of both worlds, in
many ways, although it may not satisfy the LFM criteria relating to
discouraging divergence from a single paradigm.
> Does this bother anyone else? Or do I just need to up my medication? ;-)
"My name is Anton and I'm a linguaholic..."