Live data from Hacker News

ExpressJS vs. Actix-Web: performance and running cost comparison

medium.com

31–40 of 58 posts

Re: ExpressJS vs. Actix-Web: performance and running cost comparison

#31

Earlier quoted context omitted.

I can only think of ecosystem size and language familiarity. Authors addressed development speed and found that Rust's static typing and compiler checks reduced development time vs JS. What other reasons did you have in mind?

I’m skeptical of this finding out at least it’s generalizability. I know (and like) Rust a fair bit better than JS, but I would be surprised if I could build a nontrivial web app in Rust faster than Node. And that’s without using TypeScript. YMMV, but I’d be curious to hear from others with experience with both languages.

I've used Rust for two years and still regularly get stumped.

Recently, I wanted to maintain a map of routes to futures so that multiple in-flight requests could await the same future while it fetches from disk.

The Javascript version took about one minute.

Using Rust doesn't give you free performance wins, especially not when working with async code where lifetimes actually get hard. Any time you're carrying around your own event loop / cpu pool while trying to avoid blocking requests, that's also another bombshell in itself. Similar challenges when using something like NIO/Netty, especially towards the beginning.

Add things like sinking a stream of lazy futures into a response and it can be very hard to understand what your actual performance looks like and where things will block, especially with parallel requests. The only way you could say it's a free lunch is if you're a Rust expert who has done it before, which doesn't apply if you're considering Rust vs JS/TS anyways.

Not to say nobody out there should be writing Rust, that would be silly. But someone upstream is seriously asking what advantages JS could have over Rust and difficulty is one of them. And it's not a small one.

Re: ExpressJS vs. Actix-Web: performance and running cost comparison

#32
A lot of Rust advocating here lately. But most miss the point. Nobody doubts the performance, efficiency, packaging solution or language design of Rust.

A more interesting question is:

As a CTO: Why would or wouldn't you choose Rust over Java, Node or Go?

Rust is not a new language (started in 2006, 1.0 Release in 2015). Why is its adoption kind of disappointing compared to its technical value?

The answers are not even more benchmarks or another even more wicked zero cost abstraction async runtime.

I'd like to read stories about some real world adoption. Can your average Java or Go devs become proficient in Rust in a reasonable amount of time? Is the code really mostly maintaince free, once it has compiled? Would it have been cheaper to just add some more servers to handle the load? How about large teams working on large domains (Java land)?

Re: ExpressJS vs. Actix-Web: performance and running cost comparison

#33

Is there any surprise here? Anecdotally Node seems fast for interpreters, but of course a compiled systems language like Rust blows it away. That’s a known trade off you make when picking a technology like Node; there are plenty of other reasons to use it.

I can only think of ecosystem size and language familiarity. Authors addressed development speed and found that Rust's static typing and compiler checks reduced development time vs JS. What other reasons did you have in mind?

Another upside: you'll never be stumped implementing something in Javascript/TS. There is no lifetime management. And the entire ecosystem is async-everything. You aren't stuck in an async-ready subecosystem like you are in Rust, Python's Twisted, Ruby's Event Machine, etc.

Re: ExpressJS vs. Actix-Web: performance and running cost comparison

#34

Can someone ELI5 the node code sample? > full = full == "true"; Umm.. Why? > if (!!limit Not not limit? Is this due to some corner case conversion for JS to make 100% sure this gets into a boolean..? I'm sure both samples have its reasoning, I'm just not aware. Any help please?

“!!” is a way to convert any “falsy” value to a Boolean false. E.g. if you have a flag “enableFoo” that can take the values of undefined, null, numerical zero, NaN, empty string, and actual Boolean false, all these values will be converted to false with “not not”. All other values, including - ironically - “false” as a string, will be converted to Boolean true.

I even once got a `!!!someVariable` in a codebase I inherited. It's what convinced me that the previous devs weren't doing weird things to work around a bad backend: they just didn't know what they were doing

Re: ExpressJS vs. Actix-Web: performance and running cost comparison

#35

Can someone ELI5 the node code sample? > full = full == "true"; Umm.. Why? > if (!!limit Not not limit? Is this due to some corner case conversion for JS to make 100% sure this gets into a boolean..? I'm sure both samples have its reasoning, I'm just not aware. Any help please?

> full = full == "true"

When you send ?full=true in a query, your req.query object is { full: "true" }. It's not going to assume it can deserialize arbitrary strings.

Re: ExpressJS vs. Actix-Web: performance and running cost comparison

#36

Can someone ELI5 the node code sample? > full = full == "true"; Umm.. Why? > if (!!limit Not not limit? Is this due to some corner case conversion for JS to make 100% sure this gets into a boolean..? I'm sure both samples have its reasoning, I'm just not aware. Any help please?

Here is another hack we lazy devs used a lot back in the old days: double tilde operator[1]

[1]: https://stackoverflow.com/questions/5971645/what-is-the-doub...

Re: ExpressJS vs. Actix-Web: performance and running cost comparison

#37
post #26
post #11

Earlier quoted context omitted.

Express.js active development seems to stop. The last commit on v5 branch was from October 2018. We are still waiting for http2 (2 years) or better support for promises (3 years). https://github.com/expressjs/express/tree/5.0 https://github.com/expressjs/express/pull/4196 https://github.com/expressjs/express/issues/2761 If someone is doing a new project in node I would recommend: https://github.com/fastify/fastify ht…

I feel like Koa JS deserves a mention. https://koajs.com/

Koa is great and makes the two obvious improvements to Express: first-class promises, and bubbling up a representation of the response instead of having your routes directly send the response. So you now have middleware instead of just Express' "beforeware".

Re: ExpressJS vs. Actix-Web: performance and running cost comparison

#39

It calls expressjs minimalist, but it has 52 dependencies. I really feel like we really need to reconsider what "minimalist" means in the js ecosystem.

A real minimalist web framework for Node is Koa. Basically anything besides the bare minimum is a separate dependency, so you only install what you need.

That said, it probably means minimalist in a usage sense. Compared to things like Nest.js (which I love, don't get me wrong), express is a lot more straightforward and basic.

Re: ExpressJS vs. Actix-Web: performance and running cost comparison

#40
post #39

It calls expressjs minimalist, but it has 52 dependencies. I really feel like we really need to reconsider what "minimalist" means in the js ecosystem.

A real minimalist web framework for Node is Koa. Basically anything besides the bare minimum is a separate dependency, so you only install what you need. That said, it probably means minimalist in a usage sense. Compared to things like Nest.js (which I love, don't get me wrong), express is a lot more straightforward and basic.

Koa is better but still has 43 dependencies...
Post reply on HN