General

Jruby Blues

Man today was one of those days, I am about to give up on Jruby. Don’t get me wrong I absolutely love the idea of Jruby, great way to sneak in Ruby into the enterprise. But I don’t think it is quite there yet.

If you want to use Jruby and Spring all you got do is include these dependencies into your pom file.

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
<version>2.5</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jruby</groupId>
<artifactId>jruby-complete</artifactId>
<version>1.0.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib-nodep</artifactId>
<version>2.1_3</version>
<scope>compile</scope>
</dependency>

And it works great,……………as long as you don’t have to use Hibernate. It just so happens that Jruby uses asm-2.2.3.jar file and Hibernate uses asm-1.5.3 and apparently the api is very different between these two versions, result is

java.lang.NoSuchMethodError: net.sf.cglib.core.Signature.(Ljava/lang/String;Lnet/sf/cglib/asm/Type;[Lnet/sf/cglib/asm/Type ; ) V

Man this is frustrating, I spent all day trying to work around the problem but no go. Now here is the kicker, it works perfectly fine in eclipse and I am using maven 2 ide .

I spoke with my colleague (Tim) about this and he thinks it works because of OSGI which allows different jar’s depend on different versions of other jars.

General

Erlang Blues I

So yesterday I had this bright idea to connect to MySql using Erlang, so in order to do this there seems to be two options one is to use a native interface completely written in Erlang or use ODBC . So I tried to use the native interface first.

There seems to be no documentation on how to use this, I finally found a blog with some so I gave it a try, apparently it only works if there is a password, if your password is null it will not. Frustrated I pulled out the source of the implementation, with the idea that I could somehow mess with it enough to get it to work, but the Makefile does not work. It was already 1 in the morning so I just gave up.

The second option is to use ODBC, but if I am reading this correctly you have to get erlang from the source and compile it with MySql ODBC drivers in order for this to work ! I had compiled Erlang on my computer last week, but I have no clue as to what ODBC driver I had used to compile. And too lazy to do it all over again.

Maybe I am doing something stupid here, maybe erlang is not really meant to be talking to traditional relation databases, after all once you start connecting Erlang to Mysql will it really be parallel ?   Maybe I should be extracting all the data into Mnesia.

General

How does Erlang Fare ?

Don Stewart recently wrote a blog comparing the time it took to compute Fibonacci numbers in Ruby, Python and Haskell, according to his results Haskell blew away the competition.

Here are HIS results

Ruby (1.8.5) 64.26s
Python (2.4) 25.16s
Haskell (GHC 6.8) 0.48s
Parallel Haskell (GHC 6.8) 0.42s

Since I am learning Erlang I wanted to see how Erlang does (please note I am a Erlang newbie) so here goes !

The Code

-module(fib).
-export([fib/1,for/2,start/0]).


fib(0) -> 0;
fib(1) -> 1;
fib(N) -> fib(N-1) + fib(N-2).


for(N,N) -> [fib(N)];
for(I,N) -> [fib(I)|for(I+1,N)].


start() -> timer:tc(?MODULE,for,[1,35]).

And the results

{3018587,
[1,
1,
2,
3,
5,
8,
13,
21,
34,
55,
89,
144,
233,
377,
610,
987,
1597,
2584,
4181,
6765,
10946,
17711,
28657,
46368,
75025,
121393,
196418|...]}
2>

That is 3.02 seconds, though not as good as Haskell, it still blew away Ruby and Python. Hey Erlang gurus out there is there any way we can seed this up ?

General

I am becoming a total nerd

Ok it is Saturday and as usual I am reading my feeds and I come across this article Style or Function canI please have both  and immediately my thoughts ran to hmm maybe he is talking about how Ruby language  has beautiful  syntax, and erlang is really great at extracting every bit of performance from a multicore processor but syntax is not that easy to read/beautiful hmm, or he is talking about lisp and bracket hell the possibilities were endless so I clicked on the link as quicly as possible ….

It turns out to be about a blackberry, oh the horror !!

General

My ‘InBox Zero’ Way

I am sure you have already heard about Inbox Zero by Merlin Mann, I love it and have modified to to fit my own needs. My process is very simple I classify all the emails I get into two categories,

  1. Ones that I need to process and delete which is a very broad category and,
  2. Ones that I need to backup which is a very narrow one.

Most of the emails once I process them, I delete them and by that I mean not just sending it to the trash box but emptying it out of my trash as well. Many people inadvertently turn there trash box into a mini backup folder. Which is really bad, if you have something to backup, well back it up, trash is well just trash and just as we do not pileup trash in our homes, we should not pileup trash in our mailboxes either. Also I process my email about once in an hour or when ever I remember to do it, keeping my mail open all the time is extremely distracting and I got better things to do than constantly processing my mail like a rat running in a wheel cage.

Second category of mails are the ones that I backup, I have a gmail account that I use specifically to do this, I have not found any other tool better capable of searching emails than gmail. What kind of emails do I backup ? only the ones that I have read and know I will need to refer back to it sometime in the future, like an explanation to some query. (Please don’t confuse this with an explain plan to a sql query :-)). An email has be of a lot of value to me in-order for it to go to backup. Think of your backup as a very precious resource. Clutter is your worst enemy even when it comes to email.

And that’s about it, armed with my system I have conqured my inbox, how about you ? What do you use ?

General

Some Interesting Articles

It is Saturday and I am just browsing and catching up on my feeds, came across some interesting articles.

Defining Success is an interesting article on IT projects, talks about how IT project success rate is really not as bad as what The Chaos Report makes it out to be. Here is an interesting quote from the article “It appears that project managers are more interested in delivering on time and on budget than delivering when the system is ready.laughing

Shared Mutable Memory Must Die, in another interesting article talks about problems with multi core cpu and programming languages, here is an interesting quote “Hopefully, if this trend continues, we shall find that certain warts of the computing industry, such as C, disappear from general use, appearing only in the most specific and suitable corners. Maybe even C++ and Object Orientation in general all but disappear as the assumptions of computing on which they are built become ever slower and unwieldy to maintain.

Comparing JVM Web Frameworks, now this article came as a shock to me , did not know flex was so popular!

In other news I have started using google reader, it has vastly improved in performance since I last used it about a year ago, it is now almost as good as desktop (LifeArea) feed reader that I use , few months ago it had crashed and since I was stupid enough not to backup my opml file, I had to setup my feeds all over again and since then I am thinking about moving to a web based feed reader. My main objection to using a web based reader was it was just not as fast as a traditional desktop app but things are changing.

General

YAY ! Java Erlang

Now that I got OtpErlang.jar (see my previous post), my next step was to connect Java to Erlang, if you have been following the book, you would have come across the Name server example in Chapter 10, this java code will connect to the name server

static void store(OtpConnection connection) throws Exception {
OtpErlangObject[] elements = new OtpErlangObject[] {
new OtpErlangString("weather"), new OtpErlangString("very nice") };
OtpErlangList erlangList = new OtpErlangList(elements);
connection.sendRPC("kvs", "store", erlangList);
OtpErlangObject received = connection.receiveRPC();
System.out.println(received);
}

static void lookup(OtpConnection connection) throws Exception {
OtpErlangObject[] elements = new OtpErlangObject[] { new OtpErlangString(
“weather”) };
OtpErlangList erlangList = new OtpErlangList(elements);
connection.sendRPC(“kvs”, “lookup”, erlangList);
OtpErlangObject received = connection.receiveRPC();
System.out.println(received);
}

public static void main(String[] args) throws Exception {
OtpSelf self = new OtpSelf(“client”);
OtpPeer other = new OtpPeer(“gandalf@devender-laptop”);
OtpConnection connection = self.connect(other);

store(connection);
lookup(connection);
}

General

YAY I finally got OtpErlang.jar

It’s the small things in life that make you happy !! As you know I have Ubuntu 7.10 and I installed erlang using ‘apt-get install erlang’. Unfortunately this style will not install Jinterface libraries. So the only way we can get it is by actually downloading the erlang source and building it yourself.

  1. Download the source from here
  2. Make sure you have all these libraries installed (use apt-get install ) # gcc
    libssl-dev, m4, libncurses5-dev, g++, openssl, gcc, java-gcj-compat, java-gcj-compat-dev, make, unixodbc-dev
  3. Make sure you have Java installed and have the JAVA_HOME variable set up in your profile.
  4. Do a ‘./configure’ followed by a ‘make’ and ‘sudo make install’

Many thanks to the following 2 links
Ethical Hacker
CouchDb

General, random thoughts, Tech

RE: Software Metrics Don’t Kill Projects, Moronic Managers Kill Projects

Great article Software Metrics Don’t Kill Projects, Moronic Managers Kill Projects, couldn’t agree less. I had written about working for good managers a while ago, thinking back about it and in general about the rate of successful Software projects I can’t help but think, Does the software industry in general have a high rate of Moronic Managers ? how come the software industry has so many failed projects ?

I think part of the problem lies in the fact that most managers have a technical background, they are great programmers and their success was rewarded with a promotion. Wish there were some online program or cash course that these new budding managers could take. I know there are a lot of books that can help too. I think it should become mandatory that one has to either read or get certified before he becomes a manager.

We have a saying in India, ‘For an intelligent person, you just need to show him the direction”, he will do the rest, I think programmers in general are very intelligent they just need the right direction 🙂