News for hackers. Stuff that matters.
Re:Rust from 0 to 80% for JavaScript Developers by LAC-Tech on Sunday May 01, 2022 @12:30AM (#31222197)
Rust is one rabbit hole I really, really regret going down. Put weeks of work into it, got frustrated nearly every day, wrote copious notes, re-read things, and the end result is... I still can't use it for anything gnarly (ie everthing, because why else would I use a systems programming language if I wasn't doing funky stuff with memory?)

Rust has great PR but I found it to be a profound waste of time. YMMV.

Re:Rust from 0 to 80% for JavaScript Developers by tick_tock_tick on Sunday May 01, 2022 @01:47AM (#31222539)
I think Rust gets much easier when you understand it's the most or close to the most opinionated language ever made. If something is hard or feels really awkward to express it means you're "doing it wrong". A lot of classic solutions to problems that you've learned over your career are hard or impossible for Rust to validate. When you run into these hurdles you're supposed to switch to different style/solution rather then trying to fit a round peg in a square hole.
Re:Rust from 0 to 80% for JavaScript Developers by pkolaczk on Sunday May 01, 2022 @02:38AM (#31222754)
Yeah, this. Particularly when you come from a language that is heavy on using references like JS, Python or Java (and probably a good majority of languages with GC), you might get initially hard time with Rust. After I started appreciating pass-by-move, accepted occasional cloning and used references mostly for temporary, short-term borrows, suddenly it all clicked for me. The upside is that this way the code is actually much simpler than a spaghetti of cyclic references I got used to in big Java projects.
Re:Rust from 0 to 80% for JavaScript Developers by ebingdom on Sunday May 01, 2022 @01:20AM (#31222411)
Personally, I've had the opposite experience. Rust is one of the few languages that has proper support for algebraic data types and pattern matching, which I consider table stakes for a programming language. I know that's not what draws most people to Rust, and I'm also drawn to many other aspects of it, but it bothers me that most languages embrace product types but have little or no support for their categorical dual.
Re:Rust from 0 to 80% for JavaScript Developers by ALittleLight on Sunday May 01, 2022 @12:35AM (#31222219)
I tried picking it up recently. Not for any real reason, just curiosity. I didn't get terribly far, but found a lot of frustration. I then watched a YouTube video where a guy was saying how even though he knew and liked Rust he still got frustrated a lot by it and found that developing in Go was much more productive. I dropped Rust and started experimenting with Go because I began to get afraid that I wouldn't get past the unwieldy stage with Rust.
Re:Rust from 0 to 80% for JavaScript Developers by conradludgate on Sunday May 01, 2022 @01:54AM (#31222571)
> because why else would I use a systems programming language if I wasn't doing funky stuff with memory?

We use Rust for regular boring old backend servers at work. Not for speed or efficiency either. Rust doesn't need to be just a hot mess of memory manipulation (and you're never going to learn it like that)

If you want to learn it, don't do the weird stuff first, it'll just be confusing

Re:Rust from 0 to 80% for JavaScript Developers by pkolaczk on Sunday May 01, 2022 @02:43AM (#31222775)
> why else would I use a systems programming language if I wasn't doing funky stuff with memory?

Actually quite the opposite. You would appreciate Rust in applications that manage non-memory resources. RAII is a breath of fresh air compared to all those try-with-resources / AutoCloseable hacks.

Re:Rust from 0 to 80% for JavaScript Developers by kaba0 on Sunday May 01, 2022 @09:37AM (#31224921)
Chances are you don’t need Rust then. I think the only fail of Rust is that it markets to a much wider audience then needed. It is a low-level language, period. Sure, it is one of the most handy and expressive low level languages, but if your program doesn’t have to sit too close to the hardware than the litany of managed languages will be just good enough. GCs are plenty fast so the slight tradeoff is entirely worth itz
Re:Rust from 0 to 80% for JavaScript Developers by LAC-Tech on Sunday May 01, 2022 @09:24PM (#31230442)
I was much more productive with C++20. Finding a known bug in the borrow checker (people were telling me what I wrote should have compiled) was the last straw for me.
Re:Rust from 0 to 80% for JavaScript Developers by Cyph0n on Sunday May 01, 2022 @01:24AM (#31222427)
I’m not sure what “gnarly” things you tried to implement, but for anyone else in a similar situation, a good starter usecase for Rust is writing a command line utility.

Crates to check out:

- clap for command and argument parsing

- anyhow for “easy” error handling

- log + env_logger for logging

- reqwest for HTTP requests (start off by using the blocking client)

- serde + serde_json for handling JSON

- rayon to “magically” parallelize your code (using multiple threads)

Re:Rust from 0 to 80% for JavaScript Developers by pjmlp on Sunday May 01, 2022 @03:25AM (#31222921)
Exactly, Rust's sweet spot are kernels, drivers, firmware, GPGPU and everything else where using a language with automatic memory management isn't an option.
Re:Rust from 0 to 80% for JavaScript Developers by sydthrowaway on Sunday May 01, 2022 @01:54AM (#31222568)
What's an alternative?
Re:Rust from 0 to 80% for JavaScript Developers by olah_1 on Sunday May 01, 2022 @01:57AM (#31222585)
Zig or Nim maybe
Re:Rust from 0 to 80% for JavaScript Developers by winrid on Sunday May 01, 2022 @02:40AM (#31222762)
Zig is way more low level. Nim is a great alternative though. 90% of the performance with 50% of the work.
Re:Rust from 0 to 80% for JavaScript Developers by kaba0 on Sunday May 01, 2022 @09:40AM (#31224936)
There is no more low-level. Rust and zig can express the exact same programs. Rust just catches a few more erroneous ones at compile time, but you have to manage memory explicitly in both.
Re:Rust from 0 to 80% for JavaScript Developers by winrid on Sunday May 01, 2022 @12:30PM (#31226342)
Zig doesn't even have a string type. It's not an alternative to Rust, which is meant as a safer C++.

Nim has a huge stdlib.

Re:Rust from 0 to 80% for JavaScript Developers by sydthrowaway on Sunday May 01, 2022 @04:38PM (#31228444)
Do any of them have a wasm target?
Re:Rust from 0 to 80% for JavaScript Developers by antifa on Sunday May 01, 2022 @10:20PM (#31230755)
Nim can target js directly, but if you really want wasm it's mostly probably possible https://forum.nim-lang.org/t/7365