Java vs. C#
-
Ian Shlasko wrote:
IEnumerable. Seriously, why does it matter if a function returns an array or a list, if all I'm going to do is iterate it? Arrays and Lists need to implement some common interface(s) so I'm not always converting back and forth depending on which third-party library uses which.
Does
Iterable<T>
[^] work for you? /raviMy new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com
Not as long as this code fails to compile:
Integer[] arrayOfStuff = functionThatReturnsAnArray();
Iterable iter = arrayOfStuff;Proud to have finally moved to the A-Ark. Which one are you in?
Author of the Guardians Saga (Sci-Fi/Fantasy novels) -
I apologize in advance for not telling a joke about telling jokes about things, but I need to vent, and I just happen to have the Lounge open in my browser (As always)... Ok, so I'm mainly a .NET programmer, but I've spent the last couple months writing a three-tier Java/GWT/GXT application... Hadn't used Java in over a decade, so had to teach myself a few frameworks, but that's no big deal... Part of the job... So now I think I have enough experience to complain about both... Things C# Has and Java Needs: * Property syntax... Seriously, I'm so sick of writing getThingy and setThingy methods. They're ugly and they don't add anything. I miss being able to just type "public double Thingy { get; set; }" * Namespace/package aliases. "using STUFF = com.blah.meh.ugh.stuff" would be great. Wildcards are ok, but there's so much junk in the JRE with similar names that it gets confusing * IEnumerable. Seriously, why does it matter if a function returns an array or a list, if all I'm going to do is iterate it? Arrays and Lists need to implement some common interface(s) so I'm not always converting back and forth depending on which third-party library uses which. * Function pointers that actually work... I hate having to build an inner/anonymous class that implements an interface, just so I can pass a callback. This might be a GWT weakness instead of a Java weakness... * Optional method arguments. * Partial classes. Splitting code between files makes it much easier to organize * Multiple classes per file. Honestly, if I have a handful of classes that are about five lines each, why do they each have to be a separate file? Why can't I just put them in a "Things.java" file (Or something more specific than 'Things')? * Events... Sure, there are event frameworks, but the ones I've messed with feel clumsy and hacked-in... Need native language support for it. * Project/module-based root packages. In C#, I can say my project's root namespace is "Company.This.That.TheOther" in ONE place, and never have to mess with it... In Java, my whole source tree is supposed to be under "com/company/this/that/theOther/" and every single file has to have "package com.company.this.that.theOther" at the top. If my IDE didn't automate refactoring, that would have driven me right out the window. * WPF/XAML. GWT/UiBinder is about 20% of the way there. Maybe there's another framework that gets 30% of the way... But man, I really miss DataTemplates, Styles, and dynamic binding... Things Java has and C# Needs:
No idea whether it addresses all your points but some use Scala as a "better Java," as opposed to using the functional bits. A colleague who has done extensive .NET and Java has also used Scala and prefers it. But, of course, it will have its own issues. :)
Kevin
-
No idea whether it addresses all your points but some use Scala as a "better Java," as opposed to using the functional bits. A colleague who has done extensive .NET and Java has also used Scala and prefers it. But, of course, it will have its own issues. :)
Kevin
Heh, if I was the one picking the language for this project, I would have just stuck with C#/WPF :)
Proud to have finally moved to the A-Ark. Which one are you in?
Author of the Guardians Saga (Sci-Fi/Fantasy novels) -
I apologize in advance for not telling a joke about telling jokes about things, but I need to vent, and I just happen to have the Lounge open in my browser (As always)... Ok, so I'm mainly a .NET programmer, but I've spent the last couple months writing a three-tier Java/GWT/GXT application... Hadn't used Java in over a decade, so had to teach myself a few frameworks, but that's no big deal... Part of the job... So now I think I have enough experience to complain about both... Things C# Has and Java Needs: * Property syntax... Seriously, I'm so sick of writing getThingy and setThingy methods. They're ugly and they don't add anything. I miss being able to just type "public double Thingy { get; set; }" * Namespace/package aliases. "using STUFF = com.blah.meh.ugh.stuff" would be great. Wildcards are ok, but there's so much junk in the JRE with similar names that it gets confusing * IEnumerable. Seriously, why does it matter if a function returns an array or a list, if all I'm going to do is iterate it? Arrays and Lists need to implement some common interface(s) so I'm not always converting back and forth depending on which third-party library uses which. * Function pointers that actually work... I hate having to build an inner/anonymous class that implements an interface, just so I can pass a callback. This might be a GWT weakness instead of a Java weakness... * Optional method arguments. * Partial classes. Splitting code between files makes it much easier to organize * Multiple classes per file. Honestly, if I have a handful of classes that are about five lines each, why do they each have to be a separate file? Why can't I just put them in a "Things.java" file (Or something more specific than 'Things')? * Events... Sure, there are event frameworks, but the ones I've messed with feel clumsy and hacked-in... Need native language support for it. * Project/module-based root packages. In C#, I can say my project's root namespace is "Company.This.That.TheOther" in ONE place, and never have to mess with it... In Java, my whole source tree is supposed to be under "com/company/this/that/theOther/" and every single file has to have "package com.company.this.that.theOther" at the top. If my IDE didn't automate refactoring, that would have driven me right out the window. * WPF/XAML. GWT/UiBinder is about 20% of the way there. Maybe there's another framework that gets 30% of the way... But man, I really miss DataTemplates, Styles, and dynamic binding... Things Java has and C# Needs:
-
Ian Shlasko wrote:
Property syntax...
I've found the lombok jar to be extremely useful for cleaning up pojos. Lightweight and simple to use: https://projectlombok.org/[^]
-NP Never underestimate the creativity of the end-user.
Oooooooh... Thanks :)
Proud to have finally moved to the A-Ark. Which one are you in?
Author of the Guardians Saga (Sci-Fi/Fantasy novels) -
Not as long as this code fails to compile:
Integer[] arrayOfStuff = functionThatReturnsAnArray();
Iterable iter = arrayOfStuff;Proud to have finally moved to the A-Ark. Which one are you in?
Author of the Guardians Saga (Sci-Fi/Fantasy novels)Integer[] arrayOfStuff = {1, 2, 3, 4};
Iterable iter = Arrays.asList(arrayOfStuff);#cough cough#
veni bibi saltavi
-
Integer[] arrayOfStuff = {1, 2, 3, 4};
Iterable iter = Arrays.asList(arrayOfStuff);#cough cough#
veni bibi saltavi
Yeah, see... Gotta turn it into a list in order to iterate the stupid thing :sigh: EDIT: Or rather, to return it as an iterable... Can still iterate an array, but it's not an iterable... EDIT 2: And just thinking about it more makes me irritable... Heh
Proud to have finally moved to the A-Ark. Which one are you in?
Author of the Guardians Saga (Sci-Fi/Fantasy novels) -
Well, GWT is horrible and scary at first, but when you figure out how to do things their way, it's not TOO bad... If, like me, you're familiar with WPF/XAML, you'll want to do your GWT with the UiBinder stuff... It's a XAML-wannabe... But be warned that all the data binding is static. Would suggest avoiding GWT-RPC though... Do a RESTful service or something... Keep the client and server separated. GWT-RPC is easy to use, but it binds your tiers way too tightly.
Proud to have finally moved to the A-Ark. Which one are you in?
Author of the Guardians Saga (Sci-Fi/Fantasy novels)Oh GWT... We thought you were the future and then Google released AngularJs. On a serious note, we have a GWT app that we are retiring after 6 years and migrating to Angularjs. GWT just has to much baggage. We found that we could get a lot more done using a restful json API and Angularjs.
Eric
-
Oh GWT... We thought you were the future and then Google released AngularJs. On a serious note, we have a GWT app that we are retiring after 6 years and migrating to Angularjs. GWT just has to much baggage. We found that we could get a lot more done using a restful json API and Angularjs.
Eric
Oh, I've got the restful JSON API covered... Loving the Jersey framework, despite the similarity to New Jersey (Hey, I'm a New Yorker - Making fun of NJ is just expected). Almost made me start liking Java... Until, just for fun, I tried doing the same thing in .NET and realized it was just as easy.
Proud to have finally moved to the A-Ark. Which one are you in?
Author of the Guardians Saga (Sci-Fi/Fantasy novels) -
Integer[] arrayOfStuff = {1, 2, 3, 4};
Iterable iter = Arrays.asList(arrayOfStuff);#cough cough#
veni bibi saltavi
-
harold aptroot wrote:
unsigned integers as a type (
Integer.fooUnsigned
is kind of ugly), particular bytes.Haven't had to mess with that yet...
harold aptroot wrote:
- value types.
- operator overloading.
I was advised to completely avoid 'int' in favor of 'Integer' (And the equivalents for other types) when it comes to GWT... Would be nice if it handled them, as I wince every time I look at a bunch of 'Integer' and 'Boolean' variables...
harold aptroot wrote:
generics that are actually generics. Type erasure sucks.
Hasn't bugged me yet... The opposite, actually... I had to delve into writing my own GWT code generator, because a certain third-party framework (*cough*GXT*cough*) is so hung up on generics that they can't handle polymorphism...
harold aptroot wrote:
correct arithmetic. Seriously. How the hell can they get away with this nonsense[^]?
Wow... Ok... That's just... horrid...
Proud to have finally moved to the A-Ark. Which one are you in?
Author of the Guardians Saga (Sci-Fi/Fantasy novels)Regarding the value types: Well, seeing as you're basically compiling to JS it "shouldn't" really matter. But if direct compilation to bytecodes/IL those value types do help a LOT on CPU caching optimizations. I've seen speedups of orders of magnitude on number crunching, simply by changing a class to a struct. I mean, for the love of Pete why can't I have something like a struct in Java? Do I always have to make use of several disjoint arrays of ints (necessitating multiple corroboration methods just to keep all of their indexes aligned) if my actual data is correlated in groups, why can't I just use an encapsulation to group them and still derive the benefits of sequential memory locations? True struct/class in C# isn't "wonderful" (i.e. not like C++ where you could have both in both manners), but at least it's "something". With Java there simply isn't any equivalent!
-
I apologize in advance for not telling a joke about telling jokes about things, but I need to vent, and I just happen to have the Lounge open in my browser (As always)... Ok, so I'm mainly a .NET programmer, but I've spent the last couple months writing a three-tier Java/GWT/GXT application... Hadn't used Java in over a decade, so had to teach myself a few frameworks, but that's no big deal... Part of the job... So now I think I have enough experience to complain about both... Things C# Has and Java Needs: * Property syntax... Seriously, I'm so sick of writing getThingy and setThingy methods. They're ugly and they don't add anything. I miss being able to just type "public double Thingy { get; set; }" * Namespace/package aliases. "using STUFF = com.blah.meh.ugh.stuff" would be great. Wildcards are ok, but there's so much junk in the JRE with similar names that it gets confusing * IEnumerable. Seriously, why does it matter if a function returns an array or a list, if all I'm going to do is iterate it? Arrays and Lists need to implement some common interface(s) so I'm not always converting back and forth depending on which third-party library uses which. * Function pointers that actually work... I hate having to build an inner/anonymous class that implements an interface, just so I can pass a callback. This might be a GWT weakness instead of a Java weakness... * Optional method arguments. * Partial classes. Splitting code between files makes it much easier to organize * Multiple classes per file. Honestly, if I have a handful of classes that are about five lines each, why do they each have to be a separate file? Why can't I just put them in a "Things.java" file (Or something more specific than 'Things')? * Events... Sure, there are event frameworks, but the ones I've messed with feel clumsy and hacked-in... Need native language support for it. * Project/module-based root packages. In C#, I can say my project's root namespace is "Company.This.That.TheOther" in ONE place, and never have to mess with it... In Java, my whole source tree is supposed to be under "com/company/this/that/theOther/" and every single file has to have "package com.company.this.that.theOther" at the top. If my IDE didn't automate refactoring, that would have driven me right out the window. * WPF/XAML. GWT/UiBinder is about 20% of the way there. Maybe there's another framework that gets 30% of the way... But man, I really miss DataTemplates, Styles, and dynamic binding... Things Java has and C# Needs:
"Wildcard arguments for generics. If I have Foobar and Foobar, it's nice to be able to put them in a collection/array typed as Foobar. The '? extends X' and '? super X' syntax might be a bit much, though."
C# has covariance and contravariance, no need for that. That Java sintax is horrible, I can't even understand it without reading the docs every time, even C++ sintax for templates I can get. It must be because of type erasure, Java doesn't really have Generics per se, it fucks on runtime with method binding, this is how we get the polymorphism, and without it, there's no true OO with Generics, Shame! (luckily I don't use Java everytime).