3 ms·
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
by niuzeta 1y 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.
- stevoski 1y agoA 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 1y agoAh, 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.
- DaiPlusPlus 1y 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.
- wging 1y agoString 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 https://openjdk.org/jeps/254 or Shipilev's slides (pdf warning): https://shipilev.net/talks/jfokus-Feb2016-lord-of-the-strings.pdf https://shipilev.net/talks/jfokus-Feb2016-lord-of-the-string... Shipilev's website (https://shipilev.net/#lord-of-the-strings 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/ https://shipilev.net/blog/2015/black-magic-method-dispatch/, despite the title.)
- niuzeta 1y agoAbsolutely 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!
- cempaka 1y agoThis is a good video that goes over a ton of the optimizations, especially around concatenation: https://youtu.be/z3yu1kjtcok?si=mOdZ5sh5rp8LNyap https://youtu.be/z3yu1kjtcok?si=mOdZ5sh5rp8LNyap
- niuzeta 1y agoI appreciate it! I will take a look this weekend,