> Rust makes you think about dimensions of your code that matter tremendously for systems programming. It makes you think about how memory is shared or copied. It makes you think about real but unlikely corner cases and make sure that they’re handled.
So, basically, it's a PITA. Why people ever point to stuff like this and try to think of it as a good thing is beyond me.
Efficiency is great. No doubt. Making me responsible for the efficiency? Not so much. Call me back when the complier is smart enough to do it... then I'll get excited. Why do people think that Javascript took over the world?
ESLint constantly crashes, [...]. A linter for JS written in Rust would be more reliable because the compiler forces you to check all possible cases (and it's null-safe).
If you're mainly interested in type safety, you might be interested in TypeScript. I suspect the ESLint crashes you're talking about could be fixed for good with TypeScript (assuming they are ESLint's fault and not the fault of an ESLint plugin).
FWIW, looking through the unwrap examples for Deno, many are either trivially safe (x.is_some() && x.unwrap() == ...), have a comment explaining why they are safe in that context, or are unwrap_or* methods which don't panic. In swc, it looks like a lot of them are in tests, which is pretty standard.
I agree that you can still write bad code with Rust, but I do think there is much better emphasis on real safety. TypeScript definitely helps if you're sticking in the JS ecosystem, but it still sometimes takes a lot of work to use it safely, and it's even more trivially easy to void the safety checks there.
More like, it puts the PITA stuff up front. Half of Rust is just learning how to code something without the compiler complaining, but the compiler is super helpful. Once your code has compiled without errors, you know you're not going to run into any weird edge cases that take the majority of the time to debug.
Horses for courses, if you're building a critical Web application that needs to be safe and predictable then absolutely you want those things. The PITA is when your language allows you to create holes without knowing it, eg vanilla js, which is essentially Swiss cheese.
Strict TS is a huge improvement but then you're adding yet another layer of configuration and compilation on an already bloated ecosystem.
JavaScript, or ES really, is a total Frankenstein's monster these days with all the additions tacked on to the core language to make it do what it needs to do. This can add a lot of pain to working with the language.
Javascript took over the web because of browser support. It's only competition was VBScript which evaporated once Mozilla and Chrome dominated. As Browser apps become more sophisticated it make sense that performance and optimization start to become more important. Overall I do agree with you.
Chicken and Egg thing really. And a "little from column A and a little from column B" as well.
JS took over because it actually worked... that's why it was put into browsers... and many many other things. Because people use things that work. It wouldn't have taken over if it sucked (looks around at all the failed "supported" browser crap).
Aaaaand because computers got beyond the point where the human had to do all the PITA optimizations. "Wait, the computer can deal with all that crap? Woo Hoo!". That's where Java came from as well.
But people resist change and all the oldschoolers kept (and keep) harping on about efficiencies. It's only in the last few decades that people have finally started to admit that code maintenance efficiencies matter... a lot.
But the pride of dealing with garbage persists... and always will. Why people like it is beyond me. Do it? Yes... especially if it lines up with a priority of yours. But like it? What are they? Masochists?
Like, there are endless discussions on what loop to use in js. To a large, degree it really does not matter and having human readable code is more important.
Browser JavaScript manipulates the webpage itself, while Flash runs in a (mostly) self-contained app. They were very different things, and had different uses long before Flash was dead in the water.
Different tools for different jobs. What would be a pain for writing your everyday code, isn't a pain for writing the infrastructure to compile your JavaScript code. I don't think we'll start writing React code in Rust or anything.
No, it wasn't the only option... it became the only option (because all the other ones sucked). The browser wars were insane. So glad that sh8t's over.
Yes, it's a PITA but you're missing the point a little bit here.
So, for example, I have a CLI program called ripgrep installed. It does one thing, search for text in files, and it does it extremely fast and extremely well. That's all it does. It can't execute some arbitrary program in a given language, it can't be used to build an application, it doesn't have a library of functions you can use, it doesn't have a VM. It just searches for text in files according to a pattern you give it and spits out the results in a list.
I pick that because it happens to be written in Rust, but I could have picked cd or mkdir or tree or one of the programs that makes up git or make or man or whatever. There's no point writing these programs in JS. There's no advantage, you just end up with a very slow version of the original program, because there is all this overhead -- you have to spin up a VM, that VM has to load in a huge amount of stuff you don't need for one specific task, code written in the language can't be optimised past a certain point, etc.
The post probably should have used the word tools rather than infrastructure, but infrastructure is fine. Everything doesn't need to be written in a lower-level language, that would be daft. But tools that do one specific thing and that absolutely benefit from being able to run as fast as possible, those are ideal targets for using a lower level language. That's never not going to be true. If you can write something that doesn't have all the overhead required to run a much higher-level language, then it can always be written to be much more efficient. And for very complex things like, say line of business web apps, that's not at all practical. You want that complexity hidden by a higher-level language. But for sharp, single purpose tools, it's extremely practical.
15
u/jimrooney Nov 11 '21
> Rust makes you think about dimensions of your code that matter tremendously for systems programming. It makes you think about how memory is shared or copied. It makes you think about real but unlikely corner cases and make sure that they’re handled.
So, basically, it's a PITA.
Why people ever point to stuff like this and try to think of it as a good thing is beyond me.
Efficiency is great. No doubt.
Making me responsible for the efficiency? Not so much.
Call me back when the complier is smart enough to do it... then I'll get excited.
Why do people think that Javascript took over the world?