New to this platform. Appologies if it's not the right place to ask this question.
Is it a good option use Rust in web development. Anyone has ever used it? Any experiences in it? Also if someone has any better option please suggest.
Please do make some very basic research before asking. See eg. https://www.arewewebyet.org for a (pessimistic) overview of the various aspects of web development in Rust.
I would recommend Rust for web-related things if:
- your problem requires either a lot of CPU or a lot of memory,
- and/or you must make sure it's implemented correctly.
If you're creating something like a blog/cms, then you have lots of other languages to choose from with more mature frameworks, that will be more convenient to use and likely fast enough and robust enough.
If you're processing a lot of data, e.g. generating images, or providing a path-finding back-end for a map, collecting and analyzing in real time large volumes of data, then Rust's speed and efficiency will be worth it.
Rust's strict type system and error handling also help ensuring programs are correct and won't fail because "undefined is not a function", so Rust may also be helpful if you're implementing something mission-critical or financial systems.
One more thing to note is Rust has just recently released a major upgrade (
await syntax) which makes web programming easier, but not all libraries support it yet. For the next few months expect to see a mix of old and new libraries and things in beta/alpha stage until the dust settles.
For all the people who are using for planning to use Rust for the web development, WASM or not, may i ask a simple question why you this decision to go with Rust over something other. Lets assume you want static or compiled language lets take example of Python. But i'll ask one thing why are you not interested in using any scripted language.
Rust provides more set of tools as well as the abstractions that makes it even more expressive as compared to GO, It also leads to higher results and the improved performance.
Also, it is quite awkward to say but Rust as a langugage is compared to be more safe and fast . Considering other in web development apart form Rust they can be in front end such as angular, react, jquery, bootstrap etc. And in back end development there can be Node Js, python, css3 etc.
Scripting languages cause global warming.
I have a bunch of projects that at the same time are cpu-bound, load large datasets and need to be reliable. Those requirements rule out scripting languages. Some of them were initially written in Python, and hit serious performance problems because of that.
With Rust I have full control over how memory is used, I can fully utilize hardware, generated code is as fast as it can be, and I don't have to fight with the language, ecosystem or tooling to achieve that.
Other options would be either Go or Java, of those I found Go to be sloppy and poorly designed, and I do not work in Java shop, so bringing all of its complexity is not desired, not to mention that its poor fit for cli apps and docker containers, both of which I am using heavily.
Rust certainly requires a lot more time to go from nothing to a proof of concept, compensating this 10 times however by cutting time from there to production and beyond.
My reply re: global warming was rather flippant. Simply a hint at the massive inefficiency of scripting language. When multiplied by the millions of instances running in cloud servers and data centers around the world that extra energy consumption adds up. Even on a more personal scale using an efficient software system can mean managing with small, cheaper server instances.
But let me describe why we are using Rust as much as possible in our current project whereas previously we would have used node.js. which has proven to be the best compromise between performance and ease of development for us in recent years.
Performance: Requirements call for handling many streams of real-time data from sensors, at a rate of 20 messages per second (10kB/s) each. Those messages need decoding, filtering and other processing done on the fly. On the user side we need to deliver data via web sockets at a similar rate. We never expect to scale to millions and billions of sensors and users, but everything is cost sensitive, smaller server instances are cheaper.
Correctness, reliability, shall we say "confidence". In a former life I was much involved in military and avionic systems where being sure your code works is a prime requirement. Our system does not have such strict reliability/correctness requirements but that experience left me with nagging doubts when it comes to using sloppy, dynamically typed languages. Especially as that encourages throwing together code rapidly which likely does not get thoroughly tested. (Do people actually do code coverage analysis on their JS, Ruby, Python projects?)
Of course there are a ton of less technical reasons for my interest in Rust. The documentation is very good. The community is active and very helpful. Rust is born out of Mozilla which I find far more appealing than if it had came from MS, Oracle or the like, Of course the fact that folks at MS appear to be looking into Rust gives me hope for it's long term viability.
Having said all that, I don't count myself as a "web developer" as such. I do software, from the remote embedded systems, through the servers, thought to the browser. Now a days the kids call that "IoT". I try to avoid anything to do with HTML/CSS and all that wobbly mess.
Following that you saying we can call rust a green planet language
I would add to this that in techempower benchmarks for web frameworks Rust takes 1st place in performance in 5 categories out of 6, and in the json processing it is on 3rd place by a tiny gap after C++ ulib.
Of course it is not that important when building tiny app, possibly with just a few services. Though when building application which will span to hundreds of microservices, every service in the request chain will add it's cost, you will easily get 100ms-1000ms delay on a single web request with scripting languages. In my previous place when profiling python app we found its spending 99% of cpu time just creating and wiping python objects, for a simple web to database requests.
One more benefit you would get is with WASM you still can reuse Rust code in a frontend app Angular, React or Vue, and it even plays nicely with webpack, parcel and roll-up via WASM plugins.
That reminds me that I forgot to mention code reuse.
A CPU intensive and sensor specific part of the processing chain I mentioned above is decoding the binary "blobs" that are the messages that come out of our sensors. The a lot of fiddling with bits and bytes in there that is not nice to do and performs badly in a JS or Python etc. Currently we do that decoding in the cloud servers, mostly because it was simple to put in place and easier to fiddle with. Ultimately that decoding will move down to the remote devices themselves. After all it is wasting server cycles and is sensor specific. That is very easy to do in Rust.
Previously we did that decoding in C++. It's simpler and nicer to have everything in the same language though.