4 ms·
I suppose that depends upon where you’re coming from. Many, many languages have an sprintf-style construct of one form or another, so I think it’s actually much
by chrismeller 8y ago
I suppose that depends upon where you’re coming from. Many, many languages have an sprintf-style construct of one form or another, so I think it’s actually much more familiar to most people to have a placeholder with an optional formatter. To each their own, though.
- deleted 8y ago[deleted]
- nicoburns 8y ago> Many, many languages have an sprintf-style construct of one form or another, so I think it’s actually much more familiar to most people to have a placeholder with an optional formatter Many languages also have format strings with interpolation: JavaScript, Python, Ruby, Swift, PHP, etc.
- maxxxxx 8y agoSprintf is very error prone. Maybe people are used to it but string interpolation is clearly superior because it removes a lot of potential errors. With the trend towards safer languages sprintf and similar techniques need to go away.
- oblio 8y agoWell, let's take the TIOBE index as a rough indicator of popularity: https://www.tiobe.com/tiobe-index/ https://www.tiobe.com/tiobe-index/ Java, C/C++/Objective-C/Go (I'm lumping them up because they're basically C + C NextGens), Matlab, SQL, ASM don't have them. Everything else, has them. On the list of languages that don't have it, Java is planning to add it, I don't see the C family to change because it's very conservative, and the others are domain specific and don't care that much about string operations.
- mattnewport 8y agoC++ has string streams which actually work more like string interpolation than like sprintf just without adding custom syntax.
- EpicEng 8y agoI have a hard time believing any programmer with more than a couple of months experience would have a moment of difficult figuring out what an interpolated string is doing.