Functional Programming in Smalltalk
Smalltalk is generally considered to be an object oriented language but it’s actually a mixture of object oriented and functional techniques that made it so great. It’s the functional stuff, closures, anonymous functions, and higher order functions that make Smalltalk code so terse and easy to read. The objects provide the overall structure, but the functional stuff glues them all together and makes Smalltalk what it is.
I was considering writing more about it but a quick Google search turned up this great reference Smalltalk for Lispers from the Smalltalk/X Programmers Guide that gives an excellent introduction from a more functional point of view.
If you mix object oriented programming, manifest types, and procedural programming, you get Java or C#, not exactly a fun or flexible combination of language features. Mix object oriented programming, dynamic types, and light functional programming and you get Smalltalk and Ruby, much more fun and much more flexible and productive.
People often seem to forget “object” is meant as an abstract term that means “thing”. Object oriented programming is about programming with “things”. In that sense, functions are objects too. Not all objects need be created with named classes, and all too often people who complain about OO are really complaining about their misguided view of OO and the often made newbie mistake of trying to model everything with a class. It’s not called class oriented programming, it’s called object oriented programming. Maybe approaching Smalltalk from a more functional point of view will shed some light on more interesting ways to solve problems.
Comments(8)