Transcript from the "Executing a Program" Lesson
>> Kyle Simpson: Okay so let's go back to the text, I know I kinda jumped around a little bit and I'll well let's a get ourself back on track and make sure we understand that we track back with the text. So, [COUGH] and the next topic that's addressed is what we've only talked about so far, is how to think about what a program is structured in.
[00:00:23] And maybe start to thinking our brains about what we do if we wanted to do it, but it turns out that it's much more important for the computer to run our program, in the end than it is for us to run our program. So, it is that duality as was brought up before, between needing to be able to look at a program and understand what it should do, and then being able to rely upon the computer to do what it actually must do.
[00:00:45] And those are two really important halves of the brain, if you will. So executing a program, what does that mean? Well, essentially it means, turning the statements that we've written, like a equals b times 2, into low level instructions, that a computer can do something with. The computer itself would look at a equals b times 2 and have no idea what that meant.
>> Speaker 2: Cool.
[00:02:19] So a translation level would go from that to maybe something like a = 2, right. And then something would have to go from a = 2 down into another layer, and we might be getting too far field, but I just wanna make sure you understand. So the next layer down might be something that people refer to as assembly language, which is still a high level language, it's not a 1 and a 0 but it's lower level.
[00:02:44] And I don't even memorize assembly language but it's something like mov a,2 or something like that or I think it's 2,a or something like that, but that lower level thing is like, I got these two different registers in memory or whatever and move one into the other, right?
[00:03:02] And then finally, at the lowest level of the stack its taken that thing down into a series of 1s and 0s. That's really, really long and that 1 in 0 string tells the computer what to do. So what we want, is we wanna figure out to execute my program of course we don't need this top level, but we definitely need this a = b level.
[00:04:40] So when it's working on the statement on line three, it has no idea what to expect of line four cuz it hasn't gotten there yet. It's like if you're working through a to-do list, and you're like I don't even care about item two yet, cuz the top item on my to-do list is the only thing I'm thinking about, right?
[00:04:55] Well, that's what we mean by interpreting, and there are languages that are, in fact, interpreted like that, that are interpreted line by line by line. An example of that might be something like a command line scripting like Bash or whatever. It's not fully interpreted, there's a little bit of nuance there but it's essentially interpreted line by line.
[00:05:29] It's definitely true that when Brandon was first inventing it as a prototype, he didn't really have all the time to go through all of these sophisticated stuff so he had to make just bank something out quickly, and it cut a lot of corners. And so essentially, in the very beginning it was kind of that way.
[00:06:10] And what a compiled language and an interpretative language, the way that they primarily differ, is not the way you might think that they differ. So most people think of compilation as I'm producing some physical series of 1s and 0s and putting those into a file, that I can send that series of 1s and 0s to other people, and they don't need to process it, they just need to run it.
[00:06:55] So when you put a program like this, if that was in a file and you loaded that up into browser, line one would never run, you'd immediately get an error saying line two is invalid. Whereas if you put this into a scripting language like a bash or something, line one would run and then you get an error on line two.
[00:07:27] You try to run your program and the first thing that happens is it gets compiled. And if the compilation throws an error, and says, hey, you've messed up, that's not good. Then you know what you need to fix, it'll tell you, line two is invalid, two's not a function, or whatever.