Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

While discussing a question about virtual functions on Stack Overflow, I wondered whether there was any official naming for pure (abstract) and non-pure virtual functions.

I always relied on wikipedia for my information, which states that pure and non-pure virtual functions are the general term. Unfortunately, the article doesn't back it up with a origin or references.

To quote Jon Skeet's answer to my reply that pure and non-pure are the general term used:

@Steven: Hmm... possibly, but I've only ever seen it in the context of C++ before. I suspect anyone talking about them is likely to have a C++ background :)

Did the terms originate from C++, or were they first defined or implemented in a earlier language, and are they the 'official' scientific terms?

UPDATE:

Frank Shearar helpfully provided a link to the description of the SIMULA 67 Common Base Language (1970). This language seems to be the first language to introduce OO keywords as class, object, and also virtual as a formal concept. It doesn't define pure/non-pure or abstract, but it does support the concepts.

Who defined them?

share|improve this question
1  
Might find this interesting...objectmentor.com/resources/articles/abcpvf.pdf –  Aaron McIver Feb 9 '11 at 19:32
1  
virtual functions, virtual inheritance, virtual tables - none with any real explanation of what makes them "virtual". I know the rules, but why that word? After all, a "virtual" function is as real as any other function - it just needs a late-binding lookup, is all. Maybe Stroustrup just really liked the word. I thought classes were abstract (not pure), whereas methods might be pure (but not abstract). It's possible I made that up, though. –  Steve314 Feb 9 '11 at 19:54
2  
@Steve314, it wasn't Stroustrup - apparently they were called like this already in Simula. –  Péter Török Feb 9 '11 at 20:21
add comment

3 Answers

Nygaard and Dahl first used the term, in SIMULA 67 Common Base Language. Look in section 2.1, for instance, and section 2.2.3. (As far as I can tell at least. But hey, as far as OOP's concerned, it's probably the first use of the term.)

share|improve this answer
3  
Simula was the first OO language, AFAIK, so it has the first use of lots of terms in an OOP context. It greatly influenced Stroustrup, who initially just wanted a language with C efficiency and Simula classes. –  David Thornley Feb 9 '11 at 21:10
    
I'm skimming through this paper, and yes, it seems to be the first, as they are introducing 'classes' and 'objects'. –  Steven Jeuris Feb 9 '11 at 21:15
1  
So, after some time wasted reading the SIMULA 67 definition. Simula 67 coined 'virtual' along with 'class', 'object', 'hidden', 'call by value', 'call by reference' in 1970. No sign of 'pure', 'unpure', or 'abstract'. –  Steven Jeuris Feb 9 '11 at 22:20
4  
"Wasted" seems like an odd word to use to describe reading one of the seminal papers of the field. –  Frank Shearar Feb 9 '11 at 22:33
add comment

In C++, member functions that are dynamically bound, and thus can be overridden by a sub-class are called "virtual". Virtual functions that absolutely must be overridden are called "pure virtual". Note that a pure virtual function may have a body, although often it does not. A class that has at least one pure virtual function is called "abstract", and cannot be instantiated, only derived from.

I am guessing the reason why virtual functions are called virtual is the fact that it is not known which actual function will be called at compile time. In a sense, a virtual function call "does not exist" at compile time.

I am also guessing that the reason the term "abstract" is used for a class with a pure virtual function is that you cannot have any objects of that class. In a sense it is an abstract concept far removed from the concrete world of objects.

Edit: Other languages.

As far the question of how general the term "virtual" is, here's my two cents. In Smalltalk all functions use dynamic binding, so there they are all virtual, and there is not need for a special term or a language keyword. In Java, if I am not mistaken, the compiler automatically decides whether dynamic binding should be used, so as far as the programmer is concerned there is no distinction, and hence no "virtual" keyword.

In C++ the distinction between virtual and non-virtual is necessary, because it is up to the programmer to decide when dynamic binding should be used to save on the overhead when it is not needed.

share|improve this answer
1  
+1: Also, "Abstract" applies to many languages. "Virtual" doesn't. –  S.Lott Feb 9 '11 at 21:25
    
@S.Lott: The entire question is whether or not virtual is a general term. As far as I can tell now, virtual does apply to many languages, and was first coined by Simula. Question remains about pure/non-pure and abstract. –  Steven Jeuris Feb 9 '11 at 21:40
    
@Steven Jeuris: "virtual does apply to many languages"? Really. So far, it seems to be C, C++ and Simula. It certainly does not apply to Python even a little bit. It doesn't seem to apply to Java. –  S.Lott Feb 9 '11 at 21:54
    
It applies to Object Pascal/Delphi. Delphi has an additional concept - dynamic - which is a kind of virtual method that trades space for time: they take less space, and are slower to execute, than virtual methods. –  Frank Shearar Feb 9 '11 at 22:12
2  
@Steven Jeuris: "virtual by default" is not the same thing as using "virtual" to describe abstract functions. I think folks that say "all functions are virtual" are applying a C++ concept to another language. And I think they're doing it improperly. Since all method functions are virtual in Python, the topic is never mentioned using "virtual" except in places like Stack Overflow to apply the C++ concept to Python. I think virtual is applied improperly in those cases, since the Python language docs don't use the word. –  S.Lott Feb 9 '11 at 22:26
show 2 more comments
up vote 6 down vote accepted

So ... I've been doing a little research. What follows is a little history lesson for those interested. :) Skip to the conclusion at the bottom if you're only interested in the answer.

1967:

SIMULA 67, the first object-oriented programming language defines keywords as class, object, call by reference, call by value and virtual.

SIMULA's inheritance system was originally known by a different name, concatenation (and later known as prefixing), referring to the fact that code of supertypes was copied and 'concatenated' with the code of subtypes. Later another form of inheritance system emerged, delegation, where calls are delegated by reference to the correct type.

Virtual most likely refers to the process which needs to be performed to dispatch a call to the correct implementation by using a virtual method table. It's virtual as compared to a fixed/concrete implementation.

1971:

Niklaus Wirth, writes about a concept defined as Stepwise Refinement. It basicly explains how to divide a program in partial solutions on which can be extended.

1974:

This is the earliest paper I found which coins the term abstract data types by Barbara Liskov.

An abstract data type defines a class of abstract objects which is completely characterized by the operations available on those objects. This means that an abstract type can be defined by defining the characterizing operations for that type. When a programmer makes use of an abstract data object, he is concerned only with the behavior which that object exhibits but not with any details of how that behavior is achieved by means of an implementation.

This paper also defines an operation cluster which seems to specify what we now know as an interface.

Interesting scientific terminology (paper from 1996):

Inheritance: a more low-level mechanism by which objects or classes can share behavior or data.

Subtyping: expresses conceptual specialization. A specific form of inheritance, also called interface inheritance.

Abstraction principles: The process of organizing our knowledge of an application domain into hierarchical rankings of orderings of abstractions, in order to obtain a better understanding of the phenomena in concern.

Partially implemented abstractions: abstractions whose definitions have purposely been left incomplete.

Abstract classes: Specific term for a partially implemented class in object-oriented systems.

Nonstrict inheritance: Allows operations to be redefined (or even removed) in subclasses.

Strict inheritance: Behaviorally compatible inheritance.

Conclusion:

Abstract class is the most general term to use in object-oriented systems. It seems pure and non-pure virtual functions only originate from C++. For example, this interview with Stroustrup makes it seem he invented the terms. Scientific papers use more general terminology.

Virtual originates from SIMULA, which causes it's usage to be widespread, but it isn't a general term. It already defines implementation details. Speaking in terms of types of inheritance is more appropriate. Non-virtual by default corresponds to strict inheritance by default, while virtual by default corresponds to nonstrict inheritance.

Anyone interested in adjusting the wikipedia entry? :)

share|improve this answer
    
+1 for a thorough research! –  Emmad Kareem May 22 '12 at 23:02
    
Before Barbara Liskov, Dijkstra also had something to say on "STEP-WISE PROGRAM COMPOSITION", which might also be a relevant resource. –  Steven Jeuris Mar 15 '13 at 12:38
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.