HNHacker News
TopNewBestAskShowJobs

_old_dude_

814 karma · joined January 8, 2017

submissionscomments
_old_dude_··on Java 24 to Reduce Object Header Size and Save Memory
> the default is trivial, it just returns the object's address

This was trivial a long time ago. Now, all Java GCs move objects in memory.

_old_dude_··on Bottles of OOP now available in Python
Very true, in Java, at least in the last 20 years, inheritance is de-facto deprecated, all new bits and bolts like enums, annotations, lambdas or records do not support inheritance.

So you have to use composition.

_old_dude_··on COBOL has been “dead” for so long, my grandpa wrote about it
COBOL changes very slowly, once in a decade or two. Python does not offer support of a release for more than 3 years and a half [1].

[1] https://en.wikipedia.org/wiki/History_of_Python

_old_dude_··on A Java language cumulative feature rollup
I'm using Java Almanac [1].

[1] https://javaalmanac.io/

_old_dude_··on How the STL Uses Explicit
BTW, Saint Louis is the common name of Louis IX not Louis XIV (the Sun King).

https://en.wikipedia.org/wiki/Louis_IX_of_France

_old_dude_··on Code Models
This is similar to the expression tree API of C# so no change in the JVM is required, only cooperation between the java compiler and the reflection API.

The code model can be computed by the compiler, inserted in the classfile in a specific binary or text format and read at runtime using the reflection API.

I've not taken a look to the implementation so it's speculation but I do not think the JVM need to be changed.

_old_dude_··on YouTube is A/B testing limiting logged out access to videos
They have just changed the angle of attack by baning effective ad-blockers from chrome

https://arstechnica.com/gadgets/2024/05/google-starts-deprec...

_old_dude_··on "No way to prevent this" say users of only language where this regularly happens
Yes, it's functions vs methods. You can make this explicit like in Python, you can make it implicit but have two kinds of methods, instance methods and static methods like in C++/C#/Java.

And you have JavaScript were all functions have an implicit this ...

_old_dude_··on How to Use the Foreign Function API in Java 22 to Call C Libraries

  s/jpackage/jextract/g
_old_dude_··on Bending pause times to your will with Generational ZGC
There are so many packages that only work with GODEBUG=cgocheck=0 that practically that door is closed
_old_dude_··on Daft Social: Anti-social social network for minimalists
Hello, I do not know if someone from Daft is reading this thread, but you should not use contiguous ids

https://daftsocial.com/daftsocial/?id=201

_old_dude_··on JEP draft: String Templates (Final)
We had high hope that unlike SUN, Oracle will listen.

> Iterative process

please send a link to a video of a designer from Oracle presenting the string templates at a conference. This is not Loom, there is no iterative process.

> Python, JS, and C# also don't allow for such a shortcut

The syntax of C# or Python is also lightweight, fine by me.

> it's not some special prefix

I get that, but not using a constant like STR is an anti-pattern, as you said it's a virtual method call.

> The criticism, on the other hand, seems to mostly come from people who have not actually tried it out

Ask designers to go to conferences and you will get real feedback.

_old_dude_··on JEP draft: String Templates (Final)
Even if I think that Guy Steele is a genius, an argument of authority is always a bad argument. Better listening to the foot soldiers than staying in your high tower.

Using '\' instead of '$' does not allow $variable as a shortcut to ${variable} making the syntax objectively harder to read.

Using '\' cleverly helps to detect when the processor is missing at compile time but it does not matter because the syntax mandates a big STR in front.

_old_dude_··on JEP draft: String Templates (Final)
Sadly escape analysis in Java is weak. In this case, it only works if all the template values do not escape.
_old_dude_··on JEP draft: String Templates (Final)
Yes, you do not get a compile time error, but visually a big STR is front is enough "${variable}" vs STR."${variable}"

And editors will use different colors.

Using \ or $ is not about backward compatibility but about ergonomics.

_old_dude_··on JEP draft: String Templates (Final)
You can not use the excuse of the backward compatibility twice.

If the string template is prefixed by a processor STR."foo" instead of "foo" then you do not need \{variable} instead of $variable.

_old_dude_··on JEP draft: String Templates (Final)
Both the syntax and the semantics are awful. They are overthinking it.

Processor should not require to allocate a list of objects do to string templating. Only STR and FMT get good perf because they are specialized by the compiler.

_old_dude_··on Pitfalls of object oriented programming (2009) [pdf]
You still need virtual dispatch (or type pattern matching) if there is a variable which can contain either a BDRepo or a LoggedRepo(BDRepo).
_old_dude_··on My failed attempt at using a closet as an office
I'm now retired but headphones were my invibility hat. I was easy for the kids, headphones means daddy is not home, it was harder for my wife.
_old_dude_··on FFM (Foreign Function and Memory API) Goes Final
Developers should understand if a dependency use C bindings. But why bother end users with a command line flag.

Perhaps there is a manifest entry/flag so the command line flag is not required ?

_old_dude_··on Breakelse: When Compiler Developers Get Bored
Monad to the rescue

  Optional.of(op)
    .filter(v -> !v.cond)
    .map(v -> op2(v))
    .filter(v2 -> !v2.cond)
    .map(/* do more stuff */)
    .orElseGet(() -> my_else)
_old_dude_··on How Netflix uses Java
You have two kind of concurrent GCs, the ones where the marking phase in concurrent with the application and the ones where the evacuation phase is also concurrent with the application.

G1 only does the marking concurrently, the evacuation is done in small pauses. A decade ago, there was only one concurrent evacuation GC available in Java, C4 from Azul. Now, we have Shenandoah and ZGC.

_old_dude_··on My personal C coding style as of late 2023
I remember James Gosling saying, a long time ago, that the whole class should be either mutable or not so you do not need to tag some methods with const.

The consequence is that you may define two classes, one non-mutable and one mutable like String/StringBuilder.

_old_dude_··on JDK 21 Release Notes
Or a nuclear power plant

https://www.quora.com/The-license-agreement-of-Java-says-You...

_old_dude_··on JDK 21 Release Notes
It's not generational GC, it's generational ZGC.

ZGC is a concurrent GC, both the marking phase and the evacuation phase are done concurrently with the program running. A generational ZGC is a generational concurrent GC.

MS does not have such kind of tech.

_old_dude_··on JDK 21 Release Notes
It's prefixed by "STR." so the syntax is different from any existing tools ?

It remember me the first proposed syntax for lambdas. Let's hope the next preview will fix that.

_old_dude_··on Currying in Kotlin
You need an helper method for that

    public class Main {
      private static <T,R> Function<T,R> fun(Function<T,R> function) {
        return function;
      }

      public static void main(String[] args) {
        var add = fun(x -> fun(y -> x + y));
        var addFive = add.apply(5);
        int result = addFive.apply(3);  // Output will be 8
      }
    }
Those helpers should be part of the JDK.
_old_dude_··on Project Valhalla, Simple as it can be, but not simpler
In C#, value types and reference types are two separate kind of types, value types are pass by copy (like C structs) and generics where clauses have coloring (struct constraints [1]).

In Java, value types are immutable so the VM can pass by value or by copy, as a user you don't see the difference and there are backward compatible (per the article), you don't need to recompile the user code when you replace an existing class by a value class.

C# has value types since the beginning so primitive types are value types while in Java it seems there will be 3 kinds of types instead of 2.

[1] https://learn.microsoft.com/en-us/dotnet/csharp/programming-...

_old_dude_··on Dart 3.1 and a retrospective on functional style programming in Dart
Closing the hierarchy or not depend on the use cases, for an application most hierarchies are closed. For a library most are open.

For example, if your application receive JSON objects, you know all of them so, it's a closed hierarchy.

_old_dude_··on Dart 3.1 and a retrospective on functional style programming in Dart
It depends if the hierarchy is open or closed.

If the hierarchy is open, the behavior is defined in each subtypes and it's easy to add a new subtypes but you can not add a new operation (a new method). That's the OOP way.

If the hierarchy is closed, the behavior is defined in each function, it's easy to add a new operation (new function) but you can not add a new subtype. That's the ADT way.

This is known as the https://en.wikipedia.org/wiki/Expression_problem

← PreviousPage 2 of 11Next →