irishgreencitrus / raylib.v

A simple wrapper for raylib in V
zlib License
61 stars 13 forks source link

Hot reload #18

Open yemi opened 1 year ago

yemi commented 1 year ago

Describe the solution you'd like

Ability to hot reload code changes. Is it possible at all using v's native hot reloading or otherwise?

Reasons why this should be a part of the core library

It would speed up development significantly, making this lib more attractive as a replacement for native c.

irishgreencitrus commented 1 year ago

Are there any other C bindings that work with hot reloading? Otherwise, I'm not sure how I could approach this.

spytheman commented 5 months ago

It is a V feature, available when compiling a program with v -live run program.v. It relies on tagging specific functions with @[live], then when you change them, the updates will be detected by the running program, it will recompile a shared library with the changed source, and reload it, effectively replacing the previous versions with the new ones, without losing state.

It is mainly useful for application code, where you want to tweak some algorithm, or some hardcoded values like coordinates or colors in those functions, similar to how you can tweak CSS live in a web browser inspector. It is not well suited for libraries like the raylib wrapper here.