« Religious Wars | Main | Generics in Avalon »

January 27, 2004



Even in Smalltalk implementations, where they've had 20+ years to optimize object creation and garbage collection, objects are not "free" but then neither are "structs". Copying references to objects is cheaper than copying the data of a struct (assuming the struct is larger than a 32-bit pointer).

However, it is premature optimization to worry about object creation and deletion without profiling to tell you where the slow spots are. Designing "value" objects that are immutable and "entity" objects that are not duplicated does a lot to insure good performance. (See the book Domain Driven Design by Eric Evans.) In the few situations where you migth have to create and manipulate thousands of objects per second, then you may need to do something with arrays of structs instead of lists of objects.

See http://c2.com/cgi/wiki?FirstRuleOfOptimization and http://c2.com/cgi/wiki?OptimizeLater

Chris Hanson

NeXT dealt with exactly this issue (modulo garbage collection) 15 years ago in NEXTSTEP and 10 years ago in OpenStep. And now Apple's dealing with it again as they enhance Cocoa, a derivative of OpenStep.

Their frameworks have gotten much more class-centric over the years. In 1989 (25MHz 030), the overhead of objects versus structs and raw C strings was pretty high, so NEXTSTEP didn't even have a string class. In 1994 (66+MHz 486), the overhead was much less, so aside from points, rectangles, and ranges, most everything in an OpenStep application is an object including strings. And in Cocoa, the only major new struct I can think of is a transformation matrix (which was handled in Display PostScript by OpenStep).

Of course, Microsoft will have to rediscover all of this because they don't seem to be too observant of the happenings on other platforms.

The comments to this entry are closed.

My name is Wesner Moise. I am a software entrepreneur developing revolutionary AI desktop applications. I worked as a software engineer in Microsoft Excel group for six years during the 1990s. I worked on PivotTables and wrote the most lines of code in Excel 97-- about 10 times the median developer. I have a Harvard BA in applied math/computer science and a UCLA MBA in technology entrepreneurship. I am a member of the Triple Nine Society, a 99.9 percentile high-IQ society.

December 2013

Sun Mon Tue Wed Thu Fri Sat
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31