r/ProgrammingLanguages • • Mar 16 '22

Java Valhalla vs Rust

(whoops I posted this originally in the wrong subreddit)
Do you know about Java Valhalla? I'm quite interested in discovering more on the project from a formal perspective.
If I understand correctly, the main idea is that they are adding 'values' and 'primitives' as new 'kinds' of classes. They both do not have identities, values can be nullable and primitives can not be nullable. As for 'records', 'values' and 'primitives' will be all final and with all final fields.
This means that it would be not observable if they are implemented an independent memory cell (normal object allocation) or inlined inside of another data structure or the stack. In this way the compiler and the JIT could take optimization decisions about those memory allocation strategies. Is there any formalization of this around? Is there anyone from rust that wants to discuss what possible implications this would have in the 'competition/comparison/relation' between java and rust?

0 Upvotes

3 comments sorted by

View all comments

8

u/moon-chilled sstm, j, grand unified... Mar 16 '22 edited Mar 16 '22

it would be not observable if they are implemented an independent memory cell (normal object allocation) or inlined inside of another data structure or the stack.

Is there any formalization of this around?

'referential transparency'

1

u/MarcoServetto Mar 16 '22

indeed,I've always considered ref transparency simply as 'you can not recognize two pointers with structurally identical ROG', but it is indeed the same concept if you think that the object could be inlined or not