On 2012-10-09 00:44, Ben Davis wrote:

In fairness to Java, it does share the inner char array between strings
when you request a substring. (Inside the String class you'll find a
reference to a char array, and 'start' and 'count' ints.) The String
object itself though (which is small and wraps the char array reference)
is allocated new each time. Java's GC is rather good though, so it
totally gets away with it.

The Java GC is far superior than the one in D. But in D it's possible to write a parser that doesn't allocate during processing, it just need some pre-allocation before starting. This is all due to the array slicing, which I think is pretty cool. The XML parser in Tango is an example of this:

http://dotnot.org/blog/archives/2008/02/24/xml-benchmarks-tango-ups-the-ante/

http://dotnot.org/blog/archives/2008/03/12/why-is-dtango-so-fast-at-parsing-xml/

https://github.com/SiegeLord/Tango-D2

http://www.dsource.org/projects/tango/docs/current/tango.text.xml.PullParser.html

--
/Jacob Carlborg

Reply via email to