100% Pure Ruby(tm)
September 26th, 2006
Recently I’ve been doing a fair amount of work in Ruby. And yes, I’ve felt super-productive. Particularly compared to Java.
The downside of working in Java is the 100% Pure Java(tm) mentality. In the search for a clean and cohesive system, we take the attitude that if it’s not pure Java, it’s crap. In Java, if we need something to happen periodically, we might examine TimerTask, decide it’s insufficient and move on to Quartz. So we add it to our build, figure out the API, realize it conflicts with some other dependency. Well, damn.
With Ruby, it’s scripty enough to not feel the need to have a 100% Pure Ruby(tm) mentality. A Ruby system needs something to occur periodically, we just open a pipe to crontab and hand that bit off to cron.
“But Windows doesn’t have cron!”
Too bad.
Use a better operating system.
The majority of systems deploy to Linux or some other Unix-alike. Developing on a Unix-ish system only makes sense. You wouldn’t prepare to drive an RV by tooling around in a Kia Sportage, now would you?
When you break free of the JVM mentality and assume a sensible host operating system, you realize that the OS itself is your virtual machine to play in. If it’s in your $PATH and can be expected to behave reasonably well on any sane Unix-like OS, by all means, use it.
Back to the premise… Since Ruby is indeed “scripty” you can accomplish a crapload just using a pair of backticks, effectively not even using Ruby at all.
And you can do it without guilt or complication. Completely unlike punting to Runtime.exec(…). That always makes you feel dirty.
Perhaps Groovy and JRuby will help break the never-escape-the-JVM attitude. Give a developer backticks and easy pipes to subprocesses, and no telling what sort of nefarious things he might could do.
September 26th, 2006 at 3:38 am
“Too bad.
Use a better operating system.”
dude. wake up..
September 26th, 2006 at 4:07 pm
Windows has the “AT” command instead of cron. Sadly, it has major security implications - http://passivemode.net/updates/2006/6/5/windows-xp-privilege-escalation-exploit.html
October 3rd, 2006 at 6:54 am
There are advantages to scripting existing commands. Try to run (exec) a program from Java, capturing its output and you’ll soon see all the fun and joy Java can bring. In this area, Java is a real pain compared to scripting languages like Python or Ruby.
The largest upside of the 100% Java, though, and something I’m surprised the Python and Ruby communities have not moved towards is the fact that Java database drivers (JDBC) are written 100% in Java. That means, I can connect to Oracle, for example, from Java (or MySql, or whatever) just by including a Jar file in my app.
With Ruby or Python, unfortunately, I need a library written in C and compiled for the platform in use. With Python or Ruby, I need to install the driver, which requires an extra step (and perhaps root access). This complicates installation compared to Java applications. I see nothing in Python or Ruby that would stop one from writing DB drivers within the language itself (rather than C). It’s just that no one appears to have done it.