Live data from Hacker News

Zig, the Small Language

zserge.com

261–270 of 429 posts

Re: Zig, the Small Language

#261
post #144

Earlier quoted context omitted.

It does seem confusing to me why someone would choose Zig. If you’re looking for a low-level language, Rust is safer with a better ecosystem. If you want a high-level language, Nim binaries are smaller and the Go ecosystem is better. When is Zig the best choice?

I would choose Zig because Zig has a much more approachable learning curve and Zig code is eminently legible compared to Rust code and it's overly complex type system.

Why not Go or Nim?

Re: Zig, the Small Language

#262

Earlier quoted context omitted.

> I hope in the future I can use Zig as a Go replacement I've only scratched the surface of Zig myself, but my impression is that replacing Go with Zig will probably be painful in most cases. I think of the stereotypical Go project as a backend API service, where memory is relatively plentiful, and "make a copy of this string" is something you do all the time without thinking twice about it. It seems like Zig wants y…

Strings are immutable in go so they don't need to be copied? https://go.dev/play/p/o-ly05_Q46E

Yes I know :) Equally importantly, the Go GC will keep a string alive as long as you have a reference to it, so different objects can hold a pointer to the same string without worrying about who's going to free it or whether one of those pointers might become dangling. Python and Go (and others?) get a lot of mileage out of making strings shared and immutable, but languages with manual or destructor-based memory management don't really have that option.

Re: Zig, the Small Language

#263

Earlier quoted context omitted.

There are plenty of people who love chess but hate opening theory. They look to variants such as chess960 to get their logician fix on. They also tend to love Go (the board game) and perhaps even Stratego (which has such a game tree that dwarfs the rest).

Chess was such a good example to use in this lame dichotomy that we are now pivoting to Bobby Fischer chess and completely different games.

It's not a lame dichotomy. There are loads of people who detest rote memorization and prefer to solve only the problem directly in front of them. Bobby Fischer himself invented his variant because he hated that aspect of the game. I, personally, empathize with this position as a university student who gets higher grades in pure math courses than in the "easier" applied versions due to the memorization aspect.

Re: Zig, the Small Language

#264
post #144

Earlier quoted context omitted.

It does seem confusing to me why someone would choose Zig. If you’re looking for a low-level language, Rust is safer with a better ecosystem. If you want a high-level language, Nim binaries are smaller and the Go ecosystem is better. When is Zig the best choice?

I would choose Zig because Zig has a much more approachable learning curve and Zig code is eminently legible compared to Rust code and it's overly complex type system.

it's overly complex because ...?

Re: Zig, the Small Language

#265

Earlier quoted context omitted.

> every compiler switch is a bug I totally get where this is coming from, but on the other hand it seems like Rust and Zig both get a lot of value from having the compiler understand the difference between debug and release modes, and it seems like modern C++ suffers somewhat from not having any built-in way to do something similar. The optimal number of compiler switches might not be zero.

D literally has the switches `-release` and `-debug`.

It seems to me that a possible improvement would be for the compiler to error on unreachable code in `-release` and to warn in `-debug`.

Re: Zig, the Small Language

#266

Earlier quoted context omitted.

Chess was such a good example to use in this lame dichotomy that we are now pivoting to Bobby Fischer chess and completely different games.

It's not a lame dichotomy. There are loads of people who detest rote memorization and prefer to solve only the problem directly in front of them. Bobby Fischer himself invented his variant because he hated that aspect of the game. I, personally, empathize with this position as a university student who gets higher grades in pure math courses than in the "easier" applied versions due to the memorization aspect.

Doesn’t matter because it doesn’t apply to language design.

Re: Zig, the Small Language

#267
post #176

Earlier quoted context omitted.

> Not fighting the borrow checker This isn't going to be appealing to Rust current users though, because “fighting the borrow checker” is a learning curve issue, you don't fight the borrow checker anymore once you've internalized its rules. > or making gratuitous copies of data to satisfy the borrow checker. You get it backward. In Rust there's less gratuitous copies, not more, because the ownership rules and the bor…

That was not my experience. I still fought the borrow checker after a year of using Rust. And I found many situations while using Rust where I either needed to clone, or use unsafe where it's easier to make a mistake than in other languages because the syntax is extremely unergonomic and the memory semantics are much less clear.

can you give examples please?

Re: Zig, the Small Language

#268

Earlier quoted context omitted.

I'm not at all trying to change your mind (I've never used Zig so I can't comment there), but just FYI: 1. Rust uses Zulip (ie, not Discord or Slack), 2. Rust doesn't lack for promising-looking, declarative/reactive UI frameworks: https://iced.rs/ , https://crates.io/crates/egui , for example.

>1. Rust uses Zulip (ie, not Discord or Slack), The official Rust chat is on Discord. Now, to Cyberdog's point, there is an IRC channel on libera (that I'm also a part of) and it's even bigger than Zig's channel, but it's "unofficial" and they did ask for an official one. Like, Zig's channel has the advantage of being a direct line to andrewrk which you won't get from the Rust channel.

Thanks for the correction! I conflated what (I believe) some rust teams use as the thing that every thing in official rust uses. I think Rust uses both Discord and Zulip[0].

[0] https://zulip.com/case-studies/rust/

Re: Zig, the Small Language

#269

Why would anyone use a new systems programming language that is not safe? Zig might be better than C in some aspects, but is it worth it to switch to Zig when you realize that it's not much safer than C? [0] [0]: https://www.scattered-thoughts.net/writing/how-safe-is-zig/

> systems programming language that is not safe?

It sounds like you're saying rust because I don't know what other languages claim both.

Rust is an awful language. That's why. If you're using a systems programming language then chances are unsafeness isn't the problem you're most concerned with

Re: Zig, the Small Language

#270

Why should I use Zig coming from Rust? It doesn't seem that Zig actually solves the memory problems that Rust does.

Despite what students who never programmed professionally say, memory isn't a problem to a significant amount of C and C++ developers. I think it's been a year since I last access an invalid pointer and that only happened because I forgot that I am not suppose to add elements to array in a `for (auto var : array)` loop. It use to be a for index loop and it didn't take long to figure out the change broke something
Post reply on HN