Phusion Passenger + Apache2 for RoR

Ok here goes my little notes on making a small nifty Rails App run on Apache2 with mod_rails provided by Phusion Passenger.

The installation of mod_rails is pretty straight forward. The installation steps are small and well documented here plus you have the amazing rails cast by Ryan Bates.

After watching the videos and reading the steps well I thought its gonna be a breeze I am going to wind up in 15mts and going to enjoy the night! Sigh! But things went wrong a 15mts exercise consumed close 4/5hrs of my time.

Ok here is where the fun is all about – I use RVM to maintain my installs. The first step in passenger installation is obviously to install the passenger gem. Now I felt it would be good to put the passenger in global gemset rather than any specific one and there by making it available to all. So I did

rvm use 1.9.2@global

Then
gem install passenger

Then
passenger-install-apache2-module

In my system after the above step it said some libraries were missing in the system (Ubunut Lucid Lynx), so I had to correct those by manually installing them with apt-get. After I got all the dependencies installed I again ran the passenger install and everything went fine.

At the end of the passenger-install step, it would spew a few lines of code which we need to put it on apache2.conf file. For me those lines looked like

LoadModule passenger_module /home/arun/.rvm/gems/ruby-1.9.2-p136@global/gems/passenger-3.0.5/ext/apache2/mod_passenger.so
PassengerRoot /home/arun/.rvm/gems/ruby-1.9.2-p136@global/gems/passenger-3.0.5
PassengerRuby /home/arun/.rvm/wrappers/ruby-1.9.2-p136@global/ruby

Now I added a Virtual Host to Apache to point to my sample Rails App by adding the following to the apache2.conf


<VirtualHost *:80>
ServerName http://www.depot.com
DocumentRoot /media/harddisk/work/ror/depot/public
<Directory /media/harddisk/work/ror/depot/public>
Allow from all
Options -MultiViews
</Directory>
</VirtualHost>

So that is it – restart the apache and hit http://www.depot.com in your browser you should see your rails app. But hey! wait won’t entering depot.com make the browser go and search the Internet rather than your local system. Well yes, so we have to make a small exception in the file /etc/hosts. In the file add a line

127.0.0.1 http://www.depot.com
127.0.0.1 depot.com

Ok all set! now again enter the URL to your browser biff! now got a new error

no such file to load -- bundler

The error was obvious it was not able to find the bundler. But from terminal I gave

gem list -d bundler

It was showing proper output, means bundler gem was there up and kicking. Mind you this command I was giving from the gemset which I was working on. Then I started googling this error and got many suggestions and tried one by one and spent nearly 3hrs and couldn’t make any break through. It was really frustrating.

Then finally help arrived from Hongli Lai of Phusion Team through the Phusion Passenger Google Group. She was pointing to me that ruby I am using for Phusion given in apache2.conf file was pointing to global gemset while bundler was installed in the other gemset. So I had replace the line in apache2.conf to pick up the ruby from the gemset which I was working on. So suppose foo is your gemset change PassengerRuby line in apache2.conf to

PassengerRuby /home/arun/.rvm/wrappers/ruby-1.9.2-p136@foo/ruby

Yes! This worked. Now if you are running a static site things would start working now. But my sample app had some tables so when I fired up app in browser it was complaining that tables were missing in the production.

So if you run into a similar situation just migrate the tables to production with rake.
rake db:migrate RAILS_ENV="production"

In my case I had some load scripts as well which was for loading some sample data to tables, for loading those data into production use the rails runner with following option

rails runner -e production script/load_xxxxx.rb

That is it, now I see my rails app working well in my Apache2 server with mod rails.

Ok! here is a small tip, in order to restart the Rails App after changes you need not restart the server, you can give this command from Rails Application Root

touch tmp/restart.txt

Passenger would see the timestamp of restart.txt and reload the Rails App if needed.

Advertisements

Back to emacs for Ruby on Rails

I remember last Java Sun Tech Days @ Hyderabad, when James Gosling was asking the audience who all were out there still using old editors like emacs/vim. Hardly a bunch would have raised their hands. The point he was driving was that in this age, we should probably move away from these editors and get into the groove of modern IDEs like Eclipse/NetBeans as they give powerful features like refactoring, automated testing etc. So its not worth the effort to learn all those weird key combos to drive the work. Of course he was talking more in perspective of J2EE development.

So what makes me drive back in time to the good old editor of yester years? Well, first is I am now full time into Ruby on Rails. I started Ruby learning expedition with NetBeans. But then somewhere in between I learnt Oracle has stopped support for JRuby in NetBeans. So then I moved to gedit and installed all the relevant plugins to make it a gmate (the mac-textmate equivalent in Ubuntu). Even though it was too good than the conventional gedit, still a lot was desired. So finally I decided to take the plunge and get into emacs. The good old emacs which I had been using some 4-5 years back and then ditched it to enter the snazzy world of IDEs. First few days were time for refreshing those old commands C-x s and C-x c etc. After that things just rolled out fast.

Now I am fully hooked onto emacs – the beautiful editor of Unix. To facilitate Ruby/Rails development I went ahead and installed Rinari – The Ruby on Rails Minor Mode for emacs. From there there was no looking back. The awesome keys which Rinari provides has made Rails development a breeze. If you are a Rails guy you would savour this short cuts – a ready reckoner of keyboard commands in emacs for Ruby on Rails Projects.

C-c ; f c rinari-find-controller
C-c ; f e rinari-find-environment
C-c ; f f rinari-find-file-in-project
C-c ; f h rinari-find-helper
C-c ; f i rinari-find-migration
C-c ; f j rinari-find-javascript
C-c ; f l rinari-find-plugin
C-c ; f m rinari-find-model
C-c ; f n rinari-find-configuration
C-c ; f o rinari-find-log
C-c ; f p rinari-find-public
C-c ; f s rinari-find-script
C-c ; f t rinari-find-test
C-c ; f v rinari-find-view
C-c ; f w rinari-find-worker
C-c ; f x rinari-find-fixture
C-c ; f y rinari-find-stylesheet

Rinari makes navigating within the Rails Project a breeze. Say if you are in view page you do C-c ; f c it takes you to the controller of the corresponding page and from there do C-c ; f m you land in the model of that page. It’s intelligent to figure you out the correct file for that.

Also it includes the shortcut C-c; w which starts the webserver for you within emacs. The webserver logs are like just another buffer in emacs. So when some error crops up do a C-x b to switch to the logs then in the error line in the log just hit a you land at the source code line where error has occured.

On top of Rinari, its good also to install Ruby-Electric which helps in automatic bracket closure, indentation etc. Then add up AutoCompletion and RSense to get auto completion feature in emacs for Ruby/Rails code like any other modern IDE. This blogpost is a good reference to configure emacs for Ruby on Rails.

The good thing about emacs is its just not a editor its an ecosystem unto itself, each day I am discovering something new in emacs. Once you are proficient in emacs I think you need not go out to shell or anyother place everything can be accomplished within emacs. For instance I have started maintaining my calendar & dairy and daily notes within the emacs with M-x calendar command. I have started using emacs calculator for my math occassionally, now I am trying to bring in my google mail box within emacs, small pdf documents I read within emacs now.

So the clock has turned back – its sheer joy using emacs and learning those beautiful commands.

I am not sure if there is any other editor out there which has some much features rolled into it and allow customizations to crazy levels if you know a bit of lisp.

Installing RoR in Ubuntu

The real strength of Ubuntu/Debian system is its package manager which makes the upgrade and installs in the system a breeze. In this post I am going to talk about ways to install Ruby and Rails in Ubuntu system.

Perhaps the easiest way to install Ruby is to use the apt package manager. Well you can do
sudo apt-get install ruby

But it turns out that its a bad idea to use apt for installing Ruby in Ubuntu. Primary reason being that Ruby development goes real fast and Ubuntu package managers are bit slow in catching up with it. As of today Ruby 1.9.1 is available through apt-get, but Ruby currently is 1.9.2. Ok, that is one of the reasons for not using apt, the other major reason is that we need to have a mechanism to install and switch between multiple versions of Ruby and Rails and perhaps switch back and forth between them.

Say you have to work with Ruby 1.8.7 with Rails2.3 in one project and Ruby 1.9.2 with Rails3 in another one. Using apt to install various versions of the language makes this difficult. Enter RVM (Ruby Version Manager)

Ok, if you want to further convince yourself about reasons of not going with debian package manager read this.

Some Terminologies
A newbee in Ruby Land can be overwhelmed with the terminologies in this world, so let me first clear them before diving into the how-to’s of upping the RoR in Ubuntu machine

Gem – aka RubyGem is a package manager for Ruby. As apt is the package manager for Ubuntu you can think Gem is package manager for just Ruby Ecosystem. In apt you have .deb file, here we have .gem file which is called the gem file, gem is nothing but a packaged Ruby program or library. Analogous to Java World .gem file can be equated to .jar file. But gem provides command like gem install which you can use to install gems remotely (like apt-get install). Similar commands are there for remove.

RVMRuby Version Manager is a manager which helps in installing multiple versions of ruby language and gems. You can easily mix and match the language version with various gems and use them independently. It provides a neat way of separating the versions without any clashes. RVM does this through gemsets. Essentially it provides a compartment or work-area where you can start your work with Ruby.

Gemset – Gemset is like an environment provided by RVM. In a Gemset first you choose which version of Ruby to use and then you can add as many gems within that gemset. You can create as many gemsets as you want. For each gemset you choose the ruby version and add gems into the gemset.

Installation

Ok, I hope now you are comfortable with jargons, its time to dive deep into the installation steps.

Pre-reqs To get started make sure you have git and curl in your system. Assume all those into programming will already have that ready.

Install RVM Look through the steps for RVM Install here. Its pretty straightforward. Once we have the RVM, we can install Ruby and start creating gemsets.

To install ruby you have give command
rvm install 1.9.2

Here 1.9.2 denotes the Ruby Version.

Suppose you want to have 1.8.7 Ruby also in same system do
rvm install 1.8.7

Now that you have multiple versions of Ruby in your system, you have to decide which version to use, you can give
rvm use 1.9.2

or say to make 1.9.2 default
rvm --default use 1.9.2

Creating Gemsets
Now that you have Ruby ready, you have option to create gemset or you can even ignore this and use the default (the global gemset). I feel its always better to start by creating a gemset, so that later on you can easily switch to different version if needed.

To create your own gemset give command
rvm gemset create foo

So foo is the name of your gemset. Next step would be to associate a Ruby Version to the gemset and start using it. For that start using gemset foo give
rvm use 1.9.2@foo

So you are saying that you want to use Ruby 1.9.2 with gemset foo. Note above command also switches you to the foo gemset. So from now on if you do anything it will be within the gemset foo. That is to say suppose you install any gem like rails it will be within the gemset foo.

To check the gems within gemset give
gem list --local

Ok! now to the crux, to install Rails just have to give
gem install rails

Yup! that is it, you are up and running with Ruby on Rails!

Potential Pitfalls
When you install Ruby using the rvm install command it pulls out the source code and compiles it and then installs it. So you have make sure that relevant libraries are there in the system, especially the zlib.

In one of the system, where I was trying out, didn’t have zlib so after doing all the steps when I tried to install gems with gem install command it was giving error

$ gem install rails
ERROR: Loading command: install (LoadError)
no such file to load -- zlib
ERROR: While executing gem ... (NameError)
uninitialized constant Gem::Commands::InstallCommand

This was quite vexing issue I tried to install zlib with apt-get still couldn’t resolve it. So if you face this problem you can do the following steps


$ rvm pkg install zlib
$ rvm remove 1.9.2
$ rvm install 1.9.2 --with-zlib-dir=$rvm_path/usr

Essentially what it does is installs zlib with rvm. Then we remove Ruby and then compile and install Ruby again.

The best approach to tackle this will be to do this step before start of the installation


$sudo apt-get install build-essential bison openssl libreadline5 libreadline5-dev curl git zlib1g zlib1g-dev libssl-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf

Moving Ahead

RVM installs and maintains all the gems and gemsets in your home directory under .rvm/ folder.
Here under ~/.rvm/gems folder you can find info about all your gemsets

gems>pwd
/home/arun/.rvm/gems
gems>ls -l
total 24
drwxr-xr-x 2 arun arun 4096 2011-01-30 00:29 cache
drwxr-xr-x 7 arun arun 4096 2011-01-31 18:07 ruby-1.9.2-p136@foo
drwxr-xr-x 2 arun arun 4096 2011-02-01 05:32 ruby-1.9.2-p136@foo1
drwxr-xr-x 7 arun arun 4096 2011-01-30 00:29 ruby-1.9.2-p136@global
drwxr-xr-x 2 arun arun 4096 2011-01-31 17:39 ruby-1.9.2p136@rails3tutorial

So there you can see the gemsets created by me. global is the default gemset created by rvm.

Suppose you want to download a gem and install it. Copy the downloaded gem file to $GEM_HOME.
Then you can give
gem install

Suppose you want to have Ruby RSS gem. Download it and copy it to $GEM_HOME. Then give gem install. The steps are listed below


gems>cp /media/harddisk/downloads/rubyrss-1.1.gem $GEM_HOME
gems>cd $GEM_HOME
ruby-1.9.2-p136@foo>ls
bin cache doc gems rubyrss-1.1.gem specifications
ruby-1.9.2-p136@foo>gem install rubyrss-1.1
Successfully installed rubyrss-1.1
1 gem installed
Installing ri documentation for rubyrss-1.1...
Installing RDoc documentation for rubyrss-1.1...
ruby-1.9.2-p136@foo>gem list --local
...........
rspec-mocks (2.3.0)
rspec-rails (2.3.0)
rubygems-update (1.4.2)
rubyrss (1.1)
.........................

TIP
While installing gems it’s better to avoid rdoc and ri doc which gets installed with the gem. These documentation consume space and increases time to install. Anyway most of us will be googling or consulting online docs while development so if needed we can avoid docs totally while installing any gem. For that give

gem install rubyrss-1.1 -d --no-rdoc --no-ri

Hope a new-bee would find this post useful and easily get on with RoR in Ubuntu.

Great References
http://everydayrails.com/2010/06/28/rvm-gemsets-rails3.html
http://ryanbigg.com/2010/12/ubuntu-ruby-rvm-rails-and-you
http://rvm.beginrescueend.com/

Cardinal Sins of Programming

What I am going to put here is nothing new or enlightening for a seasoned software developer, it’s just my trials and tribulations working through some heavily screwed projects over the course of my career.

So what are those software (mal)practices which sound death knell and ensue disaster? Well, here are my top recipes for embracing pain

1. Code Repetition – Remember DRY aka Do not Repeat Yourself. Even if you repeat a mere 3/4 lines of code in 10 odd places just pause and think over. Something ought to be fishy, try to put that repetition into a function, reuse the code. I have burnt my fingers fixing repeated lines of code in 10 to 100 odd places, even a full package of Java files being completely duplicated to another package. Just remain ruthless if you see duplication, it should never be there, don’t hesitate to select and hit del, even if your manager is going to fire you for that.

2. Intermixing logic – Or simply violating SRP (Single Responsibility Principle). Its really catastrophic to mix UI logic with business logic. It just makes the whole code very difficult to read/debug and even more difficult to change anything. Suppose you want a new UI for the same logic, you are screwed, you have to recode the entire business logic again or refactor the current code to separate out business logic from UI. In this aspect I need to point out a horrible technological offering from Java Stable – JSP. If not used carefully JSP spell death knell. It’s so easy to mix db calls/business logic and UI HTML into the JSP. But what we get out of this shortcut is a code mass which totally undecipherable, not at all debuggable and what more stack traces point to the dynamic servlet code line numbers of the JSP. I loathe JSPs and wish Sun never gave so much power to the naive user to intermix things and screw up life.

3. Conventions – How do you feel when you see code with variables test1, test2, test5, i, j, looper, arraylist, map1, list1 etc. Terrible and horrible. You read method half way then you wonder what this test1 actually is then you scroll up then find out what is getting assigned to it, then come down and re-read. The naming convention is not confined to Java variables or methods, even for HTML tags. Its really a bad idea to give tag ids as myForm or myButton. I faced really a real night mare when we decided to consolidate all JavaScrips littered over JSPs to a single JS and include it every where. In the end you have 10 functions with name submitForm. You are screwed, you have a real pain to correct them If your form is an Order entry form right name for form id would be orderForm and submit of that form would invoke submitOrder() method in JavaScript.

4. Looong methods – How long can a method be? 1000 lines, 4000 lines? Well I had opportunity to debug upto 10k lines of code in a method. My pea brain just could not hold on that and I just had to leave that and pray before I run those methods. I personally feel 50 is the max number of lines you can have, 50 is upper limit of tolerance, ideally a method need to be 10-15 lines of code in a well crafted software.

5. Exposing the internals – If you have class, don’t expose the internals of it to outside. If you maintain list of names as HashMap inside a class, don’t tell world that you are using HashMap. Just keep it with you and give neat interfaces to outside like
void addStudent(int id,String name)
Iterable getStudentNames()
void getStudentName(int id)

rather than using
HashMap getStudentMap()

In the latter case call can even modify the Map without you being aware of it and at later point if you are going to change the Map to a Student Class, you are screwed up because all those who are exposed to your internals need to be updated.

6. Building the code on ArrayList, HashMap – ArrayList and HashMaps are good, but should be the lowest level of implementation never exposed out through public APIs or methods. I had tremendous experiences where a HashMap contains 10 keys, 1st key returns another HashMap which intern has 10 keys and each of those keys have ArrayList, Array, String, Integer etc. Then there were wonderful data structures like an Array of ArrayList. These kind of things drive you nuts and crazy, unless you debug line by line and print line by line its never clear what goes where. Class is the most powerful abstraction you have and try to encapsulate things within the objects and pass around objects rather than Lists and Maps.

7. Think a little bit ahead – Yea its not good to code for requirements which you are not having today, but still for some cases it’s good to assume certain things and give that flexibility in the code. A case in point is internationalization, just don’t litter messages and boiler plate texts in Java/JSP/JavaScripts, have mechanism in place from beginning itself, even though you may just show things in English alone. Another aspect is db, it’s not good to assume one db and code it, code ought to be db agnostic. I had seen code where things were assumed to be always on Oracle and they take liberty of using sequences or sysdate (both Oracle specific) and one fine morning customer comes and tell you, well I want only SQL/Server. You are doomed.

8. Passion – (or lack of it) Majority of those who write code, do it for getting pay cheque at month end. Building code is cheap and easy. Anyone with a reasonable aptitude can do it. But crafting it to be readable, extensible, maintainable requires lot of pain, learning and rework. If you are not willing to take that pain, not willing to learn how to write testable software, then don’t just do it.

Google GSON – A Short Intro

We have uptaken Google GSON in our current project and have been trying to use it wherever JSON input/output is needed.

Google GSON is a Java Library that can convert any Java Object to JSON string and also form a Java Object from a JSON string.

The main advantage with using GSON is the plethora of options provided in the API which allows a bunch of customizations before converting an object to a JSON string.

One of the cases for Gson may be UI Messages. Server gets an AJAX call from browser it does the processing and want to send back a Status Message to the user. For this case we can have a small class

class UIMessage
{
      private String msgCode;
      private String msgText; //translated msg Text

      UIMessage(String msgCode, String msgText)
      {
          this.msgCode = msgCode;
          this.msgText = msgText;
      }

}

UIMessage msg = new UIMessage(“SAVE_SUCCESS”,”Updated Successfully”);
Gson gson = new Gson();
String jsonMsg = gson.toJson(msg)
;

Now we can can stream that jsonMsg back to the response and JavaScript can take in that message text from JSON.

The above is the very simplistic use case with GSON. If you want to add more sophistications into it, you can start using the GsonBuilder class which is nothing but a Builder Pattern for Gson class.

By default GSON gives field name as key for the JSON text and field value as the value. In the above example the output will be like this

{“msgCode”,”SAVE_SUCCESS”},{“msgText”,”Update Successfully”}

You have also option to control which field to serialize by using @Expose annotation (when used only serializes the fields marked with annotation) like

class UIMessage
{
      private String msgCode;
      @Expose private String msgText; //translated msg Text
}


UIMessage msg = new UIMessage(“SAVE_SUCCESS”,”Updated Successfully”);
Gson gson = new GsonBuilder.excludeFieldsWithoutExposeAnnotation().create();
String jsonOutput = gson.toJson(msg);

In the above case it will just take msgText for serialization. Other way would be to mark certain fields as transient in the class and prevent it from being Serialized.

If you use the Builder you get options like whether to serialize Null fields or change field naming using the FieldNamingPolicy. Gson also handle all Collection Objects effectively.

The biggest advantage I got with Gson apart from a flexible JSON conversion mechanism is that it promoted more OO within the system. Earlier we had messages and statuses floating around like raw Strings, now all of them have been encapsulated into its own class (like UIMessage above). Also the incoming JSON from the browser is also converted into equivalent Java Classes and these objects are further forwarded to Business Delegate Classes. Earlier the parameters were raw Strings floating around. Agreed we had the design all wrong in first place, but uptaking GSON made us create lot of classes interacting with HTTP Request and Business Logic and code is getting little better.

Guava/Google Collections – Unleash the power

I have been using Google’s core Java Library Guava (which includes Google Collections) extensively for the past few months in my project and man it’s an amazing and elegant framework to code with. Once you start using it, you can rarely get off it for its power and nimbleness.

The biggest use of it is reduce the Lines of code and avoid unnecessary looping through Java Collection Objects be it for filtering or searching or sorting. And what more it gives ability to do some amount of functional programming like in Java by passing around Predicates and Functions.

Some of basic classes which comes with Guava are

Splitter – which can split a String a produce a Iterable out of it. If you use Java String split you end up getting an array of String objects. But getting an Iterable out of it is really cool thing, especially if you get some request parameters which are comma separated you want to extract the individual parameter values.

String pattern = “Foo,Bar,Boo”;
Iterable pattLst = Splitter.on(“,”).split(pattern);

The above is a naive example, you have option to use an regex pattern, ignore empty strings etc.

Complimenting the Splitter is a Joiner, which joins the elements of a Collection for you, by joining with a pattern you provide.
Suppose you have list of values in a List which you want to concatenate with “,” and insert as a String to the db, Joiner will do the job for you in a single line rather than writing 5-10 lines in the conventional approach.

Iterable nameLst = new ArrayList();
nameLst.add(“Foo”);
nameLst.add(“Bar”);
nameLst.add(“Boo”);
String names = Joiner.on(“,”).join(nameLst); //voila!

The real power comes with Collection APIs. There are different components in it – Google Collection provides entirely new data structures like MultiMap, BiMap etc. Also it provides powerful ways to filter, search, sort and manipulate any Java Collection Object.

Let us explore the Predicate Interface, which facilitate in filtering of any Collection.

Suppose you have a class Student.

class Student {
String name;
int marks;
….
}

Further you have a list of students in a List

ArrayList studentLst = new ArrayList();

Out of the student list if you have to filter the Students with marks greater than 80, you can create a Predicate for it.
We can write a function which creates the predicate and it can used anywhere.

So in class Student we can put a static function.

public static Predicate getStudentMarkPredicate(final int mark)
{
Predicate studentPredicate = new Predicate() {
public boolean apply(Student input) {
if ( mark >= input.getMark() )
return true;
else
return false;
}
};
return studentPredicate;
}

The above function creates a Predicate, the predicate is defined such that it will return true for any input Student if his mark is greater than or equal to the given Mark.

So now if you want to filter the studentLst to get the Students who have scored above 80, you can do it with this small elegant code below

Iterable studentsAbvEighty = Iterables.filter(studentLst, Student.getStudentMarkPredicate(80));

Well you can pass any arbitrary mark above a get the list of students matching them.

Providing even more gist is the Predicates class which has some predefined Predicates like and, not, or, in etc. These are real power tools for you search and filter multiple lists elegantly.

Suppose you have two Lists
List studentLst; //master list
List failedStudents;//failed students

Now if you need to filter the passed students from studentLst you can do it with a single line of code like this
Iterable passedStudents = Iterable.filter(studentLst, and(in(studentLst),not(in(failedStudents))));

Look how readable the above code and no clunky mechanism of looping. The above is a very simplified example, but you can imagine the power by chaining ands/ors and nots and ins to produce a complex filter.

Another powerful class is the Ordering which can be used for Comparator Chaining a produce a multi-column sort. I would explore that in the next post.

So the key take away is if you are doing Java Development and haven’t used Google Collections, your moment has arrived for it now. Explore and have fun!

Vibes from Pondicherry

A laid-back and serene place, where the efflux of time is slowed quite a bit, buildings reeks of history and every street corner make you meet a motley crowd of people in jocose and where cycle and cycle-rickshaws still find a place in people’s life as a mode of transport – that is Pondicherry for you.

Mind you, what I am talking about is may be 10% of Pondicherry by the beach side the  places which were built by French settlers during 1740s – rest of the city is just as rambunctious as it can get typical of any Indian city. Thankfully that 10% is preserved till date without any alterations and walking those cloistered streets metamorphoses you at least 30-40 years back in time.

The best thing to do in Pondicherry is to walk – yes you need to be a peripatetic to enjoy the each and every nuance of Pondicherry – to visually devour it’s vibrant colors, doors, windows and gables of its heritage French and Tamil buildings and also the French streets like Rue Da La Marine, Rue Campagnie etc. It would be any photographers delight to take a promenade along vintage Pondicherry and click away it’s beauty.

The next best thing in Pondicherry is it’s beach. But unfortunately the stupidity of the Government has robbed Pondicherry of a genuine beach experience. In the name of preventing Tsunami tones of boulders are laid on the beaches running kilometers along the shoreline. The boulders are well below the ground level and I don’t think it serves any purpose of preventing any kind of sea erosion let alone a Tsunami, they are not even forming a wall. So the best thing you can do is sit by the sun bathed footpath by the sea or find a nice boulder to sit and relax and listen to the breeze and watch a distant boat sailing into horizon. Even though a genuine beach experience is robbed it’s still a nice place to loaf around and especially if you can hit the beach early in morning to watch sunrise. The whole sea front is covered in a mélange of red and orange and typical of Pondicherry you get to see a motley crowd around, making the whole milieu bubbling with life but still maintaining the trait of tranquility which I feel is the trademark of this place.

If you want a real beach experience and intend to stand by the waves, then you have to travel 15km either towards the North to Auroville beach or down South to Paradise Beach. I went to Auroville Beach and careened myself along the long shores of Auroville awash by the waters of Bay of Bengal. If you are ready to walk a k.m. or so from the beach entrance from the roadside, you can get a pretty calm and pristine beach front. We got a good collection of shells from these undisturbed parts of the beach – including star fish, oyster shells, and snail shells etc.

Apart from a Photographers delight Pondicherry can also boast to be Gourmet’s delight. From Indian to French to Italian you get every rubric of food here. We had a typical Tamil break fast of Pongal, moved for an Authentic Italian Pasta in an Italian restaurant for lunch and then for French Pan cakes with strawberry syrup for snacks. There are quite a few French and Italian restaurants all along the heritage area. Notable among them is the Le Café in the beach front. Head there in the early morning for a French Coffee and Sandwich or cakes. We had a nice French Latte at Le Cafe early in the morning witnessing the day break in eastern horizon.

In Pictures

From Vibes from Pondicherry

What to do at Pondicherry?

  • Take a heritage walk and enjoy the heritage buildings like Raj Nivas, Legislative Assembly, Aurbindo Ashram and plethora of others. You can cover the entire heritage area in about 3hrs
  • Have Google Map in hand, Pondicherry is a small place, with Google Map in hand you can easily walk through the streets
  • Try out different options of food
  • Hit the beach early in the morning, witness the day break, jog along the footpath through the entire beach [I jogged was 30mts there it was awesome]
  • Take lot of pictures if you are a shutter bug

Stay

We stayed at Hotel Corbelli in Mission Street, the advantage of this hotel is it’s very near to the beach and heritage area. You can walk down the street and reach heritage walk ways and further down in 10mts you hit the beach.

That is it from Pondicherry. “Give Time a Break”, as they say in Pondicherry Tourism promotions, true to its ad, give Pondicherry a try to escape from hubbub of city life and travel back in time for some serenity and copacetic break.