Open Menu
AllLocalCommunitiesAbout
lotide
AllLocalCommunitiesAbout
Login

Rust is Eating JavaScript

⁨333⁩ ⁨likes⁩

Submitted ⁨⁨2⁩ ⁨months⁩ ago⁩ by ⁨volkerwirsing@feddit.org⁩ to ⁨technology@lemmy.world⁩

https://leerob.com/n/rust

source

Comments

Sort:hotnewtop
  • adespoton@lemmy.ca ⁨2⁩ ⁨months⁩ ago

    JavaScript has its place as a lightweight runtime interpreter.

    Rust has its place as a secure and modern way to engineer and produce dependable software.

    source
    • sugar_in_your_tea@sh.itjust.works ⁨2⁩ ⁨months⁩ ago

      Eh, it’s not that lightweight, Lua is much better for that.

      source
    • jimmy90@lemmy.world ⁨2⁩ ⁨months⁩ ago

      with wasm and friendly new web frameworks, the only thing keeping js alive is inertia

      source
      • adespoton@lemmy.ca ⁨2⁩ ⁨months⁩ ago

        Essentially, JS is the new Flash….

        source
  • solrize@lemmy.world ⁨2⁩ ⁨months⁩ ago

    The JS tooling universe has always seemed like a Lovecraftian hellscape to me. I’ve managed to stay away from it so far, but if I were caught in it, of course I’d be trying to escape any way I could. It sounds like Rust’s attraction here has been as a viable escape corridor rather than anything about Rust per se.

    In particular, I get that everyone wants their code to be faster, and I get that certain bloaty apps (browsers) need to get their memory footprint under control, and a few niche areas (OS kernels, realtime control) can’t stand GC pauses. Other than that though, what is the attraction of Rust for stuff like tooling? As opposed to a (maybe hypothetical) compiled, GC’d language with a good type system and not too much abstraction inversion (Haskell’s weakness, more or less).

    Has Golang fizzled? It has struck me as too primitive, but basically on the right track.

    Rust seems neat from a language geek perspective, but from what I can tell, it requires considerable effort from the programmer handle a problem (manual storage reclamation) that most programs don’t really have. I do want to try it sometime. So this post is intended as more inquisitive/head scratching rather than argumentative.

    source
    • artificialfish@programming.dev ⁨2⁩ ⁨months⁩ ago

      I think once you get into rust you just have a hard time going back, and it doesn’t feel “hard” anymore. I can practically rust as easily as I can python.

      source
      • solrize@lemmy.world ⁨2⁩ ⁨months⁩ ago

        I had the impression Rust doesn’t handle concurrency particularly well, at least no better than Python, which does it badly (i.e. with colored functions). Golang, Erlang/Elixir, and GHC (Haskell) are way better in that regard, though they each have their own issues. I had believed for a while that Purescript targeting the Erlang VM and with all the JS tooling extirpated might be the answer, but that was just a pipe dream and I don’t know if it was really workable.

        source
        • -> View More Comments
    • asdfasdfasdf@lemmy.world ⁨2⁩ ⁨months⁩ ago
      1. Rust is the best language for writing WASM in, so you can write Rust and run it in the browser without transpiling to JS.
      2. Rust isn’t just about speed or GC pauses. Its type system is amazing and allows you to encode things that you cannot in any other mainstream language.
      3. It’s so incredibly well designed, it fewla like that clip from Ricky and Morty where Morty feels what standing on a truly even plane feels like then has a panic attack when he leaves. Rust rethought everything from scratch, and isn’t just some new syntax or fancy compiler tricks. No null, no exceptions, no inheritance, new typing capabilities, etc.
      source
      • solrize@lemmy.world ⁨2⁩ ⁨months⁩ ago

        Interesting point about Wasm if that is important. You can also compile C++ to wasm but then its C++ ;). I don’t know about Ada to Wasm.

        I don’t think Rust is quite mainstream yet either. My impression is that its type system has not caught up with Haskell’s except in a few areas, but of course nobody pretends Haskell is mainstream. I haven’t yet tried Idris.

        Golang seems to have a decent runtime model (lightweight threads, GC) though the language itself is underpowered. There is a Golang backend for Purescript that sounded interesting to me. The thing that turned me off the most about Purescript was the JS tooling. Purescript (purescript.org) is/was a Haskell-like language that transpiles to JS, intended for use in browsers, but Typescript filled this space before Purescript got much traction. That felt unfortunate to me.

        I don’t think HLL (high level language) has an official definition, but informally to me it has generally meant that the language is GC’d and that the native integer type is unbounded (bignum). By that standard, Rust and Ada are low level. I’ve so far thought of Rust as a modernized Ada with curly braces and more control of dynamic memory reclamation. Maybe there is more going on than that. Ada is still ahead of Rust in some ways, like generic packages, but Rust is working on that.

        If you have a suggestion of a no-nonsense Rust book, I’d be interested in looking at it. doc.rust-lang.org/book/ beat around the bush way too long before discussing the language, but I guess I should spend more time with it.

        source
        • -> View More Comments
    • qaz@lemmy.world ⁨2⁩ ⁨months⁩ ago

      I usually pick Rust for CLI tools because:

      1. It’s statically compiled and isn’t dependent on system binaries and won’t break if there if the system has the wrong version like C/C++, allowing you to distribute it as a single binary without any other installation steps
      2. Still produces fairly small binaries unlike languages like Java or C# (because of the VM)
      3. Is a modern language with a good build system (It’s like night and day compared to CMake)
      4. And I just like how the language works (errors as values etc.)
      source
      • Dark_Arc@social.packetloss.gg ⁨2⁩ ⁨months⁩ ago
        1. It’s statically compiled and isn’t dependent on system binaries and won’t break if there if the system has the wrong version like C/C++, allowing you to distribute it as a single binary without any other installation steps

        You can do that with C++ too.

        1. Still produces fairly small binaries unlike languages like Java or C# (because of the VM)

        I mean, the jars are actually pretty small; but also I really don’t get the storage argument. I mean we live in a world where people happily download a 600 MB discord client.

        1. Is a modern language with a good build system (It’s like night and day compared to CMake)

        Meson exists … as do others.

        1. And I just like how the language works (errors as values etc.)

        Fair enough; though why? What’s wrong with exceptions?

        I work in a code base where I can’t use exceptions because certain customers can’t use exceptions, and I regularly wish I could because errors as values is so tedious.

        source
        • -> View More Comments
    • Glitchvid@lemmy.world ⁨2⁩ ⁨months⁩ ago

      Maybe give it a try; it’s my favorite language to write programs in now, it has an extremely good standard library, and for everything else there’s a mass of high quality crates, its build system is actually competent and makes compiling on Windows or Linux trivial, plus many, many more quality of life features.

      source
      • CHOPSTEEQ@lemmy.ml ⁨2⁩ ⁨months⁩ ago

        If Rust had been around when I was an underclassman, I would have been totally locked into the full CompSci track. Instead, I got introduced to Java and C (and calculus…) and that looked like a nightmare compared to what I had been playing with in JS/Python land, so I noped on out of there and got a Comp Sci Lite degree.

        Years later, I’m just completely in love with Rust.

        source
        • -> View More Comments
      • solrize@lemmy.world ⁨2⁩ ⁨months⁩ ago

        Yes it’s on my infinite todo list. I’m just being too much of a curmudgeon about the available textbooks, and had a sinking feeling when the main one didn’t get “hello world” out of the way on page 1, and shift to the specifics of the language.

        source
        • -> View More Comments
    • Tanoh@lemmy.world ⁨2⁩ ⁨months⁩ ago

      Has Golang fizzled? It has struck me as too primitive, but basically on the right track.

      My biggest issue with Golang by far is the close tie to Google. They are not our friendly innovator, time and time again they make decisions that will help them earn more ad money, and nothing else. And they have a lobg history of releasing something and then never fix the issues with it, and then more or less abandon it.

      Other than that there are afaik some other issues with go, I’m not an expert but from what I hear the GC is quite aggressive and you can’t tell it to run when you want. Doing something time sensitive? Well, bad luck. GC time!

      source
      • 0x0@programming.dev ⁨2⁩ ⁨months⁩ ago

        the close tie to Google.

        Guess who’s one of the rounders of the Rust Foundation…

        source
      • solrize@lemmy.world ⁨2⁩ ⁨months⁩ ago

        True about Google ;). Yes, there are programs that really don’t want GC. I consider those to mostly be niche applications since most of us are fine with using e.g. Python, which has automatic storage management (won’t quibble about whether it is GC per se) that has occasional pauses. SImilarly, tons of important programs are written in Java, which is GC’d. Of course Java is tied up with Oracle just like Go is tied up with Google.

        Go’s main problem from what I can tell is that the language itself is too old fashioned. I’ve used it but am not expert. It feels like an improved version of C, rather than a modern, type-safe language.

        source
      • sugar_in_your_tea@sh.itjust.works ⁨2⁩ ⁨months⁩ ago

        The GC in Go is fantastic IMO since it runs in a separate thread. I used it since 1.0 (switched our product from node.js), and dealt with all the the pain of an imprecise GC (fixed in 1.5?) and all the little improvements to arrive at it’s current state.

        The main issues I have with it are pretty core to the language, unfortunately, such as:

        • interface{} is basically a void*, but since it’s a fat pointer, it can hold nil without itself being nil, which can happen by accident
        • runtime reflection is a bad habit, but it’s unfortunately really common
        • it’s really easy to deadlock by making stupid mistakes; if it had automatic unlocking based on scope (like Rust, or something like Python’s context managers), we could solve this, but defer just isn’t good enough
        • no destructors - with destructors, we could build a solution to deadlocks

        Maybe they fixed some of those issues, idk, I haven’t used it for several years.

        source
        • -> View More Comments
    • sugar_in_your_tea@sh.itjust.works ⁨2⁩ ⁨months⁩ ago

      Go is fine, but it has its flaws. I prefer Rust because:

      • memory safety is a compiler check, not a runtime check, so you catch issues earlier
      • locks contain their values, so you can’t accidentally do anything unsafe
      • no nil (() is semantically different), so no surprises with contracts
      • everything is an expression, which lends itself really well to FP concepts
      • actual dependency management at 1.0
      • pretty much no runtime, so calling from another language is super easy
      • targets WASM and microcontrollers
      • no pointers (not exactly true)

      It takes longer to learn, but I’m about as productive with both now.

      source
      • solrize@lemmy.world ⁨2⁩ ⁨months⁩ ago

        Thanks, “Comprehensive Rust” is readable so far, though I haven’t gotten to the “fun” (memory management) parts yet.

        source
    • rottingleaf@lemmy.world ⁨2⁩ ⁨months⁩ ago

      The JS tooling universe has always seemed like a Lovecraftian hellscape to me.

      That’s most of any programming of today for me.

      If it can’t be grasped in a couple of days - then na-ah.

      I can patch something I need working which doesn’t, written in C.

      autotools ftw

      source
    • pr06lefs@lemmy.ml ⁨2⁩ ⁨months⁩ ago

      I think there’s room for a rust-lite language that is GCed. Something with a functional-style type system and that compiles to machine code.

      Roc is a candidate for this language. Basically Elm that compiles to machine code, but with a number of tweaks to make it work for more than just a web front end. Like Elm, the type system is haskell like, but simplified.

      source
      • balder1991@lemmy.world ⁨2⁩ ⁨months⁩ ago

        There’s already Swift, which isn’t garbage collected, but the ref. counting does the same in practice.

        The only problem with Rust and Swift, Kotlin etc. in my opinion is that they keep growing and getting more complex with no signs of stopping.

        source
      • sugar_in_your_tea@sh.itjust.works ⁨2⁩ ⁨months⁩ ago

        Sounds kinda like Go. It’s not functional, but functional patterns work well there.

        It’s not great for FE though.

        source
        • -> View More Comments
      • solrize@lemmy.world ⁨2⁩ ⁨months⁩ ago

        Thanks, Roc sounds interesting. Ocaml also maps more closely to machine operations than Haskell does, so it has always seemed like another alternative. AMD has something called ROCm which is their version of CUDA, but I assume that is unrelated.

        source
  • ICastFist@programming.dev ⁨2⁩ ⁨months⁩ ago

    Can we please go back to making programs for the target OS and skip the browser dependency?

    source
    • JackbyDev@programming.dev ⁨2⁩ ⁨months⁩ ago

      Sure! Here! Electron.

      source
      • curry@programming.dev ⁨2⁩ ⁨months⁩ ago

        [Screams internally]

        source
    • terminhell@lemmy.dbzer0.com ⁨2⁩ ⁨months⁩ ago

      Browsers have almost become the OS. At least in user land.

      source
    • WhyJiffie@sh.itjust.works ⁨2⁩ ⁨months⁩ ago

      partly I agree, but then I would prefer to run those webapps confined in a web browser

      source
  • maximilian@lemmy.ml ⁨2⁩ ⁨months⁩ ago

    Honestly those usecases described here shouldn’t have been done in js in the first place.

    source
    • Thrashy@lemmy.world ⁨2⁩ ⁨months⁩ ago

      Look, I’m in no position to talk seeing as I once wrote a shell script in PHP, but the profusion of JavaScript in the late aughts and early teens for things that weren’t “make my website prettier!” feels very much like a bunch of “webmasters” dealing with the fact that the job market had shifted out from under them while they weren’t looking and rebranding as “developers” whose only tool was Hammer.js, and thinking all their problems could be recontextualized as Nail.js.

      source
    • commander@lemmings.world ⁨2⁩ ⁨months⁩ ago

      I agree.

      I’m noticing this species has a problem with doing things the obviously correct way the first time.

      It’s as though we’d rather put 100x more effort for 10% of the results just to prove that we “can” do it.

      source
    • Bogasse@lemmy.ml ⁨2⁩ ⁨months⁩ ago

      Well I see huge benefits in building the tools used by a community with the technology this community masters. IMO the Python’s stdlib sucks because it’s written in C which is a huge barrier to entry.

      source
      • balder1991@lemmy.world ⁨2⁩ ⁨months⁩ ago

        Not all of the stdlib is written in C. Some parts cannot be Python because it’s critical code that needs to be as fast as possible.

        Python is already slow for many use cases, if the standard lib was all built in Python it would be just too slow for much more use cases.

        source
        • -> View More Comments
  • Binette@lemmy.ml ⁨2⁩ ⁨months⁩ ago

    Fun fact! Lemmy is made in Rust!

    source
    • sugar_in_your_tea@sh.itjust.works ⁨2⁩ ⁨months⁩ ago

      The BE, yes, the FE is JS.

      source
      • Binette@lemmy.ml ⁨2⁩ ⁨months⁩ ago

        The new FE is going to be in rust though

        source
  • call_me_xale@lemmy.zip ⁨2⁩ ⁨months⁩ ago

    Thank god.

    source
  • ColdWater@lemmy.ca ⁨2⁩ ⁨months⁩ ago

    Nom nom nom

    source
    • sugar_in_your_tea@sh.itjust.works ⁨2⁩ ⁨months⁩ ago

      Everything eventually becomes a crab.

      source
      • Kolanaki@pawb.social ⁨2⁩ ⁨months⁩ ago

        That means eventually everything tastes great when smothered in butter. 🤤

        source
        • -> View More Comments
  • Diplomjodler3@lemmy.world ⁨2⁩ ⁨months⁩ ago

    Guten Appetit!

    source
  • whereisk@lemmy.world ⁨2⁩ ⁨months⁩ ago

    Is this a 2yo write up, considering the last update was in 2023?

    source
    • mostlikelyaperson@lemmy.world ⁨2⁩ ⁨months⁩ ago

      Originally 4 years old at this point it looks like, and the great shift to wasm has failed to manifest.

      source
    • zaphod@sopuli.xyz ⁨2⁩ ⁨months⁩ ago

      It was recently shared on Hackernews, I assume that’s why it’s showing up here now.

      source
  • Venator@lemmy.nz ⁨2⁩ ⁨months⁩ ago

    Can browsers run rust in the front end instead of javascript, or is it limited to transpile time and backend?

    source
    • sushibowl@feddit.nl ⁨2⁩ ⁨months⁩ ago

      Sort of, browsers can run rust code through webassembly. But i dont think this is a full replacement for JavaScript as of yet.

      source
      • sugar_in_your_tea@sh.itjust.works ⁨2⁩ ⁨months⁩ ago

        Yeah, you need to have some JS to manipulate graphics, so the Rust web frameworks have a JS shim to do that and communicate with the WebAssembly Rust code as necessary. It works surprisingly well tho.

        source
        • -> View More Comments
  • commander@lemmings.world ⁨2⁩ ⁨months⁩ ago

    Good!!!

    source
  • GreenKnight23@lemmy.world ⁨2⁩ ⁨months⁩ ago
    [deleted]
    source
    • andallthat@lemmy.world ⁨2⁩ ⁨months⁩ ago

      well, joke’s on you. Since I rewrote her in Rust, my mum runs the 100 meters hurdles in 14 seconds

      source
  • victorz@lemmy.world ⁨2⁩ ⁨months⁩ ago

    Can I just say how beautiful that page is? Such a delight to read the text on it. The legibility. The simplicity. 😙👌

    source
  • callmepk@lemmy.world ⁨2⁩ ⁨months⁩ ago

    JS become rusty

    source
  • vane@lemmy.world ⁨2⁩ ⁨months⁩ ago

    Because corporations doesn’t want web to be open, everyone can javascript, not everyone can read webassembly.

    source
    • Dark_Arc@social.packetloss.gg ⁨2⁩ ⁨months⁩ ago

      The minifiers have long made JavaScript just as indecipherable

      source
      • 0x0@programming.dev ⁨2⁩ ⁨months⁩ ago

        You can deminify, decompiling is a bit harder.

        source
      • vane@lemmy.world ⁨2⁩ ⁨months⁩ ago

        You can’t place breakpoints inside wasi binaries. You can place breakpoints inside minified js code.

        source
        • -> View More Comments
  • mesamunefire@piefed.social ⁨2⁩ ⁨months⁩ ago

    I thought python has kinda exploded lately...

    source
    • sugar_in_your_tea@sh.itjust.works ⁨2⁩ ⁨months⁩ ago

      I use it at work, and it’s finally getting an optimization pass.

      I wish I did Rust for work, but options are limited and I like my team.

      source
      • mesamunefire@piefed.social ⁨2⁩ ⁨months⁩ ago

        Yeah I've been playing around with rust but most know py. And to be fair on my it has fantastic libraries.

        source