Saturday, October 10, 2009

Like a Ruby in a Goat's A@@

I have been programmed in Java forever. Of course, there is nothing wrong with that.

Now I am learning and writing Ruby and specifically JRuby. The reason for JRuby is that I am calling the API in MagicDraw to get some things done that I have always wanted to do, but didn't have time to set up NetBeans or 'gasp' Eclipse every few months (I am Chief Architect of MagicDraw, so always working on the latest version).

I am sure that I could be writing Java, but I just don't have the time to do the setup. That's the key. You just run the scripts. No compile, no install, no waiting. There is a lot of pull.

I am also strangely attracted to Ruby (not in that way, the platonic language loving way). A few years ago I saw a lecture by Dave Thomas (of Pragmatic Programmer fame, not the founder of Wendy's), and thought that Ruby seemed compact and a rather useful language. But alas, every attempt to learn Ruby was thwarted by the chaos which is inherent in most languages... Drifting language, few standard libraries, and poor support. This has changed with the introduction of JRuby and the inevitable tread that comes with popularity of a language... sloth.

Now Ruby's pace as a syntax has slowed. Gone are the days that you can't test the latest article or book on your latest version of Ruby. Gone are the days of trying to match the right version of Ruby with some arcane GUI library. Gone are the constant changes to the language because when something is popular, change is discouraged.

There is still change, but it is additive. The GUI can now be based on Swing and I have that one in the bag. The implementation of JRuby runs on any Java JVM, so it works on any platform. Oh joy!

Things are not all good... Ruby is an interpreted language. There is no strict typing. Errors are at best cryptic for the new user. Learning Ruby is simply cool and like torture best left behind in the Bush administration because you'll never get a proper confession from a Ruby error message.

Well, with a presentation looming, I am forcing myself. I need to talk about PRR. PRR... well it is about rules as in expert systems as in artificial (pickled) intelligence and representing said rules in UML. All well and good, but what good are rules if you can't run them? So, comes Ruby to extract the rules and run them in Drools.

Well, very quickly between myself and the great aid of Gerald Meazell, up comes working JRuby extracting UML and spitting Drools! But, then came trying to get Drools to work... I panicked... Then I looked for a rule engine written in Ruby and found Ruleby!

Ruleby is based on the great work of one of my buddies, Dr Charles L. Forgy of Carnegie Mellon University. Dr Forgy invented the Rete algorithm which is simply the reason why expert systems work because it optimized the execution of rules. I'll get into Rete someday, but take my word for it, Rete is cool.

Long story short, it is all working and I am ready for my presentation at the October Rules Fest in Dallas (except for writing the presentation... the easy part). I am using JRuby, Ruleby, and Tenjin for my template language. I can even generate a Drools DRL file!

Ruby is still treating me like a reb head stepchild, but I am learning and Gerald, who is a bonafide and card carrying red headed stepchild, is helping a lot. More to come, even some code. Got great ideas and now I can find the time to script a few.




No comments:

Post a Comment