top | item 43874847

(no title)

niuzeta | 10 months ago

I love hearing more about this, especially the historical context, but don't have a good java writeups/articles on this. Would you mind sharing some suggestions/pointers? I'd very much appreciate it.

discuss

order

stevoski|10 months ago

A good starting point is Joshua Bloch’s Effective Java. He shares some stories there from Java’s early days, and - at least in passing - mentions some aspects of the String class’s history.

niuzeta|10 months ago

Ah, I certainly remember these anecdotes! What other resources would you recommend(even the tidbits) could there be for more modern Java? The original article like this one should be treasured.

wging|10 months ago

String compression was one. tl;dr: the JVM supports Unicode for strings, but uses 1-byte chars for strings where possible (previously it was UTF-16), even though it's not actually doing UTF-8.

Depending on what sort of document you're looking for, you might like either the JEP: https://openjdk.org/jeps/254

or Shipilev's slides (pdf warning): https://shipilev.net/talks/jfokus-Feb2016-lord-of-the-string...

Shipilev's website (https://shipilev.net/#lord-of-the-strings), and links from the JEP above to other JEPS, are both good places to find further reading.

(I think I saw a feature article about the implementation of the string compression feature, but I'm not sure who wrote it or where it was, or if I'm thinking about something else. Actually I think it might've been https://shipilev.net/blog/2015/black-magic-method-dispatch/, despite the title.)

niuzeta|10 months ago

Absolutely love it. Thanks a lot. A fancy hit me yesterday and I've been looking through JDK's String commit history to see little tidbits that I could grab.

Shipilev's website looks like a fascinating resource. I appreciate the pointer!

DaiPlusPlus|10 months ago

> Would you mind sharing some suggestions/pointers?

I would, but unfortunately I got a NullPointerException.

I suggest you try Rust instead; its borrow checker will ensure you can't share pointers in an unsafe manner.

gf000|10 months ago

I know it's a tongue in cheek reply but..

You can't share "pointers" in an unsafe manner in Java. Even data races are completely memory safe.