While attempting to quench my thirst for the latest and greatest software that would make my life easiser, I went ‘a searchin’ on the net to find frameworks and technologies.
Since I’m responsible for a lot of web 2.0 / enterprise software products, I wanted to find a framework and/or suite that I could leverage to cut my development time down. One of my biggest criteria in determining what is valuable is that of intuitiveness. I want things to make sense to me. Granted, this is a purely subjective statement, but I’ve found that what makes sense to me makes sense to most of the people in my field.
So, what makes sense to me? Object Oriented design.
I’m talking about pure OO – everything is an Object, objects communicate with other objects via messages, interface-driven design, abstraction, polymorphism, etc.
Well, since I’m a Java guy, I knew that I was at a dead end, since Java isn’t purely OO (ints and booleans are not objects, they’re “primitives”). But I love Java, and Java 1.5 helped a little bit with its auto boxing/unboxing feature, but that’s not perfect. Yes its verbose, and yes the compile/build/deploy cycle is cumbersome, but its strong type safety finds a heckuva lot of errors. When you’re in a team environment, thats a huge safety net. And, when you throw in frameworks like Spring, Hibernate and JUnit, I do still find myself very happy and productive. With their support, I can churn out a lot of functionality very fast in Java. But Java has its quirks, and to be honest, the strict typing thing ties your hands in a lot of ways.
What I was looking for was the next revolution. Something huge. Something that would drop my development time literally in half. I’m not kidding…something that would realistically reduce my coding/testing/rollout time 50% or more. Concretely.
Here’s what I’ve decided:
- I don’t really like Ruby all that much. The syntax is a little too cryptic which can introduce ugly code that’s hard to read (Python anyone?). But more so, its slow as hell. Rails is a great concept, but I’m not sure that Ruby is the best choice for such a framework. There is already a massive flame war about why Ruby is great or sucks, but I’m not going to get into that here. Suffice it to say its not right for me. It doesn’t leverage Java, so that means its out, even if its better than sliced bread.
- I don’t like Jython or Python – not ‘pure’ enough for me. Yes, they can adhere to the OO paradigm, but they allow a ton of procedural programming. This makes code too sloppy for my taste. Jython is cool in that it can leverage Java, but it can’t win out due to the code readability thing.
- BeanShell is cool and is really just interpreted Java. But Java/BeanShell doesn’t do everything I want. I want closures!
- Groovy supports everything I want. The syntax is very similar to Java, at least, similar enough to be able to learn the differences in a single day. It also supports everything in Java. That means I can leverage the amazing amount of functionality already written in Java (Spring, Hibernate, Ant, etc). Its not quite as fast as Rhino/JS, but it does have a decent support base over at CodeHaus. Then I found Grails.
You see, I think the OO world will return to behavior AND state in the same Class within 5 years, as OO intends. AOP makes this ability possible. Because of distributed systems and the complexities of state management, users of OO languages like Java/C++/C# etc. have split their programming paradigm. We usually write business logic in classes as functions and pass in an object POJO that contains state and nothing else. Why can’t they be the same?
Distributed systems threw a wrench into that concept. If I passed an object from one VM to another, I couldn’t guarantee that the object transferred would work correctly in VM1 as it would in VM2. Thats why folks created “state-only” objects, and let the behavior reside elsewhere in “Manager” or “Service” stateless components. I think AOP allows us to move back to what OO is meant to be – state and behavior together.
Grails helps move in that direction. Where I used to have a Book domain model object, and a BookManager service object which in turned used a BookDAO object to do persistence logic, I can have all 3 in one Class with grails:
def books = Book.findAll();
Book b = new Book( title: "Hello World", author: "John Smith" );
//at this point the book is saved in the RDBMS.
//books is now a collection of all books in the RDBMS
books = Book.find( “from Book b wher b.author like %mith%” );
//now books contains only those books whose author’s name is like “mith”;
books = Book.findByTitle( “Hello World” );
//now books contains only those books whos title is “Hello World”;
When using Grails, you don’t even have to write that last findByTitle call in your Groovy class. Grails automatically interprets that method call as a hibernate call if it doesn’t exist in your class, and essentially creates and executes the implementation dynamically, during runtime on your behalf. Pretty sweet magic going on there.
(It still rubs me the wrong way a little propagating queries up to such a high level in the code – instead of using a DAO for example – but there is nothing that prevents me from using DAOs should I choose to do so, and that discussion is worth a new post entirely. Suffice it to say doing this gets you up and running _very_ fast, and you could always implement a DAO strategy very easily if time and costs allow).
Anyway, this is a huge step in the right direction – logic and state in the same entity. Brilliant! (mmm…Guinness)
So, I started thinking.
Groovy/Grails are doing things that have been around for years. Smalltalk has type-safety. It has interpreted support (highlight a chunk of code and click “doit!”, and it evaluates). It even has closures (called blocks). AND – here’s the kicker – it is truly pure OO – everything is an object. Numbers, booleans, even the compiler itself – are all represented as instances of a class. Even null is an object (called ‘nil’, it is the only instance of the UndefinedObject class).
So, this leaves me a little frustrated. I’ve come full circle from C to Java to all these new fangled scripting langauges, all the way back to Smalltalk. Its like we CS idiots just keep reinventing the wheel when Smalltalk has had all this stuff all along! I learned Smalltalk back in college at Georgia Tech, and I have to be honest, I didn’t like it that much. We used an open-source variant called Squeak, and it was slower than molasses, it had a poorly documented API, and the IDE sucked (it looks much better now, 5 years later).
But the language itself was awesome. It made sense to me as a fledgling CS student (Java did too, so I guess that doesn’t say much). But I’ve heard of stories of 8 year olds learning Squeak in a couple days (I think Disney did some learning research with it). It took CS students in a university an entire semester to really learn Java. It takes even longer to fully understand C and C++, because you have to know the intracacies of pointer and memory management.
So, again, I’m like “what the hell!?!?”. Squeak’s VM, compiler, and IDE are written in its own language. I’ve even heard of folks modifying live code in production without restarting anything. Are you kidding me? Thats just freaking amazing. Why the heck have we reinvented the wheel like 30 times?
Smalltalk was written in the late 1970’s by Xerox Parc. It had a VM back then. How revolutionary! When CS was just a fledgeling concept and departments were one or two rooms in a Mathematics school, they were already on to the concepts of virtual machines, garbage collection, OO abstraction, design by contract, etc, etc. Holy crap those guys were smart.
So, why isn’t everyone using Smalltalk today instead of Java or C#?
The answer is Smalltalk’s price in the early days. Unfortunately, IBM and other Smalltalk vendors charged an arm and a leg for a single developer license. I think the average around 1985 was about $3000 per developer. That was a lot of money back then, and is even too expensive for today’s market when the best IDE‘s are free or inexpensive. That, and open-source was not even close to being on the radar in the late 1970’s.
So, just as Smalltalk was starting to hit the mainstream among companies that could afford it, Sun Microsystems came in in 1995 and blew up the world with a FREE developer toolkit and with marketing techniques that piggybacked the hype of the newly popular internet. Smalltalk never had a chance. Hobbyists would never pay for something so expensive, so they adopted Java, and the rest was history.
Sucks for us. Don’t get me wrong, I absolutely love Java. But I think I could love Smalltalk even more given proper community support and adoption (and a good IDE – I would much rather have an Idea or Eclipse environment than what Squeak has, even with Squeak’s improvements).
Unfortunately, I’m not sure Smalltalk can recover. Java and .NET are the really only heavy hitters out there for enterprise development. Does Smalltalk/Squeak have an ORM tool as powerful and sophistacted as Hibernate? What about application frameworks like Spring, Tapestry, Struts, etc.? I would assume so since the language has been around a lot longer than Java, but I haven’t heard of them. I would love for an experienced Smalltalker to point them to me.
So I conclude discouraged and disheveled, because the coolest language out there, the one that has been around for 30 years, and has had ALL of the feature that the most modern languages are just now starting to support – not many of us use it. There is not enough industry adoption. There is not enough of a marketing machine out there. Even IBM, an early Smalltalk supporter (VisualAge Smalltalk), has ditched most of its offerings for Java.
I love Java. I really do. I just wish Smalltalk had a heavy hitter like Sun behind it. Until then, I look to Java, Groovy and Grails, which are much more likely to catch the eye of today’s developers. Too bad we’re just now able to do things that Smalltalk has been able to do for more than 20 years.
I end this post disgusted. I’m going to get a Guinness…