-
Notifications
You must be signed in to change notification settings - Fork 17
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
Consider rewriting the C code in Swift for memory safety #44
Comments
It will be harder to contribute with esoteric language, but it is also an opportunity to learn new language. |
I do share this concern. Is memory safety really the reason for the remaining issues with this driver? |
I guess it is inevitable for macOS devs to learn Swift at some point.
Probably no |
I did an experiment rewriting the client to Swift. The result is pretty awkward, since nice abstractions for interacting with C string aren't readily available. What's more alarming though is that the binary size went from 34kB to 2.1mB in release mode. The client is probably special enough that writing it in swift isn't worth it. I also discovered a bug in the
I'll try writing the main app in swift once #69 settles. |
I would not worry about that; this is normal for most languages runtimes. Writing it in Go would result in a similar size.
Experimentation is of course good, and I'm curious how it will look. But I continue to have reservations about adding more languages to the Lima project. Historically it has always been a problem when a project combines parts in too many languages (and it has sometimes been my own fault in adding them). I understand that using VMNET makes this special, but in general I recommend sticking to:
This also gives you the biggest chance that a user of the code will debug and fix a problem themselves instead of just filing an issue and waiting for the maintainers to figure it out. So rewriting it in Swift must provide some tangible benefit beyond just wanting to use a different language. I would have the same concerns if this was about rewriting it in Rust or Zig. |
Interesting. Perhaps then the client should be in Go. Is there much C in Lima? If not, we might still consider writing this (the server) in swift given that high quality bindings for vmnet aren't available in other languages. |
I used C++ for the GUI, because it was the most portable and generated small enough binaries (with Qt libs, compared with Electron apps) But the interface with the Lima and container backends is all in JSON, and I suppose one could have used a GUI design tool for the layout... It is also quite readable, no modern C++ templates etc |
I see very little benefit in rewriting the client, it is a very trivial and short C program.
Can you open an issue? This should be a trivial fix returning an error if argc is zero after processing all arguments. The current code does not decrease argc when consuming arguments from argv. Adding a test for the client will also be useful. |
No description provided.
The text was updated successfully, but these errors were encountered: