But I think with virtual threads, esp when they work with synchronized right, will finally put Java back on top of Go. People complain about Java, but imo Java's problems are mostly accidental and acknowledged, and they do often get improved or fixed. Whereas Go seems to mostly be happy with how it is exactly right now, and are loathe to improve the many pain points. So much gocode is needlessly obtuse, and it's not like the obtuseness actually accomplishes their goal. I've still seen just god-awful Gocode, with layers and layers of interfaces in between you and getting anything done. Very java-esque, despite their OOP resistance being specifically targeting not falling prey to Java's propensity for towering class hierarchies.
If you just stuck to the core language and the JVM, it's kind of always been a nice place to code even if the language was changing glacially.
If you're used to writing nice concise code in other languages, just keep doing that, but in Java.
It's trivially easy to write Java programs without (ab)using inheritance. It's trivially easy to write Java programs in a functional style. There are countless libraries that will provide just about any programming interface you like, the only hard part is picking.
I've tried to follow along with it, but man I just can't - it's that crazy. It does work though
For other stuff I usually just write in a dialect I like to use, and be very selective about libraries and other bits I use. It's fortunate that the standard library isn't very ClassFactory and is pretty batteries included so you can get a lot done without too much fuss.
In many ways it's not terribly dissimilar to how one might approach using C++ or Perl or any other big language with lots of different ways to do things that you can pick and choose from.
package com.example.hello;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class MainApplication {
public static void main(String[] args) {
SpringApplication.run(MainApplication.class, args);
}
}
//controller file
package com.example.hello;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/api")
public class HelloController {
@GetMapping("/hello")
public String sayHello() {
return "Hello, World!";
}
}
Even C++ is better than this!! #include "crow.h"
int main() {
crow::SimpleApp app;
CROW_ROUTE(app, "/api/hello")
([]() {
return "Hello, World!";
});
app.port(8080).multithreaded().run();
}Want to pass a pure function that takes structs as arguments around, sure.
The ecosystem has been MIT since 2016, and the last few releases have been solidifying the AOT proposition.
It just has so many features that allow it to compete with C/C++ on the low level, but it also provides exceptional high level niceties (which admittedly can be slow, some LINQ for example).
I know it's not fashionable, especially in a Linux-centric world, but I have used it extensively for many years (on essentially every platform), and it's lightweight (in most instances) and has the features and tooling to make development less stressful.
Every time I use Java, it just feels overwhelming and slow.
Once Project Loom receives some more love (I believe that's scheduled for the next LTS, Java 25) I'll be very interested to see how Java's green threads will compare to C#'s async/await. I think Java's model may help programmers write more optimal code easier, but only if they can pull off their scheduling improvements.
C# does have massive advantages when calling native code, though. Java FFI is always just kind of a pain and C# FFI is pretty much trivial.
Go, D, Common Lisp (implementation dependent), and others offer GC and native compilation.
If you count automatic reference counting like Objective-C's ARC, you can add it and Swift to the list of natively compiled languages with GC.
and you can also compile to native code
zero garbage Java it is relatively common in algorithmic trading
> but in practice no one does this
that's funny, I could swear we do
Are you quite sure of that? I think you're getting stuff mixed up here. AFAICS, a native-compiled language might very well have mandatory garbage collection. Not that any such language immediately springs to mind, and I'm not even sure any do actually exist, but surely they could exist. The concepts "native compilation" and "garbage collection" are, AIUI, orthogonal.
https://www.graalvm.org/latest/reference-manual/native-image...
I'm sure the same would happen when writing C for the JVM. Tricks like dynamically rearranging/compressing pointers and altering structs to better suit the cache lines and data locality properties of the system code is running on can probably boost any major C program, but that's an incredibly complex change to a C program that the JVM just gives you for free.
Java does have a place, however, for I/O bound workloads where developer productivity matters more than performance. You can write a lot of horrible code in Java very quickly.
in fact, most projects don't have the kind of performance requirements that would make native a necessity. I say, java should be the default, and native have a place.
I certainly appreciate the amount of R&D Oracle is investing into the Java Virtual Machine. While I use the open source version of the JVMs, I also wouldn't mind also kicking some cash into the back into the devpool. Business with Oracle does seem to be a bit of a poison pill unfortunately. Leaves us "small budget" firms in a pickle. We know the ecosystem needs funding, but the option to engage Big Red is not enticing.