[1] https://docs.oracle.com/en/java/javase/19/docs/api/java.base...
814 karma · joined January 8, 2017
[1] https://docs.oracle.com/en/java/javase/19/docs/api/java.base...
The first "final", the "StatelessOp", the "StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT", the "int flags" are all here because of performance.
But usually the issue is that people talk about OOP vs FP without specifying the scale, by example the Java stream API hide the mutations / side effects (not unlike Haskell monads do), so you can use
{ record, stream, functions, types }
But internally it's still { mutability, side-effects } -XX:+PrintCompilation -XX:+UnlockDiagnosticVMOptions -XX:+PrintInlining
and -XX:+UnlockDiagnosticVMOptions -XX:+LogCompilation
The generated logs can be seen with JITWatch [1].By example, for a switch on an enum, the compiler inserts a "throw new ...Error()" automatically when the default case is not specified.
And i do not buy your argument that it will break the grammar, the parser of javac consider constructors as methods.
Current C# plugin (Omnisharp) is opensource, so they announce that it will be replaced by a closed source selector that let you choose the opensource or the proprietary plugin with the proprietary as default.
It's Embrace, Extend, Extinguish just in front of our eyes, so opensource people are pissed.
[1] https://en.wikipedia.org/wiki/Core_War [2] https://www.corewar.io/
record Cache<T, U>(Function<T, U> function) {
U get(T value) { ... }
}
you can use it that way var cache = new Cache<Integer, Integer>(v -> v + 1);
var result = cache.get(3);
with that settings, how do you specify a lambda which is recursive ? and how can you cache the intermediary steps if you can change the signature of get() ?For Kotlin, extensions methods are essential otherwise you can not extend existing Java types with Kotlin types.
For C#, you need extension methods for LINQ because modifying the .Net runtime was not an option at that time.
For Java, changing the VM is not an issue, instead of extension methods you add default methods which can be overridden by implementations.
Same feature, different tradeoffs.
The security manager has to be removed first [1]
[1] https://man7.org/linux/man-pages/man3/pthread_create.3.html
Not true anymore :)
https://docs.oracle.com/en/java/javase/17/docs/api/java.base...
sealed interface Foo<T> permits Impl {} // union type
record Impl() implements Foo<String> {} // product type
<T> T m(Foo<T> foo) {
return switch(foo) {
case Impl impl -> "hello"; // flow typing T=String
};
}And both falls on the floor the minute you want to use a spreadsheet/notebook as a library of functions, i.e it's not composable.
If you have a typed langages like Scala, Kotlin, Java, you can use jextract [1] which is a more high level API. jextract uses clang to parse C headers files and generates a jar file with all the C function seen as Java methods with all the glue generated for you (the downside is i believe that this jar is OS specific).
This API is more for dynamic languages like Clojure, Groovy, JRuby, where you want to do dynamic runtime calls and still get performance (as far as i understand, the JIT generates the adapter code once per call and you can reuse it).
[1] https://docs.oracle.com/en/java/javase/17/docs/api/java.base...()
https://www.azul.com/downloads/?version=java-17-lts&package=...
[1] https://docs.openrewrite.org/reference/yaml-format-reference