Rust is a hard way to make a web API

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

Our great sponsors
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • SaaSHub - Software Alternatives and Reviews
  • jelly

    Discontinued User authentication/sessions/etc for Actix-Web. More of a sample project than a crate, but probably useful to some people. (by ryanmcgrath)

  • I've actually "ported" Django's auth system (including their email verification pieces) to actix-web, and reused it across a few projects. I've thought about open sourcing it, but the problem is... well, then you have to maintain it, and I'm not really interested in doing that.

    But if someone wants to take up the project I don't mind donating the code.

    If anyone ever saw my version years ago[1], it's effectively Jelly 2.0.

    [1] https://github.com/ryanmcgrath/jelly

  • cargo-watch

    Watches over your Cargo project's source.

  • A few points:

    > Once your code is compiled, everything’s amazing! But in my case, this basic API - which wasn’t even feature-complete and was by no means a complex system - took more than ten minutes to compile...Caching helps as long as you don’t have to rebuild cached dependencies.

    The author glossed over that last part, but at least from a workflow perspective, it makes a huge difference. In my experiments writing a web server in Rust, I used cargo-watch (https://github.com/passcod/cargo-watch) to automatically rebuild each time I made a change. The turnaround time was usually 1-2 seconds - nearly as fast as restarting a Node server, and about the same amount of time it takes me to alt-tab and test the change. I was using Serde, a high-level HTTP framework, and several other crates. It didn't matter, because they never had to be rebuilt.

    > Rust makes you think about dimensions of your code that matter tremendously for systems programming...It makes you think about real but unlikely corner cases and make sure that they’re handled...These are all valid concerns. But for most web applications, they’re not the most important concerns.

    I disagree strongly (at least about corner cases). Maybe you don't want to bother with this stuff when you're still in the prototyping phase, but once a service is fairly well established, it's definitely beneficial to be forced to think about corner-cases (both in libraries/IO, and in your own business logic that you've hopefully modeled with Rust's powerful type system). This IMO is one of Rust's main benefits; it's been called "the practical Haskell" before, and while its ecosystem isn't yet the most practical one for web servers, it is much more so than Haskell's.

    > The Rust ecosystem is not web-centric

    This is the strongest point, in my opinion. Rust's web ecosystem is definitely still in the early days, and this is partly because Rust's benefits aren't nearly as extreme in this usecase as they are in other usecases. There is for sure a chicken-and-egg problem as not enough companies are using Rust for web servers, which means not as much time is getting invested in the relevant libraries. I hope this changes; I don't know for sure that it will. It feels like it is, but very slowly. That said:

    > Unfortunately, a lot of the incredibly exciting work in the Rust ecosystem has nothing to do with web application servers. There are some promising web frameworks - even a somewhat higher-level framework - but they’re undoubtedly in a niche. Even Actix, the main web framework, has a very top-heavy set of contributors.

    The author failed to mention or wasn't aware of Rocket (https://rocket.rs/), an up-and-coming Rust web framework that's extremely exciting and provides a programming model that's strikingly similar to Flask or Express. It's still in 0.X releases, the current release doesn't build on stable rustc (though the master branch does!), you're still going to have a hard time finding SDKs for auth and payment and cloud, etc.

    But the important thing is that it shows what's possible. Web servers can be ergonomic to write in Rust, benefiting from its wonderful type system and performance, with very few sacrifices. Hopefully enough companies will start catching on to that, and the ecosystem will flesh out.

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
  • is2

    embedded RESTy http(s) server library from Edgio

  • https://github.com/verizondigital/is2

  • Blitz

    ⚡️ The Missing Fullstack Toolkit for Next.js

  • Two I've been lightly following are Redwood[0] and Blitz[1]. Still a long ways behind something like Rails, but promising nonetheless.

    [0] https://github.com/blitz-js/blitz

  • redwood

    The App Framework for Startups

  • [1] https://github.com/redwoodjs/redwood

  • uWebSockets.js

    μWebSockets for Node.js back-ends :metal:

  • */

    const map = new Map();

    Like that.

    Express JS is still shit, koajs and fastify are a little better, I used to use nodejs's internal http and https libraries directly but these days uwebsockets.js is what you'd want since it's mature enough already (used by top crypto exchanges).

    https://github.com/uNetworking/uWebSockets.js/

    And oh it comes with TS types which are cool.

  • incubator-retired-wave

    Discontinued Apache Wave is now retired

  • > Setters and getters are only popular in Java EE/Spring based environments (and it can be easily useful).

    I'd love to see stats on how common this stuff is amongst java programmers. I agree that modern java has lots of modern tools to write reasonable code - like closures and functional primitives. But its very normal amongst a lot of java programmers to never use that stuff. I believe you if you tell me your team uses a modern, nice subset of java. But believe me when I say lots of people out there don't.

    I worked as a professional interviewer for a year or so recently and interviewed 400+ programming candidates. One of the tasks was a 30 minute coding challenge - using the candidate's own computer and preferred language. A huge percentage of the java programmers, even under explicit time pressure, wasted time adding needless junk (like getters and setters or extraneous, pointless classes) to their code. I think I only saw 1 or 2 java candidates use any of java's functional programming primitives (like map) to keep their code terse and clean.

    Is that the fault of java, the language? I don't know. As I said in another comment I think the problem is cultural. I don't really have a problem with java-the-language. But a large part of java-the-community seems blissfully content with mediocrity. I took java off my resume years ago because I don't want that kind of coworker.

    > How do you write code, are you copying something by typing?

    I don't copy+paste because in the languages I use I don't need to. Thats what the compiler is for.

    > I’m sorry to assume it, but I think you only know about java development from third-hand infos and it has nothing to do with reality.

    Nope. Eg:

    https://github.com/apache/incubator-retired-wave/search?q=ge...

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • web3.js

    Collection of comprehensive TypeScript libraries for Interaction with the Ethereum JSON RPC API and utility functions.

  • > I have a similarly bad opinion on the average JavaScript developer

    I write a lot of javascript for a living, and you're not wrong[1]. I think the struggle javascript has is that an extremely high percentage of javascript programmers are pretty new to programming in general. So there's an awful lot of javascript code written by unsteady hands.

    If javascript is a magnet for novices, java feels like a magnet language for middle aged with kids "programming is just a job for me" indifference. I feel contempt for that mindset - but to respond in kind to your apology, I think the contempt I feel is probably reflected fear / disgust at the idea of settling. To me programming still feels like casting magic spells. I think I'm terrified of that spark some day being extinguished.

    [1] I check in on this issue every year or so and it never fails to delight and horrify in equal measure: https://github.com/ChainSafe/web3.js/issues/1178

  • gleam

    ⭐️ A friendly language for building type-safe, scalable systems!

  • Hi! I'm the Gleam guy! It out curiosity what would the language need to bring it closer to what you want?

    Here's Gleam for anyone interested: https://github.com/gleam-lang/gleam

  • jelly-actix-web-starter

    Discontinued A starter template for actix-web projects that feels very Django-esque. Avoid the boring stuff and move faster.

  • https://github.com/secretkeysio/jelly-actix-web-starter

    Enjoy. :)

  • quantizr

    Quanta is an open-source CMS with ChatGPT and Social Media (Fediverse) features

  • Yeah technology stacks have gotten completely out of hand over the decades. My current concoction is here:

    https://github.com/Clay-Ferguson/quantizr

    Java+SpringBoot+Docker

    I think I'm "doing it right", but like religions no one's is provably correct.

    The younger kids are saying: "Meh, we'll just run NodeJS on the server, so we can ignore the J2EE mess the previous generation created since they're older and therefore dumber than us."

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts