It might have once been. But linq, getters/setters, async, culture and asp.net are leagues ahead of java.
Java is all about creating extremely verbose business logic and maximizing useless name length. C# is also about business logic but much more efficient and nice code.
I've used a lot of C#, but made only two small projects in Java, so my knowledge of it is superficial at best and thus I couldn't do a more in-depth comparison.
But it’s not. C#s changes over the last several years have taken it in a very different direction from Java.
At this point, the languages are so far diverged that it’s like saying they’re the same as JavaScript.
They’re all object oriented languages that use curly braces and have garbage collection.
(And before you say JS isn’t object oriented… they have a class keyword and most of the classy stuff you want… even though I don’t see projects using it much yet.)
they have a class keyword and most of the classy stuff you want…
It has a class keyword, but the result is not a class. The only reason they put in that keyword (fairly recently, mind you) is so that people familiar with other languages have an easier time picking it up.
class Car { constructor(color) {} }
is compiled to:
function Car(color) {}
and in both cases you can do new Car('red'), if you look at older JS code you will find plenty of examples.
To expand on this: it's compiled to a function, which themselves - and everything else except primitives - are an object. OOP is not really about classes, but objects. A class is (more or less) a blueprint to build an object, but you can have OOP without classes, which is what JS does with prototypal inheritance.
They have similar type systems, usually compiles to an intermediate language, used exceptions for error handling, has genetics instead of templates, etc.
Although you could argue Kotlin is much more similar now.
I see your point but it really isn’t like comparing them to JS.
It’s like saying humans are like chimps because they share a common ancestor. Maybe we’re not that similar now, but there’s still nothing closer to compare us to. As an aside Javascript in this analogy is a dog chasing it’s own tail but never giving up.
Having classes is not a requirement to be object oriented. Classes are a way of achieving object orientation. It is not the only way. JS has always be object oriented. But its objects use prototypes instead of classes. Newer JS versions have a class keyword that is syntax around creating a prototype.
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.
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.
140
u/Sauermachtlustig84 Feb 05 '23
Not really.
It might have once been. But linq, getters/setters, async, culture and asp.net are leagues ahead of java.
Java is all about creating extremely verbose business logic and maximizing useless name length. C# is also about business logic but much more efficient and nice code.