If I would want to use something like Java for a project, I would always pick C# which is a better Java in all aspects.
If I would want to use something like Java for a project, I would always pick C# which is a better Java in all aspects.
Java with IntelliJ is awesomely productive. You barely have to type anything beyond new variable / field names, everything else is generated or tab completed. Refactoring is a breeze.
That, times 'worse is better' - it's the language and toolset I already know for the types of things it's good at. I have no doubt C# is comparable or better at most things, but probably not so much so that it is worth switching.
They have a C# IDE (Rider) now, based on IntelliJ. While it was originally the only non-Windows C# IDE, I and others have switched to it from Visual Studio (which is almost as good) even on Windows.
> I have no doubt C# is comparable or better at most things, but probably not so much so that it is worth switching.
I’d say you are right. Now. 10 years or so ago (6/7/8 times) I’d have disagreed, C# avoided many of the mistakes* Java made and was able to become far more pleasurable to use, it took some time for Java to catch up again.
*: Mistakes only in hindsight
Rust is better than C
C# is better than Java
You can talk about tooling, environments, how many people use it, what you can use it for, but when it really boils down to the language there are languages that are better than others while trying to achieve the same.
I mean I use Elixir for other things than Swift or Rust or F#, Elixir is the best language for highly concurrent "message passing" systems. Some features of Elixir that I don't immediately like like it's type system unlock possibilities that no other languages have. But I don't see anything like that in Java, unless I really look around in 1993 and the only competitors are C++ and nobody-uses-it-yet Python.
My little pitch when starting a migration project in a distressed no-type language team is to make them read the code and explain it, while asking about the type of objects they use and show them when they read it's their brain parsing it with high effort. If they de-optimize and just write the types more often, it becomes much clearer longer.
You can type usually in those language but often people want to use the "proper way" as shown in ultra simplistic examples in manuals for sales pitches and end up thinking the right way to code is to write as little as possible (combined with the no-comment belief they have but don't map to "no comment because clear enough code").
That's not the case for Kotlin, that has the full weight of JetBrains behind it.
I guess that's what I see as one of the advantages of Groovy. You can do ultra rapid implementation of something with minimal code and then as it becomes more critical you increase its type safety by adding first Groovy type hints, but further along that curve, convert it fully to Java or another statically typed language. So what you describe as a problem I see as sort of, optimal workflow, and the real problem is being forced to universally choose one or the other in other languages.
If you were trying to write portable C++ code in 1996 you would get it, specially when using each OS specific C++ compiler provided by the platform vendor.
#ifdef _AIX
...
#else ifdef SGI
...
#else ifdef WINDOWS
...
#else // everything else
...
#endif
Shudder.But the other thing that Java had is the library. Compared to C++'s standard library in 1996, it was a revelation.
Things like GC, reflection, runtime loading of code, that were very familiar from more academic languages at the time.
I also did a lot of C# to help on a GUI optimization project (because doing low latency if the GUI freezes every 10 minutes isn't great), and I was really surprised by how good it was so I wouldn't disagree it works nice.
BUT I like that Java works simply in linux, I like that it didn't yet got contaminated by all the crazy constructs from elsewhere (Groovy grr), I love the tradition around the syntax (I can't stand C# quirks sometimes). I do HATE with passion the meaningless generics, and I wish we'd ditch backward compat to steal it all form C++ templates.
I enjoy more than the language syntax itself that is close to most languages I like (Javascript, C#, C++), the team spirit around it. Believe me, it's much easier to use and understand maven (or maybe gradle who starts to get dangerous in real world projects where you can't afford 2 weeks of reverse engineering a madman's build script) than it was nugget, it's easier to use IntelliJ than to receive yet another stupid email from compliance about a Visual Studio license missing, it's nicer to build a jar and run it than to go through all the kinks of exe files... I dunno I may have started from Java and got to C# and done the opposite of your journey, but while I agree C# has superior features in some aspects (but sometimes they chose mess vs safety) I just wasn't convinced it could work for something more critical where you must do things as simple as you can, as clear as you can.
And let's not even start on C++ who's superior in every conceivable way except that it encourage, or doesn't discourage, every team I ever meet to create unbearable messes they can't fix, so focused they are fixing problems we can't even imagine in Java for reasons we can't comprehend our company even accepts to finance :D
- primitives or any custom value types/structs can be used. No need for boxing or method duplication for primitives. - type information available at runtime, no need to pass 'Class<T>' parameters. - type constraint 'new' available, which means it must have a default constructor so you can do 'new T()'. No need to use reflection or pass a constructor parameter. - type constraint 'notnull' available - class-scoped compiler enforced covariance and contravariance, though I think you can get similar results with java's "? extends T" and "? super T" constraints
return new T();
is possible in C#, not in java.
Definitely not pleasant though.
I'm sure it's me but do you use it yourself and why ? Don't you get lost in the indirections in big projects "oh shit where is that thing again that auto inject itself here" ?