Skip to content

Instantly share code, notes, and snippets.

@jasonknight
Created November 3, 2019 22:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasonknight/1604017cdd6282fa4c7423979d0221e4 to your computer and use it in GitHub Desktop.
Save jasonknight/1604017cdd6282fa4c7423979d0221e4 to your computer and use it in GitHub Desktop.
0_Introduction.md
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>0_Introduction.md</title>
<link rel="stylesheet" href="https://stackedit.io/style.css" />
</head>
<body class="stackedit">
<div class="stackedit__html"><h1 id="php-in-13-lessons">PHP in 13 Lessons</h1>
<p>If you ask anyone how best to practice the guitar, they’ll tell you to pick your favorite song and strum. Or they’ll remind you of the importance of learning and practicing chords and scales, both in songs, and just as a general daily practice.</p>
<p>In fact, practice and repetition are the core of learning anything, not just guitar, but Martial Arts.</p>
<blockquote>
<p>I don’t fear the man who has practiced 10,000 kicks. I fear the man who practiced one kick, 10,000 times.<br>
<strong>Bruce Lee</strong></p>
</blockquote>
<p>Even <strong>Mozart</strong> practiced, he once said:</p>
<blockquote>
<p>There is scarecely a famous master in music whose works I have not frequently and diligently studied.</p>
</blockquote>
<p><strong>Leonardo da Vinci</strong> once said that “Science is the captain, and practice the soldiers.” And <strong>Lebron James</strong> said, “I practice pretty much every shot that I take in a game.”</p>
<p>I once read in a book (GM Ram as I recall) that to make it to a 1,200 rating in chess, you would have to memorize at least one grand-master level game in its entirety. <strong>Magnus Carlson</strong> is said to have memorized no less than 10,000 chess games, many including his own, and on many occasions he has been tested on this fact and answered convincingly.</p>
<p>The one skill that we never seem to apply this too is programming. We expect the Basketball champion to get up at 3 am and shoot 500 shots before breakfast. We expect the Martial Arts to repeat forms and katas ad infinitum, even though the full explanations of a particular form application may not be explained until black belt.</p>
<p>Guitarists repeat strumming patterns over and over on the same chords, or they practice the subtle shifts between chord changes in the most common progressions.</p>
<p>But not programming.</p>
<p>When we teach programming, we give students an impossible direction, we tell them to learn by doing. But we never think about what that really means. You cannot do programming until you learn programming. When we give them the direction to learn by doing, we are asking them to learn by creating.</p>
<p>This course is not going to be that way. I don’t expect you to be able to create coherent programs on the fly. I am going to take you through a tour of programmings greatest hits. It is essential that when we practice, we practice correctly. That is why the musician learns popular songs, because popular songs are by definition the “correct answer.”</p>
<p><strong>Michael Jordan</strong> once said that it didn’t matter if you practiced 8 hours a day, if you practiced wrong. The most important thing for any skilled person is a solid foundation of correct answers.</p>
<p>This course is organized around the concept of Mastery, it doesn’t matter how long it takes you, there is no time restriction. It might take you 13 hours, 13 days, or 13 months to learn this material. The only thing I guarantee is that if you want to be a professional programmer, you have to know what I’m about to teach you 100%.</p>
<h2 id="preliminary-information">Preliminary Information</h2>
<blockquote>
<p>The prupose of all programs, and all parts of those programs, is to transform data from one form to another.<br>
<strong>Mike Acton</strong></p>
</blockquote>
<p>The ultimate goal of all programs is not the program itself, it is the result of the program. Its correctness.</p>
<p>Our field is poorly named, programmer or coder, but a carpenter is not a hammer-er. Programming is the tool, one of many, that we use to get results.</p>
<h3 id="the-4-levels">The 4 Levels</h3>
<p>Now there are, to my mind, 4 levels of programming.</p>
<ol>
<li>To make a program that has a correct results.</li>
<li>1, and to make a program that can be managed by power users.</li>
<li>1,2 and to make a program that is easy to extend and develop by other programmers.</li>
<li>1,2,3 and to make a program extensible without someone having to edit or recompile the code.</li>
</ol>
<h3 id="the-8-fold-path">The 8 fold path</h3>
<p>To achieve the 4 levels of programming you have to learn the 8 fold path. To learn and use any programming language effectively you must:</p>
<ol>
<li>Know how to combine primitive expressions and statements, and to name them.</li>
<li>Know how to define functions.</li>
<li>Know how to handle arrays.</li>
<li>Know how to handle structs and objects.</li>
<li>Know how to handle input and output, especially files.</li>
<li>Know how to work with strings.</li>
<li>Know how to include code, or execute foreign code.</li>
<li>Know how to represent basic data structures.</li>
</ol>
<h3 id="the-5-gems">The 5 gems</h3>
<p>In order to truly master the 8 fold path, especially point 3, you will need to know the 5 gems of programming, these are features and functions so common and frequently used they have names.</p>
<ol>
<li>Map</li>
<li>Filter</li>
<li>Fold</li>
<li>Sort</li>
<li>Iterate</li>
</ol>
<p>Most languages will provide you with builtin versions of these functions.</p>
<h2 id="the-zen-of-programming">The Zen of Programming</h2>
<p>There are 13 general principles of programming that I have defined, these principles are inspired by many things. See: <a href="https://www.python.org/dev/peps/pep-0020/">The Zen of Python</a>, <a href="https://www.joelonsoftware.com/2009/09/23/the-duct-tape-programmer/">The Duct Tape Programmer</a>, <a href="http://dreamsongs.com/RiseOfWorseIsBetter.html">Worse is Better</a></p>
<p>These 13 principles elucidate the overarching philosophy of programming, and what should be in your mind with you think about code.</p>
<ol>
<li>In the beginning we want results, until we realize we need control.</li>
<li>Speed is more important than anything else. Time is battery, time to market, time to completion.</li>
<li>It is better to ship 80% today than 100% never.</li>
<li>Beautiful code is its own reward.</li>
<li>Simplicity is better than complexity.</li>
<li>But complexity is better than complication.</li>
<li>Be explicit and code down the center of a language.</li>
<li>Right now is better than never, though never is better than soon.</li>
<li>If you cannot explain it to a junior programmer, it’s a bad idea.</li>
<li>What is practical is better than what is ideal.</li>
<li>Readability is good, but the illiterate will never read it.</li>
<li>Typing less is not the point, be wary of terse languages and snippets.</li>
<li>Only write as much code as you need, and not a single line more.</li>
</ol>
<h2 id="programming-paradigms">Programming Paradigms</h2>
<p>Programming Paradigms, like <strong>Object Oriented Programming</strong> and <strong>Functional Programming</strong> are big ideas, and they are worth learning. But they are not really language bound. While many languages will provide you with syntactic sugar to help you with one style or the other, the purpose of this course is not to further any specific doctrine.</p>
<p>Just because you use functions does not mean you are doing <strong>Functional Programming</strong> and just because you use classes and objects does not mean you are doing <strong>Object Oriented Programming</strong>.</p>
<p>What you will learn in this course can be equally applied to any paradigm, even <strong>Imperative</strong> or <strong>Procedural</strong>.</p>
<p>Nevertheless, if you want to know which way I lean, then it would be more towards the <strong>Procedural</strong> and <strong>Functional</strong> paradigms. I am in no way a fan of <strong>Object Oriented Programming</strong>. With that being said I’ll make every effort to keep my bias in check.</p>
<p>The reason I won’t be explicitly teaching you these paradigms is that they are largely theoretical, they are less about any specific techniques or linguistic features, and more about the design and organization of large programming projects. This course is not about projects, it’s about foundational skills with code. The level of code we will be dealing with is far too small to introduce big ideas like a paradigm into.</p>
<h2 id="a-catch-22">A catch-22</h2>
<p>Many programming courses try to break code down into little tiny chunks and organize lessons based on what the create thinks is the “easiest” to understand. I don’t agree with that method, because it quickly devolves into a disconnected understanding of things.</p>
<p>Also, I do not agree that any concept is universally easier or harder for all people in general. We often learn slowly on things we’ve been told are hard, and quickly on things we’ve been told are easy, and it has nothing to do with any reality other than subjective bias that has been injected into our minds.</p>
<p>What I will be doing is introducing you to shapes and patterns, and sometimes I will ask you to just trust me that the pattern is correct, and not focus too much on things that don’t concern the topic at hand.</p>
<p>Nothing that I am going to teach you is difficult, but that your mind makes it so.</p>
<p>When Luke Skywalker was asked by Yoda to lift his X-Wing out of the swamp, he said it was impossible, it was too big.</p>
<blockquote>
<p><strong>Luke</strong>: Oh, no! We’ll never get it out now!<br>
<strong>Yoda</strong>: So certain, are you? Always with you, what cannot be done. Hear you nothing that I say?<br>
<strong>Luke</strong>: Master, moving stones around is one thing, but this is… totally different!<br>
<strong>Yoda</strong>: No! <em>No</em> different! Only different in your mind. You must <em>unlearn</em> what you have learned.<br>
<strong>Luke</strong>: All right, I’ll give it a try.<br>
<strong>Yoda</strong>: No! Try not. Do… or do not. There is no try.<br>
<strong>Luke</strong>: I can’t. It’s too big.<br>
<strong>Yoda</strong>: Size matters not. Look at me. Judge me by my size, do you? Hmm? Hmm. And well you should not. For my ally is the Force, and a<br>
powerful ally it is. […]<br>
<strong>Luke</strong>: You want the impossible. <em>[sees Yoda use the Force to levitate the X-wing out of the bog and gets flustered when he does<br>
it]</em> I don’t… I don’t believe it!<br>
<strong>Yoda</strong>: That is why you fail.</p>
</blockquote>
<p>I am going to make a suggestion to you. You have no idea what complexity is, or what is more or less complicated. Everything that I am about to show you is not only easy, it is basic. These things are the basic understandings that you will have to employ daily as a programmer. Every programmer already knows them.</p>
<p>You can learn them, easily, if you focus your mind, if you practice, if you repeat the code over and over again and then think about each line.</p>
<p>The code I will be showing you is perfect, not a single line is wasted, everything is intentional, and in every line there is a lesson, a fact, a truth to be discovered.</p>
<p>I do not say this code is perfect because I wrote it. 99% of the code I will be teaching you was figured out by someone else long before either of us were even born.</p>
<p>This is code from the masters, algorithms, solutions, and examples that have taught generations of programmers.</p>
<p>Now I say that this code is easy and basic, but I don’t define what those words really mean. They are relative terms. Easy as compared to what?</p>
<p>Easy as compared to the problems you will be required to face every day as a programmer. Learning these 13 lessons is only the beginning of your career. It will be as easy as you make it.</p>
<p>Now many courses try to teach you programming in a bad order because they don’t want to scare you away. This is why most courses produce not simply bad programmers, but programmers who never actually become programmers.</p>
<p>The reality of programming is that you always start from a place of complete confusion and the unknown.</p>
<p>Every time I get hired on a project, the first time I look at the source code I wonder “what the hell was this guy thinking?”</p>
<p>I start in confusion, but I persist until I understand. That is what you have to learn. The code doesn’t really matter, it’s just a tool. Your comprehension of some discreet piece of code is irrelevant.</p>
<p>After hundreds of hours of teaching people programming face to face I realized that every time they said they understood some concept, what they were really saying is: “Confusion makes me feel bad, I don’t want to be confused, so I’m going to say I understand so we can move on and I won’t have to feel like this.”</p>
<p>I’ve watched so many students complete entire bootcamp courses and yet not actually know anything about programming, and they aren’t able to spontaneously program even the most trivial solution. Many of them can’t even get the syntax of primitive operations right, after spending 10 or 20 weeks in a program that spoon fed them digestable chunks.</p>
<p>I expect you to spend hours on small bits of code trying to understand them. If it takes you less time, great, but trust me there are plenty of things in this course that you will be reading, and re-reading, and puzzling about for days.</p>
<p>To give you an idea it took me a week of reading, searching, and playing around just to understand what a monad is. I read the same explanation 11 times (it was over 3,000 words). I read and re-read dozens of articles. I had to play around with code in 3 different programming languages.</p>
<p>Welcome to #DevLife.</p>
<p>Just accept that you aren’t going to understand any of this the first 2-3 times you read it. And also accept that you won’t fully understand everything I’m about to teach you for the next 10 years.</p>
<p>Paul Graham wrote an interesting essay on <strong>Schlep Blindness</strong>. A schlep is something that is painful and tedious to do. Learning to program is a schlep, that’s why so few people do it, and why of the people who do do it, most of them are largely incompetent. Humans don’t simply shy away from pain, we pretend it doesn’t exist, or wouldn’t work, all in an effort to avoid doing the painful work that success demands.</p>
<p>All the work and effort that has gone into programming tutorials and courses that try to make it easy and painless only make it pointless. Edith Hamilton created what I consider the best translation of one of the most poignant quotes in history. It was this version of Aeschylus that Robert Kennedy read aloud at the death of Martin Luther King jr. And it is this version that applies to everything in life.</p>
<blockquote>
<p><strong>He who learns must suffer</strong>. And even in our sleep pain that cannot forget falls drop by drop upon the heart, and in our own despair, against our will, comes wisdom by the awful grace of God.<br>
<strong>Agamemnon</strong></p>
</blockquote>
<p>No one will ever pay you to do something that is easy. What they pay you to do is something that is hard, and painful. Many people would love to play in the NFL, but very few people ever bother to go through the pain of learning to run fast enough, or hit hard enough.</p>
<p>If you want to make a 6 figure income, you bet your sweet patootie that you will pain in pain for every dollar you earn. The more you learn to cope with the pain and confusion and irritation that programming represents, the more you’re going to prepare yourself to run digital touchdowns.</p>
<blockquote>
<p>If you play good, they pay good.<br>
<strong>Deion Sanders</strong></p>
</blockquote>
<p>See:</p>
<ul>
<li><a href="https://norvig.com/21-days.html">Teach yourself programming in 10 years</a>,</li>
<li><a href="http://www.paulgraham.com/avg.html">Beating the Averages</a>,</li>
<li><a href="http://dreamsongs.com/RiseOfWorseIsBetter.html">Worse is Better</a>,</li>
<li><a href="http://doc.cat-v.org/bell_labs/pikestyle">Notes on programming in C </a>,</li>
<li><a href="http://www.paulgraham.com/schlep.html">Schlep Blindness</a></li>
</ul>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment