Java 16
jdk.java.net
jdk.java.net
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 https://benjiweber.co.uk/blog/2021/03/14/java-16-pattern-mat...
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.
Also, a significant part of Java development happens at the runtime level, where I would wager the catch-up is in the opposite direction, in some areas by quite large margins.
That being said, I'm currently getting paid to write C#, so if you've got any resources for converts, I'd love them! :)
Broad availability of third-party libraries? Java Flight Recorder? IntelliJ? Multiple build system options including first-class support for Bazel, Gradle, and so on. (Msbuild gets old quick...)
That said, personally I prefer TypeScript over all of the above if performance isn't an issue. ;-)
Even still, libraries are not a problem. Nothing you can't do in C#. You should check out Rider. Bazel and Gradle are cross platform as well.
Flight Recorder is good. I'll give you that. The .NET debugging tools are top notch...on windows. JFR wins out handily until the Linux tools reach parity. Though, again, this is all ecosystem and not language design.
You say "careful", others would say "stubborn". The refusal to add things like operator overloading lead to a much less aesthetically pleasing language to read and write.
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.
While it's good for C#/Java, it does make it harder to push for adoption for a language such as Scala and F#. Why bother investing in the languages with a much smaller market share when the big boys adopt good bits and pieces from them constantly?
This won't always apply, but sometimes (many times?) there's a software endeavor that permanently feels on the margins of a programming language's capabilities, whatever that means. You may forego market share in order to be 5 or 10 years ahead of current practice. In other words, the mainstream isn't converging to a stable F# / Scala / whatever. It's lagging behind. It's not the last time that a mainstream language adopts a feature that has been available for years in a more fringe ecosystem.
In practice, I'm sure the most important thing is humans and their skill, so mainstreamness matters. But if you can somehow be less sensitive to that, you may reap a lot of benefit from using Foo before it was cool.
So I do not see them a sure win for projects I work on.
The only big F# feature I know of that's fallen out of favor is type providers, and, IMO, that's not because the feature was half-baked so much as because it was one of the many casualties of .NET's transition to being a truly cross-platform toolkit.
because if you know exactly what you want to do there's no reason to settle for the second best thing. If you want F#, no harm with going exactly with F#.
I talked to a bunch of Jane Street engineers once and the consensus seemed to be that Ocaml, despite its very small footprint, actually helped them attract the kind of people who were super enthusiastic about building really good stuff with a good technology, so it actually made recruiting for them easier.
Sounds like a strong case of selection bias.
There is no shortage of people who are super enthusiastic about building really good stuff with good technology, and it's hard to believe that it's easier to hire Ocaml engineers than other languages.
On the other hand, if you see someone took the time to learn OCaml, I think you can be reasonably well assured they legitimately love programming. Signal value jumps from "this person has ever programmed" to "maybe this person has a real passion for it."
The C# versions of F# features tend to be pretty clunky compared to the F# versions. This is because F# was designed for them from the beginning, rather than having them tacked on. Functional programming is getting easier in C#, no question about that, but honestly, it still kind of sucks. And the OOP-minded C# devs on your team still won't be able to make sense of your code that leverages all these fancy new features anyway.
I think some things about functional programming make code feel cleaner, but I don't like it enough to use F# or Haskell.
(Note this is horrible because C# does not support this style well, in F# it's idomatic)
What matters is what we do with the language, more than the name of it no?
UPDATE: Ah, C# v9.0 thank you all.
Parsing that sentence the subject is C# and F# is referenced, but the subject of the sentence didn't change, it remained C# thus logically v9 applies to it.
In the end platform languages always take the most relevant pieces from the guest languages, which eventually fade away.
I think records already existed in FORTRAN and other languages like ALGOL-60. C has structs, too.
COBOL was a popular, very early language supporting hierarchical data of different types. This dates back to approximately 1960.
FORTRAN didn’t have records other than I/O “records” (at least for the first 20 years). ALGOL-60 didn’t have records. Algol-68 did have records, however Algol-68 wasn’t in very widespread use. I never had an opportunity to use it; compiler technology at that time wasn’t really ready for such a challenging language. Algol-68 may not have had widespread use, but a number of it’s features made their way into influential languages like C, Pascal, and Simula. These languages did have records.
As I recall, IBM’s PL/1 did have records, I seem to recall using them in the 70’s in a PL/1 program. PL/1 was kind of an amalgamation of FORTRAN and COBOL’s features.
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.
Think it’s safe to say both influenced Java’s Record, shoulda mentioned Kotlin too.
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.
Structs/value types can be mutable, records are not. They are basically tuples with names. And as far as I know, while records have a sane default equals defined, they are still identity objects in that they are passed by reference.
Fair point about record fields not being reassignable (not the same as immutable for others reading this).
> And as far as I know, while records have a sane default equals defined, they are still identity objects in that they are passed by reference.
Well, sure. All non-primitives are passed by reference. That doesn't stop them from being referred to as value types.
But in light of your first point, I agree that choosing a totally new term probably makes sense.
But in any case, I'm thinking that the real timeline is more that Java is prioritizing features that are most attractive from Kotlin, which borrowed the ideas from Scala. But Scala never got super popular, so there was not much pressure or "proof" that these were good ideas until everyone fell in love with Kotlin.
... but, you have to be pretty damn good to win out over the native language of a platform. And if it were just Kotlin today vs. Java 16, I think Kotlin is a much nicer language, but it doesn't really differentiate itself that much. Sure, it's syntax is much nicer, but you still basically have the same semantics as Java. You have classes; everything is a reference; no const/immutable data; no (good) general way to clone things; you have the same-ish type system with inheritance and interfaces, but no type classes; still have weird shit like sized numeric types with over/underflow; exceptions for error handling; etc.
At least Scala has monads and type classes, so you can say it actually has some expressability that Java truly doesn't. I'm not sure that Kotlin has that. Clojure is a totally different beast that really doesn't directly compete over Java devs, IMO. It just happens to use the JVM as a platform.
I generally agree that being multiplatform is a lofty goal. And as much as I like Kotlin, it clearly inherits some of Java's (IMO) deficiencies. I'm not sure why I'd want those deficiencies exported to my native code when I could use lots of other nice languages.
Java 11 is the newest LTS release. The next LTS release will be Java 17. Many companies won't touch anything that isn't LTS. There are still a large number of companies staying on Java 8 :shrug:
chart here https://en.wikipedia.org/wiki/Java_version_history
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 easily coming from older Java versions. It's not impossible, but it may require a different deployment strategy and may not benefit you much over going from LTS to LTS.
I think that there is also an unspoken feeling that the LTS releases are more stable, which again may be due to the libraries you depend on not always being as well tested on the intermediate releases. I think a lot of Java developers burned their fingers on Java 9 and 10 and are now sticking to the LTS releases, but that is just my gut-feeling.
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.
Think of Java versions as patch releases for Java 8. There are minor changes between releases.
This is where I hope Java adopts the .NET support lifecycle. .NET also has (relatively) fast-paced releases now, once per year with LTS every other year, but the prior non-LTS is supported for 3 months after the next one comes out. That's still pretty aggressive, but it's very doable with a modern app to upgrade within 3 months.
With Java, JDK 15 support ends this month, the same month that JDK 16 comes out. Not just that, but we're halfway through the month already. So if you're on JDK 15, you now have only two weeks to upgrade and still be supported, according to their official schedule.
https://www.oracle.com/java/technologies/java-se-support-roa...
Edit: I may have been too generous in my reading of their support roadmap. It seems like the previous non-LTS version is immediately out of support as soon as the new one "supersedes" it.
I know because I use Spring (and hibernate) and everything just works.
(If you are on the most recent Spring version)
Time for me to learn so let me rephrase this question! Those who use java without EE or Spring framework, what are your go-to libraries? What are you using for DI / REST / ORM / Auth etc?
Yes. And I don't just mean people doing Android development.
1) DI: Don't always need DI. For things like injecting values from config, it's really unnecessary given that we have very good control over production, down to building our boxes from a playbook. For things like mocks, plain old Java suffices -- you can roll your own (actually, someone in your team just needs to do it once and it keeps getting improved/forked). Guice exists as a fallback.
2) REST: Jersey + own libraries on top, Retrofit. Using Spring for REST is probably the poorest use for Spring, for me.
3) ORM: you can use "just" JPA. Don't always need an ORM either -- the strategy varies depending on the requirement. Although for some projects I have used Spring Data JPA because it seemed like the easiest path. At least Spring was localized to that artifact.
4) Lots of good OAuth2 libraries as well as things like pac4j. If you're wondering about Spring Security, it's definitely one to consider if you're doing lots of webapps in Java. But in a polyglot environment, a lot of Java code just handles APIs while node handles the UI.
Anyhow, this isn't to hate on Spring or anything -- I use it if it adds value. This is more about not taking the the complexity hit if you can help it. It also makes the code a bit more straightforward and readable.
If you read Ron Pressler's comment on Reddit[1], the recommendation is
> In any event, the default position should be to keep up with the current JDK as much as possible (it's OK to skip a version or two), and consider LTS only if there is some specific difficulty preventing you from doing so. As I said before, the "current JDK" upgrade path is designed to be the one that is overall the cheapest and easiest for the vast majority of users -- easier and cheaper than the old model.
For users who are happy with the current JDK language level, newer releases also have JRE improvements:
> ...those users should [also] prefer the current JDK, too, as that is the easiest, cheapest update path. Also, new feature releases contain performance and monitoring improvements (e.g. JFR, ZGC, AppCDS in the last few releases) that may be of interest even when users are not interested in new language/library features.
> The problem with LTS is that it's costly (costlier than the old model): on the one hand, the risk of a breaking change in an LTS patch is no lower than in a feature release, and on the other hand, the patches no longer contain many gradual implementation features (that you use without knowing). In addition, the OpenJDK development process revolves around feature releases without regard for LTS, so features can be removed without notice in an LTS release. This makes an LTS->LTS upgrade more costly than in the old model.
> LTS is designed and is advisable for companies that prefer a costly, but well-planned, three-yearly upgrade process.
> Even if you've carefully considered the options and decided that LTS is the right approach for you, you are strongly advised to test your app against the current JDK release to reduce the cost of an LTS->LTS upgrade.
> It's true that upgrading from 8 to post-9 can be non-trivial (9 was the last ever major release), but once you do that, you have an update path that ensures you'll not have a major upgrade ever again.
Java upgrades inside enterprises cost time and money, no sense in taking that cost if you can help it, and many engineering teams with good DevOps can easily dodge this cost.
[1] https://www.reddit.com/r/java/comments/c5pl1q/adoptopenjdk_i... , https://www.reddit.com/r/java/comments/c5pl1q/adoptopenjdk_i...
I would say, try it out and see.
What kind of problem could you identify? Same might happen with LTS release (e.g. I had it in JDK 8, suddenly I wasn't able to use some crypto libs).
Fixes always go first to JDK latest, and then are backported to 11 and 8.
Without it the only LTS is current java version: 16 right now and 17 in 6 months.
And many Java devs employers don't pay for LTS.
So ad 1 and 1 and you get a false claim that any java 11 version is an LTS, which is not true.
https://inside.java/podcast/#:~:text=The%20Inside%20Java%20P...!
Yet clearly I'm mistaken, since Java is still one of the most popular languages.
Edit: also please help me understand - do I have to pay for a license even though Java is open source? Is this normal for other languages too?
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 Swift." [1]
And that's just startups and FAANG. On top of that, every enterprise, government organization, and financial organization also uses tons of Java with the exception of Microsoft shops, which use C# in its place (or also use C# on top of Java).
Think of it this way: you know how C# is a big industry? It's #5 in the TIOBE index. Java is #2, and has been between bouncing between #1, #2, and #3 spots for decades.
And on top of Java there's the JVM, which also powers Kotlin, Clojure, Scala, Groovy, and other languages...
>Java applets are dead
Java applets have been dead on arrival. It was just a fan around 1997-1999 and not that succesful even then (I was there). They were never a big part of Java's allure.
>Java is supposed to be able to "run anywhere," yet C++ is more portable because it doesn't require the JVM to run.
That's a non-sequitur.
[1] https://insights.dice.com/2019/07/12/python-java-kotlin-skil...
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 would hang while some java applet demonstrating the math was supposedly loading, and then most of the time it didn't actually work.
Worked like a charm. I have yet to see anything similar to that.
There's a link to the original Java version below, that one doesn't work for me anymore, I no longer have a java-enabled browser
Well, plus the fact that no modern browser runs Java applets...
It's a very popular backend language. Ironically, "run anywhere" isn't much of a requirement for backend development.
> C++ is more portable because it doesn't require the JVM to run.
For backend development, this isn't much of an issue either way. These days, the main advantages C++ has to Java is startup time and no GC pauses.
It's also not as portable as you'd think. Take a look at cross-platform C/C++ projects and you'll see a lot of special cases for particular platforms.
Java's popularity mostly boils down to it's mature, has a large ecosystem, and is adequate for a lot of things. Unless you're writing an iPhone app or system-level code, it's unlikely to be a bad choice.
If you’re using Java, you can develop on macOS, deploy on Windows Server, then switch to Linux on AWS Graviton and M1 Macbook. Without a singe recompilation.
Also, for very different use cases like soft real time, there are specific JVMs with real time guarantees.
Here is a great post about it: https://jet-start.sh/blog/2020/06/09/jdk-gc-benchmarks-part1
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.
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 PC or any Linux box, but you need a different executable for each target with a C++ program.
The JVM isn't portable. That needs to be recompiled for each new target, but your Java .class files are portable.
On the desktop and servers, maybe. But there is more in heaven and embedded than is dreamt of in your philosophy.
If you wanted the full fat SE Sun/Oracle JVM you were pretty much stuck with power or ARM, and even then you had to be careful. Remember the portability disaster that was symbian and Java ME? These ISAs weren't exactly the low end of the embedded market at the time either. The farther away from x86 you got the less portability you could actually take advantage of.
Don't forget Java Card in that list. Which Oracle still tries to claim as a Java portability win, even though it doesn't support basically anything. And I don't mean missing standard libraries, I mean like it doesn't support char, double, float, and long, or multidimensional arrays. Support for int is even optional. Doesn't support exceptions and you can't even assume it has a garbage collector. Among many other limitations.
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 pretending to run a .class file)
So to make a "portable Java" program you're already stuck compiling it 3 times for the 3 major OS platforms, but without anything helping you to actually specialize for a platform like exists with C++. Making Java less portable in practice than C++.
Toss in that other popular platform, web, and the "portability" of Java gets even worse compared to others like C++.
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.
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.
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.
Android is not moving to Kotlin: Kotlin is simply supported as a first class language in Android. Most of Android itself is written in Java and while it's clear that an increasing number of Android developers are switching to Kotlin, Java will never stop being supported on Android.
The legal battle between Google and Oracle has nothing to with Google using Java.
You can use Java for free and without any licensing concerns (use Open JDK).
C++ is less portable than Java precisely because Java runs on a JVM.
Yes, golang is shiny new thing, but there is TONS of boring back-end done in Java.
Whole Alibaba runs on Java, for example. I know of some companies (won't share names but fill in the blanks) that used to be Go shops, that were eaten by Alibaba and they migrated from Go to Java.
That's just like saying Go does not have application servers, DI, IOC, ORM frameworks, runtime reflection and so on. Different languages have different ways of achieving user requirements. It is not one-to-one matching.
> ... I can't imagine it's as mature as java.
Yes, depending on perspective, not as mature or not as fossilized as Java.
I am also working on a networked file system solution. My approach is likely fundamentally different. Instead of a single file system to represent file system artifacts across various devices I am using a single simplified data model as an abstraction for all file systems and pairing that with a new security/identity scheme. The idea is to solving for file asset distribution using point-to-point solutions that don't compromise security or privacy.
https://github.com/prettydiff/share-file-systems
I suspect your approach is likely far more stable as I am still working out the kinks in my models, but I supply a complete GUI in the browser that works the same in all browsers on all modern OSs.
The desktop application everyone has to use to report the income tax in my country is written in Java. Which is nice since it runs anywhere that has a recent enough JRE; in a distant past, before it was rewritten in Java, it was first a DOS-only and then a Windows-only desktop application.
Lets define it differently: Everything what is not an SAP System and is backend and is not Cobolt, is Java at least for automotive and banking. Automotive -> managing cars, service contracts, financing offers, accessories and for banking -> money management, insurance, contract management etc. You go to a shop and you wanna finance something? Might be a Java backend or Cobolt :D)
Spring/Spring Boot as a Framework got a lot of traction because Java specification process was just way slower and more boilerplate
And yes Oracle got fed up of doing Java for free for too long and if you wanna use an older version of java and still need patches, you will need to pay.
Luckily there is were java actually shows it strength which i have not seen in other languages: You define a specification, you get a reference implementation from someone and then everyone around it starts to build on those specifications.
This allows for different jpa (database access with java) implementations, different application server etc. It also allows for different companies to do their own JVM implementation/maintenance track/version.
From an ecosystem pserpective, the JVM itself (without java) also did a great job and shows how versatile it is. Close to what .net is doing but in a more free version. And you could throw .net/c# into the same similiar category as Java. Language feels similiar and if you are a MS company, you just use C# perhaps. But switching between c# and java is much easier than to other languages.
From all languages i know and worked with, i do like JVM based languages the most. golang is interesting but nothing i would wanna use for a big code base at all. C/C++ i would use if i need to because of tooling features, how you write it and how hard it is to write it good;
Java is fast, java has great tools for a long long time: Great Debugging features, great memory and performance analysis and tools, lots and lots of frameworks and architecture catalog.
PHP is written and used in business context like java but without the benefits of running on the JVM. I don't recommend it. Its not bad, its less boiler plate but its just not a nice well defined well designed language. Most shocking to me was the performance optimizations which were done a few years ago which shows how little interest in that language exists that you can just optimize it that much. What facebook did with PHP was just shitty and weird.
- https://en.wikipedia.org/wiki/Apache_Hadoop
- https://en.wikipedia.org/wiki/Apache_Kafka
- https://en.wikipedia.org/wiki/Apache_Cassandra
- https://en.wikipedia.org/wiki/Apache_Lucene
- https://en.wikipedia.org/wiki/Elasticsearch
I'm not saying you should adapt a technology based solely on the number of jobs...but we all gotta eat. And on the flip side if you see Java jobs decline over the years...time to learn the one that's increasing :)
There are multiple implementations of the Java VM. Java is designed by a collaboration of companies and OpenJDK is the reference implementation. Based on the license of the company, its implementation is free or not.
Now, Oracle was the biggest and most well known contributor of OpenJDK for a long time (and probably still is). And Oracle did something unusual, which is that they made their own version no longer free. Which is why you are confused. You can still get Java from Oracle, with Long Term Support, but now it is paid support.
The OpenJDK reference implementation is still free, and many companies have made their own tweaks and provide Long Term Support for these versions, mostly because they use tons of Java and/or want others to keep using Java because of its massive ecosystem, for which they can provide consulting/paid support. Note, you can still run these versions commercially, but if you want support you likely have to pay.
The Google issue was that before all this OpenJDK stuff, all designing of Java was done by a single company, Sun, which was bought by Oracle. So a single company designed, developed, implemented, maintained, and built up the ecosystem of Java. This includes years of R&D in what keywords to use, and how classes work, basically the rules of the language. Tons of developers got into Java. And they attracted big customers like banks and governments to pay them for this R&D with support and development. Then came Google and they said, we like this language design and ecosystem and developer skills, but we don't want to pay for that support, so thanks for all the hard designing of your language, but we will create our own implementation and pay you nothing. Basically Google didn't want to pay it's share of the Java R&D. Now things get a bit blurry because of Oracle, which bought Sun, and tried to make a lot more money off Java while reducing R&D spending. So Oracle isn't too popular either.
Things have improved since Oracle decided that Java isn't something to make a lot of money off, and the whole Google debacle. Now Oracle is mostly stewarding the language and other companies are now also contributing features. The past few years there have been some good and strong updates to Java, making it feel more like a leading language than a trailing language.
Basically, get AdoptOpenJDK, latest version if possible, and don't use preview features.
Most people use free OpenJDK builds (Adopt OpenJDK, Zulu OpenJDK, Oracle OpenJDK to name a few). There are some builds which require license, like Oracle Java. If you need some kind of advanced support, you have that option.
A good part of AWS is written in Java. The Hadoop, Storm, Spark, Kafka etc major backend projects are written in Java.
In fact if you are writing anything even half serious. Java is what you chose to write it in.
>>Java is supposed to be able to "run anywhere," yet C++ is more portable because it doesn't require the JVM to run.
Manual garbage collection is long dead, and it won't be revived any time soon. Machines have gotten too fast and resourceful for most of the developer community to give it a serious selection choice for their projects.
Not saying C++ or Rust is dead. They have their place. But they are not going to be used for bulk of everyday projects. That ship sailed long back.
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.
I don't agree with that. Spring Boot makes it so easy to write nice backends and a type system is often useful
> they have fewer reasons to move
Move to what btw? NodeJS?
These languages are definitely much more "portable" depending on what your definition of portability is; the JRE runs on A LOT of systems and abstracts much of the underlying system away for you, meaning that IME you have to write a lot less platform-specific code if you're targeting e.g. Windows, macOS and Linux.
As for your edit, the licensing is a bit complex for Java but TL;DR if you install OpenJDK releases you do not need to worry yourself about licensing.
HN is a funny place.One day you are convinced no smart person on HN is still writing Java and the next day you see droves discussing about a java release.
I, too, believe that usability matters a lot, and I'm curious what you think of bash.
But looks entirely different: Two words, connected by a hyphen.
But I think, it was done because of backwards compatibility. If they would have called it "closed", it would maybe break hundreds of programs that have methods/variables called "closed"
#### Why not "just" make contextual keywords?
At first glance, contextual keywords (and their friends, such as reserved type identifiers) may appear to be a magic wand; they let us create the illusion of adding new keywords without breaking existing programs. But the positive track record of contextual keywords hides a great deal of complexity and distortion.
Each grammar position is its own story; contextual keywords that might be used as modifiers (e.g., `readonly`) have different ambiguity considerations than those that might be use in code (e.g., a `matches` expression). The process of selecting a contextual keyword is not a simple matter of adding it to the grammar; each one requires an analysis of potential current and future interactions. Similarly, each token we try to repurpose may have its own special considerations; for example, we could justify the use of `var` as a reserved type name because because the naming conventions are so broadly adhered to. Finally, the use of contextual keywords in certain syntactic positions can create additional considerations for extending the syntax later.
Contextual keywords create complexity for specifications, compilers, and IDEs. With one or two special cases, we can often deal well enough, but if special cases were to become more pervasive, this would likely result in more significant maintenance costs or bug tail. While it is easy to dismiss this as “not my problem”, in reality, this is everybody’s problem. IDEs often have to guess whether a use of a contextual keyword is a keyword or identifier, and it may not have enough information to make a good guess until it’s seen more input. This results in worse user highlighting, auto-completion, and refactoring abilities — or worse. These problems quickly become everyone's problems.
So, while contextual keywords are one of the tools in our toolbox, they should also be used sparingly.
[0]. https://mail.openjdk.java.net/pipermail/amber-spec-experts/2...
What I truly don't like is C's propensity to add new keywords that begin with an underscore and an uppercase letter. Like _Bool, or _Atomic. (I know the rationale, these can't be used as identifiers due to UB, but it still looks weird to me.)
I'm surprised they were so shy to break code by introducing new keywords, after they wreaked havoc on people's codebases with removing sun.misc.BASE64Decoder etc
Hopefully this version will work better.
[1] https://www.azul.com/downloads/zulu-community/?package=jdk
You can link musl statically. So, the problems with Glibc wouldn't be there. Maybe you would have to patch musl to make it work on android.
http://docwiki.embarcadero.com/RADStudio/Sydney/en/Propertie...
You can have Get and Set methods for properties or even allow direct access to the variable itself.
type TCompass = class(TControl) private FHeading: THeading; procedure SetHeading(Value: THeading); published property Heading: THeading read FHeading write SetHeading; ... end;
Also, properties can be indexed.
type TRectangle = class private FCoordinates: array[0..3] of Longint; function GetCoordinate(Index: Integer): Longint; procedure SetCoordinate(Index: Integer; Value: Longint); public property Left: Longint index 0 read GetCoordinate write SetCoordinate; property Top: Longint index 1 read GetCoordinate write SetCoordinate; property Right: Longint index 2 read GetCoordinate write SetCoordinate; property Bottom: Longint index 3 read GetCoordinate write SetCoordinate; property Coordinates[Index: Integer]: Longint read GetCoordinate write SetCoordinate; ... end;
Properties can also have "property pages" which can show specific user interfaces for viewing/setting these properties.
https://www.delphipower.xyz/guide_8/adding_a_property_page.h...
I have yet to see anything of this sophistication in Java or for that matter in any other component framework.
ie. Scala has tail call optimization but Java doesn't, but they both run on the same JVM.
You're also missing out on var and switch expressions, which are very visible features (as are records and instanceof patterns), so the difference should be obvious between a Java 8 codebase and a Java 15 one.
We only migrated our main service from 8 to 15 a month ago (AWS deprecation), but still have lots of 8 code laying around (luckily some of the container-features were backported)
A lot of things broke in Java 9, which was short-lived (both it and Java 10 lasted only six months each), and then Java 11 broke many other things (for instance, it removed all of J2EE). As late as last year, I was still seeing changes in libraries to fix issues with Java 9 or later. It's not that no one made an effort to upgrade, it's that it was a lot of effort, and often required upgrading to later versions of libraries, which have their own breaking changes.
runtimeOnly 'org.glassfish.jaxb:jaxb-runtime:2.3.2'An example of something that compares favourably would be Go, where they always blog about the changes, and there's easy to find official language documentation (and not just autogenerated API docs).
- A list of links is not a summary. The list is too short, reading every individual linked document is too long. The format of JEPs tends to bury the lede. As such it feels like wading through mud.
- Changes that affect the programmer experience are mixed at random with changes that affect internal details of the implementation.
- Changes that introduce experimental features are mixed at random with changes that are final.
Just finished my CPU architecture and enjoying to see the new trend to adopt vectors again in the USA
It will be interesting to see the reaction of project managers some of whom still measure productivity in terms of lines of code/# of commits! (yeah, they do and still exist).
GraalVM native image is far better, it "compiles" more slowly but the resulting executable is not too big.
But since Java, the language is highly backward compatible, one can trivially use Graal as is (without the preview features though)
Closed source projects include Airbnb, Uber, eBay, Pinterest, Groupon, Spotify, Intel, Symantec
Java programs normally sit on a server, or many servers of the same arch.
The decent thing is that someone can build a JVM for a new architecture and lots of /other/ languages that target the JVM work.
But this seems different from "my program can runs on lots of architectures".
The designers of Java, as well as software community at large, had dealt with the pain of moving large codebases across platforms and so the WORA promise was very appealing.
Or an Android smartphone or media streamer (Android TV).
However, those programs won't run anywhere; they need Android.
Java has turned into C. Java programs need a platform-specific set of libraries just like C needs POSIX, or Win32, or VXWorks or ThreadX or whatever.
This is pretty much inescapable.
Android is special because it has many many special APIs, so I don’t see your point. Just look at the (unfortunately not too numerous) desktop java apps. The exact same jar from n years ago will just run on all three main OSs.
That's true right now, but it wasn't true in the recent past (SPARC) and it might not be true in the near future (ARM).
Early in my career I was on a team that migrated our Java application from elderly Sun boxes to newer x86 hardware, and it was relatively painless. There's a good chance we'll eventually to the same from x86 to ARM. Most developers will also continue develop on x86 for the foreseeable future.
While they're about it, they should also add immutable/copying data structures.
They will start with records[1], but I think all value classes (Valhalla) should have this functionality eventually.
You will be able to write:
record Point(int x, int y){}
Point pp = p with { x = 3; }
[1]https://github.com/openjdk/amber-docs/blob/master/eg-drafts/...I use Java 15 in production in 3 projects.
// define a type alias
type UserId = Long
// can be used as a regular type
val userId: UserId = 123L
val userIds: List[UserId] = List(1L, 2L, 3L)The feature I am awaiting most is the Project Loom.
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 "special" kind of Object, one that does not have any identity. The motivation here is mostly performance. The details are available in Brian Goetz "State of Valhalla" update https://cr.openjdk.java.net/~briangoetz/valhalla/sov/01-back...
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 visibility, several canonical constructors are needed. If public fields exist, a constructor that sets all public fields. If protected fields exist, a constructor that sets all public and protected fields. If package-private fields exist - setting all public, protected, and package-private fields. If private fields exist - setting all public, protected, package-private, and private fields.
What remains, is value-oriented versions of equals(), hashCode() and toString() to be defined. Probably better to express as a base class than the new keyword `record`;
class Point extends Record { public final int x, y; }
A polyfill for such a base class for older Java: import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
class Record {
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this, true);
}
@Override
public boolean equals(Object obj) {
return EqualsBuilder.reflectionEquals(this, obj, true);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this);
}
}
I practice such classes in my code, for constructors, I just don't bother for final (Java does not support it well anyways), and have factory methods in a separate class, so they are out of the readers view.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.
The same way as with default no-arg constructor.
Interesting note about serialization. That could also be part of the base class.