Smalltalk and C++ -- a Reader Comment and Response

A reader, Chris Hanson, writes:

re: A Fundamental Difference in Class Behavior between the Native and Managed Object Model

In other words, Managed C++ actually behaves like an object-oriented language, such as Smalltalk or Objective-C. An instance of a class is an instance of that class, no matter where in the hierarchy a particular method is located.

Hmm. While there is very little content to respond to in this comment and a great deal of attitude, it does reflect an interesting sentiment in the `pure’ OO community that has never been terribly pleased with the hybrid C++ language. Let’s see what if anything of interest I can make out in response to this comment. [I make no guarantees.]


Is Smalltalk the first object-oriented language and the measure of all things OO? No. Before Smalltalk, there was Simula-68, which Bjarne Stroustrup used as a doctoral student at Cambridge back in the 1970s, and which as a student in the Columbia University computer science department I used in Programming Language Concepts, which also covered Algol, Algol68, Lisp, and Prolog – Ada was still a ROYGBIV candidate competition, and C was mentioned simply to contrast its parameter passing semantics with that of Algol. Smalltalk is a branch in a much larger tree.


Stroustrup’s use of Simula at Cambridge was a mixed bag – I don’t mean to speak for Stroustrup, but use his experience as I remember hearing of it to score a contrast between the Smalltalk school of OO as championed by our Mr. Hanson, and the school represented by C++. While Simula modeled the distributed OS in most excellent fashion; its execution was dismal. Stroustrup exhausted his budgeted cpu-time before his program had generated sufficient data. Casting about for some alternative computing resource, he made use of a corner machine using the BCPL corner language. [Basic Computer Programming Language, the predecessor to Thompson’s B and Ritchie’s C languages. The arcane question we posed to new hires at Bell Labs, before C++, of course, was: given B, and then C, what should the successor language to C be called? Of course, to Walter Bright’s chagrin, it should be called P, not D.] This required hand-translating all the nifty class abstractions to the level of bytes and words, but … well, you know the rest.


Smalltalk is a dynamic language making extensive use of the run-time, and its performance reflects that. However, it provides considerable more flexible than C++. Stroustrup constrained the C++ Object Model by essentially curbing its reliance on run-time services. What he sacrificed in flexibility he made up with its extraordinary gains in performance. C++ is used in real-time virtual reality simulations [I’m familiar with the brilliant Aladdin ride developed within Disney Imagineering, for example] and its uses in computer graphics imagery and in aviation.


So, Smalltalk and C++ are two very different languages attempting to solve very different problems. Smalltalk, while visionary, was not widely used, and what use it had has been displaced by the C++-influenced Java. C++ use is pervasive: the C# compiler released under Visual Studio, for example, is implemented in C++. The three major operating systems, Windows, Linux and the Macintosh X, are all implemented in a mixture of C and C++. The major modeling and animation software that fuels the film industry and brings us wonders such as The Lord of the Rings is all powered by C/C++. That tickles me no end. C++ has brought class to C, and it underpins our entire sophisticated software infrastructure.


So C++ has been wildly successful both in its usage and, interestingly, in its influence: Java and C# are refinements of C++ that attempt to put back [some] of the dynamic nature of the Smalltalk vision. Those of us involved in the definition of C++/CLI believe we have done a better job of it then either of those two languages, but what else would you expect us to say? Better to say, rather, that it is our intent to have C++/CLI go C# one better. There’s nothing negative in that. Hopefully that represents a constructive competition that will benefit both languages and their user communities.


I have in the past joked that .NET is Smalltalk’s revenge, and Mr. Hanson’s comment, I believe, bears some small witness to the truth in that. To that degree, Visual C++ is the only language that integrates the performant hybrid OO of ISO C++ with the dynamic OO purity of C++/CLI. My point in the blog was to bring attention to the difference and mildly suggest the non-intuitive nature of the pure OO model -- because before an object is initialized, contrary to Mr. Hanson's assertion, it does not exhibit the state or behavior of an entity of that class. The sub-object partial construction of a class entity is a singularity that falls outside Mr Hanson's claim that “an instance of a class is an instance of that class“.