Slashdot Mirror


Ruby on Rails for DB2 Developers

An anonymous reader writes "Ruby on Rails seems to be the new hotness in the world of web development, right up there with Ajax. IBM DeveloperWorks has a helpful howto on how to bring the worlds of Ruby on Rails and your DB2 framework together. From the article: 'Because Rails emerged from the open source world, until recently you had to use MySQL or PostgreSQL to work with it. Now that IBM has released a DB2 adapter for Rails, it's possible to write efficient Web applications on top of your existing DB2 database investment.'"

34 of 128 comments (clear)

  1. Ruby on rails? by StaticFish · · Score: 3, Funny

    In the UK we've only just got trains to go on rails.

    --
    - There's no place like 127.0.0.1
  2. Ruby could be packaged better by bogaboga · · Score: 4, Insightful
    I have read about the beauty of Ruby and how it's better than Python or Perl. I'd not like to start flames but I wonder why Ruby does not have an IDE like that of SmallTalk. Yes, SmallTalk is old time stuff, but this absence does not help Ruby's popularity.

    Many times, I have tried learning it on my own and have been frustrated by missing or conflicting versions of components. I'm waiting for some folks to develop a one install package that will take care of all packages needed to develop serious apps on Ruby. An IDE like Access on the JET database engine would be very welcome.

    There is some effort to this end. These folks http://www.railslivecd.org/ have started some work in this direction.

    1. Re:Ruby could be packaged better by ricardo_nz · · Score: 3, Informative

      You should try Ruby Gems to solve your packaging woes. As for an IDE, there are plenty available: http://freeride.rubyforge.org/wiki/wiki.pl and http://www.mondrian-ide.com/ though I can't say much about them...

    2. Re:Ruby could be packaged better by flipper65 · · Score: 4, Informative

      Actually, if you are looking for a rails IDE I strongly suggest that you check out http://radrails.org/ available both as stand alone and as an eclipse plugin.

    3. Re:Ruby could be packaged better by 12ahead · · Score: 5, Informative

      Not sure what system you are on, but for osx there is Locomotive. You will get a magnitude of libraries (I guess the DB2 stuff won't be in there just yet) plus a nice gui to start/stop webservers for your Rails projects. Not sure if you were after Rails or plain Ruby, but anyway.

      On the IDE front you could check out RadRails. Again, this focuses on Rails instead of "just" Ruby.
       
      However, I do believe that Ruby is one of those languages that you can learn by just using it from command line. You do not need an IDE or huge framework to do fun stuff. You can at least get a feel for how Ruby does stuff to put you off it or to keep investigating.

    4. Re:Ruby could be packaged better by masklinn · · Score: 2, Informative

      Mostly because Smalltalk came from PARC and was built to work in an environment (BTW there is no Smalltalk "IDE", they're environment and you work in an image within the environment, it's a much more impressive concept than the simple concept of IDE which is merely a beefed up text editor)

      Ruby was built as a programming language and as a language only, it wasn't built with the idea of environments in mind and the editors/ides therefore have to be bolted on. Plus Ruby only recently started to get widespread adoption in occident (and fyi Python doesn't have many good IDEs and it's been popular for a much longer time in occident than Ruby).

      About the packages issue, I can't help but tell you to learn how gems work, as it automagically handles dependencies and package versioning...

      --
      "The way we can tell it's C# instead of Haskell is because it's nine lines instead of two." -- wadler
    5. Re:Ruby could be packaged better by masklinn · · Score: 2, Informative

      As an example: I'm trying to get FeedTools going for a week now. There's a gem installation available, but it seems even the developers don't trust it and recommend a manual installation.

      Uh? I find pretty much the opposite statement on the front page of the FeedTools project:

      However, the preferred method of obtaining FeedTools is with RubyGems because of FeedTools' dependancies on other gems.

      Works like a charm too:

      $> gem install FeedTools -d -y
      Attempting local installation of 'FeedTools'
      Local gem file not found: FeedTools*.gem
      Attempting remote installation of 'FeedTools'
      Successfully installed feedtools-0.2.24
      Successfully installed uuidtools-1.0.0
      Installing RDoc documentation for feedtools-0.2.24...
      Installing RDoc documentation for uuidtools-1.0.0...
      $> irb --simple-prompt
      >> require 'feed_tools'
      => false
      >> slashdot_feed = FeedTools::Feed.open('http://www.slashdot.org/inde x.rss')
      => #
      >> slashdot_feed.title
      => "Slashdot"
      >> slashdot_feed.description
      => "News for nerds, stuff that matters"
      >> slashdot_feed.link
      => "http://slashdot.org/"
      >> slashdot_feed.items.length
      => 10
      --
      "The way we can tell it's C# instead of Haskell is because it's nine lines instead of two." -- wadler
    6. Re:Ruby could be packaged better by MarkWatson · · Score: 4, Informative

      Actually, I find the Eclipse RDT and RadRails plugins to be very good (I work in this environment 8 to 15 hours a week).

      I had another more radical thought yesterday: just for fun, I installed the latest stable build of Squeak Smalltalk - years ago, I had done some natural language processing work with Squeak and I wanted to look at a newer version. Any, the idea: Smalltalk and Ruby are similar enough, that for non-GUI applications it would not be so hard to write a translater from Smalltalk to Ruby for deploying small utility applications.

      The performance of Ruby is not so great (I just had to switch part of my current project from Ruby to Common Lisp for performance), but it would be neat to be able to use a Smalltalk enviroment, and "compile to Ruby". Anyway, this is an idea that probably lacks merrit because professional versions of Smalltalk like VisualWorks have very good deployment tools (small size, low memory requirements) and even with the free Squeak system, with some effort you can build smaller "headless" applications.

      Back to Ruby: I find Ruby installation to be easy, and the rubygems system is great. The Ruby community is friendly and helpfull.

    7. Re:Ruby could be packaged better by Cryp2Nite · · Score: 2, Interesting
    8. Re:Ruby could be packaged better by Decaff · · Score: 2, Insightful

      However, I do believe that Ruby is one of those languages that you can learn by just using it from command line. You do not need an IDE or huge framework to do fun stuff. You can at least get a feel for how Ruby does stuff to put you off it or to keep investigating.

      There is very strong evidence based on decades of research (such as with Smalltalk in the 70s) that says that the best way to learn and use OOP languages is with a good GUI. There is nothing to match browsing classes and dynamically inspecting objects during the execution of a program.

      I am very skeptical whenever I hear 'you don't need a GUI'. This seems to me to be an argument along the lines of 'if we don't implement it, you don't need it'.

    9. Re:Ruby could be packaged better by aCapitalist · · Score: 2, Insightful

      I am very skeptical whenever I hear 'you don't need a GUI'. This seems to me to be an argument along the lines of 'if we don't implement it, you don't need it'.

      Actually, it's "You don't need it until we actually implement it". That's pretty typical of the linux-type crowd though that have always screamed that Vi and Emacs are the epitomy of advanced development environments.

  3. DB2... The only change? by Aladrin · · Score: 4, Insightful

    I can understand wanting to get news of the DB2 adapter out to the public... But to attach a tutorial to it that is basically just another RoR tutorial seems pointless. The only differences in this article from every other RoR article were in the paragraph that describes how to install the DB2 adapter for RoR.

    -yawn-

    --
    "If you make people think they're thinking, they'll love you; But if you really make them think, they'll hate you." - DM
  4. Re:DB2... The only change? by Anonymous Coward · · Score: 5, Insightful

    But to attach a tutorial to it that is basically just another RoR tutorial seems pointless.

    It's called "jumping onto the bandwagon"; you may have heard of it. It's what all of IBM's "cutting-edge" developerworks-articles (written by some sophomore pimply FOSS-monkey intern) are about.

  5. Really good news. by marcello_dl · · Score: 5, Interesting

    Getting the likes of IBM to recognize the usefulness of the Rails framework is a little more than just another DBMS supported: rails used to be bashed, especially by java people, for not being "enterprise ready". They criticised the limitations of the active record ORM (but it's open source, you can either extend it or make your custom sql calls), or the relative immaturity of ruby and libraries.

    Now such claims will sound less credible so more dubious people might give it a try.

    --
    ---- MISSING MISCELLANEOUS DATA SEGMENT --- [sigdash] trolololol
    1. Re:Really good news. by Decaff · · Score: 4, Insightful

      Getting the likes of IBM to recognize the usefulness of the Rails framework is a little more than just another DBMS supported: rails used to be bashed, especially by java people, for not being "enterprise ready". They criticised the limitations of the active record ORM (but it's open source, you can either extend it or make your custom sql calls), or the relative immaturity of ruby and libraries.

      Now such claims will sound less credible so more dubious people might give it a try.


      IBM has been hosting articles about RoR for some time - this is not a major change in attitude - it is indeed simply getting just annother DBMS supported. Rails is bashed for not being enterprise ready for more than just the range of databases supported. This additional support does nothing to change the limitations of the Active Record approach (and the ability to extend the system does not make it enterprise ready).

      There are many aspects of Ruby and Rails that remain a significant barrier to much enterprise use - performance, for one thing (Ruby VMs that might address this problem seem stuck in permanent beta), the ability to handle international characters is another.

      To assume that these issues are somehow fixed simply because IBM has provided DB2 support is nothing more than wishful thinking.

    2. Re:Really good news. by jizmonkey · · Score: 2, Informative
      Wait. I don't develop Ruby. But you're not honestly telling me that it doesn't at least have support for UTF-8, are you? I would have thought that UTF-8, at least, would have been a given for such a project. Is the support only partial, or is it limited, or... something?

      The (Japanese) creator of Ruby thinks that Unicode sucks, and therefore Ruby has only half-baked support for Unicode. There are patches to make Rails work with Unicode but they're a little flaky.

      --
      With great power comes great fan noise.
  6. Re:RoR vs Django? by amaupin · · Score: 3, Interesting

    Haven't tried Django, but while Ruby on Rails is making progress, it's still no match for the power and flexibility of Zope.

  7. Re:RoR vs Django? by teg · · Score: 2, Interesting

    Haven't tried Django, but while Ruby on Rails is making progress, it's still no match for the power and flexibility of Zope.

    I've been programming python for many years now - I've not used Django, but after reading the docs etc. it looks like yet another "Ruby on rails is popular, let's make something!" which is nowhere near finished. One nice thing about Ruby on Rails is focus - the entire ruby community seems to be on the bandwagon, driving it forward and integrating nicely with it. This means that docs, libraries etc are there for you.

    Zope is way too complex... when you know easily how to get most of what you want to do in python scripts from straight database tables, you'll hit your head against the wall for ages converting this from python code to Zope and its evil ZoDB[1]

    [1] The one good reason for using ZopeDB is that Python's database libraries need a large overhaul. Consistency is badly needed (making things like quoting etc. driver dependent... which sick mind thought that was a good idea?), and why are there so many drivers? There shouldn't be a need for much more than one for each database - and e.g. in the case of PostgreSQL, that should be the bundled one. pyPgSQL, PyGreSQL, Psycopg, PoPy, Proboscis.... and I'm sure I forgot some. The perl DBI interface was more pleasant to use almost 10 years ago than the python DB interface is today. JDBC also got it right. A de-facto standard python ORM would be nice too.

  8. Re:RoR vs Django? by masklinn · · Score: 5, Informative

    I've tried a bit of both, and from what I've seen:

    • Rails does more user-related stuff automagically, but doesn't build your administrative interfaces (you have to do that yourself). Django's admin interfaces are dead-easy to build and gorgeous to boot (as far as admin interfaces can be I mean).
    • Rails does a lot of things by itself, but you have to follow the Rails Path/Rails Way/whatever. It's name means it all, if you veer too far from how DHH intended Rails to work it breaks (in the sense of "it makes your life a living hell), while Django is much more flexible. If you don't like the way Rails work you're screwed while with Django you can recover. The plus side is that Rails does a lot of things for you if you follow The Rails Way.
    • I quite like the ActiveRecord ORM pattern. On the other hand i'll repeat the last point: if you want to switch to another ORM pattern or ORM period, you're going to have a hard time. Django makes it much easier to switch to a non-default ORM engine (the impressive SQL Alchemy for example)
    • Rails' quite static (directories) structure make it... well.. structured. You don't want to bend the directory structure too much (see point 2), but it's usually well thought of and gives a very clean feeling. Django "feels" much less structured out of the box.
    • Testing is strongly emphasized in Rails, and it goes a long way towards helping you write as many Unit (for models) and Functional (for controllers) tests as you can write. And every time you generate models or controllers Rails will create test stubs that you just have to fill.
    • ERb. Basically, you write your templates (views) in Ruby. This means that Ruby's templates are much more powerful than Django's (out of the box) templates, and you don't have to learn another language and switch between Ruby and your-template-language. On the other hand, Django's templating language makes it much simpler to use by designers (ERb is much more fit to coders, and the Django team considered that coders didn't know jack about web pages and weren't supposed to go near the stuff). The downside of ERb is -- of course -- that since it's much more powerful (you have the full power or Ruby available) you can turn your templates into a PHP-like crapfest with whole bunches of application/model logic in them.

    I haven't build any big application with either yet, I don't have any real preference yet (I know more about Rails than Django though), but how I see it ATM is that way: if I need an extremely extensive admin interface, I'll just go with Django, the admin scaffolds just save too much time. If I don't need that extensive admin interfaces I'll go for the most well-known language in the team (if I have Pythonistas I'll pick Django, if I have rubyists I'll go with RoR).

    --
    "The way we can tell it's C# instead of Haskell is because it's nine lines instead of two." -- wadler
  9. Re:RoR vs Django? by masklinn · · Score: 2, Interesting

    after reading the docs etc. it looks like yet another "Ruby on rails is popular, let's make something!" which is nowhere near finished

    It's not, both are extremely different from one another (and even more since the Django guys went the magic_removal route). And while Django is not finished (nor is rails) it's very much production ready.

    why are there so many drivers? There shouldn't be a need for much more than one for each database - and e.g. in the case of PostgreSQL, that should be the bundled one. pyPgSQL, PyGreSQL, Psycopg, PoPy, Proboscis.... and I'm sure I forgot some. The perl DBI interface was more pleasant to use almost 10 years ago than the python DB interface is today. JDBC also got it right. A de-facto standard python ORM would be nice too.

    I hear you, that's probably the biggest issue with the Python community, this "No tool does exactly what I want, so I'll just build a new one, no point in extending an existing one" attitude.

    Brings some interresting stuff to the table though (have you tried SQL Alchemy in your Quest For An ORM?)

    Another Python issue is that the community can hardly bring itself to standardize things, and even then people usually try to build even more tools (sometimes better though, see py.test versus STL's unittest, or effbot's ElementTree which will finally be part of the STL with Python 2.5 versus the whole xml package crapfest)

    --
    "The way we can tell it's C# instead of Haskell is because it's nine lines instead of two." -- wadler
  10. Re:DB2... The only change? by Decaff · · Score: 4, Insightful

    Massive databases often support multiple presentation layers - ecommerce, internal administration, parter access, internal reporting, etc, etc. Even if you're doing one in Java/websphere there's no reason another couldn't be in RoR.

    There is good reason why you may not want it to be. The Java/J2EE/Websphere approach often uses clustering and cacheing to give high performance and scalability. You would not want to let a small RoR application (or any other type of application) loose on such such a system.

  11. I find it hard to believe that by Mofaluna · · Score: 3, Insightful
    Now that IBM has released a DB2 adapter for Rails, it's possible to write efficient Web applications on top of your existing DB2 database investment.
    While much can be said in favor of RoR, especially the fact that the approach is the best thing since sliced bread for a certain 'niche' market, non-enterprise applications, the above quote is wrong. There is a huge difference between efficiently writing web applications, that which Ror is good at, and writing efficient web applications, that which RoR traded of in favor of efficiently writing web applications.
  12. Re:Not as hot by SilentBob0727 · · Score: 2, Interesting

    As an example of the hype machine in action, I recently interviewed for a web developer position. When the subject of my AJAX experience came up, I said that I had extensive experience. He then asked about my Ruby experience, which I said was limited. He then laughed -- LAUGHED -- and said "What are you talking about? AJAX is a *part* of Ruby!" Clearly I had no experience in either technology and was lying "because otherwise I would know this", and the interview went downhill from there.

    --
    Life would be easier if I had the source code.
  13. Re:RoR vs Django? by jcroft · · Score: 2, Informative

    Django did start out in publishing (I should know, I'm the senior designer for the publishing company that created it). But, since then, it's been developed greatly to work well in other application-type environments. While Django still excels at content-heavy sites, and you can see the roots are in publishing, I would contend it's every bit as capable for more transaction-based web apps as Rails is.

    --
    ----------
    Jeff Croft
    http://jeffcroft.com
  14. Re:DB2... The only change? by kpharmer · · Score: 2, Interesting

    > There is good reason why you may not want it to be. The Java/J2EE/Websphere approach often uses clustering and cacheing to give
    > high performance and scalability. You would not want to let a small RoR application (or any other type of application) loose on such such a system.

    It depends:
      - I'd bet that 9 out of 10 websphere/weblogic implementations don't use clustering
      - many massive databases have relatively modest websites, ie the heavy-lifting is all backend not presentation
      - many massive databases have small related "helper" applications that also need presentation layers
      - even clustering & caching applications should be able to handle changes to reference data through simple cache-refresh methods.

    Fortunately for me, most of my massive databases get php front-ends these days. And hopefully RoR soon.

  15. Re:RoR vs Django? by jcroft · · Score: 2, Insightful

    I would say this is a bit of the Python philosophy showing up in Django: Explicit is always better than implicit. Obviously Rails doesn't share this philosophy, and that's fine. But Django definitely intends to be very Pythonic, and model definitions are no exception.

    --
    ----------
    Jeff Croft
    http://jeffcroft.com
  16. Re:I imagine... by kpharmer · · Score: 3, Informative

    > I imagine that all three people who use DB2 are quite pleased with this development :)
    > What kind of market share does it have?

    Depends on how you count it. I think by revenue IBM databases account for about 1/3 of the market. This primarily consists of db2 but also includes numbers from informix and ims.

    > Seriously, I haven't seen any person or development shop in my area using DB2. I've never heard of it being used at all.

    It's used heaviest on the mainframes, but also works very well on windows & unix/linux. After having spent decades developing databases using db2, oracle, informix, sybase, sql server, postgresql, mysql, access, clipper, ims-db, vsam, etc - I've grown to like db2 quite a bit (and Informix the most). DB2 is far faster than mysql or postgresql, and about 1/2 the cost of oracle.

    The primary reason it doesn't have a larger marketshare is that IBM isn't very good at marketing, and until about four years ago its unix/windows version was a little clunky.

    DB2 works fine for small projects where it is very cost effective, but you typically see it the most on very large projects. It especially shines when your data volumes keep growing - then it gives a ton of different scalability options - all the way up to very robust beowulf-like clustering capabilities in which you can spread your database across hundreds of separate servers. For large projects like this its only real competition is Informix or Teradata.

  17. Re:RoR Question from JAVA newbie... by mr_rattles · · Score: 3, Interesting

    The API is designed for Java/.Net and you think it's a good excuse to learn Ruby? Wouldn't it be a better excuse to learn Java or .Net? Also, you said it yourself that it's a simple app so I don't think you need to bend over backwards "designing" a "full-fledged" Java app either. Just write the simple app using whichever API makes most sense for whatever you're interfacing with. On one side you say you have a Java/.Net API but what do you need to interface that with, another Java/.Net app? If that's the case your decision should be obvious.

  18. Unicode? by jopet · · Score: 2, Interesting

    Does it already properly support Unicode? Not everyone uses just English texts and the best and most common way to use characters of other languages is UTF-8.

    1. Re:Unicode? by RegularFry · · Score: 2, Interesting

      Which? DB2 or Rails? I'm assuming that DB2's got multilingual wrapped up pretty well. As far as Rails goes, there are a couple of handshakes to perform (set headers, set $KCODE, prod the DB in the right way if necessary), but once they're done, everything's just a bunch of bytes. Ruby's Unicode support isn't great (there's an active discussion about the best way to fix it up on ruby-lang right now), but 95 times out of 100 it doesn't cause a problem.

      By the way, one of the sticking points about the Unicode issue with Ruby is that the opinion that "the best and most common way to use characters of other languages is UTF-8" is not universally held. It might be the most common, but many learned and respected individuals think it's not the best.

      --
      Reality is the ultimate Rorschach.
    2. Re:Unicode? by jopet · · Score: 2, Interesting

      Since this was essentially about Rails getting DB2 support I implicitly addressed Rails/Ruby - sorry for

      In the meantime I did some research myself and found the sobering fact that Ruby/Rails essentially does NOT support Unicode in any usable way.

      A string of Unicode characters is NOT just a bunch of bytes: take the simple operation of finding the length of a word or reversing it: both string functions return nonsense in Ruby, if there is any character encoded in more than one byte in the string.
      That Ruby does not know anything about the encoding of its strings is causing lots of other problems, especially in context where one has to work with strings in different encodings (e.g. multilingual applications, applications based on texts derived from web sites).
      Ruby makes it unnecessarily difficult to do things in those cases.

      I have the impression that people tend to highly *underrate* this problem: for many of those applications I have written yet, support for Unicode and encodings like UTF-8 were quite essential.

      Regarding your statement about whether UTF-8 is the best way to encode characters I have to say: it depends - on the language and the source of your data. E.g. when your data comes from UTF-8 encoded database fields, it is not very pretty to re-code it into some one-byte encodig just to work around the Ruby shortcoming -- and in some cases this is not even possible.

      I really love the design of Ruby, but this is one of the biggest shortcomings in a modern programming language (unfortunately shared by several other more current languages).

      As much as I hate Java, at least they made it possible to do these things right from the start.

  19. Why Ruby? Why Rails? by mangu · · Score: 2, Insightful
    In all these articles about Ruby and RoR people always mention how great Ruby is and how great RoR is. After trying both, I must assume that I must be pretty stupid, because I fail to notice all that greatness. Let's see some case studies:


    1) I work for an aerospace company, and I recently needed some way to get NORAD TLEs from Celestrak. Never mind what TLEs are, I went to CPAN and found what I needed in a few minutes. How does Ruby compare to Perl in available libraries and utilities? If I have to get the TLE specifications and code my own functions in Ruby, sorry, but I'd rather cope with Perl's shortcomings.


    2) Occasionally I have to do some web applications to access corporate databases in Oracle, Ingres, and Postgres. The data contains international characters, which may be in UTF or ISO-8859, I need support for both and an easy way to shift between them, often in the same application. For this kind of work I use PHP together with the eGroupWare suite. I have no need for very complicated code here, these are mostly simple web forms and tables, which PHP+eGroupWare handle quite well. Using the built-in etemplates utility I can code applications very quickly.


    3) For really complex work I use C, or C++ with Qt if there is need for a GUI. I often create prototypes for my C code, using either Perl, Python, or Matlab to develop some of the algorithms. After I have the algorithm, I reimplement it in C using the many libraries available, such as GSL, Lapack, or FFTW, for instance.


    With all that, I have yet to find a reasonable niche where Ruby would fit, with or without Rails. I can see how someone who wants to learn only one language would think Ruby is the best, but I cannot imagine being more productive in Ruby than in the languages I use for each of the jobs I described.


    And the attitude one finds in Slashdot "hey stupid, Ruby is 'teh' language, you must be a troll" doesn't help either. For any other language I can find websites that give detailed descriptions of its good and bad points, but I have seen very little on comparing Ruby with other languages. From the little I have seen, it gives the impression of being somewhat remotely related to Lisp, like Python. How about creating a site that shows some examples comparing code written in Ruby with the same program in Python, Perl, C, PHP, Java, etc?

  20. Re:Not as hot by I+Like+Pudding · · Score: 2, Interesting

    I would actually consider this a good thing. This guy let on that he didn't know what the hell he was talking about right up front at the interview, on top of demonstrating a lack of professionalism - a great time to walk, assuming you weren't hurting for the money. I wish every company were so forthcoming about their flaws.

  21. Re:Not as hot by domukun367 · · Score: 2, Interesting

    It sounds like you were saved from having to work with morons there SilentBob.

    I view a job interview as a chance not just for them to find out about me, but a chance to find out whether they are a group of people worth working for.

    --
    Please don't send a Word document when a text file will do the job.