Check out a free preview of the full Complete Intro to Web Development, v3 course

The "JavaScript Intro" Lesson is part of the full, Complete Intro to Web Development, v3 course featured in this preview video. Here's what you'd learn in this lesson:

Brian provides some encouraging words regarding the JavaScript portion of the course and discusses that "code is communication." Well thought out, documented, and laid out code will make it easier to understand and maintain in the future.

Preview
Close

Transcript from the "JavaScript Intro" Lesson

[00:00:00]
>> I'm gonna say now that this course gets significantly harder from this point forward. I apologize. I frequently got the feedback in the first time that I did this, that the first parts people felt really good about themselves. They were getting everything, and then they hit the JavaScript portion, they hit the wall.

[00:00:19]
We're gonna go slow, but the other thing I'm gonna tell you is, this is just harder, right? There's more stuff going on here. This is the more difficult portion of this for someone that hasn't programmed before. If you've programmed before, a lot of this will look somewhat familiar.

[00:00:36]
But again, remember this course is geared towards people that haven't programmed before. So, bear with me through the basics here and hopefully you'll learn tidbits about programming that you didn't know before. I promise you there's stuff in here that will help everybody. Okay, So, What is code? And I think my answer might surprise a lot of people.

[00:01:03]
People think it's something that humans work really hard on so that computers will do the thing that you tell them to do. Partial definition, I think is correct. But I'm gonna argue the code is for humans first and computers second. And the reason why I say that is you write code so that later you can go back and maintain that code.

[00:01:28]
If we were writing code purely for computers, you and I would be both writing Assembly right now. Or directly to binary, because that will make it go faster, guaranteed, right? JavaScript has a lot of overhead just in terms of it's a very high level language. There's a lot of layers to get JavaScript to work, so why do we choose to write JavaScript instead of C or Assembly?

[00:01:52]
It's because it's easier for humans to understand and maintain and continue forward with. So I want you to keep that in mind when you're writing code, that you're writing this so that someone later can read it. You're not writing it so that your program will work correctly, necessarily, you're doing that as well.

[00:02:11]
But you're writing it so that you can come back and understand what you were thinking, understand what you were trying to do, and then if there's a bug in there be able to fix it. So another way I like thinking about this, which I put here in my notes, is you're essentially writing notes to yourself about how to solve a problem that a computer can understand.

[00:02:31]
That's how I view code. Why is this an important distinction? Because we're really tempted to write the most clever code possible, right? Have you ever heard of what's called code golf? It's basically people try and write code that it's the smallest thing possible to solve some problem. So you've seen people that can write full video games in three kilobytes of JavaScript.

[00:02:56]
It's just bonkers, some of the things that people do with code. Just Google it, code golf, there's some wild things out there. And the code that they have to do to be able to achieve that is so clever. It's unreadably clever. Don't do that, [LAUGH] unless you're doing code golf, you don't want your code to be clever.

[00:03:17]
You want your code to be clear, succinct, to the point, all these kinds of things. Yeah, I've had to maintain code that's 10 years old, 15 years old, 20 years old, and the code that's really well written, makes it feel really nice to try and maintain that code.

[00:03:37]
Even if it's using really old style and techniques and stuff like that, if it's well documented and well thought out and clearly laid out, it's no problem. But then I had to maintain this just bananas PHP for in-memory graph database that someone invented. And it was just written in just the most opaque, weird style of writing code.

[00:04:01]
They used single letter variables and a bunch of stuff like that. It was like a nightmare. One of the worst parts of my career is trying to maintain this person's really old, terrible code. So, all this is, I will probably be your coworker some day. This is my plea to you to write clear code so that we can both understand it.

[00:04:26]
Okay, be explicit. It's okay to write more code to be more explicit. Computers are really fast these days. So for the most part, you can take a little bit of performance hit to be extra clear on things, optimized for humans first and computers later. Okay, that's my spiel to you, I start with that because I want you to take that ethos with you of, I'm gonna write clear code that I can understand.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now