what's Mgpt? So are they going to teach you C/C++ in this next module or just use it for your programming?
Mgpt is one of the assessment methods here at Ncb. You'll get lots of info here . To put it simply, is a sort of a topcoder puzzle solving contest. Complexity of problems varies from "very difficult" to "writing a compiler is easier" levels. We have to clear Mgpt's for two modules, Java programming and Data Structures using Java. Generally only 3-4 students clear both in the entire year.
In the current module we are being taught programming in C/C++. C was just 2 sessions. C++ has more sessions but still really fast. And we are covering the new std C++. One of the C++ assignments is to create a Big Integer (BigInt) data type. The BigInt can have upto 100 digits and we are supposed to overload operators for < , > , == , +, - , / , % and few others. Just completed this one and division (/) has been amazing to code!!
In the next modules we have to create projects and no assignment problems as such. In those we can choose any language of implementation, Java or C++. No prizes for guessing what I'll prefer.
Just for an overview - C# programming
I have a super huge grin on me face. You don't know how happy this made me. Change is good :-)
I've always wanted to learn more programming languages. I think we agree that to be a complete dev have to know more than a particular lang. Good to appreciate design of each lang. Its just that I've been too lazy. Once you've entered the comfort zone with a lang, its hard to get out.
C++ has been a good experience. Lots to learn still but seen some really cool stuff. I dunno if I'll ever do stuff like python etc..
So hope that cleared some stuff up. What are your impressions of .NET from the book. I've been blogging a lot about this stuff so you should be familiar with some of it already - atleast I hope.
I had to switch to C++ so didn't do much. Most of the explanations you gave caused me to wonder.. what happens in Java. So I'll probably research on this for some time.
All your blogs on C# have been super helpful. I still have a few doubts, but those will get fixed only when I start coding. There's a limit to how much you can understand by reading.
Sunday, October 10, 2004
Wednesday, October 06, 2004
Google's domain registrations
There was an article on slashdot regarding the registration of gbrowser.com. Some dude who was as early investor in google said that they weren't going to be entering the newly emerged browser wars. Check out these comments...
Now it makes you wonder why Google registered gbrowser.com?
>> No it doesn't. They also registered googlesucks.com, but I don't
>> think they feel that way about themselves.
>> They registered Googlesucks.com? This is clear evidence
>> they're entering the vacuum cleaner market!
>> Crap! I was hoping it was an adult content
>> search engine :(
Now it makes you wonder why Google registered gbrowser.com?
>> No it doesn't. They also registered googlesucks.com, but I don't
>> think they feel that way about themselves.
>> They registered Googlesucks.com? This is clear evidence
>> they're entering the vacuum cleaner market!
>> Crap! I was hoping it was an adult content
>> search engine :(
Saturday, October 02, 2004
Tuesday, September 28, 2004
Re: C# ?
The DS module in Cdac is over and I just flunked in the Mgpt. The next module is C and C++ programming and so I should have lots of questions coming up soon.
Sorry if you've told me this before already but what's Mgpt? So are they going to teach you C/C++ in this next module or just use it for your programming?
Just for a change I got a book from the library which I plan to go through very fast just for an overview - C# Progamming (with the public beta) by Wrox. So got another bunch of questions...
I have a super huge grin on me face. You don't know how happy this made me. Change is good :-)
Enums in c# are value types. So firstly are data types stored on the stack? And even class instances can be stored on the stack.. so what's the syntax for that?
In .NET there are two sets of objects... Reference and Value types. Reference types are Classes, Interfaces, Delegates, Arrays. Value types are Structs and Enums. Basically, all objects in the system have System.Object as the root object. But value types, also derive from System.ValueType. So you CANNOT create class instances on the stack. You can only create struct instances on the stack, which implicitly derive from System.ValueType. And btw, all primitive types in C# like int, double etc... are structs in the BCL (Base Class Library).
On enums i wanted to compare them with java enums. In java 5.0, enums were added which are actually classes. So when you say enum {something} you are actually extending a class. So enums in java are pretty advanced. I'll have to read more to give more info. What about c#? You can get more info on Enums from this Oreilly sample chapter
I guess again the motivation for making enums classes was for backward/forward compatibility. I scanned the article link you sent briefly and you're right... java enums have much more ability since they are full blown classes. Personally, I don't see the point of this. Enums play a very specific role in C++ and C#. They are just defining type-safe constants as a group. Why complicate matters by allowing it to do everything a class can do? Why would you want to define methods on an enum? Dyou see a benefit?
Another thing was the huge number of keywords. I read on const and readonly. Are they really required over final?
I dunno the exact number, but I guess C# must have maybe +20 keywords over java.
Regarding const and readonly - they serve two different purposes. const is evaluated at compile time and is implicitly static. So every instance of the class gets only one copy. readonly is evaluated at runtime and are not static. So every instance gets its own copy.
If you make any fields const in your app, when you compile it, the compiler will replace all the fields with the actual value. For ex.
class Math
{
public const double PI = 3.14;
}
class Circle
{
private double circumference( double radius )
{
return 2 * Math.PI * radius;
}
}
Here, it will turn into 2 * 3.14 * radius. The compiler can make this optimization. You can't do it for readonly fields since they are evaluated at runtime.
But readonly fields have a different benefit. What if you shipped this code and then later on realized that PI is wrong or you want to make it more accurate. If you had made it a readonly field, you can just make the change and ship the updated Math class. Your Circle class's Circumference method will automatically use the new updated PI value without re-compiling. Since PI is evaluated at runtime it will automatically use the updated value. But since it's const here, you will have to recompile.
Does final do both?
The main question that propmted this blog was inheritance.virtual override new sealed and abstract... wow so many keywords and complex relationshipsDo you make use of all these keywords?? Isn't the Java style much more simple? Trying to appease c++ programmers, but added awhole extra bunch of words!!
Again, all those keywords serve a purpose just as const vs readonly. They didn't just get keyword happy. I had written a blog regarding polymorphism in C++, Java and C# long back - http://codeword.blogspot.com/2003/12/polymorphism-c-vs-java-vs-c.html. It talks about virtual, override and new. So check it out and see if you think they serve some meaningful purpose.
Java uses one keyword which can be used on classes, methods and fields. They have the same essential meaning for all - preventing things from being changed. C# has taken a different route. They make all methods non-changeable by default and then make you explicitly say if you want to change something. They requires more keywords.
On boxing and unboxing, why the need for a different object class from the default Object class? In Java the wrapper classes for primitives like Integer for int can be cast to Object. Wrt Java 5.0 I think the compiler will be generating casting code which was generally written by hand.
One thing you should understand is that all the types are defined in the .NET BCL. The language itself does NOT define any types. The languages only provide an alias for primitive, string and object types. So in C#, int == System.Int32, long == System.Int64, double == System.Double, string == System.String, object == System.Object etc... Same way VB and Managed C++ provide something similar. So there is no different object class from the default Object class.
So hope that cleared some stuff up. What are your impressions of .NET from the book. I've been blogging a lot about this stuff so you should be familiar with some of it already - atleast I hope.
Btw, check this link out - C# from a Java Developers Perspective. It's a bit old but quite comprehensive and an easy read. He'll have to update it for Tiger. And before you expect some .NET bashing... he's a Microsoft employee.
Sorry if you've told me this before already but what's Mgpt? So are they going to teach you C/C++ in this next module or just use it for your programming?
Just for a change I got a book from the library which I plan to go through very fast just for an overview - C# Progamming (with the public beta) by Wrox. So got another bunch of questions...
I have a super huge grin on me face. You don't know how happy this made me. Change is good :-)
Enums in c# are value types. So firstly are data types stored on the stack? And even class instances can be stored on the stack.. so what's the syntax for that?
In .NET there are two sets of objects... Reference and Value types. Reference types are Classes, Interfaces, Delegates, Arrays. Value types are Structs and Enums. Basically, all objects in the system have System.Object as the root object. But value types, also derive from System.ValueType. So you CANNOT create class instances on the stack. You can only create struct instances on the stack, which implicitly derive from System.ValueType. And btw, all primitive types in C# like int, double etc... are structs in the BCL (Base Class Library).
On enums i wanted to compare them with java enums. In java 5.0, enums were added which are actually classes. So when you say enum {something} you are actually extending a class. So enums in java are pretty advanced. I'll have to read more to give more info. What about c#? You can get more info on Enums from this Oreilly sample chapter
I guess again the motivation for making enums classes was for backward/forward compatibility. I scanned the article link you sent briefly and you're right... java enums have much more ability since they are full blown classes. Personally, I don't see the point of this. Enums play a very specific role in C++ and C#. They are just defining type-safe constants as a group. Why complicate matters by allowing it to do everything a class can do? Why would you want to define methods on an enum? Dyou see a benefit?
Another thing was the huge number of keywords. I read on const and readonly. Are they really required over final?
I dunno the exact number, but I guess C# must have maybe +20 keywords over java.
Regarding const and readonly - they serve two different purposes. const is evaluated at compile time and is implicitly static. So every instance of the class gets only one copy. readonly is evaluated at runtime and are not static. So every instance gets its own copy.
If you make any fields const in your app, when you compile it, the compiler will replace all the fields with the actual value. For ex.
class Math
{
public const double PI = 3.14;
}
class Circle
{
private double circumference( double radius )
{
return 2 * Math.PI * radius;
}
}
Here, it will turn into 2 * 3.14 * radius. The compiler can make this optimization. You can't do it for readonly fields since they are evaluated at runtime.
But readonly fields have a different benefit. What if you shipped this code and then later on realized that PI is wrong or you want to make it more accurate. If you had made it a readonly field, you can just make the change and ship the updated Math class. Your Circle class's Circumference method will automatically use the new updated PI value without re-compiling. Since PI is evaluated at runtime it will automatically use the updated value. But since it's const here, you will have to recompile.
Does final do both?
The main question that propmted this blog was inheritance.virtual override new sealed and abstract... wow so many keywords and complex relationshipsDo you make use of all these keywords?? Isn't the Java style much more simple? Trying to appease c++ programmers, but added awhole extra bunch of words!!
Again, all those keywords serve a purpose just as const vs readonly. They didn't just get keyword happy. I had written a blog regarding polymorphism in C++, Java and C# long back - http://codeword.blogspot.com/2003/12/polymorphism-c-vs-java-vs-c.html. It talks about virtual, override and new. So check it out and see if you think they serve some meaningful purpose.
Java uses one keyword which can be used on classes, methods and fields. They have the same essential meaning for all - preventing things from being changed. C# has taken a different route. They make all methods non-changeable by default and then make you explicitly say if you want to change something. They requires more keywords.
On boxing and unboxing, why the need for a different object class from the default Object class? In Java the wrapper classes for primitives like Integer for int can be cast to Object. Wrt Java 5.0 I think the compiler will be generating casting code which was generally written by hand.
One thing you should understand is that all the types are defined in the .NET BCL. The language itself does NOT define any types. The languages only provide an alias for primitive, string and object types. So in C#, int == System.Int32, long == System.Int64, double == System.Double, string == System.String, object == System.Object etc... Same way VB and Managed C++ provide something similar. So there is no different object class from the default Object class.
So hope that cleared some stuff up. What are your impressions of .NET from the book. I've been blogging a lot about this stuff so you should be familiar with some of it already - atleast I hope.
Btw, check this link out - C# from a Java Developers Perspective. It's a bit old but quite comprehensive and an easy read. He'll have to update it for Tiger. And before you expect some .NET bashing... he's a Microsoft employee.
Re: A9 ??
If I would get a good net connection I think I would. It has a better UI with more features.
The site looks good. They are providing a more "dynamic" user interface and some potentially useful additional features like keeping a history and bookmarking your searches. No doubt about this.
The point I was trying to make is, it is not a huge leap from what google is offering. Essentially, when I search, I want results - that's it. I don't even go to google's website anymore... just use it from the toolbar on Opera, Firefox and IE. So the UI that a9 is offering makes no difference to me since they are just returning google results. If it was using a different technology entirely, then yeah, maybe I'd use it to see how it compares to google (which has set the standard for everybody).
What's your opinion? Dyou agree on the point about functionality?
Do you use rich-UI sites? I know you don't like sites with flash overkill but does this qualify as the same?
Yup, generally I don't like Flash sites. The keyword is "generally". My experience has been that they go totally overboard and are too flashy (pun intended). But that's not to say I don't like rich-UI sites. The best example is GMail. It qualifies as a rich-UI site. And it's superbly designed... extremely simple, but functional and useable.
I know you have an opposite view regarding flash sites.
The site looks good. They are providing a more "dynamic" user interface and some potentially useful additional features like keeping a history and bookmarking your searches. No doubt about this.
The point I was trying to make is, it is not a huge leap from what google is offering. Essentially, when I search, I want results - that's it. I don't even go to google's website anymore... just use it from the toolbar on Opera, Firefox and IE. So the UI that a9 is offering makes no difference to me since they are just returning google results. If it was using a different technology entirely, then yeah, maybe I'd use it to see how it compares to google (which has set the standard for everybody).
What's your opinion? Dyou agree on the point about functionality?
Do you use rich-UI sites? I know you don't like sites with flash overkill but does this qualify as the same?
Yup, generally I don't like Flash sites. The keyword is "generally". My experience has been that they go totally overboard and are too flashy (pun intended). But that's not to say I don't like rich-UI sites. The best example is GMail. It qualifies as a rich-UI site. And it's superbly designed... extremely simple, but functional and useable.
I know you have an opposite view regarding flash sites.
C# ?
The DS module in Cdac is over and I just flunked in the Mgpt. The next module is C and C++ programming and so I should have lots of questions coming up soon.
Just for a change I got a book from the library which I plan to go through very fast just for an overview - C# Progamming (with the public beta) by Wrox. So got another bunch of questions...
Enums in c# are value types. So firstly are data types stored on the stack? And even class instances can be stored on the stack.. so what's the syntax for that? On enums i wanted to compare them with java enums. In java 5.0, enums were added which are actually classes. So when you say enum {something} you are actually extending a class. So enums in java are pretty advanced. I'll have to read more to give more info. What about c#? You can get more info on Enums from this Oreilly sample chapter
Another thing was the huge number of keywords. I read on const and readonly. Are they really required over final?
The main question that propmted this blog was inheritance.virtual override new sealed and abstract... wow so many keywords and complex relationshipsDo you make use of all these keywords?? Isn't the Java style much more simple? Trying to appease c++ programmers, but added awhole extra bunch of words!!
On boxing and unboxing, why the need for a different object class from the default Object class? In Java the wrapper classes for primitives like Integer for int can be cast to Object. Wrt Java 5.0 I think the compiler will be generating casting code which was generally written by hand.
Just for a change I got a book from the library which I plan to go through very fast just for an overview - C# Progamming (with the public beta) by Wrox. So got another bunch of questions...
Enums in c# are value types. So firstly are data types stored on the stack? And even class instances can be stored on the stack.. so what's the syntax for that? On enums i wanted to compare them with java enums. In java 5.0, enums were added which are actually classes. So when you say enum {something} you are actually extending a class. So enums in java are pretty advanced. I'll have to read more to give more info. What about c#? You can get more info on Enums from this Oreilly sample chapter
Another thing was the huge number of keywords. I read on const and readonly. Are they really required over final?
The main question that propmted this blog was inheritance.virtual override new sealed and abstract... wow so many keywords and complex relationshipsDo you make use of all these keywords?? Isn't the Java style much more simple? Trying to appease c++ programmers, but added awhole extra bunch of words!!
On boxing and unboxing, why the need for a different object class from the default Object class? In Java the wrapper classes for primitives like Integer for int can be cast to Object. Wrt Java 5.0 I think the compiler will be generating casting code which was generally written by hand.
Re: A9 ??
Haven't used it much, but don't see it as being anything great. One major thing is the site info and history. Other than that, a bit advanced user interface.
This is my view. How dyou find it? Would you use it over google?
If I would get a good net connection I think I would. It has a better UI with more features. Do you use rich-UI sites? I know you don't like sites with flash overkill but does this qualify as the same?
This is my view. How dyou find it? Would you use it over google?
If I would get a good net connection I think I would. It has a better UI with more features. Do you use rich-UI sites? I know you don't like sites with flash overkill but does this qualify as the same?
Saturday, September 25, 2004
Re: Generics and different interpretations of backwards compatibility
When backward compatibility is mentioned about Java releases, it means that the bytecode is similar to old releases. So new compilers will not generate bytecode which is new. Just the conversion of code like generics to bytecode will be done by the compiler. Other features also need the compiler to generate code. So the VM as such does not need to recognise any new keywords. So the JVM's do not need to change the core.
So what you're saying is that the bytecode that was designed back when Java first came out is set and won't be changed for stuff like generics? And the class file that is generated won't have anything that can't be recognized by previous VMs?
In .NET on the other hand newer bytecode keywords might have been added. So running that code will require different changes in the VM.
This is what I understand. I guess there will have to be changes to the IL and assembly metadata when compiling new features like generics. So you can't load it on previous CLR versions.
Which do you think is better??
I've always understood "backwards compatibility" to mean "be able to run older code on newer platforms without making any changes". This gives you the freedom to make any improvements you want to new stuff as long as older stuff works. And this is what .NET is doing.
Somehow Java is trying to do both things... backwards and forwards. Run old code on newer JVM without problem, and also run newer code on older JVM. But this second part has a catch - you can only use the old APIs. If you want to use new features like API improvements and generics, you will need the newer VM and APIs. I don't see the point. One argument is, there will be a larger installed base, but I mean, you can't use new features so just work with previous APIs and VM.
I'm still confused about something... can you clarify. Is VM and Java API completely separate? So can you use VM 1.5 with API 1.4? I believe this can be done with .NET. If you have the newest version of the CLR, you can use all previous API versions. They plan to have only one CLR in Longhorn.
So what you're saying is that the bytecode that was designed back when Java first came out is set and won't be changed for stuff like generics? And the class file that is generated won't have anything that can't be recognized by previous VMs?
In .NET on the other hand newer bytecode keywords might have been added. So running that code will require different changes in the VM.
This is what I understand. I guess there will have to be changes to the IL and assembly metadata when compiling new features like generics. So you can't load it on previous CLR versions.
Which do you think is better??
I've always understood "backwards compatibility" to mean "be able to run older code on newer platforms without making any changes". This gives you the freedom to make any improvements you want to new stuff as long as older stuff works. And this is what .NET is doing.
Somehow Java is trying to do both things... backwards and forwards. Run old code on newer JVM without problem, and also run newer code on older JVM. But this second part has a catch - you can only use the old APIs. If you want to use new features like API improvements and generics, you will need the newer VM and APIs. I don't see the point. One argument is, there will be a larger installed base, but I mean, you can't use new features so just work with previous APIs and VM.
I'm still confused about something... can you clarify. Is VM and Java API completely separate? So can you use VM 1.5 with API 1.4? I believe this can be done with .NET. If you have the newest version of the CLR, you can use all previous API versions. They plan to have only one CLR in Longhorn.
Re: SUN in the news again!!
Somehow I always get the feeling Sun has a bit of an identity crisis. For ex. with IBM, you know they've put their full force behind Open Source. But with Sun, they support it, don't support it, now Open Sourcing Solaris, attacking Linux. It's hard to see where they will go.
I guess pretty much all closed sourced companies are under pressure now to open their source code to the world because of Linux. Microsoft already opened up Windows to major governments and recently did the same for Office. Sun felt the heat too and so decided to open source Solaris. Dyou see a great benefit from doing this? I guess they are mostly doing this to appease people than get anything out of it. I doubt there will be much community involvment in it as it will always be seen as controlled by Sun. Somehow it seems like a fad right now - Open Source everything... whether it will be of any use or not.
Sun has already open-sourced a lot of stuff and are very open with Java. Personally I do not think that Java should be open-sourced. They have to get the community on their side. Thats a very hard task.
I agree with you. It's a bad idea to open source Java. What they keep saying is Open Standards rather than Open source and that seems a good way to go. Actually, all the source for the Java API's are available. And Java is already quite open in that a lot of companies are involved in improving it.
I guess pretty much all closed sourced companies are under pressure now to open their source code to the world because of Linux. Microsoft already opened up Windows to major governments and recently did the same for Office. Sun felt the heat too and so decided to open source Solaris. Dyou see a great benefit from doing this? I guess they are mostly doing this to appease people than get anything out of it. I doubt there will be much community involvment in it as it will always be seen as controlled by Sun. Somehow it seems like a fad right now - Open Source everything... whether it will be of any use or not.
Sun has already open-sourced a lot of stuff and are very open with Java. Personally I do not think that Java should be open-sourced. They have to get the community on their side. Thats a very hard task.
I agree with you. It's a bad idea to open source Java. What they keep saying is Open Standards rather than Open source and that seems a good way to go. Actually, all the source for the Java API's are available. And Java is already quite open in that a lot of companies are involved in improving it.
Re: Generics and different interpretations of backwards compatibility
I'm actually a bit confused about this. If your new Java 1.5 code can run on previous VM's then you will only be able to use the Java API from previous versions right? You can't use any new functionality added to the library. So you will need to get the new API's anyway?
I am not sure if my explanation is totally correct.
What Mohn said about needing the Java 5.0 VM to run 5.0 API enhancements is correct. When backward compatibility is mentioned about Java releases, it means that the bytecode is similar to old releases. So new compilers will not generate bytecode which is new. Just the conversion of code like generics to bytecode will be done by the compiler. Other features also need the compiler to generate code. So the VM as such does not need to recognise any new keywords. So the JVM's do not need to change the core. Just add the newer libraries (rt.jar). Only one keyword enum has been added in 5.0. Enums are also classes in Java.
In .NET on the other hand newer bytecode keywords might have been added. So running that code will require different changes in the VM.
Which do you think is better??
(I think I made this blog a bit confusing)
I am not sure if my explanation is totally correct.
What Mohn said about needing the Java 5.0 VM to run 5.0 API enhancements is correct. When backward compatibility is mentioned about Java releases, it means that the bytecode is similar to old releases. So new compilers will not generate bytecode which is new. Just the conversion of code like generics to bytecode will be done by the compiler. Other features also need the compiler to generate code. So the VM as such does not need to recognise any new keywords. So the JVM's do not need to change the core. Just add the newer libraries (rt.jar). Only one keyword enum has been added in 5.0. Enums are also classes in Java.
In .NET on the other hand newer bytecode keywords might have been added. So running that code will require different changes in the VM.
Which do you think is better??
(I think I made this blog a bit confusing)
SUN in the news again!!
Well Sun is in the news again as they might open source Solaris and are also changing their strategy by attacking Red Hat.
So got a few interesting links..
Sun's plans...and how they could go wrong
Reflections on OS addiction
I really suggest reading some follow-up blogs from the second link. Really cool.
Sun has already open-sourced a lot of stuff and are very open with Java. Personally I do not think that Java should be open-sourced. They have to get the community on their side. Thats a very hard task.
Is this bad or good for Linux/SUN/MS..?
So got a few interesting links..
Sun's plans...and how they could go wrong
Reflections on OS addiction
I really suggest reading some follow-up blogs from the second link. Really cool.
Sun has already open-sourced a lot of stuff and are very open with Java. Personally I do not think that Java should be open-sourced. They have to get the community on their side. Thats a very hard task.
Is this bad or good for Linux/SUN/MS..?
Friday, September 24, 2004
Generics and different interpretations of backwards compatibility
From Bruce Eckel's blog - http://mindview.net/WebLog/log-0058
Going back to his disappointment at Java generics and erasure. Erasure erases the type info at runtime, so casting is done under the hood w/o programmer's knowledge. .NET retains type info as metadata and is accessible at runtime.
Interesting to see what he writes about backward compatibility. Whereas Java wants to be able to write code using Java 1.5 and be able to run it on previous VM's, .NET wants to be able to run previously developed code in the new CLR w/o recompilation. You can't run newly developed .NET code (v2) on previous versions of CLR.
I'm actually a bit confused about this. If your new Java 1.5 code can run on previous VM's then you will only be able to use the Java API from previous versions right? You can't use any new functionality added to the library. So you will need to get the new API's anyway?
Going back to his disappointment at Java generics and erasure. Erasure erases the type info at runtime, so casting is done under the hood w/o programmer's knowledge. .NET retains type info as metadata and is accessible at runtime.
Interesting to see what he writes about backward compatibility. Whereas Java wants to be able to write code using Java 1.5 and be able to run it on previous VM's, .NET wants to be able to run previously developed code in the new CLR w/o recompilation. You can't run newly developed .NET code (v2) on previous versions of CLR.
I'm actually a bit confused about this. If your new Java 1.5 code can run on previous VM's then you will only be able to use the Java API from previous versions right? You can't use any new functionality added to the library. So you will need to get the new API's anyway?
Tuesday, September 21, 2004
Re: A9 ??
Haven't used it much, but don't see it as being anything great. One major thing is the site info and history. Other than that, a bit advanced user interface. I'd still use google. I mean they are essentially just doing a google search and presenting it in a different way. I don't think this is meant as a competitor. I guess, amazon just wanted to get into the search game and maybe make some money with sponsored links?
This is my view. How dyou find it? Would you use it over google?
This is my view. How dyou find it? Would you use it over google?
gbrowser
There's been some roumors about google working on a browser. Apparently they've even registered gbrowser.com.
I've read on some blogs about google planning on an instant messenger and also a grand plan of a super OS. This is all speculation... nothing official, but it seems they are dipping their bud in a lot of areas.
Google is an exciting young company with a lot of bright ideas. They've been hiring the greatest brains from companies like Microsoft and Sun. Also doing some radical new stuff. Just as an example, on my bus ride to the Uni, there is a huge billboard for a google ad. The ad doesn't say that it's from google. Instead, it asks to solve a problem, which gives you a URL to a website, which asks another problem. If you get through it, they ask you to send your resume. Just some simple stuff like that which I don't think has ever been done before.
Having said all this great stuff about them, I'm a bit skeptical about the google browser, if it is true. I don't see what they could possibly come out with that will be a radical departure from Opera or Firefox, who are setting the standards for browser innovation. Sure, google has great services - search, mail, groups, but I don't see the rational in coming out with a browser just to "connect" all those properties, as some people have been speculating. Do you? And if they do come out with one, what dyou think the reaction of the open source community will be? They are behind Firefox/Mozilla full force.
I've read on some blogs about google planning on an instant messenger and also a grand plan of a super OS. This is all speculation... nothing official, but it seems they are dipping their bud in a lot of areas.
Google is an exciting young company with a lot of bright ideas. They've been hiring the greatest brains from companies like Microsoft and Sun. Also doing some radical new stuff. Just as an example, on my bus ride to the Uni, there is a huge billboard for a google ad. The ad doesn't say that it's from google. Instead, it asks to solve a problem, which gives you a URL to a website, which asks another problem. If you get through it, they ask you to send your resume. Just some simple stuff like that which I don't think has ever been done before.
Having said all this great stuff about them, I'm a bit skeptical about the google browser, if it is true. I don't see what they could possibly come out with that will be a radical departure from Opera or Firefox, who are setting the standards for browser innovation. Sure, google has great services - search, mail, groups, but I don't see the rational in coming out with a browser just to "connect" all those properties, as some people have been speculating. Do you? And if they do come out with one, what dyou think the reaction of the open source community will be? They are behind Firefox/Mozilla full force.
Monday, September 20, 2004
Re: Longhorn Features?
Firstly thanks for all the amazing info you provided.
Last year at their Professional Developer's Conference (PDC), Microsoft announced that Longhorn would include three technology pillars - "Avalon", "Indigo" and "WinFS".
For sometime they had been talking about releasing the "Indigo" set of API's as an add-on to the .NET framework.
There are pro's and con's to this...
blah blah ( :) )
What do you feel about the announcement? You think it's a major advantage for the Linux dudes?
I see the entire Longhorn issue in a different way. Its more of Win vs Win. What I mean to say is that considering all the MAJOR changes in the OS, will the industry accept. I rather think they'll take a wait and watch approach. Especially on the server-side. Btw is Longhorn going to be for the desktop or server? So adoption of a very new technology will be slightly slow. How fast did industry accept the Win NT platform? Is .NET being readily accepted? as a stable platform? I am asking questions here and not being cynical. Thats a reason why I believe an incremental update to the OS is a much better approach.
Will Linux gain in what I feel might be a sluggish initial period? I am not sure. Linux vs Windows will continue to be decided on different factors. Servers do not need the Longhorn features. Same for most co's running word processing apps. So who knows.
The same argument applies to the new Java 5.0 version. There are many new features so when will the industry adopt? We as dev's get excited with new tech. What is the status of Web Services? How many co's use them? (Again a question). I do not think Web Services have been adopted widely enough.
Whats Yukon and the other future stuff?? I read some article somwhere which basically confused all the relationship between the file-system, the database etc!! Whats supposed to do what? And like Mohn (assuming Mohn and I are not the only ones reading codeword anymore!!) mentioned the base FS is something else. So any idea about all the layers?
Other points Mohn raised was the size of the .NET framework and version problems.
The Java runtime Environment is 10Mb+ and the SDK is 30Mb+. Both platforms are mini-OS'es in a way. After Longhorn, .NET might become super huge!! Un-Downloadable !! Java also has so many extensions now (javax) which are pretty huge in size. So thats going to be a bigger problem for Java as MS will bundle .NET in the OS.
On incompatibility between versions there are differences again. In Java, all versions are backward compatible. Even though a section maybe deprecated (say 1.1), even the never versions have to support it. In other words what is marked as deprecated is never removed. This was one promise by SUN to their customers, that Java will always be backward compatible. This is not what the dev's like too much. Obviously this bloats the API and its not "clean" anymore. Having said hat the .NET scene seems more worse? What versioning system is followed in .NET? Any minor/major system? I always get the feeling that .NET is in a sort of a test phase. Maybe after Longhorn, the API will be fixed to atleast some scheme.
Last year at their Professional Developer's Conference (PDC), Microsoft announced that Longhorn would include three technology pillars - "Avalon", "Indigo" and "WinFS".
For sometime they had been talking about releasing the "Indigo" set of API's as an add-on to the .NET framework.
There are pro's and con's to this...
blah blah ( :) )
What do you feel about the announcement? You think it's a major advantage for the Linux dudes?
I see the entire Longhorn issue in a different way. Its more of Win vs Win. What I mean to say is that considering all the MAJOR changes in the OS, will the industry accept. I rather think they'll take a wait and watch approach. Especially on the server-side. Btw is Longhorn going to be for the desktop or server? So adoption of a very new technology will be slightly slow. How fast did industry accept the Win NT platform? Is .NET being readily accepted? as a stable platform? I am asking questions here and not being cynical. Thats a reason why I believe an incremental update to the OS is a much better approach.
Will Linux gain in what I feel might be a sluggish initial period? I am not sure. Linux vs Windows will continue to be decided on different factors. Servers do not need the Longhorn features. Same for most co's running word processing apps. So who knows.
The same argument applies to the new Java 5.0 version. There are many new features so when will the industry adopt? We as dev's get excited with new tech. What is the status of Web Services? How many co's use them? (Again a question). I do not think Web Services have been adopted widely enough.
Whats Yukon and the other future stuff?? I read some article somwhere which basically confused all the relationship between the file-system, the database etc!! Whats supposed to do what? And like Mohn (assuming Mohn and I are not the only ones reading codeword anymore!!) mentioned the base FS is something else. So any idea about all the layers?
Other points Mohn raised was the size of the .NET framework and version problems.
The Java runtime Environment is 10Mb+ and the SDK is 30Mb+. Both platforms are mini-OS'es in a way. After Longhorn, .NET might become super huge!! Un-Downloadable !! Java also has so many extensions now (javax) which are pretty huge in size. So thats going to be a bigger problem for Java as MS will bundle .NET in the OS.
On incompatibility between versions there are differences again. In Java, all versions are backward compatible. Even though a section maybe deprecated (say 1.1), even the never versions have to support it. In other words what is marked as deprecated is never removed. This was one promise by SUN to their customers, that Java will always be backward compatible. This is not what the dev's like too much. Obviously this bloats the API and its not "clean" anymore. Having said hat the .NET scene seems more worse? What versioning system is followed in .NET? Any minor/major system? I always get the feeling that .NET is in a sort of a test phase. Maybe after Longhorn, the API will be fixed to atleast some scheme.
A9 ??
A9 from Amazon is a new search engine.
They have a pretty neat interface and cool options. Similar to the gmail site in a way. Are these the next generation of web-sites? They seem like semi - Rich Internet Applications. (D'yu know what I mean!). You guys seen any similar stuff? With higher bandwidth becoming more common, RIA and better UI's seem to be the way to go. Just like 3-D desktops. Or will they just be more eye-candy??
Also in the A9 FAQ, it is mentioned that they internally use the google service for searching web pages. So how does A9 become a competitor to google? And wouldn't A9 have had to make an agreement with google to use them as a backend(sort of)!!.
P.s: The coolest thing i noticed so far is the site-info after performing a search. And EconomicTimes,IndiaTimes comes in a whopping 12+ seconds. Try finding something slower!!
They have a pretty neat interface and cool options. Similar to the gmail site in a way. Are these the next generation of web-sites? They seem like semi - Rich Internet Applications. (D'yu know what I mean!). You guys seen any similar stuff? With higher bandwidth becoming more common, RIA and better UI's seem to be the way to go. Just like 3-D desktops. Or will they just be more eye-candy??
Also in the A9 FAQ, it is mentioned that they internally use the google service for searching web pages. So how does A9 become a competitor to google? And wouldn't A9 have had to make an agreement with google to use them as a backend(sort of)!!.
P.s: The coolest thing i noticed so far is the site-info after performing a search. And EconomicTimes,IndiaTimes comes in a whopping 12+ seconds. Try finding something slower!!
Tuesday, September 14, 2004
Quake II .net
mms://wm.microsoft.com/ms/msnse/0408/23360/Scott_currie/Quake_Demo_56K_110K_300K.wmv
Video is a MS dev showing Quake II running under .NET
This is a pretty old story... I think summer of last year (told Rahul about this when I was in India). The guys who made Quake, ported their C code to C++ and then compiled it under the .NET CLR. They then added new functionality using managed code. The entire process is quite nicely detailed in this whitepaper, incase you're interested.
They were able to take legacy code and just compile it under .NET without making significant changes. OK, they had to first get it to C++. But after that it was just a recompile. The C++.NET compiler takes your native code and generates MSIL. This means that your app is a ".NET friendly" citizen. You can now come in and create new features using C# or VB.NET or whatever, getting all the benefits of managed code and using the .NET framework, and easily integrate it into this legacy app. Understand that the old code is NOT being GC'd. It still needs manual memory management. But it's able to play nice with managed components with little effort.
I still don't understand the exact process of what happens under the hood, but I think it's pretty damn amazing.
Video is a MS dev showing Quake II running under .NET
This is a pretty old story... I think summer of last year (told Rahul about this when I was in India). The guys who made Quake, ported their C code to C++ and then compiled it under the .NET CLR. They then added new functionality using managed code. The entire process is quite nicely detailed in this whitepaper, incase you're interested.
They were able to take legacy code and just compile it under .NET without making significant changes. OK, they had to first get it to C++. But after that it was just a recompile. The C++.NET compiler takes your native code and generates MSIL. This means that your app is a ".NET friendly" citizen. You can now come in and create new features using C# or VB.NET or whatever, getting all the benefits of managed code and using the .NET framework, and easily integrate it into this legacy app. Understand that the old code is NOT being GC'd. It still needs manual memory management. But it's able to play nice with managed components with little effort.
I still don't understand the exact process of what happens under the hood, but I think it's pretty damn amazing.
Monday, September 13, 2004
Re: Longhorn Features?
What do you think will be the implications of this. Ms guys are happy that there is a release date and non Ms guys are happy as they take it as a Ms defeat. Also is the Win API going to be completely ported to .NET in Longhorn?
Last year at their Professional Developer's Conference (PDC), Microsoft announced that Longhorn would include three technology "pillars" - a new presentation system, "Avalon", a new communications framework (I think it has to do with making web services super easy), "Indigo" and a new file system, "WinFS". And all these would be made accessible through a superset of the .NET framework, "WinFX". Essentially WinFX would replace the current Win32 API and further improve the current .NET framework to include (more or less) the entire Windows API as managed code.
This seemed quite ambitious. It would be the most complex OS ever created. I think they went a bit overboard with their goals, but it's fine - you need to aim high. But the problem for them was that they couldn't give an exact release date. People kept speculating 2006, then 2007 and some even said 2008! If you take the best case of 06, that would still be 5 years since the release of XP... worst case would be 7 years. They would be pulling the trigger on themselves if such a scenario ever came. That's just an insane amount of time between OS releases.
For sometime they had been talking about releasing the "Indigo" set of API's as an add-on to the .NET framework, which would work on previous OS's like Server 03 and XP. Now they have said that even some part of the presentation system, "Avalon", will be made available for downlevel OS's. They didn't give a specific date for all this to be available, but I guess the general timeline will be 06. They also said WinFS won't be released with Longhorn (which is also to be released around 06-07), but will be available as an add-on later on.
There are pro's and con's to this...
One pro is that there are millions of XP systems out there. Having these new capabilities on this installed base will be beneficial to developers. I'm assuming they will release an interim .NET version which will include these technologies and that can be easily deployed/downloaded just as today's Java or .NET frameworks. In this sense, I don't see any benefit to non-MS guys. If anything, it hurts them, since they were hoping that they would get a fresh start when Longhorn comes out - Longhorn install base will start with 0. Now that won't exactly be the case.
The one main con I see (I'm sure there are many others) is that there won't be a common base platform. Devs will need to keep checking to see if this version of Windows has Indigo or Avalon, what version they are running. If they don't have it, to download it or distribute it with their own apps. This is the same problem with .NET today. Not everyone has the framework today. And version 1.1 is 23 mb. Adding Indigo and Avalon will drastically increase that size.
Many people are also saying that if these are going to be available in XP, why would one upgrade to Longhorn when it comes out. They have a point. But I feel that Longhorn capabilities will be superior to what will be released for XP. They talked about three tiers for the presentation systems... based on graphical capabilities. I guess for Longhorn they can just default to the most advanced as it will be released with new machines, which at that time will include the latest graphics cards.
Finally, a lot of them are saying since WinFS won't be released with Longhorn that all the new search capabilities won't be available in Longhorn. I think that WinFS itself is not the file system. It's something that sits on top of the file system (like NTFS) and enables relational database like capabilities which interacts with the underlying file system. I feel they will improve the underlying file system itself for Longhorn which will enable better searching. WinFS will come later to better interact with it.
Having said that, I think it's a bad idea for MS to release Longhorn without WinFS. This is one of the main things people have been waiting for. And it's not going to be released for previous OS's. This is what will differentiate the Longhorn release. MS has been talking about this "unified file system" for a long time and it's dumb for them to delay it further. It should be in Longhorn even if it pushes back the release date.
What do you feel about the announcement? You think it's a major advantage for the Linux dudes?
Last year at their Professional Developer's Conference (PDC), Microsoft announced that Longhorn would include three technology "pillars" - a new presentation system, "Avalon", a new communications framework (I think it has to do with making web services super easy), "Indigo" and a new file system, "WinFS". And all these would be made accessible through a superset of the .NET framework, "WinFX". Essentially WinFX would replace the current Win32 API and further improve the current .NET framework to include (more or less) the entire Windows API as managed code.
This seemed quite ambitious. It would be the most complex OS ever created. I think they went a bit overboard with their goals, but it's fine - you need to aim high. But the problem for them was that they couldn't give an exact release date. People kept speculating 2006, then 2007 and some even said 2008! If you take the best case of 06, that would still be 5 years since the release of XP... worst case would be 7 years. They would be pulling the trigger on themselves if such a scenario ever came. That's just an insane amount of time between OS releases.
For sometime they had been talking about releasing the "Indigo" set of API's as an add-on to the .NET framework, which would work on previous OS's like Server 03 and XP. Now they have said that even some part of the presentation system, "Avalon", will be made available for downlevel OS's. They didn't give a specific date for all this to be available, but I guess the general timeline will be 06. They also said WinFS won't be released with Longhorn (which is also to be released around 06-07), but will be available as an add-on later on.
There are pro's and con's to this...
One pro is that there are millions of XP systems out there. Having these new capabilities on this installed base will be beneficial to developers. I'm assuming they will release an interim .NET version which will include these technologies and that can be easily deployed/downloaded just as today's Java or .NET frameworks. In this sense, I don't see any benefit to non-MS guys. If anything, it hurts them, since they were hoping that they would get a fresh start when Longhorn comes out - Longhorn install base will start with 0. Now that won't exactly be the case.
The one main con I see (I'm sure there are many others) is that there won't be a common base platform. Devs will need to keep checking to see if this version of Windows has Indigo or Avalon, what version they are running. If they don't have it, to download it or distribute it with their own apps. This is the same problem with .NET today. Not everyone has the framework today. And version 1.1 is 23 mb. Adding Indigo and Avalon will drastically increase that size.
Many people are also saying that if these are going to be available in XP, why would one upgrade to Longhorn when it comes out. They have a point. But I feel that Longhorn capabilities will be superior to what will be released for XP. They talked about three tiers for the presentation systems... based on graphical capabilities. I guess for Longhorn they can just default to the most advanced as it will be released with new machines, which at that time will include the latest graphics cards.
Finally, a lot of them are saying since WinFS won't be released with Longhorn that all the new search capabilities won't be available in Longhorn. I think that WinFS itself is not the file system. It's something that sits on top of the file system (like NTFS) and enables relational database like capabilities which interacts with the underlying file system. I feel they will improve the underlying file system itself for Longhorn which will enable better searching. WinFS will come later to better interact with it.
Having said that, I think it's a bad idea for MS to release Longhorn without WinFS. This is one of the main things people have been waiting for. And it's not going to be released for previous OS's. This is what will differentiate the Longhorn release. MS has been talking about this "unified file system" for a long time and it's dumb for them to delay it further. It should be in Longhorn even if it pushes back the release date.
What do you feel about the announcement? You think it's a major advantage for the Linux dudes?
Saturday, September 11, 2004
Longhorn Features?
Recently Microsoft announced that Longhorn will have a reduced set of features. The highly publicized WinFs feature will be scraped for the early version.
What do you think will be the implications of this. Ms guys are happy that there is a release date and non Ms guys are happy as they take it as a Ms defeat. Also is the Win API going to be completely ported to .NET in Longhorn?
P.s: I am fully aware that I am too small an entity to comment on such a huge topic, but hey that's why we have blogspot!!
What do you think will be the implications of this. Ms guys are happy that there is a release date and non Ms guys are happy as they take it as a Ms defeat. Also is the Win API going to be completely ported to .NET in Longhorn?
P.s: I am fully aware that I am too small an entity to comment on such a huge topic, but hey that's why we have blogspot!!
Friday, September 03, 2004
Re: Java's pass "by reference" demystified
An interesting thing to note is that in Java there is no way to create a "swap" method for primitives. A swap method is where you send in two arguments and have their values interchanged. Now, there are wrapper objects for all primitives - like Integer, Doublt etc... It's possible with that. With plain primitives, it's impossible.
Of course, I got to throw in how C# differs. There is a "ref" keyword which does pass by (true) reference as in C++. So you can infact create a swap in C#...
private void swap( ref int x, ref int y )
{
int temp = x;
x = y;
y = temp;
}
Btw, I'm also doing a course on OOP using Java. We got some introductory material on Java fundamentals.
http://www.cs.utexas.edu/users/rockhold/cs371p/handouts/Java-1.pdf
http://www.cs.utexas.edu/users/rockhold/cs371p/handouts/Java-2.pdf
http://www.cs.utexas.edu/users/rockhold/cs371p/handouts/Java-3.pdf
Of course, I got to throw in how C# differs. There is a "ref" keyword which does pass by (true) reference as in C++. So you can infact create a swap in C#...
private void swap( ref int x, ref int y )
{
int temp = x;
x = y;
y = temp;
}
Btw, I'm also doing a course on OOP using Java. We got some introductory material on Java fundamentals.
http://www.cs.utexas.edu/users/rockhold/cs371p/handouts/Java-1.pdf
http://www.cs.utexas.edu/users/rockhold/cs371p/handouts/Java-2.pdf
http://www.cs.utexas.edu/users/rockhold/cs371p/handouts/Java-3.pdf
Java's pass "by reference" demystified (by Rahul)
So finally posting a blog after ages. The course in NCST has been great and I have learnt a lot. Clearing my fundamentals. Or really learning programming for the first time to put it correctly. The first module has been in Java programming and I read a few parts of "The Java Programming Language" by Ken Arnold and James Gosling.
Got an intersting part on passing parameters via methods. Personally I always thought that primitives were passed by value and instances by reference. But the second part is wrong. I'll simply write an excerpt from the book in full knowledge of the copyright violation!!
"..
You should note that when the parameter is an object reference, the object reference - not the objectreference - not the object itself - is what is passed "by value". Thus, you can change which object a parameter refers to inside the method without affecting the reference that was passed. But if you change any fields of the object or invoke methods that change the object's state, the object is changed for every part of the program that holds a reference to it. Here is an example to show this distinction:
class PassRef {
public static void main(String[] args){
Body sirius = new Body("Sirius",null);
System.out.println("before:" + sirius);
commonName(sirius);
System.out.println("after: " + sirius);
}
public static void commonName(Body bodyRef){
bodyRef.name = "Dog Star";
bodyRef = null;
}
}
This program produces the following output:
before: 0 (Sirius)
after: 0 (Dog Star)
Notice that the contents of the object have been modified with a name change, while the reference bodyRef still refers to the Body object even though the method commonName changed the value of its bodyRef parameter to null.
.."
"..
Some people will say incorrectly that objects in Java are "pass by refernce". The term pass by reference properly means that when an argument is passed to a function, the invoked function gets a refernce to the original value, not a copy of its value. If the function modifies its parameter, the value in the calling code will be changed because the argument and parameter use the same slot in memory. If Java had pass-by-reference parameters, there would be a way to declare halveIt so that the preceding code would modify the value of one, or so that commonName could change the variable sirius to null. This is not possible. Java does not pass objects by reference; it passes object refernces by value. Because two copies of the same reference refer to the same actual object, changes made through one reference are visible through the other. There is exactly one parameter passing mode in Java - pass by value - and that keeps things simple.
.."
Did you guys know this?? Any more tips/hacks?
Got an intersting part on passing parameters via methods. Personally I always thought that primitives were passed by value and instances by reference. But the second part is wrong. I'll simply write an excerpt from the book in full knowledge of the copyright violation!!
"..
You should note that when the parameter is an object reference, the object reference - not the object
class PassRef {
public static void main(String[] args){
Body sirius = new Body("Sirius",null);
System.out.println("before:" + sirius);
commonName(sirius);
System.out.println("after: " + sirius);
}
public static void commonName(Body bodyRef){
bodyRef.name = "Dog Star";
bodyRef = null;
}
}
This program produces the following output:
before: 0 (Sirius)
after: 0 (Dog Star)
Notice that the contents of the object have been modified with a name change, while the reference bodyRef still refers to the Body object even though the method commonName changed the value of its bodyRef parameter to null.
.."
"..
Some people will say incorrectly that objects in Java are "pass by refernce". The term pass by reference properly means that when an argument is passed to a function, the invoked function gets a refernce to the original value, not a copy of its value. If the function modifies its parameter, the value in the calling code will be changed because the argument and parameter use the same slot in memory. If Java had pass-by-reference parameters, there would be a way to declare halveIt so that the preceding code would modify the value of one, or so that commonName could change the variable sirius to null. This is not possible. Java does not pass objects by reference; it passes object refernces by value. Because two copies of the same reference refer to the same actual object, changes made through one reference are visible through the other. There is exactly one parameter passing mode in Java - pass by value - and that keeps things simple.
.."
Did you guys know this?? Any more tips/hacks?
Tuesday, August 24, 2004
Exceptions - another implementation difference
Good article on IBM developerworks regarding exceptions.
Another difference in implementation between Java and C#. Java has the checked vs unchecked exceptions. C# just has unchecked. The article does a good job of explaining the thinking behind each implementation.
The problem with checked exceptions is that you need to specify which exceptions you will catch in the method signature. It's a problem because since it's part of the interface, it is essentially set in stone. If ever you refactor the code in the method and those resulting new methods throw new exceptions, you will need to modify the method signature with the added exceptions, thus breaking compatibility. As you go higher up in the code hierarchy you need to make sure that your methods keep adding exceptions that could be thrown in the lower code.
The problem with the C# way is that since there is no information about what exceptions are thrown, you dunno what to catch. You have to rely on the documentation. It's not baked into the system.
There are pro's and con's to each way as is mentioned in the article. I personally don't have a clear opinion on which is better. One thing I read that made sense was that exceptions are supposed to be exceptional. If one is thrown, something is out of the norm. It shouldn't be silently ignored which might be the temptation with Java since you have to keep track at every level.
Overall, I feel there needs to be better literature out there regarding how exactly to handle exceptions in an application. Atleast, I haven't come across too many good articles. As we had discussed before, it doesn't seem right when there are a whole bunch of try catch blocks in your code. It's not the right way.
Another difference in implementation between Java and C#. Java has the checked vs unchecked exceptions. C# just has unchecked. The article does a good job of explaining the thinking behind each implementation.
The problem with checked exceptions is that you need to specify which exceptions you will catch in the method signature. It's a problem because since it's part of the interface, it is essentially set in stone. If ever you refactor the code in the method and those resulting new methods throw new exceptions, you will need to modify the method signature with the added exceptions, thus breaking compatibility. As you go higher up in the code hierarchy you need to make sure that your methods keep adding exceptions that could be thrown in the lower code.
The problem with the C# way is that since there is no information about what exceptions are thrown, you dunno what to catch. You have to rely on the documentation. It's not baked into the system.
There are pro's and con's to each way as is mentioned in the article. I personally don't have a clear opinion on which is better. One thing I read that made sense was that exceptions are supposed to be exceptional. If one is thrown, something is out of the norm. It shouldn't be silently ignored which might be the temptation with Java since you have to keep track at every level.
Overall, I feel there needs to be better literature out there regarding how exactly to handle exceptions in an application. Atleast, I haven't come across too many good articles. As we had discussed before, it doesn't seem right when there are a whole bunch of try catch blocks in your code. It's not the right way.
Tuesday, August 03, 2004
Missed google name opportunities
Saw this on a blog...
Google got it right with Froogle (the site for searching for the least expensive products), but missed the opportunity with news, creating news.google.com instead of noogle. Here is my list of proposed names for sites Google could run:
Google: the general search site
Froogle: for searching for the lowest cost on items
Whoogle: for searching for people
Noogle: for searching news
Screwgle: for searching porn
Boogle: for searching for scary things
Toolgle: for searching for tools
Poogle: for finding the closest bathroom
Loogle: for searching legal (or finding the closest bathroom in England)
Roogle: for finding small kangaroos
Moogle: for searching money (or finding lost cows)
Vousgle: the French site for finding everything about you
Zoogle: search the local animal park
Google got it right with Froogle (the site for searching for the least expensive products), but missed the opportunity with news, creating news.google.com instead of noogle. Here is my list of proposed names for sites Google could run:
Google: the general search site
Froogle: for searching for the lowest cost on items
Whoogle: for searching for people
Noogle: for searching news
Screwgle: for searching porn
Boogle: for searching for scary things
Toolgle: for searching for tools
Poogle: for finding the closest bathroom
Loogle: for searching legal (or finding the closest bathroom in England)
Roogle: for finding small kangaroos
Moogle: for searching money (or finding lost cows)
Vousgle: the French site for finding everything about you
Zoogle: search the local animal park
Sun buys Novell
Quite a few news items have been posted recently on Sun planning to buy Novell like at eweek.
Most say Jonathan Schwartz feels it will hurt IBM for some reason. Firstly I am not sure how much Sun can hurt IBM.
Another relationship struck me.
Novell has Ximian which has Mono... hmm very interesting.
But again Mono has been released under the GPL and LGPL liscences as mentioned here. At least the GPL part can be forked.
So don't be suprised if you hear "Microsoft buys Sun"
Probably one of my worst jokes and its online now!!
Most say Jonathan Schwartz feels it will hurt IBM for some reason. Firstly I am not sure how much Sun can hurt IBM.
Another relationship struck me.
Novell has Ximian which has Mono... hmm very interesting.
But again Mono has been released under the GPL and LGPL liscences as mentioned here. At least the GPL part can be forked.
So don't be suprised if you hear "Microsoft buys Sun"
Probably one of my worst jokes and its online now!!
Saturday, July 31, 2004
Re: Inventory Editor
Here is what I bleieve to be the final version of my Inventory Editor.
This version is a lot more robust and will recover from a lot of painful mistakes made by the user. Made a few bug fixes too.
Dinesh.
This version is a lot more robust and will recover from a lot of painful mistakes made by the user. Made a few bug fixes too.
Dinesh.
Friday, July 30, 2004
Letter to American masses
I got this from http://fourthedition.blogspot.com/
A very sincere letter to the American masses:
"Dear Sir,
I am a senior citizen. During the Clinton Administration I had an extremely good and well paying job. I took numerous vacations and had several vacations homes.
Since President Bush took office, I have watched my entire life change for the worse: I lost my job. I lost my two sons in that terrible Iraqi War.
I lost my home.
I lost my health insurance.
As a matter of fact, I lost virtually everything and became homeless. Adding insult to injury, when the authorities found me living like an animal, instead of helping me, they arrested me.
I will do anything to insure President Bush's defeat in the next election.
I will do anything that Senator Kerry wants to insure that a Democrat is back in the White House come next year. Bush has to go.
I just thought you and your listeners would like to know how one senior citizen views the Bush Administration.
Thank you for taking the time to read my letter.
Sincerely,
Sadaam Hussein"
A very sincere letter to the American masses:
"Dear Sir,
I am a senior citizen. During the Clinton Administration I had an extremely good and well paying job. I took numerous vacations and had several vacations homes.
Since President Bush took office, I have watched my entire life change for the worse: I lost my job. I lost my two sons in that terrible Iraqi War.
I lost my home.
I lost my health insurance.
As a matter of fact, I lost virtually everything and became homeless. Adding insult to injury, when the authorities found me living like an animal, instead of helping me, they arrested me.
I will do anything to insure President Bush's defeat in the next election.
I will do anything that Senator Kerry wants to insure that a Democrat is back in the White House come next year. Bush has to go.
I just thought you and your listeners would like to know how one senior citizen views the Bush Administration.
Thank you for taking the time to read my letter.
Sincerely,
Sadaam Hussein"
Re: Inventory Editor
Pretty good app.
One suggest was why not club menu items 6, 7 and 8 together. It feels a bit redundant. You can have the normal table with the end like .
Total Shopping Cost is...
Total Packing Cost ...
Total Shopping Count ..
Though I might not use it as much coz shopping is not one of my major concerns. One worry is about all the tutorials and articles etc I have downloaded. Needed something like a super Bookmark app with a good way to categorize and search. Any ideas??
One suggest was why not club menu items 6, 7 and 8 together. It feels a bit redundant. You can have the normal table with the end like .
Total Shopping Cost is...
Total Packing Cost ...
Total Shopping Count ..
Though I might not use it as much coz shopping is not one of my major concerns. One worry is about all the tutorials and articles etc I have downloaded. Needed something like a super Bookmark app with a good way to categorize and search. Any ideas??
Inventory Editor
Having to move to bangalore soon got me planning and generally shopping and packing my stuff. I got irritated created stupid txt files of my inventory, so I coded a small program which turned out pretty neat ;)
The file can be found here Windows: Inventory Editor
It's not great or anything but I think it can be pretty handy. Try it out. Revo, obviously this will be of more use to you. Did one cool thing in it, I used a serialization library called Eternity by Nicola Santi :D It was good fun!!
The program supports Adding, Editing and Deleting Inventory Entries. It also supports printing the Inventory to a txt file in a nice format (view the txt file in maximized window mode). No Linux version, yet!
I'll post this on my blog too later and hence the disclaimer in the zip file. Check it out and tell me how it is. I've not found any obvious errors yet, but tell me if you find any. And the Format Specifiers for output are according to my window dimensions, so it may be distorted for you.
By the way, please enter ints where ints are expected and likewise for the other fields. I haven't done any protection against such things. I thought only I'd be using the program.
Dinesh.
The file can be found here Windows: Inventory Editor
It's not great or anything but I think it can be pretty handy. Try it out. Revo, obviously this will be of more use to you. Did one cool thing in it, I used a serialization library called Eternity by Nicola Santi :D It was good fun!!
The program supports Adding, Editing and Deleting Inventory Entries. It also supports printing the Inventory to a txt file in a nice format (view the txt file in maximized window mode). No Linux version, yet!
I'll post this on my blog too later and hence the disclaimer in the zip file. Check it out and tell me how it is. I've not found any obvious errors yet, but tell me if you find any. And the Format Specifiers for output are according to my window dimensions, so it may be distorted for you.
By the way, please enter ints where ints are expected and likewise for the other fields. I haven't done any protection against such things. I thought only I'd be using the program.
Dinesh.
Saturday, July 24, 2004
Re: OOP's basics - Access
Revo, I'm not really sure what you are asking here. Are you asking how Access Control is implemented in C++ / Java? or what is Access Control?
I'll answer the second question here. Consider the following code :
If you are still unclear, keep posting.
Dinesh.
I'll answer the second question here. Consider the following code :
#include "iostream" //replace the double quotes by < >
using namespace std;
class base
{
public:
int bval;
base(){ bval=0;}
};
class deri : public base //Note : Here it is public
{
public:
int dval;
deri(){ dval=1;}
};
class deri2 : public deri
{
public:
int dval2;
deri2(){ dval2 = 2; }
};
int main()
{
deri d1;
deri2 d2;
/* The following code is Legal when "base" is public to "deri"
d1.bval = 9; //bval is accessible because base is now a public part of deri
d2.bval = 10; // same for deri2, cause deri is public to it, which in turn makes base public
*/
/* Now when "base" is protected to "deri", the above code in red is not possible because
of the semantics of the protected key-word, which can be found in any book.
But note here that members of "base" are accessible to "deri2"'s class definition,
It's just that the objects of deri2 can't directly access it. Again all this
just pertains to the semantics of "protected".
For eg: this is legal in this context
deri2() { bval = 2; dval2 = 3; }
*/
/* And when "base" is private to "deri", "deri2" has no access to "base"'s members,
"base" just cannot be seen by "deri2".
*/
system("pause");
return 0;
}
So basically, you can say that Access Control pertains mostly to how the various classes work in Heirarchy of classes. If it's just one base and one derived class, then access control is not of much importance, because as you can see there is no difference then between "private" and "protected", only difference which can be found is between "public" and the other two.
If you are still unclear, keep posting.
Dinesh.
Thursday, July 22, 2004
OOP's basics - Access
Hrishi asked me a basic question on OOP's which I could not answer. How is access to members controlled wrt access of Classes.
I found Controlling Access to Members of a Class.
Is there a thing such as private class Gamma ? Is it the same as class Gamma ? And how does access to members change wrt to the class access ?
I found Controlling Access to Members of a Class.
Is there a thing such as private class Gamma ? Is it the same as class Gamma ? And how does access to members change wrt to the class access ?
Thursday, July 15, 2004
Mono: More than an open source curiosity
http://news.com.com/More+than+an+open-source+curiosity/2008-7344_3-5271084.html?tag=nefd.lede
Mono has the potential to be more successful on the Linux desktop than Java. Most .NET developers are familiar with writing Windows apps. Taking that knowledge over to Linux will be quite easy now with Mono. The UI classes doesn't map one to one (with Mono using GTK#), but the model is close enough to be able to carry over.
Here's an intro to using Mono: http://arstechnica.com/etc/linux/index.html
Mono has the potential to be more successful on the Linux desktop than Java. Most .NET developers are familiar with writing Windows apps. Taking that knowledge over to Linux will be quite easy now with Mono. The UI classes doesn't map one to one (with Mono using GTK#), but the model is close enough to be able to carry over.
Here's an intro to using Mono: http://arstechnica.com/etc/linux/index.html
Re: Java Issues & Directions
So what is MXML? Some eg? How different is XAML? What will be the features?
Well, MXML is what Macromedia is using for Flex. There was a slide in Eckel's presentation that showed some code. That was what I said looked quite similar to ASP.NET code. XAML is going to be for desktop based apps. MXML, like ASP .NET, is for web apps. An interesting idea is if you want to provide an "enhanced" experience for Longhorn, when you visit a website, instead of sending back HTML code, it will send back XAML code. So instead of viewing a UI within the browser, you now get a full fleged Windows app. It would be great if there is some sort of standard that can be implemented on all platforms.
There are a lot of competing technologies in the Java Community. In a way I feel this is very healthy. Ease of development I feel is a different issue. Java is not as close to the stuff like what i think MXML might be. Though tools are improving very rapidly and also the lang after Java 1.5. Btw this is how the latest SWT looks like. It doesn't look native but would you use it?
Definitely agree that the competing technologies make it healthy. Just wondering if there are any efforts in the Java world to come up with something like XAML. As in, declarative UI. This would straightaway make it really easy to build UI's.
The Eclipse app looks great. What languages does it support?
This article should explain most of the stuff. One part I noticed is that there is no EJB equivalent. Isn't ADO for database connectivity? What is COM+ ? Is it a part of .NET?
The article helped clear up some stuff. But I still couldn't figure out what exactly EJB does.
Yeah, ADO .NET is for database connectiviy... equivalant to JDBC. COM+ is stuff like Message Queueing, Transaction management etc... It was available starting with Window 2000. .NET just provides a managed layer on top of it. For ex, there is a Transaction attribute you can apply to methods, which presumably uses COM+. These are called Enterprise Services in .NET. I dunno much about this stuff. I don't really understand what it means to be an "enterprise" app.
Ya.. The video was very helpful. One part i did not understand was about was the advanced generics stuff, Factory etc.
I didn't understand the Factory stuff either. It felt like he was trying to get around the limitations of Generics. Just confused me more.
Firstly I have to say that I appreciate what Eckel had to say about Java. Those were facts and can't deny anything. Everything he said about Generics, Erasure, ease of use I could take. But Cooncurrency did really hurt. .NET has helped Java as well. I hope that things get better and fast.
I thought it was a good video. I felt it was not biased at all. Some dudes when giving talks are so biased it sickens me. He just gave a critical view of what he thought could be better in the platform.
Well, MXML is what Macromedia is using for Flex. There was a slide in Eckel's presentation that showed some code. That was what I said looked quite similar to ASP.NET code. XAML is going to be for desktop based apps. MXML, like ASP .NET, is for web apps. An interesting idea is if you want to provide an "enhanced" experience for Longhorn, when you visit a website, instead of sending back HTML code, it will send back XAML code. So instead of viewing a UI within the browser, you now get a full fleged Windows app. It would be great if there is some sort of standard that can be implemented on all platforms.
There are a lot of competing technologies in the Java Community. In a way I feel this is very healthy. Ease of development I feel is a different issue. Java is not as close to the stuff like what i think MXML might be. Though tools are improving very rapidly and also the lang after Java 1.5. Btw this is how the latest SWT looks like. It doesn't look native but would you use it?
Definitely agree that the competing technologies make it healthy. Just wondering if there are any efforts in the Java world to come up with something like XAML. As in, declarative UI. This would straightaway make it really easy to build UI's.
The Eclipse app looks great. What languages does it support?
This article should explain most of the stuff. One part I noticed is that there is no EJB equivalent. Isn't ADO for database connectivity? What is COM+ ? Is it a part of .NET?
The article helped clear up some stuff. But I still couldn't figure out what exactly EJB does.
Yeah, ADO .NET is for database connectiviy... equivalant to JDBC. COM+ is stuff like Message Queueing, Transaction management etc... It was available starting with Window 2000. .NET just provides a managed layer on top of it. For ex, there is a Transaction attribute you can apply to methods, which presumably uses COM+. These are called Enterprise Services in .NET. I dunno much about this stuff. I don't really understand what it means to be an "enterprise" app.
Ya.. The video was very helpful. One part i did not understand was about was the advanced generics stuff, Factory etc.
I didn't understand the Factory stuff either. It felt like he was trying to get around the limitations of Generics. Just confused me more.
Firstly I have to say that I appreciate what Eckel had to say about Java. Those were facts and can't deny anything. Everything he said about Generics, Erasure, ease of use I could take. But Cooncurrency did really hurt. .NET has helped Java as well. I hope that things get better and fast.
I thought it was a good video. I felt it was not biased at all. Some dudes when giving talks are so biased it sickens me. He just gave a critical view of what he thought could be better in the platform.
Wednesday, July 14, 2004
Re: Java Issues & Directions
He mentioned Macromedia Flex on one slide and showed some code. I was surprised at how similar the MXML code looked to ASP .NET.I somehow feel like Flex is not going to be mainstream for web applications. It's very rare to see a web app use Flash/Shockwave for its front-end.
So what is MXML? Some eg? How different is XAML? What will be the features?
I agree that as of now we are used to HTML etc. But everyone knows that they are very limited. Personally i feel that Flash is the best alternative out there. Especially for Java as it is cross-platform. There are a lot of examples of Flash overuse, but what I saw in the stream was just amazing. Plus it can very easily put an end to all AWT vs SWT vs Swing. The only reason why Flex will not take off coz Macromedia controls it. If it will be opened further, it could become very widely used.
He said some stuff about Java's lack of acceptance on the client. AWT vs SWT vs Swing. Goes back to the easyness thing I mentioned in a previous post. There should be one standard that makes it easy for devs right out of the box
There are a lot of competing technologies in the Java Community. In a way I feel this is very healthy. Ease of development I feel is a different issue. Java is not as close to the stuff like what i think MXML might be. Though tools are improving very rapidly and also the lang after Java 1.5. Btw this is how the latest SWT looks like. It doesn't look native but would you use it?
could you explain the entire array of Java technologies that are out there. J2EE, J2SE, J2ME and how they differ from Java 1.1, Java 1.2 ... Java 1.5. Now they have Java 5.0 right? Also, what about JSP, EJB's and servelets and how are they connected to the versioning?
This article should explain most of the stuff. One part I noticed is that there is no EJB equivalent. Isn't ADO for database connectivity? What is COM+ ? Is it a part of .NET? EJB is one huge API which a lot of dev's feel is bloated and un-necessary. There are alternatives to that too, though I am not aware how they work. I wanted to know how .NET works in that layer. This might be a major advantage of .NET. Also do .NET dev's feel some std stuff needs to be changed? Any voices of dissent?
When Java 1.x is mentioned it means J2SE 1.x. Java 1.5 is now called Java 5.0 because of the major enhacements in the lang. Remember Java 1.2 was called Java 2. JSP, EJB etc are all part of J2EE. Each component has a separate versioning system and J2EE as a whole also has it's own versions. May sound a bit confusing at first. When there are major revisions to the individual componets, a new J2EE version is declared.
Rahul - Couple of slides on Metadata/Attributes - Might explain better than just reading about it.
Ya.. The video was very helpful. One part i did not understand was about was the advanced generics stuff, Factory etc. So need to lift my lazy ass and start learning soon.
During his Concurency talk, he mentioned a bug that has been in Java since the first version in "volatile".
Firstly I have to say that I appreciate what Eckel had to say about Java. Those were facts and can't deny anything. Everything he said about Generics, Erasure, ease of use I could take. But Cooncurrency did really hurt. .NET has helped Java as well. I hope that things get better and fast.
So what is MXML? Some eg? How different is XAML? What will be the features?
I agree that as of now we are used to HTML etc. But everyone knows that they are very limited. Personally i feel that Flash is the best alternative out there. Especially for Java as it is cross-platform. There are a lot of examples of Flash overuse, but what I saw in the stream was just amazing. Plus it can very easily put an end to all AWT vs SWT vs Swing. The only reason why Flex will not take off coz Macromedia controls it. If it will be opened further, it could become very widely used.
He said some stuff about Java's lack of acceptance on the client. AWT vs SWT vs Swing. Goes back to the easyness thing I mentioned in a previous post. There should be one standard that makes it easy for devs right out of the box
There are a lot of competing technologies in the Java Community. In a way I feel this is very healthy. Ease of development I feel is a different issue. Java is not as close to the stuff like what i think MXML might be. Though tools are improving very rapidly and also the lang after Java 1.5. Btw this is how the latest SWT looks like. It doesn't look native but would you use it?
could you explain the entire array of Java technologies that are out there. J2EE, J2SE, J2ME and how they differ from Java 1.1, Java 1.2 ... Java 1.5. Now they have Java 5.0 right? Also, what about JSP, EJB's and servelets and how are they connected to the versioning?
This article should explain most of the stuff. One part I noticed is that there is no EJB equivalent. Isn't ADO for database connectivity? What is COM+ ? Is it a part of .NET? EJB is one huge API which a lot of dev's feel is bloated and un-necessary. There are alternatives to that too, though I am not aware how they work. I wanted to know how .NET works in that layer. This might be a major advantage of .NET. Also do .NET dev's feel some std stuff needs to be changed? Any voices of dissent?
When Java 1.x is mentioned it means J2SE 1.x. Java 1.5 is now called Java 5.0 because of the major enhacements in the lang. Remember Java 1.2 was called Java 2. JSP, EJB etc are all part of J2EE. Each component has a separate versioning system and J2EE as a whole also has it's own versions. May sound a bit confusing at first. When there are major revisions to the individual componets, a new J2EE version is declared.
Rahul - Couple of slides on Metadata/Attributes - Might explain better than just reading about it.
Ya.. The video was very helpful. One part i did not understand was about was the advanced generics stuff, Factory etc. So need to lift my lazy ass and start learning soon.
During his Concurency talk, he mentioned a bug that has been in Java since the first version in "volatile".
Firstly I have to say that I appreciate what Eckel had to say about Java. Those were facts and can't deny anything. Everything he said about Generics, Erasure, ease of use I could take. But Cooncurrency did really hurt. .NET has helped Java as well. I hope that things get better and fast.
Monday, July 12, 2004
Re: Unified Type System
Sunday, July 11, 2004
Java Issues & Directions
Couple weeks ago our good friend Bruce Eckel gave a talk (real) regarding Java 1.5 at UC Berkley. It's quite long - about 2 hours 15 mins - but it's well worthwhile. Highly recommend it. He begins with a wide range of issues regarding what's wrong with Java and then goes on to new features in 1.5.
Some thoughts on the talk...
He mentioned Macromedia Flex on one slide and showed some code. I was surprised at how similar the MXML code looked to ASP .NET. He also compared it to what XAML is going to accomplish on Longhorn. I somehow feel like Flex is not going to be mainstream for web applications. It's very rare to see a web app use Flash/Shockwave for its front-end. As limiting as HTML, CSS and Javascript are, they will rule for a long time. Don't see anything displacing it anytime soon. We're just too used to it.
He said some stuff about Java's lack of acceptance on the client. AWT vs SWT vs Swing with different companies (ie. IBM vs Sun) supporting different API's. Goes back to the easyness thing I mentioned in a previous post. There should be one standard that makes it easy for devs right out of the box.
Rahul - could you explain the entire array of Java technologies that are out there. J2EE, J2SE, J2ME and how they differ from Java 1.1, Java 1.2 ... Java 1.5. Now they have Java 5.0 right? Also, what about JSP, EJB's and servelets and how are they connected to the versioning?
The Generics section was particularly interesting. He mentions some gripes about "Erasure" which is where Java looses the type information when compiling generic classes vs C++/C# retaining it. C#, although differening in the actual implementation of generics, is similar with Java in having constraints when declaring generic classes/methods.
Rahul - Couple of slides on Metadata/Attributes - Might explain better than just reading about it.
During his Concurency talk, he mentioned a bug that has been in Java since the first version in "volatile". I think that's a keyword. Anyway, when using these sorts of frameworks dyou trust it completely to be solid? I feel like those guys who wrote it are gods and know 2^20 times more that I do. I mean I could never for a sec imagine that if there is a bug I'm struggling with that the problem might actually be in the library.
Dinesh - He talked about the benefits of garbage collection and that the C++ committee might be tempted to include one in the next iteration of the C++ standard. Any news on this?
Some thoughts on the talk...
He mentioned Macromedia Flex on one slide and showed some code. I was surprised at how similar the MXML code looked to ASP .NET. He also compared it to what XAML is going to accomplish on Longhorn. I somehow feel like Flex is not going to be mainstream for web applications. It's very rare to see a web app use Flash/Shockwave for its front-end. As limiting as HTML, CSS and Javascript are, they will rule for a long time. Don't see anything displacing it anytime soon. We're just too used to it.
He said some stuff about Java's lack of acceptance on the client. AWT vs SWT vs Swing with different companies (ie. IBM vs Sun) supporting different API's. Goes back to the easyness thing I mentioned in a previous post. There should be one standard that makes it easy for devs right out of the box.
Rahul - could you explain the entire array of Java technologies that are out there. J2EE, J2SE, J2ME and how they differ from Java 1.1, Java 1.2 ... Java 1.5. Now they have Java 5.0 right? Also, what about JSP, EJB's and servelets and how are they connected to the versioning?
The Generics section was particularly interesting. He mentions some gripes about "Erasure" which is where Java looses the type information when compiling generic classes vs C++/C# retaining it. C#, although differening in the actual implementation of generics, is similar with Java in having constraints when declaring generic classes/methods.
Rahul - Couple of slides on Metadata/Attributes - Might explain better than just reading about it.
During his Concurency talk, he mentioned a bug that has been in Java since the first version in "volatile". I think that's a keyword. Anyway, when using these sorts of frameworks dyou trust it completely to be solid? I feel like those guys who wrote it are gods and know 2^20 times more that I do. I mean I could never for a sec imagine that if there is a bug I'm struggling with that the problem might actually be in the library.
Dinesh - He talked about the benefits of garbage collection and that the C++ committee might be tempted to include one in the next iteration of the C++ standard. Any news on this?
Re: Unified Type System
I was thinking of garbage collection myself and I do think a common base is required that keeps say two things, a count and a vector of pointers (or references) to the objects created, at the very minimum.
That very well could be one implementation. The pointers to objects created on the heap are on the stack. So, dyou think it would be economical for the garbage collector to also have pointers to those objects?
In .NET, when a collection is invoked, it walks through the roots (ie. global, static and stack pointers) recursively and creates a graph. This signifies all reachable objects. The non-reachable objects (ie. garbage) are marked. Those marked objects are deleted after the graph has been created. The others are compacted.
That mark phase... The Object base class could play a role. As I said last time, there could be some flag in Object thats set signifying that it's garbage and should be deleted. The other way could be that the collector creates a table of pointers to just the garbage objects to delete. In that case, we wouldn't need that base class with the flag.
The other reason why I feel having Object as the base class is not directly connected to garbage collection is cause MFC also has a root CObject class. I'm not very knowlegable about MFC, but if you want to "play well" with the framework and use your objects in the collections, you need to derive from CObject.
I guess Rahul might be on the right track regarding having those common methods in all objects. But I'm still not totally convinced.
Generics in C++ essentially auto-generate the classes based on type?
Yup. Templates - It's all done at compile-time. If the compiler comes across a declaration of the template with a type, it will auto-generate the class based on the type. And then that class is compiled. Dinesh can you confirm this?
What do you think happens in Java/.NET Generics? I suppose they 'fortified' the current Collections by forcing Type. This reduces Casting troubles at run-time and also provides better perf. So I think Generics are as dependent on Object.
As I understand it, in .NET, when the compiler comes across a declaration of a generic class with a value type (primitives, structs), it creates a new class definition. But it will only create one class definition for all reference types. This is because it holds references, which are the same regardless of what type it's pointing to.
So for example, if you have
ArrayList<int> intList = new ArrayList<int>();
ArrayList<double> doubleList = new ArrayList<double>();
ArrayList<string> stringList = ArrayList<string>();
ArrayList<MyClass> myClassList = ArrayList<MyClass>();
This code will create only three class definitions - One for int, one for double and one for references. The references definition will be used for both string and MyClass.
I believe Java will spit out four definitions.
You seem to have agreed with the importance of the other methods. toString( ), clone( ) and equals( ) are not the most important, but are pretty useful in many cases. Placing them in Object must have been thought over.
Actually, I just gave those methods as examples. I was talking about all of them. I realize they were thought over a lot. The guys who designed these systems are geniuses. I'm just trying to understand if that really was the reason for having a Unified Type System.
That very well could be one implementation. The pointers to objects created on the heap are on the stack. So, dyou think it would be economical for the garbage collector to also have pointers to those objects?
In .NET, when a collection is invoked, it walks through the roots (ie. global, static and stack pointers) recursively and creates a graph. This signifies all reachable objects. The non-reachable objects (ie. garbage) are marked. Those marked objects are deleted after the graph has been created. The others are compacted.
That mark phase... The Object base class could play a role. As I said last time, there could be some flag in Object thats set signifying that it's garbage and should be deleted. The other way could be that the collector creates a table of pointers to just the garbage objects to delete. In that case, we wouldn't need that base class with the flag.
The other reason why I feel having Object as the base class is not directly connected to garbage collection is cause MFC also has a root CObject class. I'm not very knowlegable about MFC, but if you want to "play well" with the framework and use your objects in the collections, you need to derive from CObject.
I guess Rahul might be on the right track regarding having those common methods in all objects. But I'm still not totally convinced.
Generics in C++ essentially auto-generate the classes based on type?
Yup. Templates - It's all done at compile-time. If the compiler comes across a declaration of the template with a type, it will auto-generate the class based on the type. And then that class is compiled. Dinesh can you confirm this?
What do you think happens in Java/.NET Generics? I suppose they 'fortified' the current Collections by forcing Type. This reduces Casting troubles at run-time and also provides better perf. So I think Generics are as dependent on Object.
As I understand it, in .NET, when the compiler comes across a declaration of a generic class with a value type (primitives, structs), it creates a new class definition. But it will only create one class definition for all reference types. This is because it holds references, which are the same regardless of what type it's pointing to.
So for example, if you have
ArrayList<int> intList = new ArrayList<int>();
ArrayList<double> doubleList = new ArrayList<double>();
ArrayList<string> stringList = ArrayList<string>();
ArrayList<MyClass> myClassList = ArrayList<MyClass>();
This code will create only three class definitions - One for int, one for double and one for references. The references definition will be used for both string and MyClass.
I believe Java will spit out four definitions.
You seem to have agreed with the importance of the other methods. toString( ), clone( ) and equals( ) are not the most important, but are pretty useful in many cases. Placing them in Object must have been thought over.
Actually, I just gave those methods as examples. I was talking about all of them. I realize they were thought over a lot. The guys who designed these systems are geniuses. I'm just trying to understand if that really was the reason for having a Unified Type System.
Saturday, July 10, 2004
Re: Unified Type System
I was saying because there is a hierarchy with Object being the root, the Collection classes can work with just Objects and not have to worry about other classes. Now, if they had introduced the framework with generics, you could have just done ArrayList, ArrayList, ArrayList and they would NOT need to inherit from Object. This is how it is in C++.
I'll repeat what I think you meant. Collections store pointers of type Object which can be later Cast into various Types. If this is what you meant, yipee for understanding and I see your point.
Generics in C++ essentially auto-generate the classes based on type?
What do you think happens in Java/.NET Generics? I suppose they 'fortified' the current Collections by forcing Type. This reduces Casting troubles at run-time and also provides better perf. So I think Generics are as dependent on Object.
I don't see this as an advantage
You seem to have agreed with the importance of the other methods. toString( ), clone( ) and equals( ) are not the most important, but are pretty useful in many cases. Placing them in Object must have been thought over.
I'll repeat what I think you meant. Collections store pointers of type Object which can be later Cast into various Types. If this is what you meant, yipee for understanding and I see your point.
Generics in C++ essentially auto-generate the classes based on type?
What do you think happens in Java/.NET Generics? I suppose they 'fortified' the current Collections by forcing Type. This reduces Casting troubles at run-time and also provides better perf. So I think Generics are as dependent on Object.
I don't see this as an advantage
You seem to have agreed with the importance of the other methods. toString( ), clone( ) and equals( ) are not the most important, but are pretty useful in many cases. Placing them in Object must have been thought over.
Friday, July 09, 2004
Re: Unified Type System
But, I'm skeptical since there are garbage collectors out there for C++ and we all know C++ doesn't have a Unified Type System. Even Java allows for different garbage collectors. So I wouldn't think that Object would play a role in it.
The reason I said that was sometime back I had gone through some simplistic garbage collection code and I remember distinctly that the objects had to be inherited from a common base IMMObject or something, which kept track of the various objects created. This is as far as my memory serves me, cause I think this was quite some time back!!
I was thinking of garbage collection myself and I do think a common base is required that keeps say two things, a count and a vector of pointers (or references) to the objects created, at the very minimum.
Or maybe it's just a whole "everything has to be OOP's" thing. So they created a single root hierarchy.
Dinesh.
The reason I said that was sometime back I had gone through some simplistic garbage collection code and I remember distinctly that the objects had to be inherited from a common base IMMObject or something, which kept track of the various objects created. This is as far as my memory serves me, cause I think this was quite some time back!!
I was thinking of garbage collection myself and I do think a common base is required that keeps say two things, a count and a vector of pointers (or references) to the objects created, at the very minimum.
Or maybe it's just a whole "everything has to be OOP's" thing. So they created a single root hierarchy.
Dinesh.
Re: Unified Type System
I was a bit confused about what you are trying to say? Do you mean simple Casting? How is C++ better at handling collections/generics w/o unified type system?
I was saying because there is a hierarchy with Object being the root, the Collection classes (just as an example) can work with just Objects and not have to worry about other classes. If they didn't have this hierarchy then you would need a StringArrayList, IntArrayList, MyClassArrayList etc... In other words, specializations for every possible class you would want to put into any collection. Now, if they had introduced the framework with generics, you could have just done ArrayList<String>, ArrayList<Int>, ArrayList<MyClass> and they would NOT need to inherit from Object. This is how it is in C++.
To notice the advantages of Object look at the class itself. Object guarantees that Thread support is provided out of the box with final classes like wait( ) notify( ). Other methods like clone( ) equals( ) getClass( ) and hashCode( ) provide features to be extended by child classes. getClass( ) is important for Reflections. hashCode( ) is important for generating hashcode indices for Collections like Map. Also finalize( ) serves as a Destructor.
I don't see this as an advantage. If your class never needs to be output to console (or whereever), you won't need the ToString() method. Similarly for Clone(), if you won't ever make a copy of yourself or Equals() if you will never be compared. C++ gives you the option. If you want to output to console (or whereever) you overload operator<<. Same for equals and clone... overload operator== and copy construtor. You are in control. There is no default overhead.
You even could argue why they didn't make CompareTo() a method in Object. Why did they choose to go for an interface Comparator (IComparator in .NET)? C++ has a similar way of doing it. Not with interfaces, but functors. If you want your object to be sorted, you create a functor, which performs the comparison, and pass it to an algorithm that sorts the collection.
I think I may have drifted quite a bit, but hey.. it is a pvt blog!! Now can any of you verify this?
Drift as much as you like... It's all good.
We discussed casting a while back. Check out the archives. It's pretty much exactly as you said it.
Do you know how it happens in C++?
I would think it's the same, except there is no Object at the top. In Java and .NET, it's ALWAYS there.
I thought this had to do in a Major way with garbage collection too
You might be right, but it would depend on implementation details. When a garbage collection is invoked, it creates a graph of all reachable objects from the roots in the application. It marks all those that are NOT reachable and destroys them. I guess this is called the mark and sweep collector. Maybe during the mark phase, an implementation would change a flag in the objects to say that it is garbage. If this were the case, then, yeah, Object would play a role.
But, I'm skeptical since there are garbage collectors out there for C++ and we all know C++ doesn't have a Unified Type System. Even Java allows for different garbage collectors. So I wouldn't think that Object would play a role in it.
Not sure though, a detailed answer by someone would be welcome.
I'm quite confused about this. I don't think any of us has hit the nail.
I was saying because there is a hierarchy with Object being the root, the Collection classes (just as an example) can work with just Objects and not have to worry about other classes. If they didn't have this hierarchy then you would need a StringArrayList, IntArrayList, MyClassArrayList etc... In other words, specializations for every possible class you would want to put into any collection. Now, if they had introduced the framework with generics, you could have just done ArrayList<String>, ArrayList<Int>, ArrayList<MyClass> and they would NOT need to inherit from Object. This is how it is in C++.
To notice the advantages of Object look at the class itself. Object guarantees that Thread support is provided out of the box with final classes like wait( ) notify( ). Other methods like clone( ) equals( ) getClass( ) and hashCode( ) provide features to be extended by child classes. getClass( ) is important for Reflections. hashCode( ) is important for generating hashcode indices for Collections like Map. Also finalize( ) serves as a Destructor.
I don't see this as an advantage. If your class never needs to be output to console (or whereever), you won't need the ToString() method. Similarly for Clone(), if you won't ever make a copy of yourself or Equals() if you will never be compared. C++ gives you the option. If you want to output to console (or whereever) you overload operator<<. Same for equals and clone... overload operator== and copy construtor. You are in control. There is no default overhead.
You even could argue why they didn't make CompareTo() a method in Object. Why did they choose to go for an interface Comparator (IComparator in .NET)? C++ has a similar way of doing it. Not with interfaces, but functors. If you want your object to be sorted, you create a functor, which performs the comparison, and pass it to an algorithm that sorts the collection.
I think I may have drifted quite a bit, but hey.. it is a pvt blog!! Now can any of you verify this?
Drift as much as you like... It's all good.
We discussed casting a while back. Check out the archives. It's pretty much exactly as you said it.
Do you know how it happens in C++?
I would think it's the same, except there is no Object at the top. In Java and .NET, it's ALWAYS there.
I thought this had to do in a Major way with garbage collection too
You might be right, but it would depend on implementation details. When a garbage collection is invoked, it creates a graph of all reachable objects from the roots in the application. It marks all those that are NOT reachable and destroys them. I guess this is called the mark and sweep collector. Maybe during the mark phase, an implementation would change a flag in the objects to say that it is garbage. If this were the case, then, yeah, Object would play a role.
But, I'm skeptical since there are garbage collectors out there for C++ and we all know C++ doesn't have a Unified Type System. Even Java allows for different garbage collectors. So I wouldn't think that Object would play a role in it.
Not sure though, a detailed answer by someone would be welcome.
I'm quite confused about this. I don't think any of us has hit the nail.
Thursday, July 08, 2004
Re: Unified Type System
My immediate thoughts turned to collections... 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 was a bit confused about what you are trying to say? Do you mean simple Casting? How is C++ better at handling collections/generics w/o unified type system?
Personally I do not think that Collections were a reason for Object. Object was an initial design consideration, but Collections came in at a later stage. Casting though is a very important factor.
To notice the advantages of Object look at the class itself. Object guarantees that Thread support is provided out of the box with final classes like wait( ) notify( ). Other methods like clone( ) equals( ) getClass( ) and hashCode( ) provide features to be extended by child classes. getClass( ) is important for Reflections. hashCode( ) is important for generating hashcode indices for Collections like Map. Also finalize( ) serves as a Destructor.
Actually I have this picture of how a JVM may work. I have already given you guys lots of dumb ideas and stuff before so one more. I do not know from where I got this idea or if I have mentioned it before. Anyways...
Suppose I have 3 Classes with C extending B and B extending A.
C c = new C( );
And now only one pointer is created on the stack pointing to the new C object on the heap. Something like ..
ptr-----> ((((Object)A)B)C)
stack---> heap
so if I say (B)c;
ptr is used to read data sizeof(B) and that is used to retrieve (rather reconstruct) the instance from the heap.
if I say (A)c;
the same ptr is used to read data sizeof(A) and that is used to get the instance of type A.
And in this way Casting is done.
So I would like to emphasize that one pointer is used which initially points to type Object and this can be 'extended'. In this way the JVM and Classloader have a starting point for any Class which is seems to be a benefit.
I think I may have drifted quite a bit, but hey.. it is a pvt blog!! Now can any of you verify this? Do you know how it happens in C++?
I was a bit confused about what you are trying to say? Do you mean simple Casting? How is C++ better at handling collections/generics w/o unified type system?
Personally I do not think that Collections were a reason for Object. Object was an initial design consideration, but Collections came in at a later stage. Casting though is a very important factor.
To notice the advantages of Object look at the class itself. Object guarantees that Thread support is provided out of the box with final classes like wait( ) notify( ). Other methods like clone( ) equals( ) getClass( ) and hashCode( ) provide features to be extended by child classes. getClass( ) is important for Reflections. hashCode( ) is important for generating hashcode indices for Collections like Map. Also finalize( ) serves as a Destructor.
Actually I have this picture of how a JVM may work. I have already given you guys lots of dumb ideas and stuff before so one more. I do not know from where I got this idea or if I have mentioned it before. Anyways...
Suppose I have 3 Classes with C extending B and B extending A.
C c = new C( );
And now only one pointer is created on the stack pointing to the new C object on the heap. Something like ..
ptr-----> ((((Object)A)B)C)
stack---> heap
so if I say (B)c;
ptr is used to read data sizeof(B) and that is used to retrieve (rather reconstruct) the instance from the heap.
if I say (A)c;
the same ptr is used to read data sizeof(A) and that is used to get the instance of type A.
And in this way Casting is done.
So I would like to emphasize that one pointer is used which initially points to type Object and this can be 'extended'. In this way the JVM and Classloader have a starting point for any Class which is seems to be a benefit.
I think I may have drifted quite a bit, but hey.. it is a pvt blog!! Now can any of you verify this? Do you know how it happens in C++?
Re: Unified Type System
I thought this had to do in a Major way with garbage collection too. Not sure though, a detailed answer by someone would be welcome.
Dinesh.
Dinesh.
Wednesday, July 07, 2004
Re: The C++ Source (C++ future)
One complaint which Java devs have of Swing (Java GUI) is that GUI components like Buttons etc have to be placed within containers and stuff. It is not possible to place components at absolute positions on the screen. Everything has to be relative to other components. How is it in .NET?
Any particular reason they've done that?
In .NET each control is independent of others. You have the option of grouping them together if you want. Each control has absolute position. Before .NET, this could cause some problems. If you expanded the windows, all the controls would stay in the same exact location - it wasn't dynamic in relation to the window size. In .NET, you can assign properties to each control in relation to the window size. You can either have it "grow" when the window resizes or just change location.
Any particular reason they've done that?
In .NET each control is independent of others. You have the option of grouping them together if you want. Each control has absolute position. Before .NET, this could cause some problems. If you expanded the windows, all the controls would stay in the same exact location - it wasn't dynamic in relation to the window size. In .NET, you can assign properties to each control in relation to the window size. You can either have it "grow" when the window resizes or just change location.
Performance of Java vs C++
http://www.idiom.com/~zilla/Computer/javaCbenchmark.html
The actual benchmark isn't the main attraction. The article has several general points that I thought were quite good.
The actual benchmark isn't the main attraction. The article has several general points that I thought were quite good.
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.
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.
Re: The C++ Source (C++ future)
We're all borderline bums so we don't have real work.
I know that. I'm in the same category!!
Anyway, those UI's looked good. It's not impossible to come up with a good UI in Java. The question is how easy is it?
One complaint which Java devs have of Swing (Java GUI) is that GUI components like Buttons etc have to be placed within containers and stuff. It is not possible to place components at absolute positions on the screen. Everything has to be relative to other components. How is it in .NET?
I can't claim to have used many Java client apps. The only one I have used is Forte by Sun. It was an alright experience - not bad, but definitely could be better. It just felt like the app was out of place in Windows.
In Java there exists a concept called LookAndFeel (laf). laf is like a theme/skin. So a skin can be applied to a GUI like Motif, Windows, Metal. As of now Metal is the default cross platform laf. A few more lines of code have to be written to apply the native laf. In Java 1.5 the Win XP and Red Hat laf's have been added.
Is it possible to create a java desktop application that w/o any change will work on any platform?
Simple answer - YES. Any Java app is cross-platform. Unless some native libraries are used, which is very very rare.
I know that. I'm in the same category!!
Anyway, those UI's looked good. It's not impossible to come up with a good UI in Java. The question is how easy is it?
One complaint which Java devs have of Swing (Java GUI) is that GUI components like Buttons etc have to be placed within containers and stuff. It is not possible to place components at absolute positions on the screen. Everything has to be relative to other components. How is it in .NET?
I can't claim to have used many Java client apps. The only one I have used is Forte by Sun. It was an alright experience - not bad, but definitely could be better. It just felt like the app was out of place in Windows.
In Java there exists a concept called LookAndFeel (laf). laf is like a theme/skin. So a skin can be applied to a GUI like Motif, Windows, Metal. As of now Metal is the default cross platform laf. A few more lines of code have to be written to apply the native laf. In Java 1.5 the Win XP and Red Hat laf's have been added.
Is it possible to create a java desktop application that w/o any change will work on any platform?
Simple answer - YES. Any Java app is cross-platform. Unless some native libraries are used, which is very very rare.
Tuesday, July 06, 2004
Sunday, July 04, 2004
Re: The C++ Source (C++ future)
If you guys have no real work; have a look at a few of the better Java desktop applications here.
We're all borderline bums so we don't have real work.
Anyway, those UI's looked good. It's not impossible to come up with a good UI in Java. The question is how easy is it? If it's not straightforward "by default" then regular joe java devs will be putting out awful interfaces. And I guess that's whats been happening. The less expected of programmers the better.
I can't claim to have used many Java client apps. The only one I have used is Forte by Sun. It was an alright experience - not bad, but definitely could be better. It just felt like the app was out of place in Windows. I feel like apps should look like they were made for "my" platform. Each platform has its own features and strengths and the apps should use that. This is the area I feel Java is limiting.
Is it possible to create a java desktop application that w/o any change will work on any platform?
Java's strengths are it's weaknesses and I suppose same for the other languages/platforms.
Can't think of a better way of putting this.
We're all borderline bums so we don't have real work.
Anyway, those UI's looked good. It's not impossible to come up with a good UI in Java. The question is how easy is it? If it's not straightforward "by default" then regular joe java devs will be putting out awful interfaces. And I guess that's whats been happening. The less expected of programmers the better.
I can't claim to have used many Java client apps. The only one I have used is Forte by Sun. It was an alright experience - not bad, but definitely could be better. It just felt like the app was out of place in Windows. I feel like apps should look like they were made for "my" platform. Each platform has its own features and strengths and the apps should use that. This is the area I feel Java is limiting.
Is it possible to create a java desktop application that w/o any change will work on any platform?
Java's strengths are it's weaknesses and I suppose same for the other languages/platforms.
Can't think of a better way of putting this.
Saturday, July 03, 2004
Re: The C++ Source (C++ future)
When you think of Java, you immediately think about server-side code. It's got a bad rap on the client and I don't feel like that perception will change much... not on a large enough scale.
The java community itself has to blame for the mess on the client side. They are doing some stuff on this front but will take time. Java's UI API, Swing is a bit slow. What really caused a mess for java on the desktop is dev's making UI designs. Many crappy, user -'UN'friendly apps were made. I suppose for larger complex UI's designers should be brought in.
If you guys have no real work; have a look at a few of the better Java desktop applications here.
Java has done a commendable job in keeping itself platform independent, but the costs seem to be quite high. There is this lowest common denominator rule it has to follow.
Another valid point. Java's strengths are it's weaknesses and I suppose same for the other languages/platforms.
It's really cool how each of us stuck out for our own lang. These discussions would have been slightly boring if all of us had been on the same side.
p.s. the same side would obviously be Java :)
The java community itself has to blame for the mess on the client side. They are doing some stuff on this front but will take time. Java's UI API, Swing is a bit slow. What really caused a mess for java on the desktop is dev's making UI designs. Many crappy, user -'UN'friendly apps were made. I suppose for larger complex UI's designers should be brought in.
If you guys have no real work; have a look at a few of the better Java desktop applications here.
Java has done a commendable job in keeping itself platform independent, but the costs seem to be quite high. There is this lowest common denominator rule it has to follow.
Another valid point. Java's strengths are it's weaknesses and I suppose same for the other languages/platforms.
It's really cool how each of us stuck out for our own lang. These discussions would have been slightly boring if all of us had been on the same side.
p.s. the same side would obviously be Java :)
Friday, July 02, 2004
Generics v Templates
Comparing .NET Generics and C++ Templates
Good article essentially covering our discussion several months ago. As we had understood, because .NET does the specialization at run-time there is the need for "Constraints". What terminology does Java use?
Good article essentially covering our discussion several months ago. As we had understood, because .NET does the specialization at run-time there is the need for "Constraints". What terminology does Java use?
Re: The C++ Source (C++ future)
Personally I feel managed code will be adopted even more in the future and at a later stage C++ will loose its hold on desktop applications. This will happen sooner in Windows especially after Longhorn. On linux this should take much more time, simply because of mistrust of Java, Sun.
On the Windows front, it's as good as done. As you say, with Longhorn the whole platform is going managed. It will be backward compatible with Win32, so it's not like your C/C++ apps won't work. It will be deprecated. This has already started with .NET. Java introduced managed code long back (and Smalltalk long before that), but only with Microsoft getting into the game will it have a major impact. They control the direction developers take on the client.
Linux on the other hand is a completely different story. I don't think managed code will be successful on non-windows platforms. Linux devs don't trust anything that is not open source. As of now, there isn't (not that I know of) a completely independent open source managed code platform. Mono is heavily associated with .NET and we all know how much the oss community loves Microsoft. C/C++ should rule here for a while.
Another question is much on dev on Win will be done using Java?
I don't see it as having much success on the desktop even with improvements they've made. When you think of Java, you immediately think about server-side code. It's got a bad rap on the client and I don't feel like that perception will change much... not on a large enough scale. If you are developing a Windows app, it wouldn't make sense NOT to choose .NET. You get performance and can access the full capabilities of Win32 if you need to.
Java has done a commendable job in keeping itself platform independent, but the costs seem to be quite high. There is this lowest common denominator rule it has to follow. All functionality has to be the same everywhere. Each platform has some capability unique to it. Java, if not prevents, discourages you from using that. So this is another big debate... Platform independence and lowest denominator or platform specific features.
Frankly, I can see why managed code is becoming such an ally to developers, but I think the most important thing to consider is the fact that there are millions and millions of lines of code in C++ already, where does that go?
This is an important point. Legacy code will always be there. Even when we move on to the next great thing and leave Java/.NET in the dust. I'm sure there's still old Fortran code hanging in some mainframe somewhere that needs to be maintained. But I don't see any new software being developed using Fortran.
I share the same feeling with you regarding C++. It's a wonderful language and will be around for a long time. I just feel like for custom apps it will eventually be displaced. I'm not talking about big applications like Office/Mozilla, system code or OS's. And I don't expect games to move over to the managed world anytime soon either (Although Vertigo manged to port Quake II to .NET and even added new features using Win Forms). I'm talking about apps IT departments develop. The complexity, when compared to .NET/Java is just too high.
They are actually reconsidering the C++ Standard and I think in the next update the Boost library will be included, lets see how far they go to actually "compete" with the others (Java et al), if at all.
I don't ever think that C++ will ever have a monolithic library akin to the Java API or the .NET framework. Having such frameworks makes it super convenient to develop applications cause you'll find more or less everything but the kitchen sink - collections, graphics, networking, threads, UI, etc... But the disadvantage is that you need your clients to have that framework installed. This goes against c++'s "culture". Even the STL (at this stage) is mostly about collections and algorithms. These are something almost all, even the most basic of applications, need. I dunno what their future plans are for extending the standard library, but I doubt it would involve anything that isn't generic.
What dyou feel?
On the Windows front, it's as good as done. As you say, with Longhorn the whole platform is going managed. It will be backward compatible with Win32, so it's not like your C/C++ apps won't work. It will be deprecated. This has already started with .NET. Java introduced managed code long back (and Smalltalk long before that), but only with Microsoft getting into the game will it have a major impact. They control the direction developers take on the client.
Linux on the other hand is a completely different story. I don't think managed code will be successful on non-windows platforms. Linux devs don't trust anything that is not open source. As of now, there isn't (not that I know of) a completely independent open source managed code platform. Mono is heavily associated with .NET and we all know how much the oss community loves Microsoft. C/C++ should rule here for a while.
Another question is much on dev on Win will be done using Java?
I don't see it as having much success on the desktop even with improvements they've made. When you think of Java, you immediately think about server-side code. It's got a bad rap on the client and I don't feel like that perception will change much... not on a large enough scale. If you are developing a Windows app, it wouldn't make sense NOT to choose .NET. You get performance and can access the full capabilities of Win32 if you need to.
Java has done a commendable job in keeping itself platform independent, but the costs seem to be quite high. There is this lowest common denominator rule it has to follow. All functionality has to be the same everywhere. Each platform has some capability unique to it. Java, if not prevents, discourages you from using that. So this is another big debate... Platform independence and lowest denominator or platform specific features.
Frankly, I can see why managed code is becoming such an ally to developers, but I think the most important thing to consider is the fact that there are millions and millions of lines of code in C++ already, where does that go?
This is an important point. Legacy code will always be there. Even when we move on to the next great thing and leave Java/.NET in the dust. I'm sure there's still old Fortran code hanging in some mainframe somewhere that needs to be maintained. But I don't see any new software being developed using Fortran.
I share the same feeling with you regarding C++. It's a wonderful language and will be around for a long time. I just feel like for custom apps it will eventually be displaced. I'm not talking about big applications like Office/Mozilla, system code or OS's. And I don't expect games to move over to the managed world anytime soon either (Although Vertigo manged to port Quake II to .NET and even added new features using Win Forms). I'm talking about apps IT departments develop. The complexity, when compared to .NET/Java is just too high.
They are actually reconsidering the C++ Standard and I think in the next update the Boost library will be included, lets see how far they go to actually "compete" with the others (Java et al), if at all.
I don't ever think that C++ will ever have a monolithic library akin to the Java API or the .NET framework. Having such frameworks makes it super convenient to develop applications cause you'll find more or less everything but the kitchen sink - collections, graphics, networking, threads, UI, etc... But the disadvantage is that you need your clients to have that framework installed. This goes against c++'s "culture". Even the STL (at this stage) is mostly about collections and algorithms. These are something almost all, even the most basic of applications, need. I dunno what their future plans are for extending the standard library, but I doubt it would involve anything that isn't generic.
What dyou feel?
Tuesday, June 29, 2004
Re: The C++ Source (C++ future)
Frankly, I can see why managed code is becoming such an ally to developers, but I think the most important thing to consider is the fact that there are millions and millions of lines of code in C++ already, where does that go?
As far as I can tell, I do see an eventual shift from C++ to managed code, but call me old fashioned I just love C++. But I, like most other people, want to do things in better ways than possible now, so the only question to answer is whether managed code will be better (now or in the near future), once that happens, no one's going to just want to stick to C++ because of tradition or because I love it.
As long as it proves to be a worthy successor, Managed Code is going to pave the new paths. But this will take time and no, I don't see C++ completely phasing out in the immediate future.
They are actually reconsidering the C++ Standard and I think in the next update the Boost library will be included, lets see how far they go to actually "compete" with the others (Java et al), if at all.
Dinesh.
As far as I can tell, I do see an eventual shift from C++ to managed code, but call me old fashioned I just love C++. But I, like most other people, want to do things in better ways than possible now, so the only question to answer is whether managed code will be better (now or in the near future), once that happens, no one's going to just want to stick to C++ because of tradition or because I love it.
As long as it proves to be a worthy successor, Managed Code is going to pave the new paths. But this will take time and no, I don't see C++ completely phasing out in the immediate future.
They are actually reconsidering the C++ Standard and I think in the next update the Boost library will be included, lets see how far they go to actually "compete" with the others (Java et al), if at all.
Dinesh.
Re The C++ Source (C++ future)
I know this question has been debated many many times before, but what do you feel about the future of C++? With the emergence of managed code in the form of Java and .NET, where productivity is noticably higher, do you think C++ is falling behind for desktop application development? This is it's forte, but is it still relevant? I doubt anyone uses it anymore for web applications. Atleast on Windows, Microsoft seems to be giving less attention to MFC and is encouranging all developers to move to .NET. You already have Java in the Unix world.
What makes this debate interesting is our varying background. Mohnish and I do have a managed code bias so it is very important to know what Dinesh and Hrishi feel.
Personally I feel managed code will be adopted even more in the future and at a later stage C++ will loose its hold on desktop applications. This will happen sooner in Windows especially after Longhorn. On linux this should take much more time, simply because of mistrust of Java, Sun.
Another question is much on dev on Win will be done using Java? Java 5.0 (formerly Java 1.5) is now in beta and has many new features and enhancements as shown here. Speed is claimed to have been increased drastically. More importantly "Many areas of the rich desktop client have been enhanced including an updated, more modern, cross-platform look and feel." So the ugly and slow java apps might be a bit less uglier and more faster. I cannot claim that Java will hurt .NET on Windows, but as Mohn pointed out, Java is being taught in lots of universities. Those guys might become comfortable with Java. So as we all are resilient to change, some dev on Windows might be done in Java. Also a lot of API's are being added to Java which will make it an alternative to .NET. Otherwise I suppose most C++ devs like Dinesh will jump on to .NET unless they really need platform independence which for desktop apps doesn't seem to be the biggest driver.
Ps: have yu guys seen maestro? The Nasa space rover simulation app.
What makes this debate interesting is our varying background. Mohnish and I do have a managed code bias so it is very important to know what Dinesh and Hrishi feel.
Personally I feel managed code will be adopted even more in the future and at a later stage C++ will loose its hold on desktop applications. This will happen sooner in Windows especially after Longhorn. On linux this should take much more time, simply because of mistrust of Java, Sun.
Another question is much on dev on Win will be done using Java? Java 5.0 (formerly Java 1.5) is now in beta and has many new features and enhancements as shown here. Speed is claimed to have been increased drastically. More importantly "Many areas of the rich desktop client have been enhanced including an updated, more modern, cross-platform look and feel." So the ugly and slow java apps might be a bit less uglier and more faster. I cannot claim that Java will hurt .NET on Windows, but as Mohn pointed out, Java is being taught in lots of universities. Those guys might become comfortable with Java. So as we all are resilient to change, some dev on Windows might be done in Java. Also a lot of API's are being added to Java which will make it an alternative to .NET. Otherwise I suppose most C++ devs like Dinesh will jump on to .NET unless they really need platform independence which for desktop apps doesn't seem to be the biggest driver.
Ps: have yu guys seen maestro? The Nasa space rover simulation app.
Monday, June 28, 2004
Re: Tales from the server side
Those were some good 'enterprise' jokes.
Especially liked EJB persistence and The conspiracy.
Framework Lock-In occurs in the Java world when 'other's make API's for something lacking in the general Java API. There are also instances of API's being created which compete with standard Java API's.
Does such a situation ever occur in .NET?
Especially liked EJB persistence and The conspiracy.
Framework Lock-In occurs in the Java world when 'other's make API's for something lacking in the general Java API. There are also instances of API's being created which compete with standard Java API's.
Does such a situation ever occur in .NET?
Security: The root of the problem
A very nice article on software security issues over at Queue magazine.
This again leads to my previous post regarding the relevance of C++ as we move forward. One of the reasons most Universites (atleast in the US) are moving to Java, is that you are by default sheilded from memory management, which is the root of most security problems. There is a benefit from having a safety net below you. The less expected of the programmer, the better :-)
This again leads to my previous post regarding the relevance of C++ as we move forward. One of the reasons most Universites (atleast in the US) are moving to Java, is that you are by default sheilded from memory management, which is the root of most security problems. There is a benefit from having a safety net below you. The less expected of the programmer, the better :-)
The C++ Source
Artima has started a site devoted to c++ entitled The C++ Source. Here's an intro. All the big guns seem to be in on it - Check out the advisory board.
I know this question has been debated many many times before, but what do you feel about the future of C++? With the emergence of managed code in the form of Java and .NET, where productivity is noticably higher, do you think C++ is falling behind for desktop application development? This is it's forte, but is it still relevant? I doubt anyone uses it anymore for web applications. Atleast on Windows, Microsoft seems to be giving less attention to MFC and is encouranging all developers to move to .NET. You already have Java in the Unix world.
I know this question has been debated many many times before, but what do you feel about the future of C++? With the emergence of managed code in the form of Java and .NET, where productivity is noticably higher, do you think C++ is falling behind for desktop application development? This is it's forte, but is it still relevant? I doubt anyone uses it anymore for web applications. Atleast on Windows, Microsoft seems to be giving less attention to MFC and is encouranging all developers to move to .NET. You already have Java in the Unix world.
Tales from the server side
Been a while since we've had some activity here. Time we get it going again.
http://www.theserverside.com/cartoons/TalesFromTheServerSide.tss
http://www.theserverside.com/cartoons/TalesFromTheServerSide.tss
Saturday, June 12, 2004
Re: N-queens solution
I still haven't read Dinesh's 'Optimum' solution completely and am assuming i understood what i read. But another idea came to my mind. I don't know how much performance gain can be achieved if any at all. You be the judge.
The idea is to use Reflection.
Reflection allows Classes to be thought of as objects and it is possible to create instances of classes and use those to invoke methods etc of the Class. (just a intro for completeness). As mohn put it,(i think) Reflection is using meta-data of the Classes.
I am not sure if Reflection is possible in C++.
In Dinesh's 'Optimum' solution,
File ChessBoard.cpp, method void Search(int xpos), iteration is done at each step by these lines
ChessBoard* chess = new ChessBoard ( currSol,order);
chess->Search(g+1);
I guess creating 'new' instances for every row each time, is very costly. Hey.. Reflection is definitely costlier than 'new'. But could be used here.
If N instances of ChessBoard are created and stored in a List, these can be used for the solutions.
A new method, say flush(), to clear the state of the ChessBoard could be created.
Now instead of multiple 'new', the instances are created only once. Then Method objects can be created and invoked(). For each row, the Method of the element of the List can be called and after a search, all the List elements are 'flush()'ed for a new search...
The idea is to use Reflection.
Reflection allows Classes to be thought of as objects and it is possible to create instances of classes and use those to invoke methods etc of the Class. (just a intro for completeness). As mohn put it,(i think) Reflection is using meta-data of the Classes.
I am not sure if Reflection is possible in C++.
In Dinesh's 'Optimum' solution,
File ChessBoard.cpp, method void Search(int xpos), iteration is done at each step by these lines
ChessBoard* chess = new ChessBoard ( currSol,order);
chess->Search(g+1);
I guess creating 'new' instances for every row each time, is very costly. Hey.. Reflection is definitely costlier than 'new'. But could be used here.
If N instances of ChessBoard are created and stored in a List, these can be used for the solutions.
A new method, say flush(), to clear the state of the ChessBoard could be created.
Now instead of multiple 'new', the instances are created only once. Then Method objects can be created and invoked(). For each row, the Method of the element of the List can be called and after a search, all the List elements are 'flush()'ed for a new search...
Thursday, June 10, 2004
Re: N-queens solution
Explanation of N-queens
I will assume the 4-queens problem for sake of simplicity. 4-queens has 2 solutions.
The Optimal Solution (without notDuplicate() and other functions)
The objective of the program is to generate the positions on a 4x4 chess board such that when queens are placed on those postions, they do not attack each other.
The mobility of the queen sets the rules by which the other queens can be placed on the board.
This is how my program goes. The main() enters a loop to go through the first row of the chess board. So in the first iteration of the loop list< Solution > holds a single point (0,0) and this is used to construct the first chessBoard object,through a pointer "chess". The constructor for ChessBoard takes "candidate Solution list" and size of the board (in this case 4x4, hence n=4). Next, in the loop chess->Search() is exceuted. Search() represents the main algorithm which does most of the work in the program. Search() takes an argument which is the row number where the child has to be searched. If you notice, in this version, I'm feeding forward, as in, since my first point is (0,0), I search for a child in row 1.
Now I'll break down Search() for initial point of (0,0). The first step in Search() is to check whether the list currSol's size equals the size of of n. This case is possible only when a solution is found and hence here an "if" statement checks for that and on being true, Search() prints the Solution, increments the no. of solutions found and then returns.
Now if the size is not equal to n, that means the list still has to grow to find a solution. Hence the next step is to Map the chess board, i.e. to setup the unsafe positions on the board. This is achieved by the function setAttForEach(). For (0,0), the resultant board layout is:
Print currSol
Position on board is: 0 , 0
Print Board
1 0 0 0
0 0 1 1
0 1 0 1
0 1 1 0
Now once the board has been setup, the main loop of the Search() function starts. xpos sets which row has to be searched to find a new safe position. The loop starts iterating through through that row (namely row 1) and the "if" statement checks whether the board position is safe or not. This is the critical part, If a safe position is found, first the new Point is appended to the currSol list and after that a new object of ChessBoard is created giving currSol to the new object's constructor and then chess->Search(g+1) is called, i.e Search() is called on the new object - for the next row (namely row 2).
Now again Search() executes for the new object, first checking if solution is found (which fails) and then Mapping the board of the new object according to it's currSol, which has the Points (0,0) and (1,2), the board now has the following setup:
Print currSol
Position on board is: 0 , 0
Position on board is: 1 , 2
Print Board
1 0 0 0
0 0 1 0
0 0 0 0
0 1 0 0
As you can notice when Search() goes through row 2, it finds no 1's hence the search on this object returns. Returns to where? Returns to the first object's Search(). See Search(), there is a "delete chess", hence the first object (the one with (0,0))deletes the new object (the one with (0,0) & (1,2)), and then does a currSol.pop_back(), which means that (1,2) is removed from the first object's currSol (remember we had pushed it in before creating new object, hence we pop it back out, since there is not solution to be found from that). The next line (setAttForEach) is redundant and is not needed, hence you can delete it. Now the first object's currSol has only (0,0) and it continues with the loop, i.e. it continues to search through row 1. It now finds (1,3) to be a probable child and in this way the search continues for all possible safe positions in row 1. But 4-queens doesn't have any solutions with (0,0), so this object search finally returns back to main(), where again the object is deleted and the main's loop continues, so now a new ChessBoard is created for the initial point of (0,1). This does find a solution:
Print currSol
Position on board is: 0 , 1
Position on board is: 1 , 3
Position on board is: 2 , 0
Position on board is: 3 , 2
Solutions: 1
And the second solution found is
Print currSol
Position on board is: 0 , 2
Position on board is: 1 , 0
Position on board is: 2 , 3
Position on board is: 3 , 1
Solutions: 2
Actually these also are similar, these two are basically what you call reflections of each other (try swapping the x,y values in first and re-order, you get the second solution). So the First is the "Unique" solution.
So this was the explanation, hope it made sense to you'll. This may not be the most efficient way to solve this problem, but my aim was to brush up with c++, which I achieved. So all in all, I'm pretty happy with the product!
Dinesh.
I will assume the 4-queens problem for sake of simplicity. 4-queens has 2 solutions.
The Optimal Solution (without notDuplicate() and other functions)
The objective of the program is to generate the positions on a 4x4 chess board such that when queens are placed on those postions, they do not attack each other.
The mobility of the queen sets the rules by which the other queens can be placed on the board.
This is how my program goes. The main() enters a loop to go through the first row of the chess board. So in the first iteration of the loop list< Solution > holds a single point (0,0) and this is used to construct the first chessBoard object,through a pointer "chess". The constructor for ChessBoard takes "candidate Solution list" and size of the board (in this case 4x4, hence n=4). Next, in the loop chess->Search() is exceuted. Search() represents the main algorithm which does most of the work in the program. Search() takes an argument which is the row number where the child has to be searched. If you notice, in this version, I'm feeding forward, as in, since my first point is (0,0), I search for a child in row 1.
Now I'll break down Search() for initial point of (0,0). The first step in Search() is to check whether the list currSol's size equals the size of of n. This case is possible only when a solution is found and hence here an "if" statement checks for that and on being true, Search() prints the Solution, increments the no. of solutions found and then returns.
Now if the size is not equal to n, that means the list still has to grow to find a solution. Hence the next step is to Map the chess board, i.e. to setup the unsafe positions on the board. This is achieved by the function setAttForEach(). For (0,0), the resultant board layout is:
Print currSol
Position on board is: 0 , 0
Print Board
1 0 0 0
0 0 1 1
0 1 0 1
0 1 1 0
Now once the board has been setup, the main loop of the Search() function starts. xpos sets which row has to be searched to find a new safe position. The loop starts iterating through through that row (namely row 1) and the "if" statement checks whether the board position is safe or not. This is the critical part, If a safe position is found, first the new Point is appended to the currSol list and after that a new object of ChessBoard is created giving currSol to the new object's constructor and then chess->Search(g+1) is called, i.e Search() is called on the new object - for the next row (namely row 2).
Now again Search() executes for the new object, first checking if solution is found (which fails) and then Mapping the board of the new object according to it's currSol, which has the Points (0,0) and (1,2), the board now has the following setup:
Print currSol
Position on board is: 0 , 0
Position on board is: 1 , 2
Print Board
1 0 0 0
0 0 1 0
0 0 0 0
0 1 0 0
As you can notice when Search() goes through row 2, it finds no 1's hence the search on this object returns. Returns to where? Returns to the first object's Search(). See Search(), there is a "delete chess", hence the first object (the one with (0,0))deletes the new object (the one with (0,0) & (1,2)), and then does a currSol.pop_back(), which means that (1,2) is removed from the first object's currSol (remember we had pushed it in before creating new object, hence we pop it back out, since there is not solution to be found from that). The next line (setAttForEach) is redundant and is not needed, hence you can delete it. Now the first object's currSol has only (0,0) and it continues with the loop, i.e. it continues to search through row 1. It now finds (1,3) to be a probable child and in this way the search continues for all possible safe positions in row 1. But 4-queens doesn't have any solutions with (0,0), so this object search finally returns back to main(), where again the object is deleted and the main's loop continues, so now a new ChessBoard is created for the initial point of (0,1). This does find a solution:
Print currSol
Position on board is: 0 , 1
Position on board is: 1 , 3
Position on board is: 2 , 0
Position on board is: 3 , 2
Solutions: 1
And the second solution found is
Print currSol
Position on board is: 0 , 2
Position on board is: 1 , 0
Position on board is: 2 , 3
Position on board is: 3 , 1
Solutions: 2
Actually these also are similar, these two are basically what you call reflections of each other (try swapping the x,y values in first and re-order, you get the second solution). So the First is the "Unique" solution.
So this was the explanation, hope it made sense to you'll. This may not be the most efficient way to solve this problem, but my aim was to brush up with c++, which I achieved. So all in all, I'm pretty happy with the product!
Dinesh.
Wednesday, June 09, 2004
Re: N-queens solution
Ok, my favourite part when I was doing this was when I tried to make my own version of the standard library function mem_fun_ref_t. You'll will know it as mem_fun_ref, which is basically an adapter for the first!
Now what I was trying to do was to get for_each() working in this way,
for_each(currSol.begin(),currSol.end(),setatt)
But it would let me, saying that address of setatt couldn't be taken. Then I tried
for_each(currSol.begin(),currSol.end(),mem_fun_ref, (&ChessBoard::setatt))
This was really bad, cause as I later found out, my whole idea of what the adapters mem_fun and mem_fun_ref did was wrong.
Mohnish, this is especially for you, man try reading the source for stl_function.h !! You'll learn an awful lot about the way things work! try stl_algorithm.h too! But it's not for the faint-hearted!! :):) I thought I knew exactly what it did, but I was a bit wrong! It was time well spent trying to read it!!
I tried making my own version of mem_fun_ref, but there were problems and I wasn't able to get it right, yet!!
If you guys want I'll post explanations of mem_fun & mem_fun_ref! Tell me if you want it! Atleast I'll try, I'm still figuring out :)
Dinesh.
Now what I was trying to do was to get for_each() working in this way,
for_each(currSol.begin(),currSol.end(),setatt)
But it would let me, saying that address of setatt couldn't be taken. Then I tried
for_each(currSol.begin(),currSol.end(),mem_fun_ref, (&ChessBoard::setatt))
This was really bad, cause as I later found out, my whole idea of what the adapters mem_fun and mem_fun_ref did was wrong.
Mohnish, this is especially for you, man try reading the source for stl_function.h !! You'll learn an awful lot about the way things work! try stl_algorithm.h too! But it's not for the faint-hearted!! :):) I thought I knew exactly what it did, but I was a bit wrong! It was time well spent trying to read it!!
I tried making my own version of mem_fun_ref, but there were problems and I wasn't able to get it right, yet!!
If you guys want I'll post explanations of mem_fun & mem_fun_ref! Tell me if you want it! Atleast I'll try, I'm still figuring out :)
Dinesh.
Re: N-queens solution
Revo of course the thing will work!!! I was really stupid, I should have given your'll this solution rather than the duplicate one. Remember I had said, I had written a program before also on 8-queens using brute search rather than "back-tracking", well that incorporated this idea.
This was at the back of my mind, but just forgot to use it for optimization! I'm sorry, I can get pretty dumb like this at times!! Thanks Revo!!
My aim for this thing was brushing up with C++, hence it's a little more complex than it should be. But I had a lot of fun with it.
I did the whole duplicate thing because I wanted to see what happened if I started say for an initial position on (0,0), I appended the nth-level queen to it. I wanted to see if the path taken was any different. But the nature of the problem is still such that, even if I append an nth-level queen all it gives me is a duplicate of the original solution! This is really a cool problem!
So I wanted to make a multi-level search and see what I found rather than just making a single-level search. For me the most interesting thing was the tree structure that was getting created.
You can find the optimized source here: Windows & Linux
Dinesh.
This was at the back of my mind, but just forgot to use it for optimization! I'm sorry, I can get pretty dumb like this at times!! Thanks Revo!!
My aim for this thing was brushing up with C++, hence it's a little more complex than it should be. But I had a lot of fun with it.
I did the whole duplicate thing because I wanted to see what happened if I started say for an initial position on (0,0), I appended the nth-level queen to it. I wanted to see if the path taken was any different. But the nature of the problem is still such that, even if I append an nth-level queen all it gives me is a duplicate of the original solution! This is really a cool problem!
So I wanted to make a multi-level search and see what I found rather than just making a single-level search. For me the most interesting thing was the tree structure that was getting created.
You can find the optimized source here: Windows & Linux
Dinesh.
Re: N-queens solution
Firstly i would like to clarify that I have not read Dinesh's solution yet. Too lazy to read and C++ is not the easiest language.
I got thinking of the problem and may have a solution. I think its different cause I did not feel the need for a duplicate() or the need to set many attack conditions. Maybe the soln's might be same. And it's almost 3:30 AM so I'll just present an algo, which if different, I'll try coding later.
My basic principle is that each queen on the chess board will occupy only one row. There are 8 queens, q0, q1,.. q7 where qn will be placed in the n th row.
The methods are
[ ] getSafePositions()........//returns all safe column positions for a queen in a row
setAttackBelow()..............//set all positions below current position as unsafe
setAttackDiagonalLeft()...//set all positions diagonally left of current position as unsafe
setAttackDiagonalRight()..//set all positions diagonally right of current position as unsafe
.[ ] q0.getSafePositions()
.if [ ] == null, {reset board & continue};
.for each in [ ]
....q0.setAttack()
....[ ] q1.getSafePositions()
....for each in [ ]
.... ..
.... ..
...// and iterate for each lower row.
...// finally
.......[ ]q7.getSafePositions()
...........if [ ] != null
.............else {we have a soln}
Here q0 is the queen placed anywhere in the first row, q1 in the second row and so on. if q7 is also placed on the board, then thats a solution.
Now the other attack combinations ( up of the current queen row ) are not required as the next queen just cannot be placed there. So those above positions can be neglected for setAttack and also for getSafePositions()
So is my solution different or did I make a fool out of myself not reading Dinesh's code??
I suggest Hrishi and Mohn also try some solutions. Should we try more problems like these? We'll get a million from sites like topcoder.com.
I got thinking of the problem and may have a solution. I think its different cause I did not feel the need for a duplicate() or the need to set many attack conditions. Maybe the soln's might be same. And it's almost 3:30 AM so I'll just present an algo, which if different, I'll try coding later.
My basic principle is that each queen on the chess board will occupy only one row. There are 8 queens, q0, q1,.. q7 where qn will be placed in the n th row.
The methods are
[ ] getSafePositions()........//returns all safe column positions for a queen in a row
setAttackBelow()..............//set all positions below current position as unsafe
setAttackDiagonalLeft()...//set all positions diagonally left of current position as unsafe
setAttackDiagonalRight()..//set all positions diagonally right of current position as unsafe
.[ ] q0.getSafePositions()
.if [ ] == null, {reset board & continue};
.for each in [ ]
....q0.setAttack()
....[ ] q1.getSafePositions()
....for each in [ ]
.... ..
.... ..
...// and iterate for each lower row.
...// finally
.......[ ]q7.getSafePositions()
...........if [ ] != null
.............else {we have a soln}
Here q0 is the queen placed anywhere in the first row, q1 in the second row and so on. if q7 is also placed on the board, then thats a solution.
Now the other attack combinations ( up of the current queen row ) are not required as the next queen just cannot be placed there. So those above positions can be neglected for setAttack and also for getSafePositions()
So is my solution different or did I make a fool out of myself not reading Dinesh's code??
I suggest Hrishi and Mohn also try some solutions. Should we try more problems like these? We'll get a million from sites like topcoder.com.
N-queens solution
Have you'll heard about the 8-queens problem, I think most CS guys are familiar with it. I was generally trying to brush up with C++, so I thought I'd try to generate the solutions to the 8-queens problem (there are 92 of them). Then I thought if I'm going for a solver might as well make it a generic one and so I wrote the following code to solve n-queens for any given n.
The source code can be found here : Windows & Linux
It was really a lot of fun!! For 8 queens, I got the execution time down from 435 seconds to 213 seconds to 20 seconds!!!
As far as I know, the code will generate solutions for any n, considering some critical resource doesn't get exhausted. I tested it for 9 queens which has 352 solutions, it generated all 352 of them! So it should work!!
Dinesh.
The source code can be found here : Windows & Linux
It was really a lot of fun!! For 8 queens, I got the execution time down from 435 seconds to 213 seconds to 20 seconds!!!
As far as I know, the code will generate solutions for any n, considering some critical resource doesn't get exhausted. I tested it for 9 queens which has 352 solutions, it generated all 352 of them! So it should work!!
Dinesh.
Saturday, June 05, 2004
some news
here are some good links i got
link here
desription
One way to think of Fast Infoset is as a GZIPed XML. It has the same property that you only need to know it is encoded to recover the original. The main difference is that Fast Infoset is customized for XML and leads to better encoding and decoding times.
link here
description
open source java
do you guys think java will be used in linux more if java is open sourced or will dev's stick to c/c++.
also what are your resources for computer related news?
link here
desription
One way to think of Fast Infoset is as a GZIPed XML. It has the same property that you only need to know it is encoded to recover the original. The main difference is that Fast Infoset is customized for XML and leads to better encoding and decoding times.
link here
description
open source java
do you guys think java will be used in linux more if java is open sourced or will dev's stick to c/c++.
also what are your resources for computer related news?
Wednesday, June 02, 2004
Re: To be or not to be virtual
Even I personally like the C++ style. And I think you hit the nail on the head by talking about designer control. Java partially forces you to adhere to a particular style whereas C++ can fit quite a few roles.
As far as the Design of C++ is concerned Bjarne put it best "Simplicity was an important design criterion: where there was a choice between simplifying the language definition and simplifying the compiler, the former was chosen."
I think Java went too far with the above, this is just a personal opinion, but everytime I write code in Java, I feel that I'm being spoonfed and that ultimately it seems like the design fits the language rather than the language fitting the design.
Dinesh.
As far as the Design of C++ is concerned Bjarne put it best "Simplicity was an important design criterion: where there was a choice between simplifying the language definition and simplifying the compiler, the former was chosen."
I think Java went too far with the above, this is just a personal opinion, but everytime I write code in Java, I feel that I'm being spoonfed and that ultimately it seems like the design fits the language rather than the language fitting the design.
Dinesh.
Subscribe to:
Posts (Atom)