I think you are conflating your personal preference for not managing emscripten as a zig dependency, with the hackiness of how it is currently used as a dependency (by raylib and other projects that have used that hacky solution).
I think nobody who looks at it finds it pretty or reliable in theory, I think the only reason why it is being used, is that it works surprisingly well in practice and solves an immediate need for enough people, so it keeps spreading. It provides a solution for a use case and happens to work well enough, often enough. (Yes I want better solutions, but I don’t think this means emscripten can’t be managed as a Zig dependency)
My Ideal solution would be that people can either use an immutable emscripten zig dependency or detect/provide an override to use some system dependency. I don’t see why any one of the two should be the only option.
From what I have heard about Zig’s buildsystem, it was supposed to give people the means to make and enable these choices, but I also think that some of those features aren’t implemented yet, things like version resolution/overrides, reproducible, isolated and sandboxed package builds, etc.
From a perspective of “what should be” a lot of your points make sense, but practically speaking I don’t think that we are there yet, for example if
then it should be a compile error, when they aren’t, but currently you still can do funky stuff, which maybe you shouldn’t do, but you can.
And these kind of hacks exist, because they bridge gaps for things, that don’t exist yet. I think a lot of game developers that have spent a lot of time learning and implementing all kinds of stuff, don’t want a workflow where they have to setup a whole bunch of things manually and have to learn about details that they shouldn’t have to know.
When you can simply zig build
for desktop and even for other operating systems, but then for web you first have to understand a whole bunch of details to pick your preferred way of installing emscripten, that seems silly to me.
I think it is way better to have a suboptimal way that happens to work most of the time and then make it so that people can opt-in to something where they need to know more about the details.
And I think the hackiness is because emscripten is an awkward dependency, it seems too big and clunky, but once you have gotten it to give you what you want “make it compile for web”, you no longer want to spend time on making it better and would rather do something that feels rewarding, like adding content to the game, instead of trying to understand how emscripten works internally and how it could be packaged better.
Having good workflows matters and forcing people to make choices they don’t care about doesn’t help.
So I think what you describe should eventually be one of the things that people can do, but I also think there should be a default/just-compile-the-damn-thing option where people can be blissfully unaware of emscripten’s existence, until their hard drive contains 40 gigs of different emscripten versions and it causes them to clear that cache, or somebody got annoyed enough to improve the situation.
Personally I don’t think “install emscripten manually on your system” is a satisfying solution, but I do agree that it should be one of the supported options, at least when there is some versioning flexibility.
For example games that require fully deterministic simulation, would not want any system packages and instead build everything from immutable packages for the parts related to the deterministic simulation.
I think there are different workflows and use-cases, forcing one, over all the others, doesn’t work, the raylib’s build.zig
manages to be useful for people, because people try to enable their use-cases without destroying other peoples existing use-cases.
Saying
doesn’t make much sense in the context of how raylib’s build.zig
currently grows organically, because currently it is just that whatever happens to work for the people who update the build.zig
, is supported and everything else might be, or not be, supported.
And this just happens to be the thing that raylib’s build.zig
had already assumed.
The idea behind this topic was to get people talking, so that things can improve over time, through incremental improvements, but we can’t just completely change things and mess up all existing workflows, just because it doesn’t work perfectly every time.
Peoples use-cases should be kept intact and only broken when it really can’t be avoided.