Monday, July 24, 2006

Java Generics FAQ

Java Generics FAQs - Frequently Asked Questions - This is a collection of answers to frequently asked questions (FAQs) about Java Generics, a new language feature added to the Java programming language in version 5.0 of the Java Standard Edition (J2SE 5.0).

Sunday, July 23, 2006


I've always liked Mid-Day. I was pretty happy to find their site. But the format they have is pretty sucky. They provide a pdf for each page. So to read the entier paper, each page has to be downloaded separately. Not the most convenient thing.

I had started looking at Python a bit (going from the previous post). This seemed to be a pretty good project to use it for. The script - midday - automates the process. Given the paper you want (sunday|mumbai|vashi), it downloads each paper's pdf pages to your machine. It also uses a third party app - pdftk - to combine all the pages into one pdf. It needs to be downloaded and the location it was installed in needs to be passed into the script, but its not necessary. The script still works w/o it, but the pages are in separate pdfs. Should work on both Windows and Linux, but I've tested it only on Linux.

Overall, I liked Python quite a bit. Definitely more productive that Java... for something like this. Less upfront design needed, but is still structured. All the data structures mentioned in the last post came into play. Also, being interpreted, it's pretty easy to make it work on multiple platforms. The library is pretty extensive and with the easy ability to call other programs (especially in the linux environment where the culture is to create small programs that can be stiched together), python can be used for a wide range of applications.

Re: One Array to rule them all

Pretty late reply... I've been doing a bit of python of late. And although there isn't 'one array to rule them all' there are some similarities. In python there are three main data structures - lists, dictionaries and tuples. Lists are growable arrays (ArrayList in Java) and Dictionaries are associative arrays (HashMap in Java). Tuples are just containters to hold other objects (No equivalent in Java). They are immutable.

People always talk of productivity with dynamic languages. These built-in data structures are one of the main reasons for it. Sure Java has an amazing collections framework, but it's not a language feature. It's a framework built on top of the language. In python, these are part of the language... [] creates a list, {} creates a dictionary and () creates a tuple.

Having these be part of the language makes a huge difference. In Java, if you want to return multiple values from a method... either do something ugly like return an array with the values (the values have to be of the same type) or define a new class to hold the values and return an instance of that class. Quite a pain. In python, you just put the values (of any type) inside a tuple and return. As simple as that. And as you can imagine, lists are used a lot to hold collections of data. But probably the most used data structure is the dictionary. It's a dumping ground in all sorts of situations. You would think it would be a readability nightmare but it isn't. It's almost a convention in python and when you come across code, it is immediately recognizable. And these ds's combined make for more productivity gains. Tuples, being immutable, can be used as keys. Also, python has support for sets as well.

Saturday, July 15, 2006

Right to Information

The Right to Information Act (RTI) was passed in 2005 which empowers Indians to ask the Government about anything that concerns them. You can ask questions like why the road outside your house is not repaired or why some facility is polluting your city. The official is under an obligation to respond to your query within a stipulated period.

Now things are amazing on paper. I doubt that information comes so fast and easily. There are a few sites, organisations which assist in this.


Maybe such a wiki like community site would better serve this purpose

Thursday, July 06, 2006

[Trackback]How to concentrate on writing

Something to think about..

When I am up against a deadline and I absolutely, definitely have to get on with my work, I use a few tactics to force myself to concentrate:

1. Switch off email. I don’t start Outlook (or if I do, I disable all the notifications that tell me I have new mail).

2. Isolate myself. I use Bose noise-cancelling headphones but don’t plug them into anything. The silence really is golden.

3. Greed and guilt. I remind myself how much money I’m getting paid for a particular assignment and how ashamed I will be if I miss the deadline. This actually works sometimes.

4. Stop with the blog already. When I’m pressed for time, distractions like blogging and hoovering become very compelling. Knowing this makes it easier to resist.

5. Get up early. 6am is the most productive time of day for writing. No distractions. It also feels more virtuous than staying up late with work.

6. Little treats. I bribe myself: ‘Matthew, if you write another 500 words, you can have a cup of tea and a biscuit.’

7. Chunking. Setting a timer or alarm clock for 15, 20, 30, 50 minutes and doing nothing but writing until it goes off and then taking a break seems like a good way to make progress.

8. Go full screen. Switching Word into full screen mode (from the view menu) eliminates all distractions but the piece I’m working on.

9. Shitty first draft. Splitting the work into distinct writing and editing phases breaks the job down nicely and it takes off some of the pressure to ‘get it right first time’.

10. Change location. Sometimes, if I’m really struggling to get started, taking a laptop or my notebook to a cafe and scribbling out something there - a fresh new location - is a good way to jolt-start an assignment.