3 ms·
So, when writing a high-performance, scalable web-server, which language should I pick: Go, C++, Rust, Scala, other?
by amelius 12y ago
So, when writing a high-performance, scalable web-server, which language should I pick: Go, C++, Rust, Scala, other?
- rjammala 12y agoGo is the easiest.
- Zikes 12y agoI'm a Go fan, but ease is a very subjective measure.
- jonnybgood 12y agoClojure should also be a consideration.
- anom9999 12y agoWhichever you're most competent in. Any of those languages (and many others) would be a suitable option, so it boils down to what you are most proficient in.
- lomnakkus 12y agoI would amend that. Start with whichever you're fastest (not necessarily most competent) in. Once you discover whether the whole thing is worth the effort, move towards safe languages. That's basically Rust, Scala, or (functional-language-of-your-choice-or-) Haskell. EDIT: Personally, I would start in something like Haskell or Scala just to do a proof-of-concept without having to worry too much about undefined behavior (C/C++) or absurd verbosity (Java), but then I am pretty familiar with those two languages. Maybe it would be worth learning one or two very terse languages to start with, just in case you hit upon a great idea? (Btw, I think Python or Perl qualifies.) EDIT#2: As a sort of second or third order bit of advice, I'd encourage anyone to brush up on programming languages that might make you faster. It's a sort of "propellant" and can increase your speed exponentially.
- npalli 12y agoYou would pick Java
- detrino 12y agoGo will never match (in performance) C or C++ (using epoll) for this task.
- staunch 12y agoYou're right, but it's got nothing to do with not using epoll. Still, Go is far faster than what most people use on the web. https://www.techempower.com/benchmarks/ https://www.techempower.com/benchmarks/
- cyber1 12y agoThe same test but on i7 https://www.techempower.com/benchmarks/#section=data-r9&hw=i7&test=json https://www.techempower.com/benchmarks/#section=data-r9&hw=i... - Go winner!
- cyber1 12y agoIf you choose Go, you get simple scalable language with safe memory, superior standard library and performance close to C. Performance: Go vs Python - http://benchmarksgame.alioth.debian.org/u64q/compare.php?lang=go&lang2=python3 http://benchmarksgame.alioth.debian.org/u64q/compare.php?lan... Go vs C++ - http://benchmarksgame.alioth.debian.org/u64q/compare.php?lang=go&lang2=gpp http://benchmarksgame.alioth.debian.org/u64q/compare.php?lan...
- IshKebab 12y agoRust isn't ready yet so I wouldn't pick that. Scala I'm not familiar with. C++ is great. Very fast and powerful, and really not as complicated or difficult as people make out. The manual memory management thing isn't really an issue if you do it right. However writing multithreaded C++ code is never fun. Go is very simple and easy. I think of it like Simple English. It's very easy to write, and everyone will understand what you are saying, but you'll end up being way more verbose and often a bit more clunky than you might be in a more powerful language like C++. Huge limitations are that there is no overloading at all. I.e. you have to implement `minFloat64(a, b float64)`, `minFloat32(a, b float32)`, `minInt(a, b int)` and so on, whereas in C++ function overloading means it is just `min()`, and templates mean you only need to write it ones. The other big issue is lack of templates (AKA generics), so containers (list, map, etc.) are a pain in the arse to use. However Go does have great concurrency support, and is close enough in speed to C++ that I'd probably always choose it to write servers in. So I'd say Go, maybe C++. In a year reconsider Rust.
- tomohawk 12y agoHaving done web servers in Java, C++, Ruby, and Python, I was pleasantly surprised by the capabilities offered by Go. In these other languages, the first thing you do is usually figure out a framework to use, which usually comes with its opinionated way of doing things. Often, the framework is really there to paper over issues with the language or the available standard libraries. In go, the std library offers very good support, and if you need more, there are things such as gorilla (a web toolkit that enhances the std lib). There are also frameworks, of course, but many people find there is much less of a need for that. The goroutine support is really great, and servicing concurrent client requests with them is effortless.
- eonil 12y agoI believe you're going to learn a new language for future problems, and I strongly recommend Rust. If your performance (throughput and latency) requirement is not very critical, language really doesn't matter. Even scripting languages like Python, Javascript or Ruby performs very well by spawning servers on each cores. But if your performance requirements goes serious, I believe you will get unusual bottleneck (e.g. GC, VM, memory usage pattern, specific hardware,... ), then you'll want a kind of "full-control". In this case, the only traditional choice was C/C++, and that's why many large-scale companies like Google and Facebook are using C++ internally. Anyway C/C++ cannot provide enough level of safety that required to provide good productivity. As a workaround, you can use a sort of dynamic checkers (sanitisers), but the dynamic checkers are very immature, and fundamentally dynamic. A new, and the only current alternative for this case is Rust. Rust provides far batter safety from first at "compile time". It also provides far better linguistic constructs and semantics. But the language itself is immature. Anyway, (1) there is huge demand for this kind of features from C++ community and (2) Rust is completely engineer community driven (3) and fully open-sourced. So I expect the maturing speed of the language will be incredible that never been existed in language history. And it's fully open sourced.