Messaging in the GNU Objective-C runtime (1 of 2)

I’ve mentioned before that, of all of the C dialects available, Objective-C appeals most to me from the standpoint of simplicity and elegance. The language isn’t perfect but, prior to version 2.0, I found the syntax to be relatively clean and intuitive, unlike that of C++.

When examining the syntax of the language, particularly the use of bracketed statements to indicate method calls (messaging), it’s easy to see that Smalltalk features were imposed on the underlying C syntax rather than being added as a natural evolution of the language — but I’d guess that this was because the initial "compiler" for Objective C was something closer to a preprocessor than a full-blown parser. Nevertheless, the syntax does make method calls easy to recognize in long stretches of code; and the ability to "tag" parameters also helps to clarify the purpose and use of each object.

Unfortunately, Objective C never really caught on as a mainstream language, and Apple seems to have abandoned it in favor of a language with semantics that are closer to C++ (read: uglier, in my opinion). Much of the reluctance to use the language seems to revolve around the idea that Objective C code can never compete with C and C++ in terms of performance: Objective C resolves method calls (messages) to their implementations at runtime, while traditional compilers do so at compile time. In general, the former approach is supposed to provide the most flexibility in implementing of a given method, while the latter approach will provide the greatest speed. But does the flexibility offered by Objective C actually actually penalize code execution times?

For the Apple implementation of the Objective C runtime, the answer would appear to be "yes" — at least, this was the case in 2003. But that was more than twenty years ago, and with the traditional Apple runtime. The question is whether the Objective C runtime implementation presently offered by GCC suffers from the same speed penalty.

(more…)

Site changes

After several years of using PmWiki and BlogIt, I’ve decided to move to WordPress. Primarily, I wanted a Markdown-enabled editor that didn’t become confused by wiki syntax, and I had to bow to the idea that mobile devices have become prevalent enough that I needed a site rendering option which could handle that. I’ve checked the output of the new site in links, too, just to be certain that it’s still accessible. I’m not really a fan of the over-reliance on JavaScript that plagues the majority of modern websites.

All of the previous posts are still available.

Hacking the Portable Object Compiler

Note: This article is a work in progress.

I’m partial to C for its simplicity and power, but I prefer to work in an object-oriented mindset when I write code. I’m no fan of the hot mess that is C++, however. So I was quite excited when I found Objective C a few years ago. Although from a syntactical standpoint, the language is clearly an imposition on the underlying C syntax, I think the overall effect is more intuitive and elegant than the Arcane Wizard Scrawl™ that C++ has become. I’d hoped to start using Objective C, by way of GCC, as my main programming language — but their desire to keep pace with Apple’s slow destruction of the language ruined those plans.

In an effort to find an alternative, I stumbled across the Portable Object Compiler. The basic syntax is the same as what Apple brought out of NeXT, except that protocols (interfaces) are not supported — though there are ways to live without this — and categories have to be implemented in a different fashion, albeit one that makes sense.

Intrigued, I downloaded the bootstrap compiler and compiler sources and…they didn’t compile on my Linux box.

(more…)