Live data from Hacker News

What’s New in C# 7.0

blogs.msdn.microsoft.com

121–130 of 278 posts

Re: What’s New in C# 7.0

#121
Having done a lot of python recently, this looks great (and familiar).

But some things feel a little bit rushed:

- In the example "(o is int i || (o is string s && int.TryParse(s, out i))": When reading this statement as a human, o is obviously not an int when it comes down to the TryParse function. But if the 1st part was removed, the 2nd part wouldn't be valid either. I know this is technically how declarations work and I don't have an idea, if there is a better solution for this, but it feels weird.

- The new features of the case statement are nice but the old syntax with the mandatory break is probably worth getting rid of. Especially since all cases share a scope, adding/removing cases is prone to errors. I'd love to see a solution similar to "catch".

- The Deconstruct method is introduced as a "magic name". No interface, no override, nothing... Even the return type is "void". Why not use something like "public out Point(...)" to keep it similar in fashion to the constructor. Other options may be something with "this" (like indexing) or "operator".

Re: What’s New in C# 7.0

#122

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.

Can you give an example of how C# would be different with anonymous classes? Googling that term just gives a whole lot of references to inner classes in Java.

Implementation of IComparer

Re: What’s New in C# 7.0

#123
post #108

Earlier quoted context omitted.

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.

And a very verbose syntax. You have to repeat everywhere the different types of the different members.

[deleted]

Re: What’s New in C# 7.0

#124
I don't like the idea of accessing tuple values by their local name

    var names = LookupName(id);
    WriteLine($"found {names.first} {names.last}.");
It's leaky and should simply use the deconstructing syntax instead.

I'm on the fence about the ref returns. It can lead to some fantastic performance improvements and enable otherwise unusable datastructures. But is C# really a language you want if that is important to you. Why not go all in a use a lib in C or C++ for the critical parts of the code?

I still miss better immutability support, and probably most of all, ability to declare something at non-nullable.

But that said, the update is a fantastic update to an already good language.

Re: What’s New in C# 7.0

#125
post #97
post #42

Earlier quoted context omitted.

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…

> Between 1998 and 2000 VB6 was perfect, you could develop Windows GUI applications in a rapid manner

Delphi was much better.

Re: What’s New in C# 7.0

#126

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…

> 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)

Actually you are getting a benefit in return (unlike, say, in Rust) - the libraries. Verbose syntax is less complex in regard to writing the code, so more developers write the code. I have no scientific evidence to provide about the fact, but observations speak for themselves. Compare the quantity of libraries available for Rust and yet another 'overly verbose' language, Go. We can find Go wrapper for almost anything, and often a few to chose from.

Re: What’s New in C# 7.0

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

Did you ever maintain vb6 apps? Because I still want to cry thinking about the times I've had to.

Re: What’s New in C# 7.0

#128
post #90
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…

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.)

> I want the speed of C but the safety of C#

Try OCaml.

Re: What’s New in C# 7.0

#129
post #52

Earlier quoted context omitted.

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

These tend to become cargo cult practices, "thou shalt never" that get in the way of those few places where they are useful.

I don't think so. The purpose of compiler warnings, lint-like tools, static analyzers and such is to bring developer attention to some block of code. Not 'Hey, you should not do it this way', but 'Hey, is this thing here as intended by you or just a typo or mistake?'.

I like the way its implemented in Perl. Use 'use strict' by default, and guard the block where you really need something unusual by 'no strict something' - refs, vars, subs - so neither compiler nor people reading your code never being confused whether is it a mistake or author's intention.

Re: What’s New in C# 7.0

#130
post #65

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.
Post reply on HN