Blog CSHARK

IT Ocean blog

Blog subscription

17/12/18

Is There A Revolution Coming To C# And .NET in 2019?

Is There A Revolution Coming To C# And .NET in 2019?

If you are a young software developer and on the brink of deciding what avenue to pursue in IT, be sure about two guaranteed things – taxes and a constant need for learning, forced by constant changes in programming languages. A lot of people have tried to fight taxes (few even ran from them for a moment) but there’s no single case of a man trying to withhold the development of his technology to have more time. It can’t be done. We are rapidly approaching 2019 and every developer has to ask himself or herself one important question: what’s new and what will I have to learn?

C# 8

Developed since 1999 by Anders Hejlsberg, emerged as a response for a need of new programming languages at the end of the ‘90s, when development of IT as an industry gained traction and turned into a well-oiled machine that we see today. It’s hard to believe that after 19 years .NET developers will have the 8th iteration of this complete and high object language at their disposal. Similar to previous editions, Microsoft has prepared a lot of new functionalities that should ease our daily work with the code. Among them we can find:

Nullable reference types

Null has taken its toll on misfortunate developers, “I call it my billion-dollar mistake” – says Tony Hoare, inventor of null reference. C# team decides to hop on the “no null allowed” train, sitting next to Kotlin and Typescript, and introduces nullable reference types. Similar to its nullable value types counterpart (denoted by question mark or “Nullable” structure) it allows to explicitly say some value can contain null, like string? or object? - at the same time it prohibits null from getting into regular types like string or object. This will allow developers to get rid of famous NullReferenceException completely! Using a value that may contain null will now result in a warning, this can be fixed by introducing null checks or suppressed by prepending dot with an exclamation mark. This should not only make code safer, but also reduce number of if statements, as checking for null once and passing forward as non-nullable is enough for the compiler.

A default interface implementation

This change perfectly shows that developers like to be inspired by the solutions proven by the competition, for the default implementation inside the interface is something that Java enthusiasts have been using since 2015, alongside with Java 8 launch.

This new and powerful addition enables an extension of already existing classes without the necessity to duplicate the code while adding new interface methods. In the near future, if the developer will like to expand one of many interfaces in the project that is inherited by the countless number of classes, he won’t be forced to implement methods that expand the interface for every linked object. It’s probably one of the most interesting changes that brings C# 8.

New types: Index and Range

Afrer another set of inspirations, this time coming straight from Python, Microsoft decided on bringing two types – Index and Range. Both of them will be helpful when working with indexes in array. Starting from 2019 there won’t be a need of worrying about mistakes in selection and editing various array elements, because in a convenient way, by using Index, user will be able to point to a specific element in array, by order number. It wouldn’t be so shocking if not for the simple addition called the ‘^’ operator which allows for picking elements starting from the end of the array.

The second type, Range, is for choosing a subgroup of elements from the chosen array, using only the indexes numbers.

During the announcement of Index and Range I had one and returning question: why so late? Maybe they do not present a revolution to work with array, but it’s important enough to be happy about and it certainly will make some daily routines easier. Working with a source code when working on an application will be simpler.

Async streams

Adding a new interface of the collection IAsyncEnumerable will ease the work on data streams. It’s a great feature for every specialist working on the Internet of Things (IoT) or cloud computing. It works similarly to collection interface IEnumerable which is based on and in a manner of speaking, we can call this C# 8 addition an asynchronic variation of IEnumerable. It’s hard to speak about the utility of this new feature but there are chances for a large group of devoted fans in the near future.

Recursive pattern matching

One of the most interesting changes in C# 8 is an expansion of pattern matching, added in the previous version of the language. Starting from 2019 there will be a possibility for nesting another pattern matching in your content; it will be called a recursive pattern matching. It shouldn’t be a surprise for anyone, using this popular feature allows for the clarity of the code. With its tight rules of engagement the pattern matching itself proved to be very useful. It allows for skipping a never ending list of ‘if and that works for the code quality. Adding more functionality to the pattern will further advance C# as a language.

.NET Core 3.0

In the near future .NET Core will totally replace .NET Standard. It seems that announced in May 2018, a new version should help in the development of desktop applications within the Windows environment and allow for easy translation of already existing applications from .NET Standard to .NET Core. New information about this framework should be available at the beginning of 2019.

The second announced change in .NET Core 3.0 is a brand new approach to managing and development of project files in solution. Currently there are no further information on the topic, we have to wait beyond Valentine’s Day.

.NET Framework 4.8

Announced with .NET Core 3.0 a new and supposedly better version of .NET Framework didn’t receive that much of improvement, at least for now. The main differences should lie in perfecting Windows Forms Accessibility, adding SelectionTextBrush, better performance of ZLib and better overall performance of the entire framework itself. Microsoft also announced that they weren’t able to add all projected features and eliminate all remaining bugs. They should however be added and removed in the near feature.

Summary

After a solid research about upcoming changes to C# and .NET I can say that the next year won’t present itself as a period full of sleepless nights and oceans of coffee. Microsoft is betting on evolution not revolution. With features and changes developed for desktop, web and mobile applications, Microsoft wants to not only add fuel to already existing solutions but also to create them. Without a special spark, though.