10

I'm curious as to which language was the first to literally have a formatted text output procedure called 'printf'. A trivial question, sure, but I was prompted to ask by a recent question on ZSPL.

I'll accept a language statement in lieu of a procedure/function/subroutine, but it has to be spelled 'printf' (or variants involving upper case, bold, or underlined letters). Other formatted I/O, such as FORTRAN's FORMAT facilities, don't count.

I think the answer is Algol68, but that might just be historical ignorance on my part. For what its worth, Algol68 treated a format not as a string but as a unique datatype with its own denotation.

Similar but not quite 'printf' arrangements could also be interesting, even if not the specific answer I'm asking for.

  • 1
    The Algol68 formatter statement is similar to the Fortran one: just that the write was reworded as printf. – cup May 2 '19 at 14:30
  • 4
    Are you just interested in functions with the spelling of printf, or are you interested in the % style formatting specifiers as used in the C printf function? – Greg Hewgill May 2 '19 at 21:58
  • 1
    My intent was functions spelled 'printf' - it's become almost the automatic choice for naming this sort of thing, so I wondered where it started. But if you've got other functions with the C-style format specifiers, that might be interesting too. – another-dave May 2 '19 at 23:37
  • @another-dave "it's become almost the ..." sure, but that's just because it's today usually the first of such functions learners encounter, thus not anything relevant. Formated print itself even predates (most) HLL. Classic machines do provide according CPU instructions. For example like ED (Edit) and EDMK (Edit Marked) on a /370, instructions essential to format ledger printouts. – Raffzahn May 3 '19 at 9:08
  • 1
    Agreed; I'm not thinking this is a deep question. It's similar in intent to the recent question asking why ASCII control characters are written as caret,letter -- someone set a precedent which is now followed faute de mieux, and I'm curious as to how it started. – another-dave May 3 '19 at 11:47
18

Having poked around, I feel ready to answer my own question.

The first language to have an actual formatted-print function literally named printf was Algol 68, per the 1973 Revised Report (the original Report in 1968 used outf).

The format specification for Algol 68 owed IMO something to FORTRAN usage; elements were format directives unless they were specifically identified as literal strings - the inverse of C usage, if you see what I mean. For example, FORMAT f = $ "the number is " 3d $ (Dollar signs enclose a FORMAT denotation).

An honorary mention goes to BCPL, which had a writef or writes procedure (sources vary in their opinion, and the BCPL Reference Manual describes only the language, not any library), using a standard string for the format, rather than a specialized datatype (Algol [68) or statement type (FORTRAN).

  • Wikipedia: "C was originally developed at Bell Labs by Dennis Ritchie between 1972 and 1973 to make utilities running on Unix." So C's printf may predate Algol68's printf 1974 revision. The source of truth might be found by searching in the Algol Bulletins at ACM... Good luck. ¢ It would be wonderfully weird if C managed to "influence" Algol68. ¢ – NevilleDNZ Nov 23 '19 at 12:30
  • 1
    AB36 on page 15 summarizes the change that introduced printf. The out function turned into put (to avoid confusion with the basic symbol out), outf became putf, and printf was the version specific to putf on stand out. This doesn't answer the matter of whether there was C influence of course! – another-dave Nov 23 '19 at 23:50
  • IIRC: For similar reasons ... from algol68 the ELSF rev0 got replaced with ELIF rev1 ... to avoid confusion with ELSE ¢ The line printers of the day were not so good as font detail :-) ¢ ... I'm not sure if this also means that algol68 "invented" ELIF. It would be novel (but a long shot) to ponder if our putf actually originated in algol68. Here are a few more "new" tid-bits of python/algol68 Déjà vu ... printf($n(width_val)d$,int_val) and := for assignment! – NevilleDNZ Dec 9 '19 at 0:14

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.