As part of my OO class, I'm learning Smalltalk. More specifically, I'm learning Squeak which is an open implementation of Smalltalk. What follows are some of my observations about the language. I'm assuming that most readers are unfamiliar with it as Smalltalk is not one of the popular languages any more.
- Smalltalk is a very small core language. The syntax describes classes, objects, variables, blocks (closures), and messages. That's about it. All method calling is via message passing.
- Everything else is in the library. Even most control flow operations are part of the library, not language primitives.
- The library is all open. Not only the library, but the entire environment. Everything has its source code open. Not just source code that is available for download and compiling. It's all in the environment. When you debug an error being thrown, you can debug through the error generation and handling code. Even the UI from which you called the offending code is at the top of the stack. This has the result that you can modify *everything* about the system should you want to.
- Because everything is open, the library feels chaotic. Often the same functionality is implemented in different ways in different parts of the system.
- Convention rules over language features. Whereas in most languages there is a syntax for pure virtual functions or interfaces, in Smalltalk, there isn't. When you want to declare a pure virtual function, you just have it call subclassResponsibility (or subclassResponsibilityMarker or fred). If you want to instantiate an abstract class, you can. There are no constructors. There are no truly private methods. Both are merely conventions.
- There are no source files. Everything is done in the programming environment. There is a way to export .st files but a) they apparently aren't standard and b) they are only partially human readable. If you want to add a method, you click here. If you want to create a class. Click there. As someone that uses Vim to code, this is very strange indeed. This also has the effect of rendering standard tools like grep and regex useless.
- Everything is dynamic. There are no types. There are no (or few) errors found by the compiler. If you want to pass an array to something that takes a string, everything will work until you try to use a string method, when it pukes. If there is a syntax bug in your code, you won't find it until you actually execute the method. No wonder these guys pioneered unit testing.
- Precedence rules are strange. There are three kinds of messages and they are each executed in a specific order. Within each class, the ordering is left to right. Standard math conventions are ignored. 8 + 3 * 6 is 66, not 26.
- Polymorphism comes from having messages with the same name, not from an interface as modern languages define them. There is no inheritance involved. It's almost like calling methods inside template code or macros in C++.
- All data is protected. The only way to access class/instance variables is through methods.
Smalltalk is a very interesting language, but it is old. Newer languages have refined the concepts and implemented them better. I don't think Smalltalk makes a great production language anymore. However, there is a lot useful here. Learning it can be beneficial.