hi I'm Chris Peach I'm a professor of computer science at Stanford University today I'll be answering questions from Twitter this is coding support [Music] first up from mojem txt how many coding languages are there well mojom there's a lot of coding languages some of the most popular ones include python that's great if you're doing data science or if you're writing scripts for your computer there's JavaScript that's great if you're writing a website and there's a whole bunch of other ones like C C plus plus Java and that's just five of the top most common ones my friend from University even made a coding language of their own just for fun Eugene Daniel asks can coding be self-taught absolutely coding is such a special field what matters is that you have the skills it doesn't matter so much if you have a credential saying you can do it what matters is that you can pick up a computer and you can code it and make it do wonderful things there's a lot of incredible resources out there Stanford myself we offer free programming class if you're interested I know a lot of self-taught success stories when I worked at Pixar I knew a lot of programmers there who had never even studied computer science in University or anything like that they just taught themselves and now we're working at one of the coolest programming companies okay next up glacial icon I always wonder apocalyptic and action movies how do coders manage to save the day without ever using stack Overflow and the glacial icon I'm going to say that's a fantastic question realistically when we're coding we're using stack overflow stack Overflow is a website where you can go ask questions and see answers and you can see code Snippets that other people use to solve problems every serious coder I know uses stack Overflow to build better answers and so it's pretty unrealistic that in an action movie they're not using stack Overflow so I guess if you only have a few minutes to save the world maybe you have to code without getting any help the origin of the term stack Overflow is actually an interesting story it comes from one of the problems that you could have while programming your program has a certain amount of memory part of it's called the stack and if that stack uses too much memory it throws a stack Overflow error and this often happens when there's something going really wrong with your program it's just consuming memory wildly but the stack Overflow website isn't just about that problem it's a whole Community where people come together and help each other and I love that community of all of us coming together and making each other better R40 aha 40 asks what does front and and back end mean I love this question and you know what to show you I'd like to explain a little bit of how how the internet works when you use a mobile application let's say you're using Google Maps and Google Maps is telling you how to get from point A to point B there's a computer program that's running on your phone and that's called the front end but not all the work is done on your phone in fact a lot of the work might be done on a different computer so what your phone does is it connects over the internet to another computer that we call a server and that computer can do calculations and send the answer back to your phone and you know this is basically the idea of the internet we have all these devices and they're talking to other computers on different parts of the world and programs that run on this computer we call those the back end so you have the front end running on things that you interface with and back end running on things that are doing some work behind the scenes that you'd never see you know maybe it's a little bit like a car the front end might be the steering wheel that's what humans interact with there's a whole bunch of Technology there the back end is the technology you don't see maybe it's like the engine it's doing really important stuff but when everything's working smoothly you just interact with that steering wheel some people only specialize in writing programs for the front end some people only specialize in writing programs for the back end or you might hear this term full stack engineer and those are programmers who can do both the front and and the back end and that's a good thing to be next question from begus Gasper what is the shortest piece of code that changed the world that's a good question and over a drink we could have a great conversation and debate this I'm gonna say back propagation for artificial intelligence back propagation is the few lines of code that tells an artificial intelligence algorithm if I see data how can I become smarter based off of that data it's a very simple piece of code based off some cool calculus and that's where most AI gets its intelligence from say your AI algorithm is trying to learn what a cat is and it sees a picture of a cat it can put it through its own little AI brain back propagation will tell it how to change its AI brain so that it is better able to understand cats in the future pseudo arba doesn't really have a question but a cute little rhyme how much could a C plus plus if a c plus could plus plus C plus plus is one of the most popular programming languages in fact it's the one that I first learned on that's how old I am and C plus plus it's what you want to use if you're writing a really intense program like a 3D computer game or if you're writing the program to animate a Pixar movie C plus plus is what you'd use C plus plus is actually descendant of another programming language called C and C is like the grandfather of all languages like the Latin equivalent from which many different languages attend C plus plus is one of those and you can see where he got its name from it's C and then plus plus is programming speech for one better so it's like I'm like C but I'm a little bit better and there's other descendants you might have heard of like Java and Python and the fact that all these three languages descend from C tells you how similar that they they are to one another why is C or C plus plus so good for video game programming because it's so computationally intense you have to to render an entire 3D World with trees in the distance and things animating in the front and that just asks so much of your computer C and C plus plus they're like your bare bones programming languages they're the most efficient so they can run the fastest and they can do the most computations per second Python and Java they're easier to read so it's easier to write the program but the computer can't run them as quickly Los merenges 14 asks my computer science teacher asked what is Python and I replied a very dangerous snake uh and he beat me up I feel like we have to have a different conversation about corporal punishment here did you know the name python the name for this programming language actually comes from Monty Python's Flying Circus the person who invented the programming language called python was a big fan of the TV show so gave it that name it's a general pro purpose programming language so you could write a Google Maps backend on it you could write data science you could just write a script that does something fun or you could write a chat bot even do you want to see what python looks like I can show you a really basic intro to play Python program uh hello world and print 10 numbers here's an example of a very simple Python program this says when you run this program so somebody goes to the computer and they click on click on your program it's going to open up a console and it's going to say hello world that's the greeting we use when we're trying to show that we can write our first program it's like your program saying hi I'm new to this world tell me all about it and then your program in very cool faction says I'm going to print the numbers the first 10 numbers so it'll print zero then one then two then three then four then five then six and seven then eight the nine main is what happens when somebody starts your program so deaf main says when someone starts your program I'm going to execute all of these commands and then I write the commands uh one by one the first command I wrote is print hello world print doesn't mean like print through your printer it means show up on the screen the next line says for I in range one of the great things about computer is that they can do lots of repetitive tasks without beingcoming frustrated humans not so much this is one of those basic commands you need to know to make a computer repeated task it says I want to repeat something 10 times and 10 times I would like to print out a value this is a value that's going to change numbers from 0 up to nine so when you run this program it'll print zero then one then two then three and four then five then six and seven and eight the nine next question from Che Esquire what is the meaning of pair 404 Arrow 404 is what you see when you go to a website and that website doesn't exist and the web page is saying I don't know what website you're looking for more broadly when programs don't know what to do or when they break they often throw a thing called an error and as a human you're given these errors errors always have codes they tell the human and they tell somebody who's trying to diagnose what went wrong exactly what the problem was so when you see Arrow 404 that's a specific message saying exactly what went wrong was that I wasn't able to find the particular URL you were looking for web error codes were actually defined by the guy who invented the web Tim Bern early as I understand it he was just coming up with sequential codes I think the first four means that there is a problem with your web page 401 402 403 404 or just different problems that could come up when you're trying to load a web page okay next question formula are programming coding the same thing yes coding is the process of opening up an application on your computer and writing a sequence of commands that look a lot like English but are in a specific language that your computer can understand you can code in something like python or JavaScript these are the languages of coding and that's how you tell a computer I want you to perform all these actions when somebody hits a button or when somebody opens this application programming is the exact same thing you're making a program when you're coding future leer what is Raspberry Pi and what can be used for futurelear this is a Raspberry Pi and this is one of the world's cheapest computers what are we looking at here we're looking at small version of a motherboard and on it it has things that you can plug in like a USB has a place for audio and a place for internet connection and on the chip it has a thing called a CPU so it's Central Processing Unit so it can process programs and it has some space for memory so it can store some data it can connect to a power source it could connect to a monitor and it can connect to lots of sensors and why is it so cool let's say you want to write a program but you wanted to make get physical and interact in the real world maybe you wanted to make a robot or maybe you wanted to make a smart doorbell or something like that you could use this super cheap programmable computer and maybe you put a sensor in it and maybe you make you know another actuator and then you make something happen in the real world next question from TJ Jesse TJ how do you code AI wow what a deep deep question in so few words people might be wondering what AI means AI stands for artificial intelligence and artificial intelligence is a very broad term it literally means any algorithm which is acting in an intelligent way the most common type of artificial intelligence is a type called machine learning and that's when an algorithm gets smarter when it looks at data or when it gets experiences of its own the most common way to code AI is in Python using something like Pi torch or tensorflow you say here is the structure of my artificial intelligence Network and once I have that structure I'm going to write some code that can take in data and I'll tell my artificial intelligence to get smarter using data and that's all done in Python but in 2022 the way people write AI could be changing there are these really large artificial intelligence networks which have been published and sometimes writing AI is figuring out how to talk to these really billion parameter neural networks so you can put in prompts that would give you interesting answers do you practice algorithms frequently if yes why I do practice algorithms frequently I practice algorithms frequently for lots of reasons one because they're neat one because I teach them one because they keep me becoming a great programmer but also because we invent algorithms but what's an algorithm an algorithm is basically any piece of code that does an interesting task so maybe it solves a problem that would take a lot of thought one example of something we worked on recently is we made an algorithm that can do a digital eye test and it's always being thoughtful about what size letter to show somebody next one algorithm you might hear a lot about is like The Tick Tock algorithm what that does is it decides what video you should see next how does it it work that's in fact a bit of a mystery I don't think they tell the world this is how our algorithm works but when people say The Tick Tock algorithm what they're talking about is how Tick Tock chooses that next video and um ass git Hub what the hell is GitHub it sounds rude GitHub is not rude hub's your friend GitHub is a website where a lot of US host our code so when I write a program often I'm working with other people and we use GitHub to store our code a lot like using Google docs for when you're working on a Word document together github's our place for code it's also a place where you can go and see other people's code some people choose to put their code up publicly which means that when I'm working on a project I can see what other people have done that's one of the cool things about computer science we're always building on top of each other's ideas so if somebody's built a really cool program I don't have to start from scratch off and I can build a top of their really cool program next up from Nana Simon which coding language is the easiest one that's a good question when we teach intro computer science at Stanford we use Python because we think it's the most gentle introduction to programming but in the very first week we use an even simpler programming language called Carol this is Carol Carol's a simple robot Carol can only move turn left put down a beeper or pick up a beeper but when you add in some of the basic control flow of programming Carol can do anything that we can do in Python which is incredible we use as a gentle introduction just to show you the basics and it's a great way to learn if you're curious diners asks do you have to be good at math to code I low-key want to learn bomb terrible at math do it learn to code you don't need to be great at math to code this is a common misconception I think it has its historical roots in the fact that when programming was first invented they didn't know where to put it inside the university and they happened to put it in the math department so people think you have to be great at math but in reality I've seen so many amazing programmers who don't feel that confident in math and you know what learn to program it'll probably help your math out because it helps you do lots of things that use logic and math is one example of something that could use some logic I'd say what skills do you really want to have if you want to learn how to program the desire to build things because programming is all about making stuff and patience because sometimes when you're making things it won't work out the way you expected and if you're patient you're willing to work through step by step you'll figure it out bangkash1401 I have always been curious about the origin of coding computer software artificial intelligence my questions were like how scientists could have bridged hardware and software for the first time what was there mean to do that and when did they realize that such a thing could be possible oh the history is so interesting in it it plays into so many important parts of human history certainly one of the turning points was World War II When Alan turning and a group of other people in the UK came up with what some people would consider the first computer why so that they could decrypt German messages that they were sending between each other and you needed to try a whole bunch of different secret keys if you want to decrypt it they built what I would consider some of one of the first computers and would try lots and lots of different keys until it could decrypt the German messages you could think of this as one of the first pieces of artificial intelligence because cracking someone else's code that sounds a lot like intelligence but the history of software goes way before that people were theorizing that you could have something like a computer back back in the day in the 1800s at a Lovelace and another professor Charles Babbage they were saying I think we could have computers that work on digital ones and zeros and actually these things could solve problems and add a Lovelace without even having a computer started writing all these different algorithms and programs when computers didn't even exist and they kind of showed the world this is going to be cool once we have the electronics for it nihar DM asks is coding required for web design what's web design web design is when you make a website and that can often involve coding it turns out a lot of the websites you interact with they're running a lot of interesting code underneath the hood what happens when you click this button when I fill in this form what's supposed to occur next and people write that in a coding having said that a big part of a web design team is also artists people are just thinking how can I make this a beautiful website or how can I make this a beautiful user experience and it's a really valuable skill to learn how to become that artist or that user experience designer you don't necessarily need coding for that pretty hat hacker asks the real question is do you need to know how to code in order to hack why or why not we should break down what hack means because it means different things to different people to some people hacking means breaking into someone's website or something like that maybe getting into a database stealing some passwords in my field we actually call that cracking and that's quite illegal and I wouldn't recommend people do that hacking in the world of computer science sometimes is a shorthand for writing really impressive code regardless of which version you're doing the illegal version or the less illegal version if you want to be doing really interesting things with computers that maybe go against the grain certainly knowing how to code is important don't do anything illegal at home Jerry bandito why is coding important coding is how you get compared is to do things for you so the ability to communicate with computers is just such a powerful tool to have whether you're not you're doing data science or you're in policy or you're in art no matter what you're doing there's probably a time when your career would benefit from being able to speak the language of computers but I also think coding isn't just useful it's also beautiful it is a really beautiful process of how you speak to the computer how you create things out of nothing when I'm coding I take ideas in my mind and I make them into reality sometimes that's useful and sometimes it's just a beautiful process okay that's all the questions hope you learned something until next time [Music]