DiGuru said:
I can't test that now, but I'm pretty sure that will give you the name of the thing. Like, Keys.Numpad8.ToString() gives "Numpad8", not "8".
...
Perhaps. But then again, I like things simple. That every object now has a ToString method (even the ones where that makes no sense) with multiple results can be very nice, but I really want to be able to use the simple things, like plain chars without having to dig through multiple objects to find them, as well. KISS. I don't want endless routines cascading through many objects when I want to do a simple thing.
Char has an explicit cast operator to and from the Keys enum from memory.. so (char)e.KeyCode should be '8' if memory serves.
Edit: For another example: try to write a file to LPT1:. If you want to do it by the books, you cannot, because the only thing associated with that is a CGI device to print stuff to a printer (a printer driver). You're specially forbidden to treat it as any stream.
hence C++.net
But at the same time, most containers accept any kind of data. It's (as an example) pretty hard to make a list (like the Delphi TStringList), with many properties and methods, that only accepts strings and still uses the .NET classes. And so the general methods support any data, and it depends on the context which specific method from what class is actually used. Which is again a form of automatic type casting.
List<string> ?
when making a generic (template) you can be even more specific than that.. such as only allowing class's implementing X interface, etc. .NET generics are very powerful things.
I've got this .NET 1.1 application running on my laptop, but when I install it on the computer from the client, it throws up an exception right away: System.TypeInitialization exception.
that is usually casued by something going amiss in a static class constructor. Take a look at the InnerException (which shoud definitly be set to something)
Java libraries are much better tested and documented, from my personal experience.
.Net has extensive xml-based in-code documentation (even forcable by the compiler) out of the box, all integrated into intellisense, etc. Java has had many competing tools that do the same thing such as xdoclet... but none really compare to the native xml doc that .net languages support (esecially in terms of ease of use). The quality of the documentation in the .net class library I feel is far superior to that of java. Also .net documentation integrates with IDE's better.
For a comparison...
the String class:
java:
http://java.sun.com/j2se/1.3/docs/api/java/lang/String.html
.NET:
http://msdn2.microsoft.com/en-us/library/System.String
and
http://msdn2.microsoft.com/en-us/library/system.string_members
compare something simple, for example the String(Char[]) constructors in each... There isn't really any contest, 2 sentences in java, about 3 pages in msdn...
A few things I want to say about .net compared to java...
Just remember, when comparing java to .net, java is a language with a class library. .NET is a platform that includes a class library (which in my opinion is superior).
Many people assume .NET is microsofts attempt to clone java. Well, no, not true. See it turns out Microsoft started the design of .NET approximatly 15 years ago. Hang on, java has been around about 12 years... hmm..
C# is the .net language most comparable to java (ignoring J#), although I'd say it almost has more in common with C++, and in my opinion it trumps java in every way. There is still an *awful* lot that the .net platform can do that C# does not expose (functional programming and SQL-like querys for example will arrive in C# 3.0). Taken on top of things like properties, delegates, good generics, attributes, etc, and C#/.net already useful-feature-wise has a significant advantage over java.
When directly comparing the java and .net libraries, it's my feeling that java is bloated and poorly designed, it's been a get-it-out, patch-it-later attitude. Where .NET has very strict style, naming and general design guidelines and quality control that get strictly inforced. Java I feel is quite loose in comparison.
The core java class lib is ok, but it's definitly not wonderful. There are far too many problems with general contradiction of the conventions, and also a somewhat unplanned feel. The simplest example I can think of is trying to write text to the console. This originally required 4 objects in Java (although with current versions this is less, as they have added more 'simplifing' objects - ie more bloat). The collections set, while now adequate, has been pretty poor the entire time. The original java collections were flat out crap, the full set of java collections in 1.2 (?) were definitly extensive, but their design was shocking. The stack class was just a vector with push/pop methods added (ie, stack extends vector). Granted things have changed (and there are now *far* too many collection related classes/interfaces), but still, it's taken them 10+ years and still java does not compare to .net generic collections (which are brand new). - imo java generics are appauling but thats another matter.
Don't even get me started on Swing, J2EE, etc. Possibly some of the most poorly designed APIs in recent history. Yet unfortunatly this isn't exactly uncommon in java.
simple case in point:
in .NET, fixed length array-style items have a 'Length' property. variable length items have a 'Count' property. In java this can be one of the folowing (and more): getLength(), GetLength(), length(), getSize(), size(), getCount(), count(), getItemLength(), get... etc etc.
Also I feel the .NET namespace naming convensions are far better. All standard stuff is stored in System, so thats almost always the first place you look.
For example, I recently wanted to find a mutex in java. In .NET thats System.Threading.Mutex. Easy. Logical. In java it turns out there isn't a mutex pre- java 1.5, the 1.5 mutex... well, I can't actually find it anymore.. it was buiried so deep, and in some obscure place that didn't really make any sense. Ohh well.
Also it simply comes down to bugs in the software. I have *countless* times been stumped by something completly whacky happening in java. Possibly the most rediculous is in Swing, where when you are using a GridBagLayout (ohh god! the horror) attached to a panel, even if you tell it explicitly to make the grid exacting pixel-by-pixel sizes, it still may resize itself without warning. The solution? well, turns out the only way to get around this bug is:
panel.SetPreferredSize( panel.GetPrefferedSize() );
Yup. Great. Obvious.
*sigh*
and don't get me started on J2EE. The weeks of my life wasted on that stinking pile of....
but I should stop myself. I don't want to start a java - .net flame war. These things are just personal preference. I've just had far too many bad experiences with java to even consider it anymore. Both are very capable tools, I just feel .net is the better one.