Hacker News new | ask | show | jobs
by adrian_b 19 days ago
The first use in computing of the word "heap", which refers to a data structure used for priority queues or for sorting, i.e. a kind of binary tree, was in an article published in June 1964, about the algorithm "Heapsort" (by John William Joseph Williams).

The second use in computing of the word "heap", which has no relationship whatsoever with the other meaning, occurred first in the report about the programming language ALGOL 68, which was published in December 1968 by Adriaan van Wijngaarden et al.

In ALGOL 68, "heap" is used as a keyword, to indicate that a new variable must be allocated in the heap, instead of being allocated in the stack, which is the default.

So "heap" in the second sense, which is used by you and traditionally in UNIX, was coined to oppose "stack", as not being constrained by a LIFO allocate/free policy.

The word stack had been popularized by another Dutch, Edsger W. Dijkstra, in May 1960, who explained how to use a stack and a stack pointer for implementing the blocks of ALGOL 60. So both "stack" and "heap", in the senses related to memory management, come from Dutch computer scientists, and they have been used first in connection with the languages ALGOL 60 and, respectively, ALGOL 68.

Before ALGOL 68, the language IBM PL/I had used since December 1964 the terms "automatic storage" instead of "stack" (the source of the C keyword "auto") and "controlled storage" instead of "heap".

John McCarthy published the description of the garbage collector used by LISP in April 1960, but he did not use any special word for the heap, because in LISP that was the only kind of memory used for data, so unlike in PL/I or ALGOL 68 there was no need to distinguish it from memory areas that were managed in a different way.