Webware and Rich Internet Applications
11 Jul
Today I’ve been thinking about beauty of Smalltalk, about how productive we can be with Squeak or Seaside. Of course everone has a different opinion about productivity and efficiency. For me it means that I don’t need to worry about nothing else but only logical aspect of some programming problem, I mean - code at the speed of thought. It’s more a pragmatic, practical way of thinking but it works. Today we have many outstanding frameworks, languages, but even if you choose my favorit Ruby on Rails you have to still answer on several questions:
This is only the top of the iceberg. You haven’t these problems with Squeak or Seaside, you have one image and there is everything - version controll, IDE, debugger (great debbuger!), editors. What is more, you can save your image and copy to other computer in one move and it still works , it’s so simple. For me Seaside or Squeak is something like an iPod, you have only features which are really important nothing else. One small shiny button which gives you unlimited possibilities :).
But back to my topic DSL (domain-specific language) with Smalltalk, it’s really iteresting because I was always talking here about Ruby and power which gives us. For example BNL (Business Natural Languages) or of course simple stunnig Ruby DSL example - RSpec. But .. again things still could be better, Ruby is great to build DSL although Smalltalk is even better. Smalltalk seems much more a notation, we can simple say “that can do nothing but build domain specific languages.” - sentence from really good onsmalltalk blog. Why it is so ? “Ruby isn’t object oriented at the level Smalltalk is, is still falls back to procedural constructs and special syntax for many things. Smalltalk, is pure, objects all the way down, at every level, even the simplest and most common domain specific language of all, predicate logic. When you create a domain specific language in Smalltalk, your code never looks different than code provided by the compiler writer himself, it’s one syntax to rule them all.”. There is also an interesting podcast called Smalltalk is a DSL. DSLs have always been part of the Smalltalk farbic - “Code should read like a conversation“. Sounds nifty and it really is, Smalltalk is so elegant in all these things and this elegance is in my opinion simple way to create great programs.
Another thing is Metaprogramming, discipline in which Smalltalk always wins. Here is a good example of metaprogramming from Randal Schwartz’s blog:
“You can even create anonymous classes and give them behavior, then instantiate them.”
| myClass myInstance | myClass := Behavior new. "create anon behavior" myClass compile: 'theAnswer ^42'. "add a method for instances" myInstance := myClass new. "create an instance" Transcript show: myInstance theAnswer; cr. "shows 42"
Look also at SOUL(The Smalltalk Open Unification Language). If we are in “Meta World” there is another interesting thing in smalltalk called Magritte - fully dynamic meta-description framework.
So generally as we can see Smalltalk is very very flexible and powerful language in which we can solve all our problems in very elegant and simple way.