Falling Down the Rabbit Hole

For quite some time now, I have been following all the hype of application frameworks. The analogy is that if a programming language were clay, an application framework would be the tools needed to mold that clay into something beautiful. Of course you could make something beautiful with your bare hands alone, but the tools aim to help speed the process.

From what I have been gathering, Ruby on Rails is the framework of frameworks. For a proper introduction, visit the official site. Ruby is a scripting language that was largely influenced by Perl. I have read that the name Ruby comes from the birth stone of July as Perl (Pearl) is the birth stone of June. No one seems to claim they know for sure, but it is a popular theory. Ruby has been around for some ten years, but it wasn’t until about three years ago with the release of Ruby on Rails that the movement behind Ruby really gained momentum.

When I first saw Ruby, I was a bit confused to be honest. In retrospect, when I saw my first programming language, I was a bit confused. Ruby appears to be a very elegant language. It is purely object oriented, which I won’t discuss now, and can almost be read like a sentence.

The Rails aspect, is even more intriguing. The framework has loads of features built right into it, making development as easy as typing in a few commands and filling in the blanks. But what I think is the most fascinating thing about Rails is it’s dominance. I don’t think the Ruby programming language was even in the top ten programming languages until Ruby on Rails came along. Additionally, it is THE framework for Ruby and has inspired a handful of frameworks in other languages.

Speaking frameworks in other languages, I have investigated a few PHP frameworks. I was hoping to get similar functionality of Ruby on Rails, but still be able to code in PHP (which I feel more comfortable in). A couple that share similarities to Ruby on Rails and are fairly easy to get up and running are CakePHP and Code Igniter. But still, they have a long ways to go to catch Ruby on Rails.

This leaves me with an interesting scenario. Do I dig deeper into Ruby so I can learn more Rails or do I try to navigate through all the documentation for a PHP framework and lose some of the cool features of Rails? I’ve scoured internet forums for answers and there are people on both sides of the fence. Not an easy decision if you ask me.

Count your chips and cache them in!

I was pleasantly surprised to find out that caching wasn’t super difficult to implement. I found this article on caching and knew that sooner or later I would have to implement it into my blog page.

What is caching?

To put it simply, caching makes websites perform faster and there are two ways (that I know of) that caching works.

Method 1. This is the caching that most people think of when they think of caching. Our internet browsers will save little snippets of web pages to be used if we return to a page. Because retrieving information from the internet is a lot slower than retrieving information from our hard drive or RAM, saving information locally will speed up sites we often visit.

Method 2. This is the method that I used for speeding up my site. The blog page of my site retrieves information from my Blogger account and then dynamically creates the HTML to be displayed. In plain English, my site was a greedy pig. If two people were to visit the same page, the server could not remember that a page had already been visited, thus it would recreate the page from scratch.

The solution. Caching, obviously. Now the second person that visits the page has the convenience of visiting a page that has already been generated and is less of a wait.

The savings. I was surprised how much time maybe 20 lines of code or so saved. It was taking some pages *gasp* almost 10 seconds to render. After the page has been cached, it’s fractions of hundreths of seconds.

Now on to the fun stuff. Look out AJAX!!!

If your page is greedy and you’re using PHP, I’d suggest taking a gander at the article.