Hacker News new | past | comments | ask | show | jobs | submit | page 2 login
What’s New in C# 7.0 (microsoft.com)
322 points by runesoerensen on Aug 25, 2016 | hide | past | web | favorite | 268 comments



Is 6.0 widely used in industry/open source?


25-strong dev team using C# 6 right now. Painless upgrade apart from a few pieces of legacy tooling. Some patterns haven't really been adopted much (e.g. exception filters). C# 7 looks like more of a leap but there's always an appetite to stay current in our team and I'm sure we'll take the plunge.


At my work I do a lot with 3.5 still. We need to upgrade our version of devexpress. More recent projects use MVC with .Net 4.0 or 4.5 (but our IT guy is nervous about installing such new runtimes on the servers that don't have 4.5 already..)

We use VS2012


You can easily use c# 6 with .NET 3.5. I know because we do!

You just need to upgrade VS to 2015. Language version has nothing to do with framework version!


Feel your pain. My work laptop has VS2012 on it.

Last year we were still targeting XP.


Noob question, why tuples? I mean why 3?


t doesn't mean three, it works with 2 or more.


Microsoft is mixing object oriented and functional in c#. This is not right, not only in case of Microsoft but also Python etc. They are fundamentally different and self-contained and need to be kept separate.


Unfortunately, C# can flail about adopting F# features yet the best feature of F# is something C# can never get:

Dependency Order Compilation


Except it does. And F# doesn't. F# just has in-order compilation. C# has an extra step to determine dependencies and compile them in dependency order.

The only thing for F# is that F# allows the user to determine the compilation order and show it in Visual Studio.


Sorry I wasn't clear, I meant in the following sense:

"One of the most common complaints about F# is that it requires code to be in dependency order."

In light of your statement I understand the way I put it made little sense.


Hi David, language designer here.

Can you give an example of where you'd want to take advantage of this in C#?

Thanks!


I don't understand the question, rather what's the point of it?


My instant concern: the variable names used by function declarations have become part of the API. If you use var to match the library producer's naming for tuple members, a rename of the variable in the definition will break your code, as the name you previously used will no longer exist!

Old example:

    bool Hello(string name) {...}
    var myName = "world";
    Hello(myName);
The developer can change the name of variables in the prototype to be more (or less!) descriptive without a problem - they're decoupled.

New example:

    (string interjection, string name) GenerateGreeting() {...}
    var greeting = Greeting();
    Console.Write("{0} {1}", interjection, name);
Now should the author change "interjection" to "greeting", _ your code won't compile _ and in a way that you likely didn't expect.


I assumed they are still decoupled and just shorthand for:

  string interjection;
  string name;
  (interjection, name) =  GenerateGreeting() {...}
I can't believe the C# team would introduce something so brittle into the language. If you're right, that a serious concern.


The names of the tuple field are a part of the method signature. Would you expect to be able to change other parts of the method signature, like the method name or argument types, and not have stuff break?

[edit] unless you're talking about how your example magically introduces "interjection" into the scope. That's not how it works. You would have to say "greeting.interjection". Or use the destruction syntax and say "var (ichosethis, andthis) = generateGreeting();", in which case its the order of the fields, not the name of them, that is important.


I think named tuple parameters only matters when not deconstructed, when deconstructed the position matter and you can choose your name. If you don't want to take that risk don't name your output parameters.

But that's the same as named parameter, and you didn't complained, if the client used named parameters and you change them it will break their code. The full signature of the method is the public API, as you can see when navigating a compiled assembly.


Agreed, I would much prefer something like:

(string first, string last) name = GetName();




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: