Request for feedback on draft blog post: What Zig and TypeScript can Learn from Each Other

Great post!

Some minor clarifications:

I believe what you’re looking for is either std.SinglyLinkedList (for LIFO) or std.DoublyLinkedList (which used to be named TailQueue, and before that just LinkedList). EDIT: Or std.fifo.LinearFifo for FIFO, see this comment

There’s been quite a bit of discussion around the naming/implementation of these data structures, but it’s rather spread out. Here’s a few relevant links:

I’d instead say “pointer to an array of N items.” Might not seem like much of a difference, but since arrays are value types in Zig, it makes the difference between *[N]T (where N must be comptime known) and []T with a len of N a bit more clear.

Here’s a relevant thread: Are sentinels only intended for null terminators?

@kristoff gave the better explanation here, but an additional thing that’s slightly interesting to note is that the language itself is not aware of heap allocation at all–heap allocation (and therefore out-of-memory) is fully a “userland” concept, so there’s currently no way for the compiler to insert checks for out-of-memory conditions even if it wanted to.

(this somewhat ties into something I’ve written about before)

4 Likes