Live data from Hacker News

Maintain It with Zig

kristoff.it

231–240 of 286 posts

Re: Maintain It with Zig

#231
post #202

Earlier quoted context omitted.

I'm not close to Zig development, but in addition to the GeneralPurposeAllocator work that a comment already links to, there is other ongoing stuff in that space, like an allocator in 64-bit that does not reuse pages (and instead keeps using new addresses in the "infinite" 64-bit space). There are also known techniques like Type-After-Type that can avoid use-after free in C and C++ [0]. And also advances in hardware…

what does zig offer over c/c++ with sanitizers?

Sanity.

Seriously. You get these tests for free with zig, no extra tooling, if you use testing allocator in your tests. This also is a carrot to get you to write tests. Hell, I even mocked libc's malloc/calloc/free to make sure that my code doesn't leak memory:

https://github.com/ityonemo/Primes/blob/ee81d05e80d68854ab11...

Re: Maintain It with Zig

#232

Earlier quoted context omitted.

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.

I believe the creator is on record on some youtube video or something stating that the intent is to replace C.

The guy you are responding to IS the creator of the language.

Re: Maintain It with Zig

#234
post #180
post #140

Earlier quoted context omitted.

> ...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.

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....

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

#235
post #169
post #165

Earlier quoted context omitted.

If you read Oberon documentation, modules importing SYSTEM are tainted and considered unsafe. Just like Modula-2 already does it.

Well...that's what I meant. But which one is it, then?

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

#236
post #6

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-…

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.

Re: Maintain It with Zig

#237

Earlier quoted context omitted.

what does zig offer over c/c++ with sanitizers?

Sanity. Seriously. You get these tests for free with zig, no extra tooling, if you use testing allocator in your tests. This also is a carrot to get you to write tests. Hell, I even mocked libc's malloc/calloc/free to make sure that my code doesn't leak memory: https://github.com/ityonemo/Primes/blob/ee81d05e80d68854ab11...

What sanity when the developer is still responsible for tracking memory manually by themselves?

> It is the Zig programmer's responsibility to ensure that a pointer is not accessed when the memory pointed to is no longer available.

https://ziglang.org/documentation/0.8.1/#Memory

Mocking malloc you say?

https://docs.microsoft.com/en-us/visualstudio/debugger/crt-d...

It exists at very least since Visual C++ 5.0, and Borland had similar tooling since their first Win16 compilers.

Re: Maintain It with Zig

#238

Agreed for sure that working with C and C++ is the only way forward for systems languages. Rust's expression of this is the zero-cost C FFI, using native platform tooling, and stuff like that. Rust was never about re-writing the world, after all, its reason for existing was to eventually improve Firefox. The very first presentation about Rust ( http://venge.net/graydon/talks/intro-talk-2.pdf ) says "We are not “rewri…

The boat has already sailed, but it's GCd languages and not Rust that replaced most usage of C and C++ in systems programming. Rust is nibbling at the remaining niche islands of C/C++.

Re: Maintain It with Zig

#239
post #90

I prefer D, it can be fully compatible with C, the syntax is easy to learn if you've used any of the C family you already know 80%, the package system is simple, modules mean no more headers or include statements just import things where and when you need them, supports every style of programming, QOL improvements like ranges and foreach, proper strings, optional garbage collector, has a long history of continuous im…

For strings in C nothing beats SDS by antirez. So simple

Sadly it is the kind of stuff that keeps being ignored by WG14.

Re: Maintain It with Zig

#240
post #15

Earlier quoted context omitted.

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 pos…

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.

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.

Post reply on HN