• Venator@lemmy.nz
        link
        fedilink
        arrow-up
        10
        arrow-down
        3
        ·
        11 months ago

        Ease of access to the underlying hardware in your programming language is only ever needed for embedded programming in the current year. Change my mind.

        • ShortN0te@lemmy.ml
          link
          fedilink
          arrow-up
          9
          ·
          11 months ago

          There are actual use cases where direct memory access and pointer magic can be very efficient or almost necessary. We work a lot with large images and basically always the first steps are some pointer operations.

        • davel [he/him]@lemmy.ml
          link
          fedilink
          English
          arrow-up
          6
          ·
          edit-2
          11 months ago

          Every operating system running on bare metal needs access to the hardware. And if not on bare metal, it needs access to the virtual hardware.

      • ShortN0te@lemmy.ml
        link
        fedilink
        arrow-up
        10
        arrow-down
        4
        ·
        11 months ago

        Exactly for that a memory safe language would avoid so many security vulnerabilities.

      • umulu@lemmy.world
        link
        fedilink
        arrow-up
        6
        ·
        11 months ago

        Even for small 4/8 bit soc systems?

        I had the idea that C was the go-to language for that.

        • Jordan_U@lemmy.ml
          link
          fedilink
          arrow-up
          2
          ·
          11 months ago

          Yes: https://github.com/avr-rust

          When you’re writing code involving global state and interrupts, and any access to an integer larger than a u8 needs to be surrounded by cli() and sei() just for guaranteed atomicity, then you will truly come to value rust’s statically enforced thread / memory safety.

        • fl42v@lemmy.ml
          link
          fedilink
          arrow-up
          2
          ·
          edit-2
          11 months ago

          Are those still in use? With how cheap modern MCUs got, it kinda seems like it often makes more sense to get smth a bit more powerful and get the benefits of overall easier and faster development. May be wrong here, tho – it’s not like I compared numbers or something

          Addit: I mean, 8 bit may easily still be a bit cheaper, yet corps will likely spend more than the difference in price paying devs

    • Jordan_U@lemmy.ml
      link
      fedilink
      arrow-up
      2
      ·
      11 months ago

      For years I wrote embedded C for 8 bit microcontrollers used in industrial controls.

      Never again.

      Rust is by far a better language for embedded. The only times I would consider it reasonable to write embedded code in C is if you’re doing it for fun, or you depend on an existing and well tested / audited codebase or library and your application logic is less complicated than rust to C FFI.

      Even then, you won’t find me contributing to that effort.

    • frezik@midwest.social
      link
      fedilink
      arrow-up
      1
      ·
      11 months ago

      Rust is making inroads.

      Or micropython. That might sound nuts, but consider that Python was released two years after the 486 and two years before the Pentium. The RP2040 microcontroller has a far higher clock rate than those, has dual cores, and costs a dollar. It may lack RAM compared to some of those desktops at the time, though.