The fourth paradigm is...

luqui on 2005-11-19T09:26:48

Okay, I thought about this some. I walked around the house, talked to myself, played with some fresh fruit (moving them here and there, describing their properties), and I think I've come up with a very vague idea of this fourth control paradigm.

First, here's how I started. I figured, I'm trying to classify the three existing control paradigms (imperative, functional, logical) into two orthogonal properties. Well, it has to be one of these:

      A              B
X | Imperative | Functional |
Y | Logical    | ???        |

A B X | Functional | Imperative | Y | Logical | ??? |

A B X | Logical | Functional | Y | Imperative | ??? |


That covers all the possible cases. I then did a little scanning back and forth, and settled on the second diagram, where A ~~ "doesn't change anything" and B ~~ "does change something". Then I did some brainstorming to figure out what X and Y were based on that.

And I think this is it: You give a functional program an object, and it tells you some property of the object (these can be very complex objects and properties, but it ultimately reduces to that). You give a logical program a property, and it gives you an object that satisfies that.

Then, the imperative parallel is: You give an imperative program an *action* and it tells you the result. So, the fourth paradigm is the converse of this; a generalized inverse kinematics engine: you give it a result, and it tells you the action.

A prime example of this kind of paradigm is the UNIX diff program. You give it a file, and the result of some action on that file, and it tells you how to modify the original to get the result. Also, in gaming, pathfinding and inverse kinematics (the process of finding how to move, say, a human body from one position to another in a physically sound way) are both examples of this paradigm.

So what does a language that enables this paradigm look like? And what would you name it?


FWIW

cog on 2005-11-19T13:26:08

FWIW, back at Uni we actually have the following classes: Programming Paradigms I, II, III and IV.

What we learn in these classes is, respectively, Functional, Imperative, Logic and OO programming.

In my case, this was done mostly with Haskell, C, Prolog and Java (sometimes they change the languages).

There was also a teacher who used to say that databases are a paradigm on its own.

Also, I was first introduced to Perl in the classes of "Scripting as a Programming Paradigm".

Re:FWIW

luqui on 2005-11-19T22:51:17

> What we learn in these classes is, respectively,
> Functional, Imperative, Logic and OO programming.

Yep, those are the four that I identified in my last post. However, I argue that OO is an "abstraction style", and not a "control style", which is what I'm looking for.

Re:FWIW

chromatic on 2005-11-22T01:04:49

If you want a control style, where does event-driven programming fit? What if it's asynchronous?

Re:FWIW

luqui on 2005-11-23T09:00:22

> If you want a control style, where does
> event-driven programming fit? What if it's
> asynchronous?

I define the control paradigm by the input (code) and the output (what happens when you run it). In the event driven case, you give it actions to execute when certain things happen. But the first part is the important part, you're giving it actions, and it tells you what happens when those actions are executed, even though those actions are triggered rather than sequenced. Therefore, I think event-driven programming is a form of imperative, which isn't surprising, since most programming these days is imperative (it is a, er, logical thing to program in, because it maps most closely to what the computer actually does).

However, the point of this little exercise was to identify the binary dimensions on which the different languages lie. So maybe event-driven programming is one of those dimensions:

        Event-driven functional: Compute what properties of the world change as objects are introduced and removed (this is what I called forward-chaining logic, and I want a system that does it badly!)
        Event-driven logical: Compute the set of objects satisfying a property continually as objects are introduced and removed
        Event-driven imperative: Do stuff to the world as you detect it change
        Event-driven logiparitive (or whatever this fourth control style is called): Compute the changes the world is undergoing as it changes

Some of those are a little bit stretchy, but it kinda seems to work.

As far as asynchronous programming, I think that's definitely a binary dimension, as it is referring to the *order* in which things are done (which serial or parallel), and the control style doesn't refer to that at all. I have also seen asynchronous functional languages and logic engines, so it seems like it can be put into any paradigm (though async Haskell is all within the IO monad, so it's arguable whether it really fits in the functional world).

Hmm...

autrijus on 2005-11-20T15:26:11

I'll probably call it autonomous programming, or even proof-assisted programming.

Re:Hmm...

Ruud on 2005-11-21T21:51:25

I was thinking in the direction of Genetic Algorithms: the programming is in the training.

Re:Hmm...

n1vux on 2005-11-21T22:07:10

Genetic algorithms, and also perhaps other relaxation / constraint techniques like the Simplex method of Linear programming?

Re:Hmm...

luqui on 2005-11-23T09:10:26

> Genetic algorithms, and also perhaps other
> relaxation / constraint techniques like the
> Simplex method of Linear programming?

The only thing I know about linear programming is that my grad-student friend is taking a course in it and he's working his ass off... :-)

Genetic algorithms are an interesting idea for this control style. My thinking (and my toy implementation) was that you would specify a class of functions, and it would find which function in that class that mapped a given input to a given output. But it could be argued that that's just logic programming (find me function objects that satisfy the constraint that they map this input to this output). Genetic algorithms take a bunch of inputs and outputs and try to find the most general function that covers all of them, which seems closer to the mark, in that it is farther from logic programming. Genetic algorithms are a specific "solution method" to this style of problem. I wonder what the others are...

I should have read this before replying before

Crag on 2005-11-27T20:32:35

I like your logic, but I don't know how you'd make a programming language out of that fourth type. But then, I don't grok logical programming either, so maybe it's just me.

The fourth paradigm

Trieu on 2005-12-01T04:59:20

I liked the logic. When you give the fourth paradigm a result. There might be so many *actions* corresponding to that unique result. So, the next step is that, which actions should be the best. --> Optimization?

(Hey, assume that the 4th paradigm was made :-)