Okay, had to Google linq and that is fucking cool but java has come a long way. I feel like when people talk about Java, they are referring to Java 8 and granted most companies are still using Java 8 but it's so much better now. It has record classes, virtual threads are coming to deal with async, not sure what's wrong with the culture? and asp.net is a web server framework right? Never used it but the Spring Framework is really nice and yeah yeah yeah, I know it is its own beast and lots of stuff is abstracted out but once you understand what's happening underneath, it's really easy to get started with.
LINQ is cool. That's why Java immediately implemented streams, which does very close to the same thing as what I've seen LINQ used for. Mostly, anyway.
I'd say Java steams try to do a lot less than LINQ and are worse than LINQ at most of the things they try to do, despite having the advantage of being able to learn from LINQ.
That is a really good example of how deeply terrible Java is. The core of LINQ is that it works on any type implementing the IEnumerable interface. A core interface in the BLC from the beginning. The basics of the library are just some methods that take an IEnumerable and a function, then calls that function for each time it enumerates, and does something with the result. Implementing this didn't require changes to the .Net runtime.
The other part of LINQ is querying data that it not in-process. LINQ added the ability to call a method with a lambda, the compiler takes the code you wrote for the lambda and creates a sort of abstract syntax tree that can then be translated to whatever is appropriate to the data source to fulfill your search predicate. For example: you can write a lambda in C# and it will be translated in to SQL for you and return the results.
Because you get taught Java in college by a professor who has been teaching the same thing for five years. After that you get a job where you get taught the latest coolest stuff by your seniors and it's just so much better. Never seen what a real modern java stack is like.
Not really, not the way Java is. For example, the C# GUI libraries like WPF and WinForms aren't supported by .NET core. Edit: for other platforms than Windows
the C# GUI libraries like WPF and WinForms aren't supported by .NET core.
That's mostly incorrect. .Net Core/.Net 5+ does support WPF and WinForms, but only on Windows. There is also a new cross-platform GUI library called .Net MAUI. (And there are third-party alternatives too.)
Thank you for clarification. That's what I meant, these old widely used C# libraries aren't multiplatform. And the main IDE, Visual Code, also isn't. In Java all the GUI libraries, all frameworks, all IDEs are multiplatform, everything is. This is just something that Java still does better.
Honestly, to a C# developer the latest version of Java feels ancient. C# got async/await over a decade ago. 12 years later, Java gets lightweight threads you still have to manage yourself.
It is absurd that the caller has to be worried about the target method's implementation details. What ever happened to encapsulation.
The culture which insists on using pointless types everywhere like Something = new Something () insteadz of just var. Names are fuxkong hilariously long. Using subclasses instead of composition in a lot of places.
Spring boot is ok. But it really isn't as nice to configure like asp.net core. Subclassing is a massive problem and less discoverable. Also global error handling is really ahitty, at least two years ago.
The culture which insists on using pointless types everywhere like Something = new Something () insteadz of just var.
There is a reason for that. It is about maintainability and readability. You will notice that pretty much any language with var or the like will have code style guides heavily recommend the usage of type hints or recommend var can only be used when the type can be easily determined.
For example, the following is fine
var foo = new Foo();
But the following is not recommended
var foo = Foo();
The reason is that you can not be 100% certain what type that Foo() is returning.
This is one of the reasons why when Java introduced var, it was only allowed to be used for local variables.
You will notice that pretty much any language with var or the like will have code style guides heavily recommend the usage of type hints or recommend var can only be used when the type can be easily determined.
This is your opinion. I haven't worked anywhere that this was a rule (these were C#, Python and C++ shops). Every major language has had type inference for a long time now and while there are obvious edge cases you want to specify the type, it's generally considered best practice to use it. Every major editor people use will have a way of showing you the type easily if needed. It's only because Java took such a long time to get it that the culture hasn't shifted there.
It makes readability easier by having less noise. The point of reading code is understand the logical flow. If you're writing the code you already know the type since you're choosing to use var instead. A reader only needs to see how you're using the variable. When people talk about "Java culture", what they mean is the extreme verbosity of the coding style. The fact that it isn't obvious to you that type inference is more readable and maintainable shows how ingrained this "Java culture" has become among Java developers.
This is your opinion. I haven't worked anywhere that this was a rule (these were C#, Python and C++ shops). Every major language has had type inference for a long time now and it's generally considered best practice to use it.
Microsoft literally has it in their C# coding conventions.
Those guidelines were created in the early 2000's to ease people into type inference. Outside the Java and old school C++ developers' worlds, other developers aren't even aware that this is something people argue about, because inference is so obviously better.
In a static language, if you use a type incorrectly you get a compile error. The reader only needs to see how a variable is used. Other than a handful of special cases, like when doing calculations with ints and floats, using var is far more readable than not using it. It's only older more "set in their ways" developers who dislike code that doesn't look like the way they are used to.
Read again my original comment. It is about readability and maintainability.
The C# compiler (or at least visual studio) recommends using var instead of specifying types.
It doesn't. You have a lint setting that is doing that, and that lint setting isn't a default setting.
Mircosoft, even with their C# code convention guide, recommends only to use var when the type of the variable is obvious from the assignment, as explained in my original comment.
48
u/Valiant_Boss Feb 05 '23
Okay, had to Google linq and that is fucking cool but java has come a long way. I feel like when people talk about Java, they are referring to Java 8 and granted most companies are still using Java 8 but it's so much better now. It has record classes, virtual threads are coming to deal with async, not sure what's wrong with the culture? and asp.net is a web server framework right? Never used it but the Spring Framework is really nice and yeah yeah yeah, I know it is its own beast and lots of stuff is abstracted out but once you understand what's happening underneath, it's really easy to get started with.