Wednesday, July 07, 2004

Unified Type System

I came across this question on one software developer' blog I read: "Why is each class in Java implicitly inherited from Object?"

My immediate thoughts turned to collections. Because neither system (Java nor .NET) had generics when they were introduced, without having every class implicitly inherit from Object, it would require a specialization for every possible class to be able to put it in a collection (which is impossible). Having a requirement that every class in the system implement a common interface (Object's) makes it possible for collections to be generic enough to be used with anyone.

I can't think of any other reason. How about you?

We sort of take it for granted that Java (and .NET) has a unified type system. We rarely really think about why it is that way.

No comments: