What can Smalltalk Do?

There's a resurgence of interest in Smalltalk, and with that resurgence has come a search for basic information about Smalltalk. Given that, here are some basic questions along with answers. We are always looking to get more and better information out about Cincom Smalltalk, so - if you have suggested questions for this page, send them to James Robertson, the Cincom Smalltalk Product Evangelist. You should also check out Smalltalk Daily, our screencast series covering the length and breadth of Cincom Smalltalk. If you prefer written documentation, we have the PDF documentation available here

What platforms does Smalltalk run on?

Cincom Smalltalk gives you two options: Seamless cross platform portability with VisualWorks, or the native Windows (including Vista) experience of ObjectStudio 8. Both have access to the same Cincom Smalltalk library stack, which covers everything from SOA to ActiveX, and web development to client/server.

What about non-GUI apps then? Can I create a Windows service, or a Unix style cron job?

The server you are reading this on is a non-GUI, Cincom Smalltalk web application server. With Smalltalk, you can create Windows services, Unix/Linux services, and nearly any kind of non-GUI application you might need

Does Smalltalk have "BigNumber" capability?

Not only does Smalltalk have big numbers, number objects auto-promote. Try this:


10000 factorial inspect.

For more information, you can view the short screencast here.

BigNumber

Does Smalltalk have auto-resizing Arrays?

While the Array class itself does not resize, most collections in Smalltalk do. The most commonly used classes - OrderedCollection, SortedCollection, and List - all automatically resize as you use them. The Array class is an optimization for the cases where having a fixed size collection would be useful

Does Smalltalk have hash/map classes?

In Smalltalk we call this a Dictionary, and there are two kinds:

  • Dictionary, where the keys are compared using an equality test
  • IdentityDictionary, where the keys are compared using an object identity test

To explain the difference, if you do the following:


| dict |
dict := Dictionary new.
dict at: 'foo' put: 'bar'.
dict at: 'foo' put: 'baz'.

You'll get this:

Dictionary

If, on the other hand, you try it with an IdentityDictionary:


| dict |
dict := IdentityDictionary new.
dict at: 'foo' put: 'bar'.
dict at: 'foo' put: 'baz'.

You'll get this:

IdentityDictionary

The reason? When we create a string, we get a new object, and it's not the same as another with the same characters. So, in the first example, the equality test results in a new value replacing the old. In the second example, the identity test results in two different entries

Can Smalltalk call out to C code?

Smalltalk connects fairly easily to C code, less easily to C++. For some examples of how to do this, visit the Smalltalk Daily page for external connectivity - it includes a number of examples.

What about using multiple threads?

A single Smalltalk process (image) runs in the context of one operating system process, using a single OS level thread. Within that process, you can manage an arbitrary number of lightweight (green) threads - This Smalltalk Daily page has numerous examples of Process usage, including Mutex usage and Promises. There's also a general overview of the Smalltalk process model. What about calling external platform functions? You can have such API calls use an independent platform thread, assuming that the library you are calling can be safely called that way.

What about File Access?

Reading and writing files in Smalltalk is quite simple; there are numerous examples given on this Smalltalk Daily page. To get you started, here's a simple example:


| file line |
file := 'myNewFile.txt' asFilename writeStream.
file nextPutAll: 'Hello World!'; cr.
file close.

file := 'myNewFile.txt' asFilename readStream.
line := file upTo: Character cr.
file close.


Continue on to the next section