Community
Chat Logs
Friday, July 31, 2026
- Parahttps://news.ycombinator.com/item?id=49119063
- nevetJEP 401: Value Objects (Preview) merged to OpenJDK master | Hacker News
- javabotPara's title: "JEP 401: Value Objects (Preview) merged to OpenJDK master | Hacker News"
- NeXeNman i can't wait
- jreicherNeXeN: Para: what do you intend to use that for? I also have a use for it, but it's unlikely to be the same as yours
- jreicher~jep401
- javabot'JEP 401: Value Objects (Preview)' can be found at http://openjdk.java.net/jeps/401
- nevetJEP 401: Value Objects (Preview)
- NeXeNi'm building a library to help devs to leverage various ways of limiting scope and creating value objects seamlessly without worrying about implementing edge cases themselves
- NeXeNsince you lose identity there are some things there that have sharp corners, and so it'll just guarantee things like immutability and being able to do a thing and leverage it without so much work. mostly dx
- NeXeNmight not be something one would use, but it's at least something one can look at and learn about the various strategies in implementing value objects
- NeXeNnot every implementation needs value objects, but i'd like to at least have it for myself so i don't have to worry as much and i can just stay in the flow
- jreicherNeXeN: do the objects get created "in isolation", or do you have something to create data structures?
- hassoon'morning
- Parajreicher: I don't intend to do anything special with that, it's more that the basis of Valhalla is in there and that will bring a lot of other things as well.
- ParaI'll be surprised if something doesn't break because of that.
- NeXeNjreicher: i dunno i'm just surmising
- NeXeNmy plan is to simply implement various things that lend themselves to value objects, like Vector2D, Point3D, etc then complex numbers which will make them like primitives.....and say monetary amounts, timeseries timestamps, tensors, etc.
- NeXeNjreicher: i found a neat trick with the try-with-resources statement that i'll use to limit scope. i'll use static global (with a scope object in the try statement) to change whatever strategy, like identity safe, primitive-packed ...you know...and during that scope block between the squirrely brackets you can do like Vector2D position = MyLib.vector2D(100.5, 200.25); or some such and it'll automagically produce that type of object but as a value object
- NeXeN instead of a standard one
- NeXeNtechnically anything implementing AutoCloseable can be scoped with a t-w-r block
- NeXeNbecause at times you do want identity and at times you don't. so you could change it at any time procedurally within the block by passing an enum to a static method
- NeXeNi could also use a lambda, hrmm with them being incredibly cheap that would eliminate typing try statement
- NeXeNwait no, now that i think of it. using a lambda will allocate closure objects if you happen to reference local variables outside scope. in a large collection that would probably defeat the purpose. would have to document it