3 ms·
I'm a bit confused about all the doubt on such a common feature industry wide. No, it's not magic, it's a simple transformation, takes about 30 seconds to learn
by mixmastamyk 11y ago
I'm a bit confused about all the doubt on such a common feature industry wide. No, it's not magic, it's a simple transformation, takes about 30 seconds to learn, and is becoming an industry standard among modern languages. See C#, Scala, JS, Swift, etc, not to mention bash and perl.
It also has little in common with i18n, the use cases differ too much. Perhaps in the future someone can figure out how to bring them together, but not today.
- schmichael 11y agoAll of the languages you list have been criticized for adding too many language features. Go and Rust are two notable new languages which require explicit formatting functions as opposed to relying on special string interpolation syntax.
- mixmastamyk 11y agoInterpolation is one of the features I require in a rapid prototyping language, it is useful every single day and not esoteric.
- pcwalton 11y agoWell, Rust formatting is magical, unlike that of Go: it has to be because it has type-safe format strings, which can't be expressed in the normal language. But the magic is encapsulated into a macro, so the complexity doesn't leak into the language per se. Someone could write a similar string interpolation macro and replicate Python's feature without modifying the compiler if they wanted--though the fact that nobody has so far indicates to me that it probably isn't needed, as the {} syntax is awfully lightweight already.
- schmichael 11y agoPython was and still is to some diminishing degree influenced by C, C++, and Java - none of which have language syntax for interpolating strings based on variables in scope.
- mixmastamyk 11y agoYes, though it has more in common with Perl and Ruby, which do.
- icebraining 11y agoI wouldn't say it was influenced by Java, seeing as all the core syntax (functions, classes, modules, etc) was already present when Java was first released publicly. The stuff added later doesn't come from it either (list comprehensions, generators, etc).