News for hackers. Stuff that matters.
Re:Maintain It with Zig by skywal_l on Wednesday September 08, 2021 @12:56PM (#28459812)
Zig is a very interesting language. You are able to do thing that would require wizard level skills in C with simple plain language construct. Like serializing/deserializing an enum variants over the wire for example in the most efficient way (look at std.json.{parser, stringify} [0]).

> soon we’ll also have a package manager

This. If they succeed to do this (and I have my doubts) it will be a paradigm shift for low-level "system" programming.

Let's hope this is not vaporware.

Finally, it's relatively easy to contribute to Zig. Andrew Kelley is very opinionated on where the language should go with an emphasis on simplicity which sometimes can make things awkward but he is also persuasive and welcoming. I have been using Zig for a month and I am still positively surprised so he must be onto something.

[0]: https://github.com/ziglang/zig/blob/master/lib/std/json.zig#...

Re:Maintain It with Zig by AndyKelley on Wednesday September 08, 2021 @03:33PM (#28461930)
> Let's hope this is not vaporware.

I sincerely approve of the skepticism. I can assure you there is already a very large fire under my ass to get this shipped.

To provide some more context, here is a snippet from the latest release notes[0]:

> Having a package manager built into the Zig compiler is a long-anticipated feature. Zig 0.8.0 does not have this feature.

> If the package manager works well, people will use it, which means building Zig projects will involve compiling more lines of Zig code, which means the Zig compiler must get faster, better at incremental compilation, and better at resource management.

> Therefore, the package manager depends on finishing the Self-Hosted Compiler, since it is planned to have these improved performance characteristics, while the Bootstrap Compiler is not planned to have them.

I can't help but mention, I am incredibly excited about how well the self-hosted compiler is coming along. Progress is swift, and all the ambitious design decisions (fully incremental compilation[1], extremely fast debug builds[2], low memory usage, multi-threaded) are intact. I anticipate it to make quite a splash once it becomes generally usable.

I don't expect the package manager to take nearly as long to develop.

[0]: https://ziglang.org/download/0.8.0/release-notes.html#Packag...

[1]: https://vimeo.com/491488902

[2]: https://twitter.com/andy_kelley/status/1416485475125141504

Re:Maintain It with Zig by cs702 on Wednesday September 08, 2021 @04:07PM (#28462367)
> ...I can assure you there is already a very large fire under my ass to get this shipped ... [followed by a short, easy-to-follow explanation as to why it's taking so long]

I'm going to check out Zig because of your response.

I love coming across comments like this one on HN.

Re:Maintain It with Zig by ljm on Wednesday September 08, 2021 @05:57PM (#28463550)
Zig has been on my radar precisely because of Andrew Kelley's vision.

I wrote about cross-compiling to a raspberry-pi and writing a barebones driver for an OLED display[^1]

That was a lot of fun despite the fact the code was incredibly basic. The interop with C was effortless.

[^1] https://www.kamelasa.dev/posts/gettin-ziggy-with-it-pi-zero....

Re:Maintain It with Zig by gobookdev on Thursday September 09, 2021 @01:42AM (#28466658)
Yeah I watched a couple of his talks, enjoyed every word. There is another interesting language (won't mention the name) but the creator won't let the public in and has a superiority complex, turned me off instantly. I believe Zig will blow up just because of the strong vision but without being a dick about it. It's next on my list for sure.
Re:Maintain It with Zig by rk06 on Thursday September 09, 2021 @03:14AM (#28467150)
Ahh you mean Elm, by any chance?

I feel Elm's growth has been stunted because the creator is actively hostile with whoever disagrees with him. I remember the infamous "leaving elm" post which was handled so poorly by Elm's author.

If they had handled it well, elm would have definitely seen a large uptick in adoption

Re:Maintain It with Zig by kristoff_it on Thursday September 09, 2021 @03:40AM (#28467288)
Parent poster 99% is referring to Jai. I'm of the same general opinion: interesting language, I've spent a lot of time watching jblow talk about it on Twitch, and it would be nice if it succeeded, unfortunately I have my doubts given jblow's attitude both in terms of external communication and within the development team [0].

[0] https://www.youtube.com/watch?v=Nutcb6ao0mc&t=4508s

Re:Maintain It with Zig by earth_walker on Thursday September 09, 2021 @08:23PM (#28476353)
There really isn't any call to trash Elm and its creator like this.

There's very little evidence of ongoing hostility from Evan - I pay attention to his work and writings and find he's rarely if ever hostile. In fact he's very mild-mannered, and is painstakingly detailed about explaining the reasons for why he does things the way he does, over and over again.

Perhaps that wore thin once or twice in the face of repeated criticism and demands. We've all seen way worse.

Yes, sticking to his vision has excluded ideas and contributions, and made some people very angry. There have been several high profile blogposts and twiits painting him as some kind of despot. And when other overzealous developers swooped in to defend his work, it just fed the meme, one which people on HN like to repeat every chance they get.

Well, I for one am glad he's a 'code despot' - considering how many people keep demanding that they dilute Elm's guarantees for the sake of JS library interop or marginally less boilerplate. Any bending to these demands and Elm today would be just another framework with a slightly different syntax, with none of guarantees that allow for the innovative tooling and libraries [1] we see coming out of the community.

Whether you agree with Evan's vision or not, Elm is doing just fine meeting its stated goals and is a fantastic and delightful technology and toolchain.

So please give over with trashing other people's hard work. If you don't like it, just don't use Elm.

[1] for example, the compiler's dead code elimination capabilities, elm-review's tco detection and other amazing auto-fixes, lamdera, etc.

Re:Maintain It with Zig by rk06 on Sunday September 12, 2021 @02:45AM (#28499112)
Elm has done some great work, even the ones, who left elm for other tech, acknowledge elm's elegant design.

However, elm is not pragmatic. the issues mentioned in Luke plant's "leaving elm" [0] are valid. and Evan's response to that was far from satisfactory[1] and this has affected Elm's popularity.

The disagreement between BDFL and community has happened in many other cases as well. and there is a way to solve them amicably. Most recently, Vue faced it when community caused uproar over composition API RFC. and Vue solved it nicely and amicably[2]. If Elm has followed similar approach, Elm too would be praised for it, and gained even more popularity.

[0] https://lukeplant.me.uk/blog/posts/why-im-leaving-elm/

[1] https://www.reddit.com/r/elm/comments/g070sz/evans_response_...

[2] https://dev.to/danielelkington/vue-s-darkest-day-3fgh

Re:Maintain It with Zig by ljm on Friday September 10, 2021 @07:29AM (#28480041)
I think you're saying Evan is the BDFL (Benevolent Dictator for Life) for Elm, except it's interesting you chose the word 'despot' because many of the decisions made with Elm are far from benevolent (like preventing certain library usage and interop if the code isn't hosted on github, within the elm org).

The criticism is valid. Haskell is painfully strict and, still, it offers various ways out of its guarantees. Rust is painfully strict and gives you `unsafe`. Neither of them break your build if you don't host your code in a specific github org.

Re:Maintain It with Zig by earth_walker on Friday September 10, 2021 @06:02PM (#28487401)
I purposely avoided 'BDFL': too much precedent as to what that means!

Limiting certain kinds of js access to vetted libraries is benevolent, if that's part of the language's goals. Likewise the lack of type classes or mutability/unsafe escape hatches.

Elm's developers do not enforce constraints to be 'hostile' or 'far from benevolant'. It's a tradeoff - language power for certain guarantees, guarantees that not even Haskell can provide.

Unfortunately, this sometimes means trying to constrain access to the completely unconstrained js library ecosystem, so the solution, at least for now, is a bit of a blunt weapon.

Note that Elm doesn't 'break your build' if you don't use github - that's a constraint on linking to official libraries only. I don't use github and my code works just fine.

Re:Maintain It with Zig by gobookdev on Thursday September 09, 2021 @03:24AM (#28467189)
Nah another one, don't want to bad mouth it because I still hope the language does well. There's actually a bunch that could fit into the category.
Re:Maintain It with Zig by thechao on Wednesday September 08, 2021 @04:26PM (#28462588)
> Progress is swift ...

ahem

> Progress is zig ...

Thanks for all your work! I ported a bunch of basic data-structures from C++ to Zig very early on (right as y'all began exposing generics). Even though the code no longer compiles, still worth learning The Zig Way™.

Re:Maintain It with Zig by optymizer on Wednesday September 08, 2021 @11:52PM (#28465996)
Hi Andy, I'm really intrigued by Zig's features - you're definitely solving the right and hard problems for C developers like myself.

If I may, my only piece of feedback (as someone who looked at Zig with fresh eyes) is that the syntax has lots of special chars (@, !void, .{}, &, etc). Is there a rationale published for these and other design choices (even if it's "I like it that way"). I would have expected a language with ambitious goals like Zig to take a stab at coming up with a grammar that's even simpler and cleaner than C.

Regardless, getting a new programming language working, noticed and used is monumental effort, so I wish you best of luck with Zig!

Re:Maintain It with Zig by dnautics on Thursday September 09, 2021 @12:30AM (#28466208)
One of the things after working with zig for a bit, is that the dangerous stuff is cumbersome to write (not hard to read, though), and has lots of fiddly bits like @ signs... So your eye is drawn to it as if to say "here are the parts of the code that need careful review".

Relative to c, though there are imo fewer special chars:. Zig adds ! and ?, Which are there for really good reason, but subtracts for example <> and #.

The hardest thing is the . syntax for anonymous structs and tuples, but to be fair it is very consistent, and so many times I'd think,"hey I wonder if..." And then try it with the syntax and of course it works.

Re:Maintain It with Zig by szanni on Thursday September 09, 2021 @10:44AM (#28470238)
>If I may, my only piece of feedback (as someone who looked at Zig with fresh eyes) is that the syntax has lots of special chars (@, !void, .{}, &, etc). Is there a rationale published for these and other design choices (even if it's "I like it that way"). I would have expected a language with ambitious goals like Zig to take a stab at coming up with a grammar that's even simpler and cleaner than C.

That is sadly my gripe with a lot of the newer languages too. I have been looking for something to replace C for a long time, something that makes it easier to not shoot yourself in the foot. I just find most of them significantly less readable than C.

Rust seems to be going down the route of C++, hence I do not deem it a safe language at all, as I have an exceedingly hard time parsing the source and figuring out what is going on.

Zig is WAY better in that regard, but as OP mentions: all the special characters make things more difficult to parse. Calls like these (taken from the introduction page) contain so much visual clutter:

  try expect(@call(.{}, add, .{3, 9}) == 12);
I sadly doubt any of this is possible to change at this stage anymore. Zig definitely seems the most promising C replacement with regards to tooling, especially cross compiling and C interop are a breeze. Truly inspiring work!

The only new C-like language that really nailed it for me syntax wise would be Nim. Very clean and easy to reason about, which - from a programmer perspective - makes it exceedingly safe to program in. It just seemingly lacks most of the safety guarantees that the compilers of other, newer languages provide.

Re:Maintain It with Zig by simplify on Tuesday September 14, 2021 @08:35PM (#28533513)
Isn't the example difficult to parse only because it's unfamiliar to you? As someone who has never used zig, I feel like 5 minutes of study would make this line easy to read.
Re:Maintain It with Zig by cb321 on Thursday September 09, 2021 @02:49PM (#28473176)
You should take a closer look at Nim. I suspect it probably has all that you want, but said features may not be "by default/well advertised" (yet). Alternatively, you should be more specific about what you think it lacks.
Re:Maintain It with Zig by wizwit999 on Wednesday September 08, 2021 @10:43PM (#28465622)
Please make sure you include private repositories in the design from the start.
Re:Maintain It with Zig by gravypod on Wednesday September 08, 2021 @05:30PM (#28463302)
Will the compiler have something like go's ability to vendor code locally? I've worked on some science projects and this has been a hard requirement on some systems for tape archive storage.
Re:Maintain It with Zig by nrr on Wednesday September 08, 2021 @08:15PM (#28464643)
Zig's build system has a first-class notion of packages that satisfies exactly this requirement. The Ziglearn documentation[0] has more details.

To make things a little more interesting though, Zig's shape in this regard should be roughly congruent to C's, so you should be able to do anything with Zig that you can with C. This includes linking against shared objects for C libraries like, e.g., SDL2[1] or building mixed-language Zig+C projects[2].

0: https://ziglearn.org/chapter-3/#packages 1: https://dev.to/fabioarnold/setup-zig-for-gamedev-2bmf 2: https://tiehu.is/blog/zig1

Re:Maintain It with Zig by pryelluw on Wednesday September 08, 2021 @05:33PM (#28463340)
How can I help?
Re:Maintain It with Zig by pryelluw on Wednesday September 08, 2021 @08:45PM (#28464886)
There’s this helpful guide:

https://github.com/ziglang/zig/blob/master/CONTRIBUTING.md

Though I’m interested in hearing from the creator itself as well.

Re:Maintain It with Zig by zamadatix on Wednesday September 08, 2021 @05:09PM (#28463100)
After self hosted compiler and package manager what are the big ticket items blocking 1.0 (other than fixes for a lot of the stuff that is broken)?
Re:Maintain It with Zig by lhorie on Wednesday September 08, 2021 @07:05PM (#28464165)
IIRC nailing down stdlib and its documentation was a big one
Re:Maintain It with Zig by randyrand on Thursday September 09, 2021 @03:36AM (#28467261)
With the self hosted compiler, is there a plan to provably determine the binary remains free from viruses?

How will you verify the chain of trust?

Re:Maintain It with Zig by moogly on Wednesday September 08, 2021 @02:21PM (#28461087)
I've been toying with Zig over the summer, and I'm really impressed by the build system, general ergonomics and the explicitness of the language.

The only thing I've found being a pain point is C's biggest pain point: the lack of a proper string type. Even though I've worked for years in the past with C and C++, I still get tripped up, and in Zig I keep on being confused whether I should use raw byte arrays, or sentinel-terminated arrays for certain string manipulations. Maybe I'm not familiar with common idioms in Zig that might help avoid this C-style tracking of string/buffer lengths malarkey that I tend to end up with where a slice is not appropriate.

Maybe a dynamic-length string library is the way forward.

I've always tried as much as possible to treat strings as just opaque data and never look into them, which tends to work well, but in some domains you really need to look at and massage the characters/codepoints/grapheme clusters, and the lack of a first-citizen UTF-8-aware string type is, I think, a bit unfortunate in this day and age. I understand having one of those could make C interop a bit gnarlier (I think Odin's approach of having two separate string types -- one of which is just meant to be used for interop -- should be workable).

Oh, and the ecosystem of libraries is still young. I needed to format timestamps as human readable date/time to a file, and had to step down to C to do something that basic[1], but it'll get there in time, I'm sure.

[1]: "basic" from the perspective of the end-user of the language. Having written a (not even fully featured) date/time library in C++, I consider date and time to be one of the hardest domains I've ever had to work in.

Re:Maintain It with Zig by losvedir on Wednesday September 08, 2021 @02:53PM (#28461516)
Note that while strings are generally opaque bytes in Zig, there are standard library functions[0] to work with them as Unicode codepoints and such. But Unicode is quite large and complicated, and things like grapheme clusters aren't in the standard library (yet?). I also believe that that module is planned to be rewritten. So it's more the case that Zig plans to someday support Unicode at the standard library level, but not as a specific type.

Then again, I'm not sure exactly what a type would be for Unicode. Basically just a flag that the array of bytes has been checked and is valid? It's nice to let the type system help you enforce your application boundaries, but I think you could wrap it pretty easily in a struct of your own if you needed that.

[0] https://github.com/ziglang/zig/blob/master/lib/std/unicode.z...

Re:Maintain It with Zig by tialaramex on Wednesday September 08, 2021 @04:45PM (#28462817)
> Basically just a flag that the array of bytes has been checked and is valid?

In something like Zig I think it's OK that it's merely a stated assumption that these bytes are UTF-8, not actually checked - so long as people take that seriously.

It's nice in code that maybe isn't very concerned with such things to be able to know that any "string" is actually text we can display, output to a console, something like that. Not for example a TCP/IP packet we haven't decoded yet, or the first 32 bytes of a JPEG image.

Programmers who aren't writing firmware for a vacuum cleaner or washing machine, probably want string literals like "this" in their code, and you'd naturally want those to have a type, for which a string type is the obvious fit. I believe in 2021 this type should obviously be UTF-8. "It's just some bytes" is far from useless, but it isn't much of a string type.

I was sceptical at first about Rust's choice to build in str (immutable UTF-8 string slices), because that seems like a relatively high level concept. But unlike std::string::String, str isn't that tricky after all. See, the only place such things would come from (not having std::string::String to make new ones) is the program source, and our compiler is necessarily already reading the program source, so it follows that the compiler must know how the source is encoded etc and thus it does actually know exactly what those literal strings are. If your literal wasn't Unicode, that wasn't a Rust program and it won't compile.

Re:Maintain It with Zig by coldtea on Thursday September 09, 2021 @12:33AM (#28466221)
>In something like Zig I think it's OK that it's merely a stated assumption that these bytes are UTF-8, not actually checked - so long as people take that seriously.

And also as long as all supported operations on those bytes still result in utf-8 strings (there could be unsafe operations too, like splitting at a random byte offset, but there should be a clearly marked safe set that wont corrupt a valid utf-8 byte sequence).

Re:Maintain It with Zig by mamcx on Wednesday September 08, 2021 @05:48PM (#28463476)
> Then again, I'm not sure exactly what a type would be for Unicode.

I have this internally in my lang AST Rust

    Utf8
I think that is the type:

    struct City {
        name:Utf8
    }
For a scripting lang like mine I surface it as `Str` but in a system language I think is better to say `Utf8`
Re:Maintain It with Zig by moogly on Wednesday September 08, 2021 @03:06PM (#28461649)
Looks like this is an attempt: https://github.com/jecolon/zigstr
Re:Maintain It with Zig by coldtea on Thursday September 09, 2021 @12:31AM (#28466211)
>*It's nice to let the type system help you enforce your application boundaries, but I think you could wrap it pretty easily in a struct of your own if you needed that.

Well, as you said "Unicode is quite large and complicated".

And in 2021 it's not just anglosaxon software users anymore (if they ever were), good unicode lib if not type is a must.

Re:Maintain It with Zig by 10000truths on Wednesday September 08, 2021 @02:43PM (#28461378)
> I've always tried as much as possible to treat strings as just opaque data and never look into them, which tends to work well, but in some domains you really need to look at and massage the characters/codepoints/grapheme clusters, and the lack of a first-citizen UTF-8-aware string type is, I think, a bit unfortunate in this day and age.

You don't need a string type for that, you just need routines that handle UTF-8 strings, like utfcpp (https://github.com/nemtrif/utfcpp).

Re:Maintain It with Zig by moogly on Wednesday September 08, 2021 @02:58PM (#28461560)
Sure, you're not wrong. For my purposes that'd work, but I'm of the opinion that delegating that to an optional library will make a lot of developers lazy and not even bother thinking about Unicode/i18n/l10n issues at all. I've seen so much code, in a multitude of languages that is oblivious to it, but even if it's reified in a type or even having some form of language support, I guess you can argue that people can still ignore it.
Re:Maintain It with Zig by moogly on Wednesday September 08, 2021 @06:29PM (#28463841)
In addition, I should add there are synergy effects in having the community (and the major libraries) settling on a common way, and you'll only really get that if there is a built-in.

However, if the philosophy here is to be unopinionated and optimize for flexibility over everything else, I feel I can't really fault them for making that choice.

Re:Maintain It with Zig by mikepurvis on Wednesday September 08, 2021 @05:41PM (#28463417)
That was basically the state of affairs with strings in Python 2, and although the transition was awful, I'm really, really appreciative of Python 3 now having clearly-separated str and bytes types.
Re:Maintain It with Zig by kristoff_it on Wednesday September 08, 2021 @02:50PM (#28461469)
Agreed, and Zig also has a lib for that as well:

https://github.com/jecolon/ziglyph/

Re:Maintain It with Zig by coldtea on Thursday September 09, 2021 @12:35AM (#28466231)
If it's not a single official library, then this will just end up in a future mess...

Like in any language with any lib that is not self-contained (cuts across all aspects of a program and can be used anywhere) and has many different implementations and no sanctioned one.

Re:Maintain It with Zig by moogly on Wednesday September 08, 2021 @03:01PM (#28461587)
Ooh, haven't come across this. Thanks!
Re:Maintain It with Zig by AndyKelley on Wednesday September 08, 2021 @03:17PM (#28461768)
Out of curiosity, what are you working on that requires a proper string type (rather than encoded UTF-8 bytes)?
Re:Maintain It with Zig by moogly on Wednesday September 08, 2021 @06:15PM (#28463714)
I wouldn't use the word "require", and perhaps you didn't mean it that strongly. Don't get me wrong: I could get by without and achieve what I needed to, but to be honest it didn't feel great.

I was doing some pretty gnarly high-level filesystem work (transforming an unstructured tree of files/folders into a more structured tree following certain naming and categorization conventions -- a lot of parsing/building/concatenating paths). I have been working with higher-level languages for the past decade or so, but have had a wanderlust to get away from garbage collected langauges and go back to my roots a bit, so I've been comparing some of the newer options in the "improved C"/"C++ replacement" space.

It may very well be that I'm not the target demographic for Zig, and that's totally fair, but to me it felt pretty jarring to go back to working with C-style character (byte) arrays and all the (well-known) issues with which they are fraught. I didn't feel like Zig was an improvement over C in the string handling area (as opposed to all other areas), whereas languages like Go and Rust are.

Other than that, I felt Zig was a joy to use.

Re:Maintain It with Zig by nyanpasu64 on Wednesday September 08, 2021 @08:14PM (#28464634)
Keep in mind that filesystem paths aren't strings. On Linux, they are raw bytes without any fixed encoding (but usually UTF-8 on UTF-8-based locales), and on Windows, they are sequences of 16-bit codepoints which are expected to be UTF-16 but not validated.

Rust's OsStr is my favorite approach so far. It stores Linux's raw bytes as-is, and stores Windows's possibly-valid UTF-16 as WTF-8. This makes path management "just work", with the ability to operate normally on invalid UTF-8 or UTF-16 paths, and zero-copy conversion from UTF-8/ASCII strings to OsStr (though converting OsStr into UTF-16 requires parsing). (Qt's QString-based file dialogs on Linux fail to convert invalid UTF-8 paths like those in https://github.com/petrosagg/wtfiles into QString, causing Qt-based apps to open/save the wrong paths.)

However there are difficulties in printing an OsStr. For example, a file dialog that shows filenames as raw bytes can't show non-Latin/Unicode characters in a human-readable form, and a file dialog that shows filenames as Unicode strings can't handle invalid Unicode filenames. GTK3 file dialogs show filenames as Unicode strings, and when encountering files with invalid Unicode names, instead displays "file�name.txt (invalid encoding)".

Worse yet, how should a file dialog allow users to rename files? If it's based around byte arrays, the user can't enter Unicode characters directly, and if it's based around Unicode (or a locale-specific text encoding), it can't display existing files with invalid Unicode/etc. in the name (probably not an issue if it allows the user to rename to a valid name), nor allow users to enter invalid Unicode (which is not an issue IMO).

Re:Maintain It with Zig by roca on Wednesday September 08, 2021 @10:54PM (#28465695)
The difficulty of printing OsStr is nothing to do with Rust, it's really just the difficulty of printing Linux file names in any context given you don't know what the non-UTF8 bytes mean.
Re:Maintain It with Zig by int_19h on Thursday September 09, 2021 @11:19PM (#28477443)
It's also a good rationale for why filenames should be valid Unicode - because they're data displayed to the end user.
Re:Maintain It with Zig by dnautics on Wednesday September 08, 2021 @09:40PM (#28465243)
MacOS filesystem is utf-8 strings with valid Unicode glyphs that are pinned to a certain revision of Unicode.
Re:Maintain It with Zig by masklinn on Thursday September 09, 2021 @12:49PM (#28471760)
> MacOS filesystem is utf-8 strings

APFS is utf8, HFS+ is utf16.

> with valid Unicode glyphs

That doesn’t really mean anything.

Apple’s fs do guarantee the paths are correct, as in, valid whatever encoding this has nothing to do with glyphs.

APFS also does not perform any normalisation while HFS+ uses a custom variant if NFD. While HFS+’s normalisation has its issues and critics, APFS’s lack of normalisation is probably worse: https://eclecticlight.co/2017/04/06/apfs-is-currently-unusab...

Re:Maintain It with Zig by Lvl999Noob on Wednesday September 08, 2021 @11:46PM (#28465971)
For strings, I believe Rust's approach of a dynamic `String` and a view `str` is the right approach.

For a minimal std, maybe Zig can have a standard `str` type which is used for all functions that don't need to grow the string and the `String` type is provided by any 3rd party library which is expected to provide a conversion function from `String` to `str`.

These strings types could or could not have a requirement of being Utf-8. Maybe there is a builtin wrapper to convert them. So you can any dynamic byte array which can be converted to `str` (just a pointer and length, no validation) which can be later converted to `utf8` (str but validated). A `String` which guarantees Utf-8 could directly convert to `utf8` to save validation costs.

Re:Maintain It with Zig by void_mint on Wednesday September 08, 2021 @12:58PM (#28459857)
I've been paying attention to Zig posts on HN, mostly just because it seems well-liked and I think Andrew Kelley is interesting/smart. Would it be fair to say that Zig is to C, what Rust is to C++? Or are they both just kind of...low-ish-level systems languages solving similar problems, differently?
Re:Maintain It with Zig by JoshTriplett on Wednesday September 08, 2021 @01:39PM (#28460458)
> Would it be fair to say that Zig is to C, what Rust is to C++?

I don't think that's the parallel I would draw.

Rather, I think both Zig and Rust aim to serve the use cases C and C++ do, but Zig and Rust pick different points on the tradeoffs involving safety. Zig feels like a "better C", in the sense of bringing modern language features to C, but it chooses safer rather than safe. Rust supplies modern language features as well, and chooses to prioritize safe; sometimes that comes at the expense of other factors, such as productivity or compile time. I personally prefer the point on the spectrum that Rust chose, but I think Zig still offers improvements over C.

Re:Maintain It with Zig by mumblemumble on Wednesday September 08, 2021 @01:57PM (#28460747)
disclaimer: I haven't actually used either, just done a lot of interested reading and a little toying around.

One thing that impressed me about Zig is how simple the language is. I get the impression that it would take very little time to properly learn the language and become effective at it.

Rust, on the other hand, has a whole lot of complexity even without the ownership semantics. So much to learn and understand. And, in some cases, work around. It seems, from looking at others' code, that there is a very strong temptation to lean on `unsafe` instead of figuring out how to solve a problem within the constraints it normally applies.

That has me wondering if there's really all that much safety difference in practice? Simpler code is generally easier to understand, and it's generally easier to find and fix bugs in code that's easier to understand. I can imagine a world where it's a tradeoff between, "You definitely won't have any of this relatively narrow category of bug, unless of course you opt out of the static checks, which you will probably do sometimes, even though we tell you you shouldn't," and, "There are no particular guarantees, but you're generally less likely to have any of this broader category of bug."

Re:Maintain It with Zig by steveklabnik on Wednesday September 08, 2021 @02:03PM (#28460848)
"simple" is, unfortunately, not a simple concept, nor does everyone agree on its effects on programs written in a language that is or is not simple.

Some people do believe that, let's say "conceptually parsimonious" languages (using complicated words to describe simplicity is amusing to me, sorry) do exactly what you say. Others believe that complexity inherently exists, and you can put it in the language, where a compiler can tirelessly check certain properties for you or a runtime can do magical complicated work on your behalf, or you can put it in the programs, where users have to check such things themselves.

Another way I heard this expressed one time is Ruby vs Python. I once heard someone talk about how they preferred Python as a language more, because it was simpler, but enjoyed actually programming in Ruby more, even thought it was more complex, and they value simplicity. The reason is that all of that nasty ugly stuff Ruby lets you do makes you be able to make extremely nice APIs. Things you couldn't do, or just folks don't do, in Python. And therefore they ended up liking using Ruby more in practice.

I suspect that this is a topic that we, as a profession, will debate about endlessly.

Re:Maintain It with Zig by pron on Wednesday September 08, 2021 @04:18PM (#28462486)
> Others believe that complexity inherently exists, and you can put it in the language, where a compiler can tirelessly check certain properties for you or a runtime can do magical complicated work on your behalf, or you can put it in the programs, where users have to check such things themselves.

I think we'd all agree there's a spectrum, with, say, Assembly on one end and Idris on the other, where neither Zig nor Rust are near either extreme, and are actually rather close to each other. It's not a matter of accepting or rejecting a principle, but on picking slightly different sweet spots (hopefully) on a tradeoff spectrum.

Rust doesn't check at compile-time most things that could be checked at compile-time. In fact both language check almost the same things at compile-time, and almost the same things at runtime. The design differences come down to one or two things that are clearly tricky and that neither language "does for you" -- i.e. you still need to think about them -- but are, indeed, checked in different ways.

Re:Maintain It with Zig by steveklabnik on Wednesday September 08, 2021 @04:25PM (#28462578)
Yep. I agree they’re closer to each other than the extremes for sure.
Re:Maintain It with Zig by dman on Wednesday September 08, 2021 @02:18PM (#28461067)
There is also the notion of languages you love writing code in vs languages you like reading code in. Languages with more powerful abstraction abilities bring joy to the writer but make things tedious for the reader.
Re:Maintain It with Zig by paavohtl on Wednesday September 08, 2021 @02:23PM (#28461115)
I don't agree with that. For example, I think it brings me joy as a reader that I can tell at a glance from a function signature which arguments are modified and which ones are just read. Without the abstraction of mutable and immutable references I would have to read the entire source code of the function and every function it calls to know for sure what it does with the pointers. It also brings me joy as a reader that common functionality like equality comparisons or string formatting can be derived by the compiler, instead of having separate hand-made implementations for each data structure, which might have subtle differences.
Re:Maintain It with Zig by steveklabnik on Wednesday September 08, 2021 @02:26PM (#28461161)
Totally.

I personally would not agree with

> Languages with more powerful abstraction abilities bring joy to the writer but make things tedious for the reader.

I find map/filter to be easier to read than a C-style for loop. Things that are conceptually denser make discussion between experts easier, even if it makes things harder for non-experts. This is why jargon exists, for example.

Re:Maintain It with Zig by dman on Wednesday September 08, 2021 @02:34PM (#28461262)
Ah yes - that makes sense. I should have been more precise - I meant abstractions that allow you to add opaqueness (like macros and operator overloading). Again culture plays a role here too - some communities normalize such abstractions more than others.

In short I believe languages that one can pick up in a couple of days and then read code where reasoning of the code is highly local would stand a higher chance of being perceived as simple.

Re:Maintain It with Zig by Jach on Wednesday September 08, 2021 @07:25PM (#28464296)
As always it depends. If you're thinking about preprocessor macros and operator overloading from C++, sure, those can be annoying, it's more to do with C++'s implementation and usage of them than the features themselves. You might want to try Common Lisp sometime; so much of the base language is made up of macros without which programs would be neither pleasant to read or write, and the language itself provides facilities to ask "ok but what function(s) are actually going to get called with this data" so that even not-so-local things like e.g. transparent logging of a call's input/output become visible if you need to know. But CL is not a language one can pick up in a couple of days -- albeit CL shops report success in getting new hires to be productive after a week or two of reading a book and the company code, which is a common onboarding time at many companies with any language.

Programmers notoriously conflate "simple" and "easy" (classic talk: https://www.infoq.com/presentations/Simple-Made-Easy/) and so I believe languages that are easy for a lot of programmers will also be perceived as simple, whether or not that's accurate.

Re:Maintain It with Zig by kaba0 on Thursday September 09, 2021 @05:44AM (#28467971)
Without powerful abstraction (of course used sparingly) you will just copy-paste the same logic in multiple places. Which is error prone and unmaintainable. And I would argue that even though a small part of it may be easier to read, you will have a harder time getting the big picture with low abstraction.
Re:Maintain It with Zig by Arnavion on Wednesday September 08, 2021 @03:39PM (#28462009)
Is

    char* c_foo(char* bar) { ... }
simpler than

    fn rust_foo<'a>(bar: &'a str) -> &'a str { ... }
?

On the one hand, c_foo is shorter and doesn't use strange symbols. On the other hand, rust_foo doesn't leave you guessing on whether the returned value needs to be free()d or not, and whether the heap allocation backing `bar` can be free()d after the call or not.

Re:Maintain It with Zig by steveklabnik on Wednesday September 08, 2021 @03:49PM (#28462124)
(You have a tiny typo; you forgot the <'a>. Also, I know you know this, but for those that don't, this signature could be written as

  fn rust_foo(a: &str) -> &str { ... }
but Arnavion is trying to be explicit here to make a steelman.)
Re:Maintain It with Zig by Arnavion on Wednesday September 08, 2021 @03:55PM (#28462227)
Yeah, I fixed that typo. And yes, foo is arbitrary, so one can assume it has another * / & parameter such that the lifetimes can't be elided any more.
Re:Maintain It with Zig by strokirk on Saturday September 11, 2021 @04:46PM (#28495805)
The first example is definitely simpler, yes.
Re:Maintain It with Zig by user-the-name on Wednesday September 08, 2021 @03:50PM (#28462149)
You are talking about the simplicity of a line of code. The topic being discussed, though, was the simplicity of the language itself.
Re:Maintain It with Zig by Arnavion on Wednesday September 08, 2021 @03:57PM (#28462254)
The simplicity of the language is directly correlated to the simplicity of that line. The fact that the language makes relationships between inputs and outputs explicit is a feature of the language, because of its borrow checker, at the expense of being syntactically verbose compared to C.
Re:Maintain It with Zig by user-the-name on Wednesday September 08, 2021 @05:35PM (#28463355)
Not at all. A single line will use a tiny subset of language features. It will show you nothing about the overall complexity of the language, just about those things it happens to use.
Re:Maintain It with Zig by paavohtl on Wednesday September 08, 2021 @02:11PM (#28460961)
In my experience unsafe tends to be used really sparingly by most users, if at all. And besides, unsafe doesn't really turn off static checks - it allows you to do a few extra things that can't be proven to be safe statically, in tightly scoped specially annotated regions. It's mostly about bending the rules temporarily, for 1-5 lines of code at a time.
Re:Maintain It with Zig by dimitrios1 on Wednesday September 08, 2021 @03:48PM (#28462122)
Side note: Nothing is provable in rust because it does not have a formal, verifiable specification. We have a reference implementation that we believe does the things it says it does on one particular architecture. But trust, not proofs, is indeed required. >:) (don't downvote murder me, I love rust)
Re:Maintain It with Zig by steveklabnik on Wednesday September 08, 2021 @03:54PM (#28462214)
A subset of Rust has been formalized and proven, but you're right that we're still working on it.
Re:Maintain It with Zig by heavyset_go on Wednesday September 08, 2021 @02:15PM (#28461023)
> It seems, from looking at others' code, that there is a very strong temptation to lean on `unsafe` instead of figuring out how to solve a problem within the constraints it normally applies.

Are you sure those examples of unsafe Rust code were written using unsafe in order to work around safety constraints due to difficulty?

I ask because there are some very real and valid use cases for unsafe code in Rust that have nothing to do with the fact that writing the code safely might be more difficult.

Re:Maintain It with Zig by mumblemumble on Wednesday September 08, 2021 @02:30PM (#28461209)
Not sure at all - I have effectively zero working knowledge of Rust - and certainly not looking to second-guess people's motivations for using the feature.

The big bias I'm working from here is that, as an outsider, I have a hard time reconciling all the big talk about how Rust makes it impossible to experience certain classes of bugs, with the existence of a known set of things that its type checker can't check, and which includes a lot of things that are difficult to avoid. One could be forgiven for thinking that the Rust community has a habit of keeping its fingers crossed behind its back when talking.

I don't want to make the perfect the enemy of the good, of course. I realize the feature is there for an important reason. But it sure looks to me like Zig is also good despite being imperfect. Perhaps they're both similarly good languages.

Re:Maintain It with Zig by not2b on Wednesday September 08, 2021 @03:06PM (#28461642)
Proper use of 'unsafe' in Rust is to write safe code that the compiler cannot prove is safe. In fact, this is done to implement many parts of Rust's standard library. See the split_at_mut example in

https://doc.rust-lang.org/book/ch19-01-unsafe-rust.html

The spec here is to turn one mutable slice into two non-overlapping mutable slices. The operation does not violate memory safety; we wind up with only one mutable reference to any part of the object. But the compiler does not know how to verify that the programmer has done this correctly. Here, 'unsafe' means 'I certify that this is safe, use that as a lemma to do further checking'.

Re:Maintain It with Zig by pjmlp on Wednesday September 08, 2021 @03:35PM (#28461945)
All systems programming languages need the ability to do unsafe stuff, the big difference between C , C++, Objective-C and all the remaining system programming languages since JOVIAL and NEWP, is the explicit unsafe code blocks that make that visible.

It is a big difference to have it on your face that something might need to be properly double checked and having each line of code as possible security exploit.

Re:Maintain It with Zig by jhgb on Wednesday September 08, 2021 @04:44PM (#28462811)
> the big difference between C , C++, Objective-C and all the remaining system programming languages since JOVIAL and NEWP, is the explicit unsafe code blocks that make that visible.

Would you consider Oberon to belong in the former or latter category? On one hand, there's no explicit code blocks as such (syntactically). On the other hand, unsafe primitive operations are limited to the SYSTEM module, so functions calling operations in the SYSTEM module can be considered doing unsafe things.

Re:Maintain It with Zig by pjmlp on Wednesday September 08, 2021 @05:08PM (#28463089)
If you read Oberon documentation, modules importing SYSTEM are tainted and considered unsafe.

Just like Modula-2 already does it.

Re:Maintain It with Zig by jhgb on Wednesday September 08, 2021 @05:19PM (#28463204)
Well...that's what I meant. But which one is it, then?
Re:Maintain It with Zig by pjmlp on Thursday September 09, 2021 @02:06AM (#28466808)
Just like the languages that have unsafe code blocks it is relatively easy to track down unsafe modules, same thing.

And just like languages with unsafe code blocks, there are compilers that have switches to forbid the use of tainted modules unless explicitly allowed.

In any case, way better than what C, C++ and Objective-C offer, regarding security per line of code.

Re:Maintain It with Zig by Ar-Curunir on Wednesday September 08, 2021 @02:49PM (#28461453)
No type checker can catch all buggy programs (that involve solving the halting problem). In practice, Rust strikes a good balance: in over 120,000 LoC of Rust code that I have helped write and maintain, we have maybe 10 lines of unsafe, with performance matching or exceeding that of the C/C++ counterparts.
Re:Maintain It with Zig by tialaramex on Wednesday September 08, 2021 @08:51PM (#28464936)
> No type checker can catch all buggy programs (that involve solving the halting problem).

It's far worse than that, the problem is that the machine can't know what was intended. The result 5 from calling sum([1,2,1,1]) makes sense, but alas this function was intended to produce the product not the sum, the inputs were supposed to be [1,2,3,4] and the desired result was 24... the machine can't hope to guess that.

A program may be buggy even if it its meaning is transparent and exactly reflects its effect, simply because it doesn't reflect the intention of the person who wrote the wrong program.

This quote is attributed to Babbage:

'On two occasions I have been asked, – "Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?" ... I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question'

But that is what we wanted, even if we obviously can't have it.

Re:Maintain It with Zig by heavyset_go on Wednesday September 08, 2021 @03:44PM (#28462072)
It might help to better understand the motivations behind unsafe Rust by reading some of The Rustonomicon[1].

[1] https://doc.rust-lang.org/nomicon/

Re:Maintain It with Zig by rattray on Wednesday September 08, 2021 @01:14PM (#28460113)
I think they solve some similar and some different problems, with some similarities and differences!

The biggest difference in the problems they solve, in my view, is that Zig does not aim for safety. It'll be easier to write safe programs yourself with Zig than it might be with C, but it doesn't give you any guarantees.

Zig also seems like it may be a better fit for embedded programming; there's a big community around embedded Rust, and it sounds like there's a lot of progress, but still an uphill battle.

But yes, Zig:Rust :: C:C++ has merit in that Zig is a much smaller, less feature-rich language.

Re:Maintain It with Zig by void_mint on Wednesday September 08, 2021 @01:19PM (#28460176)
Thanks for the response. I'm excited for as many viable alternatives to C/C++ as we can get.
Re:Maintain It with Zig by travisgriggs on Thursday September 09, 2021 @12:31AM (#28466210)
I write/maintain multiple code bases for XMega, SAMD, and STM chips. The kind where 32K ram is cool and 256K flash is lots. I'm curious if either of these is ready for normal humans to cross compile for these kinds of targets (M0 and the ilk). Zig looks very interesting to me.
Re:Maintain It with Zig by steveklabnik on Wednesday September 08, 2021 @01:35PM (#28460410)
Many people say this, and there's some truth to it, but like all analogies, it can be useful in some contexts but not others.

The issue with this analogy is that it assumes that C, one of the languages used in the most diverse set of circumstances ever, means the same thing to everyone. Same with C++, frankly.

Re:Maintain It with Zig by oconnor663 on Wednesday September 08, 2021 @01:10PM (#28460044)
> Would it be fair to say that Zig is to C, what Rust is to C++?

There's definitely something to that analogy, but I think it also misses a lot of really important details. For example, Zig has generics, which right off the bat makes it hard to say that it's "like C". Also Rust enforces memory safety, which isn't like C or C++.

Re:Maintain It with Zig by roblabla on Wednesday September 08, 2021 @01:43PM (#28460526)
I mean, C11 also has generics, but I would really suggest not using it X). See https://en.cppreference.com/w/c/language/generic

Of couse, it's a much less powerful feature, there's nothing like interfaces or stuff, just a way to "overload" based on the type.

Re:Maintain It with Zig by yisonPylkita on Wednesday September 08, 2021 @03:51PM (#28462164)
Thank you. I had no idea that you could do such a thing in C11 preprocessor
Re:Maintain It with Zig by flohofwoe on Thursday September 09, 2021 @04:54AM (#28467698)
_Generic() is not a preprocessor feature, but a "real" language feature (I was confused too when I saw it first though).

The only preprocessor part in the example is mapping the function-like macro 'cbrt(X)' to the language keyword '_Generic(X)'.

Re:Maintain It with Zig by woodrowbarlow on Wednesday September 08, 2021 @02:48PM (#28461424)
i love that zig doesn't have a special syntax for generics, it just allows anything to be resolved at compile-time -- including types. which gives you generics 'for free'.
Re:Maintain It with Zig by maleldil on Wednesday September 08, 2021 @04:50PM (#28462886)
I've only cursory of Zig, so bear with me. Does this mean that Zig templates are like C++, that is, duck typing? Or is there a notion of constraining the type arguments?
Re:Maintain It with Zig by kristoff_it on Wednesday September 08, 2021 @05:07PM (#28463082)
It's duck typed but it's not based on a funky and limited syntax, but rather types at comptime become normal arguments to functions that you can then inspect using normal Zig code.

I wrote a blog post about comptime if you want to learn more: https://kristoff.it/blog/what-is-zig-comptime/

Re:Maintain It with Zig by dnautics on Wednesday September 08, 2021 @06:46PM (#28464002)
It's duck typed but let's say your "template" takes an integer and divides by two depending on some boolean (perhaps you need to return a lookup table of sometimes half the bitwidth of an integer type). That function called by your template at compile time to maybe-divide-by-two is in the same language as runtime zig, and you could even conceivably call that very same function as a compiled entity in the runtime context.
Re:Maintain It with Zig by robinei on Wednesday September 08, 2021 @05:07PM (#28463080)
You can constrain type arguments with a compile-time `if` check, and generate a compile error on violation.
Re:Maintain It with Zig by nrclark on Wednesday September 08, 2021 @01:13PM (#28460092)
I think that's correct with some overlap, yes. Zig's explicit goal - as stated by the creator - is to replace C. Nothing more, nothing less.

I feel like Rust wants to replace C but it also wants to replace C++. And given the complexity difference between the two languages, that means that Rust will end up closer to C++ than to C.

So there's some overlap based on how Rust positions itself, but not based on how Zig positions itself.

Re:Maintain It with Zig by masklinn on Wednesday September 08, 2021 @01:34PM (#28460399)
> I feel like Rust wants to replace C but it also wants to replace C++.

Rust wants to make systems programming memory safe (and type safe while at it). It's not really about any specific language, it's about dragging the field forwards on the safety front.

Well it's not really Rust, it's the Rust community, which kinda wrestled it away from Graydon Hoare: the original inception of Rust was more of an applications language (what with the evented model and the split stack and the planned-though-never-really-implemented GC'd pointers) — which explains part of the historical confusion with / comparison to Go.

But then a critical mass of people took a look at this early rust and figured "we've got plenty of memory-safe and type-safe (ish) languages for applications, but this thing has precise control over memory and lifetimes and shit, we could actually build reliable infrastructure with that", and it coincided with a lot of memory safety issues news (which has been continuing ever since), and the rest is history, pretty much.

Re:Maintain It with Zig by AndyKelley on Wednesday September 08, 2021 @03:24PM (#28461846)
You can find Zig's explicit goal as stated by the creator on the homepage:

> Zig is a general-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.

Re:Maintain It with Zig by nrclark on Thursday September 09, 2021 @02:27AM (#28466920)
Touche! I heard you on Corecursive, which is where I got that from.

Keep up the good work, I'm excited to see where Zig goes next.

Re:Maintain It with Zig by dnautics on Thursday September 09, 2021 @12:40AM (#28466265)
I believe the creator is on record on some youtube video or something stating that the intent is to replace C.
Re:Maintain It with Zig by skywal_l on Thursday September 09, 2021 @01:21AM (#28466531)
The guy you are responding to IS the creator of the language.
Re:Maintain It with Zig by dnautics on Thursday September 09, 2021 @10:08AM (#28469858)
yes, I'm aware, and he's aware of who I am too =D
Re:Maintain It with Zig by abledon on Wednesday September 08, 2021 @02:54PM (#28461518)
We already have c/c++ as low level bases, now zig/rust are coming for the throne, I really hope contenders dont keep spawning like rabbits. If everyone got behind a smaller # of initiatives the worlds codebase would be simpler going forward?

I'm imaging some poor software engineer in 2065, having to maintain an enterprise legacy stack... levels of FORTRAN/COBOL->C->C++->ZIG->RUST->PERL->PYTHON.... all the way up....JS..etc..

Re:Maintain It with Zig by roca on Wednesday September 08, 2021 @10:59PM (#28465729)
I don't want contenders to spawn like rabbits. I want the industry to coalesce around just a few contenders to maximise network effects so as to kill off C and C++ more effectively.
Re:Maintain It with Zig by IggleSniggle on Wednesday September 08, 2021 @09:53PM (#28465322)
While I would absolutely love to have that job, I’m afraid I’ll never get to do it. Language cross-compilers seem to keep getting better. It may be that case that one day, you will run a legacy program through a babelfish and get something understandable to you back out.

Of course, the complexity might explode from there…or you might just not really notice it all that often. Anybody familiar with LLVM or WASM or heck even a language that can transpile to JavaScript can probably relate to this possibility.

The thing that’s harder to fathom is going from low-level to high-level. High-level -> intermediary low-level -> high-level is fathomable though.

Re:Maintain It with Zig by flohofwoe on Thursday September 09, 2021 @04:56AM (#28467715)
> I really hope contenders dont keep spawning like rabbits

I do, because that would mean that more attention must be paid to make languages work together, instead of each language ecosystem becoming its own little island. Maintaining a project built from a dozen languages (where each language does one thing well) should be just as simple as maintaining a mono-language project.

Re:Maintain It with Zig by kaibee on Wednesday September 08, 2021 @03:23PM (#28461836)
> I'm imaging some poor software engineer in 2065, having to maintain an enterprise legacy stack... levels of FORTRAN/COBOL->C->C++->ZIG->RUST->PERL->PYTHON.... all the way up....JS..etc..

I have good news and bad news: That programmer will not know any of those languages, as they will just program in English and GPT-3000 will convert it into code.

Re:Maintain It with Zig by PaulDavisThe1st on Wednesday September 08, 2021 @04:35PM (#28462696)
The reason that we have programming languages at all is that English and all other natural languages are too ambiguous to be used for this purpose.

GPT-3000 will have no problem understanding some interpretation of your English (or Spanish or Mandarin) "program", but will it be the right one? How long will it take to get GPT-3000 to understand what you mean when you can only talk to it in English (or Spanish or Mandarin) ?

Re:Maintain It with Zig by AnIdiotOnTheNet on Wednesday September 08, 2021 @05:59PM (#28463576)
Eventually maybe only the same amount of time it takes the average programmer to understand your meaning.
Re:Maintain It with Zig by chubot on Wednesday September 08, 2021 @07:40PM (#28464398)
So like months and years? On every project I’ve worked on, the programmers conception of the requirements evolves until the minute they stop working on it. And they only understand the part they worked on, not the whole thing
Re:Maintain It with Zig by PaulDavisThe1st on Wednesday September 08, 2021 @07:48PM (#28464460)
The discussion is not about understanding "requirements".

A piece of software is a set of instructions that tell a computer how to do something. We use languages like C, Python, Haskell and Lisp to describe what to do in ways that avoid as much ambiguity as possible.

The question is: if you used a natural (human) language, how much confusion would (a) the putative GPT-3000 (b) another programmer (c) a compiler/interpreter incur when trying to understand your instructions?

Re:Maintain It with Zig by PaulDavisThe1st on Wednesday September 08, 2021 @07:50PM (#28464476)
That might be true. But the comparison is not with another programmer. Rather, it's with the essentially instantaneous understanding that a compiler/interpreter has when you feed in a programming language.
Re:Maintain It with Zig by flohofwoe on Thursday September 09, 2021 @05:09AM (#28467784)
This has been attempted many times in the last century but never happened, I think it's quite safe to say that this also won't happen in the next century.
Re:Maintain It with Zig by jhoechtl on Wednesday September 08, 2021 @01:39PM (#28460460)
> Zig's explicit goal - as stated by the creator - is to replace C. Nothing more, nothing less.

The ZIG compiler requires a C compiler to compile to a native executable though.

Re:Maintain It with Zig by Twisol on Wednesday September 08, 2021 @01:44PM (#28460552)
To be fair, the C compiler also requires a C compiler. Bootstrapping is a common milestone in language development (Rust can bootstrap itself too), so while the current state of affairs for Zig might require a C compiler, that's not necessarily written in stone.
Re:Maintain It with Zig by wyldfire on Wednesday September 08, 2021 @01:49PM (#28460626)
> The ZIG compiler requires a C compiler to compile to a native executable though.

Do you mean compiling the zig compiler or zig programs?

I think neither is quite the case. zig itself can build both Zig programs and C/C++ ones. Zig doesn't need to use a C compiler to build native Zig executables. It does need a linker, as does Rust, as do C/C++ programs and AFAIK zld is not yet ready.

However it's accurate to say that it's only able to compile the C/C++ code by leveraging libclang, the C/C++ compiler underneath.

Re:Maintain It with Zig by AndyKelley on Wednesday September 08, 2021 @03:49PM (#28462134)
Here's the info on zld status: https://ziglang.org/download/0.8.0/release-notes.html#Self-H...

By the way, check out this project by Zig core team member, Vexu: https://github.com/Vexu/arocc

Re:Maintain It with Zig by messe on Wednesday September 08, 2021 @02:42PM (#28461364)
> The ZIG compiler requires a C compiler to compile to a native executable though.

No it doesn't? Not unless you want to also compile C, which the Zig compiler is capable of doing because it bundles clang.

Re:Maintain It with Zig by tristan957 on Wednesday September 08, 2021 @01:00PM (#28459889)
Zig/Rust aim to fit in the same systems/general purpose space which can be viewed as alternatives to both C and C++.
Re:Maintain It with Zig by matu3ba on Wednesday September 08, 2021 @03:10PM (#28461696)
Take a look at my comparison of semantics that unfortunately not yet includes a sketch of memory and synchronization: https://gist.github.com/matu3ba/dda72ad5ee473e3ea26426c121e0...
Re:Maintain It with Zig by phplovesong on Thursday September 09, 2021 @02:06AM (#28466812)
Just curious. Why do you have doubts about about the package manager? There are so many languages that have a package ecosystem, so by now you'd think its easy to find out what works and what does not.