Re: Garbage collection - was Beginner with Cocoa
Re: Garbage collection - was Beginner with Cocoa
- Subject: Re: Garbage collection - was Beginner with Cocoa
- From: Erik Buck <email@hidden>
- Date: Mon, 24 Mar 2008 12:12:36 -0400
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.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden