Become a fan of Slashdot on Facebook

 



Forgot your password?
typodupeerror
×
Programming Microsoft IT

Microsoft's Rust Experiments Are Going Well, But Some Features Are Missing (zdnet.com) 33

Microsoft gave a status update today on its experiments on using the Rust programming language instead of C and C++ to write Windows components. From a report: Microsoft began experimenting with Rust over the summer. The Redmond-based software giant said it was interested in Rust because, over the past decade, more than 70% of the security patches it shipped out fixed memory-related bugs, an issue that Rust was created to address.

[...] Today, almost four months later, we got the first feedback. "I've been tasked with an experimental rewrite of a low-level system component of the Windows codebase (sorry, we can't say which one yet)," said Adam Burch, Software Engineer at the Microsoft Hyper-V team, in a blog post today. "Though the project is not yet finished, I can say that my experience with Rust has been generally positive," Burch added. "In general, new components or existing components with clean interfaces will be the easiest to port to Rust," the Microsoft engineer said. However, not all things went smoothly. It would have been unrealistic if we expected they would. Burch cited the lack of safe transmutation, safe support for C style unions, fallible allocation, and a lack of support for at-scale unit testing, needed for Microsoft's sprawling code-testing infrastructure.

This discussion has been archived. No new comments can be posted.

Microsoft's Rust Experiments Are Going Well, But Some Features Are Missing

Comments Filter:
  • by jfdavis668 ( 1414919 ) on Thursday November 07, 2019 @10:14PM (#59392692)
    When all these west coast companies convert, we will have a new Rust belt.
  • by Dan East ( 318230 ) on Thursday November 07, 2019 @10:51PM (#59392782) Journal

    Burch cited the lack of safe transmutation, safe support for C style unions, fallible allocation

    Rust is missing these things compared to what? I didn't know any of that was "safe" in C or C++ in the first place.

    • by DarkOx ( 621550 )

      How do you make a UNION safe anyway? I guess you can do bounds checks like anything else but beyond that? I guess you could add a field or something to track which member was last used to write on the instance and error if someone tries to read a different member? Seems like a lot of complexity

      • The compiler is free to add metadata into your structure, but honestly the primary purpose of unions is to bash bits unmolested.
      • In C, a union is "safe" meaning that the way to access it is defined in advance,
        It's a fixed memory location (the union) which can be accessed as the exhaustive list of types which is set in advance (the member types listed in the union).
        It would be unlikely to accidentally access the wrong memory section or as an unexpected type.

        The "unsafe" C version would be using pointer math.
        The memory location being accessed with some generic pointer (say: void* ptr;) and using pointer cast to access it as other type

      • by DrXym ( 126579 )
        I suppose the compiler could track unions in some limited situations e.g. if the first use of the union references field foo then treat it as being that and throw errors if it is treated some other way. I don't know how it is supposed to do it at runtime.

        Perhaps that's all that is necessary. Rust has stupidly powerful enums which are good as unions at runtime.

        Rust also has some limited safe transmutation functions, e.g to turn numbers in and out of endian formats. But if you're transmuting some random b

    • C++ has std::variant [cppreference.com] which is a safe union. It remembers what kind of data it has and won't let you access the wrong one.
      For example:

      #include <variant>

      int main()
      {
      std::variant<int, float> v;
      v = 12; // v now contains an int
      int value = std::get<int>(v); // no problem
      float value2 = std::get<float>(v); // throws error, v contains an int
      }

    • Maybe he's just pointing out features he'd like to see added?
  • by DatbeDank ( 4580343 ) on Friday November 08, 2019 @01:27AM (#59393002)

    Really interesting read. I never knew about these considerations needed for coding in those different languages.

    I really like the Microsoft of the 2019s. It's matured quite a bit from a bombastic 90s demon to a surprisingly mature and yet innovative IBM like entity.

  • I enjoy hearing about every random thing Microsoft does, but wonder what they're doing to modernize the shitter. I look forward to hearing their experiences with different models, and the blow by blow of breaking in a new one on particularly trying projects like "Bad Burrito Night".

    • You're probably joking, but the Gates Foundation invests a lot of money in sanitation, including toilets, as part of the work to get clean water and eradicate waterborne diseases like cholera.

    • Don't know about you guys but I'm buying one of those $300 Toto systems that fit on a regular toilet. It's the good one with heated water and will go in my basement bathroom.

  • The only ones who think C-likes are superior, are those who never truly looked into anything more advanced.

    Which unfortunately, is the majority of grunts out there.

    Patching it up left and right, with tricks and grafting features onto it, will only result in either a Windows ME situation, or one of those advanced languages (like Haskell) that they shunned. Because guess what: That is that advanced part they were designed for! You're re-inventing the wheel. Badly. And with a butt-ugly syntax.

    • by gtall ( 79522 )

      Oh, you mean the world of programming grunts has refused to see better alternatives because they were too alternative? One doesn't turn an aircraft carrier around on a dime. And the syntax isn't any more butt-ugly that C's, hell it even copied most of C's.

    • by DrXym ( 126579 )
      Superior to what? More advanced? What are you even talking about?

      Rust isn't patched up C. The syntax has some C-like aspects for blocks and comments which makes it more familiar to people who may have used other languages like C, C++, JavaScript, Java, Swift, Go etc. That is a good thing.

      The language itself isn't C although it is a compiled language with similar runtime characteristics.

  • In general, new components or existing components with clean interfaces will be the easiest

    "In general" indeed! Just take out the part that specifically mentions porting to Rust, and it turns out these guys' project is exactly the same as everyone else's.

  • Rust was originally designed by Graydon Hoare at Mozilla Research, with contributions from Dave Herman, Brendan Eich, and others

    Brendan Eich formally of Mozilla before he was cancelled by the social justice fanatics.

"More software projects have gone awry for lack of calendar time than for all other causes combined." -- Fred Brooks, Jr., _The Mythical Man Month_

Working...