Friday, December 16, 2005

Re; Free UML Tool?

There is an experimental one being developed at MIT:

http://relo.csail.mit.edu/

Singleton design pattern

Mohnish & I had a small discussion recently about Singleton vs static method only class.

A few advantages of Singleton we came up with were..

Singletons can be subclassed. And preferably used with Factories or Registries.

Another subtle difference was usage. When you have a singleton, you get back a class instance on which you then perform operations. Like..

Singleton singleton = Singleton.getInstance();
singleton.doSomething();
singleton.doSomethingMore();

Compare this to ..

Math.cos(..);
Math.round(..);

The Singleton is just more correct because it allows to think in terms of a type and its behaviour and limits the instances. The static method form does not exhibit the same level of coherent behaviour. It's not the most cleanest distinction but I guess you know what I mean.

I was in the mood to read more on this and stumbled on an article on Javaworld - Simply Singleton. Definitely worth a read.


...which reminded me of a basic feature of Singletons we missed - controlled instance creation

Thursday, December 15, 2005

RE: Free UML Tool?

Revo, Most of the reverse engineering software's that can be found for
UML are not freely available. There's EclipseUML @
http://www.omondo.com/ that you can try. The free version does not have
reverse engineering capabilities and the Enterprise Edition has a 30-day
evaluation limit.

There are others too, but more or less the story stays the same, go to -
http://eclipse-plugins.2y.net/eclipse/plugins.jsp?category=UML

If you do decide to evaluate EclipseUML (which is a plug-in for Eclipse)
make sure you have the dependencies of the EMF, UML and GEF packages
right.

Dinesh.

Sunday, December 11, 2005

Free UML Tool?

Do any of you use any UML tools? I was looking for a tool which would convert existing code (again Java) to a UML Diagram - Class and sequence diagrams.

Preferably the tool should be light on resources.

Monday, November 21, 2005

Ajax & PHP without using the XmlHttpRequest Object

Much cleaner....

http://www.phpit.net/article/ajax-php-without-xmlhttprequest/

Sunday, November 20, 2005

Re: Generics in Java

The other thing is that unlike C++, in Java all the checks (as you said) are done at runtime. Add to this the fact that it has a unified type system where all types (except primitives) inherit from Object makes it even more complicated. Both these are the reason for things like "? extends X" and "? super Y". You don't find these in C++ templates. Everything is checked at compile time so the compiler will warn you if the parameter types don't have expected methods. There's no need to specify that you want parameter types to extend or be the super type of some class.

This generics thread is just going to get more and more complicated. In Java, the compiler checks all* generic code at compilation time.

So if I say,
List<Integer> ints = new ArrayList<Integer>();
ints.add("a String"); //Oops... compilation error

But the bytecode generated will be similar to that generated pre Java 5 with casts inserted by the compiler.

Now there are some cases where you have no option but to make an unchecked cast to make code work. In such cases the compiler is not sure that the code/cast is wrong. So compilation is allowed with an unchecked cast warning.

class UncheckedCast<E> {
 private E[] arr;
 public void meth() {
  arr = (E[])new Object[5]; // unchecked cast
 }
}

Also....
<excerpt>
Generics for Java are accompanied by a cast-iron guarantee: no cast inserted by erasure will fail, so long as there are no unchecked warnings. The above illustrates the converse: if there are unchecked warnings, then casts inserted by erasure may fail.
</excerpt>


"? extends X" and "? super Y" are Wildcards. They are used to increase the range of Types that can be put in or removed from Generic methods/classes. This is a hack to reduce the effects of Erasure. I do not think this will be there in C++ or C#.


A slight diversion..
Does C# too have primitives? I have come across a few instances where having primitives in Java has hurt. Primitives requires having to make all special conversions and stuff. I suppose SmallTalk, Ruby are pure-OOPs wrt this.


I haven't delved too deep into how C# (.NET) has handled these situations. But I think there will be differences since the two implementations are different... no erasure, so type info is preserved. There is something called a constraint which basically allows you to declare an interface you want the parameter type to implement or inherit from some base class or specify that it has a default constructor...

Java too supports Constraints and its called Bounds. So the example Mohnish mentioned for max can be written in Java as...

public static <T extends Comparable<T>> T max (T a, T b) {
 if( a.compareTo(b) < 0 )
  return b;
 return a;
}

Btw Comparable is an interface which takes a generic type T.

I don't remember reading about Bounds/Constraints in C++... How is a similar thing done?

About the C# Constraints...


where T : new() T must have a no-parameter constructor


Java doesn't have anything similar. It seems to be an interesting constraint which should be useful in creating types of T even though the Type T is only known at runtime.


where T : class T must be reference type (a class)
where T : class_name T may be either class_name or one of its sub-classes (or is below class_name in the inheritance hierarchy)


Could you give an example of the usage of the above Constraints. To clarify; the first constraint only takes T, and the second takes T or its sub-class.

Saturday, November 19, 2005

Re: Generics in Java

This blog post made me realize how little I really know about Generics in Java. Conceptually, I feel generics are easy to understand but when looking at these details, it becomes interesting i.e. confusing.

But having said this, I think it's important to take some perspective. Most Java programmers are 'consumers' of APIs. Using these generic classes isn't very difficult. It actually makes better type guarantees and is more natural to use (no messing with casts). The complications of generics only occur when you write generic APIs - this burden is borne by the 'producers'. This is in a way good since there are generally more consumers than producers, so fewer people have to understand the complexities of covariants, contravariants and invariants etc... When was the last time you wrote a generic class?

The other thing is that unlike C++, in Java all the checks (as you said) are done at runtime. Add to this the fact that it has a unified type system where all types (except primitives) inherit from Object makes it even more complicated. Both these are the reason for things like "? extends X" and "? super Y". You don't find these in C++ templates (Atleast I haven't seen them - can someone confirm?). Everything is checked at compile time so the compiler will warn you if the parameter types don't have expected methods. There's no need to specify that you want parameter types to extend or be the super type of some class.

I haven't delved too deep into how C# (.NET) has handled these situations. But I think there will be differences since the two implementations are different... no erasure, so type info is preserved. There is something called a constraint which basically allows you to declare an interface you want the parameter type to implement or inherit from some base class or specify that it has a default construtor...

public T genericMethod<T>() where T : constraint

where constraints can be...

where T : struct T must be a value type (a struct)
where T : class T must be reference type (a class)
where T : new() T must have a no-parameter constructor
where T : class_name T may be either class_name or one of its
sub-classes (or is below class_name
in the inheritance hierarchy)
where T : interface_name T must implement the specified interface


Why the need for constraints? Consider this simple ex.

public static T Max<T>( T a, T b )
{
    if ( a.CompareTo( b ) < 0 )
        return a;

    return b;
}


This will fail at compile time. The compiler doesn't know whether a and b support the CompareTo method. There needs to be a way to limit what the parameter types can be... some constraint.

public static T Max<T>( T a, T b ) where T : IComparable
{
    if ( a.CompareTo( b ) < 0 )
        return a;

    return b;
}


This satiates the compiler since it will make sure that when you call this method, the types of objects used as parameters implement Icomparable.

This seems like a bit of a sidetrack. I'll try and read up some more on C# generics and post any differences/similarities to covariants, contravariants and invariants.

Friday, November 18, 2005

Re: codeWord changes??

Also I was thinking of opening codeWord more. First we can allow Anyone to post comments.

We could also publish codeWord in a few blog directories.


Both are fine by me. Anybody have objections?

Thursday, November 17, 2005

codeWord changes??

I added Google Analytics to codeWord. See Google Analytics. If any of you want the info let me know.

Also I was thinking of opening codeWord more. First we can allow Anyone to post comments.

We could also publish codeWord in a few blog directories.

Suggestions?

Re: Happy Birthday CodeWord

Its been 2 yrs since CodeWord was started..

Happy (Belated) Birthday indeed!

..lets try and write blogs more often.

I'm happy we've kept it up this long, but the posts have been lean and infrequent of late. I've been a big culprit myself. We should all try to get back to the ol days of having long discussions on topics of interest. There's certainly no shortage on things to talk about.

So this is my great rallying call for the troops ala Bill Gates who does it every five years.

Monday, November 14, 2005

Happy Birthday CodeWord

Its been 2 yrs since CodeWord was started..

..lets try and write blogs more often.

Btw. I posted the Generics blog so that I could say the above line!!

Also I suppose I made the Generics blog a bit cryptic. Ask questions incase.

Saturday, November 12, 2005

Generics in Java

I've finally started trying to learn about the new Java 5 features...

Generics is one of the most important. There is a draft book by Oreilly at java.net - Generics and Collections in Java 5. And there are quite a few do's and dont's with Java generics. Definitely makes the language more complicated but it is needed too. Thought of sharing a few interesting excerpts here...

<excerpt>

Array subtyping is covariant, meaning that type S[] is considered to be a subtype of T[] whenever S is a subtype of T. Consider the following code fragment, which allocates an array of integers, assigns it to an array of numbers, and then attempts to assign a float into the array.

Integer[] ints = new Integer[] {1,2,3};
Number[] nums = ints;
nums[2] = 3.14; // array store exception
assert Arrays.toString(ints).equals("[1, 2, 3.14]"); // uh oh!

The subtyping relation for generics is invariant, meaning that type List<S> is not considered to be a subtype of List<T> except in the trivial case where S and T are identical. Here is a code fragment analogous to the one above, with lists replacing arrays.

List<Integer> ints = Arrays.asList(1,2,3);
List<Number> nums = ints; // compile-time error
nums.put(2, 3.14);
assert ints.toString().equals("[1, 2, 3.14]"); // uh oh!

</excerpt>

It is obvious that invariant behavior in generic limits is usefulness. So wildcards can be used to introduce covariant behavior.

<excerpt>

Wildcards reintroduce covariant subtyping for generics, in that type List<S> is considered to be a subtype of List<? extends T>, when S is a subtype of T. Here is a third variant of the fragment.

List<Integer> ints = Arrays.asList(1,2,3);
List<? extends Number> nums = ints;
nums.put(2, 3.14); // compile-time error
assert ints.toString().equals("[1, 2, 3.14]"); // uh oh!

</excerpt>

And it gets even more interesting when...

<excerpt>

Wildcards also introduce contravariant subtyping for generics, in that type List<S> is considered to be a subtype of List<? super T>, when S is a supertype of T (as opposed to a subtype). Arrays do not support contravariant subtyping.

</excerpt>

So there are quite a few differences between Arrays and Generic Collections in Java and the author suggests using only Collections. The covariant and contravariant behavior is used to increase the range of Types that can be used by a Collection of type <T>.

The covariant behavior (<? extends T>) is used to get types from a colletion.

<excerpt>

Here is a method that takes a collection of numbers, converts each to a double, and sums them up.

public static double sum(Collection<? extends Number> nums) {
double s = 0.0;
for (Number num : nums) s += num.doubleValue();
return s;
}

Since this uses extends, all of the following calls are legal.
List<Integer> ints = Arrays.asList(1,2,3);
assert sum(ints) == 6.0;

List<Number> nums = Arrays.<Number>asList(1,2,2.78,3.14);
assert sum(nums) == 8.92;

</excerpt>

So if I have a Collection of a type which extends Number, I know I can atleast safely remove type Number. This is what the author calls the Get principle.


The contravariant behavior (<? super T>) is used to put types into a colletion; which is analogous to the above behavior.


<excerpt>

Here is a method that takes a collection of numbers and an integer n, and puts the first n integers, starting from zero, into the collection.

public static void count(Collection<? super Integer> ints, int n) {
for (int i = 0; i < n; i++) ints.add(i);
}

Since this uses super, all of the following calls are legal.

List<Integer> ints = new ArrayList<Integer>();
count(ints, 5);
assert ints.toString().equals("[0, 1, 2, 3, 4]");

List<Object> objs = new ArrayList<Object>();
count(objs, 5); objs.add("five");
assert objs.toString().equals("[0, 1, 2, 3, 4, five]");

</excerpt>

So if I have a Collection of a type which super Integer, I know I can safely add type Integer. This is what the author calls the Put principle.

Incase a method has to both Get and Put into a same Collection, then wildcards cannot be used. Btw in this blog wherever I have used interesting you can substitute confusing. Yet with a little time and practice generic in Java should not be that tough.

A lot of this is caused because generic in Java is implemented using Erasure in which the type (<T>) is basically removed and casts are added by the compiler. So at runtime there is no info of the type. There are many more quirks caused due to Erasure... but this much is scary enough for one blog.

Could you guys compare generic in C# and C++. Also Mohn what are the new features in C#??

Thursday, October 27, 2005

Re: War on Terror - bash style

When I first read the title "War on Terror - bash style".. i thought it was a typo instead of "War on Terror - bush style"

Good read... I meant the bash one

War on Terror - bash style

Seriously (geeky) hilarious - http://blogs.sun.com/roller/page/ThinGuy?entry=the_war_on_terror_as

Charles Petzold on Visual Studio

 
Avalon's dynamic layout sounds interesting. I actually may be doing a POC on Avalon sooner or later for one the projects here! Hoping the work comes through soon!!
 
Dinesh.
 

Thursday, October 20, 2005

AJAX Apps

Word Processor:
http://www.writely.com/

Calendar:
http://www.kiko.com/

Todo List:
http://www.rememberthemilk.com

Monday, October 17, 2005

Re: Project Anyone??


I generated the pdf of the deverloperworks site and it looks just fine.

It all just depends if you want to play with js or read the article.


Like u said the PDF thing worked fine. What I was a bit confused was how the page style changed. I thought it was doing something funny with javascript. But later it was nothing to do with js; but CSS. With CSS you can specify the media type as well as explained here. So the print css was a no frills style which was auto used when printing.

Actually wanted to play with Greasemonkey.. but will try it later.

Sunday, October 09, 2005

Re: Project Anyone??

Revo,
 
I generated the pdf of the deverloperworks site and it looks just fine. If your purpose is just to read the articles then I don't see why you would want anything else. If you want the frills and colors, then do what mohnish suggested.. Say "File -> Save As" and select the type as *.mht, thats a web archive. I tried that too, its even better than the pdf!
 
It all just depends if you want to play with js or read the article.
 
Dinesh.

Friday, October 07, 2005

Re: Project Anyone??

Also related to this, you guys aware of any JavaScript(js) tools. One thing I use a bit is the Javascript console in firefox. But only get errors for lousy methods I have writen. Is there any way I can get all the js loaded by a site. Or the dynamic tracing/state of all the js variables/methods etc that are currently loaded/working in a page.

Download this extension for Firefox. Here is his site. Probably the greatest invention for Javascript ever. Not exaggeratating!

As for your problem... why don't you just use the 'email this page' link to email the page to your 2 1/2 gig gmail account? Or even easier why not just "File -> Save Page As..."?

Re: Project Anyone??

Just install pdf995 - http://www.pdf995.com..

Thanks,,, I was aware of that tool. First the pages are not very printer-friendly. Too many extra elements. Also the idea was to first get the underlying format. And then try to make some Greasemonkey script to modify the developerworks pages and add another; say PDF link.

Also related to this, you guys aware of any JavaScript(js) tools. One thing I use a bit is the Javascript console in firefox. But only get errors for lousy methods I have writen. Is there any way I can get all the js loaded by a site. Or the dynamic tracing/state of all the js variables/methods etc that are currently loaded/working in a page.

Thursday, October 06, 2005

Re: Project Anyone??

Revo,
 
Just install pdf995 - http://www.pdf995.com.. It installs as a printer and when your page asks you to choose the printer, choose the software one and it will print it to a pdf.
 
Dinesh.

Re: What is Web 2.0?

I had read the article recently. That term seems to have got a lot of buzz of late. I guess one of the things that really got it moving was AJAX interfaces.

What I'm starting to notice is that a lot of 'concept' apps or whatever you want to call it are just trying to ape what regular desktop apps do. Now that there is the new idea of making http requests asynchronously which don't require page refreshes, people are going crazy using it as a hammer and seeing everything as a nail. From the few I've seen - they suck. Sure they are all jazzy making full use of dhtml, now with xmlhttprequests behind the scene. But they are a usability nightmare. They are slow as hell. AJAX is a new concept and with people trying to take it to the limits they are abusing the browser. When you want to use a web app you expect it to work in some 'preconcieved' way - through so many years of surfing the web we've become comfortable with certain conventions. AJAX apps go against it. Plus who the hell wants to use a windows type app through a browser? Adam Bosworth - a big shot at Google - the 'father' of AJAX apps - even posted problems he see a while back.

I'm not saying AJAX sucks. I think it's superb. Really. I feel it should be used to enhance the web experience and accepted paradigms. Not just try to rehash Windows type apps.

Wednesday, October 05, 2005

What Is Web 2.0?

A really good writeup on - What Is Web 2.0? at Oreilly.

The conclusions included the following points....

* Services, not packaged software, with cost-effective scalability
* Control over unique, hard-to-recreate data sources that get richer as more people use them
* Trusting users as co-developers
* Harnessing collective intelligence
* Leveraging the long tail through customer self-service
* Software above the level of a single device
* Lightweight user interfaces, development models, AND business models

What I felt is the most important is Control over "unique, hard-to-recreate data sources". If you can generate/own such data; you can expose an API and thus take care of the other points mentioned.

Another point mentioned is rich UI using AJAX.

Monday, September 26, 2005

Project anyone??

I usually get quite a lot of good articles at IBM developerworks. They would initially offer articles in different formats like PDF; which I would save locally. Recently the site was changed and the PDF format support was removed. Instead a "Print this page" link which calls a JavaScript method is present.

As I do not have a printer on clicking the link, it gives me a "No printer found error". So could any of you guys tell me what method is being called on that link. I do not really know JavaScript and was unable to figure out what gets called.

I suppose the method will return a format which is printer friendly and then I could move ahead from there...

Any takers??

Thursday, September 22, 2005

The Jackpot project

Some pretty interesting stuff in this project. See this link http://www.artima.com/weblogs/viewpost.jsp?thread=116895 at artima.

Jackpot provides a few compiler specific views which can then be used for code-optimization etc. Read the article..

Wednesday, August 24, 2005

Comparing Java and .NET security

I'm back. Hopefully there'll be more traffic from my side.

Here's an interesting paper published by couple of students - Comparing Java and .NET security - Lessons learned and missed. Haven't read it, but scanned some parts and it seemed pretty good.

Saturday, August 06, 2005

Hacking the Linux 2.6 kernel

There is a good tutorial at developerworks on Hacking the Linux kernel..

I havent tried the stuff yet.. but seems like a good starting point to go that one level deeper into the Linux OS. Read Part 1 and Part 2.

Friday, July 29, 2005

Hardware: Super Fast Storage

See this article on anandtech.com which is a good site for hardware reviews. The article is about the review of a new product - Solid State Storage (i-RAM). Simply put, i-RAM has a 4 RAM slots. Put in upto 4*1GB RAM cards and what you get is a super fast and silent Storage device. i-RAM plugs into the PCI slot for power and has a battery backup for maintaining data in the RAM cards after power shut down. More on the power to the card.. "As long as your power supply is still plugged in and turned on, regardless of whether or not your system is running, shut down or in standby mode, the i-RAM will still be powered by the 3.3V line feeding it from the PCI slot."

Costly but cool.

Sunday, July 17, 2005

Re: Java Generics Considered Harmful

He's right to say that Generics adds a certain level of complexity to the language. But it's designed to simplify programming. If you don't abuse it, it is a benefit rather than a hindrance.

Consider C++... Why do people think it's so difficult? It's because there are so many different ways to do things and a lot of the features are abused. But if you only use a controlled subset of the features in a consistent way, that complexity goes down and it becomes manageable.

It's the same with Generics. He's given some examples of some real weird stuff that could be done with it. But why would you want to do it? If the whole point of this is to simplify things, why do things like that? I've used Generics and I feel it has made things better. When you're looking over code and you see them declarations which specify what type of object the data structure contains, it makes things so much more clear.

I can't say people in the .NET community have voiced similar concerns, but that may be partly cause .NET 2.0 hasn't come out yet. Maybe once it's out there for a while and people start seeing problems like this there'll be some complaints. I haven't seen a total/complete comparison between the Java/.NET implementations and what can be done with them so I dunno if what he's talking about can be done in .NET also (I would assume so). So lets see.

As I said, my personal feeling is that Generics is definitely an improvement and is something that is needed.

As an aside - Just noticing these two trends... Java and .NET are moving to things like Generics which require you to specify MORE detailed type information, whereas there's also a huge move towards dynamic languages like Python, Ruby and Javascript which are the opposite and infer all type info.

Thursday, July 07, 2005

Re: Why Indians Aren’t Software Innovators?


In the current software industry, there is little ongoing innovation.

The Indian education system fails to teach underlying concepts and understanding.


What you said about education in India is mostly correct. The majority of the students perform really well by rote learning. Although the Indian educational system has flaws, I suppose the courses in schools are much more rigorous compared to stuff taught in Western countries.


If the Indian education system does not actively foster innovative thinking, one may ask why there are so many successful Indian entrepreneurs in the software industry in the United States.

One reason may be that many of these successful ventures were started by graduates of the Indian Institutes of Technology (IIT).
One many then ask about the success of non-IIT Indian software entrepreneurs in the United States. Most of the remaining Indian entrepreneurs are likely completed graduate studies in the United States have developed innovative thinking through these institutions.


I somehow believe that innovation cannot be taught. Pawan mentioned fostering innovation which is more correct. Without a doubt there are many intelligent guys in India. I believe that there are also many innovators. Why? Simply because of the environment. There is a lot of chaos and huge ammounts of competition. This harsh environment makes the best innovators. Those Indians who move abroad find an environment where it is easier to explore new ideas. They can survive anywhere. Remove red-tape and Indians really thrive.

Also IITians are a bunch of really intelligent guys. But not necessarily good at software and definitely not necessarily good innovators. Innovation like Leadership is self-taught. For a similar reason I find it absurd that people are taught managerial skills in MBA schools.

As Pawan mentioned, there is a less demand for products in India. And so most guys move to services.


Therefore, the Indian software industry will inevitably either perish or will have to become innovative as the payoffs for outsourcing decrease.


The Indian software industry has a very long life ahead. They are already moving to higher end services. From testing jobs, companies are now doing some design stuff too. Even in hardware and other domains, more jobs where high skills are needed are being shifted. The quality of the "outsourced jobs" is improving.

Java Generics Considered Harmful

Ken Arnold is one of the authors of The Java Programming Language along with James Gosling.

In this post on Java.Net blogs; he says..

"I don't know how to ease into this gently. So I'll just spit it out.
Generics are a mistake. "

That is a pretty big statement to make.

His reasoning is that for the benefit Generics offer, they are too complex to learn and hence a mistake.

As lazy as I am I have still not played with Generics; so I cannot say much.

Any such feeling in the .NET world??

Thursday, June 23, 2005

Re: Intel at Apple's Core

I don't think this will be the case at all. Apple isn't going to let you run their OS on PCs. A huge part of their revenue is from hardware

Yur right... Apple will try to control their platform/OS and work on specific hardware too.


Sure, people will manage to get it on PCs and there will be hacks etc... but I doubt it will be anything big. Plus OS X isn't Open Source so there's less incentive for the OS community to bother with it.

Actually MacOSX is open source. See darwinsource/. I knew that they are based on BSD Unix, but just realised they are open source too!!.

IMHO the OSX hacks will get quite popular if it happens..

Admin pics

Admins Ashtray
Admins Ashtray

Admins Archive of Babelfish
Admins Archive of Babelfish

Homeless Admin
Homeless Admin

Wednesday, June 22, 2005

Re: The Future of Microsoft

I did read that article. Linus makes sense. But I don't see his statements supporting what you wrote.

Anyway, since we're on the topic, came across this post from an MS dev... The Innovation Tax

Re: The Future of Microsoft

Relating to my essay, here's a recent interview with Linus about the future of Microsoft that I found on slashdot.

http://blogs.siliconvalley.com/gmsv/2005/06/an_interview_wi.html

Monday, June 20, 2005

Why Indians Aren’t Software Innovators?

In the current software industry, there is little ongoing innovation. The core of the industry relies on the outsourcing of projects from international (mainly American) firms. Based on the experiences of many of my relatives who work for such companies as Infosys, Wipro, Tata Consultancy Services (TCS) and Motorola India Electronics Limited (MIEL), I have observed they are usually given well-defined projects that have little room for creativity. But I believe that this is not an issue for most developers in India since most have been trained to engineer based on solid and well-defined specifications. This mindset is may be due in large part to the style of education in Indian schools and colleges.

Most Indians have been trained to be good engineers but not good innovators. For example, a few years ago, my cousin in India and I were both studying electricity and magnetism as a part of our high school physics curriculums. I was shocked to see how she would solve a problem regarding electric fields and flux using Gaussian surfaces. Her professor had taught the class the standard Gaussian surfaces: sphere, pillbox, etc. The class would then memorize the necessary integrations and formulas to answer any questions on the standard state government exam. However, in my high school we had approached these problems by evaluating them from scratch instead of plugging in numbers into memorized formula. When I asked my cousin a question regarding some of the more general concepts of electricity and magnetism, she could not answer them. Though this is a small example, the Indian education system fails to teach underlying concepts and understanding. Therefore I believe that the Indian software industry is missing “out of the box” thinking which is necessary for software innovation.

If the Indian education system does not actively foster innovative thinking, one may ask why there are so many successful Indian entrepreneurs in the software industry in the United States. In fact, EconomicTimes.com states:

“.3,000 of the technology firms created in the Silicon Valley since 1980 are run by Indian and Chinese entrepreneurs. Accounting for over thirty per cent of the total number of technological start-ups, reaching $19 billion in sales, and creating 70,000 new jobs, these businesses have made significant contributions to the local economy. …Today, there are more than 20,000 Indian millionaires in the Silicon Valley.[1]

One reason may be that many of these successful ventures were started by graduates of the Indian Institutes of Technology (IIT). In order to be one of the 2% of applicants admitted into IIT, students must be able to pass a notoriously difficult entrance exam.[2] Therefore unlike government issued entrance tests for all other Indian universities, where memorizing will work, the IIT entrance test requires students to master the underlying concepts rather than just memorize and drill problem solving techniques.

One many then ask about the success of non-IIT Indian software entrepreneurs in the United States. Most of the remaining Indian entrepreneurs are likely completed graduate studies in the United States have developed innovative thinking through these institutions. Many of my friends who completed an undergraduate engineering degree in India and are now graduate students in the United States, have expressed much appreciation for the American style of higher-level education. For example, when they took a course on operating systems in India, they simply had to memorize the architecture of several major operating systems from a book. However, when they retook the course after immigrating to the US, they actually had to build an operating system which brought a whole new level of understanding.

Secondly, there are no successful software entrepreneurs in India outside the outsourcing arena because there is no direct interaction with potential software consumers. Domestically, there is no significant demand for software because home ownership of a personal computer is limited to a few individuals in the upper-middle class. It is also difficult for an Indian software product company to develop products for international clients because it is hard to determine the customer’s needs from the other side of the world. Therefore the only model for an Indian products company is to establish sales and marketing offices in foreign countries and conduct development efforts at home. However in such a company, market assessment and innovation would essentially be occurring abroad and coding would be done in India – basically what is already occurring in India already.

The third reason we have not seen any product companies from India is because there currently is no need for them. Given the current boom times in India, an entrepreneur is likely to follow a proven formula by founding a small outsourcing company rather than take undue risks to start a products company. Over time, the profitability and attractiveness of outsourcing firms in India will decrease and only then will Indian entrepreneurs be forced to look at other business models.

Therefore, the Indian software industry will inevitably either perish or will have to become innovative as the payoffs for outsourcing decrease. Furthermore, as the domestic demand for software grows, Indian companies will not only have an upper hand in a larger market, but they will also have direct exposure to customer needs. However, in order to expedite this industry transformation, the Indian government should look toward reforming engineering curriculums to cultivate a generation who not just backend engineers but true innovators.


[1] http://www.nasscom.org/artdisplay.asp?Art_id=2692

[2] http://www.indianembassy.org/US_Media/2003/mar/cbs_iit.shtml

Sunday, June 19, 2005

Re: The Future of Microsoft

Microsoft has over 80 products stretched over many markets from mobile device software, to RFID, to MSN services, to desktop applications to video games.

As companies get bigger they need to start looking at expanding their product base. Sure a lot of them won't click (with Microsoft it's a lot), but that's how they can get to the "next big thing". I don't see they having 80+ products stretched over many markets to be a problem at all. They are investing in many areas and they will hope that some of those will click for them. The reliance they have on Windows and Office is unbelieveable. It is an eventuality that these will subside. They NEED to look at other products.

But you can start to see signs from the Microsoft culture that the company is beginning to no longer be as cohesive as it once was. As Microsoft becomes a larger and more mature company, they will always continue to struggle to find the balance of performing with the strength of a large company while maintaining the efficiency of a small one.

I don't think this is anything unavoidable. It's sort of like a country. You have many subgroups and subcultures within. You relate yourself with both. Once a company gets to a certain size, you can't do things the same way as a startup. So rules change and so does the culture. We spoke a little about Google and how it operates. They are small right now, but aggressively hiring left and right. Eventually, the entire company will find itself in a situation similar to how many others before them have. They will need to change. How and what they do will have to be seen. But the certainty is that they won't be the same as they are right now and maintaining the "efficiency" they have right now won't be possible.

This can be seen from the recent resurgence of Netscape’s Firefox browser in the software market. In the Business of Software, it is mentioned that the Netscape Navigator code base grew from “100,000 lines in 1994 to 3 millions lines in 1994”. Netscape’s inability to add new features while maintaining stability in the product was one of the major reasons for their loss in the browser wars.

Yes, ONE of the reasons for Netscape's downfall was because version 4 was a real sucky application. It didn't even compare with IE 4, which was years ahead of it in every way. The most important being its implementation of the DOM. But I won't say that the size of the code was the reason for Netscape releasing such a bad app. I'm sure IE was also had similar number of lines of code. It's how the app is architected that matters. Look at Win 9x vs Win NT. Windows 2k/XP are much larger than Windows 9x, yet they are better OSs. So just trimming down the LOC (lines of code) isn't the answer.

Prahalad’s theory basically claim’s that 90% of the world technology and commercial products are targeting the richest 2 billion people in the world. This in turn has left the 4 billion people who earn less than $4 per day out of the world’s markets. But he thinks that is can all change, because now the “bottom of the pyramid” has reached such a critical mass that companies can still large profits despite smaller profit margins per sale.

I agree. The Asian market is HUGE. And these companies, Microsoft included, will need to do more to make their presence felt there. And not only target the upper/middle classes, but even the lower classes.

A few weeks ago, Microsoft announced they would be releasing stripped down Hindi version of Windows XP to the India market for $70 as a pilot program.

You're talking about Windows Starter Edition right? I actually think this was really stupid. From what I remember, this version only allows you to open up three applications or windows or something. You can't take a product that's sold for X in the US and sell it for around the same price in another country like India or China. Even $70 (Rs. 3000+) is too much. The only way they will come down to a reasonable price is when they start feeling the heat from Linux. China already has Red Flag Linux which is a home baked version. It looks like the Chinese govt. is heavily promoting it since they don't want to rely on a foreign American company. If India, with its IT superpower, status does the same, Microsoft will be forced to bring down the cost.

And regarding language, I think Linux comes in more languages than any other OS. There was a story long back where a small town in some scandinvian country threatened to move to Linux unless MS released a version of Office or Windows in their language.

In conclusion, I feel that in order for Microsoft to maintain their market dominance, they need to focus as a company. They not only need to question whether their new product lines are actually viable and worth pursuing but they also need to streamline their existing flagship products. And finally as software commoditizes, they need to find new ways for the entire software market to grow.

Yeah focus is needed, but at the same time I feel Microsoft needs to try out different markets. They need to see what works and diversify away from their reliance on Windows and Office. It might sound strange but the spread of broadband is a direct threat to Microsoft. As more people have access to high speed internet, they are more likely to store their data in a remote place and work with think clients. Essentially what runs on the client won't matter much anymore - which is exactly what MS is trying to prevent. They are in a catch 22. Classic example is IE. During it's hayday - v. 4, 5, 5.5 - it was absolutely brilliant. Blew everything else out of the picture. But they saw what they were doing... encouraging people to build web apps and not Windows apps. This was fine in a way, since IE only ran on Windows and no other browser supported the cool stuff in IE. But as Mozilla, Opera and other guys started having similar features which could support complicated Web apps, the OS didn't seem to matter much anymore. So they let IE rot. And this is it's present state. Let's see what new developer features IE 7 will have. I'm sure it will have all the general user friendly features like tabs and RSS support etc...

Boy that was a big tangent. Anyway, my point is that yes they need to put out better software with more innovative features, but they need to also expand into other markets or even create new categories of products.

Re: Intel at Apple's Core

I think this is going to be really huge. I've always wanted to try Mac. But the main barrier has been very very expensive non-x86 hardware. I guess this is an issue for lots of other guys. On the home pc front, Apple may gain a larger market share. Not that Apple is going to overthrow MS, but will definitely make inroads into the market share.

I don't think this will be the case at all. Apple isn't going to let you run their OS on PCs. A huge part of their revenue is from hardware and they aren't going to let Dell, HP and all the other PC dudes take that away. Not to mention the fact that Mac OS won't have support for all PC hardware. Did you see the keynote where they made this announcement? I didn't see the whole thing, but I did see the part where he actually made the announcement and gave the reason for shifting - x86 architecture is more efficient at power consumption and will scale better than PPC. I didn't see making the OS available to the larger PC market as the reason. Sure, people will manage to get it on PCs and there will be hacks etc... but I doubt it will be anything big. Plus OS X isn't Open Source so there's less incentive for the OS community to bother with it. They got plenty to play with with Linux etc...

My 2 cents.

Friday, June 17, 2005

greasemonkey

greasemonkey is one really cool firefox extension i came across. From the homepage....

"Greasemonkey is a Firefox extension which lets you to add bits of DHTML ("user scripts") to any web page to change its behavior. In much the same way that user CSS lets you take control of a web page's style, user scripts let you easily control any aspect of a web page's design or interaction."

There are a whole bunch of user scripts for general and specific sites as well. An example of a generic script is Linkify. This script turn all URLs on a page into hyperlinks. Suppose a page contains text like http://java.sun.com, the Linkify script would automatically convert it to a hyperlink ( http://java.sun.com ). Google Butler is an example of a site specific user script. From their web-site

"WHAT DOES IT DO?

1* removes ads on most Google pages

2* fixes fonts on most Google pages

3* Google web search:
3.1o adds links to other search sites ("Try your search on...")
3.2o in news results, adds links to other news sites
3.3o in movie results, adds links to other movie sites
3.4o in weather results, adds links to other weather sites
3.5o in product results, adds links to other product sites

blah blah.. go see the site"

Try it out.. May improve usability of your favourite site!!

greasemonkey works by changing the DOM structure of the webpage. Dunno more details..

Does Opera have a good extension mechanism?

IE7 will be released soon I suppose, but firefox really has some really neat features.. and extensions. You think IE7 will stop firefox from taking the market??

Wednesday, June 15, 2005

The Future of Microsoft

After my experience at Microsoft, though I was quite impressed by what they had achieved up to date, however, the future seemed less promising. Microsoft seems to be stretched too thin. Microsoft has over 80 products stretched over many markets from mobile device software, to RFID, to MSN services, to desktop applications to video games. But you can start to see signs from the Microsoft culture that the company is beginning to no longer be as cohesive as it once was. For example, when other employees working on XXXXXX would use the pronoun “we”, it would refer to the XXXXXX group or occasionally the entire YYYYYYY. The pronoun “they” would be used when referring to other product groups. Though this may seem insignificant, it shows that employees at Microsoft feel a sense of belonging and loyalty towards their own product rather than the company as a whole. As Microsoft becomes a larger and more mature company, they will always continue to struggle to find the balance of performing with the strength of a large company while maintaining the efficiency of a small one.

Instead of diversifying software products, Microsoft can instead simplify their existing products to provide a more secure and stable user experience. This can be seen from the recent resurgence of Netscape’s Firefox browser in the software market. In the Business of Software, it is mentioned that the Netscape Navigator code base grew from “100,000 lines in 1994 to 3 millions lines in 1994”. Netscape’s inability to add new features while maintaining stability in the product was one of the major reasons for their loss in the browser wars. From personal experience, I can see a similar trend emerging from the Microsoft Office code base and would not be surprised to see similar trends. For example, it would sometimes take one week just to check-in code and resolve dependencies – often more time than it would take to write the new code itself. On the other hand, Netscape is beginning to turn around with the release of their latest open-source browser Firefox which has accumulated over 3 million downloads. What makes Firefox so attractive is its lightweight design, fast load times and stability – all traits which Internet Explorer once beat Navigator with but now lacks. As Microsoft product cycles approach 4-5 years, for Microsoft to retain their dominance over other applications and operating systems, they should instead follow the Firefox model and build lightweight, secure and stable software rather than continuing to bloat their existing code base.

As software begins to commoditize in the existing markets, as the industry leader, Microsoft needs to find news ways for the software industry to grow as a whole. This summer I attended a guest talk by Dr. C.K. Prahalad, a world-renowned Professor of Business Administration, Corporate Strategy and International Business at the University of Michigan, who spoke about his “bottom of the pyramid” theory, which may allow Microsoft to do just that. Prahalad’s theory basically claim’s that 90% of the world technology and commercial products are targeting the richest 2 billion people in the world. This in turn has left the 4 billion people who earn less than $4 per day out of the world’s markets. But he thinks that is can all change, because now the “bottom of the pyramid” has reached such a critical mass that companies can still large profits despite smaller profit margins per sale. One example that Prahalad gave of was how Hindustan-Lever, the Indian division of Unilever, now makes 90% of their profits by selling shampoo in small single use sachets, which are more to the poor than large bottles. At the end of the talk, Prahalad asked Microsoft to consider developing products geared to impoverished populations of the world. Not only would this allow Microsoft to enter previously untapped markets but it would also allow the poor to reap the benefits of software technology as well. Prahalad speculated that Microsoft might be able to even double their profits if they were able to successfully target these markets.

It seems that Microsoft may have bought Dr. Prahalad’s theory. A few weeks ago, Microsoft announced they would be releasing stripped down Hindi version of Windows XP to the India market for $70 as a pilot program. In addition, they plan to introduce the same product in local languages to Russia, Indonesia, Malaysia, Thailand and other parts of India. Though Microsoft has claimed they are introducing this product as a response to rampant piracy, it is important to notice that the Indian version is in Hindi and not English. This may also be an attempt to reach out to the general public sector of India rather than the corporate and upper-class sectors where English is generally accepted as a standard.

During a talk, that Microsoft CEO Steve Ballmer gave to employees and new hires this summer, he said that if Microsoft were to reduce China’s piracy level to those of Italy, which are still quite high, then Microsoft would instantly add an additional $2 billion dollars of revenue annually. He added that China will only crackdown on piracy when they have a local software industry of their own. The low cost software initiative may be an attempt to do exactly this: provide an opportunity for developers, particularly in India and Russia, to purchase Microsoft products so that they can begin develop on it on their own. Furthermore, this is also allows Microsoft to “evangelize” these developing countries that do not have preferences yet for Linux or Windows.

In conclusion, I feel that in order for Microsoft to maintain their market dominance, they need to focus as a company. They not only need to question whether their new product lines are actually viable and worth pursuing but they also need to streamline their existing flagship products. And finally as software commoditizes, they need to find new ways for the entire software market to grow.

Re: Intel at Apple's core


Any thoughts about the announcement? Personally I really don't think it's a big deal at all. It's gonna be the exact same setup expect Intel will be richer.


I think this is going to be really huge. I've always wanted to try Mac. But the main barrier has been very very expensive non-x86 hardware. I guess this is an issue for lots of other guys. On the home pc front, Apple may gain a larger market share. Not that Apple is going to overthrow MS, but will definitely make inroads into the market share.

Re: Gentoo's founder is off (to MS)

Yup.. heard about it.

I guess this means very little. Gentoo's founder Daniel Robbins created a great distro and also created a non-profit org which owns the entire distro and related stuff. So his leaving will not affect the distro much. There were a few really absurd(fun to read) forum posts at Gentoo!!

Tuesday, June 14, 2005

Intel at Apple's core

Check out this op about last week's "big" announcement.

Any thoughts about the announcement? Personally I really don't think it's a big deal at all. It's gonna be the exact same setup expect Intel will be richer. IBM will lose one of their most high profile clients (but I think Xbox 360 is gonna use a PowerPC, so don't cry too much for them).

It will be interesting to see how they will port all the apps over. This is actually the main point of the opinion article. All the Open Source apps I've downloaded have versions for all major OS's. This is just amazing. How are they able to develop platform independent code so efficiently? Even Linux itself is available on so many architectures. Gotta take your hat off to them.

Gentoo's founder is off

You heard about this?

Saturday, June 11, 2005

Re: New Member

Btw all of your posts need to bash Microsoft at some level. And you'll have to have a very high level of tolerance against really bad jokes by the other guys..

I failed to mention he interned at Microsoft last summer.

And good idea - the disclaimer about the bad jokes. At least he can't say we didn't warn him.

Friday, June 10, 2005

Re: Are Design Patterns How Languages Evolve?


Another good example in the is the Observer pattern. This is where you want to "observe" another object and be notified when an event occurs. In .NET the concept of an Event is built into the system.


What you mentioned about the Observer pattern is right. An observer(mostly UI) registers with an observable(data) to be notified about changes so that it can update/refresh itself.

I think the Event class you mention actually corresponds to the Command Design Pattern. I do not have a very good idea about this pattern so may be incorrect. Many times patterns are clubbed together to provide a solution.



I find that Design Patterns are discussed more on the Java side. I haven't found much material with regards to .NET. Dunno why.


There are a lot of patterns on the J2EE side. To build a good app.. with good perf, a lot of stuff needs to be done. Java stuff does not shield you that much. It is very easy to build an app that totally sucks in perf. A lot of experience and knowledge is required. .NET i guess protects the dev more. I guess we should try discussing more topics like say persistence as well which is one of the major areas in Enterprise apps.



I've added a new member - Pawan - to codeWord.


Welcome to the group!! Look forward to some good discussions.. on any topic whatsoever.

Btw all of your posts need to bash Microsoft at some level. And you'll have to have a very high level of tolerance against really bad jokes by the other guys..

Tuesday, June 07, 2005

New member

I've added a new member - Pawan - to codeWord. He's a fellow Google intern (You can see some pics on my personal blog). He's a senior from MIT. He's into lots of different stuff... Perl/PHP/MySQL/C#/Java/C++/VB/.NET/Graphic Design. And he's really into religion as well - specifically Hinduism. Not that it's important, but just felt like mentioning it.

So looks like Open Source web tech is going to get some coverage too. Another perspective is always good.

Re: Are Design Patterns How Languages Evolve?

So is this the author is talking about?? But again what I am talking about are not language extensions .. rather just API additions. Mohn mentioned language extensions but somehow I could not relate those to Design Patterns... Any ideas??

What I wrote in my previous post doesn't technically count as design patterns in the way it's used today. You're right. I suppose I was lumping the "hacks" or workarounds together with design patterns. Basically, something that isn't enforced by the compiler or the language but is agreed upon by the community.

As far as design patterns go, they are becoming language features. The Singleton pattern which you mentioned is one example. In the next version of C# (and VB.NET too I think), you can declare a "static" class. This makes it so that you can't create an instance of it. The constructor is automatically private. Another good example in the is the Observer pattern. This is where you want to "observe" another object and be notified when an event occurs (correct me if I'm wrong, or confused it with another pattern). In .NET the concept of an Event is built into the system. So you can actually create events, have other objects delegate their own methods to those events so that they are invoked when that event occurs.

So this is different to what you said about design patterns being built into the API's instead of the language itself.

I find that Design Patterns are discussed more on the Java side. I haven't found much material with regards to .NET. Dunno why.

Re: Are Design Patterns How Languages Evolve?


Are Design Patterns How Languages Evolve? Any thoughts?

.NET introduced the concept of "Attributes". Java 1.5 came out with a similar concept called "Annotations".

It's interesting to see the evolution of languages and how newer features are just formalized notions of what you could do before that feature came to be. More often than not, it was just "hacking" a feature for something it was'nt really meant for.


The links provided by Mohn did confuse me in a way. We could probably have a bit to discuss on this topic.

Design patterns and what Mohn mentioned are different concepts IMHO.

Mohn made a very interesting point about how newer features are added to langs, which were not initially thought of. And sometimes the 'hack' is not so clean as in Generics in Java. I think this is just happening to make the langs more developer-friendly, which is good in a way.

Design patterns are generic solutions to a particular set of problems. Take for example the Singleton pattern. This pattern helps in creating a class of which only a single instance will exist to the most throughout the lifetime of the application. Design Patterns are solutions built over OOP's concepts.

Design Patterns are now being built into languages. Iterators we use within Java Collections can be mapped to the Iterator Design Pattern. Similarly the Java Swing API heavily uses the Observer pattern and others too. The Observer pattern can be used easily in Java by using java.util.Observer and java.util.Observable. The Proxy pattern is also implemented in a way in Java. Mohn had an example ages back(.. which I still haven't read completely!!). The MVC pattern was initially thought of in SmallTalk. But nowadays many languages(or should i say libraries) provide MVC out-of-the-box. Like Mohn mentioned about ASP.NET v2. We now use many Design Patterns without even realising they exist. Many patterns are adapted to better fit the framework so look totally different.

So is this the author is talking about?? But again what I am talking about are not language extensions .. rather just API additions. Mohn mentioned language extensions but somehow I could not relate those to Design Patterns... Any ideas??

Sunday, June 05, 2005

Are Design Patterns How Languages Evolve?

Here's an interesting post. I had sort of mentioned a little about this in a previous post long back. Any thoughts?

Saturday, May 21, 2005

Re: Integrating OpenEJB with Tomcat 5.0


I know what you guys are thinking - "Dinesh talking about EJB


Welcome to the Dark Side!! Btw how many of you all like Star Wars??



I guess you all know that Tomcat is not an EJB Container and as such requires external support for it to work with EJB's, well I at work have been reading on EJB's for the past few days and as usual being my impatient self, just couldn't contend myself with reading the book, I had to see and run some code. Well, I already had Tomcat installed so I was wondering if there's anything I can do to get it working with EJB's and that's when I fell upon OpenEJB. (I think there's also Jboss)


I'll just give a brief intro. Tomcat is a J2EE Web Container which can be used to deploy Java Server Pages(JSP) and Servlets both of which are used to create dynamic web pages. Open EJB is (i suppose) just an EJB Container which allows you to deploy EJB's. OpenEJB and JBoss are open source implementations.



Revo, you'll really love this, that's if you already haven't done it. Just try it out, it's really simple and yet so powerful.


You mean calling EJB's from JSP's or Integrating OpenEJB and Tomcat?

I have used Sun's Reference Implementation(RI) J2EE App Server for deploying my EJB's. The RI includes Tomcat as a Web Container so you do not have to manually integrate. Also the RI has a good admin console. The RI is free for use. I am not sure about the source. I haven't used OpenEJB. I guess the RI will be more user friendly.



It was a great moment to see my SessionBean being called from my jsp. A good experience, but yet I'd rather be writing cryptic C++ code ;)


I am sure you have read about the functionality provided by J2EE App Servers.. all the distibuted stuff.. implicit middleware etc. Writing an app to achieve functionality like this will really take a huge team and loads of cryptic code. Btw are there any C++ App Servers which provide such services??


Also I spoke of the Dark side. EJB's are difficult to use. Don't Make me Eat the Elephant Again is an article that talks a bit on what the situation is today. There are alternatives to EJB like Spring + Hibernate which I have been hearing a lot of but have never had time to read about. Also the EJB 3 release will be coming soon which is based on J2SE 5.0 and heavily uses annotations which should really simplify coding.

Mohn.. could you mention a little about how the .NET framework handles persistence for the Enterprise?? I have heard that it is simple compared to the Java model.

Re: Adventures with Linux


Looking around I came across ndiswrapper on sourceforge. This is a really neat project which uses windows drivers to get linux to recognize the card. I had some trouble with the newest vesion (1.1), so tried different versions (.10, .09), compiled and can it. It worked! So configured "wlan0" and now writing this post in Opera 8.0 on Mandrake 10.0! Just had a feeling of euphoria!


Woohooo... Congrats man on finally getting your wlan working. Mohn had asked me to help with ndiswrapper ages back.. and as lazy as I am, he had to do it himself!!



You would think that having struggled with it for so long, I would be quite sick of it. In some ways I am, but I've also learnt a lot in the process. And this is the essence of Linux.


Exactly. There are so many things we just take for granted when we use Windows. But only for customization etc when you go deep into Linux do you understand a lot more about the OS and other stuff.

Thursday, May 19, 2005

SciTE Text & Code Editor

I have to admit that I'm a Editor freak!! I keep scourging the net for free, fast and good text editors namely for the Windows Platform. On Linux, Vim just kicks everyone else's butt!!

Recently I came across SciTE which in my opinion is one of the best I have ever used. It's simple and extremely fast. It's also extremely customizable and supports an array of programming languages!!

I think I'm going to stick with this editor for quite some time, hope you guys check it out!

Dinesh.

Wednesday, May 18, 2005

Integrating OpenEJB with Tomcat 5.0

I know what you guys are thinking - "Dinesh talking about EJB, GIVE ME A
BREAK!!" ;) But as the Walrus said "The time has come to talk of many
things" :)

I guess you all know that Tomcat is not an EJB Container and as such
requires external support for it to work with EJB's, well I at work have
been reading on EJB's for the past few days and as usual being my
impatient self, just couldn't contend myself with reading the book, I
had to see and run some code. Well, I already had Tomcat installed so I
was wondering if there's anything I can do to get it working with EJB's
and that's when I fell upon OpenEJB. (I think there's also Jboss)

I will not go into what you should do inorder to integrate the two cause
there's already an excellent article available on the subject at OnJava.com.

Revo, you'll really love this, that's if you already haven't done it.
Just try it out, it's really simple and yet so powerful.

It was a great moment to see my SessionBean being called from my jsp. A
good experience, but yet I'd rather be writing cryptic C++ code ;)
(Sorry, I'll be me, always!)

Dinesh.

Tuesday, May 17, 2005

Adventures with Linux

Ok, I admit it. I've been a blind bastard. Blind to Linux and open source. I've read about it and been keeping up with what's been going on in the "community" but never really "got" it. Well, I think something finally hit me - that light bulb turned on. Anyway, I've decided to write some stuff about my Linux experience.

Here's a brief history of my dealings with Linux as a total newbie (warning: boring stuff ahead). What got me interested in Linux, was my India trip in summer 03 when Rahul and Hrishi were using it. Before that, I never really thought about trying it out and didn't have much interest in it. But the way they spoke about it, I couldn't resist having a go at it. So after coming back, I installed Red Hat 9 on a couple of machines. At the time, I had a network setup over the phoneline and wasn't able to get Red Hat to recognize the NIC. Basically I gave up after several futile posts to message boards and many email exchanges with Rahul. Last May, I installed Mandrake 10 in the hopes that it would work. No luck there either. I realize it was my network setup - which was quite rare. So I gave up on that too. Last summer, I changed over to a wireless network. This time, I was a little more hopeful because this was a more common network setup. Anyhow, long story short, I had a usb wireless adaptor and Mandrake didn't recognize it. I remember spending an interesting afternoon with Rahul on messenger giving me step by step instrutions to recompile the kernel with added support for wireless drivers. Unfortunately, didn't work. Also tried Knoppix without luck. Finally, I installed Mandrake on a laptop which had a wirless card built in. This was pcmcia so I was hoping for better. Again, no luck.

Looking around I came across ndiswrapper on sourceforge. This is a really neat project which uses windows drivers to get linux to recognize the card. I had some trouble with the newest vesion (1.1), so tried different versions (.10, .09), compiled and can it. It worked! So configured "wlan0" and now writing this post in Opera 8.0 on Mandrake 10.0! Just had a feeling of euphoria!

You would think that having struggled with it for so long, I would be quite sick of it. In some ways I am, but I've also learnt a lot in the process. And this is the essence of Linux.

I'll post some stuff about some stuff I've liked about Linux next time.

Monday, May 09, 2005

RE: Stroustrup's Interview Leaked...

The "matter" is obviously a bunch of ******* bullshit but I would have liked to believe that it was Bjarne's idea of a joke! :-p

Friday, May 06, 2005

RE: Stroustrup's Interview Leaked...

I second Dinesh's "you got to be kidding right?" comment. Obviously the work of a C programmer.

RE: Stroustrup's Interview Leaked...

You actually thought that it was Bjarne Stroustrup?? You got to be kidding, right??

Dinesh.

Stroustrup's Interview Leaked...

I don't know how far this is true but entertaining to read nevertheless... :-)

Here's the link.

Thursday, May 05, 2005

Implementing "finally"

Java has this great facility when dealing with exceptions called "finally". When you have a finally block, any code within it will execute regardless of whether an exception has been thrown or not. It's a good place to put code that must absolutely positively be run like closing files, database connections and any other similar resources. C# also has it and I believe it's also been standardized in C++, but not sure. Anyway, ever wonder how it is actually implemented?

I wrote a really simple method that just has a try, catch, finally block and examined the bytecode generated using this really cool Eclipse plug-in.

Here's the java code...

public void testFinally()
{
    try
    {
        System.out.println( "try" );
    }
    catch ( Exception ex )
    {
        System.out.println( "catch" );
    }
    finally
    {
        System.out.println( "finally" );
    }
}


and here's the bytecode...

// testFinally()V
L0 (7)
GETSTATIC java/lang/System.out: Ljava/io/PrintStream;
LDC "try"
INVOKEVIRTUAL java/io/PrintStream.println(Ljava/lang/String;)V
GOTO L1
L2 (9)
ASTORE 1
L3 (11)
GETSTATIC java/lang/System.out: Ljava/io/PrintStream;
LDC "catch"
INVOKEVIRTUAL java/io/PrintStream.println(Ljava/lang/String;)V
L4
GOTO L1
L5 (14)
ASTORE 3
JSR L6
ALOAD 3
ATHROW
L6
ASTORE 2
L7 (15)
GETSTATIC java/lang/System.out: Ljava/io/PrintStream;
LDC "finally"
INVOKEVIRTUAL java/io/PrintStream.println(Ljava/lang/String;)V
L8 (16)
RET 2
L1 (14)
JSR L6
L9 (17)
RETURN
L10
LOCALVARIABLE this Ltest; L0 L10 0
LOCALVARIABLE ex Ljava/lang/Exception; L3 L4 1
MAXSTACK = 2
MAXLOCALS = 4


I don't understand bytecode. I would be interested in knowing more about it. But anyway, you don't need to be a bytecode specialist to understand how "finally" is always executed regardless of exception or not...

This is the "try" part

L0 (7)
GETSTATIC java/lang/System.out: Ljava/io/PrintStream;
LDC "try"
INVOKEVIRTUAL java/io/PrintStream.println(Ljava/lang/String;)V
GOTO L1


and this is the "catch" part

L3 (11)
GETSTATIC java/lang/System.out: Ljava/io/PrintStream;
LDC "catch"
INVOKEVIRTUAL java/io/PrintStream.println(Ljava/lang/String;)V
L4
GOTO L1


Notice any similarities? What is at "L1"?

L1 (14)
JSR L6


JSR is a jump instruction. So all this does is just to location L6. As you would suspect, it is the finally block...

L6
ASTORE 2
L7 (15)
GETSTATIC java/lang/System.out: Ljava/io/PrintStream;
LDC "finally"
INVOKEVIRTUAL java/io/PrintStream.println(Ljava/lang/String;)V


Voila. Mystery solved!

I have to say that the bytecode is NOT the most diffcult thing in the world to interpret. A lot of it is pretty self-explanatory. I realize this is a real toy example and it gets more complicated, but it looks like something one can pick up. It's the same situation with IL code in the .NET world. I think maybe IL is a bit easier to read.

Maybe not the most important thing, but something that's interesting and nice to know.

The essential Java language library

The essential Java language library

Seems like a decent list. Of the books mentioned, I can vouch for "Effective Java". Haven't read Bruce Eckel's "Thinking in Java", but he's a good writer... "Thinking in C++" was a good read and we've included him in many of our discussions! And I know Rahul is a big fan of "Design Patterns". As far as sites are concerned, onjava.com and theserverside.com have decent articles. onjava.com is part of oreilly which I really respect.

What are some of your fav books? We discussed books we'd LIKE to read long back, but what about books you've already read? I'll mention three - "Applied .NET Framework Programming", "Effective Java" and "The C++ Object Model". I really like books that go into detail and explain HOW things work, you know what's going on underneath the covers or talk about best practices rather than just talk about syntax. I think all these three do that and more.

Java turns 10

See James Gosling (and friends) celebrate his kid turning 10.

Warning - celebration is pretty pathetic.

Monday, April 11, 2005

Re: More on Mono

UML and strict development is good, but it's important not to get caught up in it. While I agree with their usefulness in practical situations, one must always remember that the final aim to churn up good code - and good software CAN be designed and implemented using basic common sense and just applying your mind to the problem and breaking it up into smaller parts.

When you try to make something too systematic, you run the risk of unnecessarily complicating matters. It's for us to decide where to draw the line. Use the 'formal' tools on a broad level but don't limit yourself to those or try to adhere to them like they're sacrosanct. Keep the big picture in mind and let creativity gain the upper hand! At the same time, you can't just 'hack' your way through in large apps. It's for the individual to optimize based on his requirements.

As far as mono goes, I don't have experience with it but based on whatever little I've read/heard about it, here's my two cents anyway! I don't have a great feeling about mono. It might pick up, you never know but if I were to develop a software, I wouldn't use mono! It's hard to give precise reasons; it's just a general feeling you get.

Sunday, April 10, 2005

Re: More on Mono

Firstly, seems like I struck a nerve. Seriously didn't mean to offend.

Everything you said is valid. No doubt. I was just trying to say that it really seems like things tend to become quite complicated. As you said UML is a recognized standard for communicating but it isn't required in every situation. UML is something that has come up with OOP. What about developers not using OOP? Correct me if I'm wrong, but most Linux/open source projects are still done in lower level, non-OO languages, primarily C. Many of these projects are quite huge and the ideas need to get across to many developers. How are they able to do it?

I have not downloaded or worked on any open source projects, even ones based on .NET or Java at places like sourceforge.net, but I wouldn't be surprised if there were no UML diagrams available with the source at these places. I suppose there are tools that will generate these diagrams automatically for you from source. VS .NET 2005 has this capability. I believe there are plug-ins for Eclipse also.

And what about Scripting. I've mentioned over a few posts about its gaining popularity. They are shedding their "toy" status and are being used in larger projects too. A lot of them are OO oriented, but not in the strict sense as in Java and .NET. So again, I wouldn't think UML is very popular in those communities.

I probably threw one too many things in the same boat by including Design Patterns in my dumb rant. I have'nt read the book you mentioned. I should, before saying more. I've primarily referred to this site. It seems to have most, if not all, the major ones listed. As an interesting point, I feel design patterns will be added into languages. For example, the Observer pattern is already a built in component of .NET with Delegates and Events. The next version will include a way to create a "static" class, wherein you can't create an instance of it - i.e. Singleton. If you think about it even getters/setters are in a way design patterns and they are built into .NET languages.

I'm digressing quite a bit, but this is just an example of what I'm talking about. I know I'm taking it out of context... I'm only talking small projects. But can't help but think that the trend is towards more complexity even though things like XP are trying to put up some resistance.

As an aside, dyou understand how open source projects work? How are so many people able to work on a project "unsupervised" as it were? Somehow it's just hard to imagine.

Personally I am very skeptical of Mono being used widely.

I'm assuming this is because of it being tied to .NET. Do you feel Linux guys will always reject it because of the "connection" to MS, even though it might be something useful?

Saturday, April 09, 2005

Re: More on Mono


One of the questions in the interview was about the development process behind Mono. He gives a really good answer about not being a great fan of UML and strict development processes. They are all great hackers and just want to do it because they are having fun... enjoying it. Strict dev practices etc... limit creativity and the "art" of programming.

What dyou think of his answer? I want to learn good practices about developing software because right now we all lack any substantial experience with it. But at the same time, I read about UML, design patterns, agile development, "some new hyped up buzzword" etc... and it all just seems so "messy" or tends to complicate matters. Same feeling I have with some Java developments. I've mentioned them before. It feels a lot of over engineering.


UML is a diagrammic notation to express Software design at various stages of development. You should learn UML because it is the de-facto method for communication between dev's. So if I show you a UML Class diagram you immediately know what inherits what and methods etc.. blah blah. As I mentioned various stages of developement exist for a particular piece of software. In the initial stage a Use Case diagram is made, then Analysis diagrams, then Design diags. All these help in development.

Now there are many methodologies for developing software. The various stages I mentioned were wrt the Waterfall process (or the Unified Dev Process), which I must admit is very boring. Too much documentation and managerial in nature. But understandably in a large organisation these things become important. Other methodologies include the Agile process. Agile process includes XP development practices which seem more Developer friendly. Many methodologies or processes use UML diagrams to express artifacts (or products) at various stages of development.

So firstly you should learn UML diagrams. Reading about various Development processes is also good. You will get an idea as to how many co's work. Dinesh could probably tell us a bit about his company. Which process you apply is a different matter.

And Design Patterns is a separate issue altogether. Which book for patterns or articles have you read?? Design Patterns was the first book to talk about patterns and is simply put a Bible. I have had the book since a while and even suggested to you guys to read the book. But to be frank I have not been able to understand too many patterns. We did try to apply a few in the Object Oriented Analysis and Design Module here at Ncb. Recently I read a sample from this book from Oreilly Head First Design Patterns. Read the sample chapter. The style of the book is very different, and I really loved it. Only after you read a few design patterns do you realise how beautiful solutions to generic problems can be !!

And complications in Java is another issue. I'll talk about Java some other time. I think you have mixed too many questions in one paragraph. Read about stuff to get an idea of things. UML and Design Pattens should be high on the priority list.


Also, any opinions about Mono? From his blog sometime back - "7 out of the 20 top-rated apps on gnomefiles.org are mono apps".


Even since coming here to Ncb I have harldy booted into Gentoo, and am not aware of whats going on in the Linux world. Probably Hrishi could shed more light on the popularity of Mono apps. Personally I am very skeptical of Mono being used widely.

Friday, April 08, 2005

More on Mono

Kinda obvious, but one of the great things about the programming world is that you interact, learn from, help and work with people from all over the world. Here's a video from Turkey interviewing Miguel De Icaza - the Mono dude (also GNOME founder). Can't understand half the things the interviewers are saying. I thought they were talking Turkish... turns out it was English.

Anyway, I really got a lot of respsect for Miguel. His blog gives you a good insight into his views - and not just programming related. He's like a really experienced open source hacker. Just feel like if you worked under him you would learn a lot. One of the questions in the interview was about the development process behind Mono. He gives a really good answer about not being a great fan of UML and strict development processes. They are all great hackers and just want to do it because they are having fun... enjoying it. Strict dev practices etc... limit creativity and the "art" of programming.

What dyou think of his answer? I want to learn good practices about developing software because right now we all lack any substantial experience with it. But at the same time, I read about UML, design patterns, agile development, "some new hyped up buzzword" etc... and it all just seems so "messy" or tends to complicate matters. Same feeling I have with some Java developments. I've mentioned them before. It feels a lot of over engineering. Granted this is coming from someone with little experience, but haven't you read an article which goes on about something and at the end of the 20th page you think, what the hell was that? Just seems so complicated for something which could have been done more simply.

Also, any opinions about Mono? From his blog sometime back - "7 out of the 20 top-rated apps on gnomefiles.org are mono apps". I was quite surprised/impressed. It looks like it's use has picked up.

Sunday, April 03, 2005

Google: Behind the scenes

Streaming vid (~1 hr): Behind the scenes at Google

One (more) thing which is impressive is they've built their services on top of commodity hardware... no super expensive machines. Just regular stuff with a lot of redundancy. Also, they have a ton of in built stuff - from a Google File System to some map/reduce algorithm which is infrastructure code to be fault tolerant and distribute the load among different machines (mentioned in the talk). They've recently started to share some of this.

Re: Databases Part 1

Waiting on part deux.

You'll have to wait for some more time... Very busy with the current module at Ncb as reaching the submission deadline.


A table can have a primary key.

When you say "can" dyou mean a primary key is NOT necessary? I thought it would be.


Right. A primary key is NOT necessary. But searching for a particular row will be more complicated as duplicates can be added to the table.


One thing that needs to be considered is where the error checking happen? Does it happen in the "business logic" layer or directly in the data layer? I would think a lot of times the database should ONLY be conserned with storing information.

I guess the question comes down to what responsibilities the database should take on. It seems the trend is to make more and more things happen in the data layer.


Basically databases are becoming more intelligent. So more Business logic is being pushed into the databases. It seems like mixing of responsibilities, but only specific business logic could be put into the db. Like you need to retrieve some data occasionally which spans across many tables and this is done very often. Rather than have loads of SQL in your business logic, just call a stored proc.

Another trend is distributed databases, which still have to mature well.

Error handling is possible in Stored procs. But I am not very sure how errors are sent to the host language. I think a simple SQLError could be returned by the db. We returned C-style status codes from the Stored procs.


Each trigger is associated with a TABLE on some event.

This is quite cool. I didn't know this was possible. You can basically keep a log/trace of everything that's going on in your database this way.


Care has to be taken that triggers are not written on 'events' of heavily used tables. Events could be insert, delete. Now if I have 500 inserts per sec on a table and I write a trigger on that event, its going to really load the server.


I'm interested in Stored Procedures just because I've read that they are beneficial to app performance. Is that really true?


Yes its true.

Now for some explanation.

When a simple query is submitted to a database, a few steps are carried out after which the result is returned. These include checking if the query is valid and tries to reference valid tables and columns. Then optimization of the query is done. Most queries in SQL are commutative and associative, so the order of the operations in the query can be changed without changing the meaning of the query as a whole. So the db does this based on the information it has about its tables and some heuristics as well. After this, the new SQL query tree is compiled and finally executed to return a result. Now as you have noticed, this is a very complicated and lengthy process. (and trust me, db's are really smart already wrt optimization!!)

Back to Java. There are three ways to execute a query in Java SQL - A Statement, a PreparedStatement and a Callable statement.

Now in a simple statement, the query is sent from the host language, then goes through all the steps of checking and optimization mentioned above.

A prepared statement is cached into the db for some time. So it does not have to go through all the optimizations steps each time. Probably only the new arguments have to be checked which should be faster.

A Callable statement is used to run a Stored Procedure. Now a stored procedure query resides IN the db. Only arguments are passed similar to a Prepared statement. So all optimization, compilation is already done.

I guess that should explain performance effects of various methods.

Also Stored procedures have other advantages like Mohn mentioned in his Hacking Websites blog.

< Excerpt Begin >
Be paranoid and ALWAYS validate data coming from the client. And as far as possible use Stored Procedures. Besides getting a performance boost (since they are compiled vs SQL statements that are interpreted), they use typed parameters
< Excerpt End >


What db are you working with? I've had basic experience with Access and SQL Server.


I used to work on Access before leaning what a 'real' db is supposed to do. We worked on SQL Server here at Ncb. Access does not do most of the things I blogged about. Just has tables with Primary and Foreign keys. Probably something more!!

I guess this blog introduced Stored procedures well enough. An example later..

Sunday, March 27, 2005

Dynamic Languages

Over at DevSource they have a piece on The State of the Scripting Universe. Boy, this scripting engine really is going full throtle. Everyone and his dad seems to have seen the light and gone over to scripting land. Somehow I'm still sitting in "static" darkness. We have discussed this a bit before. I guess it's the fact that I've only had very limited exposure to it... not having developed something "significant". Once you have that kind of experience under your belt it's better to compare it with C#/Java/C++.

I believe scripting in quite big in game development. A friend of mine works at a gaming company and all he does is scripting (some custom developed one) and he's in the design department! From what I understand, all games start out with the engine and you just customize that. The engine is sort of like the platform? And the scripting languages use that as an API? Maybe Dinesh can shed some light.

While on topic, Bruce Eckel had a post last month about productivity between static/dynamic languages. Productivity is one of the apparent key advantages of dynamic languages. In it he links to some dude who writes about Tests vs Type. Read his post to understand what that means.

Personally, I think the "Edit Types" block under "Explicit Typing" is way too big. To me it seems like spending time "editing types" is a way of testing. You bypass this step in "implicit typing". So I think the "editing types" part should come under tests. What dyou think?

Btw, searching for anything on the blog really sucks. I had to find the previous post link manually. Google isn't spidering/indexing the posts properly.