Thursday, May 12, 2011

Dive into Java

Today I decided to solve one task on Java. Task - DMC2011, and result of second must be Java-class.
So I can't write for example on Scala (which I read is pretty cool language). So first I started is googled "java suck" and found couple interesting texts, most interesting: http://www.slideshare.net/jeffz/why-java-sucks-and-c-rocks-final. Just real facts why java suck vs C# rocks - read it.
Next I wrote code, that go thought large (140mb) csv file and represent information in internal HashMap structure and then serialize it to file. When I run it I got to swap, so I stopped execution.
So now it's only 1/5 of file (~30mb) and I wrote Python code just to compare:
JavaPython
Lines of code7638
IMHO code looksuglynot so bad
Memory usage23.3%31.4%
Execution time (cpu)48 sec77 sec
Output file140mb150mb

In result, I can also note, that Java reads and makes structure very fast but take a long time to serialize and write to file. And Python contrary.

Still work on this stuff. Wish me good luck :)

No comments:

Post a Comment