Live data from Hacker News

Java 16

jdk.java.net

201–210 of 327 posts

Re: Java 16

#201
post #64

Earlier quoted context omitted.

I’m more a Scala dev than Kotlin Think it’s safe to say both influenced Java’s Record, shoulda mentioned Kotlin too.

Kotlins data class is functionally basically the same as a lombok @Data class used in Java. Why Java didn't keep the name "Data class" I don't know.

"Data" is such an overloaded and vague term, anyway. Almost all classes have "data", so what the heck is a "data class"? Is it one that only has data (not behavior)? Nope- these can have arbitrary methods.

So, I'm kind of glad they didn't use it. (But, to clarify, I really don't care what color the bike shed is)

I'm more wondering why they didn't go with "struct" or "value class", especially because the latter is exactly what we've been calling "class whose equals() is defined by content rather than identity" for many years.

Re: Java 16

#202
post #108
post #12

Very cool to see that Scala continues to have a huge impact on Java’s roadmap. Records and Sealed Classes are borrowed from Scala. Could be not the best news for new Scala adoption, but good news for developers having better abstractions in Java Edit: Kotlin, and other languages should also mentioned since they also include similar features. I still think Scala has had the most influence over the years.

I think Kotlin is more at risk than Scala on the server at least. Scala still has a lot of advanced features that sets itself apart. Kotlin is a better Java but Java is catching up fast.

Agreed. But Kotlin 1.5 will have enough interesting stuff with the new inline class and const methods that I think it'll keep its appeal for quite some time.

Re: Java 16

#203

Earlier quoted context omitted.

Maven runs on 1 out of the 4 mentioned platforms. There are no Android, iOS, or web builds of Maven. Maven is used to ship dependences for the other platforms, but it is not run itself on those other platforms. Shipping an Android-specific library on Maven isn't magically portable (which is what's common here - OS-specific libraries on Maven). It's still Android-specific.

All Android builds use Gradle and download their dependencies from Maven Central. I have no idea what you're talking about. Let me repeat this: all Windows, macOS, Linux, and Android apps that use Maven or Gradle to build ALL download their dependencies from Maven Central. These are the very same libraries, same bytecode. For example, do you use Mockito? You will download that exact same library from Maven Central re…

When you build Android you're not building it on Android, you're building it on Windows, MacOS, or Linux. Maven itself is not being run on Android or iOS.

The Java code that powers Maven isn't portable. The AndroidX code hosted on Maven that everyone is pulling down for Android isn't portable, either.

Your claim would be like saying that PHP is portable because every platform has a web browser that can talk to the server running modphp. That's not what portability means.

> For example, do you use Mockito? You will download that exact same library from Maven Central regardless of the platform you are building on.

Mockito only runs on 2 of the 4 platforms (doesn't run on iOS or web).

Re: Java 16

#204

Earlier quoted context omitted.

The new object type being promoted from preview feature is just the record type. Records are still Objects, they just provide a low ceremony way to create an immutable object holding some data. I see these record classes in the same category as enum objects, an evolution of the language to improve developer ergonomics. Upcoming is inline-classes (previous called value types.) When this happens we'll have a true "spec…

Even if `record` is a syntactic sugar, I'd better see a canonical constructor added to all usual classes. The constructor parameters are of types of all the fields, in the declaration order. In this case we could say class Point { public final int x, y; } instead of record Point(int x, int y) { } Usual non-record classes would benefit greatly from such a feature too. Actually, if class fields have different visibilit…

Adding a new canonical constructor to all classes would very likely have backwards compatibility issues, so we'd likely need some sort of opt-in mechanism. In the end the language designers decided that they wanted to give developers a way to create a very focused kind of object.

This goes into the design motivations: https://cr.openjdk.java.net/~briangoetz/amber/datum.html

Additionally, one less talked about benefit of records is they have a simplified serialization scheme that is safer by default. Records when being deserialized have each of their members read and then the canonical constructor is called, if the values are not valid then the constructor can reject the fields instead of allowing an "impossible" object from being created.

Re: Java 16

#205

Earlier quoted context omitted.

> As a student most of the way through a Java course, I'm wondering what Java is still used for. A huge majority of all code behind services, websites, and businesses you interact with every day. From Google, Facebook, Apple, and Twitter to your bank, and from Android to you favorite new unicorn. Of the top 25 unicorns "20 use Python; 19 use Java; eight use Kotlin. Coinbase was the only top-ten unicorn found to use S…

> Java applets have been dead on arrival The only successful Java applet I know was Runescape (if that was an applet? it ran in browser), an RPG game that ran in Java in the browser, for 15 years or so roughly afaik, today they switched to a non browser based client instead. Other Java applets almost never worked for some reason. Like, sometimes I'd visit a website about some mathematical topic, and the whole browser…

The first "real" Java program I wrote back in 1997 was a huge applet. It was the replacement for an existing X Windows application, with 42 screens. The applet itself worked great, but the networking technology at the time was such that when all the users on a network segment started their browser and launched the applet, it bogged things down to a crawl. Still, when it was loaded it was amazing (for 1997). It looked almost exactly like the original application, and updates were as easy as putting a new jar file onto the web server.

Re: Java 16

#206

As a student most of the way through a Java course, I'm wondering what Java is still used for. Java applets are dead, Android is moving on to Kotlin (apparently Google got in legal trouble with Oracle even though Java is "open source?"), and I can't think of any desktop applications that use Java anymore. Java is supposed to be able to "run anywhere," yet C++ is more portable because it doesn't require the JVM to run…

Java is rarely used for sexy stuff like front-ends or (increasingly) apps.

Java is, however, used for services. Bank logins, search engines (Google originally used it), insurance systems.

C#, C++ and Rust are in the same area. But Java, for the most case, has been around longer.

A LOT of companies used it and can't easily switch their codebase to something newer and shinier. And now Java improves with every release they have fewer reasons to move.

Re: Java 16

#207

Earlier quoted context omitted.

Arguably, Kotlin took some of the better ideas from Scala.

Arguably? I'd say it's rather obvious, but overall they're different languages with different goals.

To be fair, “arguably” has come to mean “no doubt.”

Re: Java 16

#208

Earlier quoted context omitted.

All Android builds use Gradle and download their dependencies from Maven Central. I have no idea what you're talking about. Let me repeat this: all Windows, macOS, Linux, and Android apps that use Maven or Gradle to build ALL download their dependencies from Maven Central. These are the very same libraries, same bytecode. For example, do you use Mockito? You will download that exact same library from Maven Central re…

When you build Android you're not building it on Android, you're building it on Windows, MacOS, or Linux. Maven itself is not being run on Android or iOS. The Java code that powers Maven isn't portable. The AndroidX code hosted on Maven that everyone is pulling down for Android isn't portable, either. Your claim would be like saying that PHP is portable because every platform has a web browser that can talk to the se…

Who cares about Maven-the-app, we are talking about the portability of the JVM bytecode.

There are gigs of JVM bytecodes stored on Maven Central and these bytecodes are being downloaded and run on macOS, Windows, Linux, and Android on a daily basis without a single change. The very same libraries. Unchanged.

That's the very definition of portability.

I don't understand why you keep shifting topics by bringing up irrelevant observations.

Re: Java 16

#209
post #89

Earlier quoted context omitted.

Java 8 → Java 11 → Java 17. Those are the LTS releases. If you want to follow a release cadence similar to Java 5 → Java 6 → Java 7 → Java 8, that's what you'll track. The intermediate releases can be used to test against, but adopting them too soon often means tackling lots of issues in your dependencies. And updating your application servers to a new major Java version every six months is not something you can do e…

Not quite. LTS doesn't mean anything if you mention just the Java versions. This is not e.g. Ubuntu LTS. In java you have different vendors that provide LTS and you need to pay for it. Oracle, Redhat, etc. provide LTS versions (and those happen to be 8, 11, but don't have to be). And there is one more sortof LTS: latest java version, because it always gets all the security and other bugfixes. Right now it is Java 16.

OpenJDK's supported/not-supported classification seems to match and would appear far more reasonable.

Re: Java 16

#210

Earlier quoted context omitted.

> As a student most of the way through a Java course, I'm wondering what Java is still used for. A huge majority of all code behind services, websites, and businesses you interact with every day. From Google, Facebook, Apple, and Twitter to your bank, and from Android to you favorite new unicorn. Of the top 25 unicorns "20 use Python; 19 use Java; eight use Kotlin. Coinbase was the only top-ten unicorn found to use S…

> Java applets have been dead on arrival The only successful Java applet I know was Runescape (if that was an applet? it ran in browser), an RPG game that ran in Java in the browser, for 15 years or so roughly afaik, today they switched to a non browser based client instead. Other Java applets almost never worked for some reason. Like, sometimes I'd visit a website about some mathematical topic, and the whole browser…

Don't know about "successful" or "useful", but the Java Applets on Complexification were some of the most beautiful software I've ever seen: http://www.complexification.net/gallery/
Post reply on HN