I'm reading about Swift enum
's in the Swift Programming Language guide and the text was comparing the differences between Swift's enum
and C's enum
. This made me curious as to where enumerations came from originally. I did search online before asking and even asked a few people and they assumed C. (I suppose I'm trying to confirm if enumerations came from C originally.)
Question
What was the first programming language to include enumerations?
1883: The first programming language was developed in 1883 when Ada Lovelace and Charles Babbage worked together on the Analytical Engine, which was a primitive mechanical computer. Lovelace was able to discern the importance of numbers, realizing that they could represent more than just numerical values of things.
Lovelace wrote an algorithm for the Analytical Engine, the first computer program, to compute Bernoulli numbers. 1949: Assembly language was first used as a type of computer programming language that was able to simplify machine code language, which is necessary for telling a computer what to do.
Last Updated : 21 Dec, 2018. Enumeration (or enum) is a user defined data type in C. It is mainly used to assign names to integral constants, the names make a program easy to read and maintain. enum State {Working = 1, Failed = 0}; The keyword ‘enum’ is used to declare new enumeration types in C and C++.
Martin Richards developed the BCPL programming language, forerunner of the B and C languages. Nathaniel Rochester, inventor of first assembler (IBM 701). Niklaus Wirth, inventor of Pascal, Modula and Oberon. Ole-Johan Dahl, pioneered object-oriented programming, co-invented Simula.
Pascal had enumerated types, but didn't use the keyword enum
. AFAIK, the keyword enum
was first used by C, but the concept is older by quite a margin.
See Wikipedia on Enumerated type for an example such as:
type
cardsuit = (clubs, diamonds, hearts, spades);
card = record
suit: cardsuit;
value: 1 .. 13;
end;
var
hand: array [ 1 .. 13 ] of card;
trump: cardsuit;
I think Pascal is the oldest of the languages listed on the Wikipedia page. The LISP referred to is Common Lisp, which postdates Pascal even though original LISP handily pre-dates Pascal.
The Programming Language Pascal from 1970 lists these types in section 6.1.1 Scalar Types, so for all practical purposes, these enumerated types have always been a part of Pascal. See the documents page at the Standard Pascal web site. The revised report is also available there (1972), and is probably the more widely read document. You can also track Pascal at Wikipedia, of course.
(There might be another earlier language with analogous features; I've not identified it, but I've not looked everywhere. Algol-60 was not such a language, though; nor was Fortran or Cobol. Algol-68 and PL/1 are possible contenders.)
Algol 68 did not have enums. PL/I did not have enums. Historic Lisp had no notion of compile-time types at all. Algol W and Simula 67 did not have enums. Oddly enough, COBOL is not only a possible contender but the most likely one. Not that it had user-definable types, but look up "88-level". The macro facilities of Burroughs Algol, SAIL, CORAL 66, and RTL/2 could be used to give names to numbers, which takes you almost as far as C's rather broken enums go.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With