Tuesday, August 6, 2024

Thunk

Thunk (pronounced thunk)

(1) Onomatopoeic slang for sounds such as the impressive thud when the doors close on pre-modern Mercedes-Benz; representing the dull sound of the impact of a heavy object striking another and coming to an immediate standstill, with neither object being broken by the impact.

(2) In computer programming, a delayed computation (known also as a closure routine.

(3) In computing, in the Scheme programming language, a function or procedure taking no arguments.

(4) In computing, a specialized subroutine in operating systems where one software module is used to execute code in another or inject an additional calculation into another subroutine; a mapping of machine data from one system-specific form to another, usually for compatibility reasons, to allow a 16-bit program to run on a 32-bit operating system.

(5) In computing, to execute code by means of a thunk.

(6) As “get thunked” or “go thunk yourself”, an affectionate insult among the nerdiest of programmers.

(7) In colloquial use, a past tense form of think (the standard form being "thought").  Usually it's used humorously but, if erroneous, it's polite not to correct the mistake.

1876: The first documented instance as incorrect English is from 1876 but doubtlessly it had been used before and there’s speculation it may have be a dialectical form in one or more places before dying out.  There being no oral records and with nothing in writing prior to 1876, the history is unknown.  As an echoic of the sound of impact, it’s attested from 1952.  Although occasionally heard in jocular form, except in computing, thunk is non-standard English, used as a past tense or past participle of think.  The mistake is understandable given the existence of drink/drunk, sink/sunk etc so perhaps it’s a shame (like brung from bring) that it’s not a standard form except in computing.  The plural is thunks, the present participle thunking and the simple past and past participle thunked.  The numerical value of thunk in Chaldean Numerology is 4; the value in Pythagorean Numerology is 2.  Thunk & thunking are nouns & verbs, thunker is a noun and thunked is a verb; the noun plural is thunks.  The adjective thunkish is non-standard but is used in engineering and programming circles.

Getting thunked

The origin of the word to describe a number of variations of tricks in programming is contested, the earliest dating from 1961 as onomatopoeic abstractions of computer programming.  One holds a thunk is the (virtual) sound of data hitting the stack (some say hitting the accumulator).  Another suggestion is that it’s the sound of the expression being unfrozen at argument-evaluation time. The most inventive in that it was said to have been coined during an after-midnight programming session when it was realized a type of an argument in Algol 60 could be figured out in advance with a little compile-time thought, simplifying the evaluation machinery.  In other words, it had "already been thought of"; thus it was christened a "thunk", which is “the past tense of ‘think’ at two in the morning when most good programming is done on a diet of Coca-Cola and pizza”.


Door closing on 1967 Mercedes-Benz 230 S.  Until the 1990s, the quality of even the low-end Mercedes-Benz models was outstanding and the doors closed with a satisfying thunk.

Thunking as a programming concept does seem to have been invented in 1961 as “a chunk of code which provides an address”, a way of binding parameters to their formal definitions in procedure calls.  If a procedure is called with an expression in the place of a formal parameter, the compiler generates a thunk which computes the expression and leaves the address of the result in some standard location.  It usefulness was such it was soon generalised into: an expression, frozen with its environment for later evaluation if and when needed (that point being the closure), the process of unfreezing thunks called forcing.  As operating systems evolved into overlay-rich environments, the thunk became a vital stub-routine to load and jump to the correct overlay, Microsoft and IBM both defining the mapping of the 16-bit Intel environment with segment registers and 64K address limits whereas 32 & 64-bit systems had flat addressing and semi-real memory management.  Thunking permits multiple environments to run on the same computer and operating system and to achieve this, there’s the universal thunk, the generic thunk and the flat thunk, the fine distinctions of which only programmers get.  In another example of nerd humor, a person can be said to have their activities scheduled in a thunk-like manner, the idea being they need “frequently to be forced to completion”, especially if the task is boring.

Lindsay Lohan and her lawyer in court, Los Angeles, December 2011.

So it’s a bit nerdy but modern operating systems need thunking because 8, 16, 32 and 64-bit routines can need to run both concurrently and interactively on the same machine (real or virtual).  If a 32-bit application sends something with precision data types to a 64-bit handler, without thunking, the call will fail because the precise address can’t be resolved.  Although not literally true, it’s easiest to visualise thunking as a translation layer.

IBM OS/2 2.0 in shrink-wrap, 1992.

Thunking first entered consumer computing at scale with IBM’s OS/2 in 1987, an operating system still in surprisingly wide use and supported by IBM until early in the century.  Interestingly, although both OS/2 (and its successor eCom) have been unavailable for years, in August 2017, a private project released ArcaOS, an x86 operating system derived from OS/2 and, for personal use, it retails at US$129.00.  Like OS/2, it has some features which are truly unique such as, for the handful of souls on the planet who either need or wish simultaneously to run multiple 8, 16 and 32-bit text-mode sessions, (including those internally booting different operating systems in segregated memory) in their hundreds on the one physical machine.  First done in 1992 on OS/2 2.0, it’s still quite a trick and the on-line OS/2 Museum hosts an active community, development continuing.

No comments:

Post a Comment