Live data from Hacker News

What's New in C# 6.0 [video]

channel9.msdn.com

31–40 of 145 posts

Re: What's New in C# 6.0 [video]

#31
post #26

Using static classes as namespaces addresses something I was just complaining about a week ago. Let's take it a step further! Just let us put bare functions in namespaces without the dance of the static class.

>Let's take it a step further! Just let us put bare functions in namespaces without the dance of the static class. No. C# is an object-oriented language. It doesn't have functions, it has methods. Methods are always attached to a class. Even anonymous methods (lambdas) are compiled to be a method on a class (like c__DisplayClass1). "Bare" or "global" functions have no place in C#.

If you think that way, then C# left you behind a long time ago. Because if functions had no place in C#, then there would be no static classes in the first place. The static class is nothing more papering over object oriented bureaucracy that "everything is an object" to provide functions. And using a static class as a namespace furthers that.

I get that the CLR expects a certain way of implementing things. But your own example of Lambdas are an excellent example of how we can use syntax to overcome bureaucracy in the runtime, or else we would be stuck in Java land with anonymous classes implementing interfaces.

Ultimately, it's all sugar. If a static method of a static class can be made to look like a function in calling code, then it makes sense to make it look like a function in the definition.

Re: What's New in C# 6.0 [video]

#32
post #22

I love the new read-only auto properties. 90% of the objects I write are immutable and it's a pain to declare all those private readonly backing fields just to return them in getters.

Agreed, I hardly ever used auto-implemented properties for that reason. But, Is the backing field for a read-only auto-property still readonly (i.e. only assignable from within a constructor body)?

Re: What's New in C# 6.0 [video]

#34
post #9

The null-conditional operators and string interpolation are really cool. I don't use C# anymore (job change, not out of dislike), but I was always really happy working in it. I'm still not a huge fan of Windows, but C# is a wonderful language.

I wonder how string interpolation interacts with translation though? I thought the whole idea of the numbered placeholders was so that you could translate the string and rearrange them for different languages. Now do your translators have to be careful not to break your code if they're editing it as part of the string?

Re: What's New in C# 6.0 [video]

#35
post #30

It all looks really promising. Love it. I'm a little worried about "nameof" in the hand of amateur programmers though. Efficiency aside (because it's not efficient), code readability might take a hit.

Good for reflection and renames. ReSharper helps but I don't want to rely on it.

Re: What's New in C# 6.0 [video]

#36
post #9

The null-conditional operators and string interpolation are really cool. I don't use C# anymore (job change, not out of dislike), but I was always really happy working in it. I'm still not a huge fan of Windows, but C# is a wonderful language.

I wonder how string interpolation interacts with translation though? I thought the whole idea of the numbered placeholders was so that you could translate the string and rearrange them for different languages. Now do your translators have to be careful not to break your code if they're editing it as part of the string?

That's a good point. I imagine it will require consideration by the developer/architect of how to handle internationalization. It may be that you don't want to use string-interpolation for any strings that require translation.

Re: What's New in C# 6.0 [video]

#37
post #13

I'm going to take some hits for that but... with .NET being open source (never liked Mono..) and all.. I'm tempted to use C# in the future again. Using it on Windows has always been good - and now that it compiles to native code too and that the libs are open....

I thought that native compilation was only for "Windows Store" apps. Do they now have that available for regular Windows desktop apps too (or more importantly, server-side Linux apps)?

Xamarin for iOS compiles to native as far as I am aware.

Re: What's New in C# 6.0 [video]

#38

Interestingly, if you'd like to check out how some of these features were implemented, you totally can. Roslyn is open-source ( http://roslyn.codeplex.com/ ). That being said, I hope that all the open-sourcing is going to make it available where I really want to use it - Unity, for instance. (Disclaimer: I'm an open source dev @ Microsoft)

I was hoping Unity would start loosing some market due to outdated Mono. I guess we are in for another github-like "monopoly".

Re: What's New in C# 6.0 [video]

#39
post #18

While all of the changes look nice in terms of writing less code, they are the kind of syntactic sugar I learned to hate in CoffeeScript. Mostly because the code was so much denser and harder to read. Especially when reading other people's code. As I write more and more code, the more I want simplicity and ease of understanding over typing a few less characters or having more elegant code.

Don't even try F# then :). Syntax is terse, but so academically alien.

Re: What's New in C# 6.0 [video]

#40
post #26

Earlier quoted context omitted.

>Let's take it a step further! Just let us put bare functions in namespaces without the dance of the static class. No. C# is an object-oriented language. It doesn't have functions, it has methods. Methods are always attached to a class. Even anonymous methods (lambdas) are compiled to be a method on a class (like c__DisplayClass1). "Bare" or "global" functions have no place in C#.

If you think that way, then C# left you behind a long time ago. Because if functions had no place in C#, then there would be no static classes in the first place. The static class is nothing more papering over object oriented bureaucracy that "everything is an object" to provide functions. And using a static class as a namespace furthers that. I get that the CLR expects a certain way of implementing things. But your…

> The static class is nothing more papering over object oriented bureaucracy that "everything is an object" to provide functions.

Classes (in typical static, class-based "OO" languages like C++/Java/C#) aren't objects, and static classes are classes that don't even relate to objects the way that "normal" classes do. Static classes as containers for functions aren't papering over object-oriented bureaucracy that "everything is an object", they are papering over class-oriented bureaucracy that "everything is connected to a class".

(This is a general agreement with your basic point, though.)

Post reply on HN