Home Site
 

Welcome to PC AI Online

( This Site works best with IE 5.5+ or Netscape 6.0+ )

    Page 48
16.4 Table of Contents Bottom of Page Site Map
There is quite a difference in the raw
amount of code required to do the exact same job. In the Java example, the code must repeat itself numerous times to ensure the compiler understands and does not flag a type error.
The Smalltalk example does not ask
for an Iterator or implement any looping code as in the Java example since Smalltalk uses internal itera-tors. Because Smalltalk allows the modification or inheritance of any class within an image, it is much easier to put functionality where it belongs instead of orphaning such code where needed.
Another common situation is dealing
with primitive data types, items such as Integer, Double, or Byte. In Java, there are two type systems to deal with, as this example shows:

int j = 100;
double d = 3.14568;
Map aMap = (Map)new HashMap();
aMap.put( "AnInteger", new Integer( j ) );
aMap.put( "ADouble", new Double( d ) );

Notice that, to place the primitive
values into an object collection, they had to box them in wrapper objects.
Let us now try to take them out and
add them together:

Double aDouble = (Double)aMap.
get( "ADouble" );
Integer anInteger = (Integer)aMap.get(
"AnInteger" );
double d = aDouble.doubleValue();
double i = anInteger.doubleValue();
System.out.println( "d + i = " + (d + i) );

This process of constantly boxing
and un-boxing primitive data types adds significant code, development effort, and increase the possibility of software defects. Notice that the Double and Integer classes do not have any methods to perform arithmetic, only to hold onto a primitive data types and convert between them.
Here is the same example in
Smalltalk:

| aDictionary |
aDictionary := Dictionary new.
aDictionary at: 'AnInteger' put: 100.
aDictionary at: 'ADouble' put: 3.14568.
Transcript
  show: 'AnInteger + ADouble = ';
  show: ((aDictionary at: 'AnInteger') +
    (aDictionary at: 'ADouble'))
    printString;
  cr.

Obviously, the Smalltalk example
uses less code and handles types in a more homogenous fashion. Notice that no explicit conversion code is required to add the SmallInteger to the Double.

Another Cup of Espresso?

Lets briefly discuss the most popular Smalltalk products on the market today
and the niche I perceive each one to fill. These categoriza-tions are my own and not intend to be rigid. Every Smalltalk on the market today is full-featured and capable of developing almost any application imagined.

VisualWorks

This is the granddaddy of all Smalltalks descending directly from Xerox Parc.
It has a huge class library covering desktop, web, network, and distributed programming such as CORBA. It is cross-platform at the binary level and uses an emulated user-interface, so it behaves consistently on each platform it supports.
VisualWorks is the most mature, but also the most legacy ridden, Smalltalk
on the market. Cincom has done an excellent job moving it into the future with its own multi-user Software Configuration Management (SCM) tool called StORE. The current release, version 7 incorporates the new refactoring browser from Refactory, Inc. This tool further improves programmer productivity and enables many automated methods for managing Smalltalk code, including a Lint-type tool that makes suggestions on code reorganization and possible errors.
Cincom's pricing models are varied and fair. If the goal is developing
cross-platform Smalltalk solutions in a corporate environment then this is the best bet. While it can develop desktop applications, VisualWorks lack some more modern GUI features found in other Smalltalks that more tightly integrate with Windows.
VisualWorks enjoys an extremely active programming community with
developers' constantly creating additional class libraries and help for the entire Smalltalk community. Cincom offers another Smalltalk called ObjectStudio, originally called Enfin, which is more tightly integrated with Windows and delivers a robust class library. Cincom is working to merge the technology between ObjectStudio and VisualWorks.

VisualAge for Smalltalk (VAST)

VAST is IBM's Smalltalk, containing a tremendous class library that
compares favorably with VisualWorks' class library. VAST has several IBM specific class libraries that allow quick integration with CICS, MVS, AS/400, and other IBM specific technologies. IBM offers a SCM called ENVY, which is easy to install and use in a team environment.

To Page 47

16.4 Table of Contents
Top of Page

To Page 49


16.4 2002
48

PC AI Magazine - PO Box 30130 Phoenix, AZ 85046 - Voice: 602.971.1869 Fax: 602.971.2321
e-mail: info@pcai.com - Comments? webmaster@pcai.com