Hacker News new | ask | show | jobs
by dorianniemiec 439 days ago
Go has larger ecosystem of libraries for building web servers. You have FrankenPHP for running PHP, Lego for automatic TLS, etc. For Rust there is `tokio-rustls-acme` crate (used by Ferron) for automatic TLS. While for PHP there is a `php` crate that depends on unsupported PHP version. Ferron uses FastCGI for communicating with PHP-FPM daemon instead. However, Go uses a garbage collector, unlike Rust, which has a borrow checker to ensure memory safety.
1 comments

Rust has garbage collection.
How? I rather think that it uses a borrow checker with ownership and borrowing rules.
no it doesn't
It absolute does. What do you think Arc/Rc are?
(Atomic) Reference Counted structs. They count their own references, there is no external mechanism tracking all of the reference counts at runtime. Modern rust does not include a garbage collector. You might be confusing a garbage collector with the general concept of memory management, which is a feature of (AFAIK) every high level language. Many C projects also have reference counted structs, but a reference count and a call to malloc/free doesn't quite qualify as garbage collection to most developers.
You might be confusing "garbage collector" and "garbage collection" and Rust definitely has the latter. Reference counting is also a subset of garbage collection. That is a matter of fact, not opinion. See below.

https://en.wikipedia.org/wiki/Garbage_collection_(computer_s...

I might be wrong, but I think you took offence to me suggesting you might be confused. If so, I'm sorry. I didn't mean it in a negative way, I was trying to soften my language but I phrased it badly.

Regardless, my point was that Rust _the language_ does not provide garbage collection. The Arc/Rc structs are where the reference counting is implemented. You can create reference counted objects in C, like GObjects in GLib. However, I think you would agree with most people that C does not have garbage collection. Otherwise the concept of a language having or not having garbage collection is diluted to the point of meaninglessness. At that point I think memory management is a more apt term.

By the name i'd say Arc is reference counting, which isn't exactly garbage collection...
Reference counting is quite literally a subset of garbage collection.
Garbage Collector acts mainly in unpredictable way. I mean it is possible it won't free memory even if counter is zero already. This is not true if we are talking about Rust.
Then malloc/free are quite literally a subset of the borrow checker :)