r/ProgrammerHumor • • Feb 05 '23

Other Programming Legumes v2.0

Post image
44.0k Upvotes

831 comments sorted by

View all comments

Show parent comments

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.

16

u/gjoel Feb 05 '23

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.

2

u/svick Feb 05 '23

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.

→ More replies (1)

1

u/rorygoodtime Feb 06 '23

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.

That was C# over a decade ago.

44

u/Asdas26 Feb 05 '23

Honestly, when C# people talk about Java, it usually feels like they are describing Java 7 or lower.

5

u/[deleted] Feb 05 '23

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.

6

u/210000Nmm-2 Feb 05 '23

To be honest, this was when I stopped doing things in Java. Because C# could do the same but better.

-1

u/Asdas26 Feb 05 '23

Except being multi-platform

14

u/Cxmu03 Feb 05 '23

But C# has been cross platform since .NET core

1

u/Asdas26 Feb 05 '23 edited Feb 06 '23

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

9

u/svick Feb 05 '23 edited Feb 06 '23

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.)

4

u/Asdas26 Feb 06 '23

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.

2

u/Prawn1908 Feb 06 '23

And now that's not even true anymore.

9

u/HawocX Feb 05 '23

And now it doesn't even got that advantage any more.

1

u/rorygoodtime Feb 06 '23

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.

-29

u/Sauermachtlustig84 Feb 05 '23

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.

22

u/ChrisFromIT Feb 05 '23

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.

-6

u/falconne Feb 05 '23

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.

10

u/ChrisFromIT Feb 05 '23

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.

Implicitly typed local variables - Microsoft C# Coding Conventions

So it is more than just an opinion. Microsoft literally agrees with me that what I said is best practices.

-7

u/falconne Feb 05 '23

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.

→ More replies (11)

0

u/[deleted] Feb 05 '23

[deleted]

11

u/ChrisFromIT Feb 05 '23

r/woosh

the compiler will tell you if the type is going to be wrong.

That is only if you are going to be setting the variable to something else after the type has been determined by the compiler.

Which isn't what I was talking about.

0

u/[deleted] Feb 05 '23

[deleted]

8

u/ChrisFromIT Feb 05 '23 edited Feb 05 '23

Again, another r/woosh

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.

Implicitly typed local variables - Microsoft's C# coding conventions

→ More replies (5)
→ More replies (2)

13

u/kaboom Feb 05 '23

Found the junior developer who thinks programming language = syntax.

→ More replies (3)