3 ms·
Apart from primitive specialization the biggest omission in my opinion is the lack of value types ("structs"). It's almost impossible to write code that is heap
by alkonaut 11y ago
Apart from primitive specialization the biggest omission in my opinion is the lack of value types ("structs"). It's almost impossible to write code that is heap allocation free or allows reasoning about cache locality.
- jahewson 11y agoIf you're familiar with the JVM's "escape analysis" then it is at least possible to write allocation-free code. But keeping a mental model of the JIT's optimizer in your head does not make for fun or easy programming. It's so much nicer to work with value types such as those found in C#.
- vrotaru 11y agoJust yesterday I've watched this: https://www.youtube.com/watch?v=88-szpeNfrU https://www.youtube.com/watch?v=88-szpeNfrU Long story short: keep the traditional getters and setters but have just a byte[] field to store the object state. For example If you need just the date (without the time) you can store it in 2 bytes, say 7 and 8, and in getDate() method you do public Date getDate() { int day = bytes[8] * 256 + bytes[9] return new Date(day * MILLIS_PER_DAY); } Some of the improvements are amazing
- jerven 11y agohttp://objectlayout.org/ http://objectlayout.org/ is a possible solution. But currently it and panama and JEP 169 are still forming into a hopefully coherent gestalt :(