Live data from Hacker News

New language features since Java 8 to 17

advancedweb.hu

141–150 of 358 posts

Re: New language features since Java 8 to 17

#141

Earlier quoted context omitted.

But reading terse code requires a lot more prior knowledge, which you might not have. You learn to recognize patterns in the boilerplate and just glance over it, taking no additional time.

It definitely does not take “no” additional time to read verbose boilerplate code. As for prior knowledge, that argument doesn’t fly. A lot of the verboseness of Java could be addressed VERY easily with clear syntax that doesn’t require a lot more prior knowledge. An example is getters and setters, which are very easy to understand in languages that have built-in support for concise syntax but Java has somehow ignore…

> E.g., correct usage of arrays vs. ArrayList.

Arrays vs lists is a thing in all languages, not Java. They just have different names (list, vector, sequence...)

Re: New language features since Java 8 to 17

#142
post #78

Earlier quoted context omitted.

Scala is fine. People understood it's not really worth it as a "better Java". Companies that choose Scala in 2021 are using either big data frameworks (where Python bindings are the most common alternative to Scala, not Java), or functional ecosystems (Typelevel, Zio). Scala 3 has taken an interesting direction and to me it seems that Odersky wants to win Python developers over rather than Java shops using Spring. Ne…

Kotlin started out as a better Java but it's more than that now. With Kotlin multiplatform you can compile to JVM, Javascript and Native from the same repository. Java has been catching up on language features but I'm not sure if I'm ready to switch back to Java for Spring projects yet. Mostly because of nullability, extension methods and coroutines in Kotlin.

Targeting multiple platforms is orthogonal to the core language design goal, which has always been to be more like C# on the JVM, with 100% Java interop and no need for a big standard library.

I give you nullability, however extension methods without proper typeclasses is just syntactic sugar, and coroutines will be superseded by Loom.

Java hasn't only been catching up, it now supports pattern matching which Kotlin still lacks.

Re: New language features since Java 8 to 17

#143
The “keep readability in mind” tip exposes more Java/OOP icebergs.

  var date = LocalDate.parse("2019-08-13");
  var dayOfWeek = date.getDayOfWeek();
  var dayOfMonth = date.getDayOfMonth();
> The first one is pretty intuitive, the parse method returns a LocalDate object. However, for the next two, you should be a little bit more familiar with the API: dayOfWeek returns a java.time.DayOfWeek, while dayOfMonth simply returns an int.

Java.time.dayOfWeek takes a TextStyle and a Locale, both of which have a list of properties and methods I have to read all about before using. dayOfMonth returns an int, and I can see if it’s 0- or 1-indexed then do what I want with it from there. Why does DayOfWeek have a class instead of being a function that I can throw a number at like dayOfMonth?

I’m also skeptical about Java.LocalDate being “pretty intuitive,” having worked on local vs server vs data-store timestamps, as most of us have. At least LocalDate doesn’t have mutable setter methods like other Java dates…

Re: New language features since Java 8 to 17

#144

Java sucks, and should stop being taught as the defacto language in computer science curriculums. It's extremely busy and verbose. There are better OO languages out there, if the point is to teach OO. (I'm ready for this post to get downvoted into oblivion)

Could you please support your statement with reasons?

Lots of other good arguments have been posted, but I'd like to say something to the teaching aspect. In high school, we had four years of Java. I already knew most of the curriculum at the start, so others would sometimes ask me for help with assignments. Quite a few times, even after years of school, I'd run into people being confused by classes, instances, what curly braced blocks meant on a class vs on a control statement...

You could say the class should've been taught better, or that the students just weren't good enough, but I think a good tool (programming language) should help users, not be a barrier to overcome. Programming in Java doesn't require too many concepts, but you have to start with all of them at once, and I think some students just never got over that initial step.

It's of course debatable whether another language would have been better or whether Java really contributed to the problem, but I think we can agree there are languages that better lend themselves to teaching complete beginners.

Re: New language features since Java 8 to 17

#145
post #139

Earlier quoted context omitted.

Being verbose is a plus. I really really really hate the terseness of Kotlin and how it's basically unreadable without an IDE. Languages should be dumb. Standard libraries should be smart. Not the other way around. The number of syntax constructs that generate standard library calls when compiled should be minimized as much as possible. Edit: one more thing, operator overloading is extremely harmful for readability.

The tradeoff space you’re describing doesn’t reflect reality. Adding more brackets and pointless keywords to a language doesn’t meaningfully improve the programmer experience in any way. There are plenty of terse languages that don’t require an IDE to understand. If anything, Java effectively requires an IDE to use because it’s so verbose. The things that I write in a computer program’s code should correspond as clos…

Excellent counterpoint about Java requiring an IDE because it’s so verbose. In fact when I complain about Java’s verboseness, Java fans tell me “who cares, just use your IDE’s ability to auto-generate code!” But of course that doesn’t help with the _reading_ of verbose code.

Re: New language features since Java 8 to 17

#146

Earlier quoted context omitted.

I agree with everything here except the "should stop being taught as the defacto language in computer science curriculums". Realitically, a CS curriculum needs to at least vaguely prep a student for life in the industry, and Java is not only massively popular, but is also a great way of showing how OO is used in practice i.e. kinda badly. No point teaching everyone about beautifully architected Smalltalk programs jus…

teach javascript, ruby, rust, go, kotlin....scheme. literally anything else.

how's javascript better than java in its design or elegance?

Re: New language features since Java 8 to 17

#147

Earlier quoted context omitted.

Most likely to Flutter. When Google will be ready to ditch Android API.

Android is based on the JVM, it will never switch to Flutter (and an aggravating factor is that Dart is an inferior version of Kotlin).

If you want some fun watching Jake Wartorn's opinion on it,

https://youtu.be/VX6nAvRWQg4

Re: New language features since Java 8 to 17

#148
post #48

It's good to see Java starting to waive a lot of the boilerplate. (And frustrating, when stuck on v8.)

A friendly advice: dont be afraid to use public final immutable fields and omit the getters (and setters since you cant have them w/ finals).

Probably should just use records and get all that for free.

Re: New language features since Java 8 to 17

#149

Earlier quoted context omitted.

Android is based on the JVM, it will never switch to Flutter (and an aggravating factor is that Dart is an inferior version of Kotlin).

The JVM is specifically the part of Java Android didn't use, and the layer Google has already completely replaced once.

DEX must be able to represent everything on the Java ecosystem, otherwise it is a hit and miss what can be consumed from Maven central.

Also it is quite common on embedded Java for the vendors to have their own implementation with code translation.

What isn't normal is having stagnant compatibility.

Re: New language features since Java 8 to 17

#150
post #141

Earlier quoted context omitted.

It definitely does not take “no” additional time to read verbose boilerplate code. As for prior knowledge, that argument doesn’t fly. A lot of the verboseness of Java could be addressed VERY easily with clear syntax that doesn’t require a lot more prior knowledge. An example is getters and setters, which are very easy to understand in languages that have built-in support for concise syntax but Java has somehow ignore…

> E.g., correct usage of arrays vs. ArrayList. Arrays vs lists is a thing in all languages, not Java. They just have different names (list, vector, sequence...)

I don’t think Ruby or Python have linked lists, only arrays.
Post reply on HN