lua-users home
lua-l archive

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

this is roughly my hierarchy of programming paradigms: (disclaimer, i
don't know anybody that agrees with me on this)

0.- hardwired
1.- stored code
1.2.- imperative
1.2.1.- 'raw code' (machine language, assembly, old BASIC)
1.2.2.- structured code (Pascal, C, modern BASIC) object oriented (lots of examples)
1.2.3.- functional programming (LISP, Scheme, Dylan) pure functional (Haskell, erlang?)
1.3.- declarative (SQL, spreadsheet formulas)
1.3.1.- logic programming (prolog)


- almost everything is under imperative.  for me, imperative means we
tell the computer "do this, then do that".  that includes not only
procedural, but OOP and functional.  in fact, the only examples of
non-imperative i know are declarative languages

- OOP is under structured code.  when i first heard of structured
code, it meant using subroutines, code blocks, well defined loops...
all this is live and well in OOP.  in fact, the idea is also there in
functional code too, but i put that apart because it came first (LISP
is _old_), and because the loops are different (or should be, common
lisp can look too procedural for my 'functional tastes')

- there's nothing here about dynamic/static typing.  that's an
orthogonal issue.  (but most functional languages have dynamic types,
and static OOPs have extensive runtimes to pass some dynamic features
under the compiler's nose)

but all this isn't really related to the current discussion, which is
mostly about philosophical appreciations of OOP, particularly as seen
from a dynamic-type language with full closures and coroutines.

but since we're in the mood for definitions, here are a few more:

- dynamic types: every value has a type, variables hold references to
values.  variables and function arguments don't have type.  every
operation is late-bound, typing errors are caught at runtime.

- static types: variables, function arguments, every expression has a
defined type at compile time.  values can be simple bit-layouts since
the code already knows how to interpret it.  usually variables can't
change type.

- type inference: (this is somewhat new) some expressions or arguments
can declare type, and the compiler propagates that information.
mostly used with static types, helps making code less verbose, and can
be easier to refactor.

- strong/weak typing: unrelated to dynamic/static types, weak typed
means some automatic coercion rules help transforming values from one
type to another.  too strong typing can be tedious to write (i hated
Pascal for this...), too weak typing can be just as messy (PHP, most
shells) at worst, it makes it easy to create security issues (old PHP)

hum.... that all i have at the top of my head...