Extensibility through simplicity
When people are introduced to Smalltalk, they often come away a bit befuddled, and also feeling like some of their syntactic sugar addictions can’t be fulfilled. Take the wiley “case” statement that exists in many languages. Turns out you can implement it in Smalltalk via just simply extending the underlying classes. Poof! Try that in most languages and people will look at you funny. So far, Lisp and Smalltalk are the only two languages I’ve used that are so trivially extensible to meet new requirements. Others can be extended, but not so seemlessly.
Andy Bower, however observes in the linked wiki page:
When I first came to Smalltalk from C++, I couldn’t understand how a supposedly fully fledged language didn’t support a switch/case construct. After all when I first moved up to “structured programming” from BASIC I thought that switch was one of the best things since sliced bread. However, because Smalltalk didn’t support a switch I had to look for, and understand, how to overcome this deficiency. The correct answer is, of course, to use polymorphism and to make the objects themselves dispatch to the correct piece of code. Then I realised that it wasn’t a “deficiency” at all but Smalltalk was forcing me into much finer grained OOP design than I had got(ten) used to in C++. If there had been a switch statement available it would have taken me a lot longer to learn this or, worse, I might still be programming C++/Java pseudo-object style in Smalltalk.
Something I had never really thought about, but it’s truly the difference. I still am forgetting habits that I’ve learned in other languages to fully grasp the elegance of some things. As I’ve said many times, simplicity is the path to power.
[via Lambda the Ultimate]
This entry was posted at 10:35 pm on 1 November 2005 and is filed under Smalltalk. You can follow any responses to this entry through the post-specific RSS 2.0 feed.
No comments found.
Both comments and pings are currently closed.