Explicit or implicit?

Development

As a developer, there’s an polarity of choice when it comes to frameworks regarding whether you would rather lean towards more compact code where most things are implied, or more verbose code where most things are laid out explicitly - most obviously in the web development sphere.

Ruby on Rails is continuing to be a hot property simply because it’s quite elegant and very compact for the functionality it delivers. If you’re making a relatively simple web-based, database-driven application there’s probably no faster way to do it right now - although significant concerns about practical scalability remain, perhaps Ruby 1.9 will make things better once Rails supports it. However, in order to deliver all this power, Rails makes a lot of assumptions about the way a typical user is going to want to organise things, such as driving the structure of the model from an existing database structure and auto-wiring views and controllers etc. It means that when you look at some Rails code for the first time, it can often be startlingly short and leave you wondering where the rest of it is.

In terms of rapid development, this is great. But, brevity does come at a cost, which is that when you look at the code, you’re not seeing the whole picture. That’s always the case to some degree when you’re working with OO or layered software, in that implementation hiding and the ‘onion skin’ effect mean that implementation details are always hidden somewhere. However, one difference is that in a less adaptive application development structure, the base implementation, the part you don’t necessarily see unless you start to heavily dig, is a constant - it’s invariant across all applications. Anything specific to your application will be there in the code, particularly the ‘assembly’ aspects - how it’s all tied together. When you bring in implicit configuration too, this is no longer the case - there’s some ‘magic’ in there that makes things ‘just work’, which is very cool, but it also kind of makes me feel a little nervous. Because what if it ceases to ‘just work’? How do I figure out what went wrong? If I’m looking at code someone else developed a year ago, will I be able to piece all the potential contributing factors together quickly, compared to developing a new app myself?

I had an experience a number of years back with a design tool that let you create complex (fat) GUI applications by dragging, dropping & wiring components visually. It was really impressive when building new things, and made it possible to create complex GUIs with appserver integration incredibly fast, writing almost no code at all. As time went on though, we found that while we could build things quickly, coming back to the more complex designs later to resolve issues became a bit of a nightmare, simply because picking apart all the ‘magic’ bits that were happening was problematic. When it worked, great, but when it didn’t it took a lot longer to figure out why. We found that in many ways it was like running into a tar pit - at first you were flying through it, but after a certain level of critical mass and complexity had been achieved you had a tendency to get bogged down. The metrics of effort versus output over time were not favourable, considering that a typical application spends far longer in maintenance than it ever does in initial development. From then on I’ve always been a little cautious when presented with tech that purports to make building applications fast, because I want to know that it also makes maintaining them fast too. I don’t have a handle on what Rails applications are like to maintain over a significant amount of time because I’ve never done it, obviously the ‘build’ phase is fast, but does it suffer from the problems I had with visual design tools to any degree, or does the high level of convention mitigate that (assuming your application fits into that slot neatly)?

On a purely developer level, I like things to be quick and no more verbose than they need to be, but I also dislike having to be too trusting. I’m never really comfortable when something ‘magically’ happens in technology and it’s less than obvious as to why - I tend to prefer a slightly more explicit line from cause to effect, simply because if I feel that if I can’t obviously see why something worked, how point A got connected to point B, I have a blind spot  which may well come up to bite me later. It’s also comforting to browse some source and see all the pieces slot into place, without any glaring gaps where ’stuff happens’. On balance then, I tend to prefer systems that are explicit, but at the same time I don’t advocate mindless verbosity - there’s a balance here. I quite like Spring in that regard, there’s a lot of prebuilt functionality packaged in there, but while the implementations are wrapped and out of the way it’s all wired up explicitly (unless you use auto-wiring, which I avoid) which for me is confidence building, I can browse the configuration and ‘connect the dots’ easily, dipping in deeper where I want to. It’s not what you’d call a rapid web development environment though; it’s convenient, powerful and very solid, but you’re unlikely to get a ‘20-minute app’ screencast out of it, which seems to be the primary measure of worth these days ;)

I’ve played with Rails a little, but have never used it for anything serious mostly because I’m afraid of the scalability issues I might encounter when it’s too late to do anything about it (except rewrite using something else) - once those scalability issues are resolved I may come back to it. In the meantime, if I had a need for truly rapid web development I’ve got my eye on alternatives such as Pylons or TurboGears, which share a lot with Rails but are based on Python which is somewhat more mature & proven for sizeable deployments, and they’re also a tad more explicit about some elements (like model definition) which I prefer. Whatever option I might choose, I would prefer to dig into the framework source to better understand how the automation that is there functions, rather than just accept it on face value. Rails, Pylons and TurboGears  are all open source of course so that’s at least possible - I don’t think I would ever use them if they were closed source, because ‘magical and opaque’ is the very worst combination I can think of. Not everyone feels like that I know, many people are happy to just trust that something works and move on (and in a closed framework like .Net, that’s your only real option), but over the years I’ve bashed my head against frameworks & libraries enough to dislike trusting things I can’t examine, trace through and even fix / extend when the chips are down. 

Any opinions?

Share this post: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • N4G
  • StumbleUpon
  • del.icio.us
  • Mixx
  • Google
  • blogmarks
  • Slashdot
  • Reddit

9 Responses to “Explicit or implicit?”

  1. Paul Evans Says:
    May 13th, 2008 at 7:14 pm

    Opinion? I’ve only ever been to talks about Ruby on Rails… I like the idea of how it versions databases. I like the English style 5.minutes.ago.

    I guess as I work with C# a lot of the time I am one of those “happy to trust and move on” guys. There are good communities around C# and .Net things - and even if it’s not open source there is a lot of information available about it, and you can *look* at a lot of the source via reflector, or even step in to some c# framework source if you have VS2008.

    C++ for the other part of my time, and I guess when I use libraries I tend to trust their function / object contracts and get on with it - and only check up on them when the source is available if something comes up through profiling or errors. In fact I could say the same of C#.

    I guess I’m fairly pragmatic, I tend to use whatever is available and seems the best fit for what I’m doing at the time. Though writing that seems rather wooly.

  2. Steve Says:
    May 13th, 2008 at 8:10 pm

    Not wooly at all - whatever works for you. We all use our experiences to judge what’s best in a given circumstance.

    Personally I’ve used quite a lot of closed libs & frameworks over the years and although it doesn’t happen that often, occasionally I’ve had serious blocker issues that the user community either didn’t know how to resolve, or I had an issue that was too specialised, and the official support guys (most often MS, Oracle or IBM) sometimes took a while to figure out - and even then it might be a ‘wait until the next fixpack’ kind of issue, with hacky workarounds in between. Generally with the open source stuff I’ve encountered fewer (or in most cases no) absolute blocker issues. That’s simply because there are more people familiar with the code - not just looking, but changing - and thus more variety of experience (and thus more chance someone who both knows the code and understands the issue is contactable). Worst case, I can always put a patch in myself if I’m in a tight spot. It’s led me to the conclusion that I just feel more comfortable that I won’t get stuck on an edge case when using open source. It doesn’t mean I won’t use closed source libs anymore, I just prefer not to if good alternatives are available.

  3. Sören Meyer-Eppler Says:
    May 13th, 2008 at 8:25 pm

    Your points remind me of Joel Spolsky’s article about “Leaky Abstractions”:

    http://www.joelonsoftware.com/articles/LeakyAbstractions.html

    regards,

    Sören

  4. Steve Says:
    May 13th, 2008 at 9:25 pm

    Thanks, it seems once again I’m doomed to reach conclusions that others have raised several years ago :?

  5. Randal L. Schwartz Says:
    May 13th, 2008 at 9:37 pm

    Have you seen Seaside (http://seaside.st)? I think it’s even more elegant, and faster to develop, and faster to execute than RoR. And it’s written in Portable Smalltalk. Check it out.

  6. Mark Ramm Says:
    May 14th, 2008 at 12:48 am

    I agree. I did some rails work before joining the TurboGears project, and one of the the first things I noticed was that TG had explicit imports so I knew where to look to find out how things were being done, while in Rails you often had to know where to look before you could even find the code you needed to read to understand the magic.

    I liked lots of things about rails, but convention over configuration shouldn’t be pushed so far.

  7. Steve Says:
    May 14th, 2008 at 9:04 am

    @Randal: interesting, I haven’t used Smalltalk in many, many years :)

    @Mark: yeah, I also feel more comfortable with defining model state in my code rather than it being implied from the database. I think you should only base code on data for legacy dbs, for new systems it feels more natural the other way around.

  8. Stodge Says:
    May 14th, 2008 at 4:21 pm

    Haha! I loved the celebrity example in Joel’s article, though I’d gladly let most of them travel via IP. I won’t complain if 95% of all Hollywood actors don’t arrive at their destination.

    Interesting article - I love abstraction, or packing in the sense of presenting a clean API to a developer. But I think I’ll have to spend more time thinking about “leaky abstractions” as I’m currently prototyping an in house API.

  9. Tau Says:
    May 19th, 2008 at 9:47 pm

    I’m embracing Python myself because of Google’s AppEngine… and I agree - among other languages, it’s one of the most mature and robust. The only part I dislike with Python - its whitespace paradigm…

Leave a Reply