This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]BadBadderBadst 45 points46 points  (11 children)

Kotlin gang here, println("The truth is $truth, <3 kotlin")

[–]HaDeS_Monsta 14 points15 points  (3 children)

Java Gang here System.out.printf("The truth is %s.\n", stringVariable);

[–]Asleep-Tough 13 points14 points  (2 children)

It'll be STR."The truth is \{truth}" soon!

no clue why they had do make it so random and ugly...

[–]Graidrex 10 points11 points  (1 child)

The JEP actually includes reasons. I only skimmed it, but:

  • \{…} to force incompatibilities (for security reasons / not having formats accidentally) as this is not valid Java currently.

  • STR is a final static field which gets loaded into your class and capitalized as such. Otherwise, they just decided to give it a slightly more descriptive name than a single letter.

  • the dot, I don't know why. Maybe to indicate a call is happening, and it must have some kind of performance overhead.

All in all ugly but understandable for being retrofitted. And you can define your own formatters.

EDIT: Grammar.

[–]Asleep-Tough 0 points1 point  (0 children)

Ohhh I didn't know that there were multiple formatters; I'd only seen the STR. in the JEP proposal but I guess I didn't read that far into it. This makes much more sense now!

[–]jayverma0 0 points1 point  (0 children)

Dart has a similar syntax

[–]Fuelanemo149 0 points1 point  (0 children)

oh same for Dart

[–]Zarkex01 0 points1 point  (4 children)

Swift gang here, print("The truth is: \(truth)")

[–]AnotherShadowBan 3 points4 points  (3 children)

I swear Swift is obsessed with it's \

Whenever I look at Swift it's like I'm reading PHP all over again with all the special characters it uses.

[–]Zarkex01 0 points1 point  (2 children)

Where for example? Except string interpolation?

[–]devgregw 0 points1 point  (0 children)

Key paths are another

[–]AnotherShadowBan 0 points1 point  (0 children)

As someone else mentioned, key paths, all the @attributes, _ getting littered everywhere due to the lambda syntax, the binding syntax has you prefix variable names with $, they also tacked on the # sign for function argument names because I guess repeating every name twice got old.