Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

10+ years in the making, at this year's Devoxx Brian Goetz said that they are almost ready with the design of Project Valhalla and can start JEP-ing it in future JDK releases. No timeline yet, so we probably will not see it until the next-after-next LTS release (29?)... But Java, like Cobol, is not going anywhere, so the wait will be worth it.


Great, though is that perhaps orthogonal to my complaints? My vague understanding is that Valhalla is about transparently allocating local objects on the stack instead of the heap when possible (i.e., when escape analysis confirms that they can't "get out" of the method that declared them), the way primitives are now.


But these are the same problems! I'm not intimately familiar with the current state and internals of project Valhalla, but they were proposing `primitive classes` backed by primitive types, allowing said class to be used as a type in generic code. Moreover, primitives would become ValueObjects, so you would have your int[] which would also be an Object[]. In other words, the difference between primitives and objects would be much smaller in terms of the language.

Bottom line is, you could have your cake and eat it too - have an int[] that looks like a List<Int>, and vice versa, while retaining the performance characteristics of an array.


Thanks, I'd thought that the goal was to reimplement aspects of the compiler+JVM to preserve existing language semantics but be more performant, but from what you've written I take it that the goal is actually to expand the language semantics themselves, in a way that would bring primitive types and objects (and thus generics) closer together.


Valhalla is what you want, at least for some of it.

https://openjdk.org/jeps/402

    interface Box<T> {
        T get();
        void set(T val);
    }

    interface IntBox extends Box<int> {
        int get();
        void set(int val);
    }
https://openjdk.org/projects/valhalla/


It is also about value types. I think the talk parent is talking about is [this], a bit long but worth watching

[this] https://inside.java/2024/12/16/devoxxbelgium-valhalla/




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: