Live data from Hacker News

Type resolution redesign, with language changes to taste

ziglang.org

71–80 of 284 posts

Re: Type resolution redesign, with language changes to taste

#71
post #66
post #22

Earlier quoted context omitted.

AFAIK garbage collection is basically not implemented yet. I myself do `ZIG_LOCAL_CACHE_DIR=~/.cache/zig` so I only have to nuke single directory whenever I feel like it.

what exactly people call 'garbage collection' in Zig? build cache cleanup?

Indeed what was referred to here is the zig build system cache.

Re: Type resolution redesign, with language changes to taste

#72
post #54

Earlier quoted context omitted.

I've worked on two "production" zig codebases: tigerbeetle [0] and sig [1]. These larger zig projects will stick to a tagged release (which doesn't change), and upgrade to newly tagged releases, usually a few days or months after they come out. The upgrade itself takes like a week, depending on the amount of changes to be done. These projects also tend to not use other zig dependencies. [0]: https://github.com/tigerb…

I really wanted to deep dive into zig but I'm into rust now kinda late as I'm really just started like 2024. Have you tried rust? how does it compared to zig? * just asking

Two different philosophical approaches with Zig and Rust.

- Zig: Let's have a simple language with as few footguns as possible and make good code easy to write. However we value explicitness and allow the developer to do anything they need to do. C interoperability is a primary feature that is always available. We have run time checks for as many areas of undetermined behaviour as we can.

- Rust: let's make the compiler the guardian of what is safe to do. Unless the developer hits the escape hatch, we will disallow behaviour to keep the developer safe. To allow the compiler to reason about safety we will have an intricate type system which will contain concepts like lifetimes and data mobility. This will get complex sometimes so we will have a macro system to hide that complexity.

Zig is a lot simpler than Rust, but I think it asks more of it's developer.

Re: Type resolution redesign, with language changes to taste

#73
post #57

Earlier quoted context omitted.

Why isn't rustc using Cranelift then?

I can think a few reasons: - Cranelift applies less optimizations in exchange for faster compilation times, because it was developed to compile WASM (wasmtime), but turns out that is good enough for Rust debug builds. - Cranelift does not support the wide range of platforms (AFAIK just X86_64 and some ARM targets)

So it isn't just a matter of "they would use Rust instead".

There is a whole ecosystem of contributions across the globe and the lingua franca used by those contributors.

Re: Type resolution redesign, with language changes to taste

#74
post #52

Earlier quoted context omitted.

> But I prefer Rust over Zig. The main difference is Rust chooses a "closed world" model while Zig chooses an "open world" model: in Rust, you must explicitly implement a trait while in Zig as long as the shape fits, or the `.` on a structure member exists (for whichever type you pass in), it will work (I don't use Zig so pardon hand wavy description). Do you happen to have a more specific example by any chance? I’d…

They are referring to `anytype`, which is a comptime construct telling the compiler that the parameter can be of any type and as long as the code compiles with the given value, it's good. It's an extremely useful thing, but unconstrained, it's essentially duck typing during compile time. People has been wanting some kind of trait/interface support to constrain it, but it's unlikely to happen.

Conceptually it's quite similar to how C++ templates work (not including C++20 concepts, which is the kind of constraining you're talking about).

I quite like it when writing C++ code. Makes it dead easy to write code like `min` that works for any type in a generic way. It is, however, arguably the main culprit behind C++s terrible compiler-errors, because you'll have standard library functions which have like a stack of fifteen generic calls, and it fails really deeply on some obscure inner thing which has some kind of type requirement, and it's really hard to trace back what you actually did wrong.

In my (quite limited) experience, Zig largely avoids this by having a MUCH simpler type system than C++, and the standard library written by a sane person. Zig seems "best of both worlds" in this regard.

Re: Type resolution redesign, with language changes to taste

#75

Earlier quoted context omitted.

Seriously asking, where Go sits in this categorization?

Go is modern Java, at least based on the main area of usage: server infrastructure and backend services.

i wonder what makes go more modern than java, in terms of features.

Re: Type resolution redesign, with language changes to taste

#76
post #62

Earlier quoted context omitted.

I really wanted to deep dive into zig but I'm into rust now kinda late as I'm really just started like 2024. Have you tried rust? how does it compared to zig? * just asking

Zig is a modern C, Rust is a modern C++/OCaml So if you enjoy C++, Rust is for you. If you enjoy C and wish it was more verbose and more modern, try Zig.

It is kind of interesting that the Linux kernel is slowly adopting Rust, whereas Zig seems like it would be a more natural fit?

I know, timelines not matching up, etc.

Re: Type resolution redesign, with language changes to taste

#77
post #75

Earlier quoted context omitted.

Go is modern Java, at least based on the main area of usage: server infrastructure and backend services.

i wonder what makes go more modern than java, in terms of features.

The tooling and dependency management probably

Re: Type resolution redesign, with language changes to taste

#78
post #43

Earlier quoted context omitted.

Claude CLI is based on bun. The dependency is so complete that Bun have now joined Anthropic.

Claude CLI is not exactly a reference of usable software

It's plenty usable. Most of the problems with the claude TUI stem from it being a TUI (no way to query the terminal emulator's displayed character grid), so you have to maintain your own state and try to keep them in sync, which more than a few TUIs will fail at at least sometimes, hence the popularity of conventions like Ctrl+L to redraw.

Re: Type resolution redesign, with language changes to taste

#79
post #62

Earlier quoted context omitted.

Zig is a modern C, Rust is a modern C++/OCaml So if you enjoy C++, Rust is for you. If you enjoy C and wish it was more verbose and more modern, try Zig.

Seriously asking, where Go sits in this categorization?

Nowhere, or wherever C# would sit. Go is a high level managed language.
Post reply on HN