Archive for the 'Lisp' Category

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.

Languages of the Gods

I’m always interested to see what someone new to Smalltalk has to say about it, always, but this takes the cake so far. I like what Dave had to say, but I’ll change it to “Languages of the Gods”, for Smalltalk is but one of a few. I personally give it up to both Smalltalk and Lisp, I think most other languages are derivatives of one of these two.

Languages like Smalltalk and Lisp (always got to give Lisp its props) are amplifiers. They make you more of whatever it is that you already are. If you’re a bad programmer, they’re going to make you worse, they’ll let you shoot your foot off in more interesting ways than you can imagine.

If you’re a great programmer, they’re going to make you that much greater, they’re going to let you become a God, and live entirely in a universe of your own abstractions. Anything you don’t like you can objectify or macro’fy and never have to think about it again.

These languages will never be mainstream, because the mainstream would never see the benefits they provide. The mainstream would kill themselves with such power. There’s a reason the mainstream likes manifest typing, procedural programming, and cut and paste methodologies, quite simply, it’s all they can handle.

Reflection is too deep in the bag of tricks for most mainstream programmers, let alone meta programming, or dynamically typed custom DSL’s in esoteric languages like Smalltalk and Lisp.

You have to appreciate beauty and elegance to appreciate Smalltalk and Lisp, and quite frankly, those just aren’t mainstream values. I think Dave’s right, the “Languages of the Gods” will never be mainstream, but you know, that’s not really such a bad thing. As long as the communities are large enough to support the work I do, I really don’t care about what the bandwagon is up to.

Aha! Moments in Lisp

You know, I’m a Smalltalker, but I have a deep respect for Lisp and always love reading about it. I just ran across this great thread of some Lispers talking about their big aha! moments.

One of these days soon I’m going to have to try and do a small web application in Lisp or Scheme, I love Smalltalk, but I still drool over the idea of macros and generic functions. I guess for a Lisper, Slime is the environment to learn, but I shudder at losing my Smalltalk environment and having to learn emacs. I’ve always felt Lisp is the superior language and Smalltalk is the superior environment. If any of you are proficient in both Lisp or Scheme and Smalltalk, I’d love to hear from you.