Thursday, May 22, 2014

C# 6.0 Do I need it?

If you haven't gone through the list of changes in C# 6.0, please take a look at this MSDN post

In my opinion there is no real need for me to jump to C# 6.0. Unlike other C# releases, with this release Microsoft hasn't made any significant changes. I believe there is a reason for this. Microsoft and C# team really focused on the Roslyn compiler initiative and didn't have much time for this version. I feel they should have versioned this as C# 5.1 and not C# 6.0.

Anyway of the new changes the one thing I liked very much is the Exception-Handling improvements. This functionality currently does not exist and would help to catch a precise exception. Apart from this rest of features are syntactic sugar and in some cases makes the code sloppy.

Here is my take on these other new features:

Indexed Members and Element Initializers - This feature seems interesting and will help reducing the code. But somehow I don't like the $ keyword for wrapping my strings to objects. The good news is now we got $ in C# code :)

Auto-Properties with Initializers - I liked this syntactic sugar and will use from day one. This eliminates the need for a constructor to initialize my properties

Primary Constructors - This syntactic sugar is very confusing. I see how this reduces my code, but also adds confusion. I will be little bit hesitant to use this feature at the onset.

Static Using Statements - Another syntactic sugar, I am not excited about. I believe this leads to sloppy coding. On average a typically developer productivity is 25 to 50 lines code per day. I don't mind few additional key stokes if I can make my code more readable.

Declaration Expressions - Again I feel that this feature also promotes sloppiness and confuses developers. I am currently happy without this feature.

Binary Literals - Well this is an interesting feature and may help in code readability. I didn't see much use of this in my existing projects other than the binary flags mentioned in the MSDN blog.

As you see most of the syntactic sugars above does not add a great value and some may even confuse you. If you read the comments in the MSDN blog, most of the developers are not happy with these syntactic sugars. I feel that a language should be simple without too many bells and whistles.

Hence I am not excited with the new features of C# 6.0. But I am super excited with the Roslyn and open sourcing .NET.

1 comment: