Live data from Hacker News

Open-source Zig book

zigbook.net

421–426 of 426 posts

Re: Open-source Zig book

#421
post #398

Earlier quoted context omitted.

I don't think it's the implementation that's delaying Zig's stabilisation, but the design. I'm also not sure comptime makes the implementation all that complicated. Lisp macros are more powerful than comptime (comptime is weaker by design) and they don't make Lisp implementation complicated.

Fair. I'm not a compiler developer, so I'll defer to your expertise on that front. That being said, I suppose my ultimate wonder is how small a Zig implementation could possibly be, if code size and implementation simplicity was the priority. In other words, could a hypothetical version of the Zig language have existed in the 80's or 90's, or was such a language simply out of reach of the computers of the time.

It's not quite as minimal as C, but it definitely could have been made in the 80s or 90s (actually, 70s, too) :) There were far larger, more complex languages back then, including low-level languages such as C++ and Ada, not to mention even bigger high-level languages. High-level languages were already more elaborate even in the 70s (comptime is no more tricky than macro or other meta-programming facilities used in Lisp in the sixties or Smalltalk in the 70s; it certainly doesn't come even remotely close to the sophistication of 1970s Prolog).

I don't think there's any programming language today that couldn't have been implemented in the 90s, unless the language relies on LLMs.

Re: Open-source Zig book

#422

Earlier quoted context omitted.

Has it changed how you program in other languages? Because that to me is the true mark of a thought-shifting language.

The big thing I would say I actually learned and would intentionally apply to other languages is SIMD programming. Otherwise, I'd say it gave me a much clearer mental model of memory management that helps me understand other languages much more fundamentally. Along with getting my hands directly on custom allocators for the first time, a question that took me time to figure out but gave me a lot of clarity in answeri…

Snap! I also played around with closures a tonne in Zig. Definitely possible but not... ergonomic. Haven't ended up using them much.

And agree with allocators; in C I always considered using custom allocators but never really needed to. Having them just available in the zig std means I actually use them. The testing allocator is particularly useful IMO.

Never used Go but if it's Zig-like I might give it a shot! Thanks!

Re: Open-source Zig book

#423

Earlier quoted context omitted.

The big thing I would say I actually learned and would intentionally apply to other languages is SIMD programming. Otherwise, I'd say it gave me a much clearer mental model of memory management that helps me understand other languages much more fundamentally. Along with getting my hands directly on custom allocators for the first time, a question that took me time to figure out but gave me a lot of clarity in answeri…

Snap! I also played around with closures a tonne in Zig. Definitely possible but not... ergonomic. Haven't ended up using them much. And agree with allocators; in C I always considered using custom allocators but never really needed to. Having them just available in the zig std means I actually use them. The testing allocator is particularly useful IMO. Never used Go but if it's Zig-like I might give it a shot! Thank…

I'll make a list of the things that both languages have in common that make them feel similar to me:

    - structs and functions are the main means of composition
    - the pattern of: allocate resource, immediately defer deallocating the resource
    - errors are values, handled very similarly (multiple return values vs error unions)
    - built in json  struct support
    - especially with the 0.16.0 Io changes in Zig, the concurrency story (std.Io.async[0] is equivalent to the go keyword[1], std.Io.Queue[2] is equivalent to channels[3], std.Io.select[4] is equivalent to the select keyword[5])
    - batteries included but not sprawling stdlib
    - git based dependencies
    - built in testing
[0] https://ziglang.org/documentation/master/std/#std.Io.async

[1] https://go.dev/tour/concurrency/1

[2] https://ziglang.org/documentation/master/std/#std.Io.Queue

[3] https://go.dev/tour/concurrency/2

[4] https://ziglang.org/documentation/master/std/#std.Io.select

[5] https://go.dev/tour/concurrency/5

Re: Open-source Zig book

#424

Earlier quoted context omitted.

Thanks for the research. The point is made, though: You can see how people think Zig is a protocol and Zigbee is a (certainly the primary) vendor. Whether that's true or not!

For sure but I don't think Andrew Kelley should've let a thing like that stop him from naming the language what he wanted when it isn't true. There's a lot of projects out there and only so many good, short, pronounceable names, so there's only so much accommodating you can do for name collisions with entities that don't exist.

Yeah, I agree.

Re: Open-source Zig book

#425

Earlier quoted context omitted.

>actual mind changing aspects of the BEAM What are those aspects? newb to this area.

A few key things: - Leaning on a pre-emptive scheduler to maintain order even in the presence of ridiculous amounts of threads ("processes" on the BEAM) running - Using supervision trees to specify how and when processes and their dependents should be restarted - Using `gen_server` processes as a standard template for how a thread should be running There's more to mine from using the BEAM, but I think the above are s…

Thanks.

Re: Open-source Zig book

#426

So many comments about the AI generation part. Why does it matter? If it’s good and accurate and helpful why do you care? That’s like saying you used a calculator to calculate your equations so I can’t trust you. I am just impressed by the quality and details and approach of it all. Nicely done (PS: I know nothing about systems programming and I have been writing code for 25 years)

If I wanted an AI book I would just prompt an LLM for it.
Post reply on HN