Live data from Hacker News

What’s New in C# 7.0

blogs.msdn.microsoft.com

41–50 of 278 posts

Re: What’s New in C# 7.0

#41
post #31

All I want is easy syntax for immutable records, and C#-like a fluent syntax for .WithPhoneNumber(phoneNumber) etc. Seems like it'd be a cinch to implement, and for me the single handiest feature from F#. In F# these are "guaranteed" to be non-null, even though null instances come up during deserialization all the time. In C# use cases, I don't think the non-null "guarantee" should be made or implied, just a POCO.

Hi there! C# language designer here.

You can see (and participate in) the discussion on records here if you'd like: https://github.com/dotnet/roslyn/issues/10154

> Seems like it'd be a cinch to implement

Ah... how i wish that were so :)

Re: What’s New in C# 7.0

#42

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…

The most productive I've been as a developer was 20 years ago when I was creating VB6 apps and components...

Re: What’s New in C# 7.0

#43

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.

Re: What’s New in C# 7.0

#44
post #19

Since C# is starting to look more like JavaScript (i.e. local functions) and vice versa (i.e. arrow aka lambda expressions). I'm going to throw my pocket change into a couple features I've been growing old hoping to see: 1. Regex expressions just like Regexp in JS: /^\s+$/.IsMatch(" "); // or Regex r = /^\s+$/; 2. DateTime expressions, similar to regex, something like: DateTime clockTowerLightning = #1955/11/12 10:04…

For item 1, extension methods and implicit conversions would get you really close:

Definition: https://gist.github.com/noblethrasher/5edffb4cb2efa4ed9174fb...

    //Usage: 

    var is_match = "  ".IsMatch("^\s+$");

    //OR

    regexp rgx = "^\s+$";

    is_match = rgx.IsMatch("   ");

Re: What’s New in C# 7.0

#45
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…

Adding features for the the subset of developers that need optional performance enhancements is great. However, it does seem ripe for misuse. As in the developer who makes everything a ref reference because they read it makes it "faster." Would there be a way to get Visual Studio to warn about this?

Re: What’s New in C# 7.0

#46

Pattern matching! Tuples! Awesome, C# 7.0 is scratching two itches I've felt every time I've worked with it. If only .NET had a suitable cross-platform UI toolkit, then I'd be using it everywhere. Eto.Forms is a good attempt but I found rather buggy and limited at this point in development. Avalonia, while further along in terms of stability and features, doesn't even try to fit in with any platform's look and feel.

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.

Re: What’s New in C# 7.0

#47

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

Hi David, language designer here.

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

Thanks!

Re: What’s New in C# 7.0

#48
post #20

Earlier quoted context omitted.

> foo(out int mvar); // oops, not myvar; maybe caused by a refactor? This should fail to compile, it's the equivalent of declaring a variable twice int the same scope.

If that were int myvar you'd be correct, in this case the typo introduces a new variable mvar that won't conflict with the original declaration.

Whoops, I missed the typo. Inadvertently proving your point.

Re: What’s New in C# 7.0

#49
post #45

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…

Adding features for the the subset of developers that need optional performance enhancements is great. However, it does seem ripe for misuse. As in the developer who makes everything a ref reference because they read it makes it "faster." Would there be a way to get Visual Studio to warn about this?

Not .NET developer here but the usual way is to use some sort of linting tool to "disable" the esoteric features.

Re: What’s New in C# 7.0

#50

Pattern matching! Tuples! Awesome, C# 7.0 is scratching two itches I've felt every time I've worked with it. If only .NET had a suitable cross-platform UI toolkit, then I'd be using it everywhere. Eto.Forms is a good attempt but I found rather buggy and limited at this point in development. Avalonia, while further along in terms of stability and features, doesn't even try to fit in with any platform's look and feel.

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

A big advantage of this design over most of the other languages with tuples that I've seen is that their members can have names - that is, types can be anonymous but have named members. This I think hits a sweet spot as it's rare to not want fields to have names, but fairly common to want intermediate types that just bundle a few fields together where there's no good name that clarifies much.
Post reply on HN