Hacker News new | ask | show | jobs
by amelius 2242 days ago
The best C framework in that benchmark performs roughly equal to the best Go framework. So I don't think that garbage collector matters that much.
2 comments

That's a little disingenuous. h2o isn't really a framework as much as it is a server that can be extended as an application (Similar to CherryPy vs Flask/Django). There aren't really any good C web frameworks, and any web applications built in C are very likely to be bespoke code utilizing some HTTP library (libhttp, h2o, kore, etc).

Actix is a framework, built in Rust and non-GC'd, that performs significantly better than any of the Go frameworks. So GC does seem to have some effect.

That being said, I agree the GC is unlikely to be the problem for D's performance (in this case).

It's not all clear that a garbage collector isn't an advantage in actual workloads. Web apps tend to create a lot of short lived objects, and contrary to popular assumption malloc and free are not free.
The alternative of gc is not malloc and free. It's custom memory management, i.e. the code that decides when to execute malloc and when to execute free. Even a gc will ultimately call the equivalent of malloc or free. The difference is gc needs to do it generic enough that it works for all possible programs; whereas a programmer needs to do it in a way it works for this particular program.
Many GC languages like D offer the tooling to decide where to allocate as well, it is not GC for everything.

GC, untraced references, reference counting, stack and global memory segment allocations, OS system buffers.

The programmer also needs to do it in a way that works for a particular program instead of doing new everywhere.

The advantage being that having a GC around is much more productive for the workflows that don't need such hand tuning.