Zig for web backend services

I have some experience with Golang and have used it for web backend services.
As I can understand zig is suitable for system programming, there are libs in zig for developing web backend services. My question is how suitable is zig for web backend services and what are the obstacles one might face developing web backend services with zig.
Thanks in advance :slightly_smiling_face:

1 Like

The backend for https://logdk.goblgobl.com/ is built using Zig. I largely use it to dogfood my Zig libraries, and as a pet project whenever I have spare time.

There are fairly robust http server implementations (I wouldn’t use the one built into the standard library) and database drivers. The standard library’s argon2 implementation seems solid, and the JSON handling, while not the fastest, works well. If you need specific drivers for something, you should first check that there’s something maintained available - there are a lot of abandoned projects.

Probably the biggest gotcha right now is security/robustness. It’s probably best if you only expose a Zig-backend via a tested reverse proxy, like Nginx which can deal with TLS termination and misbehaving clients.

7 Likes

I am not sure that Zig will be suitable for web backend services at all.
For common use cases GC based languages like go,java,c# do the work better.

1 Like

Currently it is not suitable for the reasons mentioned by @karlseguin

They do not work better because of the garbage collection, they work better because they have an implementation for everything required by a web application.
For example go works better because there is an included web server and an awesome security library.

For handling web requests zig is much better suited, because ArenaAllocator not only acts as a garbage collector freeing web requests memory but it can allocate that memory once and reuse it for future requests (see: reset and retain_with_limit).

12 Likes

So from the discussion as I understand libs are not as matured as they are in case of Golang. In that case need to give some time so that libs get matured enough.

3 Likes