3 ms·
Network connections aren't the hardest problem; you can hand those across Unix sockets. The fundamental problem with hot reload is that data structures can cha
by cperciva 7y ago
Network connections aren't the hardest problem; you can hand those across Unix sockets.
The fundamental problem with hot reload is that data structures can change. If the old process has a priority queue implemented as a linked list and the new process has a priority queue implemented as a heap, how on earth is any automated mechanism going to copy the state across?
- yorwba 7y agoChanging the running code but keeping the data in memory is equivalent to changing the code but keeping the data in the database. Changing data-structure definitions is equivalent to changing the database schema. If you want to change the database schema without losing data, you need to write a migration. If you want to hot-reload code with different data-structure definitions, you'll have to write a migration. A hot-reloading solution for a statically typed programming language will at minimum have to detect whether data structures have changed and either prevent the reload or require that the new code includes a function to migrate the data.
- Joker_vD 7y agoObviously, you write a code_change/3 function that updates the old state to the new shape or, if asked to do so, downgrades the new state back to the old shape :)
- lkschubert8 7y agoI guess you could come up with some concept of migrations for data structures?