DEV Community

What are your biggest obstacles/questions for moving from NodeJS to Rust?

Bastian Gruber on March 23, 2019

NodeJS is the perfect entry for building web applications. I am getting many messages lately that people want to give Rust a try and implement their first web service in it. I would love to hear from the dev.to community what your biggest hurdles are or which questions need to be answered before you feel comfortable jumping in!

Collapse
 
yann_yinn profile image
Yann • Edited

When i gave it a try ( github.com/yann-yinn/rust_graphql_... ), the first question was "which webserver to use", and Rocket was the one that was the easier to grasp. But for now Rocket works only with unstable Rust, which is a little bit scary ^^' ... And once you tasted Rocket, it is hard to use another one, so i was mainly waiting for Rocket to work with Stable Rust

Collapse
 
softprops profile image
Doug Tangren

You might find that's the wrong starter question to be asking as times change. Keeping serverless approaches to graphql applications in mind, you may want to first consider asking "do I even need a webserver?"

Once you have a firm belief you actually do need a server then ask the question "which one?"

Collapse
 
yann_yinn profile image
Yann • Edited

What serverless solution would you advise to create a GraphQL API with Rust ?

Thread Thread
 
softprops profile image
Doug Tangren

I might take a look at aws.amazon.com/appsync/ which allows you to bind resolvers directly to your data sources or if needed a lambda. If you are coming from nodejs, you might be familiar with serverless framework. There is a serverless plugin that makes it possible to deploy lambdas written in rust - github.com/softprops/serverless-rust

Thread Thread
 
yann_yinn profile image
Yann

Fun stuff, will sure take a look at the rust plugin. Did you tried it yourself ?

Thread Thread
 
softprops profile image
Doug Tangren

I maintain it :)

Collapse
 
gklijs profile image
Gerard Klijs

Some things are waiting to get async to stable before getting there. I would use something that is not stable for a customer.
I have a GraphQL endpoint I would like to do in Rust, but subscriptions are still not supported in juniper.

Collapse
 
rosswilliams profile image
rosswilliams

Async await delay in getting an implementation out is having a negative effect on the crate ecosystem. Some are waiting for it to stabalixe while others are requiring nightly rust. The split reminds me of the OCaml Lwt vs. async split in slowing down the ecosystem and doing real damage.

Node is fast enough. Typescript is good enough, sharing typescript definitions across the stack is a big win I would need to give up. Memory savings aren’t often needed, it’s the Java and database apps taking 90% of RAM.

What is the real gain of rust? How much safer is it than typescript in a way I’ll notice in a line of business server app. If you were comparing to Ruby there might be a better case.

Collapse
 
gndplayground profile image
Giang Nguyen

I tried Rust but for now, I could say that moving all from Node to Rust is not a good thing.

Libraries document in Rust is very bad. Yeah, we have a tool to auto-generate document in Rust but many libraries expect the user is a genius hacker. I gave you API document with the minimal tutorial so I expected you can understand how to use it. Even Tokio has a separate document from API document but it's incredibly hard for beginners to understand.

Yeah JS doesn't have a standard tool to do that, I know. So they have to force to write a document from scratch, and it's might be the good thing for end user.

I want simple Promise example like Nodejs, But hey you can't do that easily.
Welcome to the bottom of hell with Tokio, Mio...
Did I hear async await?

Look at Go, and see how popular it is. In my country, a lot of company is hiring Go developers now. Mozzila is not pushed and promo the language enough. Compare to Google, Google has infinite money. If you want a stable career as a web developer then learn Go is easier.

I love Rust for trying to compete with C++. And looking forward to re-learning it again. But as a web developer, I think rust is not a good choice to do web things for now.

Collapse
 
gypsydave5 profile image
David Wickes

I think the reason I wouldn't write a webapp in Rust is the same reason I wouldn't write it in C or C++: the problems I'd be solving don't feel like a good fit for the language.

Don't get me wrong, I like Rust. But the idea of thinking about types of int, the borrow checker, and such forth, when in all likelihood I'll be writing an HTML template from a database, seems like an unnecessary overhead.

But you could convince me otherwise!

Collapse
 
gruberb profile image
Bastian Gruber

That's a fair point!

I would argue two things:

  • You won't face many of Rust features when handling simple tasks, yet you get all the benefits of safety and speed
  • To learn Rust to serve templates might be an overkill (maybe not)

However, omce you build your first few apps with Rust, you will see:

  • You grew as a developer
  • You don't face and you don't have to compeltely understand everything for the most part

It's a good feedback I think most people face, so I will get into that in more detail in the future!

Collapse
 
mfachri profile image
Fachri

Im new to rust too. But so far, moving from node (in this case express) to rust (Im using rocket) is quite challenge for me. Its good with its restriction in comparisson with the so-dynamic type in pure js (not ts).

But yes, if rocket can accomodate all packages that we could have from npm, it will be so nice in the future :)

Im quite sure moving to rust will a be a great advantage for the performance wise. Cmiiw, this is what i have if googling about performance comparisson to js framework.