Live data from Hacker News

What’s New in C# 7.0

blogs.msdn.microsoft.com

91–100 of 278 posts

Re: What’s New in C# 7.0

#91

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…

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.

Re: What’s New in C# 7.0

#92

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"

Isn't that more an example of `multiple dispatch` rather than `pattern matching`?

Re: What’s New in C# 7.0

#93

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…

Agreed, I would much prefer something like:

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

Re: What’s New in C# 7.0

#94
post #23

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

"Full" pattern matching, as one would expect from F# for example, wouldn't be something I could expect from C#. For example: type Tree = Empty | Node of 'a * Tree * Tree There is no way to express this directly in C#. Thus, I am "locked out" of a whole class of Pattern Matching that I would get with F#. But that doesn't mean that C#-style pattern matching (really, Is-patterns and a Type Switch) don't fall under the u…

> C#, is every bit a form of pattern matching as matching on a particular case of a union type.

I'm afraid that is not the case, because in the current C# version, the compiler does nothing help you determine if you've matched all the possibilities. (it is not exhaustive)

Exhaustiveness is important because it gives warning or an error to help you refactor and modify code without fear of breaking other code. Why engage in all the static typing business if the compiler is not going to help you refactor things?

This is important in the same way that adding a subclass requires exhaustively supplying all the abstract methods (true pattern matching is "dual" to adding a subclass; you use the compiler feedback to direct what actions to take next. you can't do this with the Switch based formulation because you don't get any feedback from the compiler if you missed cases or have refactored other code to add cases (for example, adding/refactoring abstract methods in a base class provides feedback on where to add/update methods in the subclasses)

Re: What’s New in C# 7.0

#95

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…

For the last decade or so the c# world has been moving away from those ill conceived tools. Winforms/Webforms were drag'n'drop based and have since been replaced with xaml and html. SSDT has given way to migration based approaches.

Intellisense has become it's own lightweight thing and consumable from more tools, you can code just fine without it. ReSharper I've never used, I find it gets in my face more than it helps.

If you want to see a tooling based approach, go look at the state of android development these days. That's why we see stuff like react native becoming popular.

Re: What’s New in C# 7.0

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

The first is almost certainly better off as it is in F#: active patterns. That'll let you define patterns that'll execute arbitrary code to match, making regex a simple library feature, vs a special one-off. C# should have focused on having proper extensible syntax vs hard coding random features (like duck typed foreach or collection initializers).

But given the constraints of mscorp and the target users perhaps they made the right decisions.

Re: What’s New in C# 7.0

#97
post #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...

So true. Between 1998 and 2000 VB6 was perfect, you could develop Windows GUI applications in a rapid manner. The VB6 IDE, the Windows UI guideline, the VB6 API, everything was great. And PlanetSourceCode.com was what was later SourceForge and nowadays GitHub. When I read about Microsoft's vision for .Net in 1999 about applications running as a service over the internet (that was their original idea), I thought that will end the great Windows platform and started looking for alternatives. Microsoft dumbed VB6, but it took them until 2003 to come up with DotNet with a different implementation, it (C# 1) was basically a Java clone with small syntax improvements. The biggest fail was to announce VB.Net and their lackluster Channel9 video that showed the third party developed the converter wizard (VB6 to VB.Net) that barely worked and was free only in the lite version. In the meantime I switched to C, C++, PHP, etc. The web replaced desktop applications in many cases anyway. And nowadays Android and iOS are important targets too. Sadly, the rapid development never got that easy to use as it was with VB6 IDE, with HTML4+PHP with Dreamweaver being almost as fast. But nowadays, the GUI builder aren't as polished and well integrated and don't support all features of the supported languages - so many skip the GUI builder and write the GUI code by hand.

Re: What’s New in C# 7.0

#98
post #92

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"

Isn't that more an example of `multiple dispatch` rather than `pattern matching`?

In Elixir land it's been taught to me as pattern matching. I have never heard of `multiple dispatch`.

Re: What’s New in C# 7.0

#99
Will C# ever start to increase type inference to make it less verbose? Local functions are ok. But why not lambda syntax+inference? Probably still because of making quoted code have ambiguous syntax. But this ends up adding noise and increases the barrier on deciding when to put code into a tiny function.

When using C# I'm constantly noticing how much extra code there is. It's just frustrating, and I don't feel like I'm getting a unique benefit in return (unlike, say, in Rust). I know F# would be more concise and work just as well. But I know it's not easy extending the existing design decisions.

(The tuple story is sad, eh? This was F#'s original design, using structs. Then they made peace with the strange heap allocated framework tuple. And now...? No tuple interop?)

Anyways, congrats, C# definitely is the best general dev language commonly accepted at a large amount of companies, especially when factoring in tooling.

Re: What’s New in C# 7.0

#100

Since we're all chipping in with features we'd like to see in C#, here are mine: anonymous classes - with actual class bodies, that can implement interfaces - and traits.

You could, if you were so inclined, just generate proxies on the fly.
Post reply on HN