Are there plans to add a runtime to Zig? The lack of one was one of it’s strong selling points for me. But pretty sure I read a couple of comments this week that seems to imply the need for one. Something to do with hot-code replace listening for changes. And some other thread that mentioned that there was a background thread now being started in main. Maybe I’m connecting the wrong dots, or misunderstood, but it sounds like a push in the direct of having a Zig runtime?
Could you please explain what is the meaning of Zig runtime?
Do you mean something comparable to the .NET framework?
So for example coming from Java, and Go, they both had a load of stuff happening on different threads that happen outside of my code, and possibly in parallel, commonly called a language Runtime? Maybe I’m getting the terminology wrong?
It always appeared to me that Zig was running without such a runtime, and was only executing code specified explicitly by me?
You’re looking for Io. That’s what Io is
I don’t think so. std.Io is still (technically) opt in in a way that a language runtime is not.
language runtime term usually used for garbage collector managed systems
something like java virtual machine or specil library for go or clr for .Net
I doubt these comments are coming from the core team. Adding a runtime would essentially mean giving up the definition that Zig is a `general purpose programming language’.
general-purpose programming language (GPL) is a programming language for building software in a wide variety of application domains.
So definitely Zig is GPL
C# also GPL - but has run-time
Go is a general-purpose language …
Our definition of ‘general purpose’ is that it can be used to program any (von neumann-ish) machine. Python for example definitely doesn’t fit that description and in general reliance on a runtime hinders your ability to target constrained environments.
I believe those comments were in regards to the compiler having a sort of “runtime” and adding more capabilities to it so a user can hook into it update application global state etc. The compiler already has this with --watch so it would just mean making it more capable. This has nothing to do with the runtime of the generated binary.
Wouldn’t it be better to coin a new term since this is in conflict with the already existing definition? Also MicroPython exists which runs on bare metal so it sounds like your definition is also technically incorrect.
MicroPython is a different language that looks a lot like Python but that is not Python. You can’t take an arbitrary Python library and add it to a MicroPython project (even if you target a normal pc, not an embedded device) because MicroPython only supports a subset of the things you can do with Python proper.
Maybe, but whatever is on Wikipedia, is ‘a’ definition, not ‘the’ definition. It’s normal for things to have more than one definition, especially for concepts that are still being explored, and in this case the definition provided by Wikipedia is IMO not all that useful. In any case IIRC we looked at other expressions in the past but none seemed better than this.
MicroPython is a different language that looks a lot like Python but that is not Python. You can’t take an arbitrary Python library and add it to a MicroPython project (even if you target a normal pc, not an embedded device) because MicroPython only supports a subset of the things you can do with Python proper.
I see, thanks for the correction. I have never used it myself and would never personally consider it for that kind of project.
Maybe, but whatever is on Wikipedia, is ‘a’ definition, not ‘the’ definition. It’s normal for things to have more than one definition, especially for concepts that are still being explored, and in this case the definition provided by Wikipedia is IMO not all that useful. In any case IIRC we looked at other expressions in the past but none seemed better than this.
Self contained is perhaps a bit more how I think of it but that has different associations so maybe that’s not good either. I don’t think saying Zig is a general purpose language would raise eyebrows. It’s more that saying that another language isn’t that would confuse people. I also think it’s a bit orthogonal to whether a language has a runtime.
Edit: Also the very definition of what it means to have runtime is probably up for debate. It’s more of a spectrum than a yes or no.
looks like microsoft looked on wrong place, from c# spec
C# is intended to be a simple, modern, general-purpose, object-oriented programming language.
C# does a lot to blur these lines considering you can deploy in several ways
- “Normal” requiring the user to have installed the correct .NET version
- Bundled with .NET so that a user doesn’t have to install anything but still using JIT
- AOT meaning it’s just a binary not requiring an external runtime
becuase it includes stripped version of clr
Good to hear, although I was thinking more in terms of it being a killer for Systems Programming which I still consider to be Zig’s star use-case.
I think the comments weren’t about a runtime, just the planned (optional) api that allows people to communicate with the compiler if it runs (via --watch -fincremental). open a communication channel between the build system and application · Issue #20604 · ziglang/zig · GitHub
Basically a nice extra feature that you don’t have to use, but could be good for things that benefit from interactive development like games or other highly interactive programs where you want to test ideas and see them quickly. (Without having to re-setup a whole bunch of state manually)
Even if they added a runtime to the executable when it’s being compiled with --watch -fincremental, it wouldn’t be a bad idea. It would just a be convenience to make a compiler feature work during development. Release builds wouldn’t have it, of course. It’s no different than the safety checks in debug mode.