What's new in C# 8 - Part 1

  Рет қаралды 80,933

Microsoft Visual Studio

Microsoft Visual Studio

Күн бұрын

Пікірлер: 84
@AnnamPrasanth
@AnnamPrasanth 5 жыл бұрын
It is truly inspiring that geniuses like him stumble across something as trivial as IsNullOrEmpty function. It just proves that all experts are fundamental humans who might forget small things. Excellent explanation btw. That one line code you have written in the return middle name function is genuinely interesting. Thanks!
@tzadiko
@tzadiko 4 жыл бұрын
I don't understand what you're saying. IsNullOrEmpty is not in any way new in C#8. It has been around a really only time
@reinterpret_cast
@reinterpret_cast 4 жыл бұрын
Nope. What it proves is that experts still feel pressure when presenting stuff for broader audience. He wouldn't stumble across it if he were coding alone.
@1dfe-4e68-bd9f
@1dfe-4e68-bd9f 3 жыл бұрын
it could happen to anyone. it was happen even with Richard Hendricks). this guy explains very clearly. thanks a lot
@mysteriouslyhandmade
@mysteriouslyhandmade 5 жыл бұрын
1. Nullable Reference Types 2. Degenerate Object Deconstruction using curly braces 3. NotNullWhen() Attribute 3. Suppressing compiler complaints for possible null reference exception using ! AKA I Know Better :D 4. Controlling Nullable compiler warning per file using #nullable disable/enable operator 5. Try to target .NET3.0 and .Net Standard 2.0
@ChrisBoot
@ChrisBoot 5 жыл бұрын
A very interesting talk. Thank you. Who'd have thought a 25 minute video on null would be as engaging as it was!
@bogdangaliceanu6326
@bogdangaliceanu6326 5 жыл бұрын
"dammit operator" is actually the ideal, most memorable name :))
@ahmadkelany
@ahmadkelany 5 жыл бұрын
24 minutes talking about nothing 😂 As always, great video.. thank you.
@AsanSultanovNet
@AsanSultanovNet 4 жыл бұрын
24 minutes talking about null.
@andreranulfo-dev8607
@andreranulfo-dev8607 4 жыл бұрын
Literally.
@dhsl
@dhsl 5 жыл бұрын
It and switch expressions make me remember PHP, a lot of options to do the same simple thing, it led us to a complete mess most of the times. In 2021 someone will be launching a brand new stricted c# to avoid these type of redundancy and unecessary things. Null coalescing already solve most of the nullable checks in a very elegant way. Nobody needs to learn that an underscore represents a default command in a switch block. If you want to do experiments you should create a new language as F#
@rotgertesla
@rotgertesla 5 жыл бұрын
Well said. This make me worried for the future of the language. I think they are doing a big mistake here.
@Kollegah9997
@Kollegah9997 5 жыл бұрын
Mads thanks for bringing C# to the next level!
@rotgertesla
@rotgertesla 5 жыл бұрын
11:15 I am sorry to have to say this, but it is a very unreadable synthax: "is { }" . It becomes even worst when you had "{Lenght: var length}". This should never be allowed. Also, Disabling Null check in the middle of a file is very dangerous for future maintenance. This will soon lead to unmaintainable code.
@kestasjk
@kestasjk 5 жыл бұрын
You need to explain how its “unreadable”
@Chiramisudo
@Chiramisudo 4 жыл бұрын
It'll be almost as bad as searching about Discards from a random snippet in some legacy code, lol. Good luck future new devs finding out what the heck that pesky underscore means in your code then legacy code 10 years from now. 😋
@nordy2010
@nordy2010 5 жыл бұрын
Wow! Just... wow! Great job team! This looks really, really awesome! Can't wait to get to use it in a code base at work!
@AdamCollings
@AdamCollings 5 жыл бұрын
Very nice. I can see this forcing me to be less lazy when it comes to null.
@jhbonarius
@jhbonarius 5 жыл бұрын
did he just say "return person?.MiddleName is {Length: var length} ? length : 0" looks nice? I think it reads terrible. Not what I would like to see in maintainable code. But tbh I see so many potential pitfalls in the things that are presented... it's made really easy to write unmaintainable code this way. Just add in some ? and ! and disable some warnings... tadaaa
@FilipCordas
@FilipCordas 5 жыл бұрын
I Agree looks like minimized JavaScript.
@Gabzes
@Gabzes 5 жыл бұрын
What? The goal of void safety is that the compiler forces you to check for null before you use a variable that is nullable.
@rpesc7918
@rpesc7918 5 жыл бұрын
Agreed, previous pattern matching that was released is helpful and reads nice, but this "MiddleName is {Length: var length} ? length : 0" does not read well at all. i'll stick with null coalescing operators and the like
@Chiramisudo
@Chiramisudo 4 жыл бұрын
Aye, and totally goes against the "don't be clever" rule. This syntax reeks of clever code and would be difficult for new developers to search on, lol.
@Chiramisudo
@Chiramisudo 4 жыл бұрын
I would have much preferred the excruciatingly obvious and self-explanatory SQL syntax: `(person?.MiddleName is not null)`. Elegant, simple, intuitive, and maintainable.
@benjaminmeier8300
@benjaminmeier8300 5 жыл бұрын
14:55 thats how I program most of the time ;-)!
@namelastname4077
@namelastname4077 4 жыл бұрын
you're fired
@Sathyaish
@Sathyaish 5 жыл бұрын
Oooohhhh! Nullable reference types! Just like Kotlin.
@Sathyaish
@Sathyaish 5 жыл бұрын
So glad to see a video by Mads after so long. Mads, you're beginning to look a bit like a mix of Doug Crockford and Don Box. :-)
@alfiewhitson7726
@alfiewhitson7726 5 жыл бұрын
the day that C# introduces multiple return statements to functions is the day that hell freezes over. Unfortunately, today is this day and that's why I switched to C++. Also please add in more pre-compiler stuff. I completely don't understand how you can only have #if statements yet you don't allow for #define. That's really weird, if not bordering on stupid. It'd really make my life, and probably the lives of many others, very much easier if you could just simplify the bloody string variable, at least at the compiler level so that strings are by default stored as a char vector because having to declare a char array, to then pass a string array to a separate string to then cast that new string to a char array to then iterate through that array to then find a single character to change, and to then have to re-write all of that back to my initial string uses up far too much memory and is frankly only going to teach developers how to be greedy when it comes to using stack memory rather than create convenience for them. If the whole idea behind high level languages such as C# is to take the place of lower level languages like C++ and C, eventually firmware development using C# will become more feasible than it is now, therefore heap memory optimisation will become more or less paramount to writing applications that can run efficiently on devices such as the Raspberry Pi were there isn't very much stack memory and heap memory optimisation is considered equally as important as the "system architecture" of the C# compiler and how it distributes memory. Not only this but this adamant culture surrounding stack memory usage is going to bugger up Linux process ID's as well if sub-processes are going to be prioritised/used like this. If that completely becomes common practice, you are going to reach your PID_MAX_LIMIT (in English that's the process ID maximum limit variable in Linux) quicker than you can breathe in. In which case, you'd have to start using GPU's for system process management which destroys the entire fucking purpose of even having a "dedicated co-processor" which should be used for stuff like AI development and openGL stuff correlating to games development and what not : in short, in the foreseeable future, if not now, why should I have to rely on the .net framework's compatability with linux in order to be concerned about inefficient memory management techniques which I should not have to worry about in a high level programming language in order to have a 128/256/512 bit interfaced co-processor manage that when this sort of thing should just be managed by my CPU which should barely even be thinking about going anywhere near my L1 cache. Why are you not worrying about this, when this is going to gratify the absolute tits out of Moore's law which I thought that every hardware manufacturer ever was working against becoming a literal reality ?????!!!!!!!!!!!!
@Chiramisudo
@Chiramisudo 4 жыл бұрын
10:33 Excellent! How can we do this prior to 8.0? Something like `(person?.MiddleName is object)` perhaps? Is this logically equivalent?
@avi12
@avi12 5 жыл бұрын
11:17 Now C# looks more like a weird version of Kotlin
@derhottemax
@derhottemax 5 жыл бұрын
Looks great - hopefully eliminates lots of „ if (foo == null) „ verbosity
@cas4425
@cas4425 4 жыл бұрын
AMAZING
@robertmcalery4574
@robertmcalery4574 5 жыл бұрын
Is this a case where "the road to hell is paved with good intentions"?
@deltaskyhawk
@deltaskyhawk 5 жыл бұрын
I hate annotations ... it is like a macro language on top of a language. It is not represented in the syntax of the language.
@avi12
@avi12 5 жыл бұрын
11:57 Seems like C# borrows some features from JavaScript ECMAScript 2015
@gergelymarko
@gergelymarko 5 жыл бұрын
Option
@tonipihlar4537
@tonipihlar4537 5 жыл бұрын
nullable should have already been in C# 1.0!
@WorstDeveloper
@WorstDeveloper 4 жыл бұрын
At 15:50 it says that the value passed to the method is not null if the method returns false. But that means that an empty string will return true and trigger the null check as well, right? Which means that it will fail to check for null values when you pass an empty string as an argument.
@everyonesview
@everyonesview 5 жыл бұрын
Great stuff
@TheSpacecraftX
@TheSpacecraftX 5 жыл бұрын
When you say you weren't allowed to use the "damn it operator" I'm thinking you just weren't allowed to drop f-bombs on the video and used damn as a middle ground.
@Steve-Richter
@Steve-Richter 5 жыл бұрын
I would like typescript to have extension methods and c# to have anonymous objects and the spread operator. Is that asking too much?
@zangetsu2k8
@zangetsu2k8 5 жыл бұрын
is it really impossible to make the object reference not set to an instance of an object error to say which property or field was null?
@Classicv5
@Classicv5 5 жыл бұрын
Seems like the first ‘feature’ adds compiler challenges and the subsequent features fix them inelegantly. Can’t believe you think declaring variables in a degenerate object constructor also used as an inverse null check is desirable..
@gaatutube
@gaatutube 4 жыл бұрын
That weird syntax ... concise but definitely not maintainable. Six months down the line when the boss asks for a new feature, even the original coder would forget what the heck was that supposed to do. KISS is always the best policy.
@UzairAli001
@UzairAli001 5 жыл бұрын
This is some pretty great stuff 👌
@RendernStattGendern
@RendernStattGendern 5 жыл бұрын
amazing :D
@warrenbuckley3267
@warrenbuckley3267 5 жыл бұрын
Did C#8 get released with VS update 16.3?
@vxchin
@vxchin 5 жыл бұрын
Yes, but only worked with .NET standard 2.1, and .NET Core 3.0, not .NET Framework.
@BrutusPalmeira
@BrutusPalmeira 4 жыл бұрын
The question is why? Why add so many things to make the code harder to read and maintain?
@ahmadkelany
@ahmadkelany 5 жыл бұрын
How can I take advantage of this in an existing winforms application?
@ZintomV1
@ZintomV1 4 жыл бұрын
.Net Core 3.1 enables lots of WinForms functionality, with the addition of C# 8 and the nullable annotation. I would suggest migrating your existing project to .Net Core 3.1, you're going to have to do it anyway with .Net 5(next month!) as the .Net Framework has been discontinued.
@holya69
@holya69 5 жыл бұрын
My goodness compiler writers are NASA level smart. I
@FBender
@FBender 5 жыл бұрын
12:28 Starts to getting nice? No it does not.
@MovieMash
@MovieMash 5 жыл бұрын
Usually u think you do ahahaha Good Point!
@alexanderuddfeldt477
@alexanderuddfeldt477 5 жыл бұрын
Can we have a null-check assign operator? I would like that - anyone else? instead of: OldValue = NewValue ?? OldValue; we do: OldValue =? NewValue; // olny assign if nullable type is not null
@astaregod
@astaregod 5 жыл бұрын
I think you're looking for the null-coalescing assignment operator (??=) available in C# 8.0. docs.microsoft.com/en-us/dotnet/csharp/language-reference/operators/null-coalescing-operator
@reinterpret_cast
@reinterpret_cast 4 жыл бұрын
This reminds of `const` in C++: doesn't really guarantee anything and therefore doesn't do what it's supposed to do. C# 7 and 8 are disappointing :(
@mastersaitama3070
@mastersaitama3070 5 жыл бұрын
15:06 🤣🤣🤣
@namelastname4077
@namelastname4077 4 жыл бұрын
return person?.MiddleName?.Length ?? 0;
@ZintomV1
@ZintomV1 4 жыл бұрын
For you that would return '0' xD
@lollo4711
@lollo4711 5 жыл бұрын
@11:11 "is { } x" is nice! A "!?" as (NOT ??) would be nice too
@deltaskyhawk
@deltaskyhawk 5 жыл бұрын
A Seinfeld episode.
@DataJuggler
@DataJuggler 5 жыл бұрын
I guess I am paranoid, but I never write code without testing for null. Expecting developers to switch everything is pretty presumptuous on your part. You salary people don't realize how much trouble this is for open source projects.
@TheSpacecraftX
@TheSpacecraftX 5 жыл бұрын
var var everywhere
@logix8969
@logix8969 5 жыл бұрын
"I'm going to switch into Visual stu..." MY EYES! Dear lord have mercy, who in the right mind uses the light theme?! No but seriously, it's 00:57 at night and this is an LED monitor... so are you trying to kill us? I will find a way to invert the screen colours for now but this is less than ideal!
@niko0679
@niko0679 5 жыл бұрын
Just simple solution watch this video during day light 😊
@DataJuggler
@DataJuggler 5 жыл бұрын
How do I convince the compiler to do the same thing with my NullHelper class as you do with is null test? I prefer my class because I can test for if (NullHelper.Exists(objects1, object2, etc.) instead of (object1 != null) && (object2 != null), etc. Thanks
@LeutnantJoker
@LeutnantJoker 5 жыл бұрын
You should be able to mark the parameters of that method with the mentioned NotNullWhen attribute, telling the compiler that if your method returns true, all parameters are confirmed not null.
@ElliotCoil
@ElliotCoil 5 жыл бұрын
kotlin nullable syntax is better.
@dergeneralist7106
@dergeneralist7106 5 жыл бұрын
Unnecessary
@charles-y2z6c
@charles-y2z6c 4 жыл бұрын
Just learned a lot of nothing. Thank you kindly
@gosnooky
@gosnooky 5 жыл бұрын
I can't use C# because method names with the first letter capitalized messes with my OCD.
@GladerDev
@GladerDev 5 жыл бұрын
Your loss.
@IsuruKusumal
@IsuruKusumal 5 жыл бұрын
C# now only getting nullables.. cute
@CambleDCS
@CambleDCS 5 жыл бұрын
C# has had nullables since 2.0. There is a difference between nullable value types and nullable reference types.
@alexm6762
@alexm6762 5 жыл бұрын
too complicated. it would be more easier to just annotate variable to not allow the null, smth like void F(string! arg)
@iqrasafdar5759
@iqrasafdar5759 5 жыл бұрын
Now u have to explicitly tell u want null. Its well thought design. Take example of sealed keyword in c#. Its explicitly seal class. Sealed classes are better for performance but few people use why ? Bcs its explicit.... So its good to be explicit.
@iqrasafdar5759
@iqrasafdar5759 5 жыл бұрын
Btw i envy implicit sealed classes.
@heteroerectus
@heteroerectus 5 жыл бұрын
that shirt is killer
What's new in C# 8 - Part 2
28:55
Microsoft Visual Studio
Рет қаралды 34 М.
What's new in C# 10
29:28
dotnet
Рет қаралды 87 М.
Из какого города смотришь? 😃
00:34
МЯТНАЯ ФАНТА
Рет қаралды 1,2 МЛН
HELP!!!
00:46
Natan por Aí
Рет қаралды 52 МЛН
What's New in C# 8.0
12:56
Microsoft Visual Studio
Рет қаралды 300 М.
SOLID Design Patterns
57:18
Microsoft Visual Studio
Рет қаралды 252 М.
Dependency Injection Is Now Complete In .NET 8!
9:49
Nick Chapsas
Рет қаралды 95 М.
C# 9 Language Features
22:39
dotnet
Рет қаралды 62 М.
Don't Model the Problem
14:32
David Hart
Рет қаралды 30 М.
Top 10 C# Best Practices (plus bonuses)
57:28
IAmTimCorey
Рет қаралды 511 М.
Dependency Injection | Prime Reacts
28:34
ThePrimeTime
Рет қаралды 349 М.
"The Life & Death of htmx" by Alexander Petros at Big Sky Dev Con 2024
23:01
Montana Programmers
Рет қаралды 68 М.
Is ASP.NET Core Better than Laravel?
16:35
Gavin Lon
Рет қаралды 2,7 М.
Entire Chess World Reeling After What Hikaru Did To Hans
11:56
Epic Chess
Рет қаралды 136 М.