2

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. FWIW, 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 at 14:30
  • 2
    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 at 21:58
  • 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 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 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 at 11:47
10

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

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.