Earlier quoted context omitted.
> seems to be antithetical to the principles of a strongly-typed language. So does this now reclassify Java as a weakly- or dynamically-typed language? Var and type inference are neither antithetical to static typing nor do they make a language dynamically typed. They're antithetical to the verboseness of Java.
Except that having the type info is really, really useful at the call site. I know the IDE is able to infer it and display it but it's still a pain to see all the vars during a code review in a browser.
New language features since Java 8 to 17
311–320 of 358 posts
Re: New language features since Java 8 to 17
#312Earlier quoted context omitted.
> C# has these "inferior practices" and is a much better language overall. Why Java doesn't adopt the low and not-so-low hanging fruit from C# is really baffling. Because Java is doing a lot better than C#, and obviously we feel Java is a much better language overall.
Java has had quite a head start (.net core came out only 5 years ago). Now the "doing a lot better" is dwindling. And dragging feet on QoL isn't helping.
Re: New language features since Java 8 to 17
#313Earlier quoted context omitted.
But at the other hand, C# is heading in the direction of C++, where even after n years working with it, it can still surprise you/find yet another way of doing this and the rest. Like, I would prefer not having 10+ initializers from C++ in a language.
But on the other hand you have object initializers directly in the language In Java you have one of these: - a hope that someone provided a useful static `.of` method - a hope that someone provided the 15000 setter methods that you have to tediously invoke one by one - a hope that someone provided a generator that created a builder that has 15000 setter methods that you have to tediously invoke one by one Meanwhile i…
And yeah, C# feels to me to be on the way to being way too feature-packed, which can be a detriment in the extreme.
Re: New language features since Java 8 to 17
#314Earlier quoted context omitted.
Global scope is not a terrible invention and if you look carefully then you will notice that the Java version uses it as well. Or where is the import to get "System" into scope? It's imported globally everywhere (just like all everything from java.lang). So the only question is: should "print" be burried under layers or not. I don't think the advantages of burrying are really worth it.
OP meant the public static void main part (that is you define what happens encapsulated in a class) Of course implicit imports are needed, like what else would you have without?
Apart from that it is really unintuitive to have something "static" within a class (which is commonly understand as a template), it is not encapsulated because it is static _and_ public. _And_ now you can search for this thing everywhere - and what happens if you find two of them?
Yeah no, the idea of "public static void main" wasn't a great one, no matter how I look at it.
It's much better to be explicit and ask the user to decide which file they want to use as the starting point.
> Of course implicit imports are needed, like what else would you have without
They are of course not needed. You could also just import everything manually. Okay, Java's import suck, but in a better language you could do "import prelude._" in the beginning of every file and otherwise you are left with keywords only. Not saying that's a great idea, but it certainly can work without implicit imports.
Re: New language features since Java 8 to 17
#315Earlier quoted context omitted.
Java is an Android's curse. Just compare how completely native iOS and iPadOS beat it in terms of speed and power saving. I hope they will get rid of the Java remnants completely and focus on the native toolchain, frameworks, system libraries.
Meanwhile there's a article literally on the front page about zero-click exploits being used against iMessage
Re: New language features since Java 8 to 17
#316Earlier quoted context omitted.
Except that having the type info is really, really useful at the call site. I know the IDE is able to infer it and display it but it's still a pain to see all the vars during a code review in a browser.
It's not the IDE, it's the compiler that infers it. So type information is always available.
To me var adding is mosttly an anti-feature - when using an IDE, I dont even bother to declare the stuff, it gets auto completed. When I read code outside the IDE - well it sucks. It's not the level of 'perl - write only', but at least it aspires to be.
Re: New language features since Java 8 to 17
#317Earlier quoted context omitted.
If Kotlin is unreadable without an IDE, it's Kotlin done badly. You can misuse its features to obfuscate the code, but in and of itself it's an extremely clear language.
Kotlin relies on the developer to write readable code, and just generally offers way too many ways of doing the same thing. Too much freedom of expression. Java, by virtue of being more verbose, requires writing everything out explicitly, so you really have to expend some extra effort to make your code unreadable.
Such as?
"Java, by virtue of being more verbose, requires writing everything out explicitly, so you really have to expend some extra effort to make your code unreadable."
Boilerplate is what makes code unreadable. Getters, setters, backing fields, all that noise, takes lots of space getting in the way of grasping the meaning of the code. Java is too much about how instead of what.
Re: New language features since Java 8 to 17
#318Earlier quoted context omitted.
Java has had quite a head start (.net core came out only 5 years ago). Now the "doing a lot better" is dwindling. And dragging feet on QoL isn't helping.
The gap between Java and C# has grown very slowly but surely for many years, and more people feel Java is changing too quickly than too slowly. Different people prefer different things, some will always prefer Pepsi (although C# will probably not be that Pepsi, as it's lost too much ground and MS seems to be losing interest in it, as they tend to do), and our goal isn't to adopt the strategy of less successful produc…
wat
> our goal isn't to adopt the strategy of less successful products
This sounds like "we don't care if some other languages have great quality of life improvements, we pretend that success (for some unknown definition of success) is the only thing that matters, so we'll keep implementing one or two features every 10 years that don't work with half the language and standard lib, and still require hundreds of lines of boilerplate to work with."
In a sibling comment you're pretending that withers is a thing that will ever happen. It won't, not for another ten years. Meanwhile we're left with a language that has to resort things like Lombok to try and cut down on the ridiculous amounts of code one still has to write for even the simplest things. Or almost but not quite incompatible lists and collections (none of which have even a pretence of a DX for easy construction). Or value types that have been a proposal for 9 years, and generics with primitive types that has been a proposal for 7. And the list (or collection? or stream? or?...) just goes on and on and on.
Thank god we finally got multiline text blocks and some form of pattern matching. Wait. Those come from less successful languages. How could you?
Re: New language features since Java 8 to 17
#319Re: New language features since Java 8 to 17
#320Earlier quoted context omitted.
But at the other hand, C# is heading in the direction of C++, where even after n years working with it, it can still surprise you/find yet another way of doing this and the rest. Like, I would prefer not having 10+ initializers from C++ in a language.
But on the other hand you have object initializers directly in the language In Java you have one of these: - a hope that someone provided a useful static `.of` method - a hope that someone provided the 15000 setter methods that you have to tediously invoke one by one - a hope that someone provided a generator that created a builder that has 15000 setter methods that you have to tediously invoke one by one Meanwhile i…
> And don't get me started on array vs list vs collections none of which are compatible with each other.
This is not true. Lists are collections, and while arrays are different, Arrays.asList() gives you a list view of arrays.
> And hundreds of other QoL improvements that are begging to be implemented, and are not.
First of all, just in the past five years we got local variable type inference (var), switch expressions, records (with much more to come), sealed classes, and basic pattern matching (with much more to come), and string templates are around the corner. All of those are significant QoL improvements.
Second, every feature comes at the expense of all others -- both because of opportunity cost and overall language complexity budget -- and the question is one of priorities. Not everyone has the same priorities.
Finally, because Java is expected to remain extremely popular for at least a couple more decades, we must be very careful about adding features. While other languages are trying desperately to gain many developers right away, we're looking ahead to ensure that we'll be attractive to developers in ten and twenty years from now, and so must spend the complexity budget carefully.