12

The Question

What are the origins of the Public/Private function paradigm?

Background

A question came up in chat about Header files in C, and their usage being mainly to help the compiler, not the programmer. It's my understanding though, that this is the first usage of the concept of "Private" functions, or functions which aren't prototyped in the header file. Had C not used header files to declare functions, would we still have the current concept of Public and Private functions as seen in C# or Java? Or was this concept initially developed elsewhere and simply implemented in the C Header/Source scheme

3 Answers 3

15

Private/public comes from the original OO language, Simula, which predated C by a few years. According to the Wikipedia article, the original concept was first implemented in the TOPS/10 variant of Simula, and was integrated into the core language standard in 1987. It doesn't say when TOPS/10 Simula was first created, though, so it may or may not have been earlier than C.

Regardless, even if C and its header file system had not been around, modern programming languages would still have inherited the concept of encapsulation through the private/public system from Simula.

1
  • 7
    And, of course, mainframe code from LONG before 1987 had "external symbols" (== "public") routines and non-external (== "private") routines, without the specific keywords. Commented Mar 24, 2014 at 22:10
2

I think the idea of making parts of your code private has roots which goes further back than Simula. Scheme (1975) was the first language to implement closures, which gives you the possibility to encapsulate data such as lambdas. Schema also lets you specify internal functions using the define keyword.

Making functions private allows more abstraction to be incorporated into a program. Building abstractions in programs has a long history, with LISP-variant languages such as Scheme contributing a lot to the development of modern programming languages.

Structure and Interpretation of Computer Programs by Abelson, Sussman is an excellent book to learn more about abstractions if you are interested in those things.

0
1

'Modula', by Niklaus Wirth, hastily added the concept of modules to a Pascal derived language around 1975-1976. His paper on it was published in 1976. However, he quickly focused on 'Modula-2' in 1977 and stopped work on Modula.

Modules had the concept of public and private symbol declarations.

He was influenced by 'Mesa' from his time at Xerox PARC (1976-1977). Mesa was a derivative of Pascal designed for systems programming. It had the module concept. In his paper (linked below), he also mentions that the module concept could also be seen as an implementation of the Abstract Data Type concept by Liskov in 1974.

UCSD Pascal added this to Pascal as 'interface' and 'implementation' around 1978. Everything in an interface was 'public' and everything in the 'implementation' was private to that module.

Simula added this concept later in the 1980's to classes. C++ as well added public and private in the 1980's.

A great account of Wirth's thoughts is from his History of Programming Languages (HOPL) paper "Modula-2 and Oberon" from June 2005.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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