Thank you so much everyone for pointing out usecases for static abstract members in interfaces. No idea how I missed it, since it's quite obvious but I'm so glad you could give me a hand wiht this one!
Async method builder allows to specify how to configure the state machine of the async method behind the scenes. Look at Microsoft's RC post - they show an example where they pool the task instances and improve the performance. About static members in interfaces - a lot of code in functional programming is repeated because there is no way to look at the shape of the type - including static members. Implementing map, reduce and filter is a great example, because the implementation of map on a collection, and on tasks, and async enumerables and option and more are pretty much the same, and the duplicate code can be totally eliminated with abstract members in interfaces. I recommend you look it up. Great video! I'm supper excited to use this in my own projects!!
The lambda with var = null causes an error because var could be a bool as there isnt a type to clarify to the compiler and bools can't be null they are binary. so by clarifyhing string before the lambda your telling that Var represents a string and only a string. Though honestly var should probably not be used as it leads to hard to read code the exception is where the type is clear such as var counter = 1 in this case its easy to tell its an int.
I love it that you if you don't know a mechanism you just say "I don't know it, but just wanted to tell you that something will be changed."! Thank you for presenting C# 10 features in this nutshell :)
Static abstract members are Typeclasses from Haskell. When implementing an interface you need to extend from it in the class declaration (class X : Interface { }), but with this new feature you can extend classes which you don't control (like extension methods, but in a controlled manner). This goes WAY beyond "numerical" code. For example, a while ago I was working on an Android project that used the class "MediaMetadataRetriever". In order to use the "try-with-resources" construct, a class should implement the "AutoClosable" interface. The class didn't implement the interface until API 29. Even if the class conformed to the interface and I could recreate the behavior using it's public API the only option I had was to make a subclass that implements it. With Typeclasses I could easily extend the interface without needing to control the class implementation. I recommend watching this video from Mads Torgersen: ua-cam.com/video/hnu_EgFLO7g/v-deo.html
I'd simply describe it as "inheritance-free contracts for static members." I will use this all over the place when swapping implementations of functions that don't need an instance, such as a configuration driven "option" or a fake for testing.
Thank you so much. If it wasn't for your comment, I wouldn't have realized that this is the very feature I was hoping, waiting and searching for since c# 4.0. Every now and then i would look at the feature list and hope they implement something close to the golang interface mechanism. Finally it is here. :D
After I played around with this feature, I sadly have to report that it is not there yet. There is one key thing missing to resemble Typeclasses from Haskell or interfaces from golang. For now there is no way to link the interface to an existing class ( e.g. extension IntExt : Int32, INumber { } ). So back to square one for me :(. I hope it will not take another 5+ years to get implemented.
@@ZipADeeeDoooDaaa Just curious, why can't you create a class and derive it from Int32? If you need a new method in that class, why not create an extension method?
So happy about the static abstract members. This is something that has been bugging me for years. I have needed this feature many times and no language ever seemed to have it. Without this functionality, if you want a class family to have common fields with hardcoded values, but with different values for each subclass, you have to instantiate the class before you can access the hardcoded fields. Now you can just call it statically from the subclass. I feel like I often want this functionality when associating enums with subclasses. You can also enforce singletons in a class hierarchy with this.
For me, the file scoped namespaces, global usings & lambda improvements are the greatest additions to the language. The only thing that Java language had better than C# was the package system; now with file scoped namespaces, I declare the Java language officially defeated. Everywhere, the C# syntax is now cleaner, shorter & more powerful. (Note that this is relevant to the Java as the language, the ecosystem has Clojure & Groovy languages which are both great.)
@@11clocky can you provide some examples? yes i agree with you enums represent states better than int but in my codes i don't represent states that much (likely never to rare.)
So I subscribed to many UA-camrs... You are the first one who got the Notificaton Bell... Great work! A ton of useful information in a short amount of time.
The abstract members in an interface, I was just wishing the other day I could do that in a game I have been working on. Nice to see that I will soon be able to. 👍
I'm disappointed the "field" keyword for properties didn't make the cut for C# 10. It would have let me get rid of so much cookie cutter code when I work WPF.
@@jfpinero They really don't. WPF has been practically abandoned by MS, only receiving small patches from the **community**. The tooling is gradually becoming more broken as we get more awesome helper packages and complex functionality
I'm happy to see F# features still flowing to C# by the bucket. Can't wait to have them back while working with C#. :) Static abstract might even be better in some cases than the explicit inlining chaos F# has been using. Now do type providers and tail recursion and units of measure. lol
They did some really nice work on this version of C#. I particularly liked the decreased amount of nesting and clutter caused by namespaces and using statements. I feel like this is revolutionary in terms of code-overview in C#! Great video by the way, I subscribed!
Great video! My favourite is Filescode namespaces, it'll just make every day work so much nicer. A quick tip on VS and SMSS (and some other editors/IDEs that want the same keybindings): Ctrl+K, C comments code (line if nothing is marked, marked code otherwise), Ctrl+K, U uncomments code (active cursor location and out).
C# 10 has really great code-reducing features, however, the static abstract members feature ups the game. Yes, it does allow for something like strong units does in F#, however, it also gives you a way to implement a Factory Pattern without having to declare a separate class. This means, one less level of complexity, and factories really make it easier to use immutable types, which means less bugs and easier-to-use libraries.
The last one is so amazing!! I've been waiting for something like this to be added, I'm seriously excited for this! It easily outshines the other changes, even though it is still in preview. The *with* keyword on structs as well as record structs are a close second - I already knew about those, but finding out we are getting what is pretty much Typeclasses has just really made my day, can't wait!
Great video as always and thank you. Just taking some time to blow some smoke up your backside: it's really refreshing to hear on the last point, "I can't think of a use for this let me know if you can..." it's the tendency of a lot of big programming YTers to be incredibly patronising and thinking they have to know everything. I'm only amateur but find a lot of channels talk down to their viewers even on complex subjects. Your approach is much more level-headed and you don't talk down to your viewers which I appreciate and will cause me to continue watching and staying subbed. Cheers.
Nick you the boss!!! You're videos are hands down the best! Please consider creating some Pluralsight or Udemy courses. They would "sell off" as we'd say here in Jamaica.
Nick I’m sure you have seen cases where abstract members in interfaces would be useful, maybe in an async creation pattern? As in, a class that requires some async behavior to be initialized, but you can’t put it in a constructor so you use a static method CreateAsync, that returns a task of the object, now that could be on an interface and mixed with generics to cleanup lots of repetitive code. And generic math is just cool
I would never think to put that on the interface for a couple of reasons. It is really rare that I would need some async initialization and if I ever did I would do that as part of DI.
@@nickchapsas that’s the usual way I go for it, but in this one case I had to go for the CreateAsync pattern for a long ass reason and it would have been nice to put that behind an interface
Interestingly, I suggested file-scoped namespaces (and file-scoped class declarations) 12 years ago on the old C# suggestion tracker. Their response was that this would not be a useful feature.
That static interface thingy is ac hellalot of awesome but only really useful whenever you work with generics. Had the need for it a lot already, love they finally added it (next please stack allocated arrays and eg. Constants as generic parameters please @c#) Main usecase is hard to explain until you come across that kind of nightmarish (in c# at least) usecase, having to use factory classes or reflection and extensive caching to solve Regarding the async method builder attribute, cannot really share anything regarding what or how it exactly works as I did not upgraded the code of that part at work yet, but it is essentially for building custom tasks (which was a nightmare in the past with loads of compiler magic functions and behavior, AFAIK that should change that), researching into it is quite likely to yield great results (eg. Got a custom promise that allows to await events that rely eg. On the user. Allows loads of way nicer code)
I like the idea of global usings in the .proj file. However, I certainly don't like some random .cs file having them. Fibers are a really neat addition! Fibers are essentially "green threads", something like go-routines. They also work co-cooperatively; however, they aren't guaranteed to run in the same thread. Static abstract members are indeed very niche, and most likely they're only really useful to make overloaded operators available to generic functions. *However*, that's actually really, really neat.
Thank you @Nick for all your videos. I have seen multiple videos in the last few days, and I must say: as a non-native English person, I sometimes don't understand what you say. You have an enormous speed, that surely is ok for the most of viewers. But these are "tutorials for every level", should you think about, that the entry levels perhaps have a problem with the speed of both presentation and speech? I remember one video, where you overlaid text - it was just impossible to read the text completely :( Yes, I know about a pause function, but this shouldn't be necessary.) Again, thank you for your work, the content is very useful!!! But I must wait to become a patreon, because I sometimes just give up ... Greetings from a German, living in Norway :)
Hello there 👋. If I am talking too fast then you can slow me down by using the speed playback feature. Unfortunately I don’t think that my videos are for entry level engineers but rather intermediate to advanced. The majority of the audience prefers the fast pace rather the slow one. There are other creators, like Tim Corey, that you might find easier to follow. Ultimately I am making content that I would like to watch myself. Greetings from a Greek living in London.
@@nickchapsas I will give the speed playback feature a try. I know Tim Coreys videos, and there I think it is too much 'overhead', compared with your content. Something in the middle would be perfect, but as long as I haven't found 'something in the middle', I think I will prefer your videos in the most of cases 😁
@@nickchapsas wrote: "Unfortunately I don’t think that my videos are for entry level engineers but rather intermediate to advanced." Your Patreon banner says "... tutorials for every level". 😉
I personally can argue that Function is way better as var. In my opinion every developer tries to be lazy. When im reading code from someone else it mostly consists of var x = "bleh". Which makes me need to think about what kind of class x is. Why not keep it type specific also in code. Everyone should stop using var if it would be up to me. I don't think ability using var in any situation makes it more readable or less cluttered as the author of this video explains. In my opinion these are additions for the "lazy" programmer not to define things. But make them less readable for any third party.
Man this youtube surfing is full of mystery, first I am watching diaper fashion video and next I am watching coding. I'll keep going, wonder where I end from here.
With the static abstract interfaces, would this allow you to perform mathematical operations in generic methods, if the constraints are set with these static abstract interfaces? It'd be really handy for vector and matrix functions, where you currently need overloads for vectors of ints, floats, and doubles, with the exact same functionality in each. Having a Vec3, instead of a Vec3f, Vec3d, and Vec3i, would be hugely beneficial. We still have no INumerical interface or equivalent constraint. This could offer a solution, or at the very least, reduce the clutter for any jury rigged workaround.
Actually, we do have such a constraint as part of .NET 6 (set LangVersion to preview) that uses the static abstract members. INumber is what you probably want, but there is also more specific interfaces like IMultiplyOperators, IComparisonOperators, IFloatingPoint, etc.
File-scoped namespaces. I can finally (and trivially) remove one indentation level in literally 99.999% of my code (and that 0.001% was just due to laziness, I can remove it there too). It's literally free (horizontal) real-estate.
does VS have an option to follow a definition? For example if you were to select JsonSerializer and follow its definition it could direct you to where the 'System.Text.Json' is imported? Would resolve the issue of being unaware of which libraries are used and where from, etc...
Thanks for nice video. I have a general reflection on all the c# versions. Its getting really messy. I work at a place where we have like 50 microservices written in c#. There is no time (and would be waste of time) to constanly update to the latest versions. So as a developer you need to keep track of what version you are in. Sometimes the feature is not available so you have to go back to a earlier version of doing this. I have been working with c# since 2005 so Im ok, In know how to do everything in .net 1.1, but I cant imagine how a new developer would cope with this "mess".
I am a bit confused about why they introduced record structs, it just makes it very confusing. Records were supposed to be immutable version of class. Now we have record structs that are actually mutable. Secondly now that we have record structs, why should one use structs instead of record structs or vice versa?
Actually records could always have mutable elements. Think of them as data classes with some immutability first logic, but that's about it. Both record classes and record structs can have mutable elements, that doesn't change. Using record structs over structs are, again, a matter of usecase and preference. Do you have a struct that just have a few immutable properties and a constructor? Make it a record. Is it more complicated than that? Then maybe use a simple struct.
I haven't. I'm only using it because Rider doesn't support all the C# 10 features yet. The moment it does I will switch back. I am not having fun at all with VS.
Nick what program do you use to broadcast your screen in overlay your head in the corner? I have to record some training videos for work, and I'd love to use a similar setup. In the past I've tried to record video on my screen but when it renders it's largely unreadable
VS is fine but I can't wait for Rider to have full C# 10 support. Everything just slows me down and there are quite a few things I am missing. It is not a bad IDE but my experience can be summarized as "Death by a thousand cuts". I feel like Rider respects me and my time/productivity as a developer more. When both IDEs have their full releases I will make a video talking about it.
@Oddik Aro Use boost advanced tasks but there is particular situations you cant even use async in c# or tasks in c++ ex: sockets. you need to use it in outside process.
I'm rather perplexed by global usings. Yeah, sure, you probably want to put System and System.Collections.Generic in every single file in your solution, but it seems kind of pointless for more niche/specialized namespaces.
We try and contain our company extension methods within the same namespaces per library e.g. Abc.Xpo.ExtensionMethod. Putting these into global usings will be a timesaver for us.
It means you can now use string interpolation in Attributes, because they require a const value. Imagine [MyHandler(Name = $"{nameof(MyClass)}Handler")] . There are other uses, I'm pretty sure I bumped against this limitation a couple of times and had to work around it in uglier way, just can't remember the specifics.
I dont agree with your love of var usage and inference from actions and functions. Having the type defined, eases the readability of the code. This seems like an attempt to obfuscate code. Code you should read as a sentence, easy to grasp. And while it can be subjective, I don't believe it is in this case. Func test = () => "Some text"; and var test = () => "Some text" while takes a tiny bit less spass, also completely removes understanding. if your "result" isn't a declared constant , but a method, then the return is defined inside the method, and you are deliberately hiding the returned object via var, making the code harder to read. Not to mention the horror that is: var text = string? () => null; why would you not write: string? text = () => null; I hate that they permitted this.
Thank you so much everyone for pointing out usecases for static abstract members in interfaces. No idea how I missed it, since it's quite obvious but I'm so glad you could give me a hand wiht this one!
Async method builder allows to specify how to configure the state machine of the async method behind the scenes. Look at Microsoft's RC post - they show an example where they pool the task instances and improve the performance.
About static members in interfaces - a lot of code in functional programming is repeated because there is no way to look at the shape of the type - including static members.
Implementing map, reduce and filter is a great example, because the implementation of map on a collection, and on tasks, and async enumerables and option and more are pretty much the same, and the duplicate code can be totally eliminated with abstract members in interfaces.
I recommend you look it up.
Great video! I'm supper excited to use this in my own projects!!
The lambda with var = null causes an error because var could be a bool as there isnt a type to clarify to the compiler and bools can't be null they are binary. so by clarifyhing string before the lambda your telling that Var represents a string and only a string. Though honestly var should probably not be used as it leads to hard to read code the exception is where the type is clear such as var counter = 1 in this case its easy to tell its an int.
I love it that you if you don't know a mechanism you just say "I don't know it, but just wanted to tell you that something will be changed."! Thank you for presenting C# 10 features in this nutshell :)
I've been coding in Typescript only for the last 6 months, came here to check on my favortie language and your video made me keen to get back to C#
Unless I've missed it in your videos, a video on Func and Action with practical use cases would also be great!
I have a video exactly like that scheduled within the next 2 weeks
@@nickchapsas Awesome, thank you!
@@nickchapsas What is the name of the video? Couldn't find it when searching through you videos
Static abstract members are Typeclasses from Haskell. When implementing an interface you need to extend from it in the class declaration (class X : Interface { }), but with this new feature you can extend classes which you don't control (like extension methods, but in a controlled manner). This goes WAY beyond "numerical" code.
For example, a while ago I was working on an Android project that used the class "MediaMetadataRetriever". In order to use the "try-with-resources" construct, a class should implement the "AutoClosable" interface. The class didn't implement the interface until API 29. Even if the class conformed to the interface and I could recreate the behavior using it's public API the only option I had was to make a subclass that implements it. With Typeclasses I could easily extend the interface without needing to control the class implementation.
I recommend watching this video from Mads Torgersen: ua-cam.com/video/hnu_EgFLO7g/v-deo.html
Thanks. This was a great resource for learning about this feature!
I'd simply describe it as "inheritance-free contracts for static members." I will use this all over the place when swapping implementations of functions that don't need an instance, such as a configuration driven "option" or a fake for testing.
Thank you so much. If it wasn't for your comment, I wouldn't have realized that this is the very feature I was hoping, waiting and searching for since c# 4.0. Every now and then i would look at the feature list and hope they implement something close to the golang interface mechanism. Finally it is here. :D
After I played around with this feature, I sadly have to report that it is not there yet. There is one key thing missing to resemble Typeclasses from Haskell or interfaces from golang. For now there is no way to link the interface to an existing class ( e.g. extension IntExt : Int32, INumber { } ).
So back to square one for me :(. I hope it will not take another 5+ years to get implemented.
@@ZipADeeeDoooDaaa Just curious, why can't you create a class and derive it from Int32? If you need a new method in that class, why not create an extension method?
So happy about the static abstract members. This is something that has been bugging me for years. I have needed this feature many times and no language ever seemed to have it.
Without this functionality, if you want a class family to have common fields with hardcoded values, but with different values for each subclass, you have to instantiate the class before you can access the hardcoded fields. Now you can just call it statically from the subclass. I feel like I often want this functionality when associating enums with subclasses. You can also enforce singletons in a class hierarchy with this.
'AssAndDeclaration' from feature 9.
You are a master of naming! )
For me, the file scoped namespaces, global usings & lambda improvements are the greatest additions to the language. The only thing that Java language had better than C# was the package system; now with file scoped namespaces, I declare the Java language officially defeated. Everywhere, the C# syntax is now cleaner, shorter & more powerful. (Note that this is relevant to the Java as the language, the ecosystem has Clojure & Groovy languages which are both great.)
and Java still doesn't have async / await in 2021
Java has better enums, though.
@@11clocky who uses enums?
@@pemifo260 I use them all the time. They are much better at representing a state than an int.
@@11clocky can you provide some examples? yes i agree with you enums represent states better than int but in my codes i don't represent states that much (likely never to rare.)
So I subscribed to many UA-camrs... You are the first one who got the Notificaton Bell... Great work! A ton of useful information in a short amount of time.
The abstract members in an interface, I was just wishing the other day I could do that in a game I have been working on. Nice to see that I will soon be able to. 👍
Been waiting on generic attributes for sometime; good to see it implemented, now hoping for static indexers
I'm disappointed the "field" keyword for properties didn't make the cut for C# 10. It would have let me get rid of so much cookie cutter code when I work WPF.
Same goes for the required keyword :(
Microsoft doesn't care about WPF. Sad, but true.
@@jankalfus42 Blazor WPF, Maui in .NET 6, do they really not care about WPF???
@@jankalfus42 And what instead?
@@jfpinero They really don't. WPF has been practically abandoned by MS, only receiving small patches from the **community**. The tooling is gradually becoming more broken as we get more awesome helper packages and complex functionality
I'm happy to see F# features still flowing to C# by the bucket. Can't wait to have them back while working with C#. :)
Static abstract might even be better in some cases than the explicit inlining chaos F# has been using.
Now do type providers and tail recursion and units of measure. lol
They did some really nice work on this version of C#. I particularly liked the decreased amount of nesting and clutter caused by namespaces and using statements. I feel like this is revolutionary in terms of code-overview in C#!
Great video by the way, I subscribed!
Great video! My favourite is Filescode namespaces, it'll just make every day work so much nicer.
A quick tip on VS and SMSS (and some other editors/IDEs that want the same keybindings): Ctrl+K, C comments code (line if nothing is marked, marked code otherwise), Ctrl+K, U uncomments code (active cursor location and out).
File scoped classes would also be great, possibly that get class name from file name.
C# 10 has really great code-reducing features, however, the static abstract members feature ups the game. Yes, it does allow for something like strong units does in F#, however, it also gives you a way to implement a Factory Pattern without having to declare a separate class. This means, one less level of complexity, and factories really make it easier to use immutable types, which means less bugs and easier-to-use libraries.
The last one is so amazing!! I've been waiting for something like this to be added, I'm seriously excited for this! It easily outshines the other changes, even though it is still in preview. The *with* keyword on structs as well as record structs are a close second - I already knew about those, but finding out we are getting what is pretty much Typeclasses has just really made my day, can't wait!
You missed the perfectly valid opportunity to make "C# 10 features in 10 second" video ;D
Incredible video. I was looking for something exactly like this
Great video as always and thank you. Just taking some time to blow some smoke up your backside: it's really refreshing to hear on the last point, "I can't think of a use for this let me know if you can..." it's the tendency of a lot of big programming YTers to be incredibly patronising and thinking they have to know everything. I'm only amateur but find a lot of channels talk down to their viewers even on complex subjects. Your approach is much more level-headed and you don't talk down to your viewers which I appreciate and will cause me to continue watching and staying subbed. Cheers.
Thanks a lot, Nick! A very nice overview.
Nick you the boss!!! You're videos are hands down the best! Please consider creating some Pluralsight or Udemy courses. They would "sell off" as we'd say here in Jamaica.
Nick I’m sure you have seen cases where abstract members in interfaces would be useful, maybe in an async creation pattern? As in, a class that requires some async behavior to be initialized, but you can’t put it in a constructor so you use a static method CreateAsync, that returns a task of the object, now that could be on an interface and mixed with generics to cleanup lots of repetitive code.
And generic math is just cool
I would never think to put that on the interface for a couple of reasons. It is really rare that I would need some async initialization and if I ever did I would do that as part of DI.
@@nickchapsas that’s the usual way I go for it, but in this one case I had to go for the CreateAsync pattern for a long ass reason and it would have been nice to put that behind an interface
It's the factory pattern, where this feature is super useful! CreateAsync is just another form of the factory pattern.
Interestingly, I suggested file-scoped namespaces (and file-scoped class declarations) 12 years ago on the old C# suggestion tracker. Their response was that this would not be a useful feature.
I know a few game engine devs who were wishing for the last feature :3 (static abstract interface implementations)
OMG, C# 9/10 is sooo similar to modern javascript :-) Loving it!!!
BTW, great material Nick
That static interface thingy is ac hellalot of awesome but only really useful whenever you work with generics. Had the need for it a lot already, love they finally added it (next please stack allocated arrays and eg. Constants as generic parameters please @c#)
Main usecase is hard to explain until you come across that kind of nightmarish (in c# at least) usecase, having to use factory classes or reflection and extensive caching to solve
Regarding the async method builder attribute, cannot really share anything regarding what or how it exactly works as I did not upgraded the code of that part at work yet, but it is essentially for building custom tasks (which was a nightmare in the past with loads of compiler magic functions and behavior, AFAIK that should change that), researching into it is quite likely to yield great results (eg. Got a custom promise that allows to await events that rely eg. On the user. Allows loads of way nicer code)
I like the idea of global usings in the .proj file. However, I certainly don't like some random .cs file having them.
Fibers are a really neat addition! Fibers are essentially "green threads", something like go-routines. They also work co-cooperatively; however, they aren't guaranteed to run in the same thread.
Static abstract members are indeed very niche, and most likely they're only really useful to make overloaded operators available to generic functions. *However*, that's actually really, really neat.
Great language improvements!
And great videos as always, Nick
Thank you @Nick for all your videos. I have seen multiple videos in the last few days, and I must say: as a non-native English person, I sometimes don't understand what you say. You have an enormous speed, that surely is ok for the most of viewers. But these are "tutorials for every level", should you think about, that the entry levels perhaps have a problem with the speed of both presentation and speech? I remember one video, where you overlaid text - it was just impossible to read the text completely :( Yes, I know about a pause function, but this shouldn't be necessary.)
Again, thank you for your work, the content is very useful!!! But I must wait to become a patreon, because I sometimes just give up ... Greetings from a German, living in Norway :)
Hello there 👋. If I am talking too fast then you can slow me down by using the speed playback feature. Unfortunately I don’t think that my videos are for entry level engineers but rather intermediate to advanced. The majority of the audience prefers the fast pace rather the slow one. There are other creators, like Tim Corey, that you might find easier to follow. Ultimately I am making content that I would like to watch myself. Greetings from a Greek living in London.
@@nickchapsas I will give the speed playback feature a try. I know Tim Coreys videos, and there I think it is too much 'overhead', compared with your content. Something in the middle would be perfect, but as long as I haven't found 'something in the middle', I think I will prefer your videos in the most of cases 😁
@@nickchapsas wrote: "Unfortunately I don’t think that my videos are for entry level engineers but rather intermediate to advanced."
Your Patreon banner says "... tutorials for every level". 😉
Arguably, var text = () => default(string) is more readable.
I personally can argue that Function is way better as var. In my opinion every developer tries to be lazy. When im reading code from someone else it mostly consists of var x = "bleh". Which makes me need to think about what kind of class x is. Why not keep it type specific also in code. Everyone should stop using var if it would be up to me.
I don't think ability using var in any situation makes it more readable or less cluttered as the author of this video explains. In my opinion these are additions for the "lazy" programmer not to define things. But make them less readable for any third party.
Man! I Wish I knew your channel earlier amazing presentation and production quality
you deserve many more subs bro!
keep it up!
Nick, would you make video about structs? Should we use them or not?
A video about structs, records and classes would be nice. The differences and when to use one over the other.
A good rule to go by: if you're not sure if you should use a class or a struct, use a class.
Man this youtube surfing is full of mystery, first I am watching diaper fashion video and next I am watching coding. I'll keep going, wonder where I end from here.
15:20
that is literally something I have tried to do but found out I couldn't, that's kinda funny
“Intendation”? ;)
Great and informative vid, Nick… I watch every one of your videos … keep up the great work! :)
Really great video Nick! Thanks for sharing
11:13 nice
1:31 - hey, how did you open up the XML via Solutions Explorer?
With the static abstract interfaces, would this allow you to perform mathematical operations in generic methods, if the constraints are set with these static abstract interfaces? It'd be really handy for vector and matrix functions, where you currently need overloads for vectors of ints, floats, and doubles, with the exact same functionality in each. Having a Vec3, instead of a Vec3f, Vec3d, and Vec3i, would be hugely beneficial. We still have no INumerical interface or equivalent constraint. This could offer a solution, or at the very least, reduce the clutter for any jury rigged workaround.
Actually, we do have such a constraint as part of .NET 6 (set LangVersion to preview) that uses the static abstract members. INumber is what you probably want, but there is also more specific interfaces like IMultiplyOperators, IComparisonOperators, IFloatingPoint, etc.
File-scoped namespaces. I can finally (and trivially) remove one indentation level in literally 99.999% of my code (and that 0.001% was just due to laziness, I can remove it there too). It's literally free (horizontal) real-estate.
great sharing, save my time, thanks very much!~
5:32 - lamda improvements. Does it make Func, Actions and I guess something else obsolete?
Great video, keep going.
You are amazing, thank you for your time and great explanation!!!
Great content as always! Thanks Nick.
I don't know if its a C# 10 Feature or a .Net 6. But the new field keyword can be very nice to use. It makes a lot of code become a lot less.
The field keyword was pushed to C# 11
does VS have an option to follow a definition? For example if you were to select JsonSerializer and follow its definition it could direct you to where the 'System.Text.Json' is imported?
Would resolve the issue of being unaware of which libraries are used and where from, etc...
Really, really, nobody commented about 420 or 69 at 11:25.
I believe even Nick kinda got upset about that.
Oh I noticed straight away, in my work projects my unit tests are filled with these values
Nice overview Nick, Thanks :)
Question: Do you try api versioning into a minimal api? is it possible?
Excellent video, thank you.
Nick, can you make a video about Multithreading, locking deadlocks?
You want to see why static abstract is useful, check how Rust implements operations on primitive types.
I’ve faced issue when the was need in partial class within the same file because of different usings (they were conflicting).
What's the shortest and quickest way to refactor the 'classic' Namespace to a File Scoped Namespace, desirably using keyboard shortcuts?
Rider has that in the quick actions menu Alt+Enter
As usual, Great explanation 👍
Thanks for nice video. I have a general reflection on all the c# versions. Its getting really messy. I work at a place where we have like 50 microservices written in c#. There is no time (and would be waste of time) to constanly update to the latest versions. So as a developer you need to keep track of what version you are in. Sometimes the feature is not available so you have to go back to a earlier version of doing this. I have been working with c# since 2005 so Im ok, In know how to do everything in .net 1.1, but I cant imagine how a new developer would cope with this "mess".
I am a bit confused about why they introduced record structs, it just makes it very confusing.
Records were supposed to be immutable version of class. Now we have record structs that are actually mutable. Secondly now that we have record structs, why should one use structs instead of record structs or vice versa?
Actually records could always have mutable elements. Think of them as data classes with some immutability first logic, but that's about it. Both record classes and record structs can have mutable elements, that doesn't change. Using record structs over structs are, again, a matter of usecase and preference. Do you have a struct that just have a few immutable properties and a constructor? Make it a record. Is it more complicated than that? Then maybe use a simple struct.
Structs aren't immutable by default anyway.
Hey, Nick! What Visual Studio Theme do you use in this video? Thanks in advance 😀
It’s a different IDE called JetBrains Rider
Can you provide a better example of the pattern matching? I don't understand why you wouldn't just put if(rectangle.Height > 100) {}.
Please, how do I call methods in csharp 10
Isn't it something very similar to module concept on VB?? Just asking
I wish C# could add much more support for const expressions.
So can we now have IoC with csproj?
I still need to learn the features from C# 9.... Things are moving too fast for me 🤕
I'm just here to comment on the "AssAndDeclarationInSameDeconstruction"
Holy shit they added TypeClasses to C#
Good job
What made you switch to Visual Studio from Rider?
I haven't. I'm only using it because Rider doesn't support all the C# 10 features yet. The moment it does I will switch back. I am not having fun at all with VS.
@@nickchapsas fingers crossed, maybe it will be better when VS 2022 comes out in a few weeks?
Nick what program do you use to broadcast your screen in overlay your head in the corner? I have to record some training videos for work, and I'd love to use a similar setup. In the past I've tried to record video on my screen but when it renders it's largely unreadable
I am using OBS Studio and I have a green screen and good lighting to chroma key the background out
Thank you very much!
Dat JavaScript influence
thanks
Why you turned off subtitles in this video guide?
Do global usings reduce performance?
Usings are only used at compile time. May, possibly, slow down things while compiling but not runtime.
Are you enjoying vs2022 or are you going to go back to rider?
VS is fine but I can't wait for Rider to have full C# 10 support. Everything just slows me down and there are quite a few things I am missing. It is not a bad IDE but my experience can be summarized as "Death by a thousand cuts". I feel like Rider respects me and my time/productivity as a developer more. When both IDEs have their full releases I will make a video talking about it.
@@nickchapsas Looking forward to that video :)
it's something weird to see something old in c++ is a new feature LOL
@Oddik Aro Use boost advanced tasks but there is particular situations you cant even use async in c# or tasks in c++ ex: sockets. you need to use it in outside process.
Great
Could you make videos on yaml pipelines?
11:18 I see you’re a man of culture 😏
nice
Hey Nick, can explan newtonsoft framework? please! thanks :)
I think this is more elegant .
var someFunc=()=> default(string?);
That function thing looks like es6 javascript
Love it :-)
Does anybody know what IDE this is? It doesn't look like rider👀
I'm rather perplexed by global usings.
Yeah, sure, you probably want to put System and System.Collections.Generic in every single file in your solution, but it seems kind of pointless for more niche/specialized namespaces.
We try and contain our company extension methods within the same namespaces per library e.g. Abc.Xpo.ExtensionMethod. Putting these into global usings will be a timesaver for us.
@@chrisroyle4813 that makes a lot of sense. I'm even tempted to steal this 😁
Static abstract classes look like Monoids to me.
420, 69, all over the place :D
.NET 6, C# 9
@@bennymountain1 Mind, blown
Oh wow generic way of doing arithmetic, now I'll be able to make generics with a type restriction for things that have a + and - operators.
String interpolation for const doesn't really make sense to me
It means you can now use string interpolation in Attributes, because they require a const value. Imagine [MyHandler(Name = $"{nameof(MyClass)}Handler")] . There are other uses, I'm pretty sure I bumped against this limitation a couple of times and had to work around it in uglier way, just can't remember the specifics.
Yeah, now let's wait like 3 years untill it comes to Unity lol
Global using is gross, i cant believe that got approved.
Ref struct, record struct, record class, ValueTask, blah, blah. They are getting a little out of control IMO
My like was the 69th, not that that is a special number or anything.
Nice
Nice
Who the hell disliked this video? :D
I dont agree with your love of var usage and inference from actions and functions.
Having the type defined, eases the readability of the code.
This seems like an attempt to obfuscate code.
Code you should read as a sentence, easy to grasp.
And while it can be subjective, I don't believe it is in this case.
Func test = () => "Some text";
and
var test = () => "Some text"
while takes a tiny bit less spass, also completely removes understanding.
if your "result" isn't a declared constant , but a method, then the return is defined inside the method, and you are deliberately hiding the returned object via var, making the code harder to read.
Not to mention the horror that is:
var text = string? () => null;
why would you not write:
string? text = () => null;
I hate that they permitted this.
C# become complete garbage :(
C# 6.0 were perfect btw
You know that global usings is going to be abused. How much time will it add to the build process when there are a lot of global usings? ;)
To the build process? Nothing noticable.