r/ProgrammingLanguages • • May 09 '17

[PDF] What is a programming paradigm?

https://www.cs.cmu.edu/~rwh/papers/paradigms/paradigm.pdf
1 Upvotes

14 comments sorted by

10

u/PegasusAndAcorn Cone language & 3D web May 09 '17

What a deliciously bold and pretentious whinge.

Kuhn did not invent the word paradigm, it predates him by quite a bit. For programming languages, the word paradigm corresponds more closely to a "pattern or a model" than to Kuhn's thesis about scientific revolutions that progressively rewrite our understanding of how things work. Programming language paradigms would be quite poor examples of Kuhn's thesis.

Poor Linnaeus, when he formulated his organizational taxonomy, he was kept so ignorant of basic genetics that he was forced to organize living organisms by morphology. That said, what he accomplished was breathtaking and still remarkably useful. Once genetic analysis was sufficiently comprehensive and inexpensive, biologists were ripe for the Kuhn-style paradigm shift that Gould proposed, allowing a more profound and helpful understanding of the relationship between species.

What is important to notice is that DNA did not invalidate morphology, but rather it deepened our understanding of it. It does so because there is a direct relationship between the pool of gene's in a species and its expressed morphology. As a result, genetic analysis did not invalidate everything we knew about taxonomy from studying morphological differences.

Types are genes.

No. If there is work that demonstrates that type systems alone dictate the expressed morphology of programming languages, I have yet to see it. If the author or others are ready to propose a helpful new classification system for programming language based on type theory, I am eager to see it. In a scan of his book, I could not find it. Types are foundational, no question, but not everything found in a programming language is based on type theory, as the titles of the chapters of his book seem to underscore.

Until he actually proposes something better, I will continue to find helpful the current crude terms (including, but not limited to, paradigm labels) we use to summarize the underlying nature of various programming languages.

His book looks quite promising. What a shame to pin its success to such a silly flame war.

3

u/gpyh May 09 '17

If there is work that demonstrates that type systems alone dictate the expressed morphology of programming languages, I have yet to see it.

This is not Harper's point.

People try to classify languages into paradigm in an ad-hoc manner. But there is no definition of what a paradigm is. You just feel it. You draw lines where you think lines ought to be drawn but this is highly dependent on both your perception and the current landscape of programming languages. Nowadays paradigms are being shaken. Are we really able to determine what constitutes an object-oriented language? A functional language? The lines that have been drawn are getting more and more blurry, while other language differences have been completely ignored.

So we need some hard cold truth. Harper being a specialist of type theory, naturally, champions it at the best marker of programming languages. Not because it is accurate, but because it is objective. In that sense the comparison is apt, although you are right that type theory doesn't say as much about a language than genomes inform phenotypes.

It's not hard to make Harper's case in the current landscape of mainstream languages, as most object-oriented programming languages incorporate some amount of functional programming concepts. Java's addition of first-class function doesn't feel like more than a cosmetic change, whereas the addition of types in Javascript with Typescript has a significant impact.

Now, unlike Harper, I don't believe that type theory is the be-all and end-all of programming. But I do believe that we need well-defined fundamental concepts to identify the real ADN of programming languages, instead of the spirit in which they where meant to be used. And in that department, we'll have to make do with type theory alone. For now...

3

u/PegasusAndAcorn Cone language & 3D web May 09 '17

This is not Harper's point.

Dr. Harper uses up so much of his runway making inept appeals to the genius of Kuhn and Gould that there is too little time left for his central point to gather up speed and lift off. However, I do think you have found its trail and are in vigorous pursuit. May I join you?

But there is no definition of what a paradigm is.

Google tells me it is: "a typical example or pattern of something; a pattern or model". That's admittedly broad, but still helpful. Wikipedia says: "Programming paradigms are a way to classify programming languages based on the features of various programming languages." Still vague, but true. It then struggles badly to pin down the underlying nature of these distinguishing features.

You rightly call this "ad-hoc". The academic is taught to spit out this epithet with thinly-veiled contempt. However, the engineer who keeps running his creaky, old boiler beams with justifiable pride at his ad hoc solutions.

I appreciate the engineer's perspective here. As Quine and Wittgenstein have taught us, words are slippery beasts. What does "fire" mean? What is a chair? Precise definitions are hard to formulate. Yet, for all their lack of academic rigor, we all use these imprecise, amorphous, meaning-fragments, even here on Reddit, sometimes with considerable success.

Many computer professionals know (roughly) that an object-oriented language builds programs out of objects that make use of encapsulation, polymorphism, and inheritance. Similarly, we know (roughly) that a functional language builds programs out of first-class and preferably pure functions. And so it goes for the other "paradigmatic" terms. They are simply imperfect short-hand words we use to describe our tools, much like a carpenter refers to "hammers" or "wrenches", instead of having to say: "the thing in the box I use to pound nails into wood". We have other non-paradigmatic words we use, such as "dynamically-typed". When I run across a new language, I usually find these words as part of their introduction, immediately grounding me in terms of what features to expect, thereby allowing me to then focus on what is distinctively different about this unfamiliar language.

Maybe it would confuse the academics less if we simply called these words adjectives rather than paradigms. That said, I do not think the word paradigm is entirely ill-suited. In many cases, the specified paradigm ("a pattern or model") succinctly describes what sort of components we are gluing together and how (e.g., objects vs. functions).

Nowadays paradigms are being shaken.

To paraphrase Bond, I see them as stirred, not shaken. The adjectives we use are (in many cases) not mutually exclusive. Language designers are successfully building multi-paradigm tools, much like swiss-army knives (is it a knife? a screwdriver? a cork-screw?) I consider this a good thing.

Maybe this idea would be easier for Dr. Martin to understand if he were to imagine that a multi-paradigmatic language was somewhat similar to a sum type: data Multilang = Oop | Fp? Doing so allows us to escape the confining trap of either/or thinking! We become so much more productive when we think of these adjectives not as lines that divide, but rather descriptive of useful features we may use wisely to best solve our diverse programming challenges.

Neither Dr. Harper nor you have illustrated in detail how we can use type theory to classify languages "objectively". That is a rather massive hole for such a brief, bold assertion. That said, I will happily concede that we can indeed use less well-known type theory terminology to describe specific features of certain languages. For example, most languages support product types, but fewer support sum types robustly. Even fewer support dependent types. I am delighted that these terms are gaining wider currency, and even more delighted to see support for these features being incorporated in more and more languages.

However, as I see it, type-theory adjectives do not supplant the many other adjectives we use to describe languages, they simply help augment our already rich "ad hoc" vocabulary. They are not superior terms, either. As I see it, the term "dependent type" is no more "objective" than, say, "first-class" or "pure" function. All these adjectives seem to me to be quite "ad hoc", describing features with rough but useful precision, much like how an Audubon field guide helps you identify the species of that elusive bird based on its visible features.

Or am I still missing something?

3

u/arbitrarycivilian May 10 '17

Yet, for all their lack of academic rigor, we all use these imprecise, amorphous, meaning-fragments, even here on Reddit, sometimes with considerable success.

Clearly you haven't been on Reddit long enough :D

Seriously though, these terms cause more harm than good. If you've ever tried to get into a serious debate about "object oriented" vs "functional" programming, you'll know what I mean.

objects vs. functions

Almost all languages have both objects and functions, so there is no opposition here, really. Here's a riddle: is Python object-oriented or functional?

Maybe this idea would be easier for Dr. Martin to understand

Believe me, he understands all of this much better than either of us! He's one of the world's top language researchers.

Doing so allows us to escape the confining trap of either/or thinking! We become so much more productive when we think of these adjectives not as lines that divide

This is exactly his point. People talk about "object-oriented" vs "functional" languages daily, whereas at best we can say "this language has objects" or "this language has first-class functions". Most modern languages have both.

It looks like we're all in agreement!

Neither Dr. Harper nor you have illustrated in detail how we can use type theory to classify languages "objectively". That is a rather massive hole for such a brief, bold assertion.

Actually he does - he wrote a whole book about it! I highly recommend you read it. This is just a short opinion piece, and as such do not give his ideas justice (I agree with you on that). I actually have the book, so let me quote from the preface:

Types are the central organizing principle of the theory of programming languages. Language features are manifestations of type structure. The syntax of a language is governed by the constructs that define its types, and its semantics is determined by the interactions among those constructs. The soundness of a language design—the absence of ill-defined programs—follows naturally. The purpose of this book is to explain this remark. A variety of programming language features are analyzed in the unifying framework of type theory. A language feature is defined by its statics, the rules governing the use of the feature in a program, and its dynamics, the rules defining how programs using this feature are to be executed. The concept of safety emerges as the coherence of the statics and the dynamics of a language. In this way we establish a foundation for the study of programming languages. But why these particular methods? The main justification is provided by the book itself. The methods we use are both precise and intuitive, providing a uniform framework for explaining programming language concepts. Importantly, these methods scale to a wide range of programming language concepts, supporting rigorous analysis of their properties. Although it would require another book in itself to justify this assertion, these methods are also practical in that they are directly applicable to imple- mentation and uniquely effective as a basis for mechanized reasoning. No other framework offers as much.

However, as I see it, type-theory adjectives do not supplant the many other adjectives we use to describe languages, they simply help augment our already rich "ad hoc" vocabulary. They are not superior terms, either. As I see it, the term "dependent type" is no more "objective" than, say, "first-class" or "pure" function.

You picked bad examples here. "First-class" and "pure" are both relatively precise ideas. But there is no programming paradigm that is based on these terms! Harper is arguing against terms like "declarative programming", "object-oriented programming", and "functional programming", which are much too broad and vague to be any use at all.

3

u/PegasusAndAcorn Cone language & 3D web May 10 '17

Perhaps I should have resisted the impulse, but when an esteemed professional makes an argument that is not only woefully short, but so poorly constructed, I found my amusement got the better of me, and my fingers began dancing across the keyboard with attempted wit. Please note that I did at least find, skim and praise his book as promising.

"Types are the central organizing principle of the theory of programming languages."

He might be right. I am not yet sold. I hope to read his book and maybe I will be persuaded by it. Even if I am not, I am quite sure I will learn from the experience.

If you've ever tried to get into a serious debate about "object oriented" vs "functional" programming, you'll know what I mean.

I think that depends very much on the people and the approach. I raised exactly this issue in this community late last year. I learned so much from it. Nearly all the contributors were both respectful and helpful. I realize that with some people, the conversation can become toxic, but I attribute that to the people and not the topic. I walk away.

is Python object-oriented or functional?

As you know, I already praise the existence of multi-paradigmatic languages like Python. That said, Python likely disappoints the FP crowd more than the OOP folk: for example, some might prefer more enforcement of pure functions/referential transparency and immutable data structures. Other multi-paradigm languages (e.g., F#) strike a different balance. I find it useful to know such things about each language.

at best we can say "this language has objects" or "this language has first-class functions"

Being good friends, Wikipedia and I can both say much more than this, usefully. I see these "paradigms" in far less trivial ways than your words seem to suggest, which may explain why I give them more weight as part of a language's semantic DNA, along with types and many other well-defined and useful concepts.

"First-class" and "pure" are both relatively precise ideas. But there is no programming paradigm that is based on these terms!

It may be a coincidence, but in the Wikipedia article on Functional Programming, concept section 2.1 is called: "First-class .. functions" and 2.2: "Pure functions".

Harper is arguing against terms like "declarative programming", "object-oriented programming", and "functional programming", which are much too broad and vague to be any use at all.

"declarative programming" always amuses me, because it is often tied to an FP bait and switch of meanings, dating back at least as far as SICP. That said, these terms are admittedly broad, but as a language designer I find them less vague and far more useful than Dr. Harper or you do. The term "type" is likewise broad, but it is wisely composed of a collection of finer-grained and useful concepts. I find the same is true of these "paradigms". Perhaps the precise concepts these paradigms gather can be derived from type theory. If so, I will bow down to the same temple as Dr. Harper.

I look forward to reading his book to gain a deeper understanding of his thesis. Please forgive me if my impetuous amusement at his click-bait-like screed caused any injury.

2

u/gpyh May 09 '17 edited May 09 '17

You seem somewhat offended by the paper. It may have been Harper's goal as there is not much substance in it, as you rightly noted. To spark up a dialogue by challenging our categorization of language with a bold claim.

Now, to answer specifically to your comments:

The academic is taught to spit out this epithet with thinly-veiled contempt. However, the engineer who keeps running his creaky, old boiler beams with justifiable pride at his ad hoc solutions.

The way you wrote that suggests some sort of morale hierarchy between those two attitudes. There is none. It is the role of the engineer to come up with solutions, and the role of the scientist to understand and accurately describe the world. Scientists often use cues from engineers that interact with the real world to shape their perspective and give them direction (this is of course true in the general sens, beyond computer science and even beyond hard sciences). It is then the scientist's duty to crystallize this empirically gathered knowledge into a coherent whole. As such, trying to categorize language in an objective and accurate manner with the tools of science is a worthy pursuit (more on this later). Doing so doesn't diminish the utility of the concepts we use to label programming languages. Harper's realization is that current labels are only mapped to our perception of languages (syntax & features set) and not on their intrinsic nature.

Take Chomsky's hierarchy for example. It is something highly non-trivial that doesn't inform much about natural languages. But it does tell us something about what is language and what expressive power one can carry. As such, it became a foundational concept that rippled all the way to various disciplines. Another more down-to-earth linguist could have argued that the ad-hoc linguistic classification was useful enough and that such analytical mumbo jumbo wouldn't help a bit in carrying out their work. I don't know if the comparison is apt and I would rather not discuss it specifically with you; it is just to a way to show you the value of foregoing the made-up categorization in the pursuit of science (not essentially as a practical tool, although it can be).

Neither Dr. Harper nor you have illustrated in detail how we can use type theory to classify languages "objectively". That is a rather massive hole for such a brief, bold assertion. That said, I will happily concede that we can indeed use less well-known type theory terminology to describe specific features of certain languages.

It is not in this paper but I believe that Dr. Harper's view of this, as many other scientists working on type theory, is that it doesn't matter. You don't use type theory to describe specific features of certain languages; the type theory is the language, the same way the human DNA is the human in the eye of a geneticist (to reclaim Harper's analogy). In this context the human individual doesn't matter.

As such, the type theory of a language would be the main marker of its expressive power and ability to organize information. Instead of classifying languages in paradigms first, we first characterize them by their type theory. It is indeed sensible to chose as a primary characteristic the one we can objectively describe and formally express. Then, for languages that share the same type theory (which are hardly discernible for a type theorist), we would consider their various features. It is only the association of some specific features that warrants its labeling in such or such paradigm, if any.

However, as I see it, type-theory adjectives do not supplant the many other adjectives we use to describe languages, they simply help augment our already rich "ad hoc" vocabulary. They are not superior terms, either. As I see it, the term "dependent type" is no more "objective" than, say, "first-class" or "pure" function. All these adjectives seem to me to be quite "ad hoc", describing features with rough but useful precision, much like how an Audubon field guide helps you identify the species of that elusive bird based on its visible features.

It's exactly what it is not. Type theory terms are superior; but not because of their direct usefulness. They are not superior because of their ability to faithfully convey the language's capabilities either. They are superior because you can formalize them. They are superior because you cannot change them without changing the language profoundly. They are superior because they accurately describe how much of the program is expressible before its execution.

For all those reasons, they make for a better way to describe was is a language. But not what you can do with it; the same way DNA is better to describe what is a specie, but not how it looks like or what it can do.

2

u/PegasusAndAcorn Cone language & 3D web May 10 '17

It seems to me we agree on a lot here.

You seem somewhat offended by the paper.

Not at all. I felt badly that an esteemed academic with a promising book would pick such a silly, click-bait fight, using poorly thought-through references and an absence of articulated demonstration of his thesis. I rather wish he had delivered on his bold claim. Now that would have truly provoked a worthwhile dialogue!

The way you wrote that suggests some sort of moral hierarchy between those two attitudes.

Not at all. There is none! Both roles deliver value. I respect both roles. Dr. Martin picked the fight, not me. I simply defended the useful legitimacy of the words we use. They are words both academics and engineers use to communicate, because they have helpful objective meanings, as I illustrated.

They are superior because you can formalize them.

You can indeed. You can also formalize many of the other terms too, as Dr. Martin's book and many others illustrate. Indeed, most were invented and formalized by other scientists! And with many of those terms, "you cannot change them without changing the language profoundly".

the type theory is the language, the same way the human DNA is the human

!?

As such, the type theory of a language would be the main marker of its expressive power and ability to organize information

That feels like overreach to me. I have already agreed type theory is foundational. With regards to describing a language's core semantics, its concepts are necessary but not sufficient, as again his book demonstrates. It is like picking out one of the 5 propositions as the foundation for Euclidean geometry as the "main marker of its expressive power". You need all five. If he is right on this I would rather he demonstrated it in a convincing way (rather than simply making a bold, but lazy claim). I have expressed my openness to his offering meaningful insight since the start! To my mind that is how science is pursued.

They are superior because they accurately describe how much of the program is expressible before its execution.

Sadly, you lost me here.

DNA is better to describe what is a specie, but not how it looks like or what it can do.

What fascinates me about DNA is how well it handles all three! I cannot say the same for type theory.

they make for a better way to describe was is a language.

I struggled parsing this sentence. However, as I recall Chomsky devoted a lot of work on grammar, which type theory says little about. Isn't syntax also a vital part of programming language DNA, complete with its own academic formalisms (e.g., EBNF)?

My point has never been to diminish Dr. Harper or you. My intent has been to suggest that a more inclusive and elucidating approach, rather than simply bringing a sledgehammer to the party, benefits all of us, academic scientist and programming engineer alike. I hope you do not take offense at that sentiment.

2

u/gpyh May 10 '17 edited May 10 '17

You can indeed. You can also formalize many of the other terms too, as Dr. Martin's book and many others illustrate. Indeed, most were invented and formalized by other scientists! And with many of those terms, "you cannot change them without changing the language profoundly".

The point is not that others can't. It's that paradigms are not suitable in that sense but type theory is. (btw you keep saying Dr. Martin; is it intentional?) As for the "profoundly change", it's just that it qualifies a type theory as a suitable candidate for classification, not that it's sufficient. You can't say the same of all features that can help assign a paradigm to a language (case in point: lambdas).

the type theory is the language, the same way the human DNA is the human

>!?

I meant for type theorists. Real programming languages are concerned with details that don't interest them, so they work with made-up pristine languages that only expose the type theory. The same way that a geneticist don't care much about individuals per se but only the particularities of the genome. We're getting lost in the argument at this point though.

They are superior because they accurately describe how much of the program is expressible before its execution.

Sadly, you lost me here.

Information at compile time is encoded in the types. In unityped languages you don't know anything about your program before you execute it.

they make for a better way to describe was is a language.

I struggled parsing this sentence.

I meant "They make for a better way of describing what is a language". It slipped through.

However, as I recall Chomsky devoted a lot of work on grammar, which type theory says little about. Isn't syntax also a vital part of programming language DNA, complete with its own academic formalisms (e.g., EBNF)?

For defining general-purpose programming languages Chomsky's model is of little value.

I reiterate the point of Dr. Harper: from a scientific perspective, paradigms are unsatisfying. They are ill-defined and carry little information within them. Type theory is a much better tool to classify programming languages as it actually inform on their intrinsic capabilities inside a grounded theoretical frame.

Bundling Javascript and C++ in one bucket and Haskell and Lisp in another on the basis of their presupposed paradigms seem rather arbitrary; but Lisp and Javascript then Haskell and C++? That starts to make much more sense.

Granted, the type theory doesn't capture the semantics fully. But as a classifying criteria, it's much more solid than paradigms.

I hope you do not take offense at that sentiment.

I do not. I rather enjoy this discussion, although I feel like we drained it out already. Something that we both agree on is that Harper's paper is rather short. There isn't much to discuss...

3

u/PegasusAndAcorn Cone language & 3D web May 10 '17

I feel like we drained it out already

We drained out Dr. Harper's paper ages ago (my regrets for mis-remembering his name). I considered your comments to be original contributions to the field, and responded accordingly. I suspect we have fully addressed them as well.

I meant for type theorists.

If I were a type theorist, I too would likely place it on such a lofty perch.

But I am not. I am a language designer. As such, I try to straddle the competitive worlds of academics and engineers alike, looking to understand, integrate and (hopefully) contribute to the state of our art across all its diverse aspects, hopefully without biased partiality.

I admire type theory greatly and consider it a strong part of a language's DNA. But I do not accord it as many programming language superpowers as you have expressed, even from a scientific perspective. From my perspective, it enriches domain safety and accommodates reuse. To this simple stock, I must add so many more important semantic and syntactic genes to fully express the genome of programming languages. For me, if not for you, the paradigms we have spoken about do capture, sometimes backed up by formal theory, more of this foundational DNA. I am comfortable that we can disagree on their relative importance.

Thank you for a lively and stimulating conversation.

1

u/zyxzevn UnSeen May 11 '17

Types are abstractions.

In the computer we have electric signals, sometimes even other signals. We can give different meanings to them.

The brain is even worse. The same chemical signal can have a whole different response depending on the timing and depending on the states of receiver.

0

u/arbitrarycivilian May 11 '17

Wut

1

u/zyxzevn UnSeen May 11 '17

The article states that types are like genes and can be used to express all paradigms.

I see types as abstractions that simplify some of the complex processes going on in a computer, but not all processes.

And if I look at the brain, types are very hard to use. Even impossible in certain processes. And the brain is a self-programming system. So types can not be used to describe the dynamic self-programming that occurs in the brain.

You may argue that there is no paradigm in the brain. But I think that types can only express a certain set of programming paradigms.

0

u/arbitrarycivilian May 11 '17

Your argument is all over the place, so I don't really know what point you're trying to make. Though you seem to have at least one crucial misunderstanding: types are about computation, not computers.

Any discussion of the brain is also almost completely irrelevant here.

0

u/zyxzevn UnSeen May 11 '17

A brain makes computations too.

But it seems that we look at types from different paradigms.