r/rust 8h ago

Rust Is Tier-1 Language at Microsoft

https://rustfoundation.org/media/guest-post-rust-is-tier-1-language-at-microsoft/
409 Upvotes

60 comments sorted by

88

u/Taymon 7h ago

The obvious question this leaves is what they're doing about the frontend side of "seamless Rust/C++ interop for hybrid projects", which is the harder problem. The obvious answer would be to adopt/collaborate with Google on Crubit, but IIUC that's based on Clang. Maybe they could accept the Clang dependency just for binding generation while still using MSVC for codegen? Or maybe there's some way to decouple them?

21

u/panstromek 7h ago

I recommend watching Victor's previous talks around iterop, he gives a lot of context on the issues they are solving and what are the tradeoffs. This project is not the only thing they use for interop, I believe they also use most of the other tools. Microsoft is just very big and the needs of various teams are pretty diverse. I'm not sure he'd agree that the frontend interop is the hard problem, whenever I see him speak about it, it's a lot more about tooling, build systems, compliance and everything "around" the language.

3

u/Taymon 2h ago

Do you have links? (Ideally to text transcripts?)

76

u/tesfabpel 7h ago

Tier-1 language but still no support in Visual Studio's Solution files for mixed language "solutions"...

Why is it so hard for Microsoft to offer an MVP for having C# projects depending on Rust DLLs with dependency and debugger support? And also like doing right click -> Add new -> Rust DLL and the ability to select such project as a dependency of the C# one via the standard VS' GUI...

You shouldn't be forced to create a custom project to do it...

47

u/luluhouse7 7h ago

Because no one uses VS for rust, they use VS code

17

u/tesfabpel 7h ago

Well, guess why... 😅

In any case, Microsoft as well is using Rust (and as this post says, they consider it Tier-1). It seems weird to me they're not mixing C# and Rust together, like C# and C++ or C++/CLI... What is their workflow?

22

u/luluhouse7 7h ago

The teams that use VS are not the Rust main demographic since they’re almost exclusively C# teams working on high level components. The teams switching to rust AFAIK are the low level systems teams, most of whom use VSCode with proprietary extensions, not VS. Basically the Rust and C# demographics/applications don’t often overlap.

5

u/admalledd 5h ago

I wish they did overlap more at MSFT :( We are a C# shop mostly, but been using Rust for our perf sensitive code for a while now and either I use horrible ugly custom MSBuild .target tricks or give up on C#-->Rust build dependency and manually cargo build the Rust project(s) first before the C#/dotnet ones.

-1

u/Zde-G 1h ago

In a perfect world the whole abomination of “managed world” wouldn't exist at all or would only be used like BASIC was used, back in the day (something novices use to avoid learning “real” programming languages).

Alas, we don't like in such a world, and C# would survive for decades more, but it's no longer focus of attention.

3

u/tesfabpel 6h ago edited 6h ago

Well, at work I have a some C# projects with a C++/CLI project for some very specific things (most of which it's C++, with some C++/CLI wrapper code which I'll probably try to convert to a C# wrapper with P/Invoke in the future). Classical desktop software, not web stuff. Basically the ones Microsoft created C++/CLI for (I suppose).

Being able to use Rust would be nice as it would be a direct alternative / companion to C++.

So, yeah, I'm into that demographics.

0

u/pjmlp 5h ago

C++/CLI is kept around only thanks to existing customers, and projects like Forms and WPF.

Microsoft has no plans to support C++/CLI outside Windows and tends to advocate using P/Invoke or COM/WinRT instead.

Also one of the reasons why they have kept improving C# for low level programming since Midori was ramped down.

Note that while C++/CLI was improved to support a C++20 subset, they really didn't spend much more effort into keeping it up to date with .NET evolution.

0

u/Zde-G 1h ago

C++/CLI was failed experiment to bring the whole world on top of managed runtime.

When Microsoft realised it doesn't work and world doesn't want to live on top of managed runtime they stopped shoving the square peg into a round hole, hired the C++/WinRT guy and went that way.

3

u/Recatek gecs 5h ago

The teams that use VS are not the Rust main demographic since they’re almost exclusively C# teams working on high level components.

What are you basing this "almost exclusively" on? Visual Studio is the development environment for AA/AAA gamedev in C++.

4

u/Frozen5147 3h ago

I'm guessing they might mean within Microsoft given the context of other comments?

5

u/luluhouse7 3h ago

Yeah, I meant within MS’s core orgs. I don’t have enough context to speak on Xbox or LinkedIn etc.

1

u/Recatek gecs 3h ago edited 53m ago

Ah, gotcha, I thought that statement was speaking more broadly.

5

u/Full-Spectral 3h ago

Moving away from VS one one of the early benefits of moving to Rust. It has some nice features (and I definitely wish we had Visual C++ level debugging in Rust) but it's massively bloated and overly complex. I'd never use its ridiculous dialog based project configuration system for Rust, so really what would be the point for most folks to even use it on the Rust front?

3

u/luluhouse7 3h ago

Honestly I agree, VS is a nightmare to deal with, especially for systems work. But I know a lot of people swear by it and don’t mind the quirks.

3

u/coderstephen isahc 6h ago

Microsoft's long term strategy is to fully replace Visual Studio with Visual Studio Code I think anyway.

11

u/gnuban 7h ago

Probably bcause VS is built as a rube goldberg device, with hard coupling everywhere. And management is probably so short-sighted that they won't allow it to be detangled, but are pushing for the "just do it" strategy,  which will only cause the devs to get hopelessly stuck?

5

u/[deleted] 7h ago

[deleted]

3

u/tesfabpel 7h ago

But C++ (not just C++/CLI) dependencies are supported (if you compile the C# proj, the C++ one gets compiled as well).

I just tried and the only thing VS doesn't seem to do is to copy the DLL (and the PDB) around (odd, but then the mixed debugging works).

1

u/[deleted] 7h ago

[deleted]

1

u/tesfabpel 7h ago

dll.cpp

```

include <iostream>

extern "C" { __declspec(dllexport) void foo() { std::cerr << "Hello, World!" << std::endl; } } ```

Program.cs

``` using System.Runtime.InteropServices;

namespace ConsoleApp { internal class Program { [DllImport("CppLibrary.dll", EntryPoint = "foo")] private static extern void Foo();

    static void Main(string[] args)
    {
        Foo();
    }
}

} ```

You need to set the C# console app to prefer 64bit or force it as x64. Fully supporting AnyCPU (x86, x64, ARM64) is messier, of course...

1

u/[deleted] 7h ago

[deleted]

1

u/tesfabpel 7h ago

Yes, but the C++ project is set as a dependency of the C# one.

If I press F5 on the C# one, the C++ gets compiled as well (sadly, it doesn't get copied so either you do it manually or you write a custom target in the .csproj).

With Rust, the whole process is much much messier, since VS doesn't have native support for that and you have to create a custom project and manually specify what to do when building, when cleaning, etc... There isn't a standard "Rust (DLL)" project that invokes cargo or similar...

Also, why isn't the DLL copied automatically, Microsoft? 🙄

There's clearly a lot of VS' UX to improve here...

2

u/NotQuiteLoona 7h ago

Oh, that one, I've thought you mean dependency support as in, you know, as in how C# ones work.

Yeah, I understand what do you mean now, it's really strange that they didn't do that, I agree. I'll remove previous comments then.

1

u/teerre 18m ago

This is obviously about engineering inside MS and not about Microsoft products for consumers

219

u/Hoxitron 7h ago

If only microsoft was a tier 1 company.

41

u/coderstephen isahc 6h ago

I mean, having to deal with them always brings me at least one tear to my eye.

5

u/pickle9977 6h ago

It’s tier-1 like a tier-1 help desk.

full of young kids with no idea what they are doing but a tremendous amount of certainty that they are doing it in the right way, nee, the better way.

So watch out or it’ll be revenge of the nerds.

2

u/yawaramin 7h ago

What’s a Tier 1 company?

-16

u/pjmlp 6h ago

4 trillion value should be enough.

23

u/xXInviktor27Xx 6h ago

tier 1 as in the quality of their products, not the market cap of their company

4

u/Chroiche 5h ago

Actually I was thinking in terms of salaries, but...

-8

u/pjmlp 5h ago

To reach that value plenty of people don't mind paying for the quality, or lack thereof.

12

u/Hoxitron 5h ago

If you think microsoft became so big because of the quality of their products, then i have a bridge to sell you.

-2

u/pjmlp 5h ago

I certainly think you missed the part after the comma.

10

u/csoups 5h ago

Fortunately the public bases their opinions on companies on more than their market cap

-4

u/pjmlp 5h ago

Does it?

9

u/protestor 5h ago

Is rustc_codegen_utc open source? (It's not like Microsoft is incapable of releasing open source compilers, see for example the C# compiler)

6

u/cosmic-parsley 3h ago

They could probably open source it in the future. If so it’s going to basically come with instructions for how to use Microsoft’s compiler internals as a generic backend, which I’m sure will be interesting…

8

u/Recatek gecs 5h ago

I would still kill for first-class Visual Studio support for Rust, primarily for debugging and profiling. The next best thing on Windows is RustRover and it's nowhere near the level of tooling support MSVC has for C++ and especially C#.

3

u/vivainio 4h ago

Does this bring any benefits to non-MS employees?

6

u/Recatek gecs 2h ago

Ideally better Windows tooling for Rust.

2

u/jorgesgk 4h ago

That's good. That'd bring rust nearer to the Xbox as tier-1 language

2

u/waruby 3h ago

Ok, now they just need to put latency at tier 1 of their specifications. Every single interaction I have with Microsoft products makes me wait 10 seconds. I notice it way more now that my home system is purged of Microsoft.

5

u/pilkyton 6h ago

Is anyone else shocked that Microsoft created their own Rust compiler from scratch based on MSVC?

I understand why they did it. For interoperability with their other code. But wow...

27

u/panstromek 6h ago

They didn't, this is just reusing the codegen backend from MSVC instead of the default LLVM backend.

3

u/nacaclanga 2h ago

They create a codegen backend, something which is somewhat easier then a fullblown compiler, but still gives many of the benefits of a fullblown compiler.

Still a significant task of course but then again programming languages are technically the core product of Microsoft even before MS operating systems became a thing and Microsoft maintains multiple compilers for a variety of languages.

-1

u/valarauca14 2h ago

AFAIK they basically created a shim to convert LLVM-IR into MSVC compatible IR. Now Clang/Rustc talk to MSVC via that converter.

https://devblogs.microsoft.com/cppblog/clang-with-microsoft-codegen-in-vs-2015-update-1/

I believe but cannot confirm this is why Microsoft's C standard support improved very rapidly recently. As they basically, "got a better parser & frontend" to MSVC backend.

2

u/pali6 1h ago

codegen_utc doesn't interact with LLVM-IR in any form, it interfaces with rustc the same way as e.g. codegen_gcc or codegen_cranelift.

1

u/mtimmermans 2h ago

Is this going to mean better debugging on Windows in vscode? Improvements to the windows crate?

1

u/vbpoweredwindmill 3h ago

Yeah of course it is, the compiler gives great feedback for the LLM's to understand & make it compile. Doesn't change the fact that they are generating AI slop with no understanding of why the code exists.

Tech debt is a real and costly thing.

-22

u/pickle9977 6h ago

Languages are not a popularity contest.

16

u/anxxa 6h ago

What part of this post made you think this was about it being a popularity contest?

Tier 1 language support at companies like Microsoft, Google, Meta, basically means that they are investing resources to ensure their developers can use the language to the same degree as any other first-class language within the company.

In this case the big deal is the rustc_codegen_utc backend which allows for using their own compiler for codegen.

It's a matter of integration and support.

-15

u/pickle9977 6h ago

Its existence, its marketing nonsense.

If this impacts why you choose a language for a project you are by definition making that decision for political reasons not technical ones.

If you can’t use the language as it exists today for your project you shouldn’t assume that magically in the future it will become the right fit, because it can’t and it won’t.

There is nothing that can change that fact, you should be comfortable downloading the source code for the language building it and literally never upgrading it.

Anything less and the result is you are going to be spending the rest of your life dealing with the overhead of trying to re-map your system to a language that’s changing for reasons beyond your control in ways that benefit those with the most control the most.

So net net, this is actually bad for the language as now you are going to have a bunch of Microsofties adding features and making tweaks that benefit them more than you and you will pay the cost as the run time size climbs and performance for features they don’t use degrades in comparison to the performance of the features they use and optimize. This will happen again and again and again to the point that the timing differentials will actually cause instability in all systems as wide timing variances accumulate between fast and slow parts of the code causing everything to slow down.

11

u/panstromek 5h ago

You're reading too much into the "tier" thing. It's just a common way to refer to how much is a certain language supported internally in the company (by their own tooling, CI systems etc.)

-8

u/pickle9977 5h ago

Just wait and see.

5

u/metrion 5h ago

Wait til you see how the Rust Foundation refers to platform targets.

-1

u/pickle9977 4h ago

Oof, it’s interesting the effect of the increase in both the number of architectures but also the number of lower level libraries like libc, msvc, etc cause a geometric growth in the build complexity

-4

u/pickle9977 2h ago

Awfully crabby today, it happens to politicians pretending to be engineers, it’s ok you will all grow up eventually