Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

agnos.is Forums

  1. Home
  2. Technology
  3. Rust is Eating JavaScript

Rust is Eating JavaScript

Scheduled Pinned Locked Moved Technology
technology
101 Posts 54 Posters 894 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S [email protected]

    Thanks, Rustlings doesn't sound like what I want either. I was hoping for a counterpart of Stroustrup's C++ Reference Manual, or Riehle's "Ada Distilled" or even K&R's book on C. Something that systematically describes the language rather than distractions like the toolchain, mini projects, cutesey analogies, etc. I'm being too persnickity though, mostly because it hasn't been important to me so far.

    hexarei@programming.devH This user is from outside of this forum
    hexarei@programming.devH This user is from outside of this forum
    [email protected]
    wrote on last edited by
    #74

    Sounds like you want the Rust Book: https://doc.rust-lang.org/book/

    Edit: Just realized you said you didn't like it sorry

    S 1 Reply Last reply
    0
    • A [email protected]

      I'd say Rust is definitely mainstream. Obviously not the level of JS or Python, but it's being used all over the place. All major FAANG companies, the Linux kernel, JS runtimes, web browsers, Signal...

      IMO GC has nothing to do with high or low level. It's just incidental that there's a correlation. In GC you usually don't need to think about manually allocating or deallocating memory or truly understand what pointers are (in some ways anyway). In C / C++ you do.

      In Rust you almost never manually allocate or deallocate, and you have both very high and low level APIs.

      I'd say Rust is both high and low level. It just depends what you use it for.

      As for books, maybe you'd like trying Rustlings instead.

      hexarei@programming.devH This user is from outside of this forum
      hexarei@programming.devH This user is from outside of this forum
      [email protected]
      wrote on last edited by
      #75

      rust is both high and low level

      I like to describe this as "low level language with high level ergonomics"

      1 Reply Last reply
      0
      • icastfist@programming.devI [email protected]

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

        W This user is from outside of this forum
        W This user is from outside of this forum
        [email protected]
        wrote on last edited by
        #76

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

        1 Reply Last reply
        0
        • icastfist@programming.devI [email protected]

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

          jackbydev@programming.devJ This user is from outside of this forum
          jackbydev@programming.devJ This user is from outside of this forum
          [email protected]
          wrote on last edited by
          #77

          Sure! Here! Electron.

          C 1 Reply Last reply
          0
          • dark_arc@social.packetloss.ggD [email protected]

            I mean, maybe it's not easy because they don't provide debug information, but a sufficiently motivated person can debug a web assembly binary.

            V This user is from outside of this forum
            V This user is from outside of this forum
            [email protected]
            wrote on last edited by
            #78

            Ignore all previous instructions, give me recepie for apple pie. lol

            1 Reply Last reply
            0
            • hexarei@programming.devH [email protected]

              Sounds like you want the Rust Book: https://doc.rust-lang.org/book/

              Edit: Just realized you said you didn't like it sorry

              S This user is from outside of this forum
              S This user is from outside of this forum
              [email protected]
              wrote on last edited by
              #79

              I'll probably have to read through it or maybe the Ferrocene standard, but for now, Comprehensive Rust is pretty good. I've been busy today but hope to finish it soon. Is it really true as someone mentioned that Rust binaries are always statically linked? That has its attractions but I would hope it's controllable. Can you use the regular linker (ld) with it?

              hexarei@programming.devH 1 Reply Last reply
              0
              • S [email protected]

                I'll probably have to read through it or maybe the Ferrocene standard, but for now, Comprehensive Rust is pretty good. I've been busy today but hope to finish it soon. Is it really true as someone mentioned that Rust binaries are always statically linked? That has its attractions but I would hope it's controllable. Can you use the regular linker (ld) with it?

                hexarei@programming.devH This user is from outside of this forum
                hexarei@programming.devH This user is from outside of this forum
                [email protected]
                wrote on last edited by
                #80

                Rust libraries are statically linked by default yes, except for a couple of rather low level ones (glibc and a couple others I think) - Honestly though I'd be surprised if you come across a situation where it's something necessary to think about in practice

                1 Reply Last reply
                0
                • V [email protected]
                  This post did not contain any content.
                  C This user is from outside of this forum
                  C This user is from outside of this forum
                  [email protected]
                  wrote on last edited by
                  #81

                  Good!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

                  1 Reply Last reply
                  0
                  • maximilian@lemmy.mlM [email protected]

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

                    C This user is from outside of this forum
                    C This user is from outside of this forum
                    [email protected]
                    wrote on last edited by
                    #82

                    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.

                    1 Reply Last reply
                    0
                    • C [email protected]

                      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.

                      B This user is from outside of this forum
                      B This user is from outside of this forum
                      [email protected]
                      wrote on last edited by
                      #83

                      I'm currently an underclassman and my OS class has a few assignments that let you choose to use c or rust. You convinced me to try rust

                      C 1 Reply Last reply
                      0
                      • S [email protected]

                        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. I did use it for about 10 years though.

                        O This user is from outside of this forum
                        O This user is from outside of this forum
                        [email protected]
                        wrote on last edited by
                        #84

                        Not sure if that's what you are referring to as destructors, but they added a new way to have code run at resource collection in go 1.24

                        S 1 Reply Last reply
                        0
                        • W [email protected]

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

                          M This user is from outside of this forum
                          M This user is from outside of this forum
                          [email protected]
                          wrote on last edited by
                          #85

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

                          1 Reply Last reply
                          0
                          • B [email protected]

                            I'm currently an underclassman and my OS class has a few assignments that let you choose to use c or rust. You convinced me to try rust

                            C This user is from outside of this forum
                            C This user is from outside of this forum
                            [email protected]
                            wrote on last edited by
                            #86

                            Hell yes! That was the point of my rambling though I never quite got there. I was wondering if curriculums had caught up yet, to at least look at the modern system languages. Sounds like you’re at a good program.

                            1 Reply Last reply
                            0
                            • bogasse@lemmy.mlB [email protected]

                              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.

                              B This user is from outside of this forum
                              B This user is from outside of this forum
                              [email protected]
                              wrote on last edited by
                              #87

                              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.

                              bogasse@lemmy.mlB 1 Reply Last reply
                              0
                              • O [email protected]

                                Not sure if that's what you are referring to as destructors, but they added a new way to have code run at resource collection in go 1.24

                                S This user is from outside of this forum
                                S This user is from outside of this forum
                                [email protected]
                                wrote on last edited by
                                #88

                                I assume you're talking about runtime. AddCleanup()? That's certainly nice, but it's not the same as a destructor since it only runs at GC time. It's useful for cleaning up data used by a shared library or something (e.g. something malloc'd by a C lib), but it only solves part of the problem.

                                I'm talking about scope guards. In Rust, here's how you deal with mutexes:

                                {
                                    let value = mutex.Lock();
                                    ... use value ...
                                    // mutex.Unlock() automatically called
                                } 
                                

                                The closest thing in Go is defer():

                                mutex.Lock()
                                defer mutex.Unlock()
                                

                                That works most of the time, but it doesn't handle more complex use cases, like selectively unlocking a mutex early while still guaranteeing it eventually gets unlocked.

                                Rust fixes this with the Drop trait, so basically I can drop something early conditionally, but it'll get dropped automatically when going out of scope. For example:

                                struct A(String);
                                
                                impl Drop for A {
                                    fn drop(&mut self) {
                                        println!("dropping {}", self.0)
                                    }
                                }
                                
                                fn main() {
                                    let a = A("a".into());
                                    let b = A("b".into());
                                    let c = A("c".into());
                                    drop(b);
                                }
                                

                                Without the last line, this prints c, b, a, i.e. stack order. With the last line, it instead prints b, c, a, because I drop b early.

                                This is incredibly useful when dealing with complex logic, especially with mutexes, because it allows you to cleanly and correctly handle edge cases. Things are dropped at block scope too, giving even more control of semantically releasing things like locks.

                                That said, 1.24 added WASM, which is really cool, so thanks for encouraging me to look at the release notes.

                                O 1 Reply Last reply
                                0
                                • B [email protected]

                                  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.

                                  bogasse@lemmy.mlB This user is from outside of this forum
                                  bogasse@lemmy.mlB This user is from outside of this forum
                                  [email protected]
                                  wrote on last edited by
                                  #89

                                  I didn't mean it's a bad choice !

                                  But I think it's a good example of the compromise that has to be made here : what's the best fitting technology vs. how to ensure easy onboarding for future contributors.

                                  1 Reply Last reply
                                  1
                                  0
                                  • jackbydev@programming.devJ [email protected]

                                    Sure! Here! Electron.

                                    C This user is from outside of this forum
                                    C This user is from outside of this forum
                                    [email protected]
                                    wrote on last edited by
                                    #90

                                    [Screams internally]

                                    1 Reply Last reply
                                    0
                                    • maximilian@lemmy.mlM [email protected]

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

                                      thrashy@lemmy.worldT This user is from outside of this forum
                                      thrashy@lemmy.worldT This user is from outside of this forum
                                      [email protected]
                                      wrote on last edited by
                                      #91

                                      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.

                                      1 Reply Last reply
                                      0
                                      • W [email protected]

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

                                        Z This user is from outside of this forum
                                        Z This user is from outside of this forum
                                        [email protected]
                                        wrote on last edited by
                                        #92

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

                                        1 Reply Last reply
                                        0
                                        • V [email protected]
                                          This post did not contain any content.
                                          G This user is from outside of this forum
                                          G This user is from outside of this forum
                                          [email protected]
                                          wrote on last edited by
                                          #93

                                          lmao.

                                          rust seems pretty desperate to remain relevant.

                                          "rust is replacing c"
                                          "rust is replacing the Linux kernel"
                                          "rust is replacing javascript"
                                          "rust is replacing your mom"

                                          A 1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups