ChatGPT can write better code than me

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everybody I'm Nick and in this video I'm going to introduce you to the brand new AI chatbots released by open AI called chat GPT it is an AI chatbot trained to effectively have dialogue so it can keep context and keep answering your questions knowing the previous context and it has a cutoff point on its knowledge in the end of 2021 so if something after the end of 2021 has been released its knowledge is very limited now the interesting thing is that one of the suggestions on the examples over here is how do I make an HTTP request in JavaScript so in this video I'm going to put it to the test and see what it can do for me as a c-sharp developer I'm gonna get it to write some code try to optimize some code and see how far it can go and how much it understands maybe get it to write some unit tests now this is another blind reaction I actually had a two and a half hour playing around yesterday on my live stream and you can go and watch that as well if you want but from what I've seen I'm very impressed and I can confidently say that this will give Google and stack Overflow a run for much money and from what I've seen until now I believe it's even better than GitHub co-pilot but let's see if you like to have content and you want to see more make sure you subscribe bring this notification Bell and for more training check out nickjobsters.com and I'm going to start simple and say write a c-sharp method that accepts a good as a string and returns a base 64 version of the good so let's go ahead and ask it and the moment I say it it starts writing the method so do base64 good string good here and then it Returns the thing and this is clearly valid C sharp you can take this and it works now there's one thing I actually do not like and that is that it is using guide.pause and guid.pause can throw if the input is invalid so I can say please also handle invalid input so if the good is not a valid input and it understands that yes if you don't have a valid good then I should use try pause and it knows that if the string is not a valid Guild return an empty string and then I can give it more context on how I wanted to handle this thing so maybe throw or return something else it's up to me now there's one thing I don't like it uses these two byte array here and we're wasting memory allocations so I can ask it can you optimize this code to not have keep allocations just go straight away and not only go straight away it says oh yeah I'm gonna use span of byte and I'm gonna stack allocate 16 bytes over here to write the byte of the good and then convert it to base64. it's so good this is actually things you would do if you wanted to optimize it it's very very impressive now let's take it a step further I'm gonna say that please give me a method that went this morning you return good morning when this afternoon you return good afternoon and when it's evening you return good evening so write a c-sharp method that returns good morning when it's morning good afternoon it's afternoon good evening when it's evening immediately it starts writing and it goes get greeting it gets the current hour getting daytime now and it says if the hour is from 0 to 12 then good morning if it's 12 to 16 good afternoon else good evening very very accurate it says this method is using the daytime now property to get the current date and time and then extracts the hour so it explains the code but what I want to tell it now is I wanted to write unit tests for this method so please write unit test for this method immediately it goes ahead and it writes tests so test morning test afternoon test evening create a new day time and here's where the insane thing comes in it actually parameterized get greeting because if you remember good greeting didn't have a parameter now daytime is a parameter in the greeting itself because we need to inject the daytime as a dependency because otherwise this would not be uni testable so I can say can I see the new code or get greeting and it's gonna go ahead and show you the new chains now that it accepts daytime it is so good and let's see how far it kind of goes so obviously now it's using any unit I don't use any unit so I wanted to use x unit as my test Library I also wanted to use what I consider to be my standard way of writing a test name which is test method underscore should do something underscore when something happened and then I'm using fluent assessions for my accessions so let's go ahead and write that can you use x unit for the test instead also use fluent that's so good accessions for accessions and since I prefer using the naming pattern method name underscore when should do something underscore when something happened then use that pattern instead okay I added an extra F in the end but it understood it was a typo and it went ahead and it goes ahead and it does it so it now changed the use x unit affluent accessions it uses the fact correctly arrange actor said correct parameter over here and it says get greeting and the name is get greeting the method name should return good morning when it is good morning it's so good I can't actually believe this how it goes in depth and explains and it says oh I use the naming pattern because basically you told me and yeah I'm using fluent assessions correctly it's so so impressive and it doesn't even end there so I could say for example now use the theory feature of X unit instead so match all three tests into one that uses ethereum has inline data to represent the daytime and the items it knows it just knows and it changes the text as well so should return correct reading when given time of day I can't believe this okay let's see how far we can go with this then so I'm gonna reset thread and I'm gonna say create and asp.net core 6 API that Returns the weather or a given City using the open weather map API for its data let's see what it can do it goes okay straight away the download.net there dotnet6 specifically that's the right location by the way then it gives you details on every step of the way you inject the open weather map API client so it did that very efficiently to not have the logic in here okay I want to see the the code that it would write for that thing so show me the code for I open weather map API client and the implementation which is open weather map API class let's see what it does this is super impressive so it explains that this is the interface explaining how I can call this API so the contract and then the implementation is here and it is injecting the client which is the best practice in asp.net core most people do this wrong and this thing could do it correctly this is insane okay and then gets the okay show me the full get weather data for CTA sync implementation because it's omitting it from what I assume so it's going to go ahead and actually write this let's see what it does so so it's going to use the ace to feed client I'm so impressed it knows it needs a key and it's injecting the key from The Constructor write comments to explain what it's doing so the API URL is here this is all correct code valid C sharp that you would write it this realizes using is it new terms of the Json the serialized object yeah it is I wouldn't want to use noodles after Json but it's not wrong it's just you can use system.text.json this is nuts okay so we have that can I push it even further let's say add resilience by adding only in the project use it to implement retries and circuit breaker let's see what it does now sometimes it takes longer because it's so heavily used by so many people around the world so it can take for a second to start typing sometimes and I am also getting rate limited so just know that it's not the thing being slow it is just that so many people use it that it is being slow here you go and it goes ahead and adds to add the poly Library into the project it just gives you all the instructions it tells you use the policy dot handling this is and it knows to Cache it so it's not created every single time I am oh my God I'm sure I can tell it to add exponential back off and a Jitter and it will all work I am so impressed with this thing wow and we'll just keep going what I want to tell you to do after this and of course I can say continue it will continue writing the thing it's so so so interesting let's see if I can get it to write some performance tests now and the library I prefer for performance tests is k6 so I'm gonna ask you to write them with this so write performance tests or this API using k6 let's see what it does yeah of course it knows how to use k6 and how to create the test Javascript file I the ah this is so useful this can be a game changer it's also a bit weird like not gonna lie but this is a perfectly valid load test it tells you how to run it as well and how to have a threshold if any of those dividers exceed 200 milliseconds of performance test will fail because it's checking on percentiles I oh my God does it know how to do staging to do something like Spike test okay write a spike test for this API start with 100 users run up to 10 1000 users and ramp down to 100 users use the stages feature in the options constant let's see if it can do it oh my God if it actually does this because it's one thing for me to tell it to do something and another thing for it to accurately yes wow continue continue you want to see the full implementation continue I am yeah it can do it of course it can do it to run the test and it even tells you how to run it okay the code block is a bit broken so it sort of reversed it because of the continuing but it is in preview so don't expect wonders but this is nuts can it convert it to any bomber so convert those load tests to our performance this is what I call them performance test to n bomber with C sharp and bomber is a.net library that can do performance testing so let's see if it can do that with the exact same criteria yeah of course it can convert it why did I have any doubt well I don't want to push it any further you get the point this thing will do effectively anything you ask it to now will it always use best practices from what they've seen no but it's significantly better in my experience than co-pilot was when it came out and even still in some cases so I would keep a very close eye on this and I will be using it more and more but what do you think do you think that now more than ever are job security is in danger leave a comment down below and let me know well that's all I had for you for this video thank you very much for watching Press and fix my patreons for making videos possible if you want to support most probably gonna find the link in description down below leave a like if you like this video subscribe more because I like this ring the bell as well and I'll see you in the next video keep coding
Info
Channel: Nick Chapsas
Views: 264,877
Rating: undefined out of 5
Keywords: Elfocrash, elfo, coding, .netcore, dot net, core, C#, how to code, tutorial, development, software engineering, microsoft, microsoft mvp, .net core, nick chapsas, chapsas, dotnet, .net, chatgpt, openai, copilot, chatgpt developer, chatgpt code, coding ai, coding chat gpt, chatpgt coding, c# chargpt, open ai chatgpt, openai chatgpt, ChatGPT is a better C# developer than me
Id: z2CKQFi746Q
Channel Id: undefined
Length: 11min 6sec (666 seconds)
Published: Thu Dec 08 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.