I built the same Web Server in 5 languages. Here's what I found…
Tags: node, rust, cpp, python
Published: 2023-05-16 16:26:55

I created the same File Share Server in Rust ( Actix Web ), C++ ( Crow ) , Python ( Django )  and Nodejs ( Express ). The results will probably surprise you. I should note that I come from a Nodejs ( Express ) environment and I am going to be biased to Express-like frameworks.

---


## The languages and frameworks
## 1. Rust ( Actix Web   )
Rust is a low-level all purposed language, it is blazingly fast with a TON of features, so many features actually that only ~10% of coders know rust.  I chose Actix Web for this although I could have chosen Rocket.rs or Warp but from what I read there is no big difference between all of them. Actix follows is inspired by the Expressjs API.
## 2. C++ ( Crow )
C++ a 45 year old low-level object-oriented programming language that lurks in almost every electronic device today yet only 22.55% of programmers know it. There weren't many options to choose from for building this project, in fact I had 2 options: Design a library myself or use Crow. I chose Crow however one tricky thing is that are 2 versions of crow the deprecated and the maintained one, be careful to install the maintained one. Crow is actually a micro web framework, it is just a single file you import. I also used the nlohmann json library for json encoding as it came with more features.
## 3. Python ( Django )
We all know the snake. My first language and probably yours, almost 50% of coders know python and it is known to be an easy-to-learn high-level and slow language. I could have used flask as an alternative but Django came first to my mind. Django offers more features than flask, technically flask is a micro web framework meaning lightweight.
## 4. JavaScript ( Express.js )
JavaScript is the language I am most comfortable with, it is like a kid of Java and Java is like the kid of C++ so JavaScript is technically a grandson of C++. JavaScript mostly powers the web and native application. It is a high-level object-oriented language with ~65% of coders of interviewed programmers knowing it and making it the most popular language as of 2022 and probably 2023. In my opinion it is so popular because it is the only language a website can understand and if you first learn to code the Frontend with Javascript odds are you will stick with it for the Backend also.

---

##The Results 
The darker color are additional lines that I thought to not count as used lines, why? For C++ the additional lines were because Crow didn't natively support "proper" file upload, so I created my own mini/micro library which is probably very slow and bad to handle the uploading. It mimics the express-fileupload library with similar functions. It is only a single 58-line header file called crow-fileupload.h . You can find the header file in the Github repo with all the other files of the servers at the end.
For python you need to do some configuration to allow static files etc. I estimated it wouldn't take more than 10 lines to add the proper config.
So the results go as following:
1. Python Django: 35 + 10 = 45 lines
2. Nodejs Express: 53 lines
3. Rust Actix Web: 89 lines
4. C++ Crow: 124 + 58 = 182 lines!
 
![LINES USED](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pnztuiuca0plkhcrgfun.png)

------


This is exciting, contradictory and logical… let me explain what I think this graph is all about. First of all Actix Web, Crow and Django perform the same so the average time range for express should have been between 40–50ms but that's not the case at all. One mistake people may make is that this graph represents how fast a language is, however, this graph represents how fast a framework is. Specifically at serving static files, not making any server side processing. Rust and C++ are faster than JS and especially Python but frameworks do not follow that pattern, they follow the pattern of popularity most times. If you need to do some crazy big computations or handle huge traffic then you may consider picking a faster language.
Here are the results:


![RESPONSE SPEED](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l4laepf1f74zc195prz7.png)

---

##My sources
Statistics source for most used/popular programming languages in 2022: [https://www.statista.com/statistics/793628/worldwide-developer-survey-most-used-languages/](https://www.statista.com/statistics/793628/worldwide-developer-survey-most-used-languages/) .
Github repo for this project: [https://github.com/yaKsirhC/5-lang-server/tree/master](https://github.com/yaKsirhC/5-lang-server/tree/master.)