Likewise Java's OOP enums (basically singletons) are something I miss too.
That's a few small features I notice missing when I switch to C#.
Plus, in general I find there's a difference in style. C# libraries tend to be more pragmatic, following on Microsoft's heavy use of reflection and stringly-typed stuff. Not much OOP navel-gazing.
Java, on the other hand, celebrates OOP to a ludicrous extreme.
Also on the community, C# has been working very hard to develop the kind of bazaar that Java has, but they're coming from far behind on that front - far more C# developers restrict them to the first-party tools compared to the Java ones.
There was also nant and a number of build tools, plus good old make.
C# guys are working on adding full-fledged pattern matching to the language:
https://github.com/dotnet/roslyn/blob/features/patterns/docs...
and there's a concurrent proposal for ADTs:
https://github.com/dotnet/roslyn/issues/6739
Given the velocity of adding new features in C# these days, these will come sooner rather than later (indeed, some basic pattern matching is already in C# 7).
Swift, Scala, and C# are statically-typed languages, like Java, whereas Apache Groovy is dynamically-typed originally -- though static typing was added in Groovy 2, virtually no-one uses it. Dynamically typed languages like Groovy are good for glue code, build scripts, and testing, not for developing actual systems.
- Class extensions: I saw code examples online that just wouldn't work for me because the compiler told me a certain method of a built-in class wouldn't exist. After I while I found out that the author of that snippet had used class extensions and not bothered to mention.
- The var keyword: While this is sometimes nice for quick scripting or hacking in the debugger console, it opens the door for hard-to-read code.
Those are not necessarily "magic", but potential obscurities that can't happen in Java, simply because Java lacks these features.
I find type inference to be the opposite, generally, because it encourages good naming, and it reduces noise/boilerplate. It also makes writing and refactoring faster (don't have to think about the return types, just the code flow).
The only situation I can even think of where it is a problem is when you are passing something to an overloaded method. For example:
void DoSomething(MySpecialType value);
void DoSomething(string value);
////
var result = GetData();
DoSomething(result);
You can't tell which one is going to be called by just looking at that code. However:* GetData() is probably badly named in this situation
* If DoSomething() does something very different depending on the type passed, it should have different names, not be overloaded
On top of that, this code can also have the same problem without type inference:
DoSomething(GetData())99% of the time it's completely obvious what the variable is because you can just look at the right side of the equal sign.
Also, you can just hover over it.
As for the extension methods, they pretty much fixed that in VS 2015, it will now tell you which using statement you need to include.
Extension methods are a good solution to a specific problem.
Dictionary<string, Tuple<int, List<string>>> foo = new Dictionary<string, Tuple<int, List<string>>>();
Is prefferable to:
var foo = new Dictionary<string, Tuple<int, List<string>>>();
What do you get from the former that makes the eye-pain worth it?
Also, the var keyword is necessary for anonymous types if you want to hold a reference to one. And this is a language feature I sorely miss in Java-land.
One thing that VS can now do (as of VS 2015) is tell you where exactly the "missing" extension method is, and offer to add a corresponding `using` declaration for you.
Not sure if VSCode or VS/Mac support that, though. But they are all built on the same code analysis engine, so there's no reason why they couldn't.
Extensions methods can be approached via default methods.
Java 9, latest by 10, will get var. It is already on the approved roadmap.
Java is a shitty language exactly because they don't put in things like these out of fear that people don't know how to use them.
So, yeah, go away because that's not contributing to the conversation.
Well, maybe there’s another implication.
Google switching to C# would lead to them neglecting and deprecating the Java ecosystem on Android. That’s gonna be real ugly for app devs, ending up having to rewrite everything.
So, maybe, there is a real contribution in the comment, which you just haven’t seen yet?
Paul Graham once said [1]:
I think it's ok to use the up and down
arrows to express agreement. Obviously
the uparrows aren't only for applauding
politeness, so it seems reasonable that
the downarrows aren't only for booing
rudeness.
It only becomes abuse when people resort
to karma bombing: downvoting a lot of
comments by one user without reading
them in order to subtract maximum karma.
Fortunately we now have several levels
of software to protect against that.
[1] https://news.ycombinator.com/item?id=117171Many have taken this to mean that down voting a comment when they disagree with the opinion therein, no matter how well it argues that opinion and no matter how much it contributes to the conversation, is fine.
The down vote causes the comment to be dimmed and seen as a rejection to the comment. It is very frustrating when the top right side is your name and your "Hacker News Points" so I don't get why the down vote if you disagree. A down vote kills the conversation.
A credible threat of Google moving Android away from Java is the best hope we have of this situation ever improving.
Operator overloading is probably the worst feature ever invented, same with Class Extensions, reducing readability of code.
And with a switch to C# Google would neglect the Java ecosystem on Android, requiring us app devs to rewrite everything again.
I’m not sure there’s an upside to switching to C#.
or greatly enhancing it. Depending on how you use it.
That's why Java is a language for idiots. I'm not saying everyone who uses it or likes it is an idiot, it's a reasonable language to like. I'm saying it's designed to be usable by idiots. Can't have operator overloading, it might be abused. Can't have unsigned types, no one ever should use those. etc...
C# also has yield, async, structs, reflection on generics, and a number of other features.
Class extensions can be fantastic and really enable design elements in elegant ways, any advanced feature could be argued that it reduces readability if used poorly.
A seemingly common sentiment, but one rarely backed by any meaningful data.
And last I checked you couldn't use Java 8 fully on Android (please correct me if I'm wrong).
There are still uses though. Lambdas are the future, but there are lots of OO-first libraries that are still quite popular. It'd be nice to create e.g. `new Newtonsoft.JsonConverter() { ReadJson() {...} WriteJson() {...}}` etc on the fly sometimes without needing separate classes.
It's possible in F# though, so nothing dotnet specific is preventing it.
public static final MyInterface SINGLETON = new MyInterface() {
...
}