IssueRaiser

alternative to C for Nvim core

This is a *tracking issue*, not a manifesto. Corrections welcome unless they are nit-picks. # Problem The C core of nvim has been armored by a lot of static analysis and compiler flags, which has greatly improved quality. But C still has these problems: - crashes from invalid pointers, arrays not bounds-checked - nul-terminated strings are awkward and have a perf cost - memory management takes effort and asan doesn't detect all the leaks - lack of modern language abstractions (e.g. generics) makes particular parts of the code over complicated and specialized (e.g. marktree, Lua/vimscript bridge). # Goal The strategy of Nvim has always been to lift logic out of C and into Lua where possible. And that still looks like a productive path. But if there is a "better C" which allows us to completely *freeze* the remaining C bits and shift to the "better C", at near-zero cost, then we should consider that. C gives us the following benefits: - broad cross-platform support - fast builds - leverage existing C codebase # Proposal This issue evaluates whether we can maintain the above benefits, while gaining new ones, by leveraging: ## rust - pros - tooling - rich type system - borrow checker gives strong guarantees - language level macros - large collection of libraries - cons - slow build times - interop with C libraries has nonzero friction - mediocre cross-compiling support ## odin - pros - Simpler language (vs zig) - Easy interop

Posted by justinmk on Oct 5, 2024, 5:34 PM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.2,000 issues0 comments

pricing (Software)

alternative to C for Nvim core

justinmkOct 5, 2024, 5:34 PM

This is a *tracking issue*, not a manifesto. Corrections welcome unless they are nit-picks. # Problem The C core of nvim has been armored by a lot of static analysis and compiler flags, which has greatly improved quality. But C still has these problems: - crashes from invalid pointers, arrays not bounds-checked - nul-terminated strings are awkward and have a perf cost - memory management takes effort and asan doesn't detect all the leaks - lack of modern language abstractions (e.g. generics) makes particular parts of the code over complicated and specialized (e.g. marktree, Lua/vimscript bridge). # Goal The strategy of Nvim has always been to lift logic out of C and into Lua where possible. And that still looks like a productive path. But if there is a "better C" which allows us to completely *freeze* the remaining C bits and shift to the "better C", at near-zero cost, then we should consider that. C gives us the following benefits: - broad cross-platform support - fast builds - leverage existing C codebase # Proposal This issue evaluates whether we can maintain the above benefits, while gaining new ones, by leveraging: ## rust - pros - tooling - rich type system - borrow checker gives strong guarantees - language level macros - large collection of libraries - cons - slow build times - interop with C libraries has nonzero friction - mediocre cross-compiling support ## odin - pros - Simpler language (vs zig) - Easy interop

Comments (0)

No comments yet. Start the discussion.

Comment on this issue