Live data from Hacker News

Zig; what I think after months of using it

strongly-typed-thoughts.net

161–170 of 181 posts

Re: Zig; what I think after months of using it

#161
post #120

Earlier quoted context omitted.

> it appears the clr author anticipated you: you didnt fork it, try, and fail, so you have ceded the authority to credibly make your speculative complaint That's a caveat. Not an expectation. Plus that's not how proof works. Neither Zig nor Zig+Clr have really proven they are safe, ergo they are unsafe or possibly safe (respectively).

wow what are you afraid of. you're working really hard to tear down something that is an incomplete proof of concept.

Nothing, it's the principle of the thing. I.e. when you make a challenging to evaluate statement, the burden of proof is on the one making the claim.

If I say "Moon is made of millennia old cheese", the burden of proof isn't on you to go create a rocket, fly to the moon, sample it and come with conclusions, but on me, making a difficult to verify statement.

Re: Zig; what I think after months of using it

#162
post #153

Earlier quoted context omitted.

If I'm told to still use === in typescript, it's not actually a statically typed language.

It's not a statically typed language. No one is claiming it is. It's a dynamic language with static types.

Nonsense.

If I need to keep using === because the type might actually be something different at runtime, it doesn't have static types.

Re: Zig; what I think after months of using it

#163
post #146

Earlier quoted context omitted.

For Rust references, rules[0] are not hard to follow: The pointer must be properly aligned. It must be non-null. It must be “dereferenceable”: a pointer is dereferenceable if the memory range of the given size starting at the pointer is entirely contained within the bounds of that allocated object. Note that in Rust, every (stack-allocated) variable is considered a separate allocated object. The pointer must point to…

One reason it’s harder to follow is you can’t have references to uninitialized memory. In Zig pointers to uninitialized memory are fine as long as you don’t dereference them. That’s also true of Rust’s raw pointers, but most Rust code uses references, so it can’t be reused in unsafe contexts. As a concrete example, I previously used Vec in unsafe code that dealt with uninitialized memory. This should be fine because…

> you can’t have references to uninitialized memory.

The method is available[0] in nightly Rust

    pub const unsafe fn as_uninit_ref(self) -> Option>
    where
        T: Sized,
    {
        // SAFETY: the caller must guarantee that `self` meets all the
        // requirements for a reference.
        if self.is_null() { None } else { Some(unsafe { &*(self as *const MaybeUninit) }) }
    }
[0]: https://doc.rust-lang.org/stable/core/primitive.pointer.html...

Re: Zig; what I think after months of using it

#164

Earlier quoted context omitted.

As a systems programmer, Rust has won. It will take decades before there is substantial Rust replacing the absurd amounts of C that runs on any modern Unix system, but I do believe that our of all the replacements for C/C++, Rust has finally gained the traction most of them have lacked at the large companies that put resources behind these types of rewrites and exploratory projects. I do not think Zig will see wide a…

Rust has very real limitations and trade-offs. It compiles slow and the binaries are large. The compiler also makes performance sacrifices that makes it generally slower than C. I'm sure the language will continue to be successful, but it hasn't "won".

I maintain a Rust project that is ~50,000 loc [1]. I've never felt that compiling is slow, in the contrary it's always a pleasure to see how fast the project compiles (at least in debug).

In release, build time is longer but in this case, it's in the CI/CD so it doesn't bother me. We try to be very conservative with adding dependencies so it may help compilation time. Also I'm coming from a Java/Kotlin world so a lot of things appear like fresh air in comparison...

[1]: https://github.com/Orange-OpenSource/hurl

Re: Zig; what I think after months of using it

#165
post #96

Earlier quoted context omitted.

Zig might not become very popular, but IMO, it will become more popular than Rust. Zig is good at all the areas Rust is good at. Zig is also good at game development which Rust is not good at. And Zig is better when integrating with C/C++ libraries.

> Zig is good at all the areas Rust is good at. Not memory safety. > Zig is also good at game development which Rust is not good at. Let's see. Over just the past year in Bevy I've implemented GPU driven rendering, two-phase GPU occlusion culling, specular tints and maps, clustered decals, multi-draw, bindless textures, mixed lighting, bindless lightmaps, glXF support, skinned mesh batching, light probe clustering, v…

What are you doing all that for? Sounds like a ton of work. Like months of full time?

Re: Zig; what I think after months of using it

#166
post #153

Earlier quoted context omitted.

It's not a statically typed language. No one is claiming it is. It's a dynamic language with static types.

Nonsense. If I need to keep using === because the type might actually be something different at runtime, it doesn't have static types.

It has static types because the compiler won't let you change a variable's type.

It's exactly as statically typed as C#. Both allow explicitly-declared dynamic variables, but they're disabled by default.

=== is incidental syntax required to maintain the goal of being a superset of JS.

Re: Zig; what I think after months of using it

#167
post #37
post #26

Earlier quoted context omitted.

It’s been a feature in languages for at least half a century. Scheme’s lexical scoping supported it in 1975, and Lisp adopted that.

Yeah, it's a feature of a language, doesn't mean we are forced to use it.

You asked when it became a feature. I answered that.

But your antipathy towards the feature is misplaced. Several languages with the most rigorous foundations support shadowing: SML, Ocaml, Haskell, Scheme,

You're probably more familiar with languages that have unrestricted mutation, in which case something much worse than shadowing is allowed: changing the value of an existing variable.

Re: Zig; what I think after months of using it

#168

C and C++ both have support for bit-fields. https://en.wikipedia.org/wiki/Bit_field#Examples https://fbb-git.gitlab.io/cppannotations/cppannotations/html... https://en.cppreference.com/w/cpp/language/bit_field

However they lack support for pointers to those fields. Which zig has.

Re: Zig; what I think after months of using it

#169
post #57

> Zig does enhance on C, there is no doubt. I would rather write Zig than C. The design is better, more modern, and the language is safer. But why stop half way? Why fix some problems and ignore the most damaging ones? I was disappointed when Rust went 1.0. It appeared to be on a good track to dethroning C++ in the domain I work in (video games)... but they locked it a while before figuring out the ergonomics to make…

> Any language that imbues the entire set of special characters (!#*&[]{}(); ...etc) with mystical semantic context is, imo, more interested in making its arcane practitioners feel smart rather than getting good work done.

On that scale COBOL is a better programming language.

Re: Zig; what I think after months of using it

#170
post #74

Earlier quoted context omitted.

It’s harder to write correct unsafe Rust than correct Zig because (1) Rust uses references all over the place, but when writing unsafe code you must scrupulously avoid “producing” an invalid reference (even if you never deference it), and (2) there’s lots of syntax noise which obscures what the code is doing (though &raw is a step in the right direction).

> Rust uses references all over the place This is mostly a concern with the Rust stdlib, though. And it's in principle fixable, by writing new varieties of those stdlib functions that take raw-pointer or &UnsafeCell arguments, and delegating the "safe" varieties to those.

There's compiler-level traits like `Iterator` and `Future` which enforce references. If wanting to do intrusive pointers into them, one risks creating overlapping references: https://github.com/tokio-rs/tokio/issues/3399
Post reply on HN