What's New in C# 8.0

Поделиться
HTML-код
  • Опубликовано: 10 сен 2024
  • Several new language features are coming to C# in the next release, included in Visual Studio 2019. Mads Torgersen will give us a quick look at how to avoid null reference exceptions with nullable reference types, how to consume and produce asynchronous streams, and much more.
    Twitter: @MadsTorgersen
    Learn more about C# 8.0: aka.ms/csharp8

Комментарии • 618

  • @SergiuTalnaci
    @SergiuTalnaci 5 лет назад +191

    0:34 - 5:34 Nullable reference types
    5:35 - 7:48 Async streams
    7:49 - 8:46 Array slice
    Thank you and best wishes to you and your team Mads, happy holidays from Aarhus.

    • @ACHUAskar
      @ACHUAskar 5 лет назад +4

      Sergiu Talnaci MVC (Most Valuable Comment)
      Thanks Mate

    • @SkyLee91
      @SkyLee91 5 лет назад

      Thanks god. It helps to save the video. LOL

    • @zhongwang3599
      @zhongwang3599 5 лет назад +1

      what a convenient comment

    • @TarBazar
      @TarBazar 5 лет назад +1

      Async Streams .. .Beautyyyyyy

  • @fuzzylilpeach6591
    @fuzzylilpeach6591 5 лет назад +50

    The switch expressions look so clean, basically like a truth table. Thats awesome!

  • @MuhammadAhmed-vi2xt
    @MuhammadAhmed-vi2xt 5 лет назад +64

    i used javascript,python,php,java. But i enjoyed alot to work with C# in its own best IDE visual studio. C# gives real understanding how programming language work in more disciplone way. Thumbs Up guys and Thank you for your great gift of C# 8.0.

    • @madstorgersen7881
      @madstorgersen7881 5 лет назад +13

      Thanks for the kind words!

    • @FlameRat_YehLon
      @FlameRat_YehLon 5 лет назад

      For some edge cases in math, F# is a bit more capable. But that edge seems to get smaller and smaller and maybe in the future F# will only really be useful for very abstract stuffs or for those who just hates brackets.

  • @elzurotsyry
    @elzurotsyry 5 лет назад +592

    C# 10.0 will read your mind:
    var person = new ("John", "Connor");

    • @refield6898
      @refield6898 5 лет назад +8

      You also can do Person p = ("",""); trick with ValueTyple and implicit conversion

    • @ahdungai8489
      @ahdungai8489 5 лет назад +7

      @@namelastname4077 Then we can
      var person = new (Encoding.ASCII.GetString(Convert.FromBase64String("JTI4LiUyMCUyOSUyOCUyMC4lMjk=")));

    • @SrIgort
      @SrIgort 5 лет назад +3

      @@ahdungai8489 I think that the compiler would be able to optimize this and so block It.

    • @nosmirck
      @nosmirck 5 лет назад +14

      new should be optional

    • @Happypig375
      @Happypig375 5 лет назад +7

      Isn't it F# records?
      type Person = { FirstName: string; LastName: string }
      let person = { FirstName = "John"; LastName = "Connor" }
      Still have to specify the record labels though.

  • @dr.joint4204
    @dr.joint4204 5 лет назад +80

    first 4 minutes is programming life in a nutshell... gets a bug, solved it.... puts in feature, gets 10 more bugs

    • @lionkor98
      @lionkor98 5 лет назад +4

      I found it really amusing, too, lol

    • @tokertl9899
      @tokertl9899 5 лет назад +2

      and we solve all the bugs until we get a running code lol

    • @mr.mikaeel6264
      @mr.mikaeel6264 4 года назад

      They say if you step on a cockroach it releases their eggs. In a sense the same as you would also get more bugs. Now the cockroach thing is a myth so does that make Microsoft a more anoying thing to deal with then? ^^

  • @RobProuse
    @RobProuse 5 лет назад +264

    It is an amazing time to be a C# programmer!

    • @madstorgersen7881
      @madstorgersen7881 5 лет назад +3

      Good times indeed!

    • @PhillipMwaniki
      @PhillipMwaniki 5 лет назад +15

      @A Hero Academia Not really. I've been doing Java n Js for a little over 2 years and I humbly admit that C# is the future

    • @TheAndrejP
      @TheAndrejP 5 лет назад +8

      @A Hero Academia if you mean Electron apps, it's not the future, it's just an unfortunate turn of events that the most broken language out there is the easiest to port to different desktop and mobile systems because every system has a web browser nowadays.
      Python though... as a prototyping tool maybe... but reimplementing anything in python? Where? Why?

    • @nosmirck
      @nosmirck 5 лет назад +1

      @@PhillipMwaniki Flutter and Dart are the future

    • @precogtyrant
      @precogtyrant 5 лет назад +1

      @@nosmirck Typescript already ate Dart alive.

  • @edwinfcapidos
    @edwinfcapidos 5 лет назад +139

    Just can't leave C#. The best modern programming language paired with the best IDE.

    • @idontusenumbers
      @idontusenumbers 5 лет назад +5

      Rider? VS with ReSharper? Have you used IDEA?

    • @edwinfcapidos
      @edwinfcapidos 5 лет назад +8

      idontusenumbers i tried VS with ReSharper and it's great. Just can't shell out money for that. I tried IDEA using Kotlin. It's good as well but not as great as VS.

    • @idontusenumbers
      @idontusenumbers 5 лет назад +6

      VS consistently lags behind IDEA and ReSharper. Every feature demonstrated in the recent VS 2019 preview has been in IDEA for at least 5 years. It's been that way pretty consistently with each release.

    • @TheAndrejP
      @TheAndrejP 5 лет назад +1

      ​@@idontusenumbers depends on what you need, but the one thing that has been consistent as well is how bloated IDEA has been getting over the past few years. I guess more functional tools in the developers' arsenal also brings some negative consequences sometimes...

    • @idontusenumbers
      @idontusenumbers 5 лет назад +1

      @@TheAndrejP what do you mean by bloated? It's driven by plugins; I have way more than the default set enabled and it loads fast, is very responsive, and never crashes. Visual studio feels more boosted to me and I can't turn of nearly as much.

  • @Trillykins
    @Trillykins 5 лет назад +28

    Was using Python yesterday for Advent of Code and thought that it would nice if we got array slicing for C#. Nice timing lol. Looks good!

  • @ThomasPoth
    @ThomasPoth 5 лет назад +22

    Nullable-reftypes are amazing, thanks for that.

    • @FlameRat_YehLon
      @FlameRat_YehLon 5 лет назад +3

      That feature is actually more of "non-nullable-reftypes" because everything used to be defaulted to be nullable :)

  • @ozgurakpinar_gr
    @ozgurakpinar_gr 5 лет назад +118

    Where is C# going? This is so absurdly good that I cannot believe all these are real (beginning from C# 7.0).

    • @madstorgersen7881
      @madstorgersen7881 5 лет назад +30

      Glad you like it! :-)

    • @PiotrKula1
      @PiotrKula1 5 лет назад +6

      Imagine how I feel. I started in VB5 🤪 no seriously though. C# is blowing my mind past few years

    • @r357bg
      @r357bg 5 лет назад

      @@PiotrKula1 and still VB6 are much faster than this

    • @Craigeek
      @Craigeek 5 лет назад +2

      C# is transforming from an Application Programming Language (Line of business "apps") to a Systems Programming language (OS)

  • @AnuragJ100
    @AnuragJ100 5 лет назад +1

    The way this team executes on adding new features to this language is really excellent. I remember Anders talking about non-nullable reference types years ago, and they figured out how to do it in such an elegant way. Good stuff!

  • @brucepierson9941
    @brucepierson9941 5 лет назад +30

    I can foresee default interface implementations being badly abused.

    • @stacklysm
      @stacklysm 5 лет назад

      I though that too... This is just virtual methods all over again. But the other features were amazing, specially switch expressions

  • @TheFerdi265
    @TheFerdi265 5 лет назад +2

    Non-nullable references, null-warnings for nullable references, async streams, better inference for new, and FINALLY switch expressions with patterns and exhaustiveness checking.
    C# is getting more and more functional, and taking notes from other functional and functionally-inspired languages like Scala, MLs, Haskell, or Rust (or F# ;P)
    Hoping C# will get something similar to Rust's Enums (like type-safe tagged unions) or Scala's Case Classes.
    All these code readability, expressiveness, and conciseness improvements, in addition to type-safety improvements (null is now completely a type-system thing) really make C# a language I _WANT_ to code in.
    And that's from a usually mainly Linux guy who mostly codes in C, Python, JavaScript and Rust, and usually only C# at internships.

  • @washington6986
    @washington6986 5 лет назад +323

    I am profoundly thankful to the past me who decided to learn C# instead of *other languages*

    • @madstorgersen7881
      @madstorgersen7881 5 лет назад +91

      I'm glad you learned C#! Don't hesitate to learn more languages too!

    • @madmanga64
      @madmanga64 5 лет назад +6

      I agree especially with Blazor web assembly looming and now open source WPF

    • @ILovePancakes24
      @ILovePancakes24 5 лет назад +34

      yea dude just focus on one language, instead of the foolish concept of learning the concepts under the language and being able to use any language ever written with minor effort like I did. :) (/s for chickenheads)

    • @ZoidbergForPresident
      @ZoidbergForPresident 5 лет назад +2

      @@ILovePancakes24 This.

    • @dariusduesentrieb
      @dariusduesentrieb 5 лет назад +10

      well you would think differently if you'd also learned C++23

  • @abdoulrhmanrif4758
    @abdoulrhmanrif4758 5 лет назад +4

    Thank you guys for taking such good care of us. :)

  • @TheUnlocked
    @TheUnlocked 5 лет назад +1

    These features look amazing. I've been following the more abstract discussions on csharplang, but actually seeing the features used in a project is so much cooler.

  • @bertye
    @bertye 5 лет назад +3

    Wow! These are awesome additions. I like the way C# is going!

  • @kewqie
    @kewqie 5 лет назад +282

    I think C# is the most elegant language out there today.

    • @grproteus
      @grproteus 5 лет назад +24

      Definitely not elegant. "random" weird operators here and there and on a per-feature implementation does not make for an elegant language.

    • @rockmehunny
      @rockmehunny 5 лет назад

      On the CLR Yes but not overall....look at kotlinlang.org/ Now they have taken inspiration from Java 8 Default methods on interfaces and null check from Kotlin.

    • @moofymoo
      @moofymoo 5 лет назад +15

      but if you define "elegant" as "work horse for 9-18 job with some cool features you can tinker when you need to spend those 30minutes before next useless meeting" then it is!

    • @giovannisolimeno5040
      @giovannisolimeno5040 5 лет назад +8

      OCaml would like to have a chat with you

    • @Sydra.
      @Sydra. 5 лет назад +10

      Maybe there is too much boilerplate in C# but yeah it's a pretty nice language. I would be happier with some "global using" feature.

  • @FlameRat_YehLon
    @FlameRat_YehLon 5 лет назад +3

    F#: hey look at my clean code!
    C#: IT'S MINE NOW

  • @TomasVasquez
    @TomasVasquez 5 лет назад +223

    Array slicing, FINALLY!!!!

    • @focl2003
      @focl2003 5 лет назад +1

      How is that useful enough?, may be video games?

    • @greenvm
      @greenvm 5 лет назад +16

      @@focl2003 It's useful for a million things, I'm using it when getting data from an array that contains FFT of audio

    • @focl2003
      @focl2003 5 лет назад +1

      @@greenvm It should be, y use linq everywhere but I know it's not that low level.

    • @galatei11
      @galatei11 5 лет назад +24

      yeah, but the syntax is horrible, why not just use the python syntax??? Too proud to admit it's better? array[1:2], array[:2], array[:-2], array[-3], etc... so much better!

    • @Happypig375
      @Happypig375 5 лет назад +1

      But the range end is implicitly exclusive and can't be changed. D:

  • @MiningForPies
    @MiningForPies 5 лет назад +12

    Don't forget if you don't like a feature (like default implementation in an interface) then you don't have to use it.
    Been developing C# apps since 2006 and I've very rarely used abstract classes, as they're not something I like tying myself to.

    • @2Fast4Mellow
      @2Fast4Mellow 5 лет назад +3

      That only works if you're not part of a team!
      Default interface implementations are mixin of a interface and an abstract base class. It creates lazy developers and it takes away the concept of a blueprint! It is a terrible idea and I hope it can be turned off in a solution-wide manner or stop compiling when MSBuild encounters such a construct..
      Changing existing interfaces should not be taking lightly. One should really reflect why such a change is necessary. Often a derived interface works just as good and otherwise you should do the work and fix the implementations that are broken by the interface change.

    • @MiningForPies
      @MiningForPies 5 лет назад

      @@2Fast4Mellow I've worked in huge teams and never had an issue.

    • @2Fast4Mellow
      @2Fast4Mellow 5 лет назад +3

      ​@@MiningForPies That is probably because you are only part of a team and not managing a team. I'm a software architect and one of my job is to enforce our coding standards, rules and conventions.
      StyleCop(.Analyzers) have (currently) only support up to c# 7.3. So, if a new intern (which watched this episode and thinks this is a quick way to extend interfaces (we follow SOLID principles, so basically everything (even entities, but that reason lies in our MongoDB ORM) is a interface), I currently have no way of stopping him, even when the coding standards say that default interface implementations are not allowed.
      If you want to use the concept of default interface implementations in new code, you can define a normal interface and create a (abstract) base which marks all methods and properties as abstract. Need to be implemented explicitly by every concrete implementation. Than when you introduce a new method to the interface, you can add a virtual method to the base class and all implementations that inherit from that base class will have that default implementation. Concrete classes that implement the interface, but not inherit from the base class will still break.
      Sounds very much like the concept of a default interface implementation. Except that if I create a new concrete implementation of the interface, it is MY decision to inherit from the base class. However, when I choose NOT to use the base class, the developer that made the interface change, will need to consult with the authors of the broken implementations, if the implementation in the base class can be copied to the broken implementation. C# will not suddenly 'add' a default implementation to my class. This is a very important architectural standpoint..
      But I'm sure that once C# 8 is officially released, StyleCop gets an update as well, so I can enforce that default interface implementations never makes into TFS because it is stopped by the checkin rule..

    • @MiningForPies
      @MiningForPies 5 лет назад +1

      @@2Fast4Mellow tools like style cop should never, ever, replace proper peer reviews.
      It sounds like a nightmare forcing everything to be an interface.

    • @2Fast4Mellow
      @2Fast4Mellow 5 лет назад +2

      You can't everything peer review. Well, you can, but than you won't make your deadlines. Style cop is a very good solution to enforce coding standards, rules and conventions. It is very simple, if you can't commit (or shelve) a default interface implementation to TFS, there is also no need for a peer review! Do you have any idea how much time this saves? Also peer reviews usually examine the requested feature, they spend almost no time checking if you did follow all the coding standards, rules and conventions..
      We have written our own ORM toolkit. Let's say you have a product entity. Magento requires different fields than Prestashop, Amazon or SalesForce. So, we have a 'base' order entity and each shop specific implementation add it own fields. So you have a Product, MagentoProduct and AmazonProduct entity. So why the interfaces. Converting product into AmazonProduct and MagentoProduct is very resource intensive because of the casting to concrete types.
      That is why we use interface entities. So, you also have IProduct, IAmazonProduct and IMagentoProduct interfaces. With the use of the reflection magic we're able to dynamicly create a 'super' entity that implicit implement IProduct and explicitly implement the addon product interfaces. This super entity has all three implementations, so passing the super entity as IMagentoProduct or IAmazonProduct is possible without casting. You don't get passed a AmazonProduct anymore. Within product document each addon has it's own section addon_{addonid}_{entityname}. The super entities than for example has a property Addon_{addonid}_amazon_product_sku which explicit implements IAmazonProduct.Sku. But the same entity can also hold a Addon_{addonid}_Magento_product_sku which implements IMagentoProduct.Sku.
      Developers don't have to create these super entities. The system does that for them, but because you don't get your original interface implementation passed to your addon, you need to use the entity interface.
      Also the 'I' from SOLID stands for Interface Segregation Principle which states that you should only program against interfaces. Interfaces are also very easy to mock and fake and that makes unit testing a breeze.. SpecFlow is used to 'prove' to the customer the code is working as described (not as hoped). That is next to the regression tests and e2e intergration tests. Writing code is at max 25% of the time spend by a developer. Writing unit tests takes at least as much time writing. Than you get the BDD and E2E tests, updating documentation, manual testing and communication (with team members or stake holders). Remember done is done. For example when we need to asses how much time developing a certain feature costs, we simply multiply the 'raw' development time by six. The first four multiplications are for the development team, the 5th for the account manager and the 6th is basically spare time. When your 3 days late, the customer is mad. When you're 3 days early, the customer throws you a parade.. We like parades!

  • @thomasanderson1416
    @thomasanderson1416 5 лет назад +12

    Can someone explain to me why not write instead :
    return switch (p. FirstName, p. MiddleName, p. LastName) {
    ...
    }
    Sounds more intuitive to me.

    • @EthimjosVelo
      @EthimjosVelo 5 лет назад +4

      "switch" is a statement and not a function, and so it cannot return any value. The return statement requires for the value that will be returned to be explicitly specified, stored in a variable or returned by another function. Your way of writing the recursive pattern is similar to a function call while the presented way is similar to an anonymous function with a switch statement inside it. If you use it like that, it would be very easy to confuse the switch statement with a function.

  • @ReuelRamos
    @ReuelRamos 5 лет назад +1

    The only thing that I am not comfortable yet it with the 'Default Interface Members'. If you give a body to the interface, now it is no longer an interface, but sort of an abstract class having the new members implemented and the old ones as abstract members (sorta!). I am still trying to convince my self that it is a good idea.

  • @vector_____
    @vector_____ 5 лет назад

    Great new features Mads, all of it is stuff I've always wanted. Keep elevating C# to new levels and bringing us more awesome stuff to play with.

  • @Ziretech
    @Ziretech 5 лет назад +4

    I really don't like the new default interface implementation feature. Feels like it will be misused by some. Probably in a project I will have to maintain in the future...

  • @vitaliiyarema
    @vitaliiyarema 5 лет назад +5

    From .NET 4.6 version you (Microsoft) are reading my thoughts. When I think It would be nice to improve coding in this part, you do it the next version. Thank you for your work.

  • @metorical
    @metorical 5 лет назад +1

    Very good explanation of the new language features. Thanks for the video!

  • @alexwilli
    @alexwilli 5 лет назад +20

    C dev here to admit that C# makes me swoon.

  • @WolfersHD
    @WolfersHD 5 лет назад +1

    I don't even use C# anymore but like watching these because they're always done so well. Microsoft has become my favorite company and I really hope they keep doing the amazing job they've done over the last 5 years.

    • @carrott741
      @carrott741 5 лет назад

      Microsoft? Your favorite company? You poor, uninformed man...

    • @WolfersHD
      @WolfersHD 5 лет назад

      @@carrott741 They are the tech giant I have the most favorable impression of, favorite company was the wrong words.

    • @carrott741
      @carrott741 5 лет назад

      @@WolfersHD I see.

  • @eriknystrom9293
    @eriknystrom9293 5 лет назад +4

    Some great things. Really looking forward to the nullable reference types. This is an amazing thing that has been missing from the mainstream OO languages. Especially like the subtle yet clear and consistent syntax.
    I almost want it to give errors instead of warnings. Almost.

    • @oathwine
      @oathwine 5 лет назад

      Some of the other languages have added the Maybe monad to their standard library. E.g. Option/Optional in Java/Scala. One advantage with this is that you can view e.g. Option as a container with zero or one elements. This means that you can use a nice linq-like chain expression on your optional instead of multiple if-statements that all check if the intermediate result is not null. Another advantage is that it is just a generic class that behaves like everything else in the type system, and not some special syntax or built-in feature in the language that complicates the language unnecessarily.

  • @alinawaz4034
    @alinawaz4034 5 лет назад +34

    i can easily say the best language of this time!!

    • @huwang102
      @huwang102 5 лет назад +2

      @Solve Everything dotnet core?

  • @mykilpee
    @mykilpee 5 лет назад +2

    The Case Expressions are awesome!

  • @nmarcel
    @nmarcel 5 лет назад +1

    C# is the best hybrid language ever! Not only for its features and evolution, but also for its ecosystem of .NET (both, Framework and Core), IDE, tools, libraries and community. Plus, now we can have it running on the browser with WASM+Mono. COOL!! ...and thanks Mads, Anders, Dustin, Eric, Gafter, and all the other people that together created this masterpiece!

  • @SJ-ds8lp
    @SJ-ds8lp 5 лет назад

    Some things I would like:
    * Inline classes (like kotlin)
    * readonly ref struct as default (the number of hoops I have to go through to get a safe, immutable and performant type is horrendous)
    * immutable as default, maybe introduce a new declaration for immutable variable: immut a = 10? And all recursive immutableness should follow through, like rust.
    * numeric generics
    * traits (default interface with operator overloading)

  •  5 лет назад +6

    Amazing job. You are tracking and learning from new languages.

  • @henke37
    @henke37 5 лет назад +4

    "Default interface members" You are so close to real multiple inherence. Don't chicken out now!

    • @St4rdog
      @St4rdog 5 лет назад

      That's hilarious. I was just reading about Lua mixins and was wishing C# had them...

  • @krm1t
    @krm1t 5 лет назад +9

    I understand why they choose to make the nullable reference types feature a thing that must be enabled - I generally like opt in stuff.
    But personally i would have liked this one to be the other way around.
    When creating a new project i have to enable a feature that (at least to me) makes sense to always have enabled - That seems wrong.
    If it was the other way around then when upgrading i suddenly get a lot of warnings (remember your code will still compile and run) I can then choose to say i don't care and opt out of the feature to remove the warnings.

    • @irwtla1
      @irwtla1 5 лет назад

      You could just add that compiler directive to your c# class template so every class you create has it regardless of the project settings.

    • @krm1t
      @krm1t 5 лет назад

      @@irwtla1 Thanks for the workaround but not really where i was going with my message :)

    • @madstorgersen7881
      @madstorgersen7881 5 лет назад +10

      I think we should probably have it on by default in new C# 8.0 projects. But people open and upgrade existing projects for many reasons, and many have "warn as error" on. We just can't break those scenarios.
      Maybe we can give an informational message telling them how many warnings they would get if they turn it on! :-D (only half joking)

    • @SimonBuchanNz
      @SimonBuchanNz 5 лет назад

      @@madstorgersen7881 "CS4000: Not all warnings enabled"

    • @christobanistan8887
      @christobanistan8887 5 лет назад

      A lot of the time non-nullable refs mean more code. I don't like them much since I am a careful programmer and I don't get null refs much.

  • @hssjohng8662
    @hssjohng8662 5 лет назад

    Implicitly typed new-expressions. Best damn thing for sure, THANK YOU

  • @Max_Jacoby
    @Max_Jacoby 5 лет назад +7

    I'm the only one who want them to stop? I don't want source code looked like a poem, it's a code. It has to has easy-to-see logical structure.
    P.S. New derictive is a joke, what is it, php?

  • @pranayamr
    @pranayamr 5 лет назад +3

    I think last feature of interface break ISP principle , i think there is no need to add method body in interface

  • @rudreshgp
    @rudreshgp 5 лет назад +221

    3 dislikes from #JAVA people. I can understand your pain java people..

    • @ACogloc
      @ACogloc 5 лет назад +33

      Eh, we've got Kotlin.

    • @you0neville0tube
      @you0neville0tube 5 лет назад +4

      ​@@ACogloc yes java got a bunch of stuff from c# :D

    • @Grimlock1979
      @Grimlock1979 5 лет назад +4

      They're finally getting local variable type inference...

    • @TheAndreArtus
      @TheAndreArtus 5 лет назад +10

      @@ACogloc, Yes, Kotlin has these features for a while now, but so does F#. I use many different languages (for fun and profit) incl. Kotlin+Java and C#+F#; it's a good time to be a programmer. Maybe someone out there is having fun with Java, who knows?

    • @wil-fri
      @wil-fri 5 лет назад

      @@TheAndreArtus C#, PHP, Java, C++, javascript, and I know VB

  • @sanjaythorat8521
    @sanjaythorat8521 5 лет назад

    Thank you Microsoft. You guys are keeping us busy to learn new things and adding values to this technology world.

  • @superpcstation
    @superpcstation 5 лет назад +3

    OMG MADS I'm so excited!!!

  • @shouvikroy4685
    @shouvikroy4685 5 лет назад

    Happy to see these features in C# ...these have been present in Scala long long back...I'm happy for both the languages boasting these

  • @ScottieSLG
    @ScottieSLG 5 лет назад +20

    I always just use (p.MiddleName ?? string.Empty). Works perfectly and way less code.

    • @Gunnerpunk
      @Gunnerpunk 5 лет назад +7

      Only problem with that in this case would be that if there was no middle name, you wouldn't want to include the extra period and space. So I would do something like (p.MiddleName != null ? p.MiddleName + ". " : string.Empty)

    • @viniciusvbf22
      @viniciusvbf22 5 лет назад +2

      Actually, it won't work in the given example - first char of MiddleName followed by "." = MiddleName[0] + ".".

    • @rafaelvascc
      @rafaelvascc 5 лет назад

      @@Gunnerpunk (p?.MiddleName ?? string.Empty)
      EDIT: Ah sorry, i misunderstood your question. Still, we need to check if p isn´t null somehow.

  • @yamazakialex2307
    @yamazakialex2307 5 лет назад

    I love how C# is getting better and better every year!

  • @kazeryuu3603
    @kazeryuu3603 5 лет назад +3

    This language only gets better!

  • @imgenus
    @imgenus 5 лет назад

    All these are nice. One thing I really want is making `new` keyword optional, like what Dart did

  • @beButters
    @beButters 5 лет назад +87

    White background..... Triggered!!!!!!

    • @BGraves
      @BGraves 5 лет назад +14

      I know dude... you gotta have that black screen in a dark room while techno plays and you recline in a layback hacker chair with ceiling suspended monitors while matrix plays on the second monitor yelling "I'm in!" every time you run a debug

  • @setsunaes
    @setsunaes 5 лет назад

    C# just keeps getting better and better. I'm very interested in Async streams. I have had recently developed something very similar to the example and it was a pain in the arse.

  • @shaunsales8313
    @shaunsales8313 5 лет назад

    Mostly watched this because it's a joy listening to Mads talk about C#. Appreciate the adoption of more functional-style expressions. However, I'm curious what the C# team thinks about Data Oriented Design, as a game developer it's a big part of how we architect large titles.

  • @captainfoambeard2846
    @captainfoambeard2846 5 лет назад +2

    Not a fulltime developer, sporadically using it for writing system tools since C# 2.0, but man, it's hard to keep up with all these features. It starts to feel bloated to me.

  • @JosephCatrambone
    @JosephCatrambone 5 лет назад +3

    It looks like Kotlin! :D No disrespect. I think that's a good indicator that we're converging on good ideas.

  • @TheCaptainPorkchop
    @TheCaptainPorkchop 5 лет назад

    I would expect more dare from a new major version of a language. I stand amazed by the awesome simplicity of Go language. C# could learn a thing or two.

  • @anders1245
    @anders1245 5 лет назад

    I understand why people who work in C# and .NET all the time are grateful for time-saving features. But for someone like me who only works with them on occasion, the extra functionality has been decreasing the language's readability and increasing the learning curve. I can write programs in C# because the fundamentals of the language are the same as other OOP languages that I use all the time. But I wouldn't feel comfortable interviewing for a job as a C# developer even though I've written the back end for my personal web apps with C# and ASP.NET (which in itself changes rapidly). It's very much a skill that if you don't work with it regularly, you fall behind because of how quickly it advances. I appreciate the power of the framework, but I have to consider my employment viability when picking technologies to use in my projects. And because my projects are desktop-style web applications that are 95% front-end work, I'll never be able to devote the steady time to C# and ASP.NET it takes to maintain marketable skills. Anyway, you guys are clearly doing great work. I just wish it was something I could justify investing my time in.

  • @RobertMulderNL
    @RobertMulderNL 5 лет назад +2

    We need a poster with all these improvements (preferably one that goes back to the older C# versions too)

  • @doge9203
    @doge9203 5 лет назад +1

    in 10:21 how can I apply a default case?

    • @geeknath
      @geeknath 5 лет назад

      something like this
      _ => string.Empty;

  • @INFEL8
    @INFEL8 5 лет назад +1

    Hm... Interface can has methods now... (it it possible and in old versions with IL, but not easy)
    What general difference between interface and abstract class now? (except multi inheritance)

  • @markokrstic3164
    @markokrstic3164 5 лет назад

    I really like those changes in foreach loop, makes life easier.

  • @dotnetdevni
    @dotnetdevni 5 лет назад

    I can’t wait till see what open source does for win forms.

  • @vkg.codefactory
    @vkg.codefactory 5 лет назад

    I personally like default interface member, it is useful for many of my use cases, thanks Mads for the sneak peak of VS2019

  • @prostra_ganesha
    @prostra_ganesha 5 лет назад

    Nice, recuresive patterns and switch expressions looks cool and reminds me about Rust's pattern matching.

  • @alinawaz4034
    @alinawaz4034 5 лет назад +21

    i wish ASP.Net become as popular as PHP is !! Micorsoft Please do something because web is the biggest platform!! make a Front end Framework for browser with C# which will easy as WPF and can also make PWA(Progressive Web Apps)

    • @mitikox
      @mitikox 5 лет назад +6

      Blazor?

    • @erinhoxha3912
      @erinhoxha3912 5 лет назад +4

      @@mitikox I wish blazor would take off but, right now it's not ready for production

    • @ssoltani498
      @ssoltani498 5 лет назад +8

      The only reason that PHP is (maybe) more popular than ASP.NET is, PHP THINGS (server, DB, etc.) are cheaper or even free.

    • @florianvandillen
      @florianvandillen 5 лет назад

      ASP.NET + Blazor is going to make our lives a lot easier!

    • @samuelgrahame3617
      @samuelgrahame3617 5 лет назад +2

      Blazor is not going anywhere until it can access the dom. Directly, not through js.

  • @marc2377
    @marc2377 5 лет назад

    What a time to be alive.

  • @endowdly
    @endowdly 5 лет назад

    I see the C# switch is finally catching up to the PowerShell switch and gaining ground on the match statement from F# :)

  • @lionkor98
    @lionkor98 5 лет назад

    Just amazing. I'm so disappointed that my University is teaching us Java (and old java at that), instead of this language. This will become the industry standard as soon as we have a reliable and nice x-platform .NET Standard, it will very likely replace C++ and Java in many application cases. It's slicker than anything I know, great job, and please keep this going. Also great to see you actually interacting with the community.

  •  5 лет назад

    Interesting features. Thank you.

  • @neralem
    @neralem 5 лет назад

    Array slicing in C#? OH GOD THANK YOU!!!

    • @FlameRat_YehLon
      @FlameRat_YehLon 5 лет назад

      You can already slice using LINQ stuffs, but having some sugar is good too, I think.

  • @TheFunKing33
    @TheFunKing33 5 лет назад

    Instead of adding 30 new commands of spaghetti code(creating more bugs) to deal with, just tell the compiler that null = empty. This has been working great for Javascript and Basic compilers for the over 20 years.

    • @ZeroXionXZ
      @ZeroXionXZ 5 лет назад

      Null being empty can carry to many undesirable situations carried by assumptions, which is something you would not expect from strong typed languages

  • @keweiwang1449
    @keweiwang1449 4 года назад

    The Language extension part is really like λaskell

  • @jitusurve
    @jitusurve 5 лет назад +2

    All looks great... except interface with implementation?!!

  • @Arhnuld
    @Arhnuld 5 лет назад +1

    Great video! Thanks!
    That syntax is added to make some things just a little simpler makes me wonder if C# isn't just done now. I feel like it is the best language already as it is now and that you can still come up with new cool stuff amazes me..
    Perhaps all these small things will make programming more difficult because there's more to learn for beginners to understand existing code. Am I getting old? Lol.
    Is there any big stuff coming in the future?

  • @EricSundquistKC
    @EricSundquistKC 5 лет назад

    Love the AsyncEnumerables! C# has Observables now.

  • @kevincharest1695
    @kevincharest1695 5 лет назад

    Is the addition of the await foreach supposed to basically replace BlockingCollection completely or is there something I am missing here ? Is there a situation where one would be used instead of the other ?

  • @drewfleming1
    @drewfleming1 5 лет назад

    Awesome features!

  • @frankszendzielarz6350
    @frankszendzielarz6350 5 лет назад

    Very nice summary. One or two questions: this might be a bit of a philosophical can of worms, but what conceptually is the difference between the behaviors IAsyncEnumerable and IObservable? My view is that the "Enumerable" part is synonymous with "Iterable," but the async part simply means 'iterate when notified.' To my mind this is the same as an IObservable with one subscriber. Do IAsyncEnumerables allow multiple subscribers in some syntactically transparent way?

  • @sacation6057
    @sacation6057 5 лет назад

    Awesome features!
    The nullable feature will be a pretty usefull tool to improve maintainability of the codebase, and i feel like c# is closely looking to languages such as python, looking at the improved tuples vrom c#7, and the index slicing of c#8 now. I love it!
    Even though i'm not a big microsoft fan, i love the .NET CORE abd c# projects, and i believe that they both have a very bright future seeing the awesome changes of last years.

  • @Nobo_On_The_Rocks
    @Nobo_On_The_Rocks 5 лет назад +1

    Default interface members looks and feels like abstract implementation , just a bit cleaner.
    Can someone explain why we broke the pattern?

  • @Astrosisphere
    @Astrosisphere 3 года назад

    One I'd like to see is automatic assignment constructors for immutable types. Ideally something that would generate the Equals and GetHashCode overrides for a struct too. Right now the best way I've found of doing this is writing a T4 template for each struct and calling code to generate it based on the properties you want. I might go one step further and create something like an EDMX file to generate T4s to generate the structs but I have a feeling that by the time I've done this, it will already have its own syntactic sugar!

  • @stvaho
    @stvaho 5 лет назад +1

    Absolutely love everything except for the very last feature... Even though I've "wanted" this for years... I just can't justify having "logic" inside an interface... however practical and useful it might be... however much I've wished it possible... opens a backdoor for unwanted untidyness and bad architecture :)
    .
    .
    .
    .
    .
    .
    .
    .
    On a sidenote: it does solve my "ooooh damn can only extend from 1 base class to have default implementations, let's just daisy chain base classes then..." situation xD

  • @raghu1858
    @raghu1858 5 лет назад +2

    Pretty much the only reason I stuck with C# was because of Anders being behind it and now Mads. C# is in good hands ladies and gentlemen.

  • @bashwin87
    @bashwin87 5 лет назад +29

    OMG, Now I am confused. What is the difference between Abstract Classes & Interfaces? Why Microsoft, Why do you have to make it more complicated?

    • @anticosmopolitan
      @anticosmopolitan 5 лет назад +1

      Exactly: this at last makes abstract classes not just partially, but fully redundant, while also finally removing the multiple inheritance prohibition constipation. If that last common-sense change has to come by such a backdoor, Microsoft, so be it; thanks!

    • @madstorgersen7881
      @madstorgersen7881 5 лет назад +18

      1. To let you add new members to a published interface without breaking existing implementers. 2. To allow better interop e.g. with Java and Swift APIs, like we do in Xamarin.

    • @madstorgersen7881
      @madstorgersen7881 5 лет назад +11

      Well abstract classes won't be redundant. Interface members with default implementations aren't inherited into classes.

    • @anticosmopolitan
      @anticosmopolitan 5 лет назад +17

      @@madstorgersen7881 "Interface members with default implementations aren't inherited into classes." This point is back-of-the-head-scratch-worthy and deserves a separate short video, sir! :)

    • @xAckarax
      @xAckarax 5 лет назад

      I agreed. And how does it relate to System.Reflection @@anticosmopolitan

  • @bigyanshrestha6938
    @bigyanshrestha6938 5 лет назад +3

    Is this some sort of joke... if interfaces will now have implementations of their own then what are abstract classes for !!! I kind of get some use cases but I don't think this is a good language design.

    • @EikeSchwass
      @EikeSchwass 5 лет назад

      Interfaces still dont have state for example

  • @pliskanova
    @pliskanova 5 лет назад

    All i really want is logical shortcuts for most used case like commenting things, duplicating lines e.t.c.

  • @zangetsu2k8
    @zangetsu2k8 5 лет назад

    Can you make it possible to print which variable is null when you get that exception? would save a lot of time when debugging.

  • @thegenxgamerguy6562
    @thegenxgamerguy6562 5 лет назад

    C# design faults:
    1. Events are strong references instead of weak ones (I guess this was a "don't really care" moment when designing the language, to be honest)
    2. Classes are not sealed by default
    3. References are nullable by default
    4. Instance variables are mutable by default (which is like an invitation to bad developers to "make MOAR STATE!!1")
    5. Old parts of the BCL don't observe Barbara Liskovs substitution principle
    6. Attributes can't inject code (AOP as part of the C# specification would be amazing, many of us use PostSharp to fix this hole in the language)

    • @FlameRat_YehLon
      @FlameRat_YehLon 5 лет назад

      Not familiar with the last two (but I guess 6 is useful for how the industry codes), but I think the first 4 are just not there because it'll break old codes, and that's why you just have to opt in. It's just like the old Visual Basic 6 days (sure not really for anything professional), where you have to _option explicit_ everything (to avoid typo).

  • @byte2702
    @byte2702 4 года назад

    I still have to smile about „string?“. The meaning of it is very clear here. But in other programming languages like Java they would wonder a lot.

  • @OblivifrekTV
    @OblivifrekTV 5 лет назад +6

    seems that C# 8.0 are getting some swift like feature. interesting

  • @maacpiash
    @maacpiash 5 лет назад +4

    I'm confused with the last feature (default interface members). Why would we need the ability to add a body to a function inside an interface?

    • @JohnLudlow
      @JohnLudlow 5 лет назад +4

      To avoid breaking things by extending the interface. Suppose you have an IPerson with FirstName and LastName, then you realise you need a MiddleName. Suddenly, anyone implementing an IPerson needs to make a change to avoid breaking their code by upgrading to the new version of your library.
      Of course it doesn't actually solve anything.

    • @madstorgersen7881
      @madstorgersen7881 5 лет назад +7

      You can add a new member to the interface without breaking existing implementers.

    • @matthew4497
      @matthew4497 5 лет назад +1

      @@madstorgersen7881 Will we be able to search for all "implied" usages of these? So, using the logging example, will I be able to search for occurrences of "Log(Exception)" where it wasn't implemented, but where I might want to implement it piecemeal?

    • @Grimlock1979
      @Grimlock1979 5 лет назад

      Wasn't a big reason for having it interop with other languages/frameworks?

  • @johnernest8109
    @johnernest8109 5 лет назад

    Switch expressions are an amazingly welcome addition, I can think of a ton of situations in the past where it would have been very helpful. C# as a language is top notch, it's been my go to language for about 90% or so of my projects since 2003, as much as I can. Now if only the rest of the .NET ecosystem can catch up, there are a few gaps to close out there in the .NET Core world revolving around Roslyn Code Analysis, DLL unloading at runtime, and so on, some gaps over especially in the Unity3D world, of course that one's 3rd party, but I would really like to see Microsoft implement something 3D on the scale of Unity for serious app development as a replacement to UWP for heavier cross-platform UIs, since I'm constantly between my Windows desktop and a MacBook. I actually use Unity for mathematics in linear algebra, calculus, and trig, better than Matlab but requires reinventing a lot of wheels and Unity's UI is primitive compared to UWP XAML, plus they don't follow best practices in a lot of areas, last I checked even though they implemented System.Threading.Tasks.Task they didn't implement a way to dispatch on the UI thread. VS for Mac has got a bit of catching up to do in the OSX world, but actually not bad.
    I spent a tad bit of time in Python, and found that even though I didn't like a lot of things about Python or some of the development communities involved with it, they had some good iterators and data types that I thought would be useful in C#. Seeing array slicing on the horizon makes me feel at home a bit more.

  • @TraxxStudios
    @TraxxStudios 5 лет назад

    Awesome work Mads!

  • @2Fast4Mellow
    @2Fast4Mellow Год назад

    Ironically the code can still produce a array out of bounds exception when MiddleName is 'String.Empty'.
    Therefor the code should check for String.IsNullOrWhitespace or even better if length is greater than zero instead of just null...

  • @shyamsundareg4486
    @shyamsundareg4486 5 лет назад

    is there a real benefit of Nullable - I don;t see that. increased few lines of code

  • @JayAyers
    @JayAyers 5 лет назад

    That nonnullable feature answered my prayers.

    • @BarrySlisk
      @BarrySlisk 5 лет назад

      Your life must be near perfect if that's your biggets issue :)

  • @vrn11
    @vrn11 5 лет назад +1

    All is good but I have a bad feeling about method body in interfaces.
    Didn't abstract people complain?

  • @jmacdono
    @jmacdono 5 лет назад +2

    Nice MONITOR bro.
    Good presentation too

  • @ruthuplol
    @ruthuplol 5 лет назад

    For the switch statements, what about numbers?
    switch (int i, int j, int k)
    {
    {0, >0} => Log("all positive");
    default: Log("default");
    }

  • @koszeggy
    @koszeggy 5 лет назад +1

    Ok so now the IEnumerable interface can finally be fixed by adding a CanReset property.
    Not as if Reset was a useful something but starting with C# 2.0 iterators it became completely useless as it was no way to query if it was implemented.

  • @cionsoc
    @cionsoc 5 лет назад

    Async streams is going to be great. Been waiting for this for years.

  • @Netryon
    @Netryon Год назад

    It's second time I've noticed this youtube comments slider, no wonder if nobody is using it it's for your protection and personal warnings. It's there for time travel or something, when we done disable it again. Do it if you avoid it or changing it, they weren't' there if you wished for your superiors guidance we had for Mythic dungeons and routes.
    Will it run, they say - we don't know we had nothing more but pencils. If it's just because of some old disabled code should not do that, but nobody can know exact purpose of before unseen variable in it.