The Inevitable Borrow Checker in Inko: A Trade-off Between Stack Allocation and Compile-Time Checks
The Inko language designer explores optimal solutions for stack allocation and borrow checking. By default, Inko types are heap-allocated, offering flexibility but incurring performance overhead. To improve performance, an `inline` modifier is introduced to support stack allocation, but this brings new challenges: how to handle borrowing and move semantics while guaranteeing memory safety. The article explores several solutions, including allowing field assignments, introducing unique types, and escape analysis, ultimately concluding that compile-time borrow checking is the best approach, but its implementation complexity is high and it won't be implemented in the short term. Currently, Inko still uses a strategy that does not allow reassignment of inline type fields.