Beta

Slashdot: News for Nerds

×

Welcome to the Slashdot Beta site -- learn more here. Use the link in the footer or click here to return to the Classic version of Slashdot.

Thank you!

Before you choose to head back to the Classic look of the site, we'd appreciate it if you share your thoughts on the Beta; your feedback is what drives our ongoing development.

Beta is different and we value you taking the time to try it out. Please take a look at the changes we've made in Beta and  learn more about it. Thanks for reading, and for making the site better!

Java API and Microsoft's .NET API: a Comparison

Soulskill posted about a year ago | from the similar-and-yet-not dept.

Programming 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."

cancel ×

319 comments

first (-1)

Anonymous Coward | about a year ago | (#44054593)

First one!

Re:first (2, Funny)

Anonymous Coward | about a year ago | (#44054685)

Damn my Java client!

Re:first (2)

iluvcapra (782887) | about a year ago | (#44054903)

2003 called, it wants its article back.

Oracle vs Microsoft (0, Troll)

ArcadeMan (2766669) | about a year ago | (#44054623)

Whoever wins, we lose.

Re:Oracle vs Microsoft (1)

Mitchell314 (1576581) | about a year ago | (#44054837)

'Win'? 'Lose'? They can't take away your choice to use a different framework/language on your own time.

BASIC forever muddafuggas ! :D

Re:Oracle vs Microsoft (1)

Anonymous Coward | about a year ago | (#44055325)

Apparently he's a corporate drone, he will follow one of these corporations blindly and unquestionably, the only thing to decide is which one.

I don't want to be "that guy", however (4, Interesting)

paysonwelch (2505012) | about a year ago | (#44054639)

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

Re:I don't want to be "that guy", however (3, Interesting)

Xest (935314) | about a year ago | (#44054695)

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:I don't want to be "that guy", however (1)

Synerg1y (2169962) | about a year ago | (#44054757)

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 (5, Insightful)

iluvcapra (782887) | about a year ago | (#44055043)

Microsoft also had the benefit of Java going first and making all the mistakes, and then Microsoft got lucky when Java lost its first-mover advantage chasing down several blind alleyways -- "Applets", Sun's mismanagement, a bureaucratic open source strategy.

Re:I don't want to be "that guy", however (1)

The End Of Days (1243248) | about a year ago | (#44054699)

I like C#. .NET is fine for what it is, although it's very apparent where the influences came from. Where Java absolutely wins, in my experience, is the sheer volume of libraries available. You can do damn near anything with some dependency declarations and a bit of glue code.

Re:I don't want to be "that guy", however (0)

Synerg1y (2169962) | about a year ago | (#44054711)

The file menu on Visual Studio is better than Eclipse's UI design & features as a whole. Imho, the languages are both entirely OOP based and are very similar in syntax and functionality.

Source:
I learned with AP Java moved on to ASP.NET in college upon introduction to it.

Re:I don't want to be "that guy", however (0)

Anonymous Coward | about a year ago | (#44055007)

In Visual Studio a SerialPort is a drag-and-drop item, even though you could just as easily instantiate and use one(or three) manually. With java you're stuck dicking around with third-party libraries like RxTx and jumping through hoops to get its basic functionality working.

The only aspect besides cross-platform interoperability where Java smashes C#, that I can see in my very limited experience, is that Java events and handling are much more simple. No tangled unreadable messes of delegates, updateCallbacks, overloaded operators, and inconsistent use of method() parenthesis conveniently omitted when methods are passed as parameters in the event handling structure. It's hard to get used to, and makes me want to choke the shit out of the people who thought all that mess was a good idea.

And I know fucking everything.

-- Ethanol-fueled

Re:I don't want to be "that guy", however (5, Funny)

OhSoLaMeow (2536022) | about a year ago | (#44054719)

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 (5, Funny)

Mitchell314 (1576581) | about a year ago | (#44054761)

Yes. It's c:\.

Re:I don't want to be "that guy", however (1)

gutnor (872759) | about a year ago | (#44055515)

C:/ where data goes to die.

Re:I don't want to be "that guy", however (0)

Anonymous Coward | about a year ago | (#44054799)

In closing, C# .NET > Java.

Please address .NET hate-responses to /dev/null

Your windows environment has /dev/null?

How cool is that?

One word: Mono. Perhaps you may have heard of it?

Re:I don't want to be "that guy", however (0)

Anonymous Coward | about a year ago | (#44054851)

Yes, we've all heard of Mono.
I can't imagine that anyone has it installed, though.
Either you use Windows, or you know better than to swallow that poison pill.

Re:I don't want to be "that guy", however (1)

Em Adespoton (792954) | about a year ago | (#44054871)

In closing, C# .NET > Java.

Please address .NET hate-responses to /dev/null

Your windows environment has /dev/null?

How cool is that?

One word: Mono. Perhaps you may have heard of it?

Heard of it, yes. Thankfully I've never got Mono.

Re:I don't want to be "that guy", however (4, Informative)

Darinbob (1142669) | about a year ago | (#44055387)

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 (2)

KingMotley (944240) | about a year ago | (#44055165)

Yes, although we call it NUL: or \Device\Null

Re:I don't want to be "that guy", however (0)

Anonymous Coward | about a year ago | (#44055475)

Your windows environment has /dev/null?

How cool is that?

Meh [wikipedia.org]

Re:I don't want to be "that guy", however (4, Insightful)

AmiMoJo (196126) | about a year ago | (#44054849)

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 (1)

Anonymous Coward | about a year ago | (#44055203)

Before we even start, let me say:
The whole point of .NET is deliberate and willful anti-competitive behavior. Because MS threw a temper tantrum like a four-year-old child after its attempt to murder Sun by EEEing Java failed. On those grounds alone it should be flat-out illegal.

Now on to the subject at hand:
Excuse me, but if you're still sitting in your tiny little box of primitive programming languages, you don't exactly get to laugh at other languages that are just as primitive except for some minute non-noteworthy differences.

If you had said Haskell or something equally advanced, I would have agreed. But this? This is just /silly/!

Also, what the hell is the point of a runtime machine that only runs on ONE OS which is also a consumer operating system? (Mono does not count as "running". Try running any .NET 4.x stuff on it.) Besides the aforementioned anti-competitiveness: NOTHING.

The end.

Re:I don't want to be "that guy", however (1)

Anonymous Coward | about a year ago | (#44055255)

Please address .NET hate-responses to /dev/null

I'm getting "Could not load file or assembly '/dev/null' or one of its dependencies" when I try that.

Re:I don't want to be "that guy", however (5, Insightful)

paulpach (798828) | about a year ago | (#44055289)

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:I don't want to be "that guy", however (1)

Darinbob (1142669) | about a year ago | (#44055309)

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 (1)

Anonymous Coward | about a year ago | (#44055447)

LINQ, PLINQ, and the TPL. Pretty wicked combo. Check it out.

Re:I don't want to be "that guy", however (5, Informative)

benjymouse (756774) | about a year ago | (#44055631)

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:I don't want to be "that guy", however (0)

Anonymous Coward | about a year ago | (#44055433)

Groovy smokes them both in terms of ease of use and features.

Re:I don't want to be "that guy", however (2)

phantomfive (622387) | about a year ago | (#44055533)

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.

Specifically I'd like to hear why you think the .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?

Eat sum open source W2K (0)

Anonymous Coward | about a year ago | (#44054671)

Try download that

Oh no (-1, Flamebait)

Xest (935314) | about a year ago | (#44054679)

Not this fucking idiot again.Hhe showed a complete and utter lack of knowledge and was thoroughly ripped to pieces here on Slashdot for it last time.

Why the fuck is he back poisoning our screens once more with his uninformed tosh.

For what it's worth no, they're not a tie and this just highlights once more how little a fucking clue this guy has on the topic. The .NET framework is far more fully feature than the core Java API and is frankly much tidier too (Date/Time handling for example) but it's irrelevant isn't it because who limits themselves to that? Most will use something like Spring to fill the gap anyway and yes, both languages have an insane amount of additional frameworks you can use that both similiarly do everything you'd ever want and then some.

As much as I like Java... (1)

MrEricSir (398214) | about a year ago | (#44054687)

As much as I like Java, there's a few obvious features that it's somehow still missing:

  • Signals/slots
  • Async methods
  • Properties

C# has all of these, of course.

Re:As much as I like Java... (0)

Anonymous Coward | about a year ago | (#44054729)

I wish C# had exception declarations or someone made a stable tool that would tell me what exceptions to expect.
And don't say ILDASM or a decompiler :P

Re:As much as I like Java... (0)

Anonymous Coward | about a year ago | (#44054869)

There is no such tool because it can't be done. The set of exceptions that can be thrown is a dynamic property of the code, it simply can't be determined at compile time. Java's exception declarations simply force people to add useless workaround to a useless restriction.

Re:As much as I like Java... (0)

Anonymous Coward | about a year ago | (#44054743)

I disagree that stuff like "Async methods" and "Signals/slots" should be in the language. This is more something for an API. Java has a great API for stuff like that in java.util.concurrent. AFAIK in .net those are just macro's expanded by the preprocessor.

Re:As much as I like Java... (0)

Anonymous Coward | about a year ago | (#44054779)

It's 2013, even C++ has std::async. If you want to stay in the 70's there's still vanilla C compilers out there.

Re:As much as I like Java... (0)

stenvar (2789879) | about a year ago | (#44054831)

There's more missing in Java:

multidimensional arrays
unsafe modules
easy interfaces to native code

Java also has some serious design errors, like its array types, its parameterized types, its exception system, and its strings.

Re:As much as I like Java... (1)

Mitchell314 (1576581) | about a year ago | (#44054881)

Huh? I thought java did have multidimensional arrays.

Re:As much as I like Java... (0)

Anonymous Coward | about a year ago | (#44055011)

If my memory doesn't fail me, there is a slight difference. Java has "array of arrays" whilst C# supports both.

Java:

int [][] array_of_arrays; // you have to initialize the outer array first, then each of the sub arrays later

C#

int [,] multi_dimensional = new int [3, 4]; // 3 rows, 4 columns multidimensional array

of course, the Java way is also supported in C#

Re:As much as I like Java... (0)

Anonymous Coward | about a year ago | (#44055175)

Java:
int [][] array = new int[3][4];
Seems to work fine.

Re:As much as I like Java... (0)

Anonymous Coward | about a year ago | (#44055251)

Huh? I thought java did have multidimensional arrays.

It does.

I think the GP was referring to easily accessing multi-dimensional arrays using a single offset, instead of splitting them into individual indices. This is possible in C/C++ because of pointers. I assume it's also possible in C#, if you use unsafe code.

Re:As much as I like Java... (1, Informative)

benjymouse (756774) | about a year ago | (#44055263)

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 that case the true multidimensional array will only require a integer multiplication and an array indirection. Jagged arrays will always require two array indirection accesses.

Re:As much as I like Java... (1)

naoursla (99850) | about a year ago | (#44055063)

Out parameters -- my favorite feature of C# over Java.

Re:As much as I like Java... (0)

Anonymous Coward | about a year ago | (#44055265)

Okay, it is an external library so it doesn't quite count, but BridJ [google.com] is probably about as easy to use as P/Invoke.

What did you expect? (2)

medv4380 (1604309) | about a year ago | (#44054739)

C# was the direct result of MS being blocked from using Java, and was their J# product re-branded into .net. The core is nearly identical with the exception that C# has access to things like DirectX, and a few other nice to have APIs from MS

Re:What did you expect? (1)

mwvdlee (775178) | about a year ago | (#44054909)

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:What did you expect? (1)

naoursla (99850) | about a year ago | (#44055077)

> How exactly was MS blocked from using Java?

By court order, IIRC.

Re:What did you expect? (5, Informative)

bmo (77928) | about a year ago | (#44055167)

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? (4, Informative)

bmo (77928) | about a year ago | (#44054989)

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

Critical Bugs (2)

thewils (463314) | about a year ago | (#44054749)

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: Critical Bugs (0)

Anonymous Coward | about a year ago | (#44054809)

There are ciritical fixes released for the .net API every so often via windows update. Neither are flawless in that regard.

Re: Critical Bugs (1, Troll)

Rockoon (1252108) | about a year ago | (#44054929)

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 (4, Informative)

benjymouse (756774) | about a year ago | (#44055083)

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: Critical Bugs (0)

stewsters (1406737) | about a year ago | (#44055543)

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.

Re:Critical Bugs (1, Informative)

phantomfive (622387) | about a year ago | (#44055551)

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.

I hate them both (5, Interesting)

Gothmolly (148874) | about a year ago | (#44054771)

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:I hate them both (2)

Elfboy (144703) | about a year ago | (#44054817)

If I only had mod points....

Also a grey hair here however C# has been paying the bills lately.

Re:I hate them both (1)

PolygamousRanchKid (1290638) | about a year ago | (#44054861)

Ok, I'll bite . . . so is there anything that you do like . . . ?

Re:I hate them both (1)

BitterOak (537666) | about a year ago | (#44054911)

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:I hate them both (0)

Anonymous Coward | about a year ago | (#44054959)

Web development? That's nice and lean and really well specified.

Now I need to replace my keyboard.

Re:I hate them both (1)

Mitchell314 (1576581) | about a year ago | (#44054995)

When you're trying to put food on the table in this economy, working as an inexperienced developer isn't what most would call being a douchebag.

Re:I hate them both (2, Funny)

hsmith (818216) | about a year ago | (#44055009)

Nice rant, grandpa. Yeah, we should all be coding in ASM, because it produces such better products! Eyeroll.

Re:I hate them both - me too (0)

Anonymous Coward | about a year ago | (#44055275)

This.
Also, I got a nice anekdote about the .NET-Framework:
Today I got to do XML processing. I needed to get the entity definition of a documents doctype.
It's totally possible to get that entity name - but it's not possible to get the content. To illustrate:

Entity:

Content:
(child-a|child-b|child-c)

So a coworker of mine used ILSpy (a .NET-disassembler) and we found out, that this content is saved in a private string.
The method InnerText was left unimplemented.

So my coworker used some funny introspection workaround to get that private field.

WFT, Microsoft?

Java has this kind of doucheness, too. Compare Unicode vs. property ISO-Encoding, for example.

Re:I hate them both (2, Funny)

The End Of Days (1243248) | about a year ago | (#44055279)

I guess it was easy in the old days when no one gave a shit if your software actually did anything. Unfortunately for the real world, you don't just get to target 15 or 20 experts anymore. There are now BILLIONS of users.

The scale probably hasn't sunk through the grey yet, but don't worry, you'll die someday and not have to worry about it.

Re:I hate them both (0)

Anonymous Coward | about a year ago | (#44055291)

Very ignorant rant. Me and many other .Net devs come from a traditional background where we have to consider garbage collection and such. We know how .Net's GC works and how to make fast, low memory applications. I wouldn't shit all over your language of choice because noobs in it frequently get segfaults.

Re:I hate them both (1)

Anonymous Coward | about a year ago | (#44055333)

As they are the harbingers of the new age, post dotcom world ...

Except that Java was started in 1991 (with Oak) and was released in 1995. Would you prefer C++, which was the mainstream alternative during that time period? As Guy Steele has said [mit.edu] : "And you're right: we were not out to win over the Lisp programmers; we were after the C++ programmers. We managed to drag a lot of them about halfway to Lisp. Aren't you happy?"

Personally I think that Java made "non-native" code much more acceptable, which allowed Python, Ruby, and even JavaScript, to become more mainstream. Perl has/had been around for a while, but it was generally squirreled away in the background with the sysadmins. "Real" developers compiled code.

In a perfect world we'd probably only be using Smalltalk/Lisp/Scheme, but as alternatives go, Java and .NET are pretty good for the average (or below average) code monkey as compared to straight C, C++, or assembler, which is what most developers probably had on their resumes back then. We're farther along now with "scripting" (i.e., dynamic) languages, but we needed a stepping stone for better acceptance IMHO, and Java isn't the worst you can do in that regard, especially given the historical context.

It got people halfway to actually-good languages, which isn't a bad accomplishment. You now have the option many more languages, so don't poo-poo it just because you don't like coding in it.

I'm sure Guy Steele wants/wanted to do certain things differently, but given his language experience (C, Fortran, Java, Lisp, Scheme, 'ECMAScript'), I think Java could have been a lot worse, and we should be content with what it allowed to happen with regards to what's acceptable in the mainstream. And even if you don't like the language, the JVM is a pretty good place to run other dynamic languages nowadays as well.

What C# have that Java sorely lacks (3, Informative)

benjymouse (756774) | about a year ago | (#44054775)

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:What C# have that Java sorely lacks (1)

Shados (741919) | about a year ago | (#44055053)

Don't forget properties as a first class concept.

Re:What C# have that Java sorely lacks (0)

sproketboy (608031) | about a year ago | (#44055583)

Right. Yet another bad idea.

Re:What C# have that Java sorely lacks (2)

TheGavster (774657) | about a year ago | (#44055209)

...
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 that allows that kind of functional programming to happen.

Re:What C# have that Java sorely lacks (1)

KingMotley (944240) | about a year ago | (#44055211)

You can add lambda expressions as well, although, that's coming in JRE 7, no, 8 maybe.

Yes, lambda expressions - and expression trees (1)

benjymouse (756774) | about a year ago | (#44055307)

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:What C# have that Java sorely lacks (0)

Anonymous Coward | about a year ago | (#44055461)

C++/CLI. I've written wrappers around C++ libs in C++/CLI and it's pretty nice. Way easier than JNI.

Re:What C# have that Java sorely lacks (0)

sproketboy (608031) | about a year ago | (#44055563)

Most of these are bad ideas so I'm glad they are not in Java.

Re:What C# have that Java sorely lacks (0)

ADRA (37398) | about a year ago | (#44055591)

"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. The big limitation is tail processing in java, but there are third party frameworks that make resuming blocks easier (though not a first class language feature). When you introduce this to a top level, you have to handle what to do with that now parked thread stack and how to clean it up when something bad happens. Its not a trivial problem, but hopefully one that lambda expressions will iron out in Java 8.

"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.

"Partial classes/methods"
Java 8 roadmap I believe

"Reified generics"
Yup, Java needs this

"LINQ (as in LINQ to objects, LINQ to Entities, LINQ to XML - all part of the core framework)"
JPQL / CriteriaQuery is the closest thing in JavaEE which do the same thing, though in a more ugly way. The one plus of Java's impl is that they didn't need a core language change to support it. I generally like simpler languages that rely on libraries to enrich vs. stuffing more and more into the core syntax.

"Dynamic typing and -interop"
I personally hate this, but there are half a dozen JVM based languages that support it.

"Value types"
Overrated and as mentioned in the article fully supportable as long as you create immutable objects. If you want the idea of value objects, create cloner or serialization (which is probably what .NET is doing behind the scenes anyways). Honest question, is the value object copy shallow or deep? Either way could be potentially horrible depending on the usage scenario.

"Operator overloading"
Thank fcking god this was never implemented. What a horrible horrible idea than changing the behaviour of +,-, etc.. Leave a method to do 100% the same thing and make it VERY clear wtf is happening vs. burying cleaver code behind common syntax patterns.

"Implicit/explicit type conversions"
Same as previous? Why not have .toInt() or toString() vs. burying the magic behind things?

Re:What C# have that Java sorely lacks (0)

Anonymous Coward | about a year ago | (#44055633)

Frankly, the lack of all the things you describe is a reason I like Java. For the most part, I can pick up some well-written Java code and see what it's doing without much fuss. No unexpected threads starting up (calling code looks identical if a method is async or sync). No inverted logic from generators. I don't need to dig through several files to find a method. No weird DSL layered on top. Static types let me, my IDE, and my compiler know what everything is and point out problems immediately. No trying to figure out what some clever developer intended for "|" to mean in some arbitrary class. And no code getting called under the hood when types get cast implicitly. Much of this stuff is syntactic sugar, and not the kind that cuts down code sizes by significant amounts.

To be fair, generator methods are nice in some contexts, but then you get developers who see everything as a generator, yielding code that has more generators than functions (pun intended).

Well-written code that uses all the features you mention just isn't as readable and maintainable.

if only you guys ada brain (0)

Anonymous Coward | about a year ago | (#44054813)

Lack of brain stems

Disagree about ease-of-use (3, Insightful)

sttlmark (737942) | about a year ago | (#44054855)

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:Disagree about ease-of-use (1)

datavirtue (1104259) | about a year ago | (#44055421)

I agree with your comment but it really sucks when you have to wade through .NET docs. It is easy to track down the API documentation for Java and get examples. In .net you have to spend a half an hour on google to get a simple sample code snippet. Ask a question on stackoverthrow and get flamed about your question. "Is this Winforms, WPF, ASP---what are you using!" Winforms. "Winforms sucks why the hell are you using that?" "What language?" VB.NET. "Why can't you use C#?"

In Java you go to the docs, see a plain hierachy with links to every class with full docs and possibly examples. If no examples are present you will find many examples very quickly with a simple search and no drama.

A tie? (0)

Anonymous Coward | about a year ago | (#44054895)

Try to develop a Web app in .NET and run it on Linux server (translate: .NET is Windows only. who can afford that these days?)

Re: A tie? (0)

Anonymous Coward | about a year ago | (#44055051)

Who can afford windows server?

The shop that doesn't have to pay linux sys admins

Re: A tie? (1)

datavirtue (1104259) | about a year ago | (#44055455)

The business doesn't really care, but who else has puked in their own mouth watching a Windows admin work? I'm so sick of even talking to these dumb fucks that I loath the IT department because of them.

mod_mono? (0)

Anonymous Coward | about a year ago | (#44055225)

You could do it in apache in mod_mono - it would be c# at least though not strictly speaking ASP.NET
does that count as .NET for you?

Re:A tie? (1)

datavirtue (1104259) | about a year ago | (#44055375)

What about Mono? Just asking, haven't tried it.

Short version (1)

Livius (318358) | about a year ago | (#44054921)

Both have big APIs.

Type Erasure (0)

Anonymous Coward | about a year ago | (#44054931)

The bit at the end about type erasure in Java is either misleading or incorrect. For an explanation that doesn't suck, see here:

http://docs.oracle.com/javase/tutorial/java/generics/erasure.html

Re:Type Erasure (1)

EvanED (569694) | about a year ago | (#44054999)

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?

Re:Type Erasure (0)

Anonymous Coward | about a year ago | (#44055283)

Reifiable versus Non-reifiable types for one

Re:Type Erasure (1)

EvanED (569694) | about a year ago | (#44055389)

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?

Re:Type Erasure (1)

benjymouse (756774) | about a year ago | (#44055549)

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 other more esoteric restrictions because of Java type erasure (yes, heap pollution is one of them).

Also consider that C# generics are fully verified at compile/load time, whereas Java generics need to perform downcasts at runtime, every time you return something that is of a generic parameter type.

None of them huge restrictions - until you hit upon them and realize that you will have to create strange code to circumvent them.

Re:Type Erasure (1)

benjymouse (756774) | about a year ago | (#44055413)

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:

Java, however, uses a method called type erasure. Essentially, the type checking only happens at compile time. The actual container types internally could still hold any type, but the compiler explicitly stops you from attempting to put other types into the containers.

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 item type as Person, you can insert Person specializations into it, like Student or Teacher. But because of type erasure the collection will in reality be a Object collection. Hence, when you read from the collection the compiler must ensure that it is indeed a Person being read.

Nevermind how the authors hastens to apologize for the shortcomings of type erasure. He also fails to mention one very big difference: Java generics do not support primitive/value types. Storing Integers in collections incur a significant overhead compared to int's because of boxing, heap allocation, unboxing and garbage collection.

Re:Type Erasure (1)

ADRA (37398) | about a year ago | (#44055415)

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.

All about the Benjamins (0)

Anonymous Coward | about a year ago | (#44055173)

.NET devs make more money.

Re:All about the Benjamins (1)

datavirtue (1104259) | about a year ago | (#44055473)

I haven't seen many job postings for Java as of late. PLENTY of .NET.

Re:All about the Benjamins (0)

Anonymous Coward | about a year ago | (#44055703)

LOL, you must really be sequestered off in your own little tiny world there, then.

Event Models (1)

datavirtue (1104259) | about a year ago | (#44055367)

I'm wondering how a comparison of the event models got skipped. Rather useless article.

Async methods (1)

benjymouse (756774) | about a year ago | (#44055479)

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.

cogswell's loading the dice then rolling them (0)

Anonymous Coward | about a year ago | (#44055659)

What an asshole.

Load More Comments
Slashdot Account

Need an Account?

Forgot your password?

Don't worry, we never post anything without your permission.

Submission Text Formatting Tips

We support a small subset of HTML, namely these tags:

  • b
  • i
  • p
  • br
  • a
  • ol
  • ul
  • li
  • dl
  • dt
  • dd
  • em
  • strong
  • tt
  • blockquote
  • div
  • quote
  • ecode

"ecode" can be used for code snippets, for example:

<ecode>    while(1) { do_something(); } </ecode>
Create a Slashdot Account

Loading...