Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potentially Discontinue C Transpilation #6

Open
vi013t opened this issue Jun 2, 2024 · 0 comments
Open

Potentially Discontinue C Transpilation #6

vi013t opened this issue Jun 2, 2024 · 0 comments
Milestone

Comments

@vi013t
Copy link
Collaborator

vi013t commented Jun 2, 2024

Currently, Cabin compiles to native by transpiling to C first and then compiling that to a native executable. This is a good quick-and-easy solution that works on pretty much all hardware. However, it comes with some drawbacks. For one, we are limited by compilation time — Cabin will always have a relatively slow compilation time because it has to compile to C first and then compile the C after that. Ideally, it'd be better to just have a one-step process.

There are many avenues to explore here. First, let's rule some out: Cabin will not be interpreted, nor will it run on a virtual machine. Both of these are huge performance knocks to the language, and we want to keep it very fast.

One option is to use LLVM, a popular choice for languages. LLVM is highly optimized and tried-and-tested as a robust framework. The biggest drawback with LLVM is that it's extremely complicated and poorly documented. Not only is this an issue for simply ease of implementation, but also it concerns maintainability. Avoiding LLVM has a number of benefits, such as some of the ones described in Zig's issue concerning moving away from LLVM. Other IR codegens like Cranelift are options too, which tend to be more simple but less performant than LLVM.

Another option is to transpile directly to native assembly, but this has the limitation that each individual architecture will need its own implementation, and we'll undoubtedly begin to introduce architecture-specific bugs.

There are other possibilities to consider, these are just some of them. Cabin could also just remain a C-transpiled language, if that is deemed best. It's just worth considering and finalizing what the compilation process will look like before 1.0.

@vi013t vi013t added this to the 1.0 🎉 milestone Jun 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant