КОМЕНТАРІ •

  • @williambell4591
    @williambell4591 4 роки тому +9

    Thanks so much for this - C# is constantly getting better and better!

  • @fabriciomagalhaessena2289
    @fabriciomagalhaessena2289 3 роки тому +5

    The unique problem of this video is the fact that I can like one time not more ... Awesome lecture!!

  • @Gi-Home
    @Gi-Home 4 роки тому +1

    Great presentation! Thank you.

  • @PraveenAV
    @PraveenAV 3 роки тому +4

    We need more such videos with C# getting new features in new releases.

  • @PrashanthKrishnamurthy
    @PrashanthKrishnamurthy 4 роки тому +108

    Start at 4:50 if you are impatient.

  • @dotnetter2006
    @dotnetter2006 4 роки тому

    Great examples and good presentation - thanks :)

  • @rilauats
    @rilauats 4 роки тому +9

    Great view on programming languages, THX!
    Somehow APL will always feel like write-only programming. "We will make reading insanely hard because nobody likes reading other developer's code..."

  • @nacasadobeirinha1524
    @nacasadobeirinha1524 4 роки тому +1

    OMG! Tks for good presentation :)

  • @mricebergbluewin
    @mricebergbluewin 4 роки тому +8

    Just when I thought I couldn't love that language more than I already do....

    • @RenegadeVile
      @RenegadeVile 3 роки тому +2

      @xOr Irrelevant. Why do people who like Python pop up everywhere, jeezes.

  • @Napernik
    @Napernik 4 роки тому +63

    I think it looks even better like this:
    public override bool Equals(object? obj) =>
    obj is Point otherPT && this == otherPT;

    • @leinh4245
      @leinh4245 4 роки тому +7

      But in term of readability, it's not better :D

    • @Napernik
      @Napernik 4 роки тому +3

      In my head it sounds as - the object is of the same type AND "this" equals to that casted object.

    • @figloalds
      @figloalds 4 роки тому +18

      @@leinh4245 In readability I think "A && B" is more readable than "A ? B : C"

    • @GeorgeTsiros
      @GeorgeTsiros 3 роки тому +1

      @@leinh4245 Everything in the expression is a direct transfer from the thinking behind it: "it is equal if and only if the other object is a point and that other point is equal to this point."

  • @rubeushagrid4131
    @rubeushagrid4131 3 роки тому +5

    I wish I could see this a little earlier.. This is an awesome demonstration of neat code. A code that looks beautiful at same time little hard to understand which serves the purpose of abstraction. I really love it.❤️

  • @boracodarcomgabrielbury1719
    @boracodarcomgabrielbury1719 4 роки тому +1

    Thank you NDC!!!

  • @Andrew90046zero
    @Andrew90046zero 4 роки тому +21

    This is literally the first time I've watched a programming speech where the guy speaking ACTUALLY had a personality and a sense of humor. Thank you Bill Wagner for not being dry, and for showing that not all programmers have the same personality.

    • @SavilliMillard
      @SavilliMillard 4 роки тому +15

      Stop watching noob tutorials, and start watching conference talks and pluralsight courses then. Lots of personality.

    • @chronny21
      @chronny21 4 роки тому +4

      Kevlin Henney has a ton of useful knowledge and lots of good humor, IMO

  • @leakyabstraction
    @leakyabstraction 3 роки тому +3

    I used to do mapping/lookup logic similar to 41:50 with Dictionaries; where what you check against is the key, and the result you want is the value. 🙈 Which is runtime-configurable, but obviously way slower to execute. Nice to know about this compact switch syntax.

    • @danielscott4514
      @danielscott4514 2 роки тому +2

      You might be surprised how fast Dictionaries are. I've found that a Dictionary is quicker at returning an item with a string key than looping over a list of just five or so items looking for the same string key inside the value (even using for-next rather than an iterator). It seems the hashing function for strings is very quick and beats a string equality test after just a few iterations.
      Granted the switch statement's jump tables are likely to be even more optimised, but my point is that a Dictionary might not be as slow as you think depending on what type your key is. A Dictionary is likely to be quicker than a set of five or more if-else branches that test strings - although ideally you want to initialise your dictionary only once if you can.

  • @dileepkumarkambali1509
    @dileepkumarkambali1509 3 роки тому +1

    Pattern matching is great escape from nested if else conditions

  • @norbertbeckers1978
    @norbertbeckers1978 4 роки тому +8

    I love how Functional programming is seeping in C# and making it more and more mainstream.

    • @sacredgeometry
      @sacredgeometry 3 роки тому +6

      It's a fashion trend and it's dumping a veritable shit ton of barely legible code into the world. It's a nightmare that we are all going to have to suffer for. But then all single paradigm advocates generally write god awful code.

    • @Zapanath
      @Zapanath 2 роки тому +4

      @@sacredgeometry I agree with this comment. At this point they should be pointing ppl to F#. Some of this stuff is getting out of hand now.

  • @VilClavicus
    @VilClavicus 4 роки тому +135

    Tuples, immutable data structures, pattern matching, null safety, avoiding inheritance hierarchies, ...
    He basically made a case for functional programing without mentioning it a single time.

    • @Yous0147
      @Yous0147 4 роки тому +27

      I guess, but the way I see it it's moreso advocating for the best of both worlds. C# is still clearly OO even with these additions, but this extends it beyond that

    • @13b78rug5h
      @13b78rug5h 4 роки тому +19

      OOP at the higher levels, functional everywhere else

    • @Knirin
      @Knirin 4 роки тому +9

      You can see F#’s influences here.

    • @RenegadeVile
      @RenegadeVile 3 роки тому +8

      Yes and no, even OOP languages have always advocated not to go overboard with inheritance and to use it only when it makes sense. Quite a few prominent names in C++ (including its creator) have taken that stance from the get-go. It's a useful tool, IF used as intended. Problem is, some people go overboard and start inheriting everything from everything, even when it makes no sense and will only cause problems. Null safety is also not a solely functional programming paradigm. etc.

    • @IIARROWS
      @IIARROWS 3 роки тому +5

      Let me ask a question: what is a program, unless pure imperative, if not a collection of functions?
      An object is just a collection of variables and functions after all.
      Object Oriented Programming is a mouthful way to say that those functions and variables belong to a class, and it helps to describe behaviour and intention.
      There is really no "functional vs object" paradigm in a program, unless you want to start a flame. Everything is compiled in a neat sequence of operations, and function calls.

  • @TheLbadwal
    @TheLbadwal 3 роки тому +1

    Beautiful!!

  • @rotgertesla
    @rotgertesla 4 роки тому +7

    Thx for the tips. Quick tips for the speaker: Shift + Delete to delete entire row. Alt + Up arrow to move a row up (no need for copy paste)

    • @igorthelight
      @igorthelight 4 роки тому +1

      And "Insert" keyboard key for replacing one letter/number for another :-)

    • @MiguelAngel-og8ng
      @MiguelAngel-og8ng 4 роки тому +7

      actually Shift + Delete, cuts the entire row, if you have something in your clipboard you'll loose it (Y)

    • @serpent77
      @serpent77 Рік тому

      And turn off night mode when doing a presentation. That orange hue makes it difficult to read on smaller screens.

  • @ManiasInc
    @ManiasInc 4 роки тому

    GREAT!!! BRAVOO!!!

  • @vincent4624
    @vincent4624 4 роки тому +5

    Very nice! I actually hated tuples earlier, because I always thought: Why not just create a new class? But the way you are using tuples here is a lot different from how I thought you were going to use them! Very nice examples!

  • @tomthunderforest1681
    @tomthunderforest1681 4 роки тому +9

    Thank you for this talk, you make me LOVE tuples !

  • @magecode9585
    @magecode9585 4 роки тому +1

    ooh my god, it changed my mind
    !!!

  • @Sollace
    @Sollace 4 роки тому +1

    I can't say I'm very comfortable with the idea of allocating two or more Tuples every time you want to do a simple allocation/comparison. Would be better to just change that point class to have one field of type Tuple and compare them by left.tuple == right.tuple.

    • @Eldering
      @Eldering 4 роки тому +2

      Point is a struct in the example, so if it allocates it is going on the stack and not on the heap. My guess is there will be some optimizations done in those simple methods but I am also curious if there is a performance cost to the tuple approach. Especially the equality code is a lot more readable though, so that might be worth it in some cases.

    • @Skarllot
      @Skarllot 4 роки тому +1

      @@Eldering the compiler is smart enough. You can play on SharpLab: sharplab.io/#v2:D4AQTAjAsAUCDMACAzgFwE4FcDGrEGFEBvWRMxASwDs8APAblPOrwE9GZzEECAKFxLQA0lGolYBKYky5leqABYVkAOmGJFylZMQBeRL3WSOXAL4zEFniAgA2RACMA9k4A2iJwAcApugCGqE7oerq8hK4ihOhSugB8Bq5qIok6uvq86EmImcZWSDb2zm4ePv6BwQCEoeGR2THxvInqKVJVBpnqORIm5HncACyIAMoA7n6evFIknLJyRjEGrCK03RbmMKZAA==

  • @kingocto
    @kingocto 4 роки тому +23

    Its funny how every new feature added takes from F#.

    • @londospark7813
      @londospark7813 4 роки тому +2

      I would laugh, but that's far too true.

    • @kingocto
      @kingocto 4 роки тому +6

      @@londospark7813 The next feature will be making semicolons and curly braces optional, you'll see.. then they'll discuss the new and exciting world of currying parameters 😂😂

    • @RogerValor
      @RogerValor 4 роки тому

      well except with tuples i think primarily python.

    • @halbeard2996
      @halbeard2996 4 роки тому +8

      Modern languages like to include functional programming features. Everything that was presented here made me think that C# wants to be like Rust with runtime checks.

    • @welltypedwitch
      @welltypedwitch 4 роки тому +3

      Yeah, but seriously, I want F#'s try-with expressions in C#! I've always hated exception handling in Imperative languages

  • @waynemv
    @waynemv 4 роки тому

    Is there a single line expression for ensuring none of the values within a tuple is null?

  • @mrki83
    @mrki83 3 роки тому +1

    At 25:40 it really bothers me that he didn't do
    => obj is Point otherPt && this == otherPt;

  • @JoeBonez
    @JoeBonez 3 роки тому

    I think the Point Distance property is wrong. Since it is initialized to default, HasValue will always be true so the real value is never computed. It should be initialized to null I believe

  • @serkan.bircan
    @serkan.bircan 4 роки тому +2

    I liked new features. (:

  • @jeromej.1992
    @jeromej.1992 4 роки тому +56

    I do think that the discard assignation to check null state is much worse than just doing a if(foo == null)

    • @TheKarabouzouklis
      @TheKarabouzouklis 4 роки тому +27

      In my opinion 'discard assignation' looks hacky.
      if (partner == null)
      throw new ArgumentNullEx...
      Is cleaner

    • @313isforme
      @313isforme 4 роки тому +11

      It's my understanding you really should use if (foo is null) instead of == in the off chance the equality operator is overloaded.

    • @789blablajaja
      @789blablajaja 4 роки тому +25

      Discard assignation is hacky and unreadable as fuck. An assignation should be to assign something.
      The case presented would be way more readable as pattern matching in c#8, and then write null explicit instead, like this:
      public string HyphenateForPartner(Person partner) => switch partner
      {
      null => throw new ArgumentNullException(),
      _ => $"{partner.LastName} - {this.LastName}"
      }

    • @termway9845
      @termway9845 4 роки тому +7

      A ternary-like form would be better IMO:
      foo is null ? throw new ArgumentException();
      That underscore syntax is an aberration.

    • @zmast333
      @zmast333 4 роки тому +8

      Yeah, I don't like the assignment to discard operator either. After all, the result of an expression is already discarded if you don't assign it to something.
      So, I'd prefer just:
      partner ?? throw new ArgumentNullException();
      but that doesn't compile.

  • @nachmanberkowitz5243
    @nachmanberkowitz5243 4 роки тому

    Is the code available anywhere?

  • @KirillKhalitov
    @KirillKhalitov 4 роки тому +1

    Does C# have feature like Scala case class (with immutable auto constructor/getters/setters)?

    • @RenegadeVile
      @RenegadeVile 3 роки тому

      C#9 is going to introduce records, which do these things out of the box. Otherwise, you can approximate some of this behavior already with structs and classes.

  • @jorhoto7064
    @jorhoto7064 4 роки тому

    What do you think about using underscores for private fields in a class?
    According to Microsoft naming conventions we shouldn't use it, but I see many examples where it is used and even in this video at: 26:32.

    • @user-hz1yc6cw6k
      @user-hz1yc6cw6k 4 роки тому +1

      Microsoft recommends to always use underscore for private fields, maybe you mean C++ style prefixes like s_ for static fields?

    • @rupertfrint8628
      @rupertfrint8628 4 роки тому +2

      Microsoft publicly encourages this.x, but they internally use _x for whatever reason

  • @hanspetervollhorst1
    @hanspetervollhorst1 4 роки тому +1

    36:56 What might be a use case for chaining switch statements? The result you want (ie a function is returning) is in the last switch statement. Why would one prepend various other switch statements?

    • @Qrzychu92
      @Qrzychu92 4 роки тому

      for example you could replace the tuples form the tolls example with nested switches. Would be usefull if you had to take into consideration for example mass of the vehicle, but only when inbound in the evening on the weekend, otherwise mass would be irrelevant. You just have more options :)

    • @Skarllot
      @Skarllot 4 роки тому

      @@Qrzychu92 he could show using "when" on switches

  • @Layarion
    @Layarion 4 роки тому +1

    11:56 could someone break down, a bit more than he did for a noob, the order this happens/why it works. It seems to be taking the expression on the right, and storing the results without coming back to them, then looks at the left and assigns the results.
    but my question is, did it do that because it's a lambda, or because it's a tuple?

    • @jonohiggs
      @jonohiggs 4 роки тому +4

      He is basically saying that it works because that's the way they wanted it to work. Internally it is creating a copy of the properties before assigning them back so that it doesn't loose one of them. The real question: it is a behaviour of the tuple. In case you are interested, that is an expression body function, not a lambda, just the newer syntax for defining functions that contain a single expression with => operator rather than enclosing it in { }. They look quite similar, I think it was inspired by the lambda syntax

    • @jonstodle
      @jonstodle 4 роки тому +10

      It works because of tuples and desctructuring. As of C# 7, some types have a method called Deconstruct on them, ValueTupe (which Wagner is using in the example) implements the Deconstruct method. When a type implements Deconstruct it allows you "unwrap" the fields of that type directly into variables:
      var (x, y, z) = myObject;
      is the same as
      var x = myObject.x;
      var y = myObject.y;
      var z = myObject.z;
      If x, y, and z already exists:
      (this.x, this.y, this.z) = myObject;
      is the same as
      this.x = myObject.x;
      this.y = myObject.y;
      this.z = myObject.z;
      In Wagner's example, the right side of the equal sign stores this.Y and this.X in a tuple. The left side then deconstructs the just created tuple into the two existing properties this.X and this.Y
      You can read more on deconstructing here: docs.microsoft.com/en-us/dotnet/csharp/deconstruct

  • @hanspetervollhorst1
    @hanspetervollhorst1 4 роки тому +16

    34:12 When you have come so far, why do you not also discard the discard? The assignment itself is superfluous and confusing. A simple *partner ?? throw Exception()* would imo be much more concise

    • @michor10
      @michor10 4 роки тому

      I guess the mechanics behind it requires an assignment. I think we need something like partner ?? ? throw Exception()

    • @AdroSlice
      @AdroSlice 4 роки тому +2

      You're in a context that expects statements, a null coalescing expression is not a statement by itself, but it can be made part of one... Such as a an assignment. I think this looks alright, but code reviewers may label it as an antipattern due to their own preferences, so having a general helper in the project like
      ThrowIfArgNull(object arg, string nameofArg)
      is probably much more widely accepted. This can be done without newer C#-features.
      Correct me if I'm wrong on something.

    • @JaredThirsk
      @JaredThirsk 3 роки тому

      How about the ??= operator?

  • @truedreams1
    @truedreams1 4 роки тому +7

    When you switch if statements to expressions if an exception happens it’s hard to tell what part of the expression is causing the error, so you might want to factor back to if statements sometimes.

    • @Skarllot
      @Skarllot 4 роки тому +2

      You can debug line by line

  • @joechang8696
    @joechang8696 4 роки тому

    I am of the opinion that we should be able to specify that certain objects be allocated from a private set of (OS) pages. When disposed, the entire set of pages is recycled, no need to check if any other object has allocations within those pages. sure, some memory is not used?, but we have memory, it is garbage collection that kills. SQL Server and other established database engines are highly robust in being able to run for very long times because the make extensive use of fix page sizes, which can be easily recycled. We might want the ability to specify certain page sizes (4KB, 2M, 1GB etc)

    • @user-lz2oh9zz4y
      @user-lz2oh9zz4y 4 роки тому

      although I agree it would be nice to have more control on how things are put into memory I don't see this as something they would put in C#

    • @jessepoulton224
      @jessepoulton224 4 роки тому

      Are you talking about object pools? Cos pretty sure they exist

    • @joechang8696
      @joechang8696 4 роки тому

      I had not known about object pools, so thanks
      the Microsoft documentation says it is a mechanism (pool) for handling objects that are expensive to create or destroy.
      what I am talking about is making sure the virtual address space can be recycled easily. Even if allocations are mostly released, there is no guarantee that a large contiguous block can be reused, hence new allocations occur beyond the previous.

  • @carbon1479
    @carbon1479 4 роки тому +4

    28:25 - newb question here - I love this use of ArgumentNullException but... can I just use reflection rather than having one of these for every single property I might use?

    • @CzarZappy
      @CzarZappy 4 роки тому +8

      Reflection is pretty expensive and not supported in some contexts. One solution is to have code that assumes nothing is null, and that forces null pointer exceptions to appear sooner, rather than being passed down through a call stack, but there are drawbacks to that as well.

    • @disklosr
      @disklosr 4 роки тому

      @@CzarZappy Or use Option/Maybe monad data structures that forces you at compile time to acknowledge the nullability of a reference type before accessing its value.

    • @ravenheartgames5537
      @ravenheartgames5537 4 роки тому

      @@disklosr This is great if you are using C# 8, but if you are doing C# development in Unity, you are stuck with C# 7.3 for now. Also, my answer was in response to the question "can I just use reflection rather than having one of these for every single property I might use?", and addressing the reflection limitations for this use case to show the name of the null parameter given. Your suggestion is another solution to identify that a given parameter is null, but not what property name to report out.

  • @sebastianwardana1527
    @sebastianwardana1527 2 роки тому +1

    sooo, the beginning is just what you should do anyways already, right?

  • @imartynenko
    @imartynenko 2 роки тому

    Not buying that HyhpenateForPartner example, you could have refactored in a similar manner with a null check without discards and it would be more readable imho

  • @SecondFinale
    @SecondFinale Рік тому

    Glad he didn't use underscore prefix. "This." is a little verbose but only appears once. The underscore appears every time and doesn't tell me anything I need (unless I'm violating single responsibility).

  • @mohanrajaloganathan5587
    @mohanrajaloganathan5587 4 роки тому

    When exception happens I want to have all the parameters value in stack trace. Is it possible?

    • @johnnybravohonk6964
      @johnnybravohonk6964 4 роки тому

      Somehow, but it costs.. with IntelliTrace in VS Enterprise

    • @GeorgeTsiros
      @GeorgeTsiros 2 роки тому

      no, not really.
      void Foo (Class value) {
      value = null;
      _ = value.ToString();
      }
      by the time the exception is raised, the argument may not exist.
      Worse, the argument may have changed.

  • @WorstDeveloper
    @WorstDeveloper 4 роки тому

    What's the cost of creating tuples?
    It would be nice if we could know the performance impact of all syntactic sugar.

    • @connorboyle2092
      @connorboyle2092 4 роки тому

      ValueTuple is a struct so there are no extra allocations, but it is a mutable type, so there may be some overhead in more complex cases.

    • @WorstDeveloper
      @WorstDeveloper 4 роки тому

      @@connorboyle2092 Okey, nice. I'm also wondering if the logic of doing comparisons between tuples is more costly than simply doing a normal equality check.

    • @Skarllot
      @Skarllot 4 роки тому

      @@WorstDeveloper yes, costs more. It uses the default equality comparer for each type.

  • @willinton06
    @willinton06 4 роки тому +20

    (X, Y) = (Y, X), beautiful

  • @BryonLape
    @BryonLape 4 роки тому

    As this is Core, does that mean the Windows version of .Net is no longer being updated?

    • @ezzypoo7909
      @ezzypoo7909 4 роки тому +1

      Channel Dad Bryon Lape it’s still getting regular updates mostly for security reasons. Right now I think dotnet framework is on version 4.8.something. However, Microsoft is transitioning a lot of their new features over to dotnet core

    • @BryonLape
      @BryonLape 4 роки тому

      @@ezzypoo7909 Thanks. That's what I thought, just wasn't 100% sure.

  • @lightbringer_
    @lightbringer_ 4 роки тому

    Can we do -
    public override bool Equals(object? obj) => (obj is Point) && this == obj;

    • @tincoyan7380
      @tincoyan7380 4 роки тому +2

      Lightbringer No. if you do like that, the type of this will be converted to object implicitly, and your statement will be a referential comparison.

    • @xiety666
      @xiety666 4 роки тому +2

      I think you can do - public override bool Equals(object? obj) => obj is Point otherPt && this == otherPt;

  • @critiquememockme2053
    @critiquememockme2053 3 роки тому +1

    This stuff is too high for my beginner ass...lol hopefully after a couple of days I can come back to this video and actually understand what this guy is saying.

  • @ianbrooke6342
    @ianbrooke6342 3 роки тому +3

    I'm looking at some of those statements as they are being typed and I'm completely blank about their meaning. This language is becoming more and more like C++ which was originally referred to as a write-only language because once written nobody could ever read and understand it.

    • @RenegadeVile
      @RenegadeVile 3 роки тому

      If you follow best practices, then C++ is perfectly understandable. Don't blame a language for programmers thinking they're being clever by being obtuse.

    • @RenegadeVile
      @RenegadeVile 2 роки тому

      @@stysner4580 That's literally what I just said, not the language's fault if its features are mishandled, or conventions are not agreed upon across an entire team. Hence why I said: 'programmers thinking they're being clever by being obtuse'.

    • @raianmr2843
      @raianmr2843 2 роки тому

      It's definitely becoming C++-ish in the sense of adding more features, but contrary to popular belief, that's a super minor issue (if that's an issue at all).
      You can easily exclusively write C++11, or C# 7.3, and make sure your compilers and teams follow along. People do this all the time.
      The real issue with C++ in this case is that the language is old and at the same time, not stuck in time like C. It precedes many modern programming language design good practices and in many cases, C++ was even the first to introduce them to the mainstream community. The consequence of this is that preexisting rules in the language form weird and unintuitive outcomes when used in conjunction with newer features. C# is very immune to this, much of the language is explicit and most of the new features are just shortcuts to things you already do. The only drawback of using them is that you need to keep up and if you don't want to use them, you can choose not to keep up.

  • @adamg8284
    @adamg8284 4 роки тому +4

    This is some nice sugar and all. However, I believe maintaining code is all about making it readable and understandable.
    Is a constructor made with a one-liner tuple really more readable and understandable than a conventional one?
    So
    public Point(double x, double y)
    {
    X = x;
    Y = y;
    Distance = Math.Sqrt(x * x + y * y);
    }
    vs
    public Point(double x, double y) => (X, Y, Distance) = (x, y, Math.Sqrt(x * x + y * y));
    It's not even like the tuple alternative is faster to write or has less characters. You might as well have written this:
    public Point(double x, double y) { X = x; Y = y; Distance = Math.Sqrt(x * x + y * y); }
    And be honest - you know people are gonna one-line the shit out of tuple constructors and the like, so it will really inspire to some great! horizontal scrolling.
    My experience with tuples is like: "lets create this anonymous type using a tuple and use it as a dictionary key because i'm too lazy to create a proper struct for it..". Let me tell you right away. This does not create readable code!
    So yeah it's nice sugar and might be useful in some situations, but i haven't experienced them yet from a production-code perspective.

    • @GeorgeTsiros
      @GeorgeTsiros 2 роки тому

      when i see => (A, B) = (a, b);
      As soon as I see the first open paren I know it is initializing props and nothing more

  • @BBMMTR
    @BBMMTR 4 роки тому +3

    but the interviewer is probably using .net 3 :(( lol

  • @user-ck1kx5ie6t
    @user-ck1kx5ie6t 4 роки тому +13

    Waiting in anxiety from 24:26 till 26:22 for him to bring up the logical AND operator... and getting disappointed in the end

    • @nkusters
      @nkusters 4 роки тому

      Same :-/

    • @omri9325
      @omri9325 4 роки тому +1

      He wanted to demonstrate the new feature, but I hope you understand how hard it is to come up with good examples for these features.

  • @casperhansen826
    @casperhansen826 4 роки тому +1

    10:10 Do you really need a != Operator?

    • @MulleDK19
      @MulleDK19 4 роки тому +1

      If you implement the == operator, you must also implement the != operator. However, it can be implemented simply as !(left==right)

    • @GeorgeTsiros
      @GeorgeTsiros 2 роки тому

      @@MulleDK19 _sometimes_

  • @figloalds
    @figloalds 4 роки тому

    42:19 i know it's a demonstration of the language feature, but the hard coding of business logic parameters makes me feel uncomfortable

  • @RenegadeVile
    @RenegadeVile 3 роки тому

    Adding readonly to getters and certain methods just looks like const-correctness from C++, or is it just me?

    • @someguy3176
      @someguy3176 3 роки тому

      It still bugs me that you can set readonly values multiple times in the constructor.

    • @GeorgeTsiros
      @GeorgeTsiros 2 роки тому

      @@someguy3176 You can write your own setter that allows only one-time assignment

    • @someguy3176
      @someguy3176 2 роки тому

      @@GeorgeTsiros True, but it seems silly since the keyword "readonly" implies that it would already do that.

    • @GeorgeTsiros
      @GeorgeTsiros 2 роки тому

      @@someguy3176 the keyword "readonly" means something. It does not mean "this may only be read, not written".

  • @jeodemp
    @jeodemp 3 роки тому

    Maybe i should learn F#

  • @MulleDK19
    @MulleDK19 4 роки тому +1

    FC#

    • @gweltazlemartret6760
      @gweltazlemartret6760 4 роки тому

      There's missing "Umple" and "Kotlin" language features to have an even cooler name... :D
      Note : C# is doing great on taking inspiration at finests, be it F#.

  • @IIARROWS
    @IIARROWS 3 роки тому

    11:17 how wonder what's the efficiency...
    Test (run over 100 s):
    Temp: 91.231.584/s
    Tuple: 88.273.078/s
    I knew it! It's 3.3% slower! The tuple method is garbage! :P
    (It still depends on the type of code you need to write, 3.3% is not that insignificant)

  • @nuagor
    @nuagor 3 роки тому +2

    29:44 hyhpenate

  • @JoseFernandez78
    @JoseFernandez78 4 роки тому

    Jetbrains Rider is 10 years ahead of Visual Studio. They've been doing static analysis of code for years now.

  •  4 роки тому +47

    I have to admit that I was not impressed with the talk. The language features are fine but the way they were presented did not sit well with me. Lots of talk about reducing the number of lines of code but the way the reductions were made was mostly due to syntax (remove braces, use ternary syntax etc). Is it better? I do not think so. The usage of throwaway variable _ to throw an exception when parameter is null was also a weird example. What is wrong with having 'if' statements? I never had problems reading code with if statements and i would always need more time to grasp code which uses ternary or null coalescing operators.

    • @PrettyBlueThings
      @PrettyBlueThings 4 роки тому +1

      @Karm Asutor You guys are absolutely spot on, give me an if statement in any language and i know instantly what i'm doing. Give me some language specific syntax and I then have to figure out the 'ins and outs' of that. Somehow its becoming more and more complex in its simplicity...

    • @courtneysmith2864
      @courtneysmith2864 4 роки тому +2

      This reminds me of some old code I came across recently. The code was messy and virtually impossible to read and had to be rewritten. Having a simple if check and some {} is so much more readable and in my opinion therefore better.

    • @declup
      @declup 4 роки тому

      I assume the throwaway variable was designed primarily for destructured variable assignments. Does it have any other intended, intuitive, or especially helpful use cases?

    • @nevzataydin1
      @nevzataydin1 4 роки тому +2

      agreed. but if some new syntax become very popular (due to it`s usefulness) and made it`s way to other languages, it will make other`s life easy as well. but to do that one must made up some syntax as well.

    • @someguy3176
      @someguy3176 3 роки тому

      If you use an if statement, then I’m going to ask you to refactor it in the code review. Logical branching is the quickest way to introduce unintended side effects.

  • @Huizelogica
    @Huizelogica 3 роки тому

    ✌️

  • @jessepoulton224
    @jessepoulton224 4 роки тому +1

    26:00: => obj is Point otherPT && otherPT == this;

  • @michaelwplde
    @michaelwplde 4 роки тому +4

    21:45 Should pull the opt out feature forward... Such a waste of calories the whole NRT fiasco. 22:50 Do not care about "potential errors", speaking as a business leader and architect, I care about REAL errors, and not dumbing down my crew by failing to engage the issues at hand. 23:30 Y'all had a sweet spot in the operators a version or two ago. That was plenty sufficient to reason about the "null" question. But if there's really this aversion to the concept, why not just remove null from the language spec altogether? Of course that would be absurd as well, right?

    • @michaelwplde
      @michaelwplde 4 роки тому

      So... case in point. That was a lot of verbiage justifying *object?* , then turn around and simply leverage existing operators, with I will grant the updated *is* operator.

  • @vejay369
    @vejay369 3 роки тому

    I got diabeetus from all the syntactic sugar

  • @xFlRSTx
    @xFlRSTx 4 роки тому

    why is it brown tho

    • @Skarllot
      @Skarllot 4 роки тому

      Solar theme

    • @user-yr1uq1qe6y
      @user-yr1uq1qe6y 3 роки тому

      I thought he had nightshift mode on (or similar)

  • @DJDoena
    @DJDoena 4 роки тому

    Can someone explain to me if there's a new shortage of disk space on the horizon? I understand why a C programmer in 1988 had to write shorthand. But nowadays? Today a junior programmer gets his code rejected if s/he starts writing "for (int i = 0;" instead of using a meaningful name for "i" that tells me what "i" actually is.
    Using a tuple as a short-hand assignment for two variables doesn't make the code anymore readable or understandable. The same goes for that awful new "if" syntax that they introduce with C# 8.0.

  • @kodaloid
    @kodaloid 4 роки тому +2

    The pattern matching at the end is fancy, but in my opinion is an absolute waste of time. From a maintainability standpoint I have no idea why switch expressions were prioritised over switch ranges, they actually would make a difference to people like myself who have large volumes of code to produce with little time to make beautiful before moving onto the next job.

  • @Kaboomnz
    @Kaboomnz 3 роки тому +2

    tuples are great until you realize the compiler still creates just as much code (pretty much identical code to long form) and you give up readability. When did readability stop being a priority?

  • @KenGormanGuitar
    @KenGormanGuitar 4 роки тому +5

    I don't know. Why not instead start with data that shows where problems most happen in code, and why the C# team chose to address or improve those?
    From my perspective, when you're in an enterprise software company, with thousands of people, deadlines, cost concerns, developers on the same team located all over the globe... I'd want to see things you've enhanced and demoed that specifically address data-supported real-world issues rather than what appears to me as the C# team brainstorming about what can be better. These improvements.. maybe someone new to C# will get excited, but not so sure about the people in the trenches.
    Also, I played this at double-speed on UA-cam... we are techies... get to the point!

  • @calvinnel3954
    @calvinnel3954 4 роки тому +2

    Content seemed a bit week, and i had to play back at 1.75 and one point i was playing back 2x speed. I know vid cant know what you know and then be targeted but boy was i hoping this was something cooler than it was. the vid should start with what the content is... like some syntax rubbish and nullable types. Perhaps im too hash but ish i was hoping for more. this could of been a 5min vid if that maybe a 2 min vid.

  • @mehmettezel726
    @mehmettezel726 4 роки тому +1

    it sounds not cooked well - You get a feeling that you are thrown into aaaa multi dimensional vector space

    • @mehmettezel726
      @mehmettezel726 4 роки тому

      it is like = c# + python + something - discard => return your addres to us neil armstrong

  • @colmx8441
    @colmx8441 3 роки тому

    Change your habits: hyhpenate your code

  • @brandonpearman9218
    @brandonpearman9218 4 роки тому +5

    Readability of these new features is bad. In your private code sure its fine, but when working with a team you need to consider juniors and all the devs still to come. Shorter is not better... the very simple code syntax may be more verbose but everyone can understand and read it. Also having more ways of doing the same thing adds many different structures to your code that increases cognitive load.

    • @toddhoatson5758
      @toddhoatson5758 4 роки тому +2

      IMHO, I think the industry is straying into the weeds...
      The original purpose of programming languages was to make a way for humans to communicate with machines, where more of the burden was on the machine to adjust to our way of expressing things, rather than the opposite. The "features" shown here look more like humans being asked to communicate more like machines! This seems really backward to me, especially considering that in many cases, the human devs are building systems like Siri, Alexa, Cortana, etc. to make the machines communicate more like humans, but the devs themselves get no such benefits... : b
      So now, instead of making code that is A. accurate, B. clearly understood and C. easily maintained, we seem to be consumed with making code that is D. most clever (inscrutable?), E. most likely to impress our peers and F. as concise as possible. Not a good trend that I'm seeing...
      > when working with a team you need to consider juniors and all the devs still to come
      Preach it!!!
      > ... having more ways of doing the same thing adds many different structures to your code that increases cognitive load.
      totally agree

  • @forytube4998
    @forytube4998 2 роки тому +1

    Only thing modern is pattern matching, other just new syntax to do old things

  • @declup
    @declup 4 роки тому +2

    Geez. Why not write some Haskell-to-.NET/CLR compiler and be done with it already? The language envy of all this drip... drip... drip... adoption of ML features is maddeningly apparent.

    • @scooobydoo27
      @scooobydoo27 4 роки тому +1

      Before F# was created, there was an effort to do that very thing, but the type systems were not compatible enough to make it work. And then, work to create F# began.
      fsharp.org/history/hopl-draft-1.pdf

  • @willemvdk4886
    @willemvdk4886 Рік тому

    As a python developer, trying to learn C#, seeing this... I'm like: "did C# really just invent tuples? and it blows their mind?!" haha

  • @SergeySagan
    @SergeySagan 4 роки тому +2

    Most expert C# devs I know hate using underscores (_), now you are forcing their use? I do like the `switch` `tupple` code... also... `inbound` should be `isInbound`

    • @789blablajaja
      @789blablajaja 4 роки тому

      Its good for their intended use, like discarding out parameters.
      For pattern matching, Id prefer default => instead of _ =>, but whatever its short and if you know the syntax its nice.

  • @Mark-ml3nv
    @Mark-ml3nv 4 роки тому

    I am changing my habits, after C# since it's inception, I am moving to Java. It's C# without all the extra bs

  • @loknathshankar5423
    @loknathshankar5423 4 роки тому +2

    does it run faster? no so stick with what you're comfortable with.

  • @TillmannHuebner
    @TillmannHuebner 4 роки тому +1

    Yo dawg, i made a touple out of touples

    • @default632
      @default632 4 роки тому

      Aka "multidimensional touples"

  • @sdstorm
    @sdstorm 4 роки тому

    I really wish .NET gets its Kotlin...

  • @courtneysmith2864
    @courtneysmith2864 4 роки тому +10

    Sorry but these examples are actually harder to read and harder to understand. Having less code does not make it more readable in these cases. The original code was easy to read. The new code just jams everything together in a mess.

    • @someguy3176
      @someguy3176 3 роки тому +2

      Many of these examples are more about avoiding side effects. Both goals are important and it can be a difficult balance.

  • @Species1571
    @Species1571 4 роки тому

    "So good afternoon"
    Oh man, bad start.

  • @ibrozdemir
    @ibrozdemir 4 роки тому +2

    i am sory but this makes me have anxiety:
    if (bla bla)
    return apple;
    else
    return lemon;
    instead i would write:
    if (bla bla)
    return apple;
    return lemon;
    why would you put "else" everywhere

  • @ZdenalAsdf
    @ZdenalAsdf 4 роки тому

    Well, I was hoping to learn something new here, but instead I got nearly half an hour about creating a dumb struct holding two doubles. And even though it's that simple, the implementation is broken (by design!) because of the cached distance. And it doesn't even have a ToString method!
    In a sane language, something like that should take approximately three lines of code and should be obviously correct.

  • @DinHamburg
    @DinHamburg 3 роки тому +1

    he skipped the most urgent upgrade - fix those braces....

  • @bocckoka
    @bocckoka 4 роки тому

    wow, tuples! so advanced! how about a fucking proper Hindley-Milner?

  • @joaokiehnjr
    @joaokiehnjr 4 роки тому +1

    Readonly feature... LOOOOOKKKK: Now we have a "const" modifier like the we had in C++.
    It's amazing to see how languages evolves to become more and more close to what C++ always was.

    • @Qrzychu92
      @Qrzychu92 4 роки тому +1

      yeah, but the const feature of C++ was the most useless thing ever. You annotate one thing, then you have to annotate 20 files. Then someone just makes a cast to not const and it's worth nothing

  • @jamesthewelsh
    @jamesthewelsh 4 роки тому

    Y'all do yourself a favour and watch back at either 1.25 or 1.5x speed because as cool as it is to learn new stuff. It is really dry.

  • @ernstraedecker6174
    @ernstraedecker6174 4 роки тому

    Syntactic sugar taken from Python and VisualBasic.NET 1.0.

  •  4 роки тому +5

    Why is there so much obsession with reducing code size? Less code doesn't mean it is easier to read or that performance is better. What is next, will we change reserved words and start using € instead of public, ° instead of class etc, just to save few chars?

    •  4 роки тому +2

      ​@wubs23 I worked for 5 years mostly on developing file parsers / converters (xml, gml, xls and custom formats from measuring devices) and never had situation with 50 lines of ifs. I think that the best way to achieve code comprehension is to extract code to methods that are named correctly and document what is going on. When I review someones code, first thing I do is go thorough it quickly to understand the flow. If I stop and have to think what someone was trying to do, then sorry but I will not approve it. You should always be explicit and avoid stuff that do things automagically.

    • @courtneysmith2864
      @courtneysmith2864 4 роки тому +2

      @ Exactly! Dropping out a few ifs and having an even more terse syntax does NOT make things more readable, and so just makes it harder to maintain and actually keep working right. Having decent methods to lay out the calls into something that makes logical sense is 100% more important. I totally agree with you.

    • @declup
      @declup 4 роки тому +3

      I don't think reducing code size was the design team's main goal (tuple syntax excepted perhaps). Instead, it looks to me like they've started to prioritize expressions and patterns over statements.

    • @toddhoatson5758
      @toddhoatson5758 4 роки тому +1

      @@declup, you may be right, that may be what they are doing, I don't know... But who has been asking them to prioritize expressions over statements??? I've never heard a coworker asking for such a thing. I have never asked for this, either.

    • @GeorgeTsiros
      @GeorgeTsiros 2 роки тому

      you still don't see it?

  • @mikebreeden6071
    @mikebreeden6071 4 роки тому +3

    Typical. Saved a few characters and made the code cryptic. Code should read like a book! It should tell a story. That code is shorter, but it does not translate into words. I would never write my code that way. Maintainability is as important as anything else.

    • @igorthelight
      @igorthelight 4 роки тому +2

      That is the main problem with new "cool" features - they takes less time (less costly for companies) but code became less readable.

    • @toddhoatson5758
      @toddhoatson5758 4 роки тому

      @@igorthelight, I totally agree. However, they don't really take less time or save money for the company when you consider how much resource goes into trying to debug cryptic code...

    • @igorthelight
      @igorthelight 4 роки тому

      @@toddhoatson5758 Agree.
      So it's just looks more cool then - nothing more :-)

    • @someguy3176
      @someguy3176 3 роки тому +2

      It’s about following functional programming principles in an object oriented language. You’ll have less bugs, but the code does end up looking a bit awkward.

  • @misterbeach8826
    @misterbeach8826 4 роки тому

    swift and kotlin are so much more powerful in 2019/20, think guard let. the null check in c# still looks awful

    • @courtneysmith2864
      @courtneysmith2864 4 роки тому +1

      Maybe.. but how many Guard let pyramids of doom are out there? C# is still more powerful in many areas - e..g. Linq and database frameworks considering those were introduced back around 2008 in c#. Core Data is nowhere near as good.

  • @SebGruch
    @SebGruch 4 роки тому +2

    Returning tuples? This is the single major thing why I'm not into functional languages. What does it mean at all: (int, int, int, double)? Totally useless, and waste of time figuring it each time you encounter such thing. Perhaps fine with the Point representation... But not with anything more complicated.

    • @Qrzychu92
      @Qrzychu92 4 роки тому +1

      That's one of the points he made. When you have more than 3 things in a tuple, make a class/struct. I'm personally sick of creating 2-3 property classes just to be able to return 2 ints at the same time. Also, after playing with F# a little, I really like those changes in C#

    • @SebGruch
      @SebGruch 4 роки тому

      @@Qrzychu92 Usually, when I return set of values, it has some meaning, therefore I have no problem creating dedicated type for it. Especialy with the help of R#.
      On the other hand, I would definitely rather use tuple than KeyValuePair. Yuck ;)

    • @Qrzychu92
      @Qrzychu92 4 роки тому

      @@SebGruch My favourite example is working with sets. For some reason, they are like the only non mutable collection in C#. When you have parsedItems and remaingItems and other sets with groups of items from various sources. I know, you will say "use list instead", but sets are good for some operations, like cross section, exlusion, etc. Then you either use two ref arguments (which becomes ugly if you need to pass them few levels down) or just return a pair.
      Yes, you can always make a class to hold the state, but sometimes it feels like a huge overkill. On top of that, you don't have use use the tuples if you don't want to. They added them so we CAN use them, not HAVE to, no one is forcing anyone to do anything. It's not Elm :P

    • @SebGruch
      @SebGruch 4 роки тому

      @@Qrzychu92 Well, unless you encounter a code where someone used this heavily ;-) And I understand what you mean about this set usage - I didn't like being forced into such resolution either ;-) Perhaps I'm too many years into "procedural" coding to feel comfortable in functional execution of control...

    • @rotgertesla
      @rotgertesla 4 роки тому +2

      You can actually name your tuple members like so (example): (int x, int y, double distance)
      You will get intellisense support when you will use the tuple.

  • @alfredopozos6981
    @alfredopozos6981 3 роки тому

    The madly brush immunohistologically plant because basketball macroscopically object minus a material lettuce. endurable, mysterious observation

  • @brtk7
    @brtk7 4 роки тому

    Just bullshit that doesn't provide real value. Language doesn't need tricks.... Look at e.g Java it grows because it was addressed for industrial, no one cares that working on spring was a nightmare, or golang this is pure language to solve real problems, great for microservices, make by engineers for engineers. Only Linux matters!

  • @yackawaytube
    @yackawaytube 4 роки тому +1

    Wake me up if you can use C# to tackle 3 of the most important segments - webapp, smartphone, and IoT devices

    • @p46288
      @p46288 4 роки тому +21

      webapp: dotnet.microsoft.com/apps/aspnet/web-apps/blazor
      smartphone: dotnet.microsoft.com/apps/xamarin
      iot: github.com/dotnet/iot

    • @SinDed0s
      @SinDed0s 4 роки тому +2

      I would also add distributed segment : getakka.net/

    • @oleggavrilov7083
      @oleggavrilov7083 4 роки тому +16

      Wait, you really thought you can't use .net for that? Really?

    • @josda1000
      @josda1000 4 роки тому

      I find it hard to believe that you are watching this video within a day of its release and you don't know you can use the microsoft stack for these purposes... what am I missing?

    • @PankajNikam
      @PankajNikam 4 роки тому +4

      Seems to be a Java fan which works EVERYWHERE :)

  • @SayWhaaaaaaaaaaaaaaaaaaaaaaat
    @SayWhaaaaaaaaaaaaaaaaaaaaaaat 3 роки тому +1

    Hate when people shorten code... Source code is for humans to read. Not computers.

  • @DanHowardMtl
    @DanHowardMtl 4 роки тому

    Java > C#

    • @Rsharlan3
      @Rsharlan3 4 роки тому

      public static operator> (Lang lang1, Lang lang2)
      {
      return lang1.Age > lang2.Age;
      }

    • @DanHowardMtl
      @DanHowardMtl 4 роки тому

      @@Rsharlan3 Are you trying to say operator overloading was a good idea? It wasn't. This feature specifically was the cause of the downfall of Smalltalk. At least Sun learned a lesson unlike MicroCrap.