Live data from Hacker News

What’s New in C# 7.0

blogs.msdn.microsoft.com

81–90 of 278 posts

Re: What’s New in C# 7.0

#81
post #38

Earlier quoted context omitted.

Feels kinda crazy to see tuples and pattern matching "just arrive" when other languages have had them for years.

There was always the Tuple class you could use since .Net 4. https://msdn.microsoft.com/en-us/library/system.tuple(v=vs.1...

There's a few downsides to the Tuple class as mentioned here: https://github.com/dotnet/roslyn/issues/347

Namely, heap allocation and the inability to name tuple members.

Re: What’s New in C# 7.0

#82
post #2

Out variables seem like a mis-feature, especially when they are adding a better alternative (Tuples) in the same release. It's great to finally have tuples, but the c/java style syntax is showing it's age compared to something like scala which has return type declarations at the end, which I find much more readable. Literal improvements will be a godsend for writing database migrations. Ref returns and locals look li…

Hey there, C# language designer here. > Out variables seem like a mis-feature, especially when they are adding a better alternative (Tuples) in the same release. Out variables are really great when working with existing code that predates Tuples (for example, the entire BCL). We don't just introduce language features that will only work well for new code. We also want to make the experience of coding against existing…

Did you guys look into alternative syntax for return types? It really is a huge eyesore, and impediment to reading, when you have more than just a typename and a couple of modifiers like * and [] attached to it.

With tuples especially, it's even worse, because the method name gets squished between two very similarly looking ()s, which is very different from how methods have historically looked in code. If I were scanning code fast, I'm not sure I would even read it as a function declaration.

C++ adopted its "auto ... -> ..." syntax a while ago - granted, they had a forcing function in form of decltype(), but many people also use it for readability reasons with complex return types. I hope C# follows suit; or, better yet, comes up with a unified type-after-name syntax a la ES6, that can be used everywhere in the language, while retaining existing syntax for back-compat purposes.

Re: What’s New in C# 7.0

#83
post #72
post #65

Is 6.0 widely used in industry/open source?

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!

Re: What’s New in C# 7.0

#84
post #80
post #23

I wish they did not call it pattern matching. Instead this is more like Destructuring combined with Switch. the guarantees are different

If you look at the original specs on Roslyn GitHub, it started as a more generalized extensible pattern matching system (tying into destructuring). I would imagine that this is still in the plans, but it just didn't fit into this version.

yes I'm aware and participated in some of the discussions.

Re: What’s New in C# 7.0

#85
post #76
post #66

Earlier quoted context omitted.

> That 'headache' has to be weighed against the needs of some parties to write very fast code and to have as little overhead as possible. ref returns enables a much more pleasant coding experience that enables these sorts of speedups in these specialized scenarios. I'm worried this could result in a loss of focus, you can't make everyone happy all the time. c# is a fantastic language to develop applications in (web o…

The Midori project proved otherwise. One of the reasons we are stuck with C and C++ is because other language vendors, including Microsoft, dropped the ball regarding performance of type safe languages. Do you think C++ would have been kept around if Java and the CLR had been AOT compiled to native code with focus on compiler optimisations since day one? I really appreciate the efforts of the .NET team in adopting th…

Some things can be rather tricky to AOT-compile, especially when you don't have a fixed "world" (i.e. when code can be dynamically loaded, as is the case with both Java classes and CLR assemblies).

Consider virtual generic methods, for example. If your set of types is not statically bound, you can't allocate the appropriate number of vtable slots in advance, because you don't know all the instantiations.

Re: What’s New in C# 7.0

#86

Earlier quoted context omitted.

Feels kinda crazy to see tuples and pattern matching "just arrive" when other languages have had them for years.

Every language has something missing, but C# has plenty of other great features so tuples weren't really that big of a problem. There are also plenty of built-in containers like the Tuple class that can offer the same functionality.

A tuple struct fills nearly zero of the real use cases for language level tuples. No pattern matching makes it sort of useless.

Re: What’s New in C# 7.0

#87
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.

Re: What’s New in C# 7.0

#88
I thought pattern matching in C# would look like pattern matching in Elixir. For example, two functions with different signatures run based on the parameters you give it.

    def hello("sergio") do
      IO.puts "Hello Sergio"
    end

    def hello(name) do
      IO.puts "Hello #{name}"
    end

    ---

    hello("sergio") => "Hello Sergio"
    hello("mia") => "Hello mia"

Re: What’s New in C# 7.0

#89

Sometimes it feels like we're entering a new age of coding. C# is so full of "features" that code refactoring tools like ReSharper, CodeRush and JustCode became simply indispensable. It is quite hard to be sure, every time, what is the most elegant/compact way of doing things. In the .Net/VisualStudio world, the language tooling (Intelisense, visual drawing XAML & WinForms, etc) became as important as the language se…

"WinForms" is "language tooling"? "XAML" is "language tooling"? By what definition?

I can write server-side C# in vim (without omnisharp) just fine, actually.

Maybe the tools became "indispensable" because they add value? I refactor my code in vim but it would probably be faster in VSCode. That doesn't make C# a bad language.

Re: What’s New in C# 7.0

#90
post #66

Earlier quoted context omitted.

Hey there, C# language designer here. > Out variables seem like a mis-feature, especially when they are adding a better alternative (Tuples) in the same release. Out variables are really great when working with existing code that predates Tuples (for example, the entire BCL). We don't just introduce language features that will only work well for new code. We also want to make the experience of coding against existing…

> That 'headache' has to be weighed against the needs of some parties to write very fast code and to have as little overhead as possible. ref returns enables a much more pleasant coding experience that enables these sorts of speedups in these specialized scenarios. I'm worried this could result in a loss of focus, you can't make everyone happy all the time. c# is a fantastic language to develop applications in (web o…

Well maybe you don't care, but there are folks that do (I'm on that list) ;-) I want the speed of C but the safety of C#.

There are many pieces of code that you probably use every day that go to great lengths to squeeze as much power as possible. Why not help these folks help us? I'm glad there is more focus on performance because we all benefit. (Hoping to see more on the CLR side.)

Post reply on HN