SelfModifying

Red Its Like Ruby for Javascript

| Comments

If you had asked me about doing this 6 months ago I would have said that it would be worth it.  It would be too hard and be a ton of work to get it functional and even then it wouldn’t be good enough to actually use.  After seeing this video I’m glad I am wrong.  This is totally sweet.

[vimeo http://vimeo.com/2189212]

Wrapping Things Up in Chennai

| Comments

This trip has been a blast.  I really hope I can come back here.  I’ve decided that I’m not much of a camera person and the next time I travel I need to bring a video camera or something.  I keep not knowing what to take pictures, and then I realize that I just want to capture the whole thing to show people.

Happy Diwali!

| Comments

I was awoken this morning at 4:30am to loud fireworks going off.  The most obvious source was about 100 feet down the road from my window, but I eventually heard the entire city erupting in explosions.

I was half expecting this when I went to bed.  Yesterday was filled with it’s share of random fireworks being set off in the street.  Sriram warned me to keep an eye out if I go out on foot because you never know where these things will go off and people will assume you are alert.  Today has been a constant barrage of fireworks all around the city.  It is now almost noon and the fireworks haven’t stopped for more than 30 seconds, and that was a notable lull.

Diwali is celebrated here as the day that Lord Krishna defeated the demon Narakasura.  The fireworks symbolize this defeat.  Apparently elsewhere it has different significance, but equal festivities.  The holiday is also referred to as the “Festival of Lights” because during the days before, during and afterward, people place oil lamps in all of the corners of their houses to drive away the darkness.  In fact last week it wasn’t uncommon to see people’s computer desktops adorned with animated oil lamps in the corners of their screens.

Another significance, at least here, for Diwali is that it is supposed to be the day that all water is coming directly from the Ganges.  By washing in the Ganges river it is believed that all of your sins up to that point are washed away.  Because all water today is to have come from the Ganges people take a bath and then put on new clothes to mark that their sins have been washed away and that they are starting anew.

Sriram is going to try and take me around to see some of the celebrations.  His aunt died earlier in the year and according to tradition his family is not supposed to celebrate any festivals for one year.  This leaves him a little more free today to be my tour guide, which is very nice of him.  I hope to have some pictures at the end of the day to show what this is like.

Data Driven vs Logic Driven

| Comments

My recent work has had me diagnosing some fairly common issues that one sees from developers moving from a language like PHP to Ruby on Rails.  The PHP philosophy (as I remember it) is to not restrict how you work and to seamlessly weave your code and your views together.  For very small websites this is fine.  I’ve even been told that this works really well for situations where most of the work is happening elsewhere (think Actionscript and Flash), which forces a kind of modularization.  Regardless we end up with lots of code and the persistence/database ends up being where we put things to remember them.  I’ve started calling this logic-driven design.  I’m not sure if I’m stealing someone else’s term, but it communicates the essence of the idea.

Logic-driven Design
To me LDD has a few key markers that make it stand out:

1. The persistence engine is used to store data and little bearing on the logic of the larger system.
1. There is no abstraction layer in which to place business logic.
1. The business logic emerges out of the flow of logic, rather than from some modular abstraction.

Most PHP programs that I have looked at fall in to this category.  Only as the project size grows past a certain complexity does one see PHP projects with more explicit abstractions around the persistence layer.  The reason this is done is because at a certain size in a project a programmer can no longer track all lines of logic in their head and continue to develop the application efficiently.

Data-driven Design
This addition of an abstraction layer around the persistence engine that is used for managing business logic is what has been called data-driven design.  This is obviously not a new idea.  In fact one of the points of pride for me in using Ruby on Rails is it’s particular grace in working in this manner.

Data-driven design aims to drive the logic and output of the application directly from the persistence engine; the data source.  The convenient side-effect of this design approach is the adjustment of most of the business rules and how the application behaves is matter of changing records in a database.

PHP to Ruby on Rails
Ruby on Rails employs an MVC architecture.  This architecture is designed to support data-driven design by providing a powerful abstraction layer for the persistence engine (the model).  Rails has a particular sweet spot for social web applications for this reason.  The framework excels in user generated content, as this is a form of data-driven design.

Developers moving from PHP to Rails often miss this shift in thinking when they make the jump.  The result is code that is primarily located either in the controller or the view layers, since this is analogous to PHP’s logic-driven model.  The end result is very heavy controllers with big functions that do a bunch of logic on database records, and then render it out to the user.  In this paradigm the Rails models are only used to retrieve the record and nothing else.

When Rails moved from solely MVC to a resource-based approach a few members of the community had some negative feedback.  Some people feel like the resource concept makes development in Rails more complicated.  What I’ve seen in practice however leads me to believe that the real difficulty with the resource based approach is that it forces you to make the jump from logic-driven to data-driven.  PHP style development becomes contradictory in a resource based rails application.  Instead you have to think about the “resource”, the entity that will affect and be affected, and build your application around that.

Mahabalipuram

| Comments

So this weekend was amazing.

On Saturday afternoon Sriram took me out shopping and touring around Chennai.  It was very neat.  The city is big and I got to see first hand how traffic can get.

More to Come…

| Comments

I’m getting ready for work right now and hoping that my pictures will make it up to Flickr before I have to pack up to go.  I’m going to write about my weekend this evening (my evening) so look forward to the next installment when you wake up!

Twelve and a Half Hours of Jet Lag

| Comments

Wow.  I’m in India.  After 2 long days of travel and 20-something hours of air time I made it.  As it turns out India is really far away.  My flight took me through Tokyo, Singapore, and finally to Chennai.  Unfortunately I arrived at both Tokyo and Singapore while it was still dark so I wasn’t able to take any pictures.  When we left from Singapore though, I got to see the city and the insanely crowded shipping lanes during take off.  I have never seen so many huge boats so close together all over the place.  It took us probably 5 minutes to fly over all of it.

The most interesting part of the whole trip actually was this last leg.  I’m pretty sure I was the only non-Indian on the flight, and it was funny to see these huge families getting really excited at the gate as we were about to board.  Clearly this kind of travel is rare in India.  Under different circumstances I probably would have found this refreshing, but by this point I had been traveling for more than 24 hours and was running on close to 4 hours of sleep so it was borderline annoying.

The flight was pretty uneventful.  It is very funny what kinds of cultural differences that we usually take for granted.  One thing that I noticed was during the flight people would stand up in the aisle and chat with their friends.  I think on a US flight the attendants would ask people to sit down.  I definitely felt more crowded on that flight than I would normally.  Another funny thing that happened, actually on all of the flights, was that people would, upon arriving at the gate, very quickly grab all of their stuff and try to run up to the front of the plane so they wouldn’t have to wait.  This was hilarious at the time for me because it seemed like such a rude thing to do, but it didn’t phase the rest of the passengers since they were just as eager to do the same thing.

I’m guessing that most of the people who were traveling from Singapore to Chennai were using the trip to buy cheap electronics.  I’ve never seen someone check a 42 inch flat screen TV, but seeing more than one get backed up on a baggage claim belt was great.  That and the sheer amount of duty free alcohol!

I’m here!

I was met at the airport by Doug and KK, two of my co-workers.  Doug is an LA native and has been living out here for 2 months now, so he’s got a pretty good idea of what I need to know in order to survive.  From the airport, after the most terrifying traffic I had previously (but not subsequently) experienced, I was dropped off at my hotel.  The room is pretty nice and most importantly the AC works.  By this point it was midday and I was struggling to stay awake until dark so I asked Doug to grab me when he was heading back in to the office in a couple of hours.  I slept for 45 minutes, unpacked, showered, and changed.  And then I got to meet the whole office.  By this point it is Tuesday afternoon (my flight left LAX at 2:30pm on Sunday).  By the time I got back to my hotel it was all that I could do to stay awake until 8pm.  Before that though I had some delicious Indian food take-out.

I’ve been very fortunate to have some obliging hosts while I’m out here.  Sriram, the project manager for my main project has taken me under his wing and been making sure I get to see the sights and experience the city.  I didn’t have any tourist-y plans when I came out here, so having him tell me what is good to see is nice.  He has been giving me a ride to and from work since I got here and I’ve had lunch with him and most of the WebWrite team (my primary project) for the last few days.  Despite the lack of familiarity in this place I have felt nothing but warm welcome from everyone.

To come

Well, I’m going to try and get some video of my drive to work just so you can see how insane driving here is.  I already miss my chance at a picture of a cart pulled by an Ox walking down the main road as we tried to pass it.  But I’m sure something equally novel will come up again.  I’m going to keep my Flickr account updated with images and video as they come in.  This weekend I’ll be going out shopping, and I’m going to visit a Hindu temple thanks to Sriram.  I expect to have some fun stories come out of that.