6
$\begingroup$

In object-oriented programming, dot notation is used when accessing the properties or methods of a class:

Dog dog
print dog.name
>> "Fido"
dog.walk()
>> Walking the dog now...

What is the origin of that syntax and why the . to notate it? It must date to some early object-oriented language, but I couldn't find mention of it anywhere.

$\endgroup$
  • $\begingroup$ Maybe Simula? $\endgroup$ – D.W. Mar 7 '18 at 22:56
6
$\begingroup$

In [1] (authored by one of the co-creators of Simula), there is a suggestion that Simula 67 may have been the first to use this dot notation. Given that Simula is widely credited for being the first OO language, it may be tricky to find an earlier example specifically in an OO context.

EDIT: On DiscreteLizard's suggestion in comments, I took a peek at the use of this dot notation for specifying fields in a record. As it turns out, according to this specification of the PL/I language for the IBM System/360 from July 1965, the dot notation was indeed used to identify fields within structures:

A qualified name takes the form:

identifier {. identifier} ...

Examples: 1. A program may contain the structures:

DECLARE 1 CARDIN, 2 PARTNO, 3 DESCRIPTION, 2 PRICE;

DECLARE 1 CARDOUT, 2 PARTNO, 2 DESCRIPTION, 2 PRICE;

Elements are then referred to as:

CARDIN.PARTNO

CARDOUT.PARTNO

CARDIN.PRICE

  1. Dahl, Ole-Johan. "The Birth of Object Orientation: the Simula Languages." From Object-Orientation to Formal Methods. Springer, Berlin, Heidelberg, 2004. 15-25.
$\endgroup$
  • $\begingroup$ Very interesting! Sadly, it doesn't mention why the . was chosen – maybe that's overly esoteric and it simply was an available character not used in mathematical operations? $\endgroup$ – JeffThompson Mar 8 '18 at 11:50
  • 1
    $\begingroup$ @JeffThompson . is also often used outside OO context to denote fields of a certain data structure. It is possible that this usage predates the OO usage. $\endgroup$ – Discrete lizard Mar 8 '18 at 12:24
  • 1
    $\begingroup$ @DiscreteLizard Perhaps. However, the Dahl paper cites two articles by C.A.R. Hoare in ALGOL Bulletin from 1965 & 1966 ("Record Handling" & "Further Thoughts on Record Handling") that, to my reading, treats the idea of records with field names as novel. Interestingly, Hoare does not use the "obj.field" dot notation in those articles but rather a more functional "field(obj)" notation. $\endgroup$ – mhum Mar 8 '18 at 18:39
  • $\begingroup$ Nice detective work @Discretelizard and @mhum! Any chance you can trace it further? Maybe it's outside this forum's scope, but it would be interesting to know where this syntax originated for data structures? Or is this 1965 article the first place it was mentioned? $\endgroup$ – JeffThompson Mar 9 '18 at 0:33
  • 1
    $\begingroup$ @JeffThompson There may very well be earlier references. However, one issue with going further back is that the languages you encounter earlier might not even have these kinds of data structures (e.g.: I think FORTRAN IV only had numbers, strings, and arrays). $\endgroup$ – mhum Mar 13 '18 at 22:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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