Smalltalk Vs. Java

A hopefully objective comparison


Smalltalk came long before Java did, and even long before java's immediate ancestors. As such, there are several things that java borrowed from Smalltalk, but nothing the other way around. However, java had the opportunity to improve upon things that were researched long after Smalltalk-80 hit the market. Unfortunately, it appears to me that java didn't take much, if any, advantage of this.

Object Models

Smalltalk has a "pure" object model. This means that it follows a very simple ontology: 1) everything is an object, and 2) every object has a class. Java doesn't have this level of purity. All of the low level types are NOT objects, and those things don't have defining classes. This in combination with Java's strong typing make it impossible to use any low level types in heterogeneous collections and leads to a breakdown in polymorphic design capabilities. This difference is probably my biggest source of frustration with Java.

Reflection

Smalltalk also has a completely reflective object model. This means that any Smalltalk object can introspect it's structure and capabilities. An instance can query it's class and figure out what methods are defined directly and in superclasses. It can use that information to it's advantage so that, for example, it can execute a method without knowing that method at the time that the programmer wrote the code. Reflection can also have very interesting applications in meta object programming (defining the object model itself).

Java has a very weak reflection model at best, and is rather opaque about it. An instance does have the ability to query it's class for various pieces of information like available methods. But in Smalltalk, when you query for a method you get an instance that really IS the definition of that method. You don't get this in Java.

Syntax

Smalltalk has one of the cleanest grammars I've ever seen in a programming language. Not one of the smallest, but one of the cleanest. This has much to do with Smalltalk looking and structured a lot like English. Many statements are simple "noun verb" form sentances.

Java is related to the C family of languages. It has a rather mechanical syntax and leads to a lower level of reading "flow". Unlike C++, Java is pretty straight-forward with regard to it's side-effects. It has very little "hidden" behavior.