Hello,
I have been experimenting with zig (really enjoyable) and have some ideas and was wondering what you think of them.
Split Up Build, Fmt, ZigC
The Build System, Zig Compiler and Formatter are different things and can be independent programs. (similar to rustc, cargo and rustfmt)
This makes it simpler to learn, maintain and document. For documentation I would really appreciate man pages.
This could be a long term goal, because now, in early development, the goal is probably to just push out features.
Dependency Management without Versions
This is how a dependency file could look like:
[git]
notstd https://codeberg.org/removewingman/notzigstd.git
zcom https://github.com/ziglibs/zCOM.git
zelda https://github.com/haze/zelda.git
[local]
routez # version 0.6
zig-network # branch stable
This makes it really simple to just use the latest dependency everytime your project is build.
So you always have the latest updates, this is a big benefit in security and why would you not want to use the latest dependency. It is still possible e.g. to always use the stable branch or use versioning, but it is opt-in. This makes writing and maintaining libraries also easier, since there is only one version: main/latest.
Higher Abstraction Level Interfaces
The zig std library is low level, which is completely fine. I am suggesting to provide higher abstraction interfaces, to increase reusability and simplicity. Also from zig zen to:
Communicate intent precisely.
Reduce the amount one must remember.
I started to experiment with this a little bit here.
Some examples include:
file.contentWith1024Buffer(allocator: Allocator, file: File) !ArrayList(u8)
stdio.readStdinWith1024Buffer(allocator: Allocator) !ArrayList(u8)
split.splittedScalar(comptime T: type, allocator: Allocator, toSplit: []const T, delimiter: T) !ArrayList([]const T)
// these could be made more declarative
The idea is to do things once, test them and then reuse them. This makes the programs that use them a lot simpler, readable and safer.
Is this a philosophy/direction where zig wants to go to? Is there already something that provides these levels of abstraction?
Feel free to point out anything. Would love to here what you think.
Since these ideas are kind of abstract, this is one post, if it goes into more detail should probably make separate ones.