Re: Java moves to copying for substrings

2013-11-19 Thread Jonathan M Davis
On Tuesday, November 19, 2013 13:54:37 Walter Bright wrote: > D doesn't need to change its approach at all because it offers both options > - the user can choose. Good point. While I wouldn't say that D's string handling is perfect, it's by far the best that I've ever dealt with, and I think tha

Re: Java moves to copying for substrings

2013-11-19 Thread Walter Bright
On 11/19/2013 2:37 AM, Jonathan M Davis wrote: So, it's something to keep in mind, but I defintely don't think that we should be changing our approach at all. D doesn't need to change its approach at all because it offers both options - the user can choose. Note that the article says that so

Re: Java moves to copying for substrings

2013-11-19 Thread Walter Bright
On 11/18/2013 11:36 PM, monarch_dodra wrote: On Tuesday, 19 November 2013 at 05:38:14 UTC, Jesse Phillips wrote: So apparently substrings were considered a common cause of memory leaks. I think it is pretty important to remember that slicing, while giving you a small view, still holds the enti

Re: Java moves to copying for substrings

2013-11-19 Thread Brian Schott
On Tuesday, 19 November 2013 at 10:38:06 UTC, Jonathan M Davis wrote: It _is_ true however that if you're not careful about it, you can end up with a lot of slices that keep whole blocks of memory from being collected when they don't really need to refer to that memory anymore. So, depending on

Re: Java moves to copying for substrings

2013-11-19 Thread Jonathan M Davis
On Tuesday, November 19, 2013 06:38:12 Jesse Phillips wrote: > Somewhat interesting, Java has chosen to make substring result in > a copy of the string data rather than returning a window of the > underlying chars. > > http://www.reddit.com/r/programming/comments/1qw73v/til_oracle_changed_the_i >

Re: Java moves to copying for substrings

2013-11-19 Thread bearophile
Jesse Phillips: Somewhat interesting, Java has chosen to make substring result in a copy of the string data rather than returning a window of the underlying chars. I presume in Java slices weren't very common, unlike in D. So I think this is the right design choice for Java (also because th

Re: Java moves to copying for substrings

2013-11-19 Thread bearophile
I presume in Java slices weren't very common, Please ignore this part. Some answers of that Reddit thread show that some people slice a lot in Java too :-) Bye, bearophile

Re: Java moves to copying for substrings

2013-11-19 Thread deadalnix
On Tuesday, 19 November 2013 at 07:36:29 UTC, monarch_dodra wrote: On Tuesday, 19 November 2013 at 05:38:14 UTC, Jesse Phillips wrote: So apparently substrings were considered a common cause of memory leaks. I think it is pretty important to remember that slicing, while giving you a small view

Re: Java moves to copying for substrings

2013-11-18 Thread monarch_dodra
On Tuesday, 19 November 2013 at 05:38:14 UTC, Jesse Phillips wrote: So apparently substrings were considered a common cause of memory leaks. I think it is pretty important to remember that slicing, while giving you a small view, still holds the entire array. I think there is nothing wrong with

Java moves to copying for substrings

2013-11-18 Thread Jesse Phillips
Somewhat interesting, Java has chosen to make substring result in a copy of the string data rather than returning a window of the underlying chars. http://www.reddit.com/r/programming/comments/1qw73v/til_oracle_changed_the_internal_string/ "reduce the size of String instances. [...] This was t