138 points · by jedisct1 · 3y ago · 64 comments
I would also be interested to hear the compile time, binary size and memory usage of those example apps.
Looks like the underlying facil.io library hasn't seen any commits since 2021, so that's a bit of a red flag. https://github.com/boazsegev/facil.io
The performance looks outstanding!
The biggest benefit isn't exactly performance, but the absurdly tiny binaries it produces (very convenient if you are working with small flash disks!), and how the Zig standard library doesn't depend on anything other than the kernel, which means you can often entirely ignore all library issues; more often than not our software 'just works' when built for some new customer platform even though I've never even targeted that environment (or even CPU architecture) before.
It’s very much a kitchen sink language.
If Rust or C++ are possible options, Zig probably isn't what you really want. Rust is especially good if you can keep everything in Rust and make the most of the ecosystem.
I like Zig, but it is a much smaller language that C++ or Rust with more than a few very, very sharp edges. That having been said, I reach for Zig in a lot more instances than I thought I would. I write a lot of relatively small programs that I want to work on Linux/Windows/macOS, and Zig is pretty good at that.
Of course, I miss Rust terribly every time I run a Zig program and get a segfault.
- Simplicity and readability
- Batteries included: projects don't have to depend on too many 3rd party dependencies
- Same code can be easily compiled to many different architectures
- Fast compile time
- Large ecosystem
With the exception of the large ecosystem, Zig offers a similar experience.
Well, given that in their benchmark Go ends up Boeing almost an order of magnitude raster than Rust, I wouldn't trust their benchmarking methodology too much.
Eg, are there C to Zig ports that have had a demonstrable performance or memory-safety gain or something like that?
(Specifically, I mean over a C-lib wrapper compiled using Zig, as matching this case.)
"The new self-hosted compiler reduces memory usage 3x compared to the old C++ implementation"
Given the current state of use-after-free and similar issues.
In your benchmarks, consider adding actix which is also in Rust but considerably faster than rust axum according to: https://www.techempower.com/benchmarks/#section=data-r21&tes...
Actix also used to be the poster child for overly focusing on benchmark performance at the expense of real world concerns.
In my personal project webserver I don't. I didn't measure, but just trying not to do unnecessary work.
Zag sounds like it's inefficient.
True
> No one will ever adopt a language called Ru...
I never made this claim.
my goal is to create a simple web framework that produces a single compiled executable, but I don't want to care too much about the HTTP(S) server portion, if possible. I have a functioning prototype, but the wrote-it-myself-and-it-shows HTTP server part sucks, so, hopefully I can find something to replace it with, instead of diving deep and writing something like this on my own.
Also, HTTP serving in Node uses code written in C, not JS.
That being said, Node is slow compared to Bun: https://bun.sh
* Some webservers "cheat" and skip a lot of request headers which one may want to use in a production scenario to get better numbers.
* Some web server architectures can do very well on many small uniformly sized requests but poorly on a mixture of request sizes.
* Some web server architectures can get very good average latency but poor p99 latency.
* Some benchmarking tools don't measure correctly: https://medium.com/@siddontang/the-coordinated-omission-prob...
etc.