This reminds me a bit of the conversation between the Odin and Elixir creator in this video.
Basically Odin tries to build everything needed into the language with its specific syntax, instead Elixir tries to have a minimal core and use meta programming to add things (including syntax) to the language.
And Zig is somewhere in the middle between the two.
But the thing is that people disagree widely on what are missing features vs unneeded features and how/if they should be added. (Which makes sense to me because people need different things)
While I can understand wanting a declarative syntax for certain initialization patterns, it doesnât necessarily match Zigâs imperative focus, personally my preferred approach would be if it was possible to make these things possible through meta programming, but with the current meta programming possibilities it is more clunky then having it in the language directly.
One part of me likes the idea of turning current Zig into a core/base language and future Zig into a multi-paradigm/language-oriented-programming language,
basically asking the question:
What if we could use the buildsystem to create different languages (including dialects) that can be used along-side zig?
So that @floooh could use Zig + C99 decl syntax
as a language for writing c-api style code and game developers could use Zig + gamemath
, while machine learning people would use Zig + machine learning math
those could share most of the implementation and differ in some details.
Adding the right operators and datatypes for every use case bloats the language (and is unlikely, more likely a lot of things get rejected)
Where adding the ability to customize the language through the buildsystem (while keeping interoperability) would give a way to do anything in a well defined way, without needing to clutter the core language or be rejected because it is too niche.
For example a Zig + webdev
language could add syntax for sql.
One way this could work is that those extensions basically have either their custom parser and compile to Zig or an ast, or even lower level formats (technically there could be a lot of different options here), or Zig could get syntax for embedding dsl-language snippets something like:
const people = #sql`SELECT * FROM people`;
Where the implementation for sql
would be defined for the module via the build system. Zig already isnât a (classical) strictly imperative language, it uses laziness, sometimes comptime meta programming is easier in a functional style.
Maybe it would make sense to have an option between use Zig (and live with some metaprogramming uses that are clunky) and create your own programming language from scratch.
I think Ziggy and SuperHTML are good examples that creating your own language can make a lot of sense, but even there it seems to me that there should be a mechanism to add ziggy as a file extension in the build system, which then would allow you to use ziggy files in your code base and for example import them from Zig files.
Basically I would want that the sort of integration that exists for zon, could also be added for ziggy (or other custom languages), ideally in a way that makes these languages equal to another (instead of one being seen as a builtin language and the other as second class).
Still I would find it reasonable to enforce that build.zig.zon
always has to be zon. (So that bootstrapping, buildsystem, package manager and third-party tooling can remain simpler)
I think it could make a lot of sense, especially if you think about something like a game where this would allow you to for example add a scripting language (and scripts written in it) to your project which then would integrate with the normal zig code and incremental compilation / hotreload.
Once we have a compile-server serving info via a protocol (instead of LSP) it would also make sense that the editor then could show you completions for things that are declared within the scripts from zig files. So basically having imports that work across language barriers, like it would be expected for zon.
I also think if the Zig language adopted something like this, a lot of ideas could be more easily solved by finding what level of support Zig has for that idea, instead of fighting over full or no support.
Basically custom languages would become an escape hatch that allow the community to explore different alternatives to what is supported in the core language. The package manager could even get a feature that allows you to throw an error if any dependency contains anything except core (if that would help with managing complexity).