-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
hot code swapping #68
Comments
This feature (automatic rebuild in background & hot code swapping) is available for C++ in Projucer IDE, built upon LLVM infrastructure. Old demo 1, old demo 2, few implementation details. Be aware that it took several years to implement and the implementor said that "it was the most complicated thing I ever did". |
@PavelVozenilek The Projucer link has died, sadly. |
Information from the dead link is probably here: |
I always wonder how should hot-swap deal with data (data structure layout and long-lived in-memory state), it seems rather difficult compared to hot-swap stateless code (like a pure function). |
here https://molecular-matters.com/products_livepp.html is a commercial product which realizes hot-reload for c/c++ projects |
I wonder if looking at the way Common Lisp deals with these things would be useful at all. Sure, CL has a fatter runtime than Zig at the binary level, but:
|
@isaachier Thanks, that article is very helpful! Now i've integrated C live coding successfully with libtcc, which hot-swap pure code flawlessly. About the state transition, I can think of a solution which serialize the state out (to a layout-agnostic format), allocate new state, then serialize in. It should work, but involves a lot of manual implementation of serializing code and is not very generic/automatic. |
nim-lang/RFCs#511 |
Regarding code swapping in C, see https://github.com/fungos/cr |
This would be a killer feature for me in game dev. Commercial game engines (Unity/Unreal) tend to implement their own hotswapping layers for engine code or rely on scripting languages to get iteration times down. To have this supported at the language level would definitely reinforce the "so productive you have to use it" narrative for zig in games. |
@cshenton It isn't "native" hot code reloading supported into the language, but it allow for a similar workflow altough it isn't the same as if it was builtin and it would be great if it was, you might find it useful ! Hoping this wasn't a necrobump. |
Lisps have a great interactive dev experience. You can It would be awesome to have this workflow supported. |
You could have a look at how it is done in erlang. However, that's a different world.. Another thing, which I haven't seen in the comments so far would be security. |
I did some live coding on this feature recently, and we got to a proof-of-concept status: It's in the hcs branch. It depends on further progress on the x86_64 backend to be generally useful. It's also for Linux only currently. Each OS will need its own hot code swapping strategy. |
There has also been https://www.jakubkonka.com/2022/03/16/hcs-zig.html (hcs-macos branch) by @kubkon |
I need HRC(Hot Reload Code) , If Zig has HRC It will be perfect language . |
Use case: industrial control applications which require "online changes" (ability to change code between control cycles with effectivley zero downtime) Would want to trigger the hot swap manually and be able to tell if a hot swap is possible or not before attempting. |
changes and automatically perform multithreaded compilation to build projects
quickly.
press "save" in your editor and see the change immediately in your running
software.
Of course this only works for some kinds of changes - obviously if you make changes to your initialization code, you won't see a difference. But it would probably work at the function level, so you could swap out any individual function for a new one.
The text was updated successfully, but these errors were encountered: