Archive for the 'Ruby' Category

A Golden Cage

Twenty years ago, my first job was to assist visitors of the Computerette–something of an Internet café without the Internet. This small company had been started by someone who did freelance jobs coding some very obscure Cobol dialect. While he kept doing his well-paid job, he hired me to take care of the shop. Besides this rather dull work, he let me do small programming jobs on the side. For this, he introduced me to Clipper, the compiled variant of the then-popular dBASE III language. Himself, he would not dream of quitting his Cobol job for this; even though he loved Clipper and Clipper jobs were abundant at the time. “It’s not about the language,” he told me, “it’s about the problems you’re asked to solve.” While I was coding my first address book application for a start-up law firm, his software was controlling the oil refineries of Pernis (the Rotterdam harbour). I did not understand him back then. Who ever would want to keep coding in Cobol, the language of the past?

At yesterday’s RubyEnRails 2008 conference, a friend told me that I’m in a golden cage: getting paid more in my current job for coding Java, than I could get in another job for doing Ruby/Rails–preventing me from switching to Ruby/Rails. His remark reminded me of my old boss who did not want to switch to Clipper. Am I turning into him? Am I coding in the language of the past? Will I still be doing so 10 or 20 years from now?

No way. It’s not about the language.

2008-06-11. 2 responses.

Test Your Ruby Skills On JavaBlackBelt.com

JavaBlackBelt is a fast growing community whose members take tests to assess their skills in various Java-related topics. The tests themselves are created also by the site’s members. A small number of Ruby enthusiasts is currently working to add a Ruby exam to this Java-oriented site. I interviewed Mr. John Rizzo, one of JavaBlackBelt’s founders, and asked him what JavaBlackBelt has to offer Java and Ruby developers.

Danny: Why do we need JavaBlackBelt if we already have Sun’s Java certificates?

John Rizzo, co-founder of JavaBlackBeltJohn: We felt that, in the real world, with real teams and real projects, we have no way to assess, in an objective way, Java developers. Java requires so many things to learn. Sun is responsible for many Java apis, like JMS, Java2D, Swing, JDBC, servlet, EJB and so on. But their exam covers only a very small part of that. For example, the Sun Certified Java Programmer (SCJP) is a coverage of a small part of Java SE; JDBC, simple database access, is not even in it. And there are so many other tools and apis that are covered by other groups: Jakarta, Eclipse, jBoss. Their core business is developing their framework, not doing certifications. So there is nothing for this. If you see what a Java developer has to learn the first six months, or the first one or two years, to be productive in a project… All these technologies, and certification covers a very small part, maybe less than 10%. This is the first reason.

The other reason is that when you have three years of experience as a Java developer, and you’d like to do the first Sun certification (SCJP), you still need to study for a few days before you can take the test. Is that normal? You are an experienced developer, and you need to study, before Sun recognizes your skills. That’s why the exams on JavaBlackBelt are made keeping in mind that the candidates have all the resources available. Books, Eclipse, Google, whatever. They can search the web, search the Java apis, they can try things out in Eclipse. They’re only limited by time. They don’t have to remember things by heart. But the exams are hard, even with that. It depends on the exams, we also have basic exams, to help the beginners and to encourage the beginner to learn. Like Ruby Basic for example. And then we have more advanced exams; not just one big certification with a lot of questions.
Continue Reading »

2007-01-29. No responses.

Swinging With Swiby

After yet another inspiring presentation by Romain Guy at last year’s JavaPolis, I’ve taken more interest in programming Swing. I programmed desktop applications for many years, using mostly Delphi. Now, after some years of web application development, discovering Swing is like finding back a long-lost friend. Why oh why did we ever turn our backs on desktop programming and open this Pandora’s box of browser incompatibilities, stylesheet hacking, a multitude of web frameworks, html files full of JavaScript, JSP files full of scriptlets, back-button-workarounds etcetera etcetera?[1] Fortunately for me, after about ten years of existence, Swing finally has a decent GUI builder as well: Matisse–even if I have to endure NetBeans to use it. At the moment, I’m working on a Swing-based variant of Picasa‘s auto-collage function (which is a nice idea but only has limited functionality).

You will probably know that Swing GUIs can be programmed as well as designed with a GUI builder. That is generally not a very pleasant activity: the code is verbose and you don’t see what you get right away. Following the ancient principle of “use the best programming language for the job, and if there isn’t one, invent a new language”, Chris Oliver developed F3, a Java-based declarative language for GUI development. In other words, a fine example of a Domain Specific Language. So maybe it was only a matter of time before someone took Ruby (great for implementing DSLs), JRuby and F3, connected the dots, and created an Ruby implementation of F3 for the Java platform. That someone is Jean Lazarou, and he named his creation Swiby. Swiby looks something like this:

require 'swiby'

class HelloWorldModel
  attr_accessor :saying
end

model = HelloWorldModel.new
model.saying = "Hello World"

Frame {
  title "Hello World F3"
  width 200
  content {
    Label {
      text bind(model, :saying)
    }
  }
  visible true
}

The question remains what you would use this for. For designing GUIs, I would still want to use a GUI builder like Matisse rather than having to code everything myself. Maybe the GUI builder could be made to generate F3/Swiby instead of spitting out endless lines of badly formatted Java gibberish. Maybe it could be made to work with a Ruby GUI library, for fast prototyping. Or maybe the Swiby code could even be used to generate… a web application?

 

[1] I’m not serious here, of course. I really love the browser and everything that comes with it.

2007-01-24. One response.

JavaPolis 2006: The Day After

Five days after my nightly arrival in beautiful Antwerpen, I drove back over those same dreary roads to Holland, to my home. Five days that have flown by. I’ve been completely submerged in mixture of Java and a little Ruby. Everything I heard about, everything I spoke about, even dreamt about, was Java. I’ve got so many new ideas, so many things I’m eager to check out or try out:

Many thanks go to Stephan Janssen and the rest of the JavaPolis team for organizing this superb event! I’ll be back next year.

2006-12-16. No responses.

Revenge of the Groovy Guys

Okay, okay, I’ll humbly admit I was wrong. A little bit. About ehm… that Groovy thing. An inspiring session by … about the Grails framework made me see things from a different perspective. There’s actually some quite nice features in Grails that could well be of use in Rails (or in some cases, Rails on JRuby).

For example, I’ve been looking for some time now for a system that would allow custom html tags in Rails’ rhtml files. The idea is to allow for all sorts of html tags, for example

  <r:for_each list="some_list" var="item">
    <li><%= @item %></li>
  </r:for_each>

This would then trigger a method named for_each (e.g. in a app/helpers/application_tags class) which could process the passed inner html block in any way you want (in this example, probably looping through some_list). Even though Ruby code in rhtml is usually not hard to read, it would still clean things up a bit and get rid of some duplicate code.

In short, it turns out that Grails already has this. Grails also has deployment to war (which is still experimental in JRuby, it’s the first thing I’ll try out once I’m back home from Belgium). And because Grails is built on top of Spring and Hibernate (amongst others), it’s easy to script-prototype your model classes that could be Hibernate-mapped or EJB3s. To be honest, that one isn’t any more difficult in JRuby if you see how easy it is to call any EJB.

Another interesting Groovy/Grails language construct I saw:

Book.get(params.id)?.true

The interesting part here is the question mark operator. This will (apparently) check if get() returns null, and if so, prohibit an error being thrown. There was an interesting discussion about this some time ago on rubyenrails.nl (in Dutch; I’ll post the link when I’m home), looking for ways to do this in Ruby.

All in all, I’m still not comfortable with the Groovy syntax (too many curly braces and arrows; and I’m missing semicolons at the end-of-lines–it’s not Ruby after all!) but there’s definitely things to learn and shamelessly steal from those Groovy and Grails guys.

2006-12-14. 6 responses.

JavaPolis day 3 continuated

Wednesday afternoon, JavaPolis really got into gear for me. I saw short ‘quicky’ sessions on Unitils (don’t like the name but some of the features (assertion through reflection!) could be very useful to me, as I’m writing tests on a daily basis) and Strecks (Struts extensions that can easily be used in an existing Struts environment–all the more pity it requires Java 5; won’t most existing Struts-based applications still be using Java 1.4, like the project I’m on right now?).

Next, I did a lab on NetBeans and Matisse, the NetBeans gui design tool. It really brought back memories of my Delphi days. I must say, NetBeans feels slick and fast and stable. Add to that the Ruby support that Tor Norbye is working on, and this might well become my next IDE of choice. We got a small sample of that in Charles’ and Tom’s conference session on JRuby, which was next. Charles showed things like usage highlighting and local rename. It might not be spectacular for a crowd of Java-with-(probably mostly)-Eclipse coders, but you’ve gotta start somewhere! (But on the other hand, Eclipse so often gets it ‘just right’–like in 3.3, the local rename got enhanced to operate locally within inner loops; such a small thing but something that happens often enough).

By the way, if the JavaPolis team is listening: those labs could do with some more publicity. Only four people out of 2800+ showed up. Maybe because the labs are somewhere in the back of the conference guide; I just found out myself a few minutes before it started. Maybe because the location is a very dark corner of MetroPolis. Worse, there was a loudspeaker directly above the lab location, blurting out advertising for MetroPolis at a very high volume (every 2 minutes Eddy Murphy shouting “Show me the candy!”, argh!).

I liked Brian Goetz’ session last year, and this year he was just as enthusiastic, showing us the reality about some Java performance myths. I know now that object allocation is normally not slow, and synchronization isn’t always slow either. Best myth however was “Clever code is faster code”. It turns out that, in normal situations, the best performing code is cleanly written code, following standard guidelines. Java is not a one-liner language.

It had already been a long day when we sat down for Geert Bevin’s session on continuations–in Java. This is definitely a fascinating concept; for using it in web applications however, it just might be too different from the way we ‘normally’ do things. It requires nothing less then a paradigm shift in web app development. More info on continuations can be found on the RIFE site.

2006-12-13. No responses.

JavaPolis day 1: mixed feelings

When expectations are high, you’re invariably up for some disappointment. Charles and Tom were unable to demo Rails-in-a-war-on-Glassfish; but at least they gave a warning in advance. But I definitely expected something more–or rather something else–from Eric Evans’ university session on domain-driven design (ddd).

The afternoon session on scripting languages went well enough anyway–or at least, the JRuby part did. The session took off with a theoretical explanation of JSR-2something (the support for scripting languages in Java SE). After that, Charles and Tom got their chance to warm up the Java-minded public for all goodness of Ruby. It took a little while for them to get comfortable, but then Tom was at the keyboard showing the simplicity of building a small Rails app from scratch; and Charles got the flow of the presentation going, explaining what Tom was doing and going into JRuby details. The hour flew by for most of the audience. When I got back after the half our break, Charles and Tom were still answering questions.


Charles and Tom showing some well-known faces

Now you have to believe me, in the 90 minutes of Groovy that followed, I did keep an open mind. I tried to look at the code samples objectively. I tried to admire the work that has gone into creating a dynamic variant of Java. I really tried hard to imagine a scenario where I would be tempted to remotely consider using Groovy in a real-world app. Okay, and I was also just a little bit busy trying to get my laptop to talk to the JavaPolis wireless network, which wasn’t easy either. But at least that one I finally succeeded at. The Groovy thing–I’m afraid it’s not for me. It gives me the worst of both worlds: no sweet Ruby syntax, and on top of that uglified Java syntax as well. Maybe next time I’ll see the light. I promise to keep an open mind.

The thing that most disappointed me however, was Eric Evans’ morning session on domain-driven design. Not that it was a bad presentation, not at all. Maybe it’s all about expectations. I expected an introduction into ddd. What is it, what’s so great about it, why should we use it, what lessons have been learned, what tips can a ddd guru give us? Instead we got a session about domain modeling: how do we get from use case to domain model. And also, if we have multiple models within our application/organization, what patterns can we discern regarding the interfacing between those models and the teams that design them? Interesting enough, no problem there; but what does this have to do with ddd? Domain modeling like this can well be done without any domain-drivenness. Or can it? I’ll know more in a week or two, when Evans’ book that I ordered will arrive.

2006-12-12. 6 responses.

JavaPolis 2006, a good start

Just arrived in Antwerp, Belgium, for the JavaPolis 2006 conference which starts tomorrow morning. Same venue (Metropolis, where I stopped on the way to pick up this year’s goodies bag), same hotel (Astrid–yeah I know it has a tacky name but it’s really not that cheap). Fortunately, the state of Antwerp’s wireless networking has advanced in a year’s time; I now have free wifi in my hotel room as well as at the JavaPolis venue. Allowing me to write this short blog entry.
And so I won’t be accused of blogging just for the sake of it, just because I can blog, I will list the university sessions that I’ll be attending tomorrow.

  • First off is Eric Evans, talking about domain-driven design. This promises to be not only a theoretical introduction to the subject, but also an interactive domain modeling session. I’ve been looking forward to hear more about ddd since visiting Sogyo’s evening session two weeks ago. Especially as that session has left me confused whether Rails might be seen as a domain-driven development framework. I’m still not convinced; maybe tomorrow’s session will bring some clarification–and new arguments!
  • In the afternoon, I’ll be at room 4 for the Dynamic Languages session. More in particular, for the JRuby part of that one. Originally, this session was scheduled as an all-JRuby university session; but somehow, the Groovy guys have managed to squeeze their way in as well. I really don’t see the point of Groovy, other than proving that Java can be as cool as Ruby if only we mutilate the language enough and make it dynamic. I promise I’ll keep an open mind during their session tomorrow, though I don’t think I’ll be able to take in anything after seeing Charles and Tom perform the miracle of Rails-in-a-war-on-Glassfish.

The all new JavaPolis 2006 bag
The all new JavaPolis 2006 bag

2006-12-10. 2 responses.

Domain-driven Ruby on Rails??

Yesterday evening I attended a session on domain-driven design (ddd) at Sogyo‘s offices, a nicely converted farmhouse located somewhere in the center of Holland. I was amazed to hear Ruby and Rails being used as an example of domain-driven development. One of the presenters even claimed that Dutch Rubyists Remco and Michiel (who reached 2nd place at this year’s RAD Race, a programming contest) had done so well because they were able to work domain-driven, thanks to Rails.

Surely he was joking. If there is one data-centric framework out there at the moment, it has to be (my beloved) Ruby on Rails. Let’s see…

  • Rails’ “domain” classes (the model) are literally an implementation of the Active Record pattern, which has a direct coupling to corresponding database tables.
  • As a result, Rails’ model classes correspond directly to database tables; a change in your table (e.g. an extra field) is automatically a change in your model class.
  • Worst of all, DHH is actually on a mission to model the whole world under the constraints of CRUD.

I really don’t see how you can call this domain-driven. This is not to say that you couldn’t implement a domain model (as in ddd) in Ruby. But in my opinion, that is not what Rails is about. Rails is limited to the presentation layer, so its model is nothing more than a view model. For small scale applications that’s good enough. But if you need your business logic to be available independantly, to be accessible from multiple views (presentation layer applications), you’ll want to put that business logic in a separate layer, not in the model of one of those views. That is how I see “enterprise Rails”: as a tool to rapidly develop presentation side applications that use and combine existing business services (WS, EJB) (using JRuby on a Java application server).

The question remains if a domain model could be implemented in Ruby (not Rails). Technically, you could, of course. But would I want to? I’m not sure. It’s very reassuring to have the Java compiler checking your back and Eclipse’s refactoring tools at your disposal. You’d have to have some very tight unit testing to replace those and still feel safe about any changes you make. I mean, we’re potentially talking about a large company’s vital business rules here. Would I feel comfortable duck-typing those? On the other hand, there’s Ruby’s excellent DSL capabilities that would come in very handy for specifying exactly those business rules. What do you think?

2006-11-30. 9 responses.

The Hot and Cold Summer

So much to do in this hot and cold summer (July: 36 degrees, August: 16 degrees) and so little to blog about. In case anybody wonders, this is what I’ve been up to lately.

Gone back two years in time: After I finally left the WebLogic project in May, a little later than planned, I was re-assigned to the organization I worked at two years ago. It was as if time had stood still when I got back there. Not only because there were many familiar faces to welcome me, but also because the entire development environment was pretty much as I’d left it. So it’s back to Java 1.4, back to Struts, back to EJB’s, back to this pre-SOA SOA architecture… Then again, as someone asked me: what would I use instead of Struts? What indeed, if not Ruby and Rails? Does it really matter which XML-infested Java framework you use? Would Shale or Spring MVC make so much of a difference? I get by because there’s a lot of code and XML to copy/paste from, but the amount of code that is the result is frightening.

Trying to keep up with the insane tempo of the JRuby guys: After trying to get Rails on JRuby to work for my NLJUG presentation in May, with help from Charles Nutter and Tom Enebo, the JRuby protagonists, I kind of stuck around on the JRuby mailing list, which reads like a Dan Brown novel (well it does if you like coding). I even got a small job, rewriting Mongrel’s HTTP/1.1 Ragel parser to a JavaCC grammar (Why is there no Ragel-to-Java translator? I wish I’d had the time to write one. Now I had to use JavaCC, which was rather frustrating, either because of the limitations of JavaCC, especially in its idea of regular expressions, or because of my own limited knowledge of parsing–but it’s here, checked in in a fresh new RubyForge project, ) and it seems to be working. Mongrel will work completely with JRuby if Ola gets his JRuby extension framework going, allowing you to extend the Ruby language with Java libraries as easily as you can now with C libraries.

Organizing the Java Summer Camp 2006: After last year’s success with Simon Ritter‘s presentation of Java 5’s new features (fortunately no-one seems to remember the train mixup that got Simon 50km away from the venue and cause Rietje (office Mom) and me to pick him up there and drive back at questionable speed), Profict decided to do another Java Summer Camp this year. Like RubyEnRails before, this turns out to be very time-consuming. Finding a theme (Java & Ajax), speakers (Greg Murray! Bram Smeets!), visitors (90+, we’re fully booked!), a venue (another castle!), seats, food, sound system, camera, parking space…

Got my first production-worthy Rails application live: as a side note to the Java Summer Camp, I rewrote the small Rails app that I used to keep track of the RubyEnRails visitors. It can now handle multiple events, multiple users, it sends bulk email to visitors, it exports visitor data to Excel to keep the managers happy and it has a new and improved gui (which took me longer to design then it did to code the application itself).

Busy finding new colleagues: Yes I know, I should be proclaiming the wonders of Ruby and Rails at all times–but the truth is, I don’t hate Java, I don’t mind (that much) doing Java as a day job, and I don’t mind working for a Java shop. Although I’ll never quit dreaming of my own world empire, someday, somehow–in the meantime I’m very happy to be working for Profict. In spite of its focus on doing application integration projects (some people love diving in at the deep end, writing code that never sees the light of day; but I prefer staying near the surface, where the code reaches the user’s screens); but there’s enough work to do at the edges of integration: portals for one; and there are always the external assignments that I’ve been on for the last couple of years (what’s English for detacheren??). But what I really like about Profict is the fact that it’s small enough to know everybody (no huge consulting firm for me, thank you). It is a close group of mostly very experienced people, formed over the years only ‘by invitation’ (employers asking those people around them to join that they themselves would like to have as colleagues). So maybe I shouldn’t advertise the fact that we’re looking for still more people on my blog, for everyone to read–on the other hand, if you’re persistent enough to read this blog entry, you’re welcome to come talk (well, if you live in Holland anyway)! Okay, end of shameless commercial intermezzo…

Done a Grey’s Anatomy and The O.C. marathon: If you hate The O.C., you have got to at least love its theme song: California by Phantom Planet. That alone makes me want to go there (or at least as soon as flying to the US becomes a little more relaxed again). And Grey’s, what can I say: it’s little more than the 835th romance-in-a-hospital show (St. Elsewhere, Chicago Hope, ER, Medisch Centrum West) but there’s something that makes me want to keep watching–maybe Izzie? (A supporting character is usually my favorite: Summer in The O.C., Chloe in 24, Paris in Gilmore Girls, Starbuck in Battlestar and of course Locke in Lost; the exception is Prison Break).

Making the switch to Linux: Somewhere in the process of getting Subversion with SSH to work under Windows XP, which proved a hopeless case, either with or without Cygwin or VMWare, I decided to to finally make the switch. I shrinked my XP partition (I’ll still need it for graphics and photography work, as I just can’t get the Gimp to do what I want just as easily) and installed Ubuntu Dapper Drake. It feels like coming home (I worked with VMS and Unix long ago). It’s still not MacOS yet, but at least my 3GHz Dual Core cost just a third of Apple’s new beast

2006-08-15. No responses.

Next »