Live data from Hacker News

What's New in C# 6.0 [video]

channel9.msdn.com

131–140 of 145 posts

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

#131
post #75

I think they missed a trick if the goal was to reduce boilerplate; which I'm all for, I'm very much moving away from C# to F# for this reason (and a few others). Why this: public int X { get; } public int Y { get; } = 5; And not this: public int X get; public int Y get = 5; The braces serve absolutely no purpose anymore, the semi-colon doesn't serve as a separator between statements. So why leave them?

For the second one you can write this: public int Y => 5;

It isn't the same. With immutable properties the constructor can change the value of Y based on its own decision logic. So 5 is just a default and the constructor may change it. That allows for multiple constructors, some that set the value some that don't.

If the value is always going to be 5, then use a const.

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

#132
post #2

You can also view a summary of the video/features as a presentation: https://view.officeapps.live.com/op/view.aspx?src=http%3a%2f...

Can't get past slide 4 (blue spinning ball on the cursor, yay Office Live). Anybody have a pdf version?

works perfectly fine on Chrome, IE, and Firefox.

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

#133
post #111

So these lines are now equivalent: public override string ToString() { return String.Format("({0}, {1})", X, Y); } public override string ToString() => "(\{X}, \{Y})" Could it go even further? This isn't paper after all, on screen why shouldn't it look like; public override string ToString() => "(X, Y)" where the X and Y are either slight italics or underlined or colored to indicate they mean X and Y the variable not…

IntelliJ has code folding that can display things using a less verbose syntax. For example, folding of closures (pre-Java 8):

http://blog.jetbrains.com/idea/2009/03/closure-folding-in-in...

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

#135
post #134

Still no first-class tuple support? Argh! All want is: var first, last = parseName(fullName); Instead of: String last; var first = parseName(fullName, out last);

i think it's because they rather have you pass in fullName string and get back a typed Name object instead.

that second example is always a bad choice and i would never but i do agree a little tuple support would be nice as a trap door kinda feature to avoid code like this

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

#136
post #111

So these lines are now equivalent: public override string ToString() { return String.Format("({0}, {1})", X, Y); } public override string ToString() => "(\{X}, \{Y})" Could it go even further? This isn't paper after all, on screen why shouldn't it look like; public override string ToString() => "(X, Y)" where the X and Y are either slight italics or underlined or colored to indicate they mean X and Y the variable not…

>where the X and Y are either slight italics or underlined or colored to indicate they mean X and Y the variable not X and Y the letters So what happens if you open the file in a different editor?

Why are we letting 50 year old technology constrain us? Why should we ever expect to edit code in a bare bones text editor? I'm not saying I like this particular idea but we shouldn't be held back by our technological history

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

#137
post #75

I think they missed a trick if the goal was to reduce boilerplate; which I'm all for, I'm very much moving away from C# to F# for this reason (and a few others). Why this: public int X { get; } public int Y { get; } = 5; And not this: public int X get; public int Y get = 5; The braces serve absolutely no purpose anymore, the semi-colon doesn't serve as a separator between statements. So why leave them?

I can comprehend braces faster than I can read the word "get". Sometimes structural code is useful as a navigation and comprehension aid. I've been doing a lot of python lately and I am much slower at scanning a file to find a piece of code or understand its structure precisely because everything is just words. This recent trend towards naive minimalism in language design is awful.

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

#138
post #134

Still no first-class tuple support? Argh! All want is: var first, last = parseName(fullName); Instead of: String last; var first = parseName(fullName, out last);

i think it's because they rather have you pass in fullName string and get back a typed Name object instead. that second example is always a bad choice and i would never but i do agree a little tuple support would be nice as a trap door kinda feature to avoid code like this

Having to create a class for everything is a chore, it doubles the amount of named things in the codebase. It also creates an undue discontinuity when moving from one returned value to two returned values during the process of codebase evolution.

Either first-class tuples or anonymous classes as return types would reduce this cognitive overhead.

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

#139
post #134

Still no first-class tuple support? Argh! All want is: var first, last = parseName(fullName); Instead of: String last; var first = parseName(fullName, out last);

Agree with the complaint but not the workaround; there is Tuple, after all, so maybe something like this?

   Tuple fullName = ParseName(fullName);
   var firstName = fullName.Item1;
   var lastName = fullName.Item2;

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

#140
post #134

Still no first-class tuple support? Argh! All want is: var first, last = parseName(fullName); Instead of: String last; var first = parseName(fullName, out last);

Totally agree on the need for tuple syntax (and pattern matching to make it really useful):

    return Tuple.Create(foo,bar);
Should be:

    return (foo,bar);
The worst part is using the Item1..ItemN properties. One way I've gotten around it is to create a Tuple extension method called Apply [1]. I allows you to do this:

    ParseName(fullName).Apply((first, last) => ... )
That allows for giving names to the tuple ItemX fields and uses them 'in scope'.

At least with C#6 we can now open static classes like namespaces and do something this:

    using Language.Helpers [2]

    ...

    return tuple(x,y);
Which already makes it start to feel like it's part of the language.

[1] https://gist.github.com/louthy/f4cee2524d0d049b4378

[2] https://gist.github.com/louthy/dc06868c446ed76f0d7a

Post reply on HN