6 ms·
Regarding the printf (pre)history see my old comment: https://news.ycombinator.com/item?id=3964475 https://news.ycombinator.com/item?id=3964475 printf is base
by acqq 11y ago
Regarding the printf (pre)history see my old comment:
https://news.ycombinator.com/item?id=3964475 https://news.ycombinator.com/item?id=3964475
printf is based on the idea implemented as early as 1956, next year it will be 60 years since!
1956: Fortran I:
PRINT 1, X
1 FORMAT (F10.2)
Fortran was invented by John Backus and there was already a finished compiler in 1956.
I/O in the first Fortran, I believe including the FN.M syntax, was implemented by Roy Nutt, also one obvious genius:
http://www.cap-lore.com/stories/Assembler.html http://www.cap-lore.com/stories/Assembler.html
"There were a few pages of description of a new assembler format for the IBM 704 that differed considerably from the NYAP that we were using." (That) "704 assembler, originally called SAP, was written in its own language by Roy Nutt."
- muaddirac 11y agoThat's very interesting, but other than in name not related to the article. If you didn't read it I would recommend you do - it's possibly one of the most interesting and reflective things I've ever read about programming as a profession.
- acqq 11y agoConsider it an addition to the type of the programmer: the one who stays by the original meanings of the names. Who still links to the Fortran libraries, writes mostly C and fondly remembers APL.
- vardump 11y agoShame that we're just nearing precompiled xprintf statements. It's so wasteful and slow to keep scanning same string for printing instructions at runtime. And very bug prone.
- mrottenkolber 11y agoCommon Lisp had precompiled printing/formatting for ever: FORMAT. E.g. FORMAT is a macro.
- capisce 11y agoAnd Idris even enables a type-safe version: https://www.youtube.com/watch?v=fVBck2Zngjo https://www.youtube.com/watch?v=fVBck2Zngjo So if you mismatch the types you'll get a compile time error instead of a run time error.
- nickpsecurity 11y agoThat's pretty cool. Looking for the text version of it led me to another one more accessible to average programmer: http://www.codeproject.com/Articles/159910/Extremely-Efficient-Type-safe-printf-Library http://www.codeproject.com/Articles/159910/Extremely-Efficie...
- deleted 11y ago[deleted]
- tmzt 11y agoF# also supports a typesafe printf format notation. http://fsharpforfunandprofit.com/posts/printf/ http://fsharpforfunandprofit.com/posts/printf/
- reikonomusha 11y agoTo be clear, FORMAT is a function possibly with an associated compiler macro to expand constant format strings into more efficient code inline.