HNHacker News
TopNewBestAskShowJobs

_old_dude_

814 karma · joined January 8, 2017

submissionscomments
_old_dude_··on Go 1.21 may have a clear(x) builtin
In Java, the primitive type double uses the IEEE-754 semantics and java.lang.Double uses the bits by bits comparison semantics [1] so List<Double>.remove() works correctly.

[1] https://docs.oracle.com/en/java/javase/19/docs/api/java.base...

_old_dude_··on What’s so great about functional programming anyway?
The problem of the Java code above is that it tries to serve many masters, one of them being the JIT, i.e. the code is written that way so the JIT can fully inline the whole code.

The first "final", the "StatelessOp", the "StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT", the "int flags" are all here because of performance.

_old_dude_··on What’s so great about functional programming anyway?
Yes, this rings a bell :)

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 }
_old_dude_··on Making a Go program faster with a one-character change
In Java

    -XX:+PrintCompilation -XX:+UnlockDiagnosticVMOptions -XX:+PrintInlining
and

    -XX:+UnlockDiagnosticVMOptions -XX:+LogCompilation
The generated logs can be seen with JITWatch [1].

[1] https://github.com/AdoptOpenJDK/jitwatch

_old_dude_··on Maps and Memory Leaks in Go
The main difference with Go is that the table of a HashMap in Java is a table of pointers, not a table of structs, so the overhead to not shrink the table is less an issue.
_old_dude_··on That Shouldn't Happen – UnreachableException in .NET 7
In Java, usually an Error like AssertionError is used for those cases.

By example, for a switch on an enum, the compiler inserts a "throw new ...Error()" automatically when the default case is not specified.

_old_dude_··on Codebase as Database: Turning the IDE Inside Out with Datalog (2020)
Funding ! eclipse IDE is in majority maintained by IBM and IBM has decided to allocate less money to Eclipse.
_old_dude_··on Paving the on-ramp to Java
It's not as bad as it seems because the language already have constructors. So instead of having a peculiar case for constructors, you unify constructors and methods by saying that void does not have to be specified.

And i do not buy your argument that it will break the grammar, the parser of javac consider constructors as methods.

_old_dude_··on Java’s Cultural Problem
And Quarkus / microprofile API offers a programmatic API, ConfigProvider.getConfig()

see https://quarkus.io/guides/config-reference

_old_dude_··on Kevins got a bad rap in France
My wife (french) said it starts because Home Alone (1990) was very popular in France. Macaulay Culkin character is named Kevin.
_old_dude_··on Byte Magazine: The C Programming Language (1983)
or a function sort(), but it was clear by 1997 that there was a lot of money thrown around for everyone knowing how to write a backend in Java.
_old_dude_··on Timsort (2019)
There is a follow up, the fix used in Java was not good enough [2].

[2] https://bugs.openjdk.org/browse/JDK-8203864

_old_dude_··on Despite best efforts .NET is still not an open platform
Microsoft is starting to port VS studio (IntelliSense) which is proprietary to VS code which is opensource.

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.

_old_dude_··on Mundane chores are all the rage in gaming
I will show my age, but did you try core war [1, 2] ?

[1] https://en.wikipedia.org/wiki/Core_War [2] https://www.corewar.io/

_old_dude_··on The Y Combinator in Go with generics
It has practical value, let say you have something that caches the result of a lambda

  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() ?
_old_dude_··on Fossil versus Git
It is still an incremental/lazy DVCS, the first checkout does not download the whole repository, but for most users it looks like a DVCS.
_old_dude_··on Java record pattern matching in JDK 19
The same feature does not entail the same tradeoff depending on the languages.

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.

_old_dude_··on Notes on Virtual Threads and Clojure
One issue to implement TCO is that the "security model"/circus of Java is based on the stack frames, so you can not remove stack frames without getting into trouble.

The security manager has to be removed first [1]

[1] https://openjdk.java.net/jeps/411

_old_dude_··on JEP proposed to target JDK 19: 425: Virtual Threads (Preview)
The problem is not Linux per se, it's the fact that pthread_create [1] reserves 2M for the stack, so the process runs out of memory if you have 1 million threads (1M * 2M == 2T)

[1] https://man7.org/linux/man-pages/man3/pthread_create.3.html

_old_dude_··on Distilling the Real Cost of Production Garbage Collectors [pdf]
> with standard APIs it is not even possible to parse an integer out of a string without allocating memory

Not true anymore :)

https://docs.oracle.com/en/java/javase/17/docs/api/java.base...

_old_dude_··on Why don't more languages offer flow typing?
You need flow typing when you do pattern matching on generalized abstract data type (GADT). Here is an example in Java

    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 
      };
    }
_old_dude_··on Excel 2.0 – Is there a better visual data model than a grid of cells?
Jupyter notebook is a regression from Excel, at least Excel computes the dependencies between the cells. With Jupyter, you have to be careful in the order you evaluate the cells.

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.

_old_dude_··on JEP 419: Foreign Function and Memory API
This is the runtime API, that uses the JITs to generate the trampoline codes necessary to go from the Java calling convention to the C calling convention (upcall and downcall), a kind of like libffi for Java.

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://github.com/openjdk/jextract

_old_dude_··on We were a few days away from being settled for life
Or, less charitably, they have provided a trove of documents to the buyer so the buyer can outgrow their business using a competitor.
_old_dude_··on Why and how we use primitive maps
I think the busy loop version can use Thread.onSpinWait() to improve performance if the tryLock fails.

[1] https://docs.oracle.com/en/java/javase/17/docs/api/java.base...()

_old_dude_··on Java 18 / JDK 18: General Availability
Azul (not affiliated) provides JDKs with JavaFX bundled

https://www.azul.com/downloads/?version=java-17-lts&package=...

_old_dude_··on Java 18 / JDK 18: General Availability
Since Java 9/11 (9 is not a LTS), String internals was reworked to use either 8 bits or 16 bits per char. [1]

[1] https://openjdk.java.net/jeps/254

_old_dude_··on Hacking sum types with Go generics
sealed typed are union types, granted they have been introduced very recently.
_old_dude_··on .NET Myths Dispelled
If you can, you can give a try to Quarkus, while the doc is not up to the level of Spring, in term of ergonomics, configuration, hot reload, test containers, this is closer to what .NET does, by example annotations are optional and are resolved at compilation not at the execution.
_old_dude_··on Coral, a Cobra fork with nearly all its features, but only 4 dependencies
I've recently used rewrite that comes with YAML recipes [1] for the common refactoring

[1] https://docs.openrewrite.org/reference/yaml-format-reference

← PreviousPage 4 of 11Next →