News for hackers. Stuff that matters.
Re:Show HN: Molecule – Streaming, zero-allocation protobuf d... by ignoramous on Sunday March 29, 2020 @04:15PM (#22722290)
I've come across a fair share of zero-alloc implementations of various things, like u/poitrus' zerolog [0] and u/jorangreef's cuckoo-hashtable [1], for instance.

Given that JavaScript runs on restrictive clients, it must have libraries in spades for this kind of a thing, but I couldn't find many. I'm really interested in techniques that are generally employed in languages like Java, Golang, Rust, C/++ that are worth translating over to JavaScript, especially now that TypedArrays are a reality. I'm pretty sure there's more to zero-alloc than just Buffers, Object pools, and Recyclables, but I can't seem to find good resources to get started with this.

[0] https://github.com/rs/zerolog

[1] https://github.com/ronomon/hash-table/blob/master/README.md

Re:Show HN: Molecule – Streaming, zero-allocation protobuf d... by kitd on Sunday March 29, 2020 @05:38PM (#22722995)
Giving different views and projections on underlying memory is really the key tactic to processing data without allocations. A slice (ie a view onto an array) is a pointer to underlying memory (or another slice), along with the length (+ capacity in Go, but that's not often needed). Underneath the bytes don't move. You simply pass around the views (or views of views) of what you want your code to actually see.

Don't know about Rust, but Go has slices built into the language, and C++ has it in the standard library. Learning idiomatic slice-handling makes working with data sans allocation much, much easier.

Re:Show HN: Molecule – Streaming, zero-allocation protobuf d... by monocasa on Sunday March 29, 2020 @06:13PM (#22723251)
> Don't know about Rust, but Go has slices built into the language, and C++ has it in the standard library.

Rust also is very big into slices as well.