Lambda the Ultimate

inactiveTopic Essay: Multi-Paradigm Design and Generic Programming
started 11/11/2002; 6:22:40 AM - last post 11/16/2002; 1:11:16 PM
Sam Gentile - Essay: Multi-Paradigm Design and Generic Programming  blueArrow
11/11/2002; 6:22:40 AM (reads: 1013, responses: 23)
On my blog, I wrote an essay Multi-paradigm Design and Generic Programming, that I would like people to take a look at. I am not a CS heavyweight, or languages expert (like people seem to be here) and I am just learning in this particular area, so please be kind-) but I would like your thoughts (constructive).

Sam Gentile - Re: Essay: Multi-Paradigm Design and Generic Programming  blueArrow
11/11/2002; 9:19:09 AM (reads: 1004, responses: 1)
I'm confused on how this site works. I pressed "New Topic" and t created an entry here unlike all the others that go on the front page? Also, I can't seem to edit my information as it seems that when you click on my name quite dreadful thigs happen -)

Ehud Lamm - Re: Essay: Multi-Paradigm Design and Generic Programming  blueArrow
11/11/2002; 9:31:38 AM (reads: 1013, responses: 0)
There's some bug with the profiles. I am not sure what it's about, so I am not sure how to go about fixing it. Some Manila quirk.

About posting (I really should update the FAQ, I know. But I am very busy at the moment. It will happen. Sorry):

Members can post to the discussion group. Only editors can post to the home page. Editors are usually members that frequently come up with good links and have insightful comments. But anyone can apply. I haven't refused anyone yet.

We usually don't link from the home page to projects we are involved with directly, but prefer other editors to give such links, if they find the work interesting enough. This gives us a two-level system: The discussion group is not moderated, but the home page is. So if a LtU reader is only interested in reading quality papers, and isn't interested in our rambling discussions, he can use the RSS fead, or just read the home page.

Often, when a discussion becomes interesting enough and editor will decide to link to it from the home page.

Isaac Gouy - Re: Essay: Multi-Paradigm Design and Generic Programming  blueArrow
11/11/2002; 11:56:07 AM (reads: 990, responses: 1)
Multi-paradigm Design and Generic Programming
Misread that as Generative Programming rather than Programming with Generics. Now there's an example of seeing what you want to ;-)

Reading the essay was fascinating and hard: as-fascinating-as a visit to an alien culture, and so hard not to scream ;-)

What does the essay mean exactly by multi-paradigm design? I expected to see something about functional programming and logic programming and constraint programming as included paradigms (Mozart/Oz). If that isn't what it means, what does it mean?

Is the essay about multiple paradigms or the unification of multiple paradigms in a single language? (Beta)

the problem domain and the solution domain Here's a rich and concise exposition on problem domains Practice, Principles and Prejudices.

As Coplien says, “All other languages debates aside, one advantage of C++ is that it directly expresses the intent of the analysis in a way that Smalltalk can only do by convention.”
What is meant by the intent of the analysis? How is it explained in the book?

Sam Gentile - Re: Essay: Multi-Paradigm Design and Generic Programming  blueArrow
11/11/2002; 12:04:11 PM (reads: 963, responses: 1)
I don't know a thing about the languages you mention or have even heard of them (nor have most people probably). I said that I am not a languages expert, an acedemic, or at the level of most people here. I am a working developer and consultant who was trying to make a big leap here. This is difficult territory for me and I was trying to stretch and learn something. If it made you want to scream, oh well..

Ehud Lamm - Re: Essay: Multi-Paradigm Design and Generic Programming  blueArrow
11/11/2002; 12:06:13 PM (reads: 1013, responses: 0)
BTW, Stroustrup wrote quite a bit about C++ being multiparadigmatic. The primary example is, of course, templates (== generics). The papers on his home page are worth a look.

Ehud Lamm - Re: Essay: Multi-Paradigm Design and Generic Programming  blueArrow
11/11/2002; 12:11:55 PM (reads: 989, responses: 0)
Sam, I don't think Isaac was trying to be offensive. The links he gave are really worth checking, esp. the Oz/Mozart system.

Sam Gentile - Re: Essay: Multi-Paradigm Design and Generic Programming  blueArrow
11/11/2002; 12:15:16 PM (reads: 964, responses: 2)
I understand and I will. I said starting out that I was not a languages heavyweight and would love to learn. I will follow the links. If it were me, I would have worded it differently but thats me.

Ehud Lamm - Re: Essay: Multi-Paradigm Design and Generic Programming  blueArrow
11/11/2002; 12:40:23 PM (reads: 995, responses: 0)
The LtU readership is very hetergenous. With have CS PhD, and also people that actually work for a living...

Personally, I am interested in what both these groups bring to the table.

Isaac Gouy - Re: Essay: Multi-Paradigm Design and Generic Programming  blueArrow
11/11/2002; 2:05:17 PM (reads: 985, responses: 0)
Those smileys just don't work anymore do they ;-) Please accept my apology, I really didn't intend to be offensive.
I was a Smalltalk programmer, I see C++ and I scream (C++ seems so close to the machine). When I see Java I curse, because Java has won, for the moment ;-)

I was trying to stretch and learn something
Help me learn something! I ask those questions because I don't have a background in C++. I'm asking you to find other ways to explain it to me.

Sam Gentile - Re: Essay: Multi-Paradigm Design and Generic Programming  blueArrow
11/11/2002; 2:09:08 PM (reads: 962, responses: 0)
Ok, Issac, my bad-). I'm oversensitive today and lacking in self-esteem-). All cool now-)

I will try to write some more later.

Sam Gentile - Re: Essay: Multi-Paradigm Design and Generic Programming  blueArrow
11/11/2002; 2:27:00 PM (reads: 948, responses: 0)
As Coplien says, “All other languages debates aside, one advantage of C++ is that it directly expresses the intent of the analysis in a way that Smalltalk can only do by convention.” What is meant by the intent of the analysis? How is it explained in the book?

Let me try. I don't know Smalltalk at all so I don't know if I will make any sense-) He says "In C++, we can write a single List template - one set of source - that can maintain lists of any kinds if objects. We can do the same thing in Smalltalk, though the mechanisms that make the same genericity possible are implemented in a much different way. All other language debates aside, one advantage of C++ is that it directly expresses the intent of the analysis in a way that Smalltalk can do only by convention."

Can you fill in the Smalltalk mechanism? Coplien is refering to the original FAST method [Weiss, David Family Based Domain Engineering, Reading Mass. Addison Wesley, 1987] which uses commonality and variability analysis to chacterize families of software artifacts or abstractions. Instead of leaving the programming langauge to chance, FAST builds a structured vocabulary of family members as the basis for a custom programming language for each domain. He is using Weiss' principles to underly most of what he proposes in the book. He states that he parts company with Weiss only at the point of choosing a programming language/ Multi=paradigm design does not derive the structure of a custom programming language from the application domain analysis. Rather, it extracts the structure from a rich, general-pupose programming language such as C++ and matches it to the needs of the application domain. It uses that structure to guide design with more regulariry than with the original synthesis process but with more flexibility than with the FAST process alone. Thats the context leading to his comments.

Does that help?

Isaac Gouy - Re: Essay: Multi-Paradigm Design and Generic Programming  blueArrow
11/11/2002; 6:34:49 PM (reads: 947, responses: 0)
Many language features are focused primarily on exploiting commonality and accommodating variability. Language mechanisms are designed to a support particular paradigm or group of paradigms such as procedural, functional, object-based, and object-oriented. Each of these paradigms reflects a recurring pairing of commonalities and variabilities.
Commonality and Variability in Software Engineering

If I've understood correctly; scope, commonality, and variability (SCV) analysis can be used with any programming paradigm. Which would lead me to think of it as cross-paradigm design. Maybe it depends on what your definition of a paradigm is:

A paradigm, as the term is popularly used in contemporary software design, is a way of organizing system abstractions around properties of commonality and variation. The object paradigm organizes systems around abstractions based on commonality in structure and behavior and variation in structure and algorithm. The template paradigm is based on structural commonality across family members, with variations explicitly factored out into template parameters. Overloaded functions form families whose members share the same name and semantics, and in which each family member is differentiated by its formal parameter types.
MultiParadigm C++ Preface

SCV seems an interesting descriptive tool and technique. Can someone on LtU can provide an example of SCV for functional programming?

All other languages debates aside, one advantage of C++ is that it directly expresses the intent of the analysis in a way that Smalltalk can only do by convention.
Maybe this doesn't say more than the obvious: C++ is statically typed - so there's type information in the source code; Smalltalk isn't statically typed - so there isn't type information in the source code (apart from naming conventions and comments).

Can you fill in the Smalltalk mechanism?
Smalltalk lists are polymorphic - they can contain any kind of object, they can contain different kinds of object at the same time.

In the usual Smalltalk way support for refactoring became part of the toolset: the Refactoring Browser.

Noel Welsh - Re: Essay: Multi-Paradigm Design and Generic Programming  blueArrow
11/12/2002; 5:38:47 AM (reads: 946, responses: 0)
A good article. I doubt it will be revolutionary to the LtU crowd but to the OO orthodoxy it could well be a new perspective. Here be ramblings on abstraction. Take what you will (or can; coherence not guaranteed ;-):

I used to think we had three types of abstraction: data, control and syntactical. OO only addresses data abstraction. Functional programming also gives you control abstraction. Macros gives you syntactical abstraction. There are levels of expressitivity in each dimension. Not all OO languages address data abstraction equally. C++ has parametric polymorphism, aka generics, aka templates. Java doesn't. There are also different approaches in each dimension. OO and FP decompose data abstraction in different ways. OO makes it easy to add new data, FP to add new operations. Some languages laughingly pretend to intergrate the two (Python, Ruby, O'Caml, PLT Scheme) but support distinct functional and OO features. Some language really intergrate the two (CLOS, Dylan, Cecil, EML) by providing multiple dispatch systems.

I'm beginning to think that time is the fourth level of abstraction. Staged evaluation systems seem like a really good thing. Being able to specify distinct configuration-time and run-time code seems to capture many uses of templates (e.g. the smart-pointers), AOP and units. I think one wants many evaluation times, not some language defined set. This idea is still hazy but it feels to me like a good one.

Isaac Gouy - Re: Essay: Multi-Paradigm Design and Generic Programming  blueArrow
11/12/2002; 9:22:30 AM (reads: 941, responses: 2)
OO only addresses data abstraction
Certainly true that data abstraction dominates OO.

Functional programming also gives you control abstraction
First class functions, higher level functions, & functional composition address control abstraction. How does functional programming address data abstraction?

Noel Welsh - Re: Essay: Multi-Paradigm Design and Generic Programming  blueArrow
11/12/2002; 10:02:03 AM (reads: 961, responses: 1)
How does functional programming address data abstraction?

If guess HOF has nothing to do with data abstraction, but functional programming has become (largely) synonymous with static type systems in which data abstraction is via the good old sum-of-product type and pattern matching on constructors.

Ehud Lamm - Re: Essay: Multi-Paradigm Design and Generic Programming  blueArrow
11/12/2002; 11:22:39 AM (reads: 981, responses: 0)
Search for "algebraic datatypes". On first look they look so much like class hierarchies, it takes you a second to realize they are quite different.

Isaac Gouy - Re: Essay: Multi-Paradigm Design and Generic Programming  blueArrow
11/12/2002; 3:54:15 PM (reads: 887, responses: 2)
That worked, amongst these course notes, lectures 16 and 17 cover algebraic datatypes.

it takes you a second
Longer than that, looks like Modula2 ;-) A high-level Modula2 & pattern matching is nice.

Michael Vanier - Re: Essay: Multi-Paradigm Design and Generic Programming  blueArrow
11/12/2002; 5:00:10 PM (reads: 869, responses: 1)
Sam, have you read Structure and Interpretation of Computer Programs by Abelson and Sussman? They go into great detail on many different kinds of abstractions and how they can be implemented in computer programs. Object-oriented abstractions are just one of many useful paradigms. I think you'd find the book very interesting.

By the way, I think it's a bit misleading to say that functional programming languages give you control abstractions. To the extent that an iterator is a control abstraction, I'd agree. However, if you want arbitrary control abstractions you need something like scheme's call/cc, which is not a feature of most functional languages.

Ehud Lamm - Re: Essay: Multi-Paradigm Design and Generic Programming  blueArrow
11/13/2002; 12:24:51 AM (reads: 886, responses: 0)
Yes. I suggest distinguishing between procedural and control abstractions. They are hardly the same.

Ehud Lamm - Re: Essay: Multi-Paradigm Design and Generic Programming  blueArrow
11/13/2002; 12:31:34 AM (reads: 887, responses: 0)
These notes are not very clear. I'll see if I can find something better.

Ehud Lamm - Re: Essay: Multi-Paradigm Design and Generic Programming  blueArrow
11/13/2002; 1:23:56 AM (reads: 897, responses: 0)
A simple example, that may look natural to guys with OOP experience:

data Point =P Float Float
data Shape = Circle Point Float |
             Rectangle Point Point

isRound ::Shape -> Bool isRound (Circle __)=True isRound (Rectangle __)=False

shapeArea ::Shape ->Float shapeArea (Circle _r )=pi *r *r shapeArea (Rectangle (P x1 y1)(P x2 y2))=abs (x1 –x2)*abs (y1 –y2)

isRound and shapeArea are functions that behave differently, acccording to the type of their argument (analogy: virtual functions/dispatching). They are not part of the type (i.e, there's no class construct, so no class interface and encapsulation. These can be implemented using the module system). The operations are defined for the various types using pattern matching (which is more declerative).

A list of Shapes can be heterogeneous and contain both Circles and Rectangles.

Sam Gentile - Re: Essay: Multi-Paradigm Design and Generic Programming  blueArrow
11/13/2002; 7:12:32 AM (reads: 848, responses: 0)
Hi Folks. I have been buried in work the last 2 days so I will try to catch up today-) It seems like lots of great discussion.

Isaac Gouy - Re: Essay: Multi-Paradigm Design and Generic Programming  blueArrow
11/16/2002; 1:11:16 PM (reads: 823, responses: 0)
algebraic datatypes
Is use-of algebraic data types orthogonal to use-of functional programming? Could we imagine a Modula-D language that implemented algebraic data types, but didn't have higher-order functions and composition and... ? It's typeful programming.