News for hackers. Stuff that matters.
Re:Performance Showdown: Rust vs Javascript (2020) by adrianN on Friday February 12, 2021 @06:58AM (#26112722)
Yeah well it's pretty obvious that you can write slow code in any language.

The interesting question is whether the code produced by the average programmer of that language is fast or not. And there language choice matters quite a bit, both because of language design (i.e. how easy is it to generate good machine code for that language) and because of the culture associated with that language (e.g. you can write extremely efficient Java, but typical Java programs chase a lot of pointers and generate a lot of garbage).

Re:Performance Showdown: Rust vs Javascript (2020) by Tehnix on Friday February 12, 2021 @07:19AM (#26112871)
>whether the code produced by the average programmer of that language is fast or not

Not just this, but the ceiling of performance improvements matter a lot too.

Rust allows you to write high-level code, where you can "easily" jump into Rust coming from JavaScript. You performance might be on par in your initial versions while you are getting into the language.

It starts to matter a lot when you now have a working application, and you start using it. With JavaScript you will quickly reach a point where your idiomatic JavaScript is about as fast as it'll go.

With Rust, there usually keeps being tricks you can pull to squeeze more performance out of it, and you can do it just for the hot-paths of your code instead of rewriting the entire thing in a new language because you reached your limit.

A good example of this limit is something like the TypeScript compiler. It has huge performance issues with larger codebases, but unfortunately there's not much that can be done without rewriting the entire damn thing in e.g. Rust, because you've reached the limits of JavaScript.

Re:Performance Showdown: Rust vs Javascript (2020) by crazypython on Friday February 12, 2021 @08:33AM (#26113430)
>Not just this, but the ceiling of performance improvements matter a lot too.

But the floor can matter too. For someone trained to write high-performance JavaScript, JavaScript's performance floor is higher than Rust's, and they can write more JavaScript faster.

> A good example of this limit is something like the TypeScript compiler. It has huge performance issues with larger codebases, but unfortunately there's not much that can be done without rewriting the entire damn thing in e.g. Rust, because you've reached the limits of JavaScript.

Actually, you can fix it by rewriting it as a single-pass compiler to improve the algorithms.

Re:Performance Showdown: Rust vs Javascript (2020) by Tehnix on Friday February 12, 2021 @09:45AM (#26114130)
>But the floor can matter too. For someone trained to write high-performance JavaScript, JavaScript's performance floor is higher than Rust's, and they can write more JavaScript faster.

I'm not sure what you mean by the floor here? Experience? The author of the article was experienced in JavaScript and was new to Rust for example.

>Actually, you can fix it by rewriting it as a single-pass compiler to improve the algorithms.

I'd say that's on the same scale of work as rewriting it in a new language.

And even then, this is most likely not a realistic solution, I can almost guarantee you there will be stuff they are currently doing that they cannot do in such an architecture.

The first problem with the words "single-pass" and "Javascript" that come to mind are the out-of-order variable declarations, i.e. var, which bubbles up.

There are a ton of other issues as well.

Re:Performance Showdown: Rust vs Javascript (2020) by lionkor on Friday February 12, 2021 @07:09AM (#26112795)
It's a really interesting and important question though; Do you measure a languages "performance"

1. by how fast it runs when written by a very experienced developer, or

2. by how fast programs run that are written by the "average" programmer, or

3. by how fast it runs when written by a bad or inexprienced programmer?

For each of these I can think of (at least) one language that would beat the performance of any other. There are languages that are "very difficult to use wrong", and there are languages that are difficult to use right. For the latter, C++ is a great example. You will copy and leak yourself out of memory before you terminate, if you dont know what you're doing.

Maybe we should stop comparing random languages from different domains by how fast they run.

Re:Performance Showdown: Rust vs Javascript (2020) by josephg on Friday February 12, 2021 @08:37AM (#26113479)
My first take at an answer is, what sort of code do I anticipate writing in each language? And what sort of code do I expect to see from my peers?

Rust makes it surprisingly easy to write code that absolutely thrashes the memory allocator - using String/Box/Vec and adding .clone() everywhere makes a lot of tricky borrowing problems go away. Is that the kind of code I expect to be writing? Or running? And if so, we shouldn’t expect that kind of code to perform much better in most cases than javascript.

Re:Performance Showdown: Rust vs Javascript (2020) by EwanToo on Friday February 12, 2021 @12:03PM (#26115767)
You're absolutely right, these are the kinds of questions any team should be asking

* Is language X that we all know suitable?" * Is there a language Y that we could all learn in an acceptable time optimal? * What does the tooling look like? * How would we bring in new people?

CPU runtime is just one aspect to consider

Re:Performance Showdown: Rust vs Javascript (2020) by farresito on Friday February 12, 2021 @11:52AM (#26115617)
You measure it of course by how fast it runs when written by a very experienced developer. I don't see how you can argue any other way.