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

twitter logo github logo ・1 min read

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!

twitter logo DISCUSS (11)
markdown guide
 

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.

 

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

 

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?"

 

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

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

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

 

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.

 

How simple is it to build a web server from scratch as you would do with node without express?
I think it's essential to know what you can do with the language itself before moving to frameworks and other utility packages.
It's like moving from Ruby to Sinatra then Rails.
Or Node to express then I don't know maybe loopback.
Or Python - flask - Django.

 

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.

 

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!

 

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!

Classic DEV Post from Dec 31 '18

My 2019 Resolutions as a Developer

The goals I will accomplish in 2019, and some others I probably won't.

Bastian Gruber profile image
Exploring Rust for the web