back to article Microsoft applies coat of Rust to Azure Sphere IoT platform

Developers can now use the Rust programming language when creating applications on Azure Sphere platform for internet-connected devices. Programmers can apply the performance and security capabilities within Rust to make software for Internet of Things devices and other embedded systems that can be the target of botnets and …

  1. cardich

    Possibly a new therapeutic approach

    Should we apply a protective coat of Rust on ourselves against cancer and other diseases?

  2. Dan 55 Silver badge

    "Forgot to initialize a variable? Nice explicit compiler errors!"

    You'd have to go a long way back to find a C compiler which didn't do that.

    1. FIA Silver badge

      Re: "Forgot to initialize a variable? Nice explicit compiler errors!"

      You'd have to go a long way back to find a C compiler which didn't do that.

      Hmmmm....

      $ cc -v

      FreeBSD clang version 14.0.5 (https://github.com/llvm/llvm-project.git llvmorg-14.0.5-0-gc12386ae247c)

      Target: x86_64-unknown-freebsd13.1

      Thread model: posix

      InstalledDir: /usr/bin

      $ echo -e "#include <stdio.h>"\\n"int main(void){ int c; printf(\"%d\\\n\",c); }" | cc -x c -o test -

      $ ./test

      0

      $

      vs...

      $ rustc -V

      rustc 1.66.0 (69f9c33d7 2022-12-12) (built from a source tarball)

      $ echo "fn main() { let c : i32; println"'!'"(\"c={c}\"); }" | rustc -o testrust -

      error[E0381]: used binding `c` isn't initialized

      --> <anon>:1:39

      |

      1 | fn main() { let c : i32; println!("c={c}"); }

      | - ^ `c` used here but it isn't initialized

      | |

      | binding declared here but left uninitialized

      |

      = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)

      help: consider assigning a value

      |

      1 | fn main() { let c : i32 = 0; println!("c={c}"); }

      | +++

      error: aborting due to previous error

      For more information about this error, try `rustc --explain E0381`.

      $

      1. Dan 55 Silver badge

        Re: "Forgot to initialize a variable? Nice explicit compiler errors!"

        Yes, OK, you can compile without e.g. "-Werror -Wall -Wextra -Wconversion" if you want to prove a point.

        1. FIA Silver badge

          Re: "Forgot to initialize a variable? Nice explicit compiler errors!"

          Yes, I can.

          And you won't know I've done it.

          That's the point.

          1. Dan 55 Silver badge

            Re: "Forgot to initialize a variable? Nice explicit compiler errors!"

            If a programmer can't even specify what errors they're interested in when compiling C (it's not difficult, just "you need to compile with this handful of flags which turns everything on), they're going to screw up in Rust as well. In spite of Rust's training wheels, they'll find a way.

            1. david 12 Silver badge

              Re: "Forgot to initialize a variable? Nice explicit compiler errors!"

              There's a difference between "must enable non-default warnings" and "won't compile unless error detection is disabled"

              It's the difference between open railway crossings and rail bridges.

              1. Dan 55 Silver badge

                Re: "Forgot to initialize a variable? Nice explicit compiler errors!"

                That's what the -Werror option does - treat warnings as errors.

            2. FIA Silver badge

              Re: "Forgot to initialize a variable? Nice explicit compiler errors!"

              Yes, they will. The rust documentation even covers some of the ways you can screw up despite it's guards.

              But they won't accidentally make a whole class of errors because the language prevents it.

              Also, it doesn't stop C existing. You can still program in C if you want. I do, it's my language of choice for my home projects because I've been programming it for years. But I still make mistakes, I still occaionally use a pointer after freeing it. Sure, the warnings help, but they don't prevent the errors happening. And probably more importantly; I've not encountered it as a professional programming language in 20 years as I work in the world of business apps, not embedded systems. (The company I work for does make hardware too, but even that is running vue.js for it's UI).

              Don't look at them as 'training wheels', that frames it as something that real programmers won't need, once they learn how to 'really program'. This is daft, programming languages are just tools. Computers these days are fantastically more powerful than they were when C was invented, why wouldn't we use that, and the lessons learnt from languages like C to improve programming languages in general?

              I used to think C was for 'real programmers' and other 'lesser' languages were for people who didn't really know how to program, and I was content in my arrogence. Meanwhile all the other people were just getting on with writing useful programs in other languages, as at the end of the day the language is just a tool to get a job done.

POST COMMENT House rules

Not a member of The Register? Create a new account here.

  • Enter your comment

  • Add an icon

Anonymous cowards cannot choose their icon

Other stories you might like