Timeline for Why didn't == operator string value comparison make it to Java?
Current License: CC BY-SA 3.0
16 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Oct 9, 2022 at 20:45 | comment | added | Thorbjørn Ravn Andersen | There was a LOT of discussions back then about how much memory was wasted by having 16-bit characters with 8-bit values (this has been fixed since). Unicode strings were a novilty then. | |
| Jun 30, 2017 at 10:50 | comment | added | Luna | Using String.intern() is usually not a good idea. See shipilev.net/jvm-anatomy-park/10-string-intern | |
| Mar 14, 2016 at 16:04 | comment | added | 5gon12eder |
I believe you have to intern() both operands of the == in order to be safe.
|
|
| Sep 13, 2013 at 22:36 | comment | added | nanofarad |
Is interning even guaranteed to exist on every implementation of the JVM and Java that follows the pertaining sections of the JLS? And regarding the new string in switch feature, how is that least-astonishment? It seems like a special case that can't use a straight-up equals() or == either way.
|
|
| Apr 3, 2013 at 19:50 | comment | added | WarrenT | @Joonas If you went back to 1962, let's say, and asked a COBOL programmer about how much he wanted the "luxury" of garbage collecting or this dream you have of this crazy character set you call "Unicode", he'd probably say "What the heck do I want that for?" If they don't apply to the environment you work in, nobody cares. In that case, it would become an annoyance. | |
| Apr 3, 2013 at 19:10 | comment | added | Donal Fellows | Interning has a cost: you get a string that will never ever be deallocated. (Well, not unless you use your own interning engine that you can throw away.) | |
| Apr 3, 2013 at 18:45 | comment | added | svick | @JoonasPulakka Then maybe you should edit your answer to say that. Because as it stands, the “total luxury” part of your answer is quite wrong. | |
| Apr 3, 2013 at 12:05 | history | edited | Joonas Pulakka | CC BY-SA 3.0 |
added 275 characters in body
|
| Apr 3, 2013 at 9:27 | vote | accept | TtT23 | ||
| Apr 3, 2013 at 6:14 | comment | added | Joonas Pulakka | @WarrenT: Sure, some (if not most) languages had some type of string, but Unicode-capable, garbage-collected strings were a novelty in 1995, I think. For example, Python introduced Unicode strings with version 2.0, year 2000. Choosing immutability was also a controversial choice at that time. | |
| Apr 3, 2013 at 0:27 | comment | added | WarrenT | Strings were a luxury in 1995? Really?? Look at the history of computer languages. The number of languages that had some type of string at the time would far outnumber those that did not. How many languages besides C and it's descendents used null terminated arrays? | |
| Apr 2, 2013 at 21:13 | comment | added | Blrfl | Special cases add astonishment. | |
| Apr 2, 2013 at 12:01 | history | edited | Joonas Pulakka | CC BY-SA 3.0 |
added 277 characters in body
|
| Apr 2, 2013 at 11:18 | history | edited | Joonas Pulakka | CC BY-SA 3.0 |
added 39 characters in body
|
| Apr 2, 2013 at 11:03 | history | edited | Joonas Pulakka | CC BY-SA 3.0 |
added 288 characters in body
|
| Apr 2, 2013 at 10:53 | history | answered | Joonas Pulakka | CC BY-SA 3.0 |