27 points · by awinter-py · 7y ago · 16 comments
1. Parse http request map them to language data structures.
2. Do some processing.
3. Convert data structures to json or HTML or blob as response.
Given this paradigm language stronger in text processing like lisp, perl, python, Ruby are easier and more productive. Rust and Go in my view are still not strong in this area, therefore might not be as strong in backend web programming.
But people have built very powerful web application in C++, Go, C and some even in Rust. So it is possible and I will be very happy that development of web application in Rust might develop powerful libraries for text precessing, which will make it more productive with memory safety.
So go ahead, if possible share your development experience.
I am still busy learning lisp, hope can find time to look into other languages.
But Go, Rust, Scala and the like blow those dynamic typed languages out of the water when it comes to APIs.
For example. If you want a number to be a positive integer you would write a Go struct containing a uint. That's all.
Want it to be optional Rust or Scala have an optional Type.
If someone submits a negative number or a float the framework automatically generates an error message.
In ruby for example you would have to write a bunch of validations per hand and a bunch of tests too, to check if those work.
Writing APIs in Go is like half the work compared to Ruby or god forbid PHP.
Have not tries Node yet but i assume it to be on a level with Ruby.
It took me a week of battling with the compiler to understand what I was doing, but afterwards it felt fairly natural.
My biggest hurdle was I went all in on async (the bikesheded, nightly feature). But a pet peeve of mine is that desktop apps were all async in the 90s and here we have webservers hoarding processes and threads, simply waiting on IO.
I quickly ran into the limits of Rust's async ecosystem. Hyper is an excellent library but there wasn't a webserver framework on top of it at the time. Now there is warp, so I intend to switch over to that from having rolled my own, but I hear some rumbling on reddit that it can lead to compiled size explosion, so gonna watch out for that.
For sql, I'm using mysql-async, but it seems like a single persons passion project. It's quite painful because even with the good libraries (serde) it feel broken to do so much hand writing of sql given the rich type information available in my structs. Everyone seems to use diesel but afaict it's incompatible with the async approach. This is my only real pain point right now.
The whole async ecosystem is still nightly and in flux all the time. Though, amazingly, it's worked quite well. It's clear the community has rallied behind it as most projects are on the bleeding edge. But hiccups happen such as mysql-async not yet supporting the new, nearly-stable version of futures.
Another pain point i've run into is there aren't great crypto libraries. Some very incomplete pure rust stuff. Some poorly documented wrappers of c stuff.
Finally, a third party web api I'm interfacing with doesn't have a rust library so I had to roll my own.
For other random needs I've been surprised by how often I find a great library. AWS libraries, for example, are surprisingly good.
My conclusion is that for web backends rust isn't plug-and-play yet (especially if you want to go all async). But it's pretty darn close.
And yeah, it's crazy fast. Like working in Modern C++ but with iron clad memory safety.
My wish list. Been noodling at making a Python port of JHipster, swapping in Rust parsers.
All libraries need to make async IO a priority.