Declarative programming vs imperative programming

  • Hi All,

    I read the above topics on wikipedia. It is very interesting...But i got struck in some places...yes..i want to match the concepts with sql side...but i can't.. Can any body give example (sql code) for the above two progrramming techniques ?

    Declarative programming:

    *expresses the logic of a computation without describing its control flow.

    Imperative programming:

    *expresses the logic of a computation with describing its control flow.

    karthik

  • Any inputs ?

    karthik

  • Hi Karthik,

    I am far from being an expert in programming language theory but here's my two bob's worth.

    SQL uses Imperative programming. You tell the DB engine what you want done and how to do it:

    SELECT, UPDATE, EXEC, CASE, function call, etc.

    Other languages like Java provide a mechanism for Declarative programming. In Java it's Annotations.

    In a piece of code you can expose its internals so that some other piece of code somewhere else can delve into it's internals and use it's internal state to make decisions. It's a metadata thing. Maybe useful in building tools?

    See http://www.onjava.com/pub/a/onjava/2004/04/21/declarative.html and good luck with understanding the point of it.

    Peter Lavelle

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply