Lots of shiny new toys to play with :) I like playing with new features and pushing to silly limits. Here's some fun things you can do now: Compiletime checked state machines with Sealed Classes [preview feature] https://benjiweber.co.uk/blog/2020/10/03/sealed-java-state-m... Autobuilders, Mixins, Conversions & more with Records https://benjiweber.co.uk/blog/2020/09/19/fun-with-java-recor... Pattern Matching fun http…
If you enjoy pattern matching in Java, I would recommend checking out the latest & greatest that C# has to offer as a comparison: https://docs.microsoft.com/en-us/dotnet/csharp/pattern-match... Being able to combine pattern matching with switch expressions has allowed us to construct extraordinarily concise state machines for our UIs.
Java 16
191–200 of 327 posts
Re: Java 16
#192Earlier quoted context omitted.
> C++ is more portable because it doesn't require the JVM to run Java is portable BECAUSE of the JVM. If a new computer architecture hits the scene, once someone writes a JVM for it your .class files will run on it (probably). Your C++ program, however, will definitely not run and you'll need to recompile it with a compiler that targets that new architecture. The same compiled Java code will(should) run on a Mac or a…
> but your Java .class files are portable. No, they aren't, they regularly have non-portable dependencies or assumptions about the environment. For example, it's more or less impossible to write a Java program that runs on Windows, Android, and iOS - the 3 most popular OS's. You have completely different UI support between Windows & Android, and there's not really any JVM for iOS (there's AOT, but now you're not even…
Platforms that do not aim to do that are not really relevant.
Re: Java 16
#193Earlier quoted context omitted.
Because Scala is a truly innovative and experimental language that came out of a programming language research group. That's why there's a lot of features that didn't play out well in real-world. F# started out as .NET rendition of OCaml. Most languages initiated by large crops don't try to be innovative, rather they take approaches introduced by different niche languages (many of them are only for research purpose)…
F#'s relationship has been vastly overblown. The truth is that they're about as closely related as C# and Objective-C. In the same way that the overlap between C# and ObjC is basically just the C bit, the overlap between F# and and OCaml is basically just the ML bit. (Actually, even less than that.) You could say that it was inspired by OCaml, but it includes almost none of what makes OCaml OCaml, and adds a lot of i…
Do people just draw the comparison because they don't actually know of any other ML languages besides OCaml?
Re: Java 16
#194Earlier quoted context omitted.
I think that is by design due to reflection needs. Hard to prune unused code when it might be called reflectively at any time.
Which is why GraalVM requires you to explicitly mention what types should be available for reflection.
Re: Java 16
#195Very 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.
> Records (...) are borrowed from Scala. I think records already existed in FORTRAN and other languages like ALGOL-60. C has structs, too.
In particular, I'm talking about the fact that Java doesn't really have "copy types" or "pass by copy" or whatever. So, sure, C has struct, Swift has struct, etc, but Java can't really model its version off of the way those work.
Re: Java 16
#196Earlier quoted context omitted.
If you enjoy pattern matching in Java, I would recommend checking out the latest & greatest that C# has to offer as a comparison: https://docs.microsoft.com/en-us/dotnet/csharp/pattern-match... Being able to combine pattern matching with switch expressions has allowed us to construct extraordinarily concise state machines for our UIs.
I used Java a lot and like some aspects. But I think C# is way ahead in some important ways and Java is playing catch-up
That being said, I'm currently getting paid to write C#, so if you've got any resources for converts, I'd love them! :)
Re: Java 16
#197Earlier quoted context omitted.
> but your Java .class files are portable. No, they aren't, they regularly have non-portable dependencies or assumptions about the environment. For example, it's more or less impossible to write a Java program that runs on Windows, Android, and iOS - the 3 most popular OS's. You have completely different UI support between Windows & Android, and there's not really any JVM for iOS (there's AOT, but now you're not even…
> For example, it's more or less impossible to write a Java program that runs on Windows, Android, and iOS Not only is it possible, it happens all the time. The entire Maven Central repository, which contains tens of thousands of JVM libraries, is usable on all the platforms you just listed. If that's not portability, I don't know what is.
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.
Re: Java 16
#198As 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…
And this isn't changing anytime soon. Their initial investment, continue investment and Java Ecosystem itself are still marching forward. I dont see any language ecosystem that could match or challenge Java any time soon. Remember you only see Java Haters on HN and Reddit. In the Real World it is all about Business Values Delivered and Get Shit Done.
JVM in itself is a monster with State of the Art GC and JIT.
All of the above means there is a positive feedback loop into making Java better. And there are things that were in the work for 10 years ( Like GraalVM ) before hitting mainstream. And many more to come.
Re: Java 16
#199Earlier quoted context omitted.
> For example, it's more or less impossible to write a Java program that runs on Windows, Android, and iOS Not only is it possible, it happens all the time. The entire Maven Central repository, which contains tens of thousands of JVM libraries, is usable on all the platforms you just listed. If that's not portability, I don't know what is.
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.
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 regardless of the platform you are building on.
Re: Java 16
#200Earlier quoted context omitted.
> but your Java .class files are portable. No, they aren't, they regularly have non-portable dependencies or assumptions about the environment. For example, it's more or less impossible to write a Java program that runs on Windows, Android, and iOS - the 3 most popular OS's. You have completely different UI support between Windows & Android, and there's not really any JVM for iOS (there's AOT, but now you're not even…
When people call .class files portable, they mean between platforms that have a JVM available and can pass the TCK. Platforms that do not aim to do that are not really relevant.
Market share determines a platform's relevance to portability claims, not its intention towards the JVM.