Caterpillar

Daily Thought - 2024-09-11

< back to list

Another performance-related aspect that could benefit from inference and the code database: data layout. If you define a struct, a compiler might re-order its fields for better performance. I don't have room to go into the reasons for that here, but if you're interested, this talk by Andrew Kelley is great.

This reordering, while beneficial, is also problematic. It means that you can't rely on a struct's layout, which is relevant for storage, communication, even function calls. But again, what if layout optimization happens in pre-compilation, and the already optimized struct gets stored in the database (where it is addressed by a hash)?

The developer would see right in the code what the compiler did. And in any situations where we exchange the struct with another entity that might have a different version of it, whatever tooling is involved can recognize the incompatibility, maybe even fix it, as long as type information is available.

<< previous thoughtnext thought >>