My "sense " is its high (~70 - 80% ) but it depends on the style of the program and adding immutable concepts to the langauge will increase this further. Most of these are lib/ standard lib not user Types eg string / CADR lists / read only collections etc. mutable strings would drop this ratio a lot but its more standard lib than language design and the standard lib style will flow to other libs . If there was a benefit i would use readonly collections more right now its just convenient to use mutable collections because you may change the collection eg on LINQ i use getArray getList even on readonly contexts .
The fact that Java and the CLR has special ( but diff.) treatment for just strings in heap becuase they are 1) Immutable 2) Do not contain a reference so no need to mark them Suggests there is advantage in treating such objects diffirently . Also consider objects that are readonly for most of their life but are only changed in 1 function , though much more difficult to optomize ( may be impoosible) as this would be extremely high. Ben On Thu, Oct 17, 2013 at 4:35 AM, Jonathan S. Shapiro <[email protected]>wrote: > What percentage of objects in Java and C# could be characterized as "init > only"? What I mean is: objects that are not mutated after construction? > > These form a very useful category for object relocation algorithms, and > I'm wondering whether they are a large enough pool, demographically, to be > worth looking to for optimizations. > > Does anybody have a sense of the ratio? And if it is small, is this a > consequence of idiom and practice, or is it somehow a structural > consequence of the language designs? > > > Jonathan > > _______________________________________________ > bitc-dev mailing list > [email protected] > http://www.coyotos.org/mailman/listinfo/bitc-dev > >
_______________________________________________ bitc-dev mailing list [email protected] http://www.coyotos.org/mailman/listinfo/bitc-dev
