ChatGPT Tutorial for Developers - 38 Ways to 10x Your Productivity

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] in this tutorial you're going to learn all about what chat GPT is how it works and most importantly how you can use it to boost your productivity as a software developer as a seasoned developer and teacher let me tell you chat GPT is a game changer you don't want to miss out on don't take my word for it just watch this video and see for yourself [Music] my name is mosh hamadani and I'm super excited to be bringing you this tutorial on chat GPT I've helped millions of people learn to code and become professional software Engineers through this Channel and my online school codewithmash.com if you are new here make sure to subscribe so you never miss a video so what exactly is chat GPT and how does it work chat jpt is a Cutting Edge AI tool created by open AI it was released in November 2022 and gained 1 million users in just 5 days in comparison it took Netflix three and a half years and Instagram two and a half months to get the same number of users chat gbt is an advanced language model that can understand and generate text you can use it to create content for your website write articles emails tweets cover letters and so on you can also use it to generate code in a number of different programming languages like python JavaScript HTML CSS and much much more you can use it to generate dummy data write unit tests translate text or code from one language to another you can use it to explain code for example if there is a piece of code you don't understand you can ask it and it will explain to you like a patient teacher but I have to be honest sometimes it explains too much chat GPT can also help you learn and remember things faster for example you can give it some text and have it ask you a bunch of questions it can also prepare you for job interviews you can have it improve your resume write a cover letter for you and also interview you like an interviewer now do you think chat GPT is going to take your job let me know in the comments below the reality is whether you like it or not chat GPT is here to stay in this tutorial I'm going to show you how to use it to get more creative and get things done a lot faster I'll be showing you various examples for different programming languages both for beginners and experienced developers but before we dive into that let's take a moment and understand how chat gbt works chat GPT uses a type of artificial intelligence called a language model a language model is a type of software that is designed to understand and generate human language it does this by looking at a large amount of Text data and learning the patterns and rules of a language for example if the language model is trained on a lot of English texts it will learn about the grammar and structure of English as well as the meanings of words and how they are used in different contexts once the language model has learned about a language it can then be used to generate text in that language now chat GPT provides different language models for different purposes gpt3 models which are designed to understand and generate natural language like English and codecs which are specifically trained to understand and generate code these models are trained on billions of lines of code publicly available on GitHub they're mostly capable in Python but they're also pretty good in a bunch of other languages like HTML CSS says JavaScript typescript Ruby SQL and more now before we look at specific examples remember shot GPT like any tool has limitations it might sometimes generate incorrect harmful or biased information so don't take whatever it tells you as a silver bullet don't use it to learn to code because the code that is generated is not guaranteed to be right it might be functional but it might not be the best way to code so in a nutshell chatgpt is a powerful tool that can help you be more creative and efficient but it's not a substitute for human expertise and judgment so that's the theory part now let's move on and see chat GPT in action so head over to chat.openai.com if you don't have an account sign up it takes only a minute once you have logged in you're going to see the main screen with an input box to talk to chat GPT there is also a Chrome extension and a desktop application available if you don't want to use the web interface I'll put the links down below this video alright now let's get to the fun part going forward I'll be showing you various use cases for different programming languages we'll start off with some general purpose questions that apply to anyone regardless of the programming languages and tools they use you will see how you can use chat GPT to learn new things write shell scripts get commands start a business write legal documents and so on once we cover the basics then we'll dive into specific examples for front-end back-end and database development I will show you examples using HTML CSS JavaScript typescript python SQL and more now here's my first question what are the top three books for learning Java all right as you can see chat GPT has given us a very comprehensive and detailed answer now here we can ask more detailed questions for example we can ask questions about the first book so we can ask what are the key takeaways from head first Java all right another comprehensive answer you can see that this book teaches you about object-oriented programming Java fundamentals threading and concurrency GUI programming and so on now we can also ask more general questions like how do I become a front-end developer so now chat GPT is saying that to become a front-end developer you need to know the basics of HTML CSS and JavaScript you should practice building websites then you should learn a front-end framework like react angular View and so on you should also know about Version Control Systems like git GitHub and Swap this is pretty much the same answer you will find on every website that gives you a roadmap to become a front-end developer now let's look at more specific examples we can ask chatgpt to write a shell command for us for example we can say write a bash command to find the name of all JPEG files in the directory and write them all to a text file take a look I love this answer so if you're not good with Linux commands you can easily find the final instruction you should use to solve that problem but what is beautiful about chatgpt is that it also explains how this command Works line by line piece by piece we can also have chat GPT red git commands for us for example we can ask how do I know how many lines of code I've committed to a git Repository we can also use chat GPT to get creative for example let's say you want to start a business you can have chat GPT generate app or website names for you for example we can say I want to make a revolutionary online shopping app give me some good app names so chatgpt is suggesting names like shop is Swift cart streamline and so on I think this list is pretty damn good now these are just some example prompt you don't need to use the exact same wording to talk to chat GPT you can ask any questions you want in your own way now if you have used this tool before let us know in the comments below the interesting questions you have asked so we can all learn and Inspire each other we can also ask chat GPT to write contracts for us here's an example I want to hire a graphic designer to design a website we have agreed that they will deliver the first draft in two weeks and offer three iterations free of charge any iteration after will be charged at fifty dollars an hour write a contract for us so the more details we give to chat GPT the better response we'll get all right take a look this is a pretty damn good contract to start with of course you don't want to take this as is and use it in the real world without first passing it by a real lawyer that's why earlier I told you that chat CPT is not a replacement for humans at least none at the moment it's just a way to increase your productivity and get things done in less time now if you're applying for a job there are a number of ways chat GPT can help you for example you can have it write a resume for you hear me can say I have three years of experience coding in HTML CSS and JavaScript write a resume for me of course we can give it more details we can explain our education level our past projects and so on but look at what we get with this simple prompt all right take a look so chat GPT created a basic layout that includes our name address phone number email some objective summary technical skills and it has already listed all the related web Technologies so we have HTML CSS JavaScript jQuery bootstrap we didn't mention any of this but it assumed that we have these skills it also included a section about professional experience including past projects as well as education certifications and so on again it's a great starting point now let's say you're applying for a front-end developer role you can ask chatgpt to write a cover letter for you that you can email to that company so we can say applying for a front and engineer role at some company write a cover letter for me all right take a look we have a comprehensive cover letter beautifully written in perfect English how good is that now let me show you another fun one you can have chat GPT ask you interview questions we can say act as a technical interviewer and ask me five questions about JavaScript take a look all right so here we have five questions that are often asked in technical interviews now let's say you don't know the answer to the first question you can ask a follow-up question so the beauty of chat GPT is that it remembers everything you have told it in this conversation thread so here we can say what is the answer to the first question again we get a very comprehensive detailed answer you can also ask chat GPT to help you write emails for example we can say write an email to my boss asking for a raise I've worked at this company for two years and successfully delivered several projects on time seriously if I wanted to write this myself it would take me 10 to 15 minutes if not longer I got the answer in just two seconds all right now let's look at a few examples involving code we'll start with using python for writing a command line tool we can say write a python function for generating a random password so as you can see we get a piece of code beautifully highlighted with explanation of how it works now if there's a part of this code that you don't understand you can always ask follow-up questions for example we can ask what this expression does in this code so we can ask what does 4 in I range of length 2 in this code take a look really really useful couldn't be better now we can also ask computer science questions like what is the time complexity of this function now if you're not familiar with this concept time complexity is a way to explain how large inputs impact the performance of an algorithm it's really beyond the scope of this tutorial I've covered it in detail in my data structures course in case you're interested so let's see what we get so chat GPT is saying that this function's time complexity is linear now let's take this to the next level we can ask chatgpt to write unit tests for this function so write unit tests for this function seriously how good is this if I wanted to write all this unit tests by hand it would take me probably 20 to 30 minutes if not longer of course we should always use our own judgment to make sure that the tests are correct but I think this code is a great starting point and it really saves us a lot of time we can also ask chat GPT for ideas to improve our code for example here on w3schools.com we have this piece of python code where we use a for Loop to iterate over a list of fruits if the fruit has a in it then we add it to a new list I'm going to copy this code and give it to chat GPT to see how we can improve this code so take a look how can I improve this code now here we should hold shift and then press enter so we go to the next line now we paste our code and then press enter to submit the question all right look a lot of details absolutely amazing one thing I love here is that chat apt is suggesting to use a list comprehension which is a one-liner for implementing the same logic of course there are more ways to improve this code we are not going to get into details here we can also ask chat jpt to convert our code from one language to another for example we can say convert this python code to JavaScript foreign just a few seconds our code was converted to JavaScript and down below we have all the details about how this code works we can also use chat CPT to generate dummy data for example we can say generate dummy data for a table called customers each customer should have an ID first name last name and City now in this case chat GPT gave us a python script for generating dummy data but what if we want the actual data not a python script we can say I don't need a python script just give me the data so now we get a list of 10 people represented using the Json format now we can take this to the next level and say create a python class for storing these objects foreign look we get an example of a python class called customer along with how we can use this class to store a bunch of customer objects inside the list absolutely beautiful now if you're a front-end developer you can ask chat jpt to generate some HTML markup for you and this is where examples get more and more interesting for example we can say write the HTML and CSS code for displaying a card foreign take a look we have the markup here we have a div with the class of card inside the div we have an image then we have the card content inside this div we have the card title and cart description really really good and right below that we have all the CSS we need to display a beautiful card of course we probably need to customize this but again this is a great starting point now we can stop here or we can customize this further for example we can say add a button below the card content foreign look what happened so now we have a new markup right under the card description we have a new div with the class of card action and inside this div we have a button beautiful now we also have more styles for this button we have the plane Styles as well as the styles for the hover effect now let's take this to the next level we can say when I hover my mouse over the card I want the card to slightly slide up so charge if it is suggesting that we should use the hover sudo class and the translate function Translate Y to slide the card up beautiful I love it it's also suggesting an alternative solution using box Shadow so it's pretty up to speed with CSS features now let me show you something really cool we can ask chat GPT to rewrite this code using Tailwind CSS if you're not familiar with Tailwind it's a CSS library that has gained a lot of popularity lately so here we can say can you rewrite this code using Tailwind CSS foreign there you go now we have the same markup but with the utilityclasses that come with Tailwind CSS so we don't have to create CSS classes anymore now here we can get more creative and see what other UI libraries are supported next we can bring some JavaScript to the mix and make this interactive so we can say when I click on the button send an HTTP request to slash API slash products foreign let's look at the generated code so chat GPT is suggesting to use the fetch API that is supported in pretty much most modern browsers but I personally don't like to use the fetch API so I'm going to customize this further and say instead of the fetch API use axis which is a library for sending HTTP requests now take a look all right now we have the instructions for installing axios using npm or yarn as well as a modified example using axis beautiful we can also ask chat GPT to help us with compile time or runtime errors here is an example let's say as part of writing some JavaScript code we got an error saying uncut type error cannot read property let's say bar of undefined anyone who has written a little bit of JavaScript code has probably come across this error so we can copy paste the error message here now chat GPT explains exactly what this error is and how we can potentially solve it so going forward I think a lot of people will start to use chat GPT instead of Google now we can also throw react here and make the example more interesting so we can say create a react component for displaying a card all right let's see what's happening here so up here we have an example of a function component for displaying a card now I personally don't like to have a parameter called props it would be nicer to destructure this parameter and grab individual properties like title description and so on so if you're not familiar with this concept don't worry just continue watching we're not going to do a lot of fancy JavaScript stuff in this video this is just to open your eyes to the possibilities so let's take this to the next level and say this structure the props parameter so the beautiful thing about chat GPT is that it remembers our conversations so let's go ahead foreign we have a new implementation of the card component with the props parameter destructured all right now let's move on and look at a few examples involving back-end development for example we can ask chat jpt to build an API for us with node and express so here we can say I need an API built with express.js to return the list of products each product should have attributes like ID title description price and image URL thank you all right look at this implementation in this implementation we have an area of products stored in memory and we have an API endpoint exposed at this URL I don't want to have an area of products in memory I want this product to be stored in a mongodb database so here we can say modify the code and retrieve the products from a mongodb or a MySQL or a postgres whatever database now we get a new implementation where products are retrieved from a mongodb database using the Mongoose Library here it is now in this implementation the type of these parameters is not clear because this code is just plain JavaScript now we can improve this implementation and use typescript so we can say use typescript in this code now we have a new implementation of the same web server implemented using typescript now let's say you're a python developer you don't want to use JavaScript so here we can say generate this API using Python and fast API which is another library for building apis using python so all right now we have a new implementation but in this implementation our products are stored in memory again we can talk to chat GPT and customize this further all right now let's look at a few examples involving databases this one is pretty interesting so I'm going to say write a SQL query to generate a table called products with four columns note that I'm not specifying the column names and types here I'm just saying I want a product table with four columns see what happens now look chat GPT is smart enough to know that quite often products have attributes like ID title description and price if this is not what you want you can always specify the name and type of each column for example we can say write a SQL query to generate a table called products with these columns now here we press shift and enter so we go to the next line and on each line we can list a column we can say ID of type integer title of type string category of type integer unit price of type float and image URL of type string and you don't necessarily have to put a type in parenthesis you can type a colon and right after that we can specify the type so chat GPT doesn't have a particular syntax you have to follow because it can understand human language all right now in the products table we have columns like ID title category unit price and so on we can also use chat GPT to write queries for retrieving or updating data for example here we can say write a query to retrieve the top five customers in Manhattan note that we don't currently have a table called customers so we're just asking chatgpt to write a query to retrieve the top five customers in Manhattan take a look alright in this example chatgpt has assumed that we have a table called customers with these columns ID name address and City if our customers table has a different schema we need to specify that ahead of time so we specify the name and type of each column then we ask chat GPT to write a query to retrieve the top five customers now look at this query in this query we're simply selecting customers who are located in Manhattan so in this query the customers are sorted by their ID in descending order and the top five are returned this is not what we really want what we want is the top customers who have spent the most so we need to be more specific with our prompt so we need to tell chat CPT to do a join with the orders table to find out how much each customer has spent then it should grab the top 5 customers who have spent the most so we can say revise this query and join the customers table with the orders table to find out how much each customer has spent then pick the top five who have spent the most and again here we can specify the schema of the orders table as well so let's go ahead all right look now chat GPT is assuming that we have two tables customers with these columns and orders with these other columns and based on this schema it has revised our query to retrieve the top five customers who have spent the most so that's it guys there are endless ways to get creative and use chat GPT I hope you found this video helpful if you enjoyed it please give it a like And subscribe for more videos like this also let me know in the comment section what interesting questions you have asked chat GPT I would love to hear from you so thanks for watching and I will see you in the next video
Info
Channel: Programming with Mosh
Views: 496,209
Rating: undefined out of 5
Keywords: chatgpt, chat gpt, chatgpt tutorial, code with mosh, programming with mosh, mosh hamedani, chatgpt examples, how to use chatgpt, openai, chatgpt explained, what is chatgpt, ai, open ai, chat gpt tutorial, programming
Id: sTeoEFzVNSc
Channel Id: undefined
Length: 28min 13sec (1693 seconds)
Published: Fri Jan 13 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.