Thursday, November 16, 2006

Java is now under GPL

That was really some amazing news. Yesterday was like a dream thinking of how bold Sun had been. Later I was thinking of what this really means for the language.

The obvious things are better community interaction with things like bug fixes and ports(palm anyone??).

Java SE will soon be bundled in almost all Linux operating systems. I think Gnome was using some Mono based applications. Now they could actually have the Java VM distributed. A whole new range of Java based desktop apps will be released. Its important to note that version 7 has been released now and version 6 will also be released later. That means that all free implementations of Java will use version 5+ Api's and so the fancy features like Generics, Enums and foreach etc. Java 6 also has a whole range of desktop specific enhancements so the "feel" of Java apps should also improve.

I am not sure if it is possible to deploy the Java ME VM without paying Sun any license fees. I want Sun to make money of Java, but if they can deploy Java to most phones/devices that would be great. Could this be the next platform after all.. almost making Java appear as an Operating System?

Of late Java lost a bit of steam. The language is mature and there are a large number of libraries to help in most tasks but age is also showing. Dynamic languages like php and ruby(with rails) provide features for faster webapp development. Even C# has some really cool features. This announcement will provide some extra steroids. In the future it will be interesting to see how "dynamic" Java can get.

To conclude.. Sun just made a lot of hackers really happy. This will definitely have some positive effects for the company and the language.

Tuesday, November 14, 2006

High on Emacs!

For the past three weeks I have been playing around with Emacs. Right from learning how to do simple editing to finally getting the Java Development Environment for Emacs (JDEE) setup on my machine, its been a whirlwind tour of this awesome editor!

I used to be a big "vi" fan, but the sheer amount of work that Emacs allows you to accomplish is simply superb! I'm looking at a phase of experimentation, to see if Emacs will be productive for me on a daily basis. For now, the answer seems yes!

Check out:-

GNU Emacs

Emacs Tutorial

Learning GNU Emacs

JDEE

Happy editing!

Wednesday, November 08, 2006

Re: Free the Platform!!

Looks like someone else had the same itch



Yet another link to the presentation above here. Get more info on the Linux phone here and here. You can get some more information on the State of Linux phones

THERE HAVE BEEN a lot of phones claiming to be 'Linux phones' and those that do run a Linux kernel, but they all miss the point of Linux: to be open. FIC is about to change that in a big way with a truly open phone, the OpenMoko.


Some of these phones are already in the market from Motorola and others. Companies like WindRiver and MontaVista also make Linux based stacks but I am not sure how open they are and whether it is possible to change/upgrade everything.

Within a few years more and more companies will release mobile frontends to their webapps. Just as Gmail recently did. As of now Symbian, Windows CE and Palm and the main OS'es for smart phones. Who then will win the battle for the dominant platform? Java has an enviable position right now as it has already been deployed in many phones already. If Sun opensources Java under GPL then there will be even more widescale adoption in the open source stacks. Nokia Series 60 also allow programming in C++ and Python now so thats another race.

Monday, October 30, 2006

Free the Platform!!

Can anyone tell me why I cant upgrade my mobile phone software?? Not some Java application on the phone, but the actual operating system. How much of a difference is there between a Nokia series 40 and Nokia series 60 phone in terms of hardware? Should I not be able to swipe the existing JVM which was based on an older Java implementation to a newer one? Will I ever be able to customise the hardware in the phone? Maybe we'll have to wait a bit longer for programmable hardware.. probably through FPGA's.

In a few years the mobile phone will be more important the the average computer. More people will use handheld devices for their daily tasks like browsing the net and listening to music. Developers will follow.. creating the next generation of killer applications.. followed by hackers to free the platform.. and by then google will own all your data

Tuesday, October 24, 2006

Ubuntu 6.06 (Dapper Drake) on Acer AS3004WLCi

I had installed Dapper Drake on my Acer AS3004WLCi Laptop a few months back. I've been happy with it but there were several things that didn't work. I've been pretty lazy but I think I've finally resolved most, if not all, of them. Here's a run down.

Firstly, what didn't work:

  • After booting up and picking Ubuntu from the grub menu list, a few kernel messages would show up and then there would be a blank screen until X Server started up with the login box. Similar issue when shutting down... didn't see any messages.

  • Same thing for Virtual Terminals... Ctl-Alt-[F1-F6] would bring up a blank screen.

  • Resolution for the 15.4 inch screen would only bring up 640x480, 800x600 and 1024x768 options. No wide-screen 1280x800 resolution.

  • Touchpad scrolling would not work.

  • Suspend/Hibernate would work the first time after booting up, but after resuming there would be a message saying there was a problem and on subsequent attemps would fail. It would look like it's doing something, screen would go blank, then all of a sudden some garbled text would be displayed at the top of a black screen and the screen saver would start up.

  • Wireless would not work. Would not detect the card.

  • Issues with sound... If multiple applications which use sound such as a music player, a flash site and skype were open, things would be very erratic. Skype would give errors like 'Problem with sound device'. Flash based sites like YouTube or Google Video would not have sound etc...


What I did to resolve these issues:

  • Turns out that the blank 'bootup/shutdown screen' and blank virtual terminals are related. When you pick Ubuntu from the grub menu list, it loads up the linux kernel which in turn loads a basic video driver to show the kernel messages. The video driver is considered to be basic and compatible with most screens. If the vga parameter is not passed to the kernel it defaults to vga=normal. It seems it wasn't with my Acer screen. So this needed to be changed. Edit /boot/grub/menu.lst. Add vga=792 to the kernel /boot/vmlinuz-<version> root=<hda> ro quiet splash line.

    HOWTO: Change bootup resolution was really helpful. It goes into further details about the bootup process etc... Also read it to understand the 792 value.

    The kernel uses the same driver for both the 'bootup/shutdown screens' as well as the virtual terminals. The vga parameter fixed both these issues.

  • The touchpad scrolling problem and the screen resolution problem had a common resolution.

    lspci | grep VGA
    shows
    VGA compatible controller: Silicon Integrated Systems [SiS] 661/741/760/761 PCI/AGP VGA Display Adapter
    on my Acer laptop.

    So we need a sis driver. Looking at /etc/X11/xorg.conf showed that it was loading the vesa driver. To fix this run
    sudo dpkg-reconfigure xserver-xorg.

    Go through all the screens and answer the questions. For most, the default will do. When you get to the video screen, pick the sis driver and the desired resolution (1280x800). Make it the default. After this is done restart X-server (Ctl-Alt-Backspace). It should start with the crisp widescreen resolution.

    The Strange screen resolution thread got me the lead on trying dpkg-reconfigure.

    Check this page for some bedtime reading on sis drivers.

    The touchpad scroll started working after going through the reconfigure. I didn't do anything specific. I think I just picked default options for the touchpad/mouse screen.

  • The Suspend/Hibernate issue was related to Wifi not working. Funny how these things are related no? The garbled text that was displayed after a failed suspend became clear after the virtual terminal issue was resolved. It was outputting bcm43xx: Error: Microcode "bcm43xx_microcode5.fw". dmesg showed the same error.

    lspci | grep Wireless
    shows
    Network controller: Broadcom Corporation BCM4318 [AirForce One 54g] 802.11g Wireless LAN Controller (rev 02)
    on this Acer laptop.

    So this is the wi-fi driver. After some searching, came upon How to: Broadcom Wireless cards (These How-Tos are amazingly helpful!). I followed the instructions and it seemed to work. iwconfig brings up the wireless network interface information + iwlst <eth> scanning shows the wireless connections available.

    After suspending and resuming, looking at the dmesg output, the errors weren't there anymore.

    Check this page for some insight into the suspend/hibernate process.

  • The sound issues took care of themselves really :) Upgrading the kernel to 2.6.15-27-386 seemed to resolve all of them. Also upgrading to Skype 1.3.0.53 helped.


Most problems have solutions out there. All it needs is a bit of searching/reading/trying.

Lets see how many of these issues are resolved in Egdy Eft which comes out tomorrow!

Saturday, October 14, 2006

Monday, October 09, 2006

hd internals

A cool demo of the hardworking hd in action.

Thursday, October 05, 2006

Ubuntu on a Dell 6400

Yipee.. I recently purchased a Dell laptop - Inspiron 6400 (also known as E1505). The first thing I had to do was to install Ubuntu. Luckily for me this is a common model and comes with some standard components and most of the things work with little or no configuration.

By default I got a resolution of 1028x768 on the widescreen which supports 1280x800 natively. So things were looking pretty stretched. The i915 wiki page explains pretty well howto get the correct resolution.

Another fun thing I did was to get the GKrellM with i8kutils. GKrellM is used to monitor the system. Its something I need to look more into. i8kutils is a dell laptop specific lib for intrumentation of the processor fans. Installation was explained in the Ubuntu forums over here. However after installing everything as explained, GKrellM still does not show any fans. For that, within the GKrellM configuration, the i8k plugin needs to be enabled first. After that two fans will be visible. Clicking on the fan can be used to toggle to Manual mode for fan and set the speed as well which you can confirm by listening to the low buzzing noise!! However I dont expect the processor to burn as the author says :) as the Intel motherboard automatically sets the fan speed based on heat.

Sunday, October 01, 2006

final by default

When talking about 'good programming practices', one thing that was recommended by a good professor of mine was to declare variables that you aren't going to modify as final. It serves two purposes:
1) A self check for yourself so you don't accidentally modify the variable down the line somewhere
2) Self documents the code: Other's reading your code know immediately of your intent.

While trying to follow this (in Java) I found all these 'final' keywords all over the place. I began to feel that it wasn't really helping. Just cluttering the codebase with 'final's.

So why not just have all variables be final by default?

Along these lines, I feel providing all the abilities of C++'s const to Java's final would be a tremendous boon. Your contracts can be better defined - not just on references but on the objects themselves.

<soapbox>Code maintainability - getting up to speed on a codebase and changing someone else's code is something that is done far more than adding new code. Anything to make readability better by clearly defining contracts/intent can only be a benefit and should be strived for.</soapbox>

Monday, September 11, 2006

Shutup PHP @ $%!

OK.. I'm getting a bit carried away here.

I saw a bit of code in PHP like ..
$contents = @file_get_contents($filename);

But what is the @ before the function call?? As bad as I am with googling I was not able to get some good docs on this. The best info I got was from meeting notes which says that its called the shut-up operator.

So then I backtracked to the PHP manual and found Error Control Operators. The doc says..
"PHP supports one error control operator: the at sign (@). When prepended to an expression in PHP, any error messages that might be generated by that expression will be ignored."

Yet another example of a lazy programmer trying to code before reading docs

Monday, September 04, 2006

Re: On the road



Took this on ride to San Francisco on Sunday. It's directly across the Oracle HQ. There are infact two billboards along the highway. Really nice to see Ubuntu get some (well deserved) publicity.

Saturday, August 26, 2006

Internet Explorer on Linux??

You mostly want to check for web page compatibility with IE if you're doing some web app stuff. So whats the solution if you prefer to use a linux distro rather than Windoz??

Enter ies4linux. ies4linux installs IE binaries over Wine. Wine is an Open Source implementation of the Windows API on top of X and Unix. ies4linux has a script which will download the IE setup files right from the microsoft site, and install over Wine. The best part is that you can install multiple versions of IE as well ;)

Saturday, August 05, 2006

Circular dependency between Tables in SQL

Update: Added a new way to solve the problem

Q) How had to create Tables with a circular dependency between them. Like

CREATE TABLE A (
....A_ID INT,
....PRIMARY KEY A_ID,
....B_FK INT,
....FOREIGN KEY B_FK
....REFERENCES B(B_ID)
);


CREATE TABLE B (
....B_ID INT,
....PRIMARY KEY B_ID,
....A_FK INT,
....FOREIGN KEY A_FK
....REFERENCES A(A_ID)
);

... now this will not work as during create, table B does not exist

A) So one solution is ...

CREATE TABLE A (
....A_ID INT,
....PRIMARY KEY A_ID
);

CREATE TABLE B (
....B_ID INT,
....PRIMARY KEY B_ID,
....A_FK INT,
....FOREIGN KEY A_FK
....REFERENCES A(A_ID)
);

ALTER TABLE A ADD COLUMN B_FK INT AFTER A_ID;
ALTER TABLE A ADD FOREIGN KEY B_FK REFERENCES B(B_ID);

A little bit of cheating does the trick :)



A) Another mysql specific solution is to use the FOREIGN_KEY_CHECKS variable.

mysql> SET FOREIGN_KEY_CHECKS = 0;
mysql> SOURCE dump_file_name;
mysql> SET FOREIGN_KEY_CHECKS = 1;

In the dump_file_name, tables can be created in any order without checking of Foreign Key constraints. So we can create tables with circular depenndencies

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

midday

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.