3 ms·
As others have noted, the title is confusing; this is really talking about live code reloading. "The build" => offline compilation in general, "is always broken
by iainmerrick 7y ago
As others have noted, the title is confusing; this is really talking about live code reloading. "The build" => offline compilation in general, "is always broken" => is not as good as live reloading.
I've used live reloading in HyperCard, where your application (the "stack") is always running and you can interactively edit the code for each UI element. I think this can work really well, but only under certain constraints:
- You have a very clean separation between code and data (in HyperCard, the data is the set of cards and backgrounds, and the contents of all the fields; the code is the event handlers attached to each object).
- The data format is stable.
- There are clear checkpoints where your data is stable and no code is running.
Those are sometimes the case in some applications. Arguably, all of them are nice properties and therefore good targets to aim for.
But there are plenty of normal scenarios that don't meet those conditions:
- You have an expensive long-running task. Trying to change the code half-way through is a fool's errand. You need to re-run it from the start, and/or find a way to split it up into smaller steps. Unit tests and a good incremental build system are your friends here.
- You're working on the core data structures. Again, trying to update the code while all the data is still in memory is a bad idea. Just use a good build system and try to make the compilation and startup time as fast as possible.
- You're changing the navigation system, so the user's current position in the app won't make sense any more. You'll need to reset back to the front page (or whatever).
For that last one, "apply changes" in C# or Android Studio will generally do the right thing, even though those are mostly traditional build systems.
There isn't really a hard distinction between a build system and live coding, it's a spectrum. I'd argue further that a build system (in the traditional "make" fashion) is more fundamental, because you can achieve anything with a build system (even if it's tedious and inefficient) whereas some tasks are just intractable with live coding. A fast, reliable and correct build system (like Bazel, as several people have mentioned already) is the best foundation for everything else.