News: 1628756946

  ARM Give a man a fire and he's warm for a day, but set fire to him and he's warm for the rest of his life (Terry Pratchett, Jingo)

Microsoft emits last preview of .NET 6 and C# 10, but is C# becoming as complex as C++?

(2021/08/12)


Microsoft has released preview 7 of its .NET 6 developer platform and declared new features "done" ahead of an expected arrival for this long-term support version in November.

The current version, .NET 5.0, is only supported until May 2022, whereas .NET 6.0 will have a lifetime of three years. Even three years is not very long; Microsoft [1]described this as a "modern lifecycle."

Even so, .NET 6.0 is a significant release and the first LTS (long-term support) iteration of Microsoft's unified .NET platform, which is intended to replace both .NET Framework (now legacy) and .NET Core.

[2]

The latest preview came with a raft of Microsoft developer news, including Visual Studio 2022 Preview 3, .NET MAUI (Multi-platform App UI) preview 7 – which replaces Xamarin for cross-platform mobile projects – and updates to ASP.NET Core.

[3]

[4]

Just to add to the usual .NET confusion, principal program manager Richard Lander [5]said .NET 6.0 will include preview features that are not supported for production. For .NET 6, "we've built the capability to mark APIs as 'in preview'," he said.

These are opt in, using an EnablePreviewFeatures project property and a reference to System.Runtime.Experimental. The features are likely to get breaking changes, so only for testing and experimentation.

[6]

Features in preview include static abstract interface members (including operators), which Lander said was "perhaps the most important new type system capability since Span<T>." The feature is described in detail [7]here , under the heading Generic Math, where software engineer Tanner Gooding explained: "You can now declare interface members that are simultaneously static and abstract." This enables what he said was a long-requested feature in .NET, "the ability to use operators on generic types."

"Welcomed feature," [8]said one developer , though they added: "Slowly I don't know any longer if I am on C# or C++".

[9]Stack Overflow survey: Microsoft IDEs dominate, GCP and Azure battle behind AWS

[10]The framework that will not die: Microsoft gives Web Forms designer fresh lick of paint in Visual Studio 2022

[11]Microsoft previews Hot Reload for .NET developers, sets date for .NET 6

[12]Microsoft: Try to break our first preview of 64-bit Visual Studio – go on, we dare you

As if to reinforce this comment, Lander said that .NET 6.0 is adding new native memory allocation APIs, "exposed via System.Runtime.InteropServices.NativeMemory," which are equivalent to the malloc, free, realloc and calloc C APIs.

Originally C# was designed to be a safe language, not vulnerable to bugs like buffer overflows or use of unallocated memory, though it was always possible to bypass this by using native interop or code marked as unsafe. Lander said that these new APIs are "intended for low-level code and algorithms. Application developers would rarely if ever use these."

Versions of C#, the primary language of .NET, align with new releases of the runtime. C# 9.0 arrived with .NET 5.0, while C# 10.0 will be in .NET 6.0. Preview features like static abstract interface members are presumably under consideration for C# 11.0, though currently [13]listed simply as for "C# 10 Preview".

[14]

A small detail in .NET 6.0 that will be welcomed by those targeting Linux is that the ZipFile class now captures and respects Unix file permissions.

ASP.NET Core has a [15]bunch of new features including HTTP/3 or QUIC support in Kestrel, the built-in .NET web server, and new support in Blazor (.NET that runs in the browser) for streaming data from JavaScript to .NET.

One consequence is that Blazor can upload files larger than 2GB. Blazor's ability to modify HTML elements has also been enhanced, with code now able to set the page title and add meta elements to the HTML Head element.

.NET MAUI is getting [16]new layouts – Grid, FlexLayout, and StackLayout – to replace the old Xamarin layouts. Another change is font scaling by default across all platforms.

Visual Studio has also been updated, with preview 3 of the forthcoming Visual Studio 2022 adding a new project properties designer, improved dark theme, and new project types to support React and Vue.js using TypeScript or JavaScript. Another new feature is the ability to work with multiple Git repositories in a single solution, a pain point for developers who find themselves in this scenario.

Visual Studio 2019 is also getting an update, to 16.11, which senior program manager Mads Kristensen [17]said is the last baseline update. Therefore, "we encourage Enterprise and Professional customers to standardize on Visual Studio 2019 16.11," he said. New features include hot reload (see the output from code changes on the fly) for .NET applications, improved Git tooling, and update of the Clang/LLVM toolchain to version 12.®

Get our [18]Tech Resources



[1] https://devblogs.microsoft.com/dotnet/net-core-releases-and-support/

[2] https://pubads.g.doubleclick.net/gampad/jump?co=1&iu=/6978/reg_software/front&sz=300x50%7C300x100%7C300x250%7C300x251%7C300x252%7C300x600%7C300x601&tile=2&c=2YRTxXTmrCAp64oWaTBaGZgAAABE&t=ct%3Dns%26unitnum%3D2%26raptor%3Dcondor%26pos%3Dtop%26test%3D0

[3] https://pubads.g.doubleclick.net/gampad/jump?co=1&iu=/6978/reg_software/front&sz=300x50%7C300x100%7C300x250%7C300x251%7C300x252%7C300x600%7C300x601&tile=4&c=44YRTxXTmrCAp64oWaTBaGZgAAABE&t=ct%3Dns%26unitnum%3D4%26raptor%3Dfalcon%26pos%3Dmid%26test%3D0

[4] https://pubads.g.doubleclick.net/gampad/jump?co=1&iu=/6978/reg_software/front&sz=300x50%7C300x100%7C300x250%7C300x251%7C300x252%7C300x600%7C300x601&tile=3&c=33YRTxXTmrCAp64oWaTBaGZgAAABE&t=ct%3Dns%26unitnum%3D3%26raptor%3Deagle%26pos%3Dmid%26test%3D0

[5] https://devblogs.microsoft.com/dotnet/announcing-net-6-preview-7/

[6] https://pubads.g.doubleclick.net/gampad/jump?co=1&iu=/6978/reg_software/front&sz=300x50%7C300x100%7C300x250%7C300x251%7C300x252%7C300x600%7C300x601&tile=4&c=44YRTxXTmrCAp64oWaTBaGZgAAABE&t=ct%3Dns%26unitnum%3D4%26raptor%3Dfalcon%26pos%3Dmid%26test%3D0

[7] https://devblogs.microsoft.com/dotnet/preview-features-in-net-6-generic-math/

[8] https://devblogs.microsoft.com/dotnet/preview-features-in-net-6-generic-math/#comment-9916

[9] https://www.theregister.com/2021/08/03/stackoverflow_developer_survey/

[10] https://www.theregister.com/2021/07/19/web_forms_designer_visual_studio/

[11] https://www.theregister.com/2021/05/27/microsoft_previews_hot_reload_for/

[12] https://www.theregister.com/2021/06/18/vs_2022/

[13] https://github.com/dotnet/roslyn/blob/main/docs/Language%20Feature%20Status.md

[14] https://pubads.g.doubleclick.net/gampad/jump?co=1&iu=/6978/reg_software/front&sz=300x50%7C300x100%7C300x250%7C300x251%7C300x252%7C300x600%7C300x601&tile=3&c=33YRTxXTmrCAp64oWaTBaGZgAAABE&t=ct%3Dns%26unitnum%3D3%26raptor%3Deagle%26pos%3Dmid%26test%3D0

[15] https://devblogs.microsoft.com/aspnet/asp-net-core-updates-in-net-6-preview-7/

[16] https://devblogs.microsoft.com/dotnet/announcing-net-maui-preview-7/

[17] https://devblogs.microsoft.com/visualstudio/visual-studio-16-11/

[18] https://whitepapers.theregister.com/



"the ability to use operators on generic types."

Pascal Monett

Generic types.

I will likely be downvoted to hell on this, but IMO generic types are the bane of proper programming.

If you don't know what you're working with, how can you possibly write the proper code to deal with it ?

Obviously, I am for strong variable typing (in case you didn't guess). I like to know that I'm dealing with a String, or an Integer, or a Long. Variant makes my skin crawl, although there are some cases where I know I won't be able to avoid it.

Generic types is just handing over all the issues to the compiler and hoping for the best. That is not good when you're responsible for your code.

There, that was my 2 cents. Blast away.

Re: "the ability to use operators on generic types."

karlkarl

Whilst I do kind of agree, they do solve a number of challenges and the alternative of classic MACRO's isn't quite as good.

Re: "the ability to use operators on generic types."

Loyal Commenter

The alternative, in a lot of use cases, to using generics, is to have multiple versions of the same code, for example, once for each type that needs it. Repeated code is definitely a code smell.

For example, take the List class. Would you rather the language had a List, with one implementation, or one class for every built-in type, such as ListOfInt, ListOfFloat, ListOfString. What about if you want a list of lists? Does the language need to define ListOfListOfInt rather than just allowing you to use List>? What about if you want to have a list of your own classes, Foo and Bar, do you want to have to write the boilerplate code yourself for ListOfFoo and ListOfBar? It's a no-brainer that the List class is defined once, has one implementation, and behaves in the the same way whichever T you use it with.

Generics are a powerful, and pretty obviously needed, tool in the programmer's arsenal. I think you may be making the mistake of thinking that they somehow erode type safety, but if you were going to try to add a string to a list of integers, you'd get a compile error. Whilst the definition of List might be generic, the implementation in the consuming code which might use List very much is not.

On the other hand, if you were to use a List, to circumvent the compiler's type checking, then you need your head boiled.

karlkarl

CSharp.NET is basically as complex as Java in both language and VM infrastructure (I shudder at the thought of having to port the JVM or CLR to a different platform). This is by design because CSharp.NET is pretty much a failed attempt at EEE on Java.

C++ is a fairly complex language but since there is no VM layer of complexity to deal with, overall it is a simpler technology.

In my old age, I really do prefer C. I saw a recent video by Stroustrup discussing an "elegant" program and it really was just all templates with very little logic. I did not find it elegant at all and realized C++ was going in a very different direction to what I really want.

I "think" I just want the RAII and safety but I am not prepared for any of the other baggage that comes with it. As for CSharp.NET... no thanks. I don't like writing bindings to technology I actually use.

Static abstract interface members

fattybacon

I enjoyed the sample code a little too much for I am nought but a child.

IP-arse-able

Is it weird in here, or is it just me?
-- Steven Wright