Open AI recently released ChatGPT, a chat based artificial intelligence that knows how to code. In this video, I put it to the test to see if it is able to complete my software engineering work for me.
Prepping for your frontend interviews? Use code ”conner” for a discount on my course FrontendExpert:
LinkedIn:
TikTok:
ChatGPT:
It seems like everyone is talking about This new chat GPT tool by openai it Seemingly can do just about anything via Just a basic chat application it’s able To write songs and essays and it’s even Able to write code so today I want to Put that to the test is chat GPT good Enough to replace me at my software Engineering job so I’m going to actually Give it my tasks for the day and to see If it’s able to replicate what I would Have done and even replace my work okay So this is the interface of chat GPT and We can see the first thing to do is Change it to dark mode and then we can Ask a question so for example write a Song about software engineering Coding interviews and now we can see if It’s able to generate a song about what I just asked it for and because it’s Already doing just that we have first One we have a Chorus Verse two the Chorus again a bridge and then the Chorus once again and it was able to do This super super quickly and we can read A little bit of this let’s read the Chorus coding interviews oh how they Test me with algorithms and data Structures to see if I have the skills To join the team coding interviews the Bane of my existence it would seem so This is actually really well written so It understood what coding interviews are About that these are interviews using
Algorithms and data structures it knows That they are the bane of software Engineers existence but with them we can Figure out how to join the team so this Is really well done and we can see that It really understood what I asked it it Was able to generate something that Seems like a human could have written it But it did it extremely quickly okay so Now what I want to do is I want to test Its knowledge of actual software Engineering a little bit so let’s see What it thinks about just some software Engineering questions let’s say what is Poly morphism And we can see if it’s able to give us a Good definition of polymorphism of Course this is something that it could Just get from some database of Information it probably has that it Scraped from the internet so I would Imagine it can do pretty well with this So polymorphism is a concept in computer Programming that allows one interface to Be used for a variety of different Implementations this allows for greater Flexibility and reusability of code in Other words polymorphism allows Different classes to implement the same Methods in different ways but they can Be used interchangeably through a common Interface this is a key feature of Object-oriented programming languages so This is a very good explanation of
Polymorphism and honestly it’s probably A better explanation than one I would Have given myself so let’s see if we can Make it get a little bit controversial When should I use react versus angular Okay let’s see what it thinks on the Age-old debate react or angular the Decision to use react or angular for a Project ultimately depends on the Specific requirements and constraints of The project as well as the preferences And experience of the development team Both react and angular are popular JavaScript libraries for building user Interfaces and they have many similar Features so this is where I would say is The first thing I’ve seen that’s sort of Objectively wrong and that angular is Not a library it’s a framework but okay We can continue one key difference Between Oh it got me one key difference between The two is that react is a library while Angular is a framework so sort of Contradicts what it said right before But okay so that is correct this means React provides a set of tools and Components for building user interfaces But it does not provide a complete Application architecture angular on the Other hand is a full-blown framework That provides a complete application Architecture including tools for routing Dependency injection and more okay so
Now what I want to see is can it Actually write real working code so Let’s simply say write a tick Attack toe game using HTML CSS and JavaScript so let’s see if it can Generate a game using Code completely From scratch so it seems like it’s Giving us steps to do it I don’t Necessarily want these steps I just want The code but okay let’s see if it adds The code below this or if it’s just Going to tell us how to do it okay so Here we have the actual code so we have HTML or the board game and it’s doing This sort of slowly I’m not sure why This is taking longer than it did before I guess it needs to figure out the code And we have a table it seems for the Actual board so then we have a style tag With our CSS so it has the table and the Table data and then we have our script Down here to handle the game logic I don’t know why it didn’t give us these In separate code segments why it’s Giving us all in one file but it’s not Really a HTML file it doesn’t have like The HTML head and body tags and all that Just sort of gave us this then it looks Like it didn’t finish so we just have a Comment here at the bombs yeah this Isn’t finished But it seems to have gotten to the end She’ll say can you finish the code I’m Not sure why it didn’t give us completed
Code so it’s a little bit strange So now it says the handle click function Can be completed Okay So it’s sort of giving us different Functions in different Snippets but I Just want like all of the code together This is a little bit strange to the way It’s doing this I guess this would work It would be a way to figure everything Out but it’s a little bit strange I also Don’t know how I feel about this like Way it’s checking winning combinations Using these strings instead of just Using like indices so this is a sort of Strange way to go about solving this it Seems like it’s Way way over complicating this Particular problem this really isn’t a Particularly complicated problem to Solve and so once again it stopped early So let me just say can you give me the Entire Code for a tic tac toe game using HTML CSS and JavaScript so let’s see if we Can get a whole thing at once rather Than these little Snippets I just want One big thing that I can copy and paste And play Tic-Tac-Toe okay so once again It did not actually finish I’m not sure What the deal is with this where it just Sort of stops in mid thoughts like it Literally opened up a string and never Finished the string it also looks like
It might be using backticks for these Strings which there’s no reason for that These aren’t template literals there’s No variables being used inside of the Strings especially when it used normal Double quotes up here so it looks like We aren’t going to be able to play Tic-Tac-Toe with just what it generated Okay so I reset chat GPT and what I want To check now is how it’s debugging Capabilities are so we’ve been told that It should be able to debug code so for Example let’s write some code and ask it To debug it so let’s say can you debug This code and below it we will have a Function I’ll call this test and this is Going to take in a number and it’s going To return test of number minus 1. so the Issue here is that this would infinitely Loop because of this recursion with no Base case so let’s see if chat GPT is Able to figure that out and it says it Looks like the function is attempting to Call itself recursively without any base Case so that’s exactly what I just said So good job on chat GPT it looks like It’s even fixing the function call for Me so this is pretty great this means That the function will continue calling Itself indefinitely resulting in a Maximum call stack size exceeded error That’s a weird way to refer to that it’s A stack Overflow but let’s find what it Says is correct to fix this you can add
A base case to the function to specify The condition which the function should Stop calling itself for example you Could add a condition that checks if the Number argument is equal to zero and if It is the function should return a value Instead of calling itself again here’s An example of how the function can be Fixed so we have the test function if Number is zero we return zero otherwise We keep doing these recursive calls so This is correct one thing I would say About chat GPT sort of from a UI Perspective though is that this is Really hard to read so for one I don’t Know like what language it thinks this Is with the coloring where it seems like Some of the words and the comments are Getting colors so for example function And return because I guess these are Keywords they’re getting colors like They are code additionally this is sort Of rapping weirdly so this text here is Part of this comment but it’s wrapping To a new line that’s I’m assuming Because of the width of the whole thing In the browser window but I would like If they would make the width the same as The max width of how many characters can Be used by chat GPT in a single line of Code that way this doesn’t happen but Either way the code seems to have fixed The bug it doesn’t really do anything But that’s fine it didn’t tell it to do
Anything it just just returns zero every Time okay so now what I want to do is Test can this do actual work can it Actually do my job for me so my job as a Software engineer is a little bit Different than most because I work for The company algo expert I spend most of My time on coding interviews and today What I needed to do was write a question Related to prim’s algorithm which is an Algorithm for finding a minimum spanning Tree in a graph so first of all let’s Just see does chat GPT even know what This is so let’s say what is krem’s Algorithm okay so that took a little bit More time than other requests but maybe That’s just because their servers are Busy but it does say prim’s algorithm is A graph search algorithm that is used For finding a minimum spending tree for A weighted undirected graph which is Completely correct that’s exactly what It does and I’m not going to read all of This but it seems to be basically Correct as to what crims is so I’d say Can you implement it in Python Okay so that did take some time and it Did actually come up with an Implementation interestingly enough it Did an implementation that uses an Adjacency Matrix as the input graph Rather than an adjacency list which Means that this is going to be a less Efficient version of prims but there’s
Not really anything in here that tells Me that this isn’t the most efficient Way to do this so if I wasn’t a software Engineer who knew about prims then I Would just see this and think this is The best way to do it and it’s not Necessarily the best way to do it so What I’m going to do is follow up and See if it can fix it but it not telling Me that this isn’t the most efficient Solution isn’t a great start so let’s Say can you use an adjacency list Instead and let’s see if it can rewrite This instead using an adjacency list and It seems like it can so it is doing that And it started doing it extremely Quickly okay so it was was able to Convert it to an adjacency list but it Didn’t actually make the code more Efficient so the reason adjacency lists Work better for prims is because of a Solution that’s going to use a priority Queue but it didn’t actually do that Just converted the solution I already Had to using an adjacency list which Maybe that’s on me for the way I asked The question so let’s ask for the time Complexity so let’s say what is the time Complexity of this solution don’t see What it gives us and then I’ll ask can It make that complexity even better okay So it does know that this isn’t the best Time complexity so it says that this is A big O of V squared time complexity
Which is correct and it does say that in Practice this time complexity can be Improved by using a more efficient data Structure to track the minimum distance Vertex for example we could use a Min Heap which is going to be that priority Queue to store the distances and the Corresponding vertices which would allow Us to find the minimum distance vertex In Big O Vlog V time which would reduce The overall time complexity to Big O of E Times log V where e is the number of Edges in the graph and that is actually Correct but the question then becomes Why didn’t it just give me that better Version to begin with but now let’s say Can you implement the more efficient Solution and I spelled efficient wrong Let’s fix that and let’s see can it Implement this better version of the Solution okay so it says here’s the Version with a man Heap and that seems To be what it is doing but let’s see how This code completely turns out okay so It was able to convert prims into using The Min Heap so it is able to convert it To this better solution once it’s sort Of been poked and prodded at a bit but Let me actually take some time I’m going To read the solution and make sure it’s Actually correct I’m assuming it Probably is but I do want to check that So give me a minute I’ll check back in Okay so after after much staring at this
Code and trying to figure out why it Doesn’t work which spoiler it doesn’t Work My conclusion so first of all the code Doesn’t work because it has this parent Variable that it uses but it never Instantiates a parent variable anywhere So that’s never created I’m not too sure What parent is supposed to be here but Regardless parent doesn’t exist so this Code does not run properly but from a High level it does have most of the Ideas correct so what this means is Basically that no I can’t just copy and Paste chat GPT code to use it as my own Code in fact I actually think it would Take me more time to debug this code Than it would take me to write my own Code to just do it myself even if it’s Something I didn’t know how to do at all I think I would end up spending more Time trying to convince myself that chat Gpt’s code is correct and if it’s not Correct trying to fix its incorrect code Then it would take me to just go do it Myself so personally I won’t really be Using this other than maybe to get some High level ideas I also think it’s Potentially very very dangerous that It’s not giving you full information all The time like how it showed us the Adjacency Matrix without telling us out Of the gate that that’s not the best Solution it also might just give you
Slightly inaccurate information and sort Of say it in this confident way that Makes you think it’s going to be correct And you don’t question it and then you Just end up with incorrect information Or incomplete information so I might use It as a place to get ideas I think it’s Great from that creative aspect I might Even use it to get high level overviews Of things related to writing code but I Don’t think just yet that I can replace My own code with it I think it’s like Self-driving cars once self-driving cars Are better at driving than humans even If they’re not perfect we can use them Instead of driving ourselves because That will be safer I think the same is True for coding humans aren’t perfect at Coding either so the bar isn’t that AI Needs to be perfect but it needs to be Substantially better than humans and Right now it’s not quite there but I do Still think it’s an amazing piece of Technology and I’m super excited get to Play with things like this and to see Where it goes in the future