Saturday, January 10, 2009

Cool applications I will probably never have time to write

Here is a list of ideas of web services that would be helpful but I would probably have no time to write. Maybe someone else would...
I'll add future ideas to this page. If you have some of your own, I'd be happy to add them. Even better if you know of a service like this that already exists let me know.

4. Software libraries release tracker (2009-01-10).
A web based tool where I can list all the third party libraries I use for my projects and can be notified (email / RSS) when a library I'm using released a new version. It would also be nice if I could upload a CSV file with my libraries and the current versions I'm using and get a report of what I need to upgrade.
Advanced feature: test libraries transitive dependencies and warn me about possible collisions. For instance, Hibernate is dependent on Log4J version x.y.1 and Spring is dependent on Log4J version x.y.2 - Since I use both Hibernate and Spring I want to be warned about possible incompatibilities I may encounter.
(note to implementer: maven has support for something like this so maybe use it as the core for this)

3. Contact name ring tone (2008-12-20).
When your friends call you they don't introduce themselves because they assume you have caller ID. Now, what if you use a bluetooth earphone? Your phone is sometimes tucked away in your bag (for instance when you drive). When people call and immediately start talking - it sometimes takes a while before you figure out who it is.
The solution is to have your phone figure out you're using an earphone and play the name of the caller instead of the regular ring tone. I guess it would do that by doing text-to-speech on the name in the phonebook entry.

2. An online log collector (2008-12-13).
The logs of your application are sent to this website (by HTTP, JMS, whatever) - You have a simple UI where you can view and query these logs.
What is it good for?
When you have a lot of servers you start finding all kind of weird ways or heavy weight solutions for collecting your logs - I'm looking for something simple.
Update: we created something like this for HiveSight: http://code.google.com/p/appenginelogger/


1. An online job scheduler (2008-12-13).
You have a form where you enter your job's schedule - it could be a simple input field where you enter a cron expression or if you want something more advanced look at the recurring meeting dialog of MS Outlook.
Then let me select from a dropdown list an action to execute (do an HTTP request, call a webservice, run a yahoo pipe, run a simple shell script, etc.).
These jobs will be run according to you schedule schedule.
What is it good for?
For various repetitive automation tasks, monitoring of web servers, anything you can do with crontab, you get the idea.

Wednesday, December 10, 2008

No such thing: "no vendor lock-in"

Every self-respecting framework or service always claim there is "no vendor lock-in" if you use their technology. I think there's no such thing.

What is a vendor lock-in? Can you measure that?
I think the best way to measure vendor lock-in is to estimate the amount of work it would take to switch from one vendor to its competitor or alternative.
For instance, switching from Tomcat to Jetty involves changing a few deployment descriptors. So vendor lock-in is not that big. What about the tweaking and tuning you did for your Tomcat, can you immediately do that for Jetty? I guess not. It will take some time before you fluently "speak" the Jetty language, so vendor lock-in is bigger. What about QA? your software was tested and working perfectly on Tomcat, how much time do you need to spend to make sure everything works on Jetty? So vendor lock-in is even bigger.

Another good example is the Spring framework or Hibernate. They both claim that your code is not dependent on their frameworks - it's true, you can write a Spring backed application with very little dependency on Spring in your code (unless you use annotations of course) but can you pull out Spring and replace it with something else? Can you replace Hibernate with another ORM solution that easily? No way - you're very strongly locked into Spring and Hibernate. In Spring they call it "dependency injection" - you can read it as "You don't have to write any code and we inject the dependency on the Spring framework automatically" :-)

No metter what frameworks you choose you're locked into it. So the only course of action is to make sure you choose the right ones that will not disappear any time soon.



Thursday, December 04, 2008

R&D Lab - You pay for your mistakes

I made a big mistake a few months ago. I bought a few servers for us to use in our office - you know, it's important to have a few machines at your disposal so you can run intensive tasks on them or run all kind of different tests you couldn't otherwise do on your single development machine.

Makes sense right? Well, not in term of ROI and here is why:

I bought a fairly good machine with 4GB of RAM and an AMD 6400+ X2 CPU - that cost me about $1000. Let's assume the machine is utilized for about 8 hours a day (in reality I guess most lab machines are used much less). Assuming 250 work days a year that's 2000 CPU hours a year. Let's say the life expectancy of this machine is 3 years so for 6000 hours I paid $1000. That's about $0.16 a machine hour.

Now let's compare this to a machine I can rent from Amazon EC2 (prices). Assuming Moore's law will hold true for the next three years (limits of Moore's law) today's EC2 large instance (m1.large) will be equivalent to two of the machines I bought for my office (I'm assuming that Amazon are nice enough to lower prices for a given hardware configuration as it becomes older). Add to my in-house investment the electricity / cooling / management (as in personnel) and it will make my (already) bad investment even worse. Oh, and for my in-house machine I had to put the money upfront and not "pay as I go".

Now what happens If I need more machines at one time (for isntance, to do some tests before a release) and none at another time (like every night). Having these machines hosted on EC2 gives me the flexibility to use as many machines as I need and then don't pay for the time they sit idle.

The bottom line - If you're a small startup - don't buy lab machine. If you're a big company you could probably save thousands of dollars every month by hosting your lab on EC2.

Monday, June 16, 2008

Twitter as a notifications hub

In HiveSight we're trying to keep eyes on our production environment as well as the status of services we need for development such as our continuous integration server and various other long running automation scripts we run on Amazon AWS.

We were looking for a way to easily see all the notifications as a single stream of data - so here is what we did:

First, we created a Twitter account where all the messages will go.
Then we made sure all notifications will be sent to the HiveSight Twitter account.
Now we can become followers of that account to receive updates.

Here are a few examples of what we used it for:

For continuous integration we're using Hudson - build results are sent to the twitter account using a plugin that was written by the Hudson community.

For production servers monitoring we're using nagios. Nagois is very easy to extend so we're using the twitter JSON API to update our account using the Linux curl command:
curl --basic --user "username:password" --data-ascii "status=Nagios: $NOTIFICATIONTYPE$ $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$" http://twitter.com/statuses/update.json
We use the same method to send notifications from various EC2 automation scripts.

We also wrote a twitter-log4j extension that allows us to log errors from our applications directly to twitter. We open-sourced it so you can find it here

Now that we have all the messages in Twitter, we developed a very simple Ruby script that is executed every few minutes, checks if there are new messages that require immediate attention and sends and SMS if there are.

Sunday, December 09, 2007

Maven repository on S3

Spring are hosting their development sub-projects Maven repositories on S3.
This is a great idea if you are hosting a project that's likely to have downloads here and there and don't want to pay for what you don't use - which is what you'd be doing if you hosted it on a regular hosting plan.
(On a side note - if you're working on an open source project you may just as well host it on SourceForge or Google Code for free - even if your working on a commercial closed-source project there are free solutions - more on that in a future post)

The nice thing is that Maven has its own support for S3. Maven has a subproject that's responsible for the transport of artifacts called "Wagon". It allows maven to transparently work with repositories that reside on File, HTTP, FTP and other locations.
Wagon also has an extension that allows it to work with repositories on S3 - so it makes Spring's choice even better.

Browse Spring's Java Config project on S3:
http://s3browse.com/explore/maven.springframework.org/snapshot/org/springframework/javaconfig/spring-javaconfig/

Wagon-S3 artifact for Maven:
http://mvnrepository.com/artifact/org.apache.maven.wagon/wagon-s3

Sunday, December 02, 2007

Computer Randomly Plays Classical Music

Look at this: http://support.microsoft.com/default.aspx?scid=kb;en-us;261186
This is the funniest error (feature) I've ever seen. The programmer who did this is a genius :-)

(got this from Elad)

Wednesday, November 21, 2007

C# 3 / .NET 3.5 / VS 2008

Microsoft released Visual Studio 2008 together with the .NET 3.5 framework and C# 3.
There are some new exciting features included in this release.
Here are some of them:

1. "var" - You can assign any object to a var (for instance: var i = 1). This is not the same as using "object" because the compiler (and VS) will figure out the actual type and make sure you don't make mistakes.
You can see how VS figures out that "j" is of type string and autocompletes the correct methods:





2. Simplified properties - Instead of having to write getters and setters blocks for class properties, you simply have to declare a "get; set;" block. For example the class User:



The compiler will automatically create the needed class fields.

3. Class and collection initializers - after you defined your class properties you can easily create a new class and initialize it with default properties.
So the class User can be instantiated like this:



4. Extension methods (duck typing in other languages) - You can add methods to an already existing class. You define a new extension method and the compiler will attach your method to any type that matches the definition - of course once you define the extension method, VS will become aware of it and will autocomplete it for you.

In the example below I define an extension method for the type "string". I want to add the "encrypt" method to string, so first I define the extension method - this is a simple method that encrypts a string but notice the encrypt method signature:

public static string encrypt(this string plaintext, string password)

It must be static and have the keyword "this" before the first argument. The "this" keyword will instruct the compiler to attach the encrypt method to the "string" class (string is the parameter type of the first argument).
Notice that the class is defined within the "Technital" namespace so only strings that are used inside this namespace will be affected (like strings in the User class defined before).



Here I use the extension method on the Password property from the User class (a string). You can see VS picked up the extension method and now offers it in the autocomplete box.



So here is the final result:



5. Anonymous types - You can declare anonymous types. They are treated as "object" and the compiler will internally assign them with a name. This is a feature which is used quite a lot with LINQ



6. Lambda expressions - C# allows using lambda expressions (which are just another way to define anonymous functions). They are defined like this:



And are especially useful when used together with LINQ (which I guess is the real reason why this feature was introduced):



Now comes the obvious comparison to Java...

When comparing these features (and considering how young C# is) you can't help but wonder how long will Java be able to hold its head above the water? I mean java stakeholders are still debating if stuff like delegates and properties should be included in JDK 7 (you can find all kinds of missing features here)
Not to mention killer features like extension methods or LINQ. We can only dream of having these in Java.

It seems like Microsoft are aware of the popularity of dynamic languages like Ruby - you can see they borrow a lot of the new features from such languages. They have developers in mind.

Sun on the other hand, are thinking of Mathematicians - not developers. They are so careful of making sure that every aspect of the Java language is mathematically valid that they forget that they are dealing with innovative software developers that want their favorite development language to be innovative as well.

The innovative developer that I am (or at least want to be) - I guess my favorite language can't be Java anymore.


Come on Sun, wake up and smell the Java.