3487

The origin of sprintf-style string formatting

Question:

The string formatting concept found in <strong>sprintf</strong> can be found in almost any language today <em>(you know, smothering a string with %s %d %f etc. and providing a list of variables to fill their places)</em>.

<strong>Which langugage was it originally that had a library function or language construct which offered this functionality?</strong>

Please specify some kind of source reference to confirm your claim, so that we avoid pure speculation or guessing.

Regards

Robert

Answer1:

<a href="http://en.wikipedia.org/wiki/Printf" rel="nofollow">Wikipedia has a pretty thorough history.</a> It suggests that the C printf function had its origins in BCPL's writef function.

Answer2:

I would say all of them trace their roots back to BCPL. We used BCPL to do operating systems programming for the 6809 processor two decades ago and it had a writef() function which took arguments such as %i2 (equivalent to C's %2d).

C was based on a cut-down version of BCPL and inherited a similar mechanism for formatting output and I'm pretty certain all other instances picked it up from C after that.

I could be wrong, it won't be the first or last time, but I'm pretty confident that's right, given what I know about the BCPL language and its origins.

Recommend

  • Data not aligned correctly in Visual Studio if run in debugger
  • Set a breakpoint inside a library jar in IntelliJ
  • arithmetic operations in query builder laravel
  • markup text parser like stackoverflow's formatter in Objective-C
  • Do newly created conda envs inherit all packages from the base env?
  • Restricting the generic type parameter to System.Enum
  • Docker containers restart fails
  • Send/Receive Intents in the same class
  • How to change Language in android WebView
  • Comparing a large set of images by content
  • How can I return more than one value from a method in C#
  • Speed up Date#parse & Date#strptime in Ruby, more elegant way or best practice?
  • Create a mobile app that just points to URL
  • Bash script to bring up and down an interface on loop
  • Java: How to refer to subclass's static variable in abstract class?
  • Using Facebook Graph API with ASP.NET
  • Find string between two substrings AND between string and the end of file
  • Redmine can't generate secret token
  • Get an image from the video
  • Azure NodeJS Error: ENOENT, open 'D:\\home\\site\\wwwroot\\bin\\views\\'
  • Use 2D Text into 3D scenes in JavaFX results in blurry texts
  • Remove stopwords and tolower function slow on a Corpus in R
  • How to search for a method or variable name within android project?
  • Why am I getting an Argument exception when creating event handler dynamically?
  • MayAVI install on Python 3.6 [duplicate]
  • Create .java file and compile it to a .class file at runtime
  • Getting Microsoft Calibri font on Amazon EC2 ubuntu
  • How to make Rss News Reader application in android …? [closed]
  • SQL Server 2012 not showing unicode character in results
  • Tensorflow Dataset API restore Iterator after completing one epoch
  • how do i compare two rows and store the similarities of the two rows in another column
  • Change cell value based on cell color in google spreadsheet
  • Spring Boot fails to start
  • Firebase: How to read from external DB?
  • WPF custom control and direct content support
  • Create/delete users from text file using Bash script
  • Time Complexity of Fibonacci Algorithm [duplicate]
  • How to check if object is null in Java?