Tuesday, October 21, 2008

Virtual Machines

Virtual machines:
You may like it or you may hate it; but there are many singular things that Java programming language should be credited for. One of them being, making virtual machines such big success, that it is today. With .Net, Microsoft took this to next level; supporting multiple languages.

Now, Java platform is striving to incorporate the same by bringing in more languages like JRuby, Scala, groovy etc. All of this appears to be big confusing chaos with platforms fighting to gain upper hand,  However it clearly also indicates deeper and deeper penetration of virtual machines in day to day computing.

As VM's mature, more and more languages are beginning to port themselves on one or the other available option. The latest one- i heard of is perl.
 
I came across this very interesting article that was posted recently:

Virtual machines for all seasons

I like the way author thinks about the future day Operating System's having a component called Virtual Machine capable of running programs written in any language.
This would mean programmers writing programs in any language (of their choice) testing it on their box (platform of their choice) without caring about what platform the program would eventually be ported on.

Nice Thought!

 

Blogged with the Flock Browser

Tuesday, October 14, 2008

Fun Weekend

I have had a great weekend. Instead of describing my experience to each one that I know, individually - I thought it would be smart to blog it once here and quickly. of course i can blabber about it but for that you will have to call me.
So where have i been and what did i do and what has become of my weekend ? well the rest of the blog is all about that.
To begin with, I have been to not one but couple of great places and an exciting event making full use of long weekend here. long weekend b'coz 13th October was a national holiday here as the day that the Japanese enjoy as health-sports day. I wonder what would be an un-healthy sport! anyways..
October 11th 2008,
Destination: Makuhari Messe, An international convention center in Chiba, Japan.
The reason we ('we' b'coz it was 5 of us) wanted to be at MM was Tokyo Game Show, an event held here every year.
TGS is one place where the latest and the greatest in computer gaming industry gets exhibited to general public or to be more precise computer gaming freaks. It is a 4 day long event with only last 2 days for general audience.
To be honest I am not a gaming freak, but I would be lying if I said I did not enjoy it. One thing I was not surprised of; is the huge crowd at the convention center, one coz I know Tokyo is one of the most populous cities in the world and two coz people here just love gaming.
In addition to the games, the event was spiced with free goodies, original merchandise and smokin hot female models on all booths :D. okay..back to the point, All in all a great event - I myself got some pictures (not of the models though) you can see the number of big shots in computer gaming who turned up and the huge crowd that overwhelmed the whole event, making it easy for someone like me to call it a success.
Done with TGS, with still the whole evening left to our discretion- we started for our second destination Tokyo Disney Land, not that i haven't been to Disney before but this was more for a colleague who had not been to TD land. We tried all possible scary rides, Sadly, I didn't manage to take great many pictures in Disney probably because we were tired and also because i am yet to acquire the skill of using camera while on the ride (wonder what fun would that be). At last we wound up tired and taking a train back home with three of us still looking forward to plans we had for Sunday.

12th October 2008, TGS and Disney had practically taken a toll on ourselves and more than that the failure to rise up early - made us cancel the plans to go Universal Studio, Osaka.
We decided to go Fuji Q!
I had always wanted to go Fuji Q - coz i had always wanted to try the rides there, well this was it, but little was i aware, what these rides were like and they turned out to be beyond what i ever thought they would be like. Rest is all in the form of pictures and the videos that I shot there. An amazing place that it is and as you would see in the pictures Fuji Q is known all around world for some of its scariest rides and its location (at the base of mount Fuji).
We didn't manage to try all the rides, as our plan was blemished by the crowd that had turned up (as it was a long weekend for everyone).
One thing I would like to mention, the scariest ride i have been on till date "Eejanaika" meaning "What the Hell" - though it is an incredible coaster; it definitely took all of our time queuing for it :(

In any case it was great and I'll sure try the other rides the next time i go Fuji Q for sure.
oh and some other rides i tried:
The Red Tower
Moonraker
Tonde Mia!!


October, 13th 2008 as you would guess was spent relaxing, speaking of this it was exactly this date a year before, I had landed in Japan.

Tuesday, October 7, 2008

The Last Lecture

A hectic week with full of hiccups and warnings, free markets in capitalist America just saw its favorite subject "Investment Banks" become history; and lets not even discuss the go - no go drama over 700 $B bailout.

Amidst this fuss with an intention of breather- I decided to turn back to what i like doing, visit the sites that (once upon a time) i used to frequent.

Having made my mind, to find out whats bleeding in java world...I thought who better to get this from; than Gosling himself. Though i was looking for something fresh that would cheer me up - i had no expectations as such.

I started surfing his blog but despite of ample material, that should have caught my attention; I got stuck with a small blog dated -July 2008..The blog was in remembrance of some Late Prof. Randy Pausch - I figured from the blog that this was some professor who had contributed a lot to the field of virtual reality and had shared campus with JG in Carnegie Mellon. The same source also revealed that professor had met his end just recently on 25th July 2008. However it was the last line of blog that changed the course of what i was planning to do with the rest of my day - it discussed of some "last lecture".

Next thing i recollect is listening to it, and to be honest it turned out to be one of the most extra ordinary session i have ever been to.
Thereafter discussing with fellow colleagues, I discovered that "The Last Lecture" was in fact an instant hit and very popular in US and the rest of the world right after the day, that it was delivered.

TLL has many takeaways but the most striking bit is the fact that it indeed is a last lecture from a very talented departing professor.
Honestly -I enjoyed it a lot and I am sure everyone who ever comes across it would only love it and not for today or tomorrow or years to come but for ages n ages it would inspire people to pursue their dreams (as did its deliverer when he lived).

Hats Off!

here
The Last lecture

Friday, March 14, 2008

Token management

Its a weekend...last week was damn busy..and i was all occupied.
Its better now and i am just planning to chill all weekend - For now I am reading Heinz Kabutz on Java Concurrency, listening to "Simon & Garfunkel - The only living boy in New York". And Ofcourse I am composing this blog.
Here is something i learnt last week. Had written some methods sometime back and now was the time to move them to live environment.
I took sometime refactoring them, I discovered a stupid flaw in my design (it was no big deal).
The flaw was to do with tokens! Wellll i still use tokens for things for which i think xml would be an overkill- this was one such instance.
I wrote a method that would just take the string name and the token as arguments and return me tokens! simple as that - List getListOfTokens(String origString, String tokeniseOn).
Like any loose API- the method got abused!
it got called from all over the place with people using it for different tokens- well i must admit that was what the method was originally written for...
But if you have a parser that has token nesting - and uses this method it can be pretty nasty!
for eg- tommy;gina;Jovi, Bon;Sambora, Ritchie
Imagine if u used the method like the one above to quickly manage these, u would loose track easily if there are many calls to it. Imagine if token changes and someone decides to use ":" instead of , !
In my opinion if you ever decide to put together something thats to deal with tokens then consider having all your tokens together - like say contants declared in one place..
for eg:
FIRST_LEVEL_TOKEN=";";
SECOND_LEVEL_TOKEN=",";

This would definately ease managing tokens across project much easy.

Saturday, March 1, 2008

Performance while designing

Is performance a factor to be considered while designing ?

This weekend, I was out with two of my friends with whom I met after long.
All of us are IT professionals so obviously it was not long when we started debating on this interesting topic (at an Indian restaurant).

In that cold dead night, the kind of tiny hotel was overwhelmed with the noice of our arguments.

Though the debate ended without any conclusion like all such debates do (it did consume couple of hours), I could not help letting it go off my head.

So here I pitch it to large audience in an attempt to seek an answer.

I think performance should not be considered while designing a system, i have been into such discussions before.
I am sure most of you ( sure not all of you) would be surprised.

So here goes explanation for what i just said and some effort that i put validating my stand.

let me start with what I think performance means.
Performance as per dictionary is the manner in
which or the efficiency with which something reacts or fulfills its intended purpose.

who gives a darn, in programming or rather SDLC it means efficiency with which something fulfills its intended functionality.

A lot of people normally missunderstand performance for just spead which is incorrect.

The second thing i would want to describe is the Design phase and its role in SDLC.

I believe When one sits to design, one should be sure of what the user wants. s/he also should ensure of what user needs is actually something that deserves to be done in the first place.

But one would argue - most of the applications in our age definately come with performance requirements right from the user.

for instance its very acceptable for a user to tell you right on the first day that he would want his application to process some "X" number of txn's in a sec.

So should this not mean we should consider this requirement while designing ?
Well you definately should but there is a catch, for something to be perfromant it should first work!
To put it in a simple manner I would first strive to design something that meets the goal (processing txn) and then care about effectively doing it.

This is just like- if I were to write a crucial mail, i would first compose the mail that covers all the points that i want to communicate accross and then care about how efficiently i wanna say that (ofcourse like most of us do spellcheck just before they do CTRL+ENTER in outlook).

To ellaborate this further when i sit to design, my goal would be to write a system that meets what it is originally supposed to do along with the implicitly understood requirements like extensibility, scalability.

by scalability what i mean here is when user says x txn's i shld write a system with clear interface and modular enough to support it.

However, clearly Design as i see should focus on things like scope, input points and input, output points and the correct expected output.

I dont deny requirement of the performance should be sitting somewhere back and should only influence how good you design the system to respond to the changes that come up in future.

You may just mention it to the implementers for them to be able to meet it.

Here is a small article with Martin Fowler ( he is the one who favours agile methodologies like refactoring, TDD and extreme programming).

http://www.artima.com/intv/tunableP.html

As can be read in the article as well, a modular class, module or system can be changed internally for better performance without impacting the "publicness" that it has.

I believe performance is more of implementation and Design is more of architecture and interfaces.

One thing i believe clarifies my point is that none of the OOAD design diagrams (neither the SSAD ones) have any way of depicting performance!

Even the most detailed ones i.e. the statechart which describes something as elementary as methods in an object, has no provision to talk anything about performance.

According to me at design you can leave it as generic as "Function Z does A (using B) and returns C, it would intake D and E" where B should be described the least, you should leave it for implementers to decide what they want to use.

The last thing i would want to add here is some of the systems like lets say algorithms are somewhat an exception to my prose above, most of the times we know what an algorithm does and they are just re-written for performance.

Even otherwise sometimes when they are written for the firsttime it has performance at its core and the core functionality is as generic and well understood as just to hold something or sort something.

More to this an interesting post on Sun website by Brian Goetz who actually advises to defer Performance late untill development and even beyond it. The way he puts it "Write Dumb Code" Search for the phase at http://java.sun.com/developer/technicalArticles/Interviews/goetz_qa.html

One thing worth noticing in his article is he talks of keeping a performance metrics with yourself. This for me is like saying "Write that 100 Txn thingy somewhere, thats what we need to test for later".

This is a lot more serious than what meets eye, considering performance religiously while designing may lead to not enough generic design!

Its tricky but true its like saying have the performance criteria's with you but dont bother about them when getting things to work first.

I hope I have made my point clear ?

Do reply and let me know what you think, I would love it if you could support it with a real life example it would be nice for all of us.

Thanks,
Ritesh


Addendum: Wikipedia for optimisation has famous quote by Donald Knuth on premature optimization:
http://en.wikipedia.org/wiki/Optimization_%28computer_science%29

Thursday, February 28, 2008

What's in a name!

What a shame it would be, if you were a painter & you had to explain all of your paintings!

Well, shoudnt be difficult to imagine; if you are one like me. A developer, coz all most of us do is "Sit n Read Code" :) Ok some of us are lucky enough to make changes as well bbbut even that to already written code!

Tell me honestly how many times have you cursed the original developer for mess 'making? Wellll i am sure almost always.. C'mon Life need not be so difficult.
So then what's the solution? - "Delegating work" - of course not.
You know what it is!
Lets just vow today, that every time we sit back to write code we will make it as simple and readable that people would think twice before saying "Comments Please!"...I mean it really sucks writing something like "Code below does blah blah blah blah...".. I am yawning already.

There is a lot to readability of code- one of the important aspect of making your code readable is Naming.

If you think about it - its nothing new...we always loved naming things! in fact we need names.

Don't we have names for just about everything around us -be it a country, city, individuals, pets etc etc and we do name things to make sense at least within what i call the "scope of an object" for instance people belonging to one country will normally have names that they can relate easily, on the contrary they might not feel the same for names from a different country (scope).

Further to this certain set of names in a scope are reserved for only a certain type of objects( well not always but most of the times :) i'l write about exceptions later).
So, why should one name things properly - coz we luv abstraction..it saves us time - believe me.
When you say "John weds Lisa"...its clear who is the bride and who is the groom.
Imagine if we made method names as descriptive! Well someone debugging the method would not be required to dwell into it; if not absolutely essential - you see what I mean. Believe me he/she will not curse you.

Naming is not just about being descriptive and scope - It also should convey how you plan to use the thing (variable/method/object etc). Perhaps let me put it this way, I don't mind naming a variable as "i" -if it only helps a for loop. However i would never have a instance/class variable named "i".

To add here i realised ( reading a java book) packages in Java aid naming in a way...

Can't think of an alternate way of adding two Date classes (one in util and another in sql package).

I believe if Shakespeare was made to develop programs he would take back his famous quote "What's in a name!"





Thursday, July 19, 2007

I am a Critic!

I am a Critic!
Well thats what they call me, and sometimes I do agree. I can’t think of a single body nor object on this planet (not that I know) that I haven’t criticized as yet.

Well, to be frank- I don’t know when I got metamorphosed into this *ever criticizing* maniac that people say I am today; but sure this is not sudden, things don’t change overnight you know.
We are all critics in some way or the other, its just that most of us dont vent it out and some like me do!

I mean look around you and isn't it a *norm* of 7 guys trying to fit in a 6 seater on a bus leaving not a single soul comfortable.
People around you who crib all the time, we hate them but they do influence us. ah... some people call it negative energy :).

People trying to spy on every bit you do forgetting that little thing we call "privacy", people asking one all sort of questions (just about anything that comes to their mind) , people pretend to be smart & getting applauded for doing absolutely sick things. Those who pretend to care when they don’t give a damn. The ever targeted *we hate deo* gang, the extra smart girls who think they are second cousin to Einstein , I even found some I thought would charge me heavy for just trying to talk to them….Gosh…. What about auto drivers who think they can better dijkstra's shortest route algorithm. The population that leaves every single inch of our spectacular road utilized. Know whats even more disgusting, just do this when you next time hit the roads- have a look at them and u will see a red patch in every meter – well thats not a modern day better substitute for bread crumbs that someone left deliberately so that they can find their way back home- this is what MTV calls *Dharti Ke Laal* Effect. (www.dhartikelaal.com)

Ok so time for some personal experience - How would you feel if you go to a so called decent restaurant and order something *hot* to eat and end up served molten lava that appears like food but leaves your palette too bad to gulp even a drop of water. Well thats what they call HOT here.

What if you pay for a cozy room in a hotel on a hill station and end up staying up all night just to keep monkeys from sneaking in- I mean monkeys ..aw common! –Funny huh but aint so funny to experience my friend.

Ok want more – so you reserve two berths in train for yourself and your close buddy and someone has nerve to ask can you *adjust* with one so that their extra large family can be made comfortable. (Ah….well believe me I am straight and I mind it!!).

What if people around you crack jokes that you don’t understand and burst out laughing for next 20 minutes leaving you no clue!

What is it like being quoted “Kya Tulsi is kaa faisla kar payegi?” and further more they go to an extent of banning good movie channels ( the only ones that you enjoy) so that you can answer this biggest question troubling Universe today.

What if you get asked “where are you going?” every single time you step out.
What if you are committed vegan and a waiter at a very reputed chain is indecisive to tell you which pizza in his hand is veg!
What if you go to a bank every month and employees there despite of knowing you very well make you sign (atleast) 10 times just to verify that its not some sort of forgery you are doing trying to get a meager amount out of your dads pension deposit account!

Believe me thats not all and there is more I can tell you but all I am doing is Critisize :).
Every thing above is a reality and I think its high time We should all either ignore it or do some thing about it…I now firmly believe world can be either black or white and my crime so far was trying to locate a shade of grey in there.