Live data from Hacker News

What’s New in C# 7.0

blogs.msdn.microsoft.com

181–190 of 278 posts

Re: What’s New in C# 7.0

#181
post #70

Earlier quoted context omitted.

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

Sure. Like how streams "just arrived" in Java yet C# has had the equivalent for years. No language has every feature. C# is making enormous strides ahead of many of its counterparts.

Java's a pretty extreme outlier for late or non-adoption of modern features, but it is true that Java is the closest direct competitor/peer to C# in terms of usage/marketshare. C# seems to be steadily shifting from being a language which initially (v1.0) looked like Java to one which looks increasingly like Scala (e.g. addition of pattern matching, tuples, local methods etc.).

Re: What’s New in C# 7.0

#182

CSharp once again showing it is the best language in terms of features and improvements. Great job all round by the designers.

> CSharp once again showing it is the best language in terms of features and improvements.

That's a pretty sweeping generalization. Most of the headline features in the article are already in other languages e.g. Scala.

Re: What’s New in C# 7.0

#183
post #167

Earlier quoted context omitted.

But then you might as well declare a class or structure to store the data. The point of tuples is to be self-contained.

It maybe wasn't clear, but I was referring to the parent's point about verbosity when using the 'old' Tuple class. using Complex = System.Tuple ; is less verbose than public class Complex { public double i { get; set; } public double j { get; set; } }

Not quite equivalent, since System.Tuple is immutable. So, at minimum:

  public class Complex {
    private readonly double _i;
    private readonly double _j;
    public double I {get {return _i;}}
    public double J {get{return _j;}}
    public Complex(double i, double j){
      _i = i;
      _j = j;
    }
  }
But System.Tuple is also IComparable, IStructuralComparable, IStructuralEquatable. I haven't had enough coffee yet to add all the boilerplate for that to the above, which only reinforces the point about verbosity.

Re: What’s New in C# 7.0

#184
post #168

I tend to avoid using switch/case for quite irrational reasons. The break statement just looks wrong and I can't layout the code in a way I find at all pleasing. I'll almost always use a sequence of else if conditions instead. In my ideal world, it'd look like... switch (x) { case 1: { /* ... */ } case 2: case 3: { /* ... */ } } And before anyone points it out, switch is the same as else if when the thing being compa…

Most of the time when I use switches, I'm returning from inside the case, because I tend to pull the switch out into another function.

It's usually a good idea to create a new scope with your cases, so you can avoid some irritating variable name clashes, since, unlike and if, switch cases don't automatically do that, i.e.

  switch(foo) {
    case 0:
      var bar = 2;
      // do stuff...
      break;
    case 1:
      var bar = 47; // error, conflicting variable name
      // do stuff...
      break;
  }

Re: What’s New in C# 7.0

#185

CSharp once again showing it is the best language in terms of features and improvements. Great job all round by the designers.

> CSharp once again showing it is the best language in terms of features and improvements. That's a pretty sweeping generalization. Most of the headline features in the article are already in other languages e.g. Scala.

The difference being CSharp is actually used by a large number of people. Scala is not even in the top 10 used languages [0].

[0] http://www.tiobe.com/tiobe-index/

Re: What’s New in C# 7.0

#186

Earlier quoted context omitted.

> But is C# really a language you want if that is important to you. C# is used by hundreds if not thousands of games by ways of Unity and is therefore demonstrably good enough in this scenario. Furthermore, just because a language is not C++ does not mean you shouldn't take every opportunity to give programmers tools to write fast code - at the end of the day I doubt anyone would be interested in a language that is p…

Isn't Unity stuck with C# 2.0 ?

Poked around Google and it seems as though you are correct about Unity; however, C# tends to use existing MSIL features and doesn't require the BCL public key token for supporting infrastructure. You can patch in many recent features in by simply defining the types yourself. A common example of that would be:

    public sealed class ExtensionAttribute : Attribute { }
Even async/await comprises of a convention and an interface - I haven't tried it, but in theory using the CLR 2.0 TPL should bring async/await your project. So far as I know, the feature being used for ref returns has always existed for C++/CLR so this stuff should work on CLR 2.0 (although you will need the C# 7.0 compiler).

Re: What’s New in C# 7.0

#187
post #178

CSharp once again showing it is the best language in terms of features and improvements. Great job all round by the designers.

I'd say Swift is more or less in line with C# with regards to functionality. Many new features added to C# seem to already exist in Swift. Swift could use some async/await mechanism en sometimes it's a bit annoying to typecast simple types for calculations, but otherwise Swift is a really sweet language to work with. Nonetheless C# is a nice language. I enjoy writing C# code, just as I enjoy writing Swift code.

Swift is my daily driver for a year and some, I love the language and I'm having much fun working in it, it have some great ideas (nullability, emphasis on value types, protocol extensions), but calling it "more or less in line with C#" is still a bit of stretch.

(For starters, Swift desperately needs to include most of the points from "Generic Manifesto" to be comparable with more mature languages like C#. Not being able to return a generic interface from a function is just silly)

Re: What’s New in C# 7.0

#188
post #163

Earlier quoted context omitted.

Edit-and-Continue is the greatest productivity feature ever added to a development stack for the real conditions one would encounter in large projects , and it astonishes me even now how misunderstood it's purpose is. Consulting has me moving jobs a lot and I encounter a veritable kaleidoscope of crappy work. Being able to correct minor issues in scope without restarting, while ten form posts deep in an archaic webfo…

Does Edit-and-Continue ever work? I'm curious, because I'm almost always forced to build x64-only, because of some libraries we have to use that are 64-bit only, and I've never been able to change code while the debugger is running. Supposedly it is supposed to work in VS 2015, but I'm not seeing it - it's always the nasty messagebox saying "Changes to 64-bit applications are not allowed"

Build 64-bit only or release 64-bit only?

I only ask as I can usually manage 32-bit builds on dev while working, then just test there's no spooky differences when I target 64-bit.

There are issues with some projects that aren't well documented. E+C on web apps on local or remote IIS are a no-go (at least to the best of my knowledge), whereas if you can target IIS express during development it works beautifully.

I've always found that the juice has been worth the squeeze, for values of squeeze that only require me to tweak configuration for my dev box.

Re: What’s New in C# 7.0

#189
I still lack some kind of sum type that is always checked for exhaustiveness. When I'm creating a class hierarchy for a domain, 9 times out of 10 I'd rather have a simple sum type. When I have to make a class hierarchy in C# anyway (because there are no simple sum types). I'd like to be able to write something like this, and have this match/switch fail to compile if I add a new type of shape.

    match(shape) 
    {
      case Rectangle r
        return r.With*r.Height;
      case Circle c
        return pi*c.Radius*c.Radius;
    }
Post reply on HN