Live data from Hacker News

Zig by Example

github.com

101–109 of 109 posts

Re: Zig by Example

#101
post #72

Earlier quoted context omitted.

Here is where I think Zig shines. When you are a high level programmer that needs to drop down to a low level programming language for performance reasons. The issue with doing that as a high level programmer is that you don't do a lot of low level work frequently. So unless you work in another domain where you do a lot of low level programming, then every time you drop down you will be out of practice. This favors u…

Looking at it from an existing knowledge base and error checking point of view, I feel like C++ smart pointers or Rust is a better option for someone doing a dangerous low level thing rarely. I'm not sure Zig is really all that favorable a choice in your given scenario.

Rust unsafe is less safe than writing C code. Rust is not good language for writing "unsafe code". C++ smart pointers are really bad compared to arena allocators, and not allocating at all. It's very easy to end up with dangling references in C++, or double frees with smart pointers. Also the fact that C++ initialization itself is a huge foot gun.

Re: Zig by Example

#102
post #13

Earlier quoted context omitted.

It might not be the version you have installed, or the same version as another project you want to glue together into a single application.

wow. this is a major miss from Zig. on top of the decision to ban AI, I can see that we haven't seen the last of bad decisions from Zig

It is still in active development and before v1. They haven't decided to make it unstable on purpose it's simply not done yet.

Anyone using it right now implicitly accepts that they'll have to keep track of the changes in the language and update their code accordingly.

Re: Zig by Example

#103

Earlier quoted context omitted.

wow. this is a major miss from Zig. on top of the decision to ban AI, I can see that we haven't seen the last of bad decisions from Zig

It is still in active development and before v1. They haven't decided to make it unstable on purpose it's simply not done yet. Anyone using it right now implicitly accepts that they'll have to keep track of the changes in the language and update their code accordingly.

The language is almost 10 years old and they are not planning a v1.0 anytime soon afaik.

Re: Zig by Example

#104
post #21

Is Zig just a trend, or will it become a solidly established language? After all, learning something is an investment of time. With Zig, it doesn't seem to have the same kind of industry pressure as Rust. There's talk in open source circles about AI-related issues, and on Hacker News people say good things about Zig. The allocator concept looks great. But there's also a possibility that it won't become mainstream, li…

Is there a particular domain you'd like to get into? It sounds like you're wanting to build expertise in something other than CRUD app assembly, but my language recommendations might change based on whether that's embedded, game development, distributed systems, system administration, etc. I don't think in your shoes I'd prioritize learning Zig for any of these domains, though, for a few reasons: * It's not a pre-req…

If you were to recommend for game development, I'm guessing it would be strictly C++ and/or C?

Re: Zig by Example

#105
post #50

This is outdated and AI generated. If you want a good source of zig learning material interactive and by examples please check out ziglings: https://codeberg.org/ziglings It's writen and tested by humans, which is essential for learning purposes. It's listed in the official zig website, by the way. This project is always up to date to the latest zig release.

I think this is a major problem with Zig in that they've cornered themselves into not utilizing AI and have attracted anti-AI absolutist crowd that is going to be a major hinderance. As a Rust user, AI has put Rust easily in the hands of developers who were previously intimidated by it. I've learned a ton about Rust simply by fiddling with LLMs and asking questions to other Rust devs who don't really care whether AI…

This is not true in any meaningful way. The most widely-used zig project (Ghostty) is very welcoming of AI contributions, and the lead developer of the project uses it heavily.

Re: Zig by Example

#106

Earlier quoted context omitted.

It is still in active development and before v1. They haven't decided to make it unstable on purpose it's simply not done yet. Anyone using it right now implicitly accepts that they'll have to keep track of the changes in the language and update their code accordingly.

The language is almost 10 years old and they are not planning a v1.0 anytime soon afaik.

Depending on how you look at it, Rust went like 9 years from inception to v1 (2006-2015). C went ~17 years before initial standardization (1972-1989).

Re: Zig by Example

#107

Earlier quoted context omitted.

I think if you need to get so close to the bare metal that you'd need unsafe Rust then the equivalent Zig is also too dangerous to use "infrequently". Stuff like writing raw assembly, pointer twiddling, volatile stores or fetches - I would hire somebody with lots more experience to do that properly once if you need it. On the other hand if safe Rust is an option that's way more handholding than you're getting in Zig.…

For clarity in this dual programming language scenario I'm talking about, I'm writing a user facing app that's mostly a lot of business logic. It's running slow so I profile it and I see my math function in pure Dart (or whatever language you are writing in) is the hot spot, and pressures the garbage collector too much, so I rewrite the function in a lower level language that doesn't have as much overhead, to speed t…

For this example the safe Rust seems like exactly the right choice to me but that's just me.

Re: Zig by Example

#108

Earlier quoted context omitted.

Is there a particular domain you'd like to get into? It sounds like you're wanting to build expertise in something other than CRUD app assembly, but my language recommendations might change based on whether that's embedded, game development, distributed systems, system administration, etc. I don't think in your shoes I'd prioritize learning Zig for any of these domains, though, for a few reasons: * It's not a pre-req…

If you were to recommend for game development, I'm guessing it would be strictly C++ and/or C?

Hmm. I don't do game development myself, so take this with a healthy dose of salt. But...not necessarily. I think game development might be one of the more varied of the domains I mentioned. If you want to actually focus on the game, rather than learn about engine development, you might want to start with the choice of engine (e.g. Godot or Unity) and learn a language they recommend for integration (e.g. C#) rather than the language the engine itself is written in, as the code you write won't necessarily be as resource-intensive as the engine code itself. Though you certainly could start by picking e.g. Rust and then looking at popular engine/framework options there (e.g. Bevy or Macroquad). It might also vary a lot based on the type of game you're interested in.
Post reply on HN