Slashdot Mirror


Ajax On Rails

mu-sly writes "Ajax and Rails - probably two of the biggest buzzwords in web development at the moment. In this article over at ONLamp, Curt Hibbs introduces the incredibly powerful Ajax support that is part of the Ruby on Rails web application framework. It's a great read, and serves as a gentle introduction to the cool stuff you can accomplish with ease using the Ajax features of Rails."

42 of 235 comments (clear)

  1. Rails, great for those fed up with J2EE. by newdamage · · Score: 5, Interesting

    I'm sure many developers like myself have a day job that probably involves J2EE. The first time I did the iniitial tutorials for Rails several weeks ago I was blown away. Connecting to a database is not susposed to be this easy.

    Even when using newer frameworks like Spring, Tapestry and Hibernate (I hate you so much Struts) Rails still manages to be easier.

    I highly suggest any developers looking for a change of pace at least give Ruby on Rails a few hours of your evening. While it's not nearly as comprehensive as Java, it's gaining libraries and functionality by leaps and bounds.

    And just so I don't get labeled as a Rails fanboy/Java basher: Rails is not perfect, I still would recommend using J2EE for large corporate projects. It's just a much more mature solution with less unknowns. I think Rails needs another year at least before people are ready to really give it a shot in the corporate environment.

    --
    ce n'est pas un Sig.
    1. Re:Rails, great for those fed up with J2EE. by Uber+Banker · · Score: 2, Interesting

      I've not tried RoR from a development perspective (I have no need/desire to write web apps), but from a user perspective it rocks! Well done Javascript can be a nice user experience, but sites that need regular reloading rarely use it, the main exception I can think of being Gmail.

      RoR, IMHO, is a major step forward to web deployed applications becomming mainstream.

    2. Re:Rails, great for those fed up with J2EE. by Cyberax · · Score: 3, Interesting

      Ruby is easier. Until you try to do something even moderately complex.

      Our company recently tried to do a web-project (workflow management application for a publishing house) based RoR. It was a spectacular failure - LOTS of things are mostly absent from RoR: caching and transaction support, object-relational mapping is inferior (yes, ActiveRecord is NOT enough), etc.

      RoR is nice, but it needs lots of polishing and some redesign. In its present state RoR can't be compared with J2EE solutions, they are far more powerfull and _flexible_.

    3. Re:Rails, great for those fed up with J2EE. by sucresemoule123 · · Score: 5, Informative

      RoR has caching : here and supports transactions : here

    4. Re:Rails, great for those fed up with J2EE. by marcello_dl · · Score: 3, Interesting

      hmmmmm troll alert?

      Ruby can't do complex things java can??? You meant rails, probably, and such confusion of terms is not a good sign.

      Have you checked out the latest rails versions' API? I see transaction support and caching of db data and cgi actions too.

      As for the 'inferior' object relational mapping: indeed Active record tries to keep things simple: I'm grateful for it. Rails developers got too far sometimes, as you see if you have a column named 'type' in your tables ;)
      But, that's not being inferior, it's being different. If your app requires convolute mappings, either extend active record to suit your needs or do without it (possibly dropping rails altogether and wasting precious ram with a JVM ;) ).

      --
      ---- MISSING MISCELLANEOUS DATA SEGMENT --- [sigdash] trolololol
    5. Re:Rails, great for those fed up with J2EE. by ajm · · Score: 2, Interesting

      So what you're saying is that RoR is becoming more complex as it tries to handle the complex things J2EE has to handle? There is a certain irreducable amount of complexity in writing enterprise software (whatever that is). Frameworks that try to support this completely generally become more and more complex themselves until they reach J2EE levels. The vast majority of the "complicated" things in J2EE are in there because they are needed to solve real world problems. Anything that attempts to solve the same set of problems will approach the same complexity.

    6. Re:Rails, great for those fed up with J2EE. by systems · · Score: 2, Insightful

      You should probably read this paper on scripting
      The moral is, no matter how complex a system build on Ruby will get, it will always be more simple to use than a system build on Java, just because Java carries the characteristics of a systems programming language while Ruby carries the characteristics of a scripting programming language.

    7. Re:Rails, great for those fed up with J2EE. by Cyberax · · Score: 2, Insightful

      Scripting is not a holy grail. The only fundamentall advantage of scripting is name-based polymorphism (i.e. dynamic dispatch), it allows you to skip extracting common interfaces in your object model. As the software grows this advantage soon becomes negligible, and may even turn to disadvantage, because you'll have to find and isolate general interfaces manually.

    8. Re:Rails, great for those fed up with J2EE. by zorander · · Score: 4, Informative

      Enterprise software is a different game. Rails is pretty all around terrible at integrating with non-rails-intended database schemas which are plentiful in any enterprise situation.

      I'm going to overlook the fact that a flexible caching mechanism has been in place since pre-snowdevil (maybe february) and transaction support was added at some point before the last time I worked with rails (late april). Keep in mind that it's still pre-1.0 and beta and not yet feature-complete. Criticizing it for a lack of features it supports, though, is in poor taste.

      Furthermore, almost all rails development at this point has been executed using very small (5 people) core teams. J2EE supports large scale development because it was designed for it. Rails was designed to let a relatively small number of people write an agile application using the set of paradigms which rails was built on. Coming at it from an "I use java in the enterprise and couldn't plug rails in its place tomorrow" is a little bit unfair, because in the same sense, I couldn't just drop J2EE onto my own desktop and start developing with it tomorrow. (Not to mention that my boss would not even begin to authorize such an expenditure for one developer on one product).

      I see rails more as a contender to PHP than to J2EE. J2EE and rails are not really comparable in the same market. Sure, rails beats the crap out of J2EE when you've got 1-3 developers on the project, and inversely, when there's more than 10, J2EE has a clear advantage. Coming from java, you're likely to miss many of the benefits of metaprogramming in rails. Even coming from python (a somewhat similar language to ruby), I was a bit startled at some of the techniques being used.

      Your project might have failed, but I'm not sure it was completely rails that caused it. AR is very easily extensible (in a matter of hours, usually) to do all sorts of more enterprise-java-like things. Ruby's dynamic messaging and open classes makes that a much simpler affair than it would be in java. Why didn't you extend it to meet your needs? Also, how did you miss the fact that caching and transactions have been there for a while? Were you trying to shoehorn rails onto an old schema? Did you have prior ruby programming experience or were you learning as you went? Did you have prior experience in a dynamically typed language writing an app of similar complexity? Nothing is going to make the solution of a hard problem easy. Some things can make it more pleasant, if used correctly.

    9. Re:Rails, great for those fed up with J2EE. by mixonic · · Score: 2, Informative

      > Ruby is easier.

      yes

      > Until you try to do something even moderately complex.

      nothing is easy when it's complex

      > caching

      nope, its there

      > transaction support

      yep it's weak.

      > object-relational mapping is inferior

      Isn't any OR mapper slow/bloated and really just a starting point?

      > RoR is nice

      yes :)

      > but it needs lots of polishing and some redesign.

      it's not 1.0 yet

      > In its present state RoR can't be compared with J2EE solutions, they are far more powerfull and _flexible_.

      I don't code Java professionally, so I don't know. But Rails ain't 1.0 yet. Check back in 3 months ;-)

    10. Re:Rails, great for those fed up with J2EE. by abulafia · · Score: 3, Interesting
      Were you trying to shoehorn rails onto an old schema?

      This, I think, is the crux.

      My company has a library, too, that makes certain assumptions about the DB. We're really wicked-fast when using it, when building an app from the gound up. It has hooks for overriding some assumptions, so we can shoe-horn it in to some other projects. But if the DB is hopeless, the game is over, and we have to do things like everyone else.

      And nearly every company out there has a hopelessly messy DB, that can't be refactored because of X, where X is legacy apps, no money, management resistance, [...]

      Hell, even Hibernate/middlegen has a problem related to this: all it takes is one clueless app developer that scorns DB constraints, and you have a Situation that can cost 10s of K to fix.

      Rails is neat (I'm a pretty big perl bigot, and I like it), but it isn't designed for integration. Folks playing around with it should recognize that up front, so that they don't try to do the wrong thing with it.

      --
      I forget what 8 was for.
    11. Re:Rails, great for those fed up with J2EE. by Cyberax · · Score: 4, Interesting

      First, you have some misconeptions about J2EE.

      True, you can't just drop J2EE on your desktop because there's no such _thing_ as J2EE. J2EE is a set of standards (which contains just about everything).

      The only things you need to start developing J2EE applications are: Tomcat (http://jakarta.apache.org/tomcat/index.html), optionally a web-framework (like http://jakarta.apache.org/tapestry/index.html) and you can start developing tomorrow (if you know Java of course) and a decent IDE (http://www.eclipse.org/). It will cost you about $0.

      Java has some metaprogramming featues starting from version 1.5. Right now we're writing application in C++ and Python, so I don't miss metaprogramming features :)

      RoR is extensible, but some features are just very hard to implement: maintaning persistent object identity, complex mappings support, distributed caching and long-running transactions with optimistic locking.

      We had previous expirience in dynamic languages (Python, Perl, PHP). This project was a sort of expirement - we wanted to see what can be done with RoR.

    12. Re:Rails, great for those fed up with J2EE. by milesegan · · Score: 4, Informative

      Rails supports optimisting locking out of the box. Just add a lock_version column to your table and it will do the rest.

    13. Re:Rails, great for those fed up with J2EE. by zorander · · Score: 2, Insightful

      ActiveRecord is a *design pattern*. It dictates, to a certain extent, the shape of the database it supports. In reality, using it well is often a relatively good way to get a flexible/good schema from scratch with less db knowledge. It's not completely braindead, but a reasonably aware developer can do much better with the active record limitations than with a blank slate IMHO.

      Rails itself could be put on top of any persistence layer. Instiki uses Madeliene instead of AR and it works fine. It just comes, out of box, with AR installed and that is the most natural. If you write your own ORM, it can work with rails. People have had success working with legacy schemas by frontending them with postgres views that behave more in the way that AR expects.

      In any case, rails is more suited to new projects with new databases at this time. AR doesn't propose nonstandard database design in principle, it just dictates certain facts (mostly naming conventions for columns/tables) which can often be overridden. The most obvious one is that rails expects non-join tables to have an INT(11) PRIMARY KEY AUTO_INCREMENT field. Not being a DBA, I don't know what database design patterns are out there. Being a performance and efficiency conscious developer, I don't see how AR's patterns could get you into a performance or maintainability muddle by using them on a new project.

    14. Re:Rails, great for those fed up with J2EE. by shutdown+-p+now · · Score: 2, Insightful
      The only things you need to start developing J2EE applications are: Tomcat (http://jakarta.apache.org/tomcat/index.html), optionally a web-framework (like http://jakarta.apache.org/tapestry/index.html) and you can start developing tomorrow (if you know Java of course) and a decent IDE (http://www.eclipse.org/). It will cost you about $0.
      You forgot the "learn J2EE" part, which is going to be a task at least a magnitude more complex than learning Java itself.
  2. Substitute for s by fa2k · · Score: 2, Interesting

    Can this again help reducing bandwidth consumption in a similar, but prettier way, than html frames?

  3. Ruby on Rails as a threat to PHP? by Sv-Manowar · · Score: 4, Insightful

    Every time I see material surrounding Ruby on Rails, I'm further convinced that it could be the web application programming foundation that starts to displace PHP as developers start to look at the transition from PHP 4 to PHP 5. Getting an increased install base for ruby on rails, as is the case with php (a fairly difficult task, admittedly) would definitely help no end in increasing the framework's popularity, at least amongst those programming smaller web applications.

    1. Re:Ruby on Rails as a threat to PHP? by DoctoRoR · · Score: 2, Interesting

      What a troll. PHP is so low performance and scales so poorly that major web sites moved to it from the Java world, and there are enterprise-focused solutions like Active Grid that are now available. It's so un-"useful" that myriad discussion boards and community portals are invariably PHP-based. New development tools and plug-in support for popular design/programming tools are popping up. Each of these web technologies has a sweet spot, but your narrow-minded viewpoint is best revealed by your aversion to "this ancient approach of text-edited, interpreted syntax." Yeah, right. Google and every other major web presence must agree with your assessment since they only use Java and .NET now.

    2. Re:Ruby on Rails as a threat to PHP? by eyeye · · Score: 2, Funny

      Translation of your comment: "eat shit, trillions of flies can't be wrong"

      --
      Bush and Blair ate my sig!
  4. Rails book from the Pragmatic Bookshelf by gavri · · Score: 4, Informative

    Get the Beta book http://pragmaticprogrammer.com/titles/rails/index. html If you're interested in Rails at all, this book is all you need.

    1. Re:Rails book from the Pragmatic Bookshelf by mav[LAG] · · Score: 5, Informative

      Agreed 100%. I bought it last week. Don't be fooled by its "beta" status - it's a thoroughly well written introduction to Rails that takes you through everything you need to know - including building a REAL application (a shopping cart) from start to finish.

      I also bought Programming Ruby by the same author because I want to do more with Ruby than just Rails, but this isn't necessary for those who just need Rails - all Ruby constructs and idioms are cross-referenced with an included introduction to the language.

      --
      --- Hot Shot City is particularly good.
  5. Which is the bigger irony: by smittyoneeach · · Score: 3, Insightful
    Then Microsoft created XMLHttpRequest in Internet Explorer 5, which let browser-side JavaScript communicate with the web server in the background without requiring the browser to display a new web page. That made it possible to develop more fluid and responsive web applications. Mozilla soon implemented XMLHttpRequest in its browsers, as did Apple (in the Safari browser) and Opera.
    XMLHttpRequest must have been one of the Web's best kept secrets. Since its debut in 1998, few sites have used it at all, and most developers, if they even knew about it, never used it. Google started to change that when it released a series of high-profile web applications with sleek new UIs powered by XMLHttpRequest.
    a) Microsoft as a first-mover in a technology, or
    b) Microsoft's own technology being used by Google to loosen Redmond's deathgrip on the market?
    --
    Get thee glass eyes, and, like a scurvy politician, seem to see things thou dost not.--King Lear
    1. Re:Which is the bigger irony: by AKAImBatman · · Score: 2, Interesting

      Then Microsoft created XMLHttpRequest in Internet Explorer 5, which let browser-side JavaScript communicate with the web server in the background without requiring the browser to display a new web page.

      This isn't quite correct. IFrame and hidden IFrame communication was invented before that. The catch is that browsers weren't stable enough or compatible enough to make use of these channels.

      XMLHttpRequest does more or less the same thing as an IFrame (via an ActiveX contarol), except that it adds the overhead of an XML parse. AFAIK, Google doesn't use the XMLHttpRequest for any of their applications.

    2. Re:Which is the bigger irony: by Buzzard2501 · · Score: 3, Informative

      AFAIK, Google doesn't use the XMLHttpRequest for any of their applications.

      Google Suggest uses XMLHttpRequest, while Google Maps uses a iframe

      --
      Real programmers don't comment their code. It was hard to write, it should be hard to understand.
  6. Dont Forget Zope by salimfadhley · · Score: 3, Insightful

    Of course Rails isnt the only completely F/OSS web application framework; Rails is best when you want to put relational data online: It's edge is it's simplicity.

    On the other hand remember Zope - If you can get your head around Aqusition, the ZODB and Product Deveopment then Zope is a super-fast development platform.

    1. Re:Dont Forget Zope by Ranger · · Score: 2, Interesting

      If you can get your head around Aqusition[sic], the ZODB and Product Deveopment[sic] then Zope is a super-fast development platform.

      I recenty became the web administrator at a small university and the college I work for uses Zope. I knew a little Zope and Python beforehand and it helped me get the job. I was all hot and heavy to switch them to a PHP/MySQL solution, though my first love is Perl. Doing stuff in PHP was fast. As I studied Zope and Python more and more I came to realize that my initial impression was correct. It does have a steep learning curve (Zope not Python), but it is very powerful and reasonably fast. I'm not crazy about ZODB. I'll keep Zope put it behing Apache and connect to MySQL when I redesign the site. Also I'll throw Plone on top.

      What does this have to do with Ruby and Rails? Not much. The user base of Plone/Zope/Python (8) is much smaller than the PHP (5)/MySQL crowd. The Ruby (23) on Rails is even smaller than the Plone crowd.

      --
      "You'll get nothing, and you'll like it!"
  7. it's an illusion alright by udderly · · Score: 4, Funny

    From the article:The most visually impressive of these is Google Maps, which gives you the illusion of being able to drag around an infinitely sizable map in its little map window.

    It's illusory alright, when I start at the US and scroll due west the first thing that I come to is the UK. Where'd all the other countries go?

    1. Re:it's an illusion alright by MyLongNickName · · Score: 4, Funny

      All the other countries don't really exist. You see, Oceana needs to have enemies in order to keep the people focused, and subservient to the government. It is all part of the plan.... ... oh shit... its the Ministry of Love. See you in a few years...

      --
      See my journal for slashdot ID's by year. Mine created in 2005. http://slashdot.org/journal/289875/slashdot-ids-by-year
  8. And the funny thing is... by TrappedByMyself · · Score: 2, Insightful

    Ajax grew from one of those hated, non-standard Microsoft features.

    --

    Help me take back Slashdot. When did 'News for Nerds' become 'FUD and Conspiracy Theories for Extremist Nutjobs'?
  9. AJAX meme by broward · · Score: 3, Informative

    The rise in AJAX is almost solely due to the recent AdaptivePath article. I'm not sure it's a major trend.

    http://www.realmeme.com/miner/technology/ajaxDejan ews.png

    However, Ruby on Rails is clearly rising,
    moving steadily upward for over a year. Thanks to a reader for bringing this to my attention.

    http://www.realmeme.com/miner/technology/hibernate vsrubyDejanews.png

    1. Re:AJAX meme by shashark · · Score: 3, Informative
      From http://en.wikipedia.org/wiki/AJAX

      There have been some critics of the term AJAX, claiming that the Adaptive Path consultancy who created it are using it as a marketing vehicle (and as a meme) for previously used techniques

      It has been pointed out that the AJAX technologies did not have a common name before, and that some welcome a unifying term for the process. However it is also reported that the Google engineers who have created the most prominent applications using this technique consider their technologies as 'Javascript'

      AJAX is not a new approach of building software. From a higher perspective the presentation layer is like a form and a programming layer behind handling the events, commonly known in programming terms as MVC. This kind of programming is very well known in older programming environments like Delphi, MFC, Visual Basic, Oracle ADF, and Windows Forms, just to name a few. Applications using this model of programming have been around for years: Microsoft Outlook Web Access using WebDAV and the Web based ERP system P2plus using web services directly from the browser. However, because there are no standards available for the communication model behind previous implementations, all use proprietary extensions.

      A new aspect to AJAX is that there are now multiple browsers that can be used to realize this type of application, as opposed to earlier technologies which were frequently limited only to Microsoft's Internet Explorer.

  10. Re:ASP.NET by Anonymous Coward · · Score: 2, Funny

    How is eating feces not better than ASP.NET?

  11. Rails changes the whole Web development game by Peter+Cooper · · Score: 3, Interesting

    Most of this product comparison site was developed in Ruby on Rails within the last two months, and it already does more than Froogle, has more search features, etc.

    I've also developed a large marketing system for the restaurant industry in Rails which lets restauranteurs develop e-cards, e-gifts, and send them to their customers on certain days.. or certain days away from their birthdays, etc.. and that will be going fully live soon.

    My 10,000 user strong RSS Digest will be making the leap to Rails soon (July 1st) and this is a system driving over half a million uses a day.

    I developed a del.icio.us-style tagged Code Snippets site in Rails within two days! It's had further refinements since then, but less than two weeks after launch, it was getting thousands of pageviews a day and hundreds of visitors a day from Google.

    I was ready to give up development work 6 months ago, and now it's the most fun and profitable work out there for me. Ruby on Rails deserves the attention it's getting. You can put together your ideas in a fraction of the time you'd have ever imagined.

  12. Will that be 5 or 10 years experience? by GoofyBoy · · Score: 4, Funny

    Time to add Ajax and Rails on my resume!

    (To all potential employeers: I kid!)

    --
    The surprise isn't how often we make bad choices; the surprise is how seldom they defeat us.
  13. Get the book by Ridgelift · · Score: 3, Informative

    I first heard of Ruby on Rails here on Slashdot. Although Rails is dead simple once you get it, getting to the "ah ha" point is a bit of a steep climb.

    If you want to learn Ajax in Rails, the best thing I've read has been Dave Thomas' new book "Agile Web Development with Ruby on Rails". The author of Ruby on Rails itself, David Heinemeier Hansson, is also a co-author. Great book, absolutely fantastic web development framework.

  14. ASP.Net 2.0 by DigitlDud · · Score: 3, Informative

    ASP.NET 2.0 does this also. You can define client callbacks on web controls which let you run code on the server-side and get the results back without reposting the page.
    http://www.developer.com/net/asp/article.php/35068 96

  15. No, you hold the hype for 3 months. by Some+Random+Username · · Score: 4, Insightful

    I am sick of seeing this excuse. You can't run around the internet screaming how rails is the greatest thing since the wheel, and how it renders java obsolete because its 100x faster to work with, and then say "its not done" when people actually try to use it. If you are ready to hype something and tell everyone how great it is, then you need to be ready to accept criticism too. If we can't compare it yet because it isn't finished, then stop running around telling us how great it is and how we should all be using it.

  16. Re:Article's examples dont work by matchboy · · Score: 2, Informative

    That's the default Rails error page. Wasn't keeping up with the /. load with the default settings. Try again now.

    --

    Robby Russell
    PLANET ARGON
    Robby on Rails
  17. Re:Q: Can you mix PHP and RoR? by Kethinov · · Score: 2

    It's possible, but not a good idea. RoR is like a Mac. It thrives on integration. Running the Darwinport of XMMS may work for you, but using iTunes is ultimately the overall better solution.

    Hope that helps.

    (This comes from someone who runs XMMS on a Mac ;)

    --
    You're right, I wouldn't steal a car. But if it were possible, I sure as hell would download one!
  18. Re:ASP.NET by team99parody · · Score: 2, Insightful
    What features of ASP.NET and J2EE are so unique and essential that they make them a "vast improvement" and the only viable choices for larger web apps?

    You don't understand one of the most important necessary preconditions for a larger web app in corporations - someone to approve it.

    J2EE and ASP.NET have rich organizations that they can loan you to take key decision makers (CFOs) out to lunch to help approve expensive J2EE projects.

    Compared to the Oracle sales guy flying my previous CFO out to some golf conference to pitch their J2EE-based framework, Rails has NOTHING..

    I speak from experience - We had the case of One Oracle Salesguy against EVERY SINGLE internally developer telling this CFO that the Oracle framework sucked and that even Oracle was moving to Tomcat. Guess who won.

    That feature - the lunch&conference&golf budget - and that feature alone is enough to make J2EE and ASP.NET win most corporate environments.

  19. What are you talking about? by Some+Random+Username · · Score: 2, Informative

    I very clearly stated that you can cache over the network, and pointed out why a network cache like memcached is faster than an RDBMS. Your post has nothing to do with what I said, so why is it a reply to me? And you can just pull an object from the cache with memcached, because every time you update the db, you also update the cache.

  20. Advantages of dynamic languages by cquark · · Score: 2, Insightful

    No, the fundamental advantage of dynamic languages is programmer productivity. You can accomplish a goal in a dynamic language like Scheme, Smalltalk, Python, or Ruby in 100 lines that would require 500 or more lines of Java. That's also an advantage when you have to modify the code--there's less of it and it's faster and easier to read as a result. It's also much simpler and faster to create unit tests in dynamic languages, leading to more and faster testing of projects. These advantages grow with the size of the project.

    The other advantage of dynamic languages is flexibility. While Java has limited support for features like reflection and generics, dynamic languages have offered much more powerful and easy to use versions of these features for years. Java is also missing other dynamic features like closures and metaprogramming. Groovy's feature list is an inverted list of many of the limitations in Java's dynamic capabilities.

    Java's main contribution to programming languages isn't any new feature. It doesn't have any significant new features, and most of its main features like object orientation, byte-compilation/VM and primitive concurrency were in other languages like Simula and Pascal in the 1960s or 1970s. Java's primary contribution is that it was well marketed and that its limited dynamic features have inspired a large number of programmers to want more of the flexibility that languages like Scheme and Smalltalk offered decades ago.