Live data from Hacker News

Raw String Literals Removed From Java 12 as Feature Set Frozen

infoq.com

21–30 of 60 posts

Re: Raw String Literals Removed From Java 12 as Feature Set Frozen

#21
Since Java 12 isn’t an LTS, isn’t the effective delay for slipping a release just 6 months? Many shops are going to use 8, 11 and 17 (assuming it’s the next LTS), so it won’t even matter to them.

If that’s right, it’s exactly how the new release cadence is supposed to work—there’s no longer such a hard decision between delaying the release, leaving a feature to languish for several years, or releasing a feature without time to validate it.

Re: Raw String Literals Removed From Java 12 as Feature Set Frozen

#23
post #5

Java Unicode escapes are kind of a mess, and the raw string literals proposal only makes it worse. Unicode escapes are processed in Java not just inside string literals, but everywhere in the source code. So, for example, the following program prints "Hello, world!" even though that line of code seems to be commented (\u000a is new line, so it ends the comment): public class Test { public static void main(String[] ar…

Wow, that is similar to the C++ trigraphs, where using ?? followed by various characters inside a string literal (and any other place) does not work as expected

But those in C++ are deprecated, yay!

Re: Raw String Literals Removed From Java 12 as Feature Set Frozen

#24
post #19
post #5

Java Unicode escapes are kind of a mess, and the raw string literals proposal only makes it worse. Unicode escapes are processed in Java not just inside string literals, but everywhere in the source code. So, for example, the following program prints "Hello, world!" even though that line of code seems to be commented (\u000a is new line, so it ends the comment): public class Test { public static void main(String[] ar…

What is the reason for Unicode escapes? It is something legacy from when Unicode was not universally accepted in all systems? Do other programming languages have this?

Several programming languages have arcane ways to write what today seem like very normal characters.

https://en.wikipedia.org/wiki/Digraphs_and_trigraphs

For example C has escape sequences for characters as basic as # and [.

Re: Raw String Literals Removed From Java 12 as Feature Set Frozen

#25
post #15

Adding new syntax to Java is tricky (unless certain other JVM languages starting with C ;) but I was really disappointed in the string proposal. At the very least, have a default, optional string substitution feature. It ain't that hard and it's something users of raw strings will NEED anyways. What good is it to have snippets of raw strings that then need to be parsed again and split and re-glued again? JavaScript b…

> unless certain other JVM languages starting with C

Are you referring to Clojure or Ceylon? Or both, or neither?

Re: Raw String Literals Removed From Java 12 as Feature Set Frozen

#26
post #8

Earlier quoted context omitted.

I don't think I've ever wanted SQL embedded in my Java source over loading it as a resource. Loading it as a resource allows me to edit the SQL in a sql-aware text editor.

IntelliJ is aware of SQL in text strings, and even validates it against the database schema. I like my SQL right next to the code that sets parameters, processes results, etc - mismatches are apparent (and also validated by IntelliJ).

Intellij also automatically escapes your string and inputs newlines wherever necessary, so if you copy a long string, it's generally done for you (I've copied pieces of XML and it generally worked totally fine).

Re: Raw String Literals Removed From Java 12 as Feature Set Frozen

#27

Can someone explain to me why java has never considered as "import com.package.foo.bar as bar" feature? I really think fully qualified names can be disgusting when you have two classes of the same name.

What do you mean? You can do both:

- import com.package.foo.Bar -> use Bar.methodOfBar() in code

- import static com.package.foo.Bar -> use methodOfBar() in code

What does "import com.package.foo.bar as bar" add? Other than some kind of aliasing, as in you import Bar, but alias it as Baz, so then you use Baz.methodOfBar() ..?

Re: Raw String Literals Removed From Java 12 as Feature Set Frozen

#28

Can someone explain to me why java has never considered as "import com.package.foo.bar as bar" feature? I really think fully qualified names can be disgusting when you have two classes of the same name.

I assume it is because Java developers rely very heavily on their IDEs. Most of these IDEs simply hide the import statements by default. So you assume the imports are irrelevant, unless explicitly spelled out - and clashes are rare enough to not be much of a problem in practice. If imports are renamed, you would have to actually care about the import statements.

Re: Raw String Literals Removed From Java 12 as Feature Set Frozen

#29

Can someone explain to me why java has never considered as "import com.package.foo.bar as bar" feature? I really think fully qualified names can be disgusting when you have two classes of the same name.

What do you mean? You can do both: - import com.package.foo.Bar -> use Bar.methodOfBar() in code - import static com.package.foo.Bar -> use methodOfBar() in code What does "import com.package.foo.bar as bar" add? Other than some kind of aliasing, as in you import Bar, but alias it as Baz, so then you use Baz.methodOfBar() ..?

I think he's saying:

    import java.util as jvutil;
    import com.betterlist as better;

    class Example {
      jvutil.List list = new better.List();
    }
Post reply on HN