Java API and Microsoft's .NET API: a Comparison
319
Nerval's Lobster writes "Previously, developer Jeff Cogswell focused on the respective performances of C# and Java. Now he's looking at yet another aspect of the languages: the runtime libraries—what exactly the libraries are, how they are called, and what features the languages provide for calling into them. Examining the official Java API (now owned by Oracle) and the official .NET API owned by Microsoft, he finds both pretty complete and pretty much a 'tie' with regard to ease-of-use and functionality, especially since Java version 7 release 6 allows for automatic resource management. Read on and see if you agree."
I don't want to be "that guy", however (Score:4, Interesting)
Re:I don't want to be "that guy", however (Score:4, Interesting)
Microsoft has had the benefit of being the single controller of the .NET framework whilst Java has been victim of design by committee a lot of the time. This is why the .NET framework has managed to stay tidier and more focussed, but as I said in my other post what does it matter, because who the fuck sticks to just the core framework anyway when there are things like Spring out there?
Re: (Score:2)
Anybody who isn't a massive corporation is better off sticking w the core framework for maintainability & scope purposes.
Re:I don't want to be "that guy", however (Score:5, Insightful)
Re: (Score:3)
Applets are still freaking good.
Look at for example: http://jchart2d.sourceforge.net/applet.shtml [sourceforge.net]
I can get a full demo of the application in my web browser, how cool is that. IMHO the browser developers sunk Java Applets, because of their concentration to Flash and JavaScript. Java Applets are still way better then what you can do with JavaScript. For example, 3D with OpenGL, and it don't take 50% of my CPU like with JavaScript.
Open source is one of the strongest points of Java. There are now 500,000 open s
Re:I don't want to be "that guy", however (Score:5, Interesting)
Re:I don't want to be "that guy", however (Score:5, Interesting)
Microsoft has also had the benefit of Anders Hejlsberg being the lead architect, one of the best minds in the industry. There are maybe a handful of people in the industry today that can stand at the same level as him, and none currently alive that can stand taller. Hiring him away was a major boon to Microsoft and a crushing blow to Borland.
As much as I love to code in C#, I think that Martin Odersky is at least as smart and knowledgeable as Anders Hejlsberg. I've seen them debate each other and IMHO Martin came out looking somewhat better. And Scala is no small feat.
Re: (Score:2)
"who the fuck sticks to just the core framework anyway "
Someone who needs a solid and consistant application platform?
Re:I don't want to be "that guy", however (Score:5, Funny)
In closing, C# .NET > Java.
Please address .NET hate-responses to /dev/null
Your windows environment has /dev/null?
How cool is that?
Re:I don't want to be "that guy", however (Score:5, Funny)
Re: (Score:2)
Re: (Score:3)
Yes, although we call it NUL: or \Device\Null
Re: (Score:2)
Re: (Score:2)
As a matter of fact, it does. I mean, strictly speaking it's at \\.\C:\Windows\SUA\dev\null, but according to bash: /dev/null /dev/null
/dev/fs/C/Windows/SUA/
$ ls -l
crw-rw-rw- 1 +SYSTEM 0 48, 0 Dec 5 2012
$ uname -a
Interix Jayne 6.2 10.0.7063.0 authenticamd AMD64_Family_21_Model_2_Stepping_0
$ echo $SUA_ROOT
Re:I don't want to be "that guy", however (Score:5, Informative)
While Mono allows C#, it does not turn .NET into a cross platform executable environment. Practical programs using C# and .NET are tightly tied to Windows capabilities. Since C# isn't a standardized language, and Microsoft doesn't even stick to their own standards with their own products anyway, there will be incompatibilities between Windows .NET and Mono. Mono also does not re-implement all of the .NET framework and is playing catch up whenever there's a new inevitable .NET release. So if you want a cross platform executable system you are much better off with Java.
Basically the whole reason for existence of .NET was to tie the developer to Windows. It was created as a direct response to Java being a cross platform system.
Re:I don't want to be "that guy", however (Score:5, Informative)
Re: (Score:3)
Wake me when C# programs run on anything other than Windows. GP is absolutely correct---if you actually try to use Mono for anything serious, you realize how quickly it starts to suck.
Re: (Score:3)
Wake me when C# programs run on anything other than Windows. GP is absolutely correct---if you actually try to use Mono for anything serious, you realize how quickly it starts to suck.
I can't run a program written in C++ on every platform. Doesn't make it not a standard.
Re:I don't want to be "that guy", however (Score:5, Insightful)
ISO is no longer a standards body in many people's opinion after some of their previous dealings with Microsoft. They can quite obviously be bought.
Re: (Score:2, Informative)
The reason for .Net is not to tie developers to Windows. Microsoft just doesn't care about developers on other platforms. It's not malice, just laziness.
That said, it's important to know where .Net came from. Others have already pounced on the C# standardization comment, so I'm going to skip that part, but here's the rest as best as I can figure it out.
In the early 90's, Java became a thing. And it was good. Slow, but good. It steadily improved, and eventually, the hype wave washed it ashore on Windows-land
Re:I don't want to be "that guy", however (Score:5, Insightful)
This is the wrong question. What matters is the quality of the apps that are written in either language. In that respect C# is way ahead on the desktop, but in other areas Java is king.
Re:I don't want to be "that guy", however (Score:5, Insightful)
I am both a professional java and C# developer. Each one has their advantages:
On the C# camp:
* delegates and events
* functional constructs
* automatic variable types
* LINQ
* Value types (efficiently allocate thousands of value objects in an array, you need some really nasty workarounds in java)
* Generics that keep their types at runtime
On the java camp:
* Spring (There is Spring.Net, but lets be honest: it does not compare)
* Collections library (much more complete and better thought out than C#'s)
* Maven
* J2EE
* A million other libraries freely available, that do _anything_ you want.
* Portable to more platforms (Mono sometimes leaves something to be desired)
So in my humble opinion, C# is much more complete as a language, but java has much better libraries and community. So which one would I pick? well, it depends on the project, the platform, and the amount of code I can reuse from open source libraries.
Re: (Score:2)
And since the OP brought up "robust",
* Checked exceptions.
Re: (Score:2)
I don't use C#, however last I looked all of its features were borrowed from other preexisting languages, same as Java. Is there something new and Microsoft for once in its life has done something novel?
Re:I don't want to be "that guy", however (Score:5, Informative)
I don't use C#, however last I looked all of its features were borrowed from other preexisting languages, same as Java. Is there something new and Microsoft for once in its life has done something novel?
LINQ is a pretty big deal. I don't know of any language that has something similar. LINQ itself is comprised of a number of language constructs such as expression trees, extension methods, type inference, anonymous types.
Async/await is huge! Right there, MS looks to leapfrog other platforms by allowing developers to create robust, asynchronous programs that doesn't need to spin up threads (or use threadpools) to achieve perfectly composable asynchronous methods.
Dynamic support (statically typed to be of dynamic type) allows the best from dynamic languages to be used from within C#, even interop'ing with dynamic languages and e.g. use an object created in Ruby as a first-class object in C# (or vice versa).
Re: (Score:2)
To be fair async still uses threadpools and you have to be careful how you use it so you don't starve it but yeah Linq, async and dynamic are all big deals. I'd also add how maintained it is. Thinking of the recent java volunerablity they new about it for something like 8 months I think before patching it. As bad as MSs rep is I don't think they would do that. Their ecosystem revolves on tools and platforms to keep the windows and Office (and SQL and sharepoint) the platform of choice for IT/devs. What does
Re: (Score:2)
To be fair async still uses threadpools and you have to be careful how you use it so you don't starve it
That is incorrect. async does not use thread pools. Async by itself says nothing about threads, and - more importantly - it will NEVER spin up a thread or take a thread from a threadpool by itself.
It is true that you can start parallel execution yourself and then use async/await to synchronize, but async/await is really a more fundamental concept compared to threads.
Re:I don't want to be "that guy", however (Score:4, Insightful)
Especially since what it actually does, doesn't seem to match up with what they tell you it does. At least in the simple cases they use for examples.
Citation needed. Care to elaborate?
Grand Central Dispatch has had similar functionality. The key differences being that Await has more concise syntax for the simple cases, but it gets progressively uglier the more complicated your cases become (such as awaiting a group of tasks that can all be done in parallel to each other
You mean like
await Task.WhenAll(task1, task2, task3); ?
You find that too complicated? I am curious how you would make that code simpler in Java, Objective-C or C?
GCD's syntax starts off somewhat ugly
Indeed
..., but doesn't really change as you do more complicated things, partly because the syntax already assumes you probably want to use blocks/lambdas by default so you can spin off 2-3 lines of code that don't really need a full function.
Apart from being verbose and ugly, GCD still does not solve the problem with composability of asynchronous operations. GCD is the equivalent of TPL (Task Parallel Library) in .NET or Futures in Java.
Re: (Score:3)
If you look at the lambda examples from Java 8 it looks like the collections API now mimic LINQ.
But still no expression trees and no ad-hoc anonymous types so nothing resembling LINQ to Entities, LINQ to Twitter etc.
Dynamic support in Java is called Invoke Dynamic and available in Java 7.
The dynamic support in Java is in the VM only. You cannot use foreign language objects as first class objects from within Java. Essentially, Javas dynamic support was created to make dynamic languages on the Java VM platform not suck. It is not a Java language feature.
C#s dynamic feature is support for dynamic languages the same way, but also lets you create objects in a foreign language a
Re: (Score:3)
Async is (or was) a pretty standard feature in some languages and run time systems and operating systems. Usually it's just a library or operating system you can use, but ya, that's not integrated into the language itself. But consider Ada with asynchronous transfer of control. Erlang has asynchronous stuff, but maybe that looks too much like message passing. Certainly Smalltalk allowed you to have blocks executed asynchronously. Though it all depends upon what your definitions are, it's too easy to say that it's just boring old message passing and it's not really in the language unless there's some special syntax for it.
Async in the context of C# usually refers to async/await [microsoft.com]. If you're familiar with PL concepts, the concise way to describe it is that it takes a sequential algorithm, and rewrites it in continuation-passing style for you, with continuation boundaries explicitly determined by where you put 'await" in your code. E.g. consider this:
This code is just reading two lines synchronously, blocking the thread between two reads waiting
Re: (Score:3)
Please address .NET hate-responses to /dev/null
You would have more luck with that if you'd actually had some substance in your post. You basically said, "I like .NET better than Java," but didn't explain why.
.NET framework is more robust than Java. Of all the reasons I could think of for supporting .NET over Java, that is not one of them. What makes you say it's robust?
Specifically I'd like to hear why you think the
Re: (Score:3)
However, I mostly code in C# .NET and I dabble in Java in my spare time to model financial markets. What I have found is that C# has some powerful features that other languages do not have. This allows the .NET framework to be a little more robust than Java. Also my opinion is that C# and .NET creates a more syntactically elegant and coder friendly experience whereas Java is good, but not as good as .NET.
In closing, C# .NET > Java.
Please address .NET hate-responses to /dev/null
I'm not saying its the case here, but often the best framework is the one you know best. Of course that is true for you personally, but its sometimes hard to distinguish "I'm not sure how to do it with that API" to "that API is not as clear as the one I know well".
Re:I don't want to be "that guy", however (Score:5, Informative)
Java is actually not "entirely OOP based" although it's close enough for most purposes. Example:
17.ToString()
works in C#. It (or the eqivalent 17.toString()) does not work in Java.
In .NET, everything is an object. "int" is another name for Int32, which is a struct (stack-allocated, value-passed object) that inherits from Object and implements a number of interfaces (IComparable, etc.).
Re:I don't want to be "that guy", however (Score:4, Funny)
In .NET, everything is an object.
Unless it isn't, of course.
As much as I like Java... (Score:2)
As much as I like Java, there's a few obvious features that it's somehow still missing:
C# has all of these, of course.
Re: (Score:2)
Re: (Score:2, Informative)
Huh? I thought java did have multidimensional arrays.
No, Java allows you to declare arrays of arrays - also called "jagged" arrays because not every "sub-array" need to have the same length (you can assign different arrays after initialization). Arrys of arrays are not multidimensional arrays, however.
C# allow you to declare both "jagged" arrays of arrays as well as true multidimensional arrays.
In some (limited) situations the true multidimensional arrays will slightly outperform jagged arrays. This happens if you mostly access random cells of the array. In t
Re: (Score:2)
Out parameters -- my favorite feature of C# over Java.
Re: (Score:2)
Or Iff in VB. That is the beauty of .Net built in support for a variety of languages. I've had at times used C# FOSS controls in VB projects and vs versa. You're knowledge of the platform transfers ridiculously quickly. We still don't get cross language projects but it is just a matter of picking the pieces to put in which libraries well and a old VB hack can work alongside someone using C# or whatever.
Re: (Score:2)
Distint signed and unsigned variants of all integer types (handy for interop with native code, and occasionally for other things), "using" blocks (forces an object to be cleaned up when it goes out of scope, instead of whenever the garbage collector gets around to noticing that it's out of scope), destructors (no, Java finalize() does *not* count), lambdas (and delegates in general; the closest thing Java has to a simple function pointer is ridiculously verbose), LINQ or anything like it, better generics th
Re: (Score:2)
Comments aren't good enough? If some code is going to throw exceptions on a ragular basis and these exceptions aren't documented, that's not code I want to be using.
On the flip side, it pisses me off to need to write try-ignore wrappers around code that I know will never throw the exception in question.
What did you expect? (Score:3)
Re: (Score:2)
How exactly was MS blocked from using Java?
Or do you mean their attempt at embrace, extend and extinguish known as J++?
FWIW, I like both languages, but they have entirely different markets. Windows-only? C#. Multi-platform? Java (Mono is no full C# .NET substitute).
Re: (Score:2)
> How exactly was MS blocked from using Java?
By court order, IIRC.
Re:What did you expect? (Score:5, Informative)
No, they weren't blocked from using Java.
They were blocked from creating their own non-standard Java.
Because Sun owned the trademark and the standard. Now owned by Evil Larry.
You can create your own language and API, but you can't call it Java if it doesn't meet the standard. How difficult is this to understand?
Poor persecuted Microsoft.
--
BMO
Re:What did you expect? (Score:5, Informative)
C# was the direct result of MS being blocked from using Java,
No, no it wasn't.
It was that Sun owned the standard and told Microsoft to quit violating the standard or call it something else.
Sun sued and won in court, because they were right.
If the situation was reversed, I'm sure you'd be saying Microsoft was in the right for defending C#.
Microsoft was always free to use Java and write their own version, as long as it conformed to the standard. But Microsoft being Microsoft, "standards are for pussies."
--
BMO
Re: (Score:2)
Re: (Score:3)
MS's extensions were to make it easier to write code that only ran on Windows.
Re: (Score:2)
Bingo. This is generally known as 'extend'.
Critical Bugs (Score:3)
C# does not appear to have 40 Critical bug fixes every quarter like Java does either. The latest Java update has caused a _lot_ of business systems to crash.
Re: (Score:2, Informative)
C# does not appear to have 40 Critical bug fixes every quarter like Java does either.
Sure they do [lmgtfy.com]. The flaws aren't in the language (with Java or Silverlight), after all, if you're running a program on your local machine in either of those languages, they're designed to give you access to the filesystem, etc. the flaw in the idea of trying to run foreign code on a local sandbox. Good luck.
Re: (Score:3)
C# does not appear to have 40 Critical bug fixes every quarter like Java does either.
Sure they do [lmgtfy.com]
You need to do better than that. Try secunia:
Silverlight 3: 2 vulnerabilities
Silverlight 4: 7 vulnerabilities
Silverlight 5: 4 vulnerabilities.
Hardly the swiss cheese that is Java applets.
Re: (Score:2, Troll)
There are ciritical fixes released for the .net API every so often via windows update. Neither are flawless in that regard.
It seems to me that Microsoft tries hard to make sure that updates to the framework dont break existing programs, whereas it doesnt seem like Oracle even makes an attempt.
Re: Critical Bugs (Score:5, Informative)
There are ciritical fixes released for the .net API every so often via windows update. Neither are flawless in that regard.
True, neither is flawless.
But one of them appears to have been considerably better designed (or better QC):
.NET 4: 34 vulnerabilities Released 2010-04 [secunia.com]
Java 1.7: 216 vulnerabilities Released 2011-07 [secunia.com]
or the previous incarnations:
.NET 2: 53 vulnerabilities Released 2006-12 [secunia.com]
Java 1.6: 432 vulnerabilities Released 2006-01 [secunia.com]
Java experiences 6-8 times the number of vulnerabilities, even over shorter time frames.
Re: (Score:2)
Java experiences 6-8 times the number of vulnerabilities, even over shorter time frames.
Leading to a statement even more unique than "Hold the newsreaderâ(TM)s nose squarely, waiter, or friendly milk will countermand my trousers":
If you want to be safe, go with Microsoft's product.
Re: (Score:3)
Re: Critical Bugs (Score:4, Informative)
95% of those java bugs are for the browser plugin. Last time I checked, activeX didnt have a great track record either. They both find about the same amount of server issues. .Net just sells their extra vulnerabilities to the NSA rather than fixing them.
No they are not. They are all over the runtime and library: Libraries, Hotspot, JavaFX, AWT (many), 2D, serialization, reflection, JAXP, RMI, beans, JAX-WS, etc etc. They are amplified by the fact that many of them are indeed in a library/feature that can be accessed through applets from remote. But the vast majority of the vulnerabilities exists isolated from the applet and could be exploited through other channels.
ActiveX has nothing to do with .NET.
And even so, there has been precious few vulnerabilities in ActiveX. The problem with ActiveX was that the model allowed foreign code to execute non-sandboxed on your machine, so that a bug in a control could have (and had) dire consequences. In that regard, ActiveX resembles SUID on *nix: You check at the gate and if the subject appears to have legitimate papers you let him in and assume that he'll be well-behaved. Just like with SUID where a bug in a SUID root tool may lead to system compromise, a bug in an ActiveX control could let the attacker run his own code with your credentials.
I hate them both (Score:5, Interesting)
As they are the harbingers of the new age, post dotcom world, where overspecced hardware fixes everything, where there are legions of entitled douchebag "developers" who took a certification course, and of apps which can't run in less than 8GB of memory (our resident BOFH hung up on our developers when they asked for a 64GB VM because they kept getting OOM errors in Java).
In short, both languages rode the crest of the cultural revolution where it is now OK to suck, to offshore code development with no expectation of quality coming back, of "agile" methods where your next version is always going to be the stable one. I'm not exactly saying that these languages CAUSED any of this, but there is at least a temporal correlation.
Yes, I am a Unix guy, and yes, I have grey hair.
Re: (Score:3)
If I only had mod points....
Also a grey hair here however C# has been paying the bills lately.
Re: (Score:2)
Ok, I'll bite . . . so is there anything that you do like . . . ?
Re: (Score:2)
Ok, I'll bite . . . so is there anything that you do like . . . ?
I'm guessing based on his comment, probably C, maybe even some assembler.
Re: (Score:2)
Re: (Score:3, Funny)
Re: (Score:3)
Yeah, because ASM is the only alternative. Eyeroll.
"Grandpa" is right. We've traded an awful lot of bloat for ... what, exactly? Vague promises of improved developer productivity? The outright lie of simplicity?
He may not be willing to blame the languages outright, but I'd back him up if he did.
Language is not the problem... (Score:3)
Let me say that it is easy to create GREAT systems in Java (and I assume in C#/.NET). However, in enterprise world, that seldom happens. That is not because of languages, but because of several management related issues:
1. Technical excelence is rarely seen as a goal, implementing features is.
2. Technical fixes do not drive development, satisfying business requirements does.
3. Things are rarely if ever refactored, consolidated or tidied up, as business doe
Re: (Score:2)
So my coworker used some funny introspection workaround to get that private field.
WFT, Microsoft?
Did you think that the private modifier is a security feature?
Re: (Score:3)
yeah, RAM is expensive - especially when your server will only stack a fixed number of sticks in there, and its being shared with several other teams. (and before you say "buy another server", you have to consider the up-front cost of it, plus the maintenance contract with the supplier plus the electricity to power it and the aircon - and electricity certainly isn't cheap nowadays, especially when you go down that road, because next thing you know, each team will want their own, and then some will want 2 or
What C# have that Java sorely lacks (Score:4, Informative)
Async methods (huge!)
Generator methods
Partial classes/methods
Reified generics
LINQ (as in LINQ to objects, LINQ to Entities, LINQ to XML - all part of the core framework)
Dynamic typing and -interop
Value types
Operator overloading
Implicit/explicit type conversions
Re: (Score:2)
Don't forget properties as a first class concept.
Re: (Score:2)
Properties as they are now in C# are a great idea - you don't need a private member variable backing them. They're now just member variables with the option to have different access control for reading an writing (e.g., public get, private set) and the option to hook in some code on get or set on those rare occasions when you need to. It just needs to evolve a bit further now to eliminate the distinction between members and properties and we're set.
Re: (Score:3)
The distinction is rather important. A property is a semantic construct. It has a meaning. A member is an implementation detail.
Its the same with Events and Delegates. While they do have some technical differences, the main difference is a semantic one. An event is a semantic way to interface with an object. A delegate is an lower level construct often, but not always, used in the implementation of an event.
Re: (Score:3)
...
...
LINQ (as in LINQ to objects, LINQ to Entities, LINQ to XML - all part of the core framework)
This is my biggest gripe with TFA: He says "the data access APIs are complete, and you can effectively accomplish the same thing". Sure, you could, with only a slightly smaller amount of code than accomplishing the code in C. The ability to both filter data and synthesize new records through combination easily, even as a feature of the standard library, is powerful. That it is a syntactic feature is amazing on the order of Perl making regular expression literals a thing. Java has absolutely no construct th
Re: (Score:2)
You can add lambda expressions as well, although, that's coming in JRE 7, no, 8 maybe.
Yes, lambda expressions - and expression trees (Score:2)
You can add lambda expressions as well, although, that's coming in JRE 7, no, 8 maybe.
Yup. I actually forget how often I use those.
Recently we have also seen expression trees put to good use, e.g. in Entity Framework code first to define relations, keys etc.
Re: (Score:2)
"Async methods (huge!)"
NIO / NIO2 ? I'm not sure what you're referring to. You can write anything you like with things like Runnable or Executor's.
Not even close. [microsoft.com]
Async/await are language extensions that allow you to write asynchronous code as if it were synchronous. Note how it is NOT about parallel/threads (although that is also a use case) but a much more fundamental concept of asynchronicity. As such you can compose asynchronous calls with branches, loops, try-catch blocks etc. Without such language support you will have to rely on futures/promises that are implemented in separate methods. Thus, you cannot easily loop over such futures/promises a
Re: (Score:2)
Java does have them:
http://docs.oracle.com/javase/6/docs/api/java/util/concurrent/ExecutorService.html [oracle.com]
http://docs.oracle.com/javase/6/docs/api/java/util/concurrent/Future.html [oracle.com]
But your comment over the wieldiness of one over the other baffles me. Fundamentally, Java's futures should operate in the exact same way as C#'s version with the same caveats. Do you know any real world example to help clear up this dissonance?
Once again, its part of the standard library without needing to change the language's syntax
Re: (Score:2)
What you linked is similar to the TPL in .NET, which is also part of the standard library and not language constructs. They're very useful.
Async/await is a way to make these things a first class concept of the language, so that once you have fairly elaborate scenarios/continuations, you can still read the code from top to bottom.
Amusingly enough, the best examples of these concepts I've seen to explain them aren't in the C# documentation, its in CoffeeScript. IcedCoffeeScript rather. The later also implemen
Re: (Score:3)
"Generator methods"
I'm assuming you're talking about re-implementing common framework service implementations, and if so Java has a ton of non-standard techniques to do this that most developers work with. It'd be nice if they were more consistent of the implementation though.
No, I'm talking about the ability to create methods that use the yield return and yield break syntax to implement infinite sequences or just allow me to yield items of a sequence and allow the consumer to process each item as it is produced rather than creating the entire sequence before returning.
http://msdn.microsoft.com/en-us/library/vstudio/9k7k7cf0.aspx [microsoft.com]
Re: (Score:2)
Well, looking it over, it does save on either performance or writing extra boiler plate to create an interator that stores loop processing state itself, but it seems like something that I'd use very sparingly, or more likely end up implementing it in different ways anyways. Leaving the code as such seems finnicky to me considering that either the inner or outer blocks could mutate the control flow (Like iterating over a list while adding/removing entries from it as a side-effect).
And just a side note, takin
Re: (Score:2)
You can and its rather frequent in C# to have them. Not too different from using an iterator within an iterator. Common, basic stuff. The yield operator is just syntax sugar to easily create iterators. They're used roughly for the same thing, but are closer to their semantic idea.
Since C# has quite a few functional constructs, having an easy way to create an iterator/generator is critical to keep the code clean, as they're used all over the place. In LINQ, they're basically in every methods.
Disagree about ease-of-use (Score:3, Insightful)
I use both, and I find that .NET really shines when you're in unfamiliar territory and working with a part of the framework that you don't touch every day. Features are more easily discovered and idioms tend to be more consistently applied in .NET, whereas it feels like Java suffers from implementers applying the pattern du jour, forcing you to wade through more docs.
I attribute much of .NET's success in this regard to the absolutely awesome book "Framework Design Guidelines: Conventions, Idioms, and Patterns for Reusable .NET Libraries," which includes a lot of direct insights from the designers of the framework. Microsoft has been really good about sticking to those guidelines, and it shows.
http://www.amazon.com/Framework-Design-Guidelines-Conventions-Libraries/dp/0321545613 [amazon.com] ...or maybe I just understand the .NET Framework better because I read that book. I'm not aware of a Java corollary that would give me the same insights, though.
Re: (Score:2)
Re: (Score:2)
You have the same thing on C#. What docs are you looking at that doesn't have plain hierarchies with links to every class and full docs with examples? I use it every day.
I'll agree with the "drama" if you're using winforms and vb.net though. Long time .NET users have been burnt a few too many times by those environments, so they get emotional about them.
Short version (Score:2)
Both have big APIs.
Re: (Score:2)
Async methods (Score:2)
I'm wondering how C# async methods got skipped. Because there's nothing similar in Java?
Async/await is huge. It makes composing async methods as terse as regular synchronous code. Unlike with the library defined task/future models, async/await adds a composable model which lets you write async methods that can loop, branch, try-catch etc. while staying perfectly async.
Lots of misconceptions (Score:2)
I was hoping to provide some insights, but the article is just riddled with misunderstandings. I stopped reading after this line:
"Generally speaking, the API makes use of properties in the case where you supply a class or object; but the classes in the API typically donâ(TM)t make use of properties."
No, not at all. Properties are used pretty much everywhere in the API. Examples abound with get only properties (ahem Length?).
Methinks Mr. Cogswell is in way over his head. Language design is not an easy s
Re: (Score:2, Funny)
Damn my Java client!
Re: (Score:3)
Re: (Score:2)
BASIC forever muddafuggas !
Re: (Score:3)
Maybe I'm a corporate drone that can only do so much as advise my superiors that either choice is wrong, but they receives "gifts" from either company.
Re: (Score:2)
Re: (Score:3)
it has specifically licensing it to the public and has the capacity to shutdown Mono at any time.
*sigh* unfortunately this comment is going to attract a lot of MS chills repeating ad nauseam phrases like "community promise" and "estoppel".
You are obviously aware of it, so why do you continue to spread this FUD? I find it especially ironic in a discussion about comparison between Java and C#, where only one of the vendors have actually tried to sue. And it is not Microsoft.
The history with the community promise is that first Microsoft submitted C# and the core libraries to ECMA and ISO for standardization. In doing so Microsoft committed to offer license for any patents essential to implementation under RAND terms (Reasonable And Non Discrimi
Re: (Score:2)
Easy. Mono + Apache. Have done it with our vertical market product.
Re: (Score:2)
Re: (Score:2)
Um, as someone who is somewhat (but not only somewhat) familiar with generics in both systems, I don't see anything in TFA's explanation which is misleading or incorrect, nor contradicted by your link. Care to elaborate on what you mean?
I can help. The author claims this:
That is wrong. In Java, type checking happens at *runtime*. During the type erasure the compiler will add downcasts into the code which will be evaluated at runtime. When a collection has been declared with i
Re: (Score:2)
You're right, the article does a pretty accurate reflection of the realities of both systems. I'd love to have runtime generics to work with under very rare conditions, but just as the article mentioned, there are workarounds that lead to slightly less elegant code to do so. Mind you, this is generally only a problem for generalized frameworks more so than day coding tasks, but its still a nice to have.
Re: (Score:2)
OK... so is what you're saying that there is a greater difference between the two runtimes than what TFA says, because .NET doesn't have the possibility of heap pollution? Something like that?
Type erasure foregoes a number of constructs available with reified generics in C#:
* Support for primitive/simple and value types without boxing/unboxing overhead
* Ability to use typeof() operator (.class in Java) on generic parameters
* Ability to create new instances of generic parameter types (with the C# new() constraint)
* Ability to declare, throw and catch generic exceptions.
* No per-realization static scope. Statics behave strangely in Java generics as all realizations share static members.
There are o
Re: (Score:2)
One of the things that's always bugged me about Java generics: array allocation. The following code works in C#. It does not work in Java:
class bar<t> {
t[] baz;
public bar() {
baz = new t[10];
}
}
To make something like that work in Java (which I've had to do before), prepare to get your hands dirty with Reflection or to be doing a lot of explicit c
Re: (Score:2)