The Artima Developer Community
Sponsored Link

Agile Buzz Forum
Objective-C++

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Keith Ray

Posts: 658
Nickname: keithray
Registered: May, 2003

Keith Ray is multi-platform software developer and Team Leader
Objective-C++ Posted: Apr 12, 2005 8:56 AM
Reply to this message Reply

This post originated from an RSS feed registered with Agile Buzz by Keith Ray.
Original Post: Objective-C++
Feed Title: MemoRanda
Feed URL: http://homepage.mac.com/1/homepage404ErrorPage.html
Feed Description: Keith Ray's notes to be remembered on agile software development, project management, oo programming, and other topics.
Latest Agile Buzz Posts
Latest Agile Buzz Posts by Keith Ray
Latest Posts From MemoRanda

Advertisement

I used to be a master of C++, even serving as a team's C++ "language lawyer"... As the language has become more esoteric, I have purposefully avoided getting into the rat-hole of meta-programming in favor of "real" programming.

Now that I'm back on the Mac doing Cocoa programming, I'm getting more work done with less keyboarding because I can use Objective-C in combination with C++. Objective-C has more run-time power and flexibility than C++.

Patrick Logan reminds us how easy it is to integrate Objective-C's first-class objects with Python, Ruby, Java, Smalltalk/Fscript... integration that does not require, for the most part, the massive amounts of code-generation that integrating C++ objects to other systems would require.

Smalltalk and Ruby's "blocks" (closures) provide a lot of power in a much more simple manner than C++ metaprogramming provides... besides passing a block around to classes and methods, you can implement new methods on blocks, to provide new control structures. This provides some sample of blocks.

Smalltalk, Ruby, Python, and Objective-C have ways for a class to intercept "invalid" method calls and do useful things with them - such as forwarding the call over a network (a network-proxy via a single method). To do network proxies in C++ requires code-generation or extensive amounts of template programming. See these Smalltalk examples for a lot of other interesting things that can be done with this interception capability that would require re-writing the compiler in another language.

I have been doing some meta programming in Objective-C this weekend. Unlike in C++, meta-programming is done in the same syntax as regular programming. Starting with the Objective-c proxy example here, I'm creating a class to log calls into an object's methods. This involves decoding the method signatures in order to log the arguments. I will be able to do something like this:

someObj = [ [ LoggingProxy alloc ] init: someObj ];

to take an existing object and start logging calls to it -- no recompilation of the sources of someObj's class would be needed. I might even be able to call this code from gdb, so my choice to start logging an object could be made at run-time when debugging.

Some parts of Aspect Oriented Programming are doable in Objective-C without using a pre-parser/code-generator, by using the forwarding/proxy and introspection features of the language.

Apple's Objective-C++ lets me use straight C, Objective-C objects/syntax, and C++ objects/syntax, and mix them in the same source files. (With some care due to differences in object-allocation and exception-handling.) Objective-C++ lets you Alternative Hard(fast) and Soft(slow) Layers within the same language.

Apple made their modifications of gcc available to the maintainers of gcc (and the sources are probably on http://developer.apple.com/darwin/ or opendarwin.org), but the last time I checked, the maintainers of gcc declined to accept those changes and make those modifications available on other platforms. If you want the power of Objective-C++, but you're not using MacOS, ask the gcc maintainers to accept Apple's mods -- or buy a Mac. :-)

Read: Objective-C++

Topic: Bad science Previous Topic   Next Topic Topic: The price

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use