Poetry of Programming

Its about Ruby on Rails – Kiran Soumya


What’s Web 2.0?

Starting from the static page, Web 1.0 has been turned to dynamic contents (like Google, yahoo etc), where users can interact with web pages, by providing instructions and contents through graphical interfaces. In short web 1.0 dealt with human-machine communication through web, accessible through wide range of operating system platforms, which was been possible by using http and html. Besides human to machine communication, the concept of web 2.0 concentrates on the following issues, that I have learned so far

  1. Machine to machine communication. You publish your content in one site, which has been automatically shared by thousands of web pages among other servers. This becomes possible through RSS. As a user, you can get updates of a web site contents, through using a RSS feeder.

  2. Human to human communication. For example point to point network, social community network etc, where pictures, emotions, biography, music etc personal resources can be shared with friends and friends community can be grown via friends of friends.

  3. Rich user experience. Using AJAX (Asynchronous JavaScript and XML), it becomes possible to send web requests from the client side to server side, through XHTTPRequest method call from browser end, which enables an user NOT to wait to work, until the reply of this web request returns back from the web server. One simplest example can be given as, in Gmail, we can attach as much as files and after then we can begin typing the mail. Lets say this type includes 6 minutes. By this time, Gmail starts sending the attachments to the server, lets say it takes 5 minutes. When my type finishes, the total process takes only 6 minutes, while not using AJAX it would take simply 11 (6+5) minutes. Web 2.0 sites provide, although NOT exactly, but a sort of much similar rich user experience like desktop application. Well one important thing to note, Ajax is not actually new technology, but uses old and very well known technology (JavaScript, xml etc) in new approach.

  4. Personal contribution over web content. Web 2.0 encourages personal contributions of the users over the web content. Blog is such a thing, which is called “Online diary”, where a person can enter his words, in daily basis. Each entry is specifically mentioned and maintained regarding it’s publish date. Several blogs in online has some common features, like archives, track back etc. Blogs has become popular, than the web 1.0 style “Persona web site”, as blog includes more personal touch. Another popular web 2.0 concept is wiki, which is called as “Online Encyclopedia”, where people can edit or contribute their knowledge there. Book marking is another web 2.0 features, where URL book marks can be saved and shared with others. Basically blog, wiki, url booking marking are the things are conceptual than latest technology and considers social aspect to share personal contents. These type of ideas encourages “tagging”, where any item can be tagged with one or more categories(in some cases these tags are being used in RSS feed).


Web 2.0 on Rocket Fuel

Ruby on Rails 1.1 is described as Web 2.0 on Rocket Fuel.

The much-anticipated new version 1.1 of Ruby on Rails hit the streets with fanfare a couple of days ago. And while even I am wary of the hyperbole that sometimes surrounds Ajax and Web 2.0, I’m very pleased to say that Ruby on Rails is the genuine article. Rails has become one of the real success stories in Web development in just the last year. Built by 37signals’ charismatic David Heinemeier Hanson and a host of contributors, Ruby on Rails has ascended to near-mainstream status nearly overnight.

For those of you not familar with Ruby on Rails, and a lot of you won’t be or have just barely heard of it, Ruby on Rails is a complete, open, and free application stack based on the Ruby programming language . This means it provides a complete solution for creating great online Ajax-based software of the kind that’s pouring out on the Web these days . Rails includes advanced Ajax support, Web services, an amazingly taut and clean model-view-controller implementation, and automatic object-relational mapping. Rails even includes seamless script.aculo.us and Prototype integration, as well as support for just about any database you will need.

Ruby itself is one of the interesting stores in software development lately because it’s a dynamic language, meaning that it isn’t compiled and is somewhat more akin to Perl and Javascript than a traditional hardcore language like Java or C++ . But that’s where similaries to Javascript end since Ruby is an elegant object-oriented language designed to make programming easy and make routine software development tasks almost effortless. In fact, when I did my C#, Java, and Ruby Web services development comparison last year, Ruby won hands down in development time, compactness, and generated by far the most readable code, even though it was the very first time I’d used it.
Ruby on Rails 1.1

Rails is a natural extension of these concepts in that it adds a framework to Ruby to make it maximally easy to build Web-based online software, with the single-minded intent of pushing complexity out to the edge cases. To get a sense of how powerful Ruby is, my recent discussion (video here) with David Heinemeier Hannson at Real-World Ajax revealed that 37signals not only built their 5 world-class online applications purely with Ruby on Rails, but they support almost 400,000 users on just 13 servers.

Dion Hinchcliffe and David Heineimeier Hansson discuss Ruby on Rails 1.1But there are dozens and dozens of Web development products out there, many of them very good, so what makes Ruby on Rails so special? One is that the Rails’ design focuses on trying to make the common Web development tasks fall-down-the-stairs easy, and it invariably succeeds. Like the Rails home page says, “Ruby on Rails is an open source Web framework that’s optimized for programmer happiness and sustainable productivity. It lets you write beautiful code by favoring convention over configuration.” Rails proponents are reknowned for their plain spokeness and directness and the result of this attitude is clear throughout the framework.

Another real advance in Rails is the fact that it considerably reduces something called abstraction impedance. Abstraction impedance is a fancy $20 phrase that describes the barrier that exists when crossing from one way of thinking to another. Say the barrier of going from objects to databases, or Javascript to Ruby. Abstraction impedance is a productivity killer that sucks up programmer time doing things that don’t matter to what the application does. So instead of providing solutions to your users, you’re spending time converting information from one form to another. Rails makes this go away by giving the programmer plain old objects to deal with, no matter if you’re dealing with XML, relational database data, and now even Javascript in the browser.

This takes us to the new features in Ruby on Rails. As its biggest new feature, version 1.1 actually allows you to write your browser-side Javascript in Ruby. Javascript is a notoriously finicky language that doesn’t make it easy to create sophisticated Ajax appliations and that’s why IDEs, frameworks, and tools are springing up everywhere to make it simpler. Now Rails has just dropped one more complexity out of the process of building Web 2.0 software applications with RJS, the Ruby to Javascript compiler.

Web 2.0 software development has its own set of expectations and best practices: rapid feature evolution, real-time feature monitoring, all functionality available in both the GUI and as Web services so others can use them in their own apps, and more. Rails makes all of these easy to do using one of the highest productivity languages out there. That’s not to say Rails is perfect, it’s so new it couldn’t possibly be fault-free, but there is clear evidence today of its reliability, scalability and ease-of-use (once you get past a brief learning curve.)

What’s New In Rails: (complete list here)

  • RJS – Write your Ajax application’s Javascript in Ruby
  • ActiveRecord++ – Rails’ ActiveRecord is a powerful, automatic Object/Relational Mapping tool. It gets a major steroid boost in Rails 1.1.
  • API Support – Adding an API for your Web 2.0 software is now even easier
  • New Integration Tests – Rails understands testing and adds even more automatic test support
  • Backwards Compatibility – Even with 500 new changes, old Rails apps will almost universally run in Rails 1.1

If you’re interested in picking up Ruby on Rails, here are twelve excellent tutorials (http://www.digitalmediaminute.com/article/1816/top-ruby-on-rails-tutorials) that can get you started. And finally, if you haven’t bought all of this yet, take a look at this screencast. It shows step-by-step how to develop a working blog application in Rails from scratch in just 15 minutes, complete with comments and an administration interface. That’s the power of Rails, it really does let you focus on delivering great online software and not get mired in details that don’t matter. In any case, Rails is so new it has almost no enterprise penetration. But as the next generation of programmers uses it more and more, expect that to change, along with the way enterprises develop with Web technology.


Script.aculo.us 1.6.4 Released on 6th September.

Thomas Fuchs has sync’d up to the latest Prototype adding features along the way:

* Update Prototype to V1.5.0_rc1 (read more on Justin Palmer’s blog)
* Add experimental alternate syntax for unit tests (Behaviour Driven
* Merge assertElementsMatch and assertElementMatches from Prototype’s
[4986] unittest.js [Sam Stephenson]
* Add assertRespondsTo and shouldRespondTo assertions

// object var testObj = { isNice: function() { } } // test assertRespondsTo(’isNice’, testObj);

* Make Sortable.serialize handle DOM IDs like “some_element_1” correctly, fixes #5324
* Add support for onStart, onDrag and onEnd events directly on Draggables (invoked from the Draggables.notify), fixes #4747 [thx scriptkitchen]

new Draggable(’some_id’,{ onStart:function(){ /* … / }, onDrag:function(){ // }, onEnd:function(){ / … */ } });

* Add autoSelect option to Autocompleters to auto select an entry if only one is returned, fixes #5183 [thx cassiano dandrea]
* Added delay option to Draggables and Sortables, see test/functional/dragdrop_delay_test.html for usage, implements #3325 [thx lsimon, tomg]
* Add version and timestamp to indvidual library files for easier identification (the files are preprocessed by the Rake fresh_scriptaculous task), fixes #3015 [thx Tobie]
* Add assertIndentical and assertNotIdentical unit test assertions, which test for equality and common type, fixes #5822 [thx glazedginger]
* Add integration test for Ajax autocompleter for results with no linebreaks, #4149
* Added a custom exception to all base effects when used on non-
existing DOM elements, added a assertRaise method to unit tests
* Add element shortcuts to Builder that can be activated by calling Builder.dump() (see the unit test), fixes #4260 [thx napalm]

Builder.dump(); var element = DIV({id:’ghosttrain’},[ DIV({style:’font-size: 11px; font-weight: bold;’},[ H1(’Ghost Train’), \”testtext\”, 2, 3, 4, UL([ LI({onclick:’alert(’test’)’},’click me’) ]), ]), ]);

* Make Effect.Puff work correctly for floating elements, fixes #3777
[thx michael hartl]
* Fix selection of correct option in SELECT element generated by
InPlaceCollectionEditor for indexed option arrays, fixes #4789 [thx
* Fix an issue with redrawing ghosted draggables that are inside a
scrolled container, fixes #3860 [thx gkupps, tsukue]
* Fix autoscrolling inside scrollable containers when window is
scrolled too, fixes #5200 [thx wseitz]
* Fix autoscrolling when dragging an element unto a scrollable
container, fixes #5017 [thx tomg]
* Fix a condition where overriding the endeffect on Draggables without
overriding the starteffect too leads to a Javascript error [thx
Javier Martinez]
* Fix a possible error with the drag/drop logic (affects the solution
to #4706)
* Fix various issues with IE detection and Opera, and setOpacity, fixes
#3886, #5973
* Remove revert cache code obsoleted by #4706, fixes #3436 (again) [thx]


Why Ruby on Rails?

The stack on the left is the Java books, the stack on the right is the Ruby books. The same breadth of material is covered. Well almost, there are on-line references for things like XSL, not covered in the Ruby books. But other than that the functionality is the same. So which stack will be easier to keep in my head? The choice is easy.

Check this url: http://www.garbett.org/?q=node/25#comment-13
Shawn gave a great comparision of Rails with Java.


Rails’ time extensions ported to JavaScript

Ström have ported Rails’ Numeric Time extensions to JavaScript since he needed to do some date calculations for a project. Now one should be able to calculate dates in JS like this:
(5).seconds() // => 5000
(2).weeks() + (2).hours() + (15).seconds() // => 1216815000
(1).week().fromNow().toDate() // => Fri Sep 22 2006 19:16:32 GMT+0200 (CEST)
var date = new Date(2000, 11, 18, 18, 15, 23);
(2).years().since(date).toDate() // => Thu Dec 19 2002 06:15:23 GMT+0100 (CET)
Thought it could be useful for others as well.
You’ll need the latest prototype and scripta.culo.us libraries, unit tests are included.


How to stop search engines from indexing your pages.

Got something you want to put online, but you don’t really want it showing up in search engine results? Here are two quick and easy solutions.
Use a specific meta tag

For each page you don’t want to appear in search engine results, have only one tag. Not a description, not some keywords, just a single tag for robots.

meta name=”robots” content=”noindex,nofollow,noarchive” />

Pop that into the of each page, and you’re telling search engines not to index the page, not to follow any links from the page, and not to archive the page.
Create a robots.txt file

If your pages are all in a separate directory, you can also block search engines by using a robots.txt file.

Create a text file and, in it, disallow all the directories you want protected:

User-agent: *

Disallow: /nameofdirectory

Disallow: /anothernameofdirectory

Do it for all the directories you want, then save the file as robots.txt, and upload it to your main directory. The search engine robots will hit the robots.txt, find out which directories you don’t want them sniffing in, and skip them.

So there you go. Two little things that can save you a world of trouble.

However, these aren’t completely effective solutions. If you really want to block search engines from accessing your pages, you can either password-protect your pages, or keep them offline.

The choice is yours. Have fun!