Failing to Learn Zig via Advent of Code

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

CodeRabbit: AI Code Reviews for Developers
Revolutionize your code reviews with AI. CodeRabbit offers PR summaries, code walkthroughs, 1-click suggestions, and AST-based analysis. Boost productivity and code quality across all major languages with each PR.
coderabbit.ai
featured
InfluxDB high-performance time series database
Collect, organize, and act on massive volumes of high-resolution data to power real-time intelligent systems.
influxdata.com
featured
  1. zig

    General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.

    My big problem with Zig is that Andrew Kelley is promising a lot of features, but doesn't really deliver much. Zig still can't proper handle UTF-8 strings [1] in 2022, which is kind of unfortunate, because it's a `requirement`. In a `recent` interview[2], he claims that Zig is faster than C and Rust, but he refers to extremely short benchmarking that has almost no value in the real world.

    At least Rust, as blamed and loved as it is, delivered a stable compiler and people started working on the ecosystem (in the first years, most packages were working only on nightly, but at least there were crates available). The ecosystem for zig is insignificant now and a stable release would help the language.

    [1] https://github.com/ziglang/zig/issues/234

  2. CodeRabbit

    CodeRabbit: AI Code Reviews for Developers. Revolutionize your code reviews with AI. CodeRabbit offers PR summaries, code walkthroughs, 1-click suggestions, and AST-based analysis. Boost productivity and code quality across all major languages with each PR.

    CodeRabbit logo
  3. The-Quick-Snippet-Reference

    Let's build the quickest snippet reference for every programming language, free to use and modify.

    I recently started learning Rust by adding snippets to The Quick Snippet Reference [0]. Without any previous knowledge of the language I knew there had to exist a data type for dynamic arrays. After several Stack Overflow searches I found it: Vec. It was very interesting to compare to Python's Array. Getting to understand the drain() method was a refreshing experience. I'm still hesitating about the best way to handle errors (Rust has no exceptions, just panic!), but that will probably become clearer when working with threads.

    [0]: https://github.com/snippetfinder/The-Quick-Snippet-Reference

  4. ziglyph

    Unicode text processing for the Zig programming language.

    > My big problem with Zig is that Andrew Kelley is promising a lot of features, but doesn't really deliver much.

    Have you, like, seen the release notes for 0.9.0?

    https://ziglang.org/download/0.9.0/release-notes.html

    > Zig still can't proper handle UTF-8 strings [1] in 2022

    There's plenty of discussion on the subject in basically every HN thread about Zig: the stdlib has some utf8 and wtf validation code, ziglyph implements the full unicode spec.

    https://github.com/jecolon/ziglyph

    You might not like how it's done, but its factually incorrect to state that Zig can't handle unicode.

    > In a `recent` interview[2], he claims that Zig is faster than C and Rust, but he refers to extremely short benchmarking that has almost no value in the real world.

    From my reddit reply to this same topic:

    This podcast interview might not be the best showcase of the practical implications of Zig's take on safety and performance. If you want something with more meat, I highly recommend Andrew's recent talk from Handmade Seattle, where he shows the work being done on the Zig self-hosted compiler.

    https://media.handmade-seattle.com/practical-data-oriented-d...

    Lots of bit fiddling that can't be fully proven safe statically, but then you get a compiler capable of compiling Zig code stupidly fast, and that's even without factoring in incremental compilation with in-place binary patching, with which we're aiming for sub-millisecond rebuilds of arbitrarily large projects.

    > The ecosystem for zig is insignificant now and a stable release would help the language.

    I hope you don't mind if we don't take this advice, given the overall tone of your post.

  5. reason

    Simple, fast & type safe code that leverages the JavaScript & OCaml ecosystems

    OCaml is pretty close already to what you're describing. The OCaml ecosystem fully embraces imperative programming. And if the syntax of OCaml is problematic, then perhaps ReasonML (https://reasonml.github.io/) is what you're looking for: a curly-braces syntax for OCaml.

  6. zig-string

    A String Library made for Zig

    Why does something as basic as uppercasing a string or decoding latin1 require a third-party library? I would expect that to be part of stdlib in any language. Also, why does that third-party library come with its own string implementation? What if my dependency X uses zigstr but dependency Y prefers zig-string <https://github.com/JakubSzark/zig-string>? Basically all languages designed in the past 30 years have at least basic and correct-for-BMP Unicode support built-in/as part of stdlib. Why doesn’t Zig?

  7. cmu-infix

    Updated infix.cl of the CMU AI repository, originally written by Mark Kantrowitz

    The Lisp version can also be more readable with a macro (like https://github.com/quil-lang/cmu-infix): #I(a(1.0-t) + bt). Or something else that would let you write GP's preferred syntax. One of the things that makes Lisp Lisp is that if the parens are over-cumbersome, you have the tools to take them away. See also CL:LOOP.

  8. ffmalloc

    That's not a C flaw, you can use an allocator that prevents use-after-free.

    https://github.com/bwickman97/ffmalloc

    The point of C and Zig is that they are low level and you can do whatever, like not use an allocator, or write an allocator.

  9. InfluxDB

    InfluxDB high-performance time series database. Collect, organize, and act on massive volumes of high-resolution data to power real-time intelligent systems.

    InfluxDB logo
  10. tigerbeetle

    Discontinued A distributed financial accounting database designed for mission critical safety and performance. [Moved to: https://github.com/tigerbeetledb/tigerbeetle] (by coilhq)

    > Checked arithmetic is a much bigger performance hit than most people expect.

    You're right about the branching cost. I believe there's a better way to solve that though then simply disabling checked arithmetic everywhere.

    I am the tech lead for TigerBeetle [1], a new distributed database that can process a million financial transactions per second.

    We differentiate between the control plane (where we want crystal clear control flow and literally thousands of assertions, see NASA's "The Power of 10: Rules for Developing Safety-Critical Code") and the data plane (where the loops are hot).

    There are few places where we wouldn't want checked arithmetic in TigerBeetle enabled by default. But where the branch mispredict cost relative to the data is too high, Zig enables us to mark the block scope as ReleaseFast to disable checked arithmetic.

    [1] https://www.tigerbeetle.com

  11. swift

    The Swift Programming Language

  12. chapel

    a Productive Parallel Programming Language

  13. zls

    A Zig language server supporting Zig developers with features like autocomplete and goto definition

    > Building is slow. It takes about ~3 seconds minimum which is frustratingly slow when I'm fighting basic syntax errors. I wish there was a fast zig check.

    > Lack of zig-analyzer makes learning hard.

    > zig fmt src/main.zig is nice. Wish it automatically ran on all files.

    I also did (well, "am doing", can only work a bit each day and am plugging through day 7 right now) AdventOfCode in Zig this year.

    These points here didn't resonate with me at all. I wonder if the author knew about or tried ZLS[0]. I had it on and integrated with my VSCode and it would check a lot of things as I went and format on save. I think I followed something like this[1] to set it up.

    [0] https://github.com/zigtools/zls

  14. v-mode

    🌻 An Emacs major mode for the V programming language.

    I did improve my Go skills solving all problems in Go, learning many things the hard way, but at end my solutions were way longer and so much less ergonomic than the NumPy & Python-based I saw by the top 100 guys! I mean, come on, Go doesn't even have built-in min(), max(), abs(), and other basics (for ints)! Some of the top developers had their solutions done in a shorter time that I needed to read the overly convoluted and confusing problems. I just didn't appreciate the infantile, and wasteful pseudo-comical style of problem definitions! I've attended any programming contest back in Bulgaria and I can't recall anything that required me to read everything carefully 2-3 times before I get what needs to be done (oh, well, I wasn't 48 back then). I also got fascinated by GitHub Copilot, which actually autocompleted many of those missing basics and surprisingly "guessed" what I was trying to accomplished and offer meaningful productivity boost. I also looked into Zig, but, honestly, I didn't like many of the syntax choices made. Instead, I installed V [0], and will actually try to use it as it fits me better.

    [0]: https://vlang.io/

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts

  • Ask HN: Possible? Faster than C, simpler than Python, safer than Rust

    5 projects | news.ycombinator.com | 3 Mar 2023
  • Shopify Embraces Rust for Systems Programming

    5 projects | /r/ruby | 14 Dec 2022
  • Why the use of semicolons?

    4 projects | /r/Zig | 8 Jul 2022
  • why you bully me

    3 projects | /r/ProgrammerHumor | 12 Apr 2022
  • Hot-code reloading Native macOS/arm64 apps with Zig

    4 projects | news.ycombinator.com | 17 Mar 2022

Did you know that Zig is
the 22nd most popular programming language
based on number of references?