13

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.

5
  • 1
    The Algol68 formatter statement is similar to the Fortran one: just that the write was reworded as printf.
    – cup
    May 2, 2019 at 14:30
  • 6
    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? May 2, 2019 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. May 2, 2019 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, 2019 at 9:08
  • 2
    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. May 3, 2019 at 11:47

2 Answers 2

20

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).

5
  • 3
    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, 2019 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! Nov 23, 2019 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, 2019 at 0:14
  • Rumor has it C had printf in 1972. Feb 8, 2020 at 21:02
  • @NevilleDNZ: Drum printers would sometimes fail to do a good job of printing the tops or bottoms of characters cleanly, so ELSE and ELSF could both look like FLSF, but I think a bigger issue would have been with distinguishing the keywords in handwritten text or spoken forms. Replacing "S" with "I" would improve the clarity of both.
    – supercat
    Aug 17, 2021 at 16:18
2

The Unix 1st manual pages (1971) don't mention printf(3), it appears in Unix 6st manual pages (1975). The so-called standard C library was developed after the language proper.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .