I start missing Rust approximately 30 minutes into every new Typescript project I work on because there's no good alternative to Rust enums (and other benefits that come with them, like pattern matching). I can't derive basic traits for my data, like specifying equality or a canonical ordering. I can't define math operations for my calendar types, my units of measure, or my 3D graphics structs. (De)serialization of data is a minefield.
In what world is Rust a lower level language compared to JavaScript at this point?
To preface, I don’t know Rust. Just looking at that code, that stuff has references to memory. In what world is a reference pointer not lower level?
That seems like a much bigger minefield, but I’d be happy to be educated on this. I’d ask that part of that education include why I’d ever introduce this class of problems into web development.
I think that's the question most people starting to learn Rust ask. The answer is a bit hairy because of how much modern garbage-collected languages normalized data sharing. Whether you're writing Ruby or Java or C# or Python, you can always do `a = BigStruct(); a.name = 'tiny struct'`.
Rust is the first mainstream language that looks at this code and says "Hold on, are you the only one modifying `a.name`?" And the intimidating part is not the question. The question is not for you. The intimidating part is that the Rust compiler asks itself the question, and it always knows the correct answer.
What the Rust compiler is looking at is the same thing the senior programmers are looking at during code reviews at your company. The people who know who should own which data. In C, once you `malloc` a struct someone has to know to `free` it. That's the rule. You acquire a resource? You're in charge of releasing it. Or at least passing the responsibility of freeing it over to someone else.
Rustc is the ultimate code reviewer. Yes, it's super pedantic, but also, hey, it can take any amount of insults you can throw at it and still thrive. If you run out of things to call it and the code still doesn't compile, guess what, the problem is probably on your side.
I repeat, Rustc is the perfect code reviewer you could ask for. And it's available 24/7. Compilation speeds are not very fast? Ok. Compare them to code review times from your peers when using a lesser language. 10 seconds for an incremental compile doesn't seem so bad when the alternative is to get instant feedback and a comment 16 hours later that you missed an edge case.
Sorry for the big post. Thanks if you read the whole thing; kudos if you scrolled straight down. Be kind, work hard, and good things will happen.
I see your point, but I think it only exposes the weakness of the terms "high-level" and "low-level" when used to describe programming languages. Rust is both low-level in that it can be used to write code for very small computers, but also high-level thanks to all the useful abstractions it provides.
There is no axis on which JavaScript (with or without Typescript) is a higher-level language than Rust in 2020. Rust offers a richer standard library, much MUCH more powerful facilities for modeling data, state-of-the-art (de)serialization that's one crate import and a one-liner annotation away.
I don't know who came up with asm.js, but that person definitely knew. JavaScript's destiny is to be a building block. Yes, it feels nice to write plain JS without importing any libraries. It's nice knowing the difference between `Array#slice` and `Array#splice` without looking it up on MDN. But it felt just as nice for ASM coders in the 80s to bypass a C compiler, and look where we are now.
I have. Purescript doesn't have typeclass derivation. BS technically does, but the time I tried it the compiler plugin was so raw it was basically useless to me. BS/Reason don't support operator overloading. Etc etc.
Redex's library selection is anemic compared to Crates.io, and so is Pursuit's. There are a couple of gems in both, but for any given use case it's just as likely you will have to write your own code than find a workable solution in the package manager.
More importantly, Rust has orders of magnitude higher bus factor than Purescript and ReasonML combined. Phil Freeman has long since left his project, and so will eventually Hongbo Zhang, at which point Reason will follow PS's slow downward spiral into open source limbo.
Believe it or not, I actually put a bit of thought into this. And I do firmly believe that Rust is by far the best ML-like language for the web available to the public right now. Perhaps I should finally write that blog post I keep putting off.
So you are missing a basic feature that a bazillion other languages can give you. I am still amazed how people think that the ML features in Rust somehow new inventions.
In what world is Rust a lower level language compared to JavaScript at this point?