(oriental flute music) - And now, the better parts. So this is Antoine de Saint-Exupery. He was an aviator, back at a time when aviation was really dangerous. That's what we used to call pilots, but he was an aviator. It was really dangerous because the planes crashed. And he experienced several crashes during his career, survived almost all of them. He was once trying to set the air speed record from Paris to Saigon, and his plane crashed in Egypt, near Cairo, out in the Sahara Desert.
And he was not prepared for survival in the desert. He did very badly there, suffered terrible dehydration, dehydrated so much that he stopped sweating, which is a really dangerous thing to do in the desert, suffered terrible hallucinations. Fortunately he was rescued by someone who understood how to treat severe dehydration, and he survived and recovered. Moved to America as the war is beginning. Becomes a writer, and it turns out he's a brilliant writer.
He writes one of the most famous children's books, The Little Prince, which is about an aviator who's stranded in the desert, who is visited by a strange little boy who lives on an asteroid, and is suicidal. Like all the best children's books, it's not really a children's book, yeah. And he wrote other books too. He wrote some very good books about aviation, books aimed at grownups. In one of them, he has one of the best sentences ever written.
He says, "It seems that perfection is attained not "when there is nothing more to add, "but when there is nothing more to subtract." Which is just brilliant. I've seen this quoted and requoted over and over again. It's used all over the place, in engineering design, anything that's creative, that requires some kind of discipline, it's just a brilliant quote. And he's talking about the design of airplanes, but it seems to talk about everything. And I think it's especially telling for programming, because we have a special relationship with perfection, right? That our programs have to be perfect or they're not going to work correctly.
And he gives us some insight as to how perfection is attained. It's by removing things, it's not by adding things. And I think we can also apply it to programming languages, because we have similar things going on there. That most of our programming languages tend to want to add things, but I think most of them could be improved by removing things. And that's where the principle of the good parts comes from. That if a feature is sometimes useful and sometimes dangerous, and if there is a better option, always use the better option.
And it surprises me that this is a controversial statement. Now there are lots of people out there who say, I don't want to use the better option. You can't make me use the better option. It's like, being better should be enough, you know, but it's not. And I think that comes from a fundamental misunderstanding about what it is that we do. We are not paid to use every feature of the language. At the end of a project, there is never a manager with a clipboard saying, did you use a With statement? Did you leave out any semicolons? Did you use comma as an operator? Excellent.
Nobody's doing that. We are paid to write programs that work well and are free of error. That's what it's all about. Now, free of error, where did that come from? Well it turns out, free of error has always been the first requirement. It's just, we so rarely attain it, it's easy to forget that it's the most important thing. - [Student] It's why I've never gotten paid, I guess. - So a good programming language should teach you. I recommend everybody learn as many languages as you can.
It had functions with first class values with lexical closure, which I had no idea that it was in there. Brendan put it in there intentionally. That's not something that gets into a language by accident, but he didn't tell anybody. And so I discovered it in reading the standard, and it was like wow, this changes everything. And at that point, my relationship with the language changed. And at that point, it was able to finally start teaching me things. And it has taught me a lot.
And JSLint has taught me an enormous amount about programming.
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