Serving static files with a rust tcp server

Hello.

I am an experienced programmer, but happen to be new to Rust.

I think you are doing a great thing trying to get real clue how things work.

However, I would argue Rust itself is rather nasty to learn as your first language mostly due to the borrow checker. There are other languages out there which will give you enough space to learn without making you think about something like this. While it is hard to say which language would be the best overall, I would argue Go is a great first pick.

This being a Rust site I may get lambasted for the following, but here it goes: there is no denying docs are atrocious and following them will actively hinder your progress. For example you took code samples from Turning Our Single-Threaded Server into a Multithreaded Server - The Rust Programming Language or a resource derived from it. Multithreading as employed there is actively detrimental to performance and is not how things are done in real programs, at least on Unix systems (like Linux, where I presume you are trying to run this). More, you can have a high performance, scalable httpd server without threads (but with multiple processes instead).

All that said, whatever language you decide to stick with, I would suggest finding production quality libraries for what you are trying to do and consulting them when stumped.

Good luck.

1 Like