This set of documentation describes the new features of the C# language, including Generics, Anonymous Methods and Partial Types. Please note that this is a draft document intended to give you a preview of the “Whidbey” release of the C# language. Additionally, InfoWorld features an article which discusses the missing .NET implementation for Itanium.
looks like c# is going to get generics before java tiger. this is proof c# is better language. boo java, long live .net
this is proof c# is better language.
Can you explain why ?
For me, C# seems to be very similar to Java, but I’ve not looked at C# in detail.
C++ is a very powerful language, but it is also error prone.
Java is a much safer language, but it lacks many features of C++.
C# aims to combine the power of C++ with the safety and special features of Java. C# allows the use of pointers, but only in specific segments that are marked by keyword “unsafe”.
Java more mature? If by “mature” you mean “older”, I’ll have to agree with you.
But having used both languages, C# tends to annoy me less. Java, it seems, goes out of its way to annoy me. (Why? The @#$% requirement that public classes must have the same name as the file they’re within, and that directory names match package names. This single rule increases the difficulty of taking small test programs and turning them into larger programs, and sharing code between platforms (not all platforms are case-sensitive), and is generally annoying.)
Plus, Java 1.5 is borrowing features from C#. (Enums anyone? Though the Java version is slightly different, the intent and basic use is similar. Then there’s the “foreach” equivalent, “for (MyType t : collection) {…}”, and automatic boxing of builtin types…)
Plus, last I heard Java generics wouldn’t support the built-in types. So you can’t have a generic class instantiated for “int”. You can do it for the wrapper types such as Integer (they’re classes), but you lose any potential efficiency benefit. Yuck.
But I’ve diverged significantly. I find C# to be a very pleasant language to work with, with features that don’t annoy (as much), and allows me to keep my code closer to the problem domain.
That’s just my $0.02.
IMO .Net and particularly C# is the best thing M$ produced in a long, long time.
I din’t use C# jet, but I think MS’s hardware is the best they have produced ever: USB-Light-Mouse, Sidewinder, …
(But the software….)
try googleing
‘yield anonymous method’ and you’ll notice that the first 5 results are ruby-related pages.
And if you ever played with ruby for a while you’ll know that defining a class in two file is a basic feature of Open Classes.
MS is ripping matz’ language, not Sun’s one
C# is excellent because you don’t have to worry about low level stuff anymore, but you can still use native dlls, activeX and COM objects by just calling the functions that you need, this is especially important in real life situations where Code reuse is needed.
a collegue of mine had to call some win32 dll functions in Java via JNI. it took more than 2 days to get it stable. it seems Java goes out of its way to prohibit platform specific things, while with C#, the attitude is It Just Works.
Int
rowel: .NET is portable, it isn’t about running only on Windows. Does mono ring any bells?
I personally have worked with both languages, even though I have much more experience with Java, and quite frankly I think it all boils down to the first language you learned. If you learned using C/C++ and actually got really into it, then you will probably like C#. If you learned using Java first, then you will probably wonder about many things in C#.
I programmed very often in C/C++ when I was younger (I am 22 now) but in college the largest dose of the ciriculum was in Java. We had to take data structures in C++ and of course we learned assembly, ada, ml, and others but Java was the main thrust.
Having been programming mainly in Java but looking through C# I can honestly say that although I think C# has some nice “whiz bang” features, most of them invariably lead to badly designed code. Have you ever worked with Delegates before? I am sorry, but using += just is not RIGHT imo. And quite frankly, even though it is “nice”, the same can be done more elegantly using interfaces imo? Forcing the developer to name their classes the same as the file (besides anonymous inner classes, you know of course) is a good design idea. For as cool as operator overloading can be sometimes (and i sure with BigInteger could use it sometimes) it can lead to (and from the way C# is already going imo) very unreadable code.
I personally look at Java 1.5 as taking the best ideas from C# while ensuring that they weren’t used in a way to promote badly written code. I like Java 1.5 obviously, and I will continue to develop in it (when applicable) instead of C# unless paid to do otherwise or am stuck to Windows only and would like some particular C# feature (which has not happened yet).
Oh and btw Interfacer, I am not quite sure what the problem your friend had with JNI (I and many others have used it with no issues), but to say with C# It Just Works, sure it just works on Windows. Even take away the win32.dll specific stuff, any sort of GUI using Win.Forms is going to be stuck using Windows too (afaik Mono is not even planning on implementing that). Quite frankly if you need to be making call to win32.dll that seems rather low level for C# too, you are probably just writing unmanaged C/C++ code and calling/mixing it C# anyway.
“who cares about running on anything besides windows because 99% of the world use windows”
That’s a very arrogant attitude.
And you forgot OS X – try running your .Net EXE there.
But it’s your usual thing, your weekly ‘java=crap’ message.
java makes mistake in trying to run on every platform .net does it right. who cares about running on anything besides windows because 99% of the world use windows. the only person who cares is linux zealot who goes “portability makes java good because it lets me run java apps on linux” well guess what linux zealot java running on linux makes java apps suck for 99% of the rest of us.
Exactly, I could not have said that better.
And it is the same in a lot of domains. I am the webmaster of a big website, and fast every month, there is a Linux zealot who said that my website sucks, who critiize me beause my site has 4 frames, one with a pub in flash, one with a lot of nested tables and a lot of Javascript, one with a nice compter in Java, and one written in VBScript+asf.
I don’t even read what they say, I already know it : my site doesn’t perform well in the validator http://validator.w3.org/ , doesn’t work with browser nobody uses like lynx or telnet, and don’t respect the “standards” for accessibility http://www.w3.org/WAI/ ,… and all their usual propaganda
These people seems to live in a different world that our. My site looks better than my concurrents in IE, and IE is the standard used by 98% of the population. Point.
So just ignore them, and if we are lucky, they will get a life and come back to the reality.
I can already hear what they will answer : so you are for “One OS, One Web, One Program” ?
This question is irrelevant, this is already the case, and it’s not going to change.
PS: there is only good thing with Java. All their open source implementation of the JVM sucks (even’t implement AWT and Swing), so they have no other choice : they must install
a proprietary program, while they pretend proprietary programs are irrelevant.
looks like c# is going to get generics before java tiger
Wrong. Are you incapable of even comprehending the headline? This is merely the specification of C# 2.0, not a working implementation. The additional language features of Java 1.5 have been documented for some time, as has work on the actual implementation. We are certain to see a release of Java 1.5 before we see a .NET release supporting C# 2.0.
What’s the opposite of a linux zealot? A reasonable person? A lazy person? A microsoft zealot? A microsoft lackey? Can’t think of any other possiblities.
If you’re going to call other people names, what would you call yourself?
“This question is irrelevant, this is already the case, and it’s not going to change.”
Do I hear laziness, futility, or intentional desire to prohibit variety? It’s hard to tell in this forum, so please explain.
Do I hear laziness, futility, or intentional desire to prohibit variety? It’s hard to tell in this forum, so please explain.
I test different forms of trolls.
I quite like this one because you have sublimatory links to things I care, like the w3 validator for interoperability in the web and the link to the W3 Accessibility Initiative. If I wrote a serious post, they wouldn’t have notice.
Sorry for you. You are one of the few who try to improve the signal over noise ratio, but the current forums of OSNews just doesn’t work : too much bad trolls, kicked too late and arbitrary (Tells me what the difference between the first comment against Java, and the first kicked post against C#)
It’s sad, because I kinda like OSNews, but no matter how good Eugenia is, a moderation by the moderators just can’t work.
The reason people should follow w3.org’s standards is so noboby should be forced to use only what is availble. What if microsoft would be gone tomorrow? Then IE would not be improved and you would be stuck with alot of sites that cant improve.
Yes I know MS won’t be gone tomorrow. But nobody should think that way. Think open and give the user a choice.
But on the other hand. It will create more work for you in doing more for the site. But atleast you did it right and cared for the future.
What about dissibilities? People that cant read etc? If you follow w3.org, you will get info on how to help out.
That was quite a good troll. And yes, fairly typical of the sorts of nonsense you get on OSNews. The only thing I would have added was a little line about java being “horribly slow” using some java applet or desktop app as evidence, and saying nobody uses it (because it isn’t seen on the desktop) and therefore it is dead/dying and losing to .NET.
I wish people would realise that Java is essentially serverside and c# essentially aimed at the windows client. Each utterly outdoes the other in each domain, for the most part, and they are barely in competition until MS comes up with something remotely competitive with j2ee.
You managed to write one line about mine comment, then write several about how it COULD have been written, then complain about what I did not write… are you feeling ok?
Re: Bascule: what’s your definition of “release”? Final product, or beta? .NET v2.0 beta will be released within a month (at the next PDC, which I think is next week), so there will be a release of C# generics before the end of the year. A cursory search on Google for Java 1.5 release dates shows it also targeting the end of 2003 (though that headline was in March, so it could have changed), so I don’t think the release dates will be too different between them.
However, this is Microsoft, so .NET v2.0 isn’t likely to be released as a final product within a year…
However, Martin Baulig of the Mono team is working on Generics suppot for Mono; see: http://primates.ximian.com/~martin/blog/
Furthermore, Miguel has been working on the other C# 2.0 features, such as anonymous methods and iterators, and some of these are already present in mcs; just pass “-v2” to mcs to enable the new features. So it’s quite possible that Mono will have support for generics before it’s 1.0 release.
Re: w_ready: I’ll agree that it’s a nice policy for class names to match the file names. However, I dislike it being a requirement. It requires lots of work just to do simple things. (Rename a class? Now you have to rename the file. If you’re working with CVS, that means you either have to have access to the CVS repository to copy the current ,v file, or you lost CVS history on the class before the name change. Sure, maybe I shouldn’t use CVS, but I don’t have much choice right now.)
As for delegates, I prefer them by far to interfaes. This is primarily for three reasons:
1. I’m lazy, and don’t like writing more code than I need to. Delegates provide a closer mapping to how I think about the problem domain, and are thus preferable to me.
2. I’m lazy, and I find it difficult to come up with good names. Delegates nicely side-step the issue; you just name the delegate, not name the interface and the method. Yes, this is a silly reason.
3. Delegates make a good building block for events, reducing the code I have to maintain for event handling purposes. Less code is good.
However, my background is in C++ (7 years), and some use of Scheme, so I find it hard to think without using function pointers…
Anders Hejlsberg has a good comparison/overview of delegates. You might find it useful:
http://www.artima.com/intv/simplexityP.html
RE: JNI: I’m having problems with it at work. I’ve got a C++ library I’ve wrapped in JNI. It always works in C++ programs. I’ve run it under valgrind. It works fine. But when I use the JNI libraries, I’ll *randomly* crash the program. Even doing the exact same things, sometimes it’ll work fine, sometimes it won’t. I’ve gone as far as to print trace statements in the JNI code, and it always exits cleanly, but I still get process corruption issues. JNI, in short, does not impress me.
Will Mono adopt this specification?
If so how long will it be because they have not even released the first production version of Mono.
I wonder if the Mono team is going to keep up without more support, does anyone have any ideas?
I was reading up about ASP.net and it seems that they have a far nicer model than PHP, more consistency etc. so it seems having Mono would be nice for the Open Source world. Having a choice of ASP.net and PHP 5 is good?
Judging by the intelligence of your post, I am sure that you have done plenty of research for your problem. The only suggestion I would have without more detail would be to try http://forums.java.sun.com if you have not already, I have found lots of good information there.
Re: renaming interfaces and laziness, I agree about the renaming issue, I too use CVS and find this to be a pain. At least using Eclipse (or insert your favorite IDE that does basic refactoring), renaming things is easy but losing history does suck, but as you pointed out I really feel this is a problem with CVS, not Java.
I definitely agree that Delegates do make a good sidepartner to Events and Events are handled very nicely in C#, it is what Java’s Observable/Observer should be. Unfortunately Java’s implementation breaks many design rules.
As I said before, I really think it is pretty much a matter of taste and personal history and in many senses the languages are pretty equal , even though I do feel Java’s history with running on multiple OS’s is much more of a plus (and may I comment that as far as I have seen almost ALL write once break anywhere code was just poorly written code not a problem with Java not to say that they don’t exist).
I’ve answered this question before. Mono is aiming to track the new C# standard.
Martin Baulig is implementing Generics support; you can read about his progress at his blog at http://primates.ximian.com~martin/blog/. With any luck (a miracle?), it’ll be implemented for Mono 1.0, which is currently being targetted at the end of 2003/beginning of 2004.
Other features, such as anonymous methods and iterators (yield), have already been implemented (to some extent) in mcs. You need to pass the “-v2” flag to mcs when compiling. There are iterator example/test programs in the mcs CVS repository; see http://www.go-mono.com/anoncvs.html for details an accessing Mono’s CVS.
Partial class support is the one feature I haven’t heard about in mcs, though I imagine it’ll be supported eventually.
Nice improvements to the language. And now I need to stop drooling on my keyboard…
Thanks for the good news!
With Windows(TM), C# more louder!
—
NEVER X11.
I personally have worked with both languages, even though I have much more experience with Java, and quite frankly I
Having been programming mainly in Java but looking through C# I can honestly say that although I think C# has some nice “whiz bang” features, most of them invariably lead to badly designed code.
I am sorry but what “whiz bang” features are those?
Have you ever worked with Delegates before? I am sorry, but using += just is not RIGHT imo.
Delegates are fantastic, overloading the += operator to use them is not.
And quite frankly, even though it is “nice”, the same can be done more elegantly using interfaces imo?
How so? An interface would require you to user inheritance to do such a thing and it would also make it a lot harder to change the behaviour of “delegates” in runtime. Delegates are more akin to typesafe function pointers than anything else.
For as cool as operator overloading can be sometimes (and i sure with BigInteger could use it sometimes) it can lead to (and from the way C# is already going imo) very unreadable code.
Operator overloading is just a tool as anything else and can be abused but it does give a “completeness” feeling to the .NET framework, that everything is equal, no exceptions like in Java.
Oh and btw Interfacer, I am not quite sure what the problem your friend had with JNI (I and many others have used it with no issues), but to say with C# It Just Works, sure it just works on Windows.
Not only on Windows but on Linux too! .NET Interop is miles ahead of JNI when it comes to using shared objects or dlls. As long as you remember the marshalling rules (char * -> string, void * -> IntPtr etc.) it’s just a matter of typing. Automatic conversion from delegates to function pointers and back is all automatic.
Quite frankly if you need to be making call to win32.dll that seems rather low level for C# too, you are probably just writing unmanaged C/C++ code and calling/mixing it C# anyway.
That’s the beauty of .NET and C#. Intermixing is so easy it’s almost transparent!
I’ve worked on and am working on serveral projects for large corporations and large branches of government. They want .NET and they want it now. It surprised me, I expected J2EE to be the choice for the large scale projects at least until .NET had a few years under it’s belt. Now all our prelim calls for new projects start off pretty much the same way. “Do you have the resources to do this in .NET?”
Language independance. Enough said.
That just isn’t happening with Java. Off the top of my head, the only other major language I can think of that can use the JRE is Python.
Wrong. Are you incapable of even comprehending the headline? This is merely the specification of C# 2.0, not a working implementation.
Generics are already implemented in the public source code release (Rotor)
This looks good and all but it’s missing one valuable thing to make it a programming language. It need to be compilable. Currently, it is not, if you look at the facts. Until then, it really can not even come close to compete with C++.
“This looks good and all but it’s missing one valuable thing to make it a programming language. It need to be compilable. Currently, it is not, if you look at the facts. Until then, it really can not even come close to compete with C++.”
.NET languages ultimately produce compiled code. All code is compiled to native code before execution. This can either be done at installtime or runtime (the norm, which is great for cross-platform distribution and optimization because the code compiles on the machine on which it is executed)or it can be compiled before distribution (which limits it to same-architecture machines like C/C++, etc.).
C#, unlike Java is a standardized language, but some important libraries are not. MS will never let another Java-like threat rise again, like Mono.
People talk about Mono in vain in my humble point of view. Don’t get me wrong. It’s a nice project, but unless it forgets about .NET compatibility and becomes a better platform with it’s own personnality, it’s doomed to become an irrelevant .NET copy that’s not 100% compatible.
You can argue forever on the technical merits of Java and C#, but you can’t deny the fact that Java is letting you the choice of the platform while .NET/C# never will. .NET’s vendor/dictator has a lucrative monopoly, and the average joe is paying for it one way or another. So the more you deal with them, the stronger them become, and the more dependant (and screwed) you are. Enough said, dump them if you can, your freedom is at stake in the long run.
As mentioned before, its a design flaw. Your source is still open to whomever you give out your “application” to. So it compiles into “native code” in memory, big deal, that’s useless if it’s not compiled into “native code” before distrobution.
As mentioned before, its a design flaw. Your source is still open to whomever you give out your “application” to. So it compiles into “native code” in memory, big deal, that’s useless if it’s not compiled into “native code” before distrobution.
No, the source isn’t open. I think maybe you don’t understand bytecode?
Think of bytecode this way. it is machine code compiled for an archetecture that doesn’t exist in hardware, but rather exists in software.
The .NET framework is basically a hardware archetecture implemented as software. Java is the same. That’s why the runtime environment is called the Java Virtual Machine, or JVM.
So no, your source is not open with Java or .NET. It’s compiled to bytecode, which is machine code for a system that doesn’t exist as hardware, but rather as software.
Think of them as compilers designed for the Java computer, or the .NET computer.
“net gives u power of runtime environment without crappy portability restriction which makes app stick out, be ugly and slow and not work right problem of java. u cannot tell .net app from normal EXE it looks the same and when u click it it runs try that with java”
I did try that with Java. And I can do the same thing. Apparently you aren’t aware of the fact that Swing can be set up to look EXACTLY like a normal Windows application. The default Java “Metal” look is just that. A default. But Swing can be set by the programmer to emulate the Windows look and feel, in which case the end user can’t tell the difference.
And as far as being slow, it has been my experience from what little I have experimented with .NET, that .NET applications are slower than Java applications.
The code it is “compiled” to, MSIL, looks almost exactly like ASM. Are you saying we write bytecode when we write in ASM?
Well, I looked at it in both a hex editor and a normal text editor. It doesn’t look anything like ASM either way as far as I can tell.