Skip navigation.
 
mlRe: Garbage collection - was Beginner with Cocoa
FROM : Erik Buck
DATE : Mon Mar 24 17:12:36 2008

> In Ruby GC just works dandy without thought. Why is it so different in
> Cocoa Obj2.0?
> What kinda of real headaches will I have jumping into osx programing
> compared to ruby ?


The short answer is that Ruby is a nifty high level scripting language 
that insulates the programmer thoroughly from pointers and memory 
management.  In contrast, C is a low level "systems" programming 
language that relies on pointers.  Many things you might want to 
program require the low level capabilities of C.  For example, I bet 
the Ruby garbage collector is written in C.  Operating systems, device 
drivers, high performance graphics, etc. all use close to the hardware 
features provided by C but absent from Java, Ruby, Python, C#, etc.

Objective-C is a combination of the original object oriented language, 
Smalltalk, and C.  The Smalltalk heritage is what makes Objective-C/
Cocoa programming so powerful and flexible.  The C heritage is what 
makes Objective-C/Cocoa so versatile and able to seamlessly integrate 
with the billions of lines of C code in the world.

With C comes pointers.  With the availability of arbitrary pointers 
and pointer arithmetic, it is basically impossible to provide 
ubiquitous automatic garbage collection.  Therefore, Objective-C will 
always be saddled with edge cases where garbage collection will be 
messy or at least not automatic.  Furthermore, there are lots of 
applications in which Objective-C can be used but automatic garbage 
collection can not.  For example, memory and resources that are not 
allocated from the heap, such as shared memory, VRAM, distributed 
objects, etc. can not be automatically collected.

Ruby solves the "what to do with uncollectible resources" problem by 
just not letting you access them.  You won't see a high performance 3D 
game engine written in Ruby any time soon!  You will see Ruby 
libraries built to use a 3D engine written in C or Objective-C.

Related mailsAuthorDate
mlBeginner with Cocoa Alex Handley Mar 21, 20:00
mlRe: Beginner with Cocoa Jeff LaMarche Mar 21, 20:21
mlRe: Beginner with Cocoa Jack Repenning Mar 24, 05:16
mlRe: Beginner with Cocoa Sherm Pendley Mar 24, 05:44
mlRe: Beginner with Cocoa Jeff LaMarche Mar 24, 13:12
mlRe: Beginner with Cocoa Erik Buck Mar 24, 15:13
mlRe: Beginner with Cocoa Scott Thompson Mar 24, 15:32
mlGarbage collection - was Beginner with Cocoa Bill Cheeseman Mar 24, 15:57
mlRe: Garbage collection - was Beginner with Cocoa colo Mar 24, 16:30
mlRe: Garbage collection - was Beginner with Cocoa Bill Cheeseman Mar 24, 17:12
mlRe: Garbage collection - was Beginner with Cocoa Erik Buck Mar 24, 17:12
mlRe: Garbage collection - was Beginner with Cocoa Clark Cox Mar 24, 17:45
mlRe: Beginner with Cocoa Jack Repenning Mar 24, 18:01
mlRe: Garbage collection - was Beginner with Cocoa colo Mar 24, 18:02
mlRe: Garbage collection - was Beginner with Cocoa Scott Thompson Mar 24, 18:36
mlRe: Beginner with Cocoa colo Mar 24, 18:43
mlRe: Garbage collection - was Beginner with Cocoa Bill Cheeseman Mar 24, 18:45
mlRe: Beginner with Cocoa Jeff LaMarche Mar 24, 18:54
mlRe: Beginner with Cocoa Sherm Pendley Mar 24, 18:57
mlRe: Beginner with Cocoa Chris Hanson Mar 24, 19:39
mlRe: Beginner with Cocoa Clark Cox Mar 24, 19:44
mlRe: Garbage collection - was Beginner with Cocoa colo Mar 24, 21:03
mlRe: Garbage collection - was Beginner with Cocoa has Mar 24, 22:59
mlRe: Garbage collection - was Beginner with Cocoa Scott Thompson Mar 25, 03:15
mlRe: Beginner with Cocoa Scott Ribe Mar 25, 21:57
mlRe: Garbage collection - was Beginner with Cocoa Scott Ribe Mar 25, 22:06
mlRe: Beginner with Cocoa Bill Cheeseman Mar 25, 22:40
mlRe: Garbage collection - was Beginner with Cocoa Jack Repenning Mar 25, 23:01
mlRe: Garbage collection - was Beginner with Cocoa Nick Zitzmann Mar 25, 23:07
mlRe: Garbage collection - was Beginner with Cocoa Paul Bruneau Mar 25, 23:11
mlRe: Garbage collection - was Beginner with Cocoa Randall Meadows Mar 25, 23:15
mlRe: Garbage collection - was Beginner with Cocoa Rob Napier Mar 26, 00:02
mlRe: Garbage collection - was Beginner with Cocoa Jack Repenning Mar 26, 00:28
mlRe: Garbage collection - was Beginner with Cocoa colo Mar 26, 00:52
mlRe: Garbage collection - was Beginner with Cocoa Erik Buck Mar 26, 01:38
mlRe: Garbage collection - was Beginner with Cocoa mmalc crawford Mar 26, 06:24