[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: OT: functional languages (was: Politics of Java)



Derrick 'dman' Hudson wrote:

> "imperative" and "procedural" are the same thing,

Well, not _exactly_. Procedural is a subset of imperative. One could
trivially imagine an imperative language with no subroutines, which
could hardly be called "procedural". In fact, MS-DOS's shell is such a
language (especially early versions, prior to the addition of the "call"
command). But for the most part, practically speaking, yes, most
imperative languages are procedural.

> and C is a prime
> example.  It is such because the structure of a C program is a
> collection of procedures which start with "main".  Each procedure is a
> linear list of statements to be executed in order.

Yes. Though C is also a very low-level language, which is why it is
sometimes called a "portable macro-assembler". 

> | it has no loops, assignments, variables or whatever.
> | 
> | Since Lisp is very similar, I was wondering if it's also "functional"...
> 
> Lisp is "functional".  The functional paradigm is based entirely on
> functions.  A function receives some input values (arguments) and
> returns some value.  It is based heavily on discrete mathmatics and
> recursion.

But Lisp is not _only_ functional, or even primarily. It has a number of
imperative features such as (progn) and (setq), and makes no attempt to
isolate side effects.

Essentially, the definition of a functional language is that it is
based on lambda calculus or combinators, and 

> The other two categories of programming languages are OO
> (object-oriented) and Logic.  Python, C++ and Java are OO languages.
> Prolog is a logic based language.

There are a number of categories beyond this, but no need to go into all
of them here. Many types are subclasses of other types, as well.

Java is a fairly lame example of an OO language; Smalltalk is a much
better one. Calling Python and C++ OO languages is misleading, since
both of them support a variety of programming models to varying extents.
For example, Python has some functional-language-like capabilities such
as lambdas, while C++ templates are really a nod in the direction of
type genericity, and have nothing directly to do with OO.

If you wanted to list some languages that are more or less pure examples
of particular types, I would suggest the following:

  Imperative non-procedural: early Fortrans, COBOLs, and BASICs; Bourne sh
  Procedural:                Algol-60, Pascal, C
  Functional:                Haskell
  OO:                        Smalltalk
  Logic:                     Prolog

Craig

Attachment: pgpqg7H_e06Na.pgp
Description: PGP signature


Reply to: