r/cpp • • Sep 17 '22

Cppfront: Herb Sutter's personal experimental C++ Syntax 2 -> Syntax 1 compiler

https://github.com/hsutter/cppfront
335 Upvotes

360 comments sorted by

View all comments

3

u/a_false_vacuum Sep 17 '22

This talk of a memory safe C++ makes me think of C++ CLI (or C++.NET as it was called before) by Microsoft. You got C++ but the resource management was done by the .NET Framework CLR. The few times I used C++/CLI was as glue so C# code could use a C++ library.

C++/CLI is still present in Visual Studio 2022, but I'm curious how many people use it.

1

u/pjmlp Sep 18 '22

Exactly for that purpose, it is easier for glue code than guessing P/Invoke annotations.

However given it is Windows only, its use is now frowned upon for crossplatform .NET code.

3

u/a_false_vacuum Sep 18 '22

From the looks of things Microsoft now just maintains C++/CLI but doesn't add to it anymore. Hence it being stuck on .NET Framework.

I wonder how much effort it would take for Microsoft to get this working on the new .NET CLR to make it multiplatform. With memory safe C++ or C++ alternatives being so in vogue these days it could be worth it to Microsoft to have their own alternative to Carbon and Rust.

3

u/pjmlp Sep 18 '22

It is not stuck on .NET Framework, in fact it was a crucial milestone for .NET Core 3.1 and has been updated to C++17.

It just isn't available outside Windows.

So far the approach has been to improve low level C# capabilities to use the same kind of CLR features that only C++/CLI could use, thus taking C++ out of the picture altogether, including the runtime. With every .NET Core release there is new bunch of code that moves from C++ into C#, as described on performance improvements blog posts.

1

u/christian_regin Sep 20 '22

If only C# added RAII then it might be a decent language.

1

u/pjmlp Sep 21 '22

You have using for Dispose as pseudo destructor, then enable one of the Rosyln analysers that break the build when you forget to make use of it.

CA2000: Dispose objects before losing scope

→ More replies (4)