- Hi, I'm Chris Piech.
I'm a professor of Computer Science at Stanford University.
Today I'll be answering your questions from Twitter.
This is Coding Support.
First up, from Mojam TXT,
"How many coding languages are there?"
Well, Mojam, 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 Java Script that's great
if you're writing a website.
And there's a whole bunch of other ones like C,
C++, 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.
EugeneDaniel asked,
"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 had just taught themselves, and now we're working
at one of the coolest programming companies.
Okay, next up.
Glacialicon, "I always wondered
in apocalyptic and action movies,
how do coders manage to save the day
without ever using Stack Overflow?"
And Glacialicon, I'm gonna say, that's a fantastic question.
Realistically, when we're coding,
we're using Stack Overflow.
Stack Overflow's 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.
Though 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,
is 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.
R40aja40 asks, "What does front end 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 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 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 end
and the back end, and that's a good thing to be.
Next question from Begusgasper,
"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.
Sudo_rbot 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++ 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++ 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++ is what you'd use.
C++ 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 extend.
C++ is one of those, and you can see
where it 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 are to one another.
Why is C or C++ so good for video game programming?
Because it's so computationally intense.
You have 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++, 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.
LosMerengues_14 asks, "My computer science teacher asked,
'What is Python?' And I replied, 'A very dangerous snake.'
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,
and so gave it that name.
It's a general 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 chatbot even.
Do you wanna see what Python looks like?
I can show you a really basic intro to Python program,
a "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 your program,
it's going to open up a console,
and it's gonna say, "Hello world."
That's the greeting we use when we are 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 fashion says,
"I'm gonna print the numbers, the first 10 numbers,"
so it'll print zero, then one, then two,
then three, then four, then five, then six,
then seven, then eight, then nine.
Main is what happens when somebody starts your program.
So def main says, "When someone starts your program,
I'm gonna execute all of these commands,"
and then I write the commands 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 computers
is that they can do lots of repetitive tasks
without becoming frustrated.
Humans, not so much.
This is one of those basic commands
you need to know to make a computer repeat a task.
It says, "I wanna repeat something 10 times,
and 10 times I would like to print out a value."
This is a value that's gonna change numbers
from zero up till nine.
So when you run this program, it'll print zero,
then one, then two, then three, then four,
then five, then six, then seven, then eight, then nine.
Next question from CheEsquire,
"What is the meaning of error 404?"
Error 404 is what you see when you go to a website
and that website doesn't exist, and the webpage 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 error 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 Berners-Lee.
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 webpage 401, 402, 403, 404,
or just different problems that could come up
when you're trying to load a webpage.
Okay, next question, Formulemur,
"Are programming and coding the same thing?"
Yes. Coding is the process of opening up
an application on your computer and writing a sequence
of a 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.
FutureLear, "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 a small version of a motherboard,
and on it it has things that you can plug in like a USB.
It 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 wanted to write a program
but you wanted to make it 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 PyTorch or TensorFlow, you say,
"Here is the structure
of my artificial intelligence network,
and once I have that structure
I'm gonna 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.
KukielkaMaciej asked,
"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 TikTok algorithm.
What that does is it decides what video you should see next.
How does 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 TikTok algorithm,
what they're talking about is how TikTok chooses
that next video.
Antom asks, "GitHub, what the hell is GitHub?
It sounds rude."
GitHub's not rude, GitHub'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 NanaouuSymeon,
"Which coding language is the easiest one?"
That's a good question.
What 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 lowkey wanna learn but I'm 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 wanna have
if you wanna learn how to program?
The desire to build things,
'cause 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 and you're willing to work
through step by step, you'll figure it out.
Banqash1401, "I have always been curious about the origin
of coding, computer software, artificial intelligence.
My questions were like, 'How scientists
could have bridged hardware with software
for the first time?
What was their mean to do that, and when did they realize
that such a thing could be possible?'"
Oh, the history is so interesting,
and it plays into so many important parts of human history.
Certainly one of the turning points was World War II.
When Alan Turing 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 wanted to decrypt it.
They built what I would consider
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, Ada 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 Ada 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 gonna 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?
What I fill in this form, what's supposed to occur next?
And people write that in a coding language.
Having said that, a big part of a web design team
is also artists.
People 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.
PrettyHatHacker asked,
"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,
'cause 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 computers to do things for you.
So the ability to communicate with computers
is just such a powerful tool to have.
Whether 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, till next time.