News for hackers. Stuff that matters.
Re:Overhead of Returning Optional Values in Java and Rust by spullara on Saturday October 16, 2021 @02:18PM (#28890065)
Kind of silly compare this before value types in Vahalla. Obviously Java optionals will be slower than Rust ones as they are just wrapper objects. However, they should at least rerun it using OptionalLong rather than Optional<Long>.
Re:Overhead of Returning Optional Values in Java and Rust by thinkharderdev on Saturday October 16, 2021 @02:37PM (#28890248)
I think the point is not really to compare Java to Rust but highlight that in Java you pay a significant performance penalty (relative to representing Optional.empty() as null).
Re:Overhead of Returning Optional Values in Java and Rust by tialaramex on Saturday October 16, 2021 @03:34PM (#28890741)
And without the Rust code, you just know people would say see, Optional is too expensive, this is why I use null. So the Rust here shows that actually no, this style doesn't need to come with a performance cost.

It's been more of a surprise to me to see people defending null as somehow preferable style in these comments.

Re:Overhead of Returning Optional Values in Java and Rust by spullara on Sunday October 17, 2021 @01:00AM (#28894081)
I think what they are saying is that it is the preferrable style in Java for now. As soon as Vahalla lands in the VM, then Optional in Java will be closer to Rust.