Thursday, May 3, 2012

Code aging:Can a computer program age?



Aging is a life phenomenon. A life always age from birth to the day it ends. A computer program also dies; we in software industry like to replace a piece of code with completely a new one. We do it by rewriting the software. Here is what happens for software:

Birth: We write the software with a purpose.

Growth: We find some bugs in the behavior of the software; we fix the bug. We do it again and again.
One fine day we feel the software is bulky to fix bugs or the purpose has grown to such an extent that we need to rewrite the software.

Death: We rewrite the software and replace the old one with the new.

How a code age? Here is how it happens (IMHO):

Software gets fat by added code all the time. We add code to fix bugs, to add feature etc.
Code becomes complex. As in life, with time, code also becomes complex by code complexity (like if –else –then). It so happens, that code becomes complex by overloaded methods, multiple entry points, more than one way to do one thing, etc. With time it becomes hard for the developer to understand the code.

The code can also age due to library it uses has aged and being replaced with newer one. Even the programming language may have morphed. Like in case of Java, concurrency, generics, etc. are making some code look old.

The other indicator of old code is its interfaces and deprecation. If an interface is filled with same methods with just parameter or return type mismatch (overloads), I suspect the code has aged.

That’s all that I can think. If you know any others please share.



Wednesday, April 25, 2012

Why I Code or note to my first love?


I am a programmer. I code every day. Why I code? Here is my answer.

Coding is an activity where I can write a program and computer will execute it. It started with very basic use of computer. I gave a command: date and it printed out the date. It was amazing. I was four years old and I started thinking how it came to know today’s date. Some years fast forward, I got into the computer lab of my school (no computer was not a subject for a 12 year old in my school, it was just luck that I was able to go inside my school computer lab), a senior was coding in Basic. I asked him what he is doing. He showed me what he was doing. I said to him can I do a simple multiplication? He said why not so I wrote (under his instruction) a program that multiplied two numbers. My first love started.

The feeling was something like a master and slave. I am your master and commander you follow my orders. This is my first understanding of coding. I understood that if I code it right it will do what I want it do. So computer gave me my first feeling of being master of something. I was not so popular among kids so I had time to play with school computer. It gave me opportunity to learn how to tell computers what to do. So then I coded so I can tell my pet what to do, and that was the reason I used to code that time.

Late in teenage, I realized that people around me were getting their friends. I mean someone special in their life. They used to spend a lot of time with them, talk to them. College was full of people who were dating. I was not even a cool guy in college. So I needed something to hold on. In our college lab we used get access to computers during college hours. So I started to show up in lab in the morning and screw all classes. I used to code. I used to code in C. I felt like I am at last in peace with the world.  I felt like I am in conversation with computer. So now I started coding to communicate to the computer as a friend. A friend who will be with me, always. My first love.

Next I joined a company as a programmer. Where I saw and met a lot of programmers in the company. They are all amazing people. I started working on code. I came to know that you do not write code from scratch you take others’ code and maintain them. I used to see code comments with bug ids, I used to go to the bug tracker pull up those bug ids and saw the names of people who worked on them. The code was talking to me, some of them were so clear as if I have coded them. Some of them were a bit awkward, hard to understand. Then I realized that I was talking to them, in space time continuum I was there sitting with them in conversation with other programmers. I was debugging the code – also trying to map their mind for a sorting logic, searching technique or a trivial account money transfer between two currencies. In all this I understood that why it is a programming language. The value of code readability, the value of lambda calculi or Turing Machine, all of that I came together so that we programmers can talk a time apart. Computer became a paper, programming be the language. My first love metamorphosed to me again.

So why I code my love, is it because I love to code or is it I want to communicate to some unknown programmer in the future. I code because I love you. I want to remain with you and discover you in my old age that I have reached a position where I can say, I know why I loved you for so long. My guess you will guide me to my nirvana. I will rest then at peace.

Monday, March 26, 2012

Needed a better Twitter so we made one for ourself

Yeah! We are out of our mind, or may be not. We felt a lot of things can be improved in twitter or micro-blogging for that matter. So what all things that we wanted to improve in a micro-blogging service:

Posting:

Give some more characters darn it. Have you ever felt like that you just need that extra 10,20 or so characters in your tweet. If so read on.

Why the hell I need to go to another service to shorten my URL. That's pretty basic. A micro-blogging site should do it automatically for you.

Following:

Why not follow my interests - in a wholesome way. So following people gives me a lot of sh*t. I have to wait for my meat. I will jump on to a conversation, if I find it interesting. One more thing about interest is it's not always people but tags. Some tags are interesting enough to follow and get a stream in.

Tagging:

This brings me to tagging. Tags are meta data not data. Please don't clutter my post with #FOO and #BAR. I should be able to add tags separately.

Can you help with suggesting some tags for a link. So we wanted an auto-tagging system, it need not to be perfect (as long as I can remove suggested tags which does not make sense), but give me something.

All this can be done. We need to do it for us. So we did it. If you are interested take a look at: ScoopSpot.

Friday, March 23, 2012

How we made a social news service with machine learning from scratch


How do you get to news which interests you in Hacker News or TechCrunch or The Next Web or the ReadWriteWeb? I mean when you go to a news website do you read all articles or do you scan the article titles and try to guess which ones to read based on your interests?

In my case I have noticed that I am looking for the news which interests me. Like startup news, Java or Ruby programming language news. So it beg the question can I build a system which scans through all the news and then classifies, indexes all relevant terms and serve to me so that I can get a stream of news which I would like to know and read about.

So we(my friend and I) started building a system which when given a website link does the following:

It tries to get the relevant content from the page.

It uses natural language processing to understand a bunch of things like: sentences, parts of speech etc. We score the word relevance in the article.

We also do classification and clustering with bunch of statistical methods of the article to find out which category an article belongs to. Like is it a technical or scientific or law related article.

Once we got the meat of the document we tag it with the terms that we have identified with the above steps.Now we were faced with the challenge that how can we make it available to us. We needed a web site which will allow us to see the content in stream. We should also be able to customize the stream to user’s choice. So we thought of creating a micro-blogging site, after all, we just needed to put a post with article title, URL and the tags. Here is how a post looks today in the stream.

If you would like to see a full stream:



As you can see here that I am seeing news with startup and java. As I am following news related to java and startup.

We noticed that we need more character support than 140 character of Twitter so we increased the character limit to 300. One more choice that we have made is adding tag separately from the actual post. This allowed us to add as many tags as we want. We feel tags are more like meta information so one should not be limited with hash tags.

Once we have such a system, we needed a way to get the latest news from Hacker News, TechCrunch, TheNextWeb etc. RSS feed came to our rescue. These websites provides RSS feed which we read periodically. We created an account called news in ScoopSpot which will do the posting in our micro-blogging site. If you would like to see news in action, visit: http://news.scoopspot.com/.

So now if a user comes to our web site and post something with an article link we are now able to auto tag it.

Here are some links to tag based pages:

Ruby: http://www.scoopspot.com/Ruby

Startup: http://www.scoopspot.com/Startups

Steve Jobs: http://www.scoopspot.com/Steve_Jobs

If you are interested to try it out you can visit: www.scoopspot.com

Wednesday, February 22, 2012

Ten Commandments for How Not to Become a Good Programmer

  1. thy should never waste time in reading about code
  2. thy should always respect your IDE and carry it all the time with you (in a USB key)
  3. thy should always find a non-existing requirement in mind and code for it
  4. thy should never write a comment
  5. thy should show your karate in all obfuscating syntax
  6. thy should show no interest in algorithm and its implications
  7. thy should always be shy away from mathematics
  8. thy should never test your code extensively; those who do are weak
  9. thy should write in abbreviation it will communicate more in less characters
  10. thy should use GOTO always
That's all I have.

Thursday, February 16, 2012

REST will stay – you can wash your SOAP away

REST web services will stay. It is a bad thing to predict future of technology. But I am ready to bet on this one. REST will stay. It will stay because of multiple reasons, and today I am going to give you mine.

  1. REST is simple. You can create a RESTful web service easily. I mean very, very easily. Actually you have been doing it all along if you are in web development. Every page in a web site is an example of REST web services (hold your concern a bit more), the only difference is your client is a web browser.
  2. REST is succinct. You can do almost everything in REST. If you cannot do something in REST chances are you do not know how to do it yet. It’s succinctness is so powerful that you can do some great magic.
  3. REST is easy to learn. If you know web development you know rest. If you need to expose your database to the web – you just need to provide a URL (with all query string and HTTP headers). Whatever is running in the background for your web server (or app server) can return the data using JSON or XML. That’s it.
  4. REST is scalable. If the dang thing supported the Internet to scale to what it is today – it can scale your web site also. Even if you have more data than Wikipedia.
  5. REST teaches you a lot more than anything else. With other web service standards – you are limited with the framework you are working with. But not with REST. It does not impose you anything – no configuration, no heavy tricks, no non-sense. Follow the conventions and you are there with your service. As it does not have any heavy stuff so it push you to think in simple terms and help you build a system which easy to maintain and consume.
  6. REST service is ready to be consumed anywhere. I mean as long as your server is reachable. So you need no fancy pant client library to work with.
  7. REST will stay – you can wash your SOAP away. If you are not with REST of us and with some other stuff. Think about the future where everyone will have a handheld try to access your service. They will have different architecture and software stack which you do not know. You will have to serve data to all of them and your SOAP will wash away.

That’s all I had in my mind. What do you think?