(bamboo flute music) (upbeat music) (calm music) - Good morning, I'm Doug Crockford.
But tomorrow will be much better. Tomorrow we're going to workshop, we're going to have fun with functions, you're going to be writing programs. It's going to be great. We're going to have a much better time tomorrow. Then on the third day, we'll do some more fun with functions and we'll also look at some very important topics, security, asynchronicity, which is something you have to deal a lot with, especially in servers, and The Better Parts, looking at the future of this language and other languages. So that sound agreeable? So let's begin with part one, Programming Style & Your Brain.
These are two topics which appear to have nothing to do with each other. Programming style is the part of your program that the compiler ignores and some people think that because the compiler doesn't care, you shouldn't care, any style's good as another, it's just a matter of taste. I'm going to try to persuade you that that is not that case, that some styles are significantly better than others. And then, your brain. Your brain is that big wad of meat in your skull that you think with. And what possible connection could there be between these two things? Well, turns out there is a connection, a surprising and important one.
I'm going to be misrepresenting the work of Daniel Kahneman, the Nobel winning psychologist. Now, Nobel does not give a prize for psychology, so they gave him the award for economics, but he's not an economist. But he found that one of the fundamental assumptions of economics doesn't hold, that is that in any transaction, a party can be expected to pursue their own best interest. Kahneman shows that this is not the case, if a party is a human being, because human beings do not think the way economists think we think.
In fact, none of us think the way we think we think, and the more you study Kahneman, the more amazing it is that we ever get anything done at all. So, Kanheman has a metaphor for human thought, based on the interactions of two systems, system two and system one. System two, which we can think of as the head, is the higher level one. It's analytic, it's algorithmic, it's where we do mathematics, and reasoning, and logic. It's a really sophisticated machine.
It requires a tremendous amount of effort to use, and it is very slow. So we leave it turned off as much as possible. It's because that system is so slow that we had to invent computers. Because system two is not capable of generating all of the numbers that society needed in order to do its social evolution, so we needed to come up with machines to do that processing for us. Then there's system one. System one, you can think of as your gut. It is intuitive, it's heuristic, it's associative.
It is very, very fast. It requires no effort. And in fact, you cannot turn it off. It's on all the time. And the idea that we have these two systems is not new. We all have this intuitive sense that we've got these two systems. And sometimes you can even hear them. Sometimes if you're confused about something important, you can hear your head telling you one thing and your gut telling you something else. I mean, we've all experienced that. What Kahneman found was how the two systems are connected. It turns out system two gets its assumptions, its givens, its working set, from system one, and is not aware of that connection.
System two think it's getting this stuff from the vault of deep truth, but it's not. It's getting it from system one. And system one, because it's an approximate system, sometimes gets things wrong. And if you have a logical system with false inputs, you can get false outputs. It turns out we do this all the time.
This course was created by Frontend Masters. It was originally released on 6/20/2016. We're pleased to host this training in our library.
- Writing code for performance
- Script tags
- Nodes and events
- ES5 and ES6
- Principles of security
- Object capabilities
- Synchronous functions
- Asynchronous functions