Detailed
Compact
Art
Reverse
December 10, 2018
This design pattern will help you make sense of your game design as it gets bigger. You can listen to episodes 77, 86, 87, and 88 for more information and background. This episode will start tying things together. I didn’t originally describe this because it really is a merging of many patterns. But as I started coding this myself, I’ve realized that there’s more to it than just sticking a few design patterns together. Enough that you can benefit from a description. Here’s the big picture. Your game will likely have many characters and objects in it. The characters can be directly controlled by one or more players or be controlled by the game as either direct opponents or just background characters. And the objects can be almost anything that your character interacts with. This could be a weapon, or an apple, or a door or table. All of these characters and objects share certain abilities and behaviors. That’s normally a good sign to use inheritance in your design. But if you go that way, you’ll find that inheritance leads to large and complicated hierarchies of classes that are difficult to change. Listen to the full episode to learn more about how the patterns work together to keep your game design understandable as it gets bigger. Or, you can read the transcript below. Transcript This is something I’ve been working on for the last three months in the game development sessions. You can listen to episodes 86, 87, and 88 for more information and background. This episode will start tying things together. And if you’d like to participate in these game development sessions, you can really learn a lot more than what I can describe here. Listen to episode 248 for a full description of a special offer now through the middle of January. And in that episode, you’ll also hear about a specific example of a template design that I was working on. The best way to participate in the game development sessions is to become a patron. You can get extra podcast episodes, videos, and free game development sessions. Okay, on to the topic for today. This brings together several design patterns. I didn’t originally describe this because it really is a merging of many patterns. But as I started coding this myself, I’ve realized that there’s more to it than just sticking a few design patterns together. Enough that you can benefit from a description. You can also listen to episode 77 about the observer pattern. That forms a big part of this as well. Here’s the big picture. Your game will likely have many characters and objects in it. The characters can be directly controlled by one or more players or be controlled by the game as either direct opponents or just background characters. And the objects can be almost anything that your character interacts with. This could be a weapon, or an apple, or a door or table. All of these characters and objects share certain abilities and behaviors. That’s normally a good sign to use inheritance in your design. But if you go that way, you’ll find that inheritance leads to large and complicated hierarchies of classes that are difficult to change. And I mean they’re difficult to change both at design time and at run time. You might want to change something about how an object looks or behaves and doing so affects other things in the game because they all inherit from the same base classes. This causes problems and increases the work and time needed to write your code. And it also causes problems when you want something in your game to change how it works during the game. Maybe you want the character to be able to move through walls like a ghost for a short while and then go back to being solid. You’ll have a really hard time designing such a game if you’ve relied too much on inheritance. Episode 86 describes the Component design pattern which can be used to attach behavior to characters and game objects by havin
November 25, 2018
There’s some special floating point values that you should be aware of. Zero, infinity, and not a number are three cases that might surprise you. Let’s get started. First of all, do you know the sign of zero? Is it positive or negative? Depending on your country and traditions, zero might either have no sign or be both positive and negative. I think it’s standard for most places that zero has no sign at all. It can be important when a value approaches zero to consider what direction it’s approaching from. In other words, is a value shrinking from a positive value towards zero? Or is it increasing from a negative value towards zero? Once a value reaches zero, then it loses it’s sign. Or it gains both signs if you prefer. The main point is that zero behaves slightly differently than all other values. This difference is most important when dividing. Listen to the full episode for more information about how dividing by a floating point 0.0 is very different than dividing by an integer 0 value. Floating point division can lead to infinity while integer division can lead to almost anything. And from there, it’s not too hard to get into “not a number” values. Or you can read the full transcript below. Transcript Because you’ll be likely to use a lot of floating point numbers when building a game, this episode will explain some special values. Zero, infinity, and not a number are three cases you should be aware of. You probably already know about zero and infinity, but even these might surprise you. And not a numbers which are usually referred to as NaNs are even more peculiar. Let’s get started. First of all, do you know the sign of zero? Is it positive or negative? Depending on your country and traditions, zero might either have no sign or be both positive and negative. I think it’s standard for most places that zero has no sign at all. It can be important when a value approaches zero to consider what direction it’s approaching from. In other words, is a value shrinking from a positive value towards zero? Or is it increasing from a negative value towards zero? Once a value reaches zero, then it loses it’s sign. Or it gains both signs if you prefer. The main point is that zero behaves slightly differently than all other values. This is most important when dividing. If you ever try to divide by zero, you get, well, you don’t really get anything. This is just not allowed. I remember a proof once when I was in high school that showed through a series of steps that 1 was equal to 2. It was obviously wrong. But why? Every algebra step along the way looked correct. But hidden in one of the steps was a divide by zero. This broke the entire proof and led to a bad result. In programming, dividing by zero using integer arithmetic is undefined. I wrote a small program for this episode to see what the result would be. I just printed the output of dividing 1 by 0. The first thing I noticed was a compiler warning that said this operation was undefined. The compiler was able to tell this because I was using the literal values 1 and 0 directly. It’s more likely in your programs that the values you’ll be dividing won’t be known until runtime. They’ll be variables. The compiler can’t warn you for things like this. Anyway, it was a warning and the program compiled. So I ran it. And it said that 1 divided by 0 was 73,896. Once you get into undefined behavior in your program, the results could be anything. Your program could crash or give you wild results that don’t make any sense. Dividing by zero is something you always need to be careful to avoid. But that’s for integer numbers. Those are whole numbers. What about dividing by zero with floating point numbers? This turns out to have a definite answer. And it depends on whether the zero is positive or negative. That’s right, in floating point format, the number zero can be
November 19, 2018
Looking for more advanced training to help you better understand how to actually build something in C++? Want to go beyond example snippets that don’t really teach you anything? How about being able to ask questions or get feedback on a suggestion? You can get all these things by attending a live game development session. This is where you get to watch and participate as I work on building a game. This is real code and unscripted. And now through the middle of January 2019, you can get a free game development session bonus when you sign up to be a patron of Take Up Code. This bonus is normally only for those patrons who choose the $10 per month game development session tier. You can get a free game development session bonus when you sign up to be a patron at any tier, now through the middle of January 2019. Just $1 a month is enough to become a patron. And for that $1, you also get access to a special podcast just for patrons. There’s already a whole series that you can listen to that will explain databases, how to use them, what they are, the differences between SQL and NoSQL databases, and even my number one suggestion for avoiding security attacks in your data. What can you learn in a game development session? Well, for one, the project I’m working on is starting to get big. Not as big as what you might find working in a large software company like Microsoft. But definitely big for what one person can create over several years. You can see and learn for yourself how to manage a large project. But more than that, you get to understand all the work that goes into the project even between commits. I try to commit regularly but even that leaves out all the small things that I try and then change my mind about. This is super important for you to understand because it’s how software actually gets written. When you read a book or watch a tutorial online, you’re getting an edited account that makes it look like the developer knew exactly how to proceed and just started writing the final code. Sure, sometimes it does work out like that. But not often. And this can leave you feeling lost and confused and maybe even thinking that you’re no good at writing code because your own attempts don’t turn out anything like what you read or watch. For a specific example, I was recently working on a hashing class. You can create a hash of different lengths. I mean a different number of bits. But the hash algorithm I was implementing only works with a couple fixed sizes. You can listen to the full episode or read the transcript below as I describe in about two minutes what actually took me several hours to create. All you have to do is visit takeupcode.com and click the Patron link at the top to get started. This will take you to a site called Patreon that I use to manage and coordinate patron registration and bonuses. While you’re there, check out some of the other creators that I support. It’s a great way to help creators such as myself and get valuable rewards at the same time for yourself. Transcript You can get all these things by attending a live game development session. This is where you get to watch and participate as I work on building a game. This is real code and unscripted. And now through the middle of January 2019, you can get a free game development session bonus when you sign up to be a patron of Take Up Code. This bonus is normally only for those patrons who choose the $10 per month game development session tier. You can get a free game development session bonus when you sign up to be a patron at any tier, now through the middle of January 2019. Just $1 a month is enough to become a patron. And for that $1, you also get access to a special podcast just for patrons. There’s already a whole series that you can listen to that will explain databases, how to use them, what they are, the differences between SQL and NoSQL databases, and even my number one suggestion for avoid
November 12, 2018
Be careful with floating point numbers when building games. You could be in for some big surprises if you don’t understand how computers work with fractional values. You might be able to write an app to keep track of your friend’s addresses without using any floating point numbers. But most games will need math that uses fractional values. That is if you want any kind of game with smooth motion. If your game consist of typing letters in words, then maybe you won’t have to worry about this. But if you want those letters to move slowly across the screen as the user drags them into place, then you’ll need to use fractional values. You might think that you can get away from this by just having really small whole numbers. Maybe you track individual pixels. The problem is that computers are really fast these days and can do a lot of work even between pixels. You might find that the computer tries to move the image by 1 thousandth of a pixel. If you only work with whole numbers, then this becomes zero. And your image will be stuck without moving at all because the computer is so fast that it’s always trying to move it by a tiny amount. Instead of limiting yourself to whole numbers, you’ll need to understand how to use fractional values. And that means you need to understand how to use floating point numbers. You should also listen to episode #112 about the float data type, or you can read the full transcript below. I try not to repeat information between episodes so you’ll find both this episode and the earlier one have something for you. Transcript You could be in for some big surprises if you don’t understand how computers work with fractional values. You might be able to write an app to keep track of your friend’s addresses without using any floating point numbers. But most games will need math that uses fractional values. That is if you want any kind of game with smooth motion. If your game consist of typing letters in words, then maybe you won’t have to worry about this. But if you want those letters to move slowly across the screen as the user drags them into place, then you’ll need to use fractional values. You might think that you can get away from this by just having really small whole numbers. Maybe you track individual pixels. The problem is that computers are really fast these days and can do a lot of work even between pixels. You might find that the computer tries to move the image by 1 thousandth of a pixel. If you only work with whole numbers, then this becomes zero. And your image will be stuck without moving at all because the computer is so fast that it’s always trying to move it by a tiny amount. Instead of limiting yourself to whole numbers, you’ll need to understand how to use fractional values. And that means you need to understand how to use floating point numbers. They’re called floating point because the decimal point that separates the whole number portion from the fractional number portion can move around as needed. Actually, I completely made up that last part. It seems reasonable to me and this is how I’ve always thought of floating point numbers. But I really have no idea where the name comes from. So I don’t repeat earlier content, you’ll want to listen to episode #112 where I described the float data type. In this episode, I just wanted to bring the topic to your attention again. Especially, since I’m describing game development topics and some of the math you’ll need to use. Early computers were really good with adding, subtracting, multiplying, and dividing whole numbers. They still are. You can represent all the values 0 up through the maximum value without missing any numbers. I mean, it would be really bad if computers, say, had trouble with 8. To a computer, all the numbers are just a series of binary 1’s and 0’s. They can even represent negative numbers through something
October 29, 2018
Do you know the differences between points and vectors? You might be surprised. I learned a few things myself recently when I implemented points and vectors in the TUCUT library. Listen to episode 240 to learn more about TUCUT. As to which you should use, that’s sort of a trick question. You’ll most likely use whatever your game engine provides. Unless you’re writing your own library like I’m doing, the idea of a point and a vector are very basic concepts that would be provided for you. Any type of drawing needs to know where to do the drawing. Animations need to know which directions to move. Game items need to know where they exist in the world. Listen to the full episode to learn what you can do with points and vectors, how they can interact, and why many game engines provide only vectors. You can also read the full transcript below. Transcript You might be surprised. I learned a few things myself recently when I implemented points and vectors in the TUCUT library. Listen to episode 240 to learn more about TUCUT. As to which you should use, that’s sort of a trick question. You’ll most likely use whatever your game engine provides. Unless you’re writing your own library like I’m doing, the idea of a point and a vector are very basic concepts that would be provided for you. Any type of drawing needs to know where to do the drawing. Animations need to know which directions to move. Game items need to know where they exist in the world. And because game engines provide these features, they need a way for you to specify points and vectors. Traditionally, points have been mostly a geometry topic and vectors an algebra topic. I see them as very close concepts and the differences between them can sometimes be a matter of preference. One of the strange things I found in my research was the idea that points have no coordinates. They exist at some location and the reason they have no coordinates is because there could be multiple coordinates that end up in the same location. For example, if you have a sphere like earth and a point is some city. Then you can pick an origin and go to the city. But you can also keep going and come all the way around the sphere until you reach the same city again. Depending on how your points exist in the universe, they might have many different coordinates. Or maybe you have multiple origins or an origin that moves around. This would cause the coordinates to change. Think of it like this, if you live near the border of a city and the city border changes, then you might get a new mailing address. It’s not like your house suddenly changed its location. But the origin changed and now your address is relative to a different city or county. Or maybe you have different ways of measuring distance. It could be millimeters or inches. The same point will have different coordinates if you use different measurement systems. To me, these are not good reasons for saying that points have no coordinates. I’m okay with the idea that coordinates need to be matched with a specific origin and measurement system. If the origin changes, then the coordinates will change. And if there’s different ways to get to the same point, then to me that’s okay too. A vector is more flexible in this sense. Because vectors have no origin. Let’s take an example in a single dimension. Imagine a point at coordinate 8 and another point at 10. A vector will tell you how to get from 8 to 10. Just move two unit positions to the right. That’s all a vector is. Just a magnitude and a direction. In this example, the magnitude is 2 and the direction is towards the right. What if you want to go from point 5 to point 7? You get the same vector, two units to the right. Now, the points themselves are based on the origin. So you get to a point at position 5 by starting at the origin and moving five units to the right. This is where the differences between points and vectors
October 15, 2018
You don’t need a lot of math to program. What you do need is usually simple. But you do need some. Don’t worry, it’s not that hard and I’ll explain it so you can understand. Game development probably needs a bit more math than you might guess. Let’s start with a point. It’s a simple concept that really just represents a position. A point has no dimensions itself. In other words, it has no length, width, or height. It just exist at some location. It’s the location that has dimensions. If we’re talking about a point in a one dimensional world, then there’s only two directions, left or right. Or, depending on how you want to view the line, it could be up or down. Or, if you can imagine that you are inside the line itself looking down it’s length, then you really have forwards and backwards as the two directions you can go. Once you know the directions, you have to decide how far you want to travel. We normally think of a line divided into equal measures like a ruler. If you start out at position zero and move forward one unit, then you can say that you’re now at position one. Moving backward from there by two units will take you back to position negative one. Everything is relative. We think of a ruler as having a specific beginning at one end that we call zero. But if you were inside that line that extends forward and backward in infinite amounts, then where is zero? Well, it’s wherever you want, really. The main thing is to be consistent. Once you pick a spot that you consider to be zero, then stick with that. Everything else will be based on that point. Listen to the full episode to learn about 2D planes and 3D and even 4D spaces. You’ll also learn why the indices are drawn 90 degrees apart from each other and what this really means. Or you can read the full transcript below. Transcript But you do need some. Don’t worry, it’s not that hard and I’ll explain it so you can understand. Game development probably needs a bit more math than you might guess. There’s a lot of things that get thrown in a game, sure, that you need to calculate where or what it’ll hit. But there’s math involved in just drawing the game objects so they look good. Things such as cloth billowing in the wind or reflections in the gentle waves of a pool of water are details that are harder to get right. They’re also things we notice if they look wrong or fake. It’s always a struggle with programming to decide how detailed you need to be. More detail either means more data or more computations. Less detail means flat surfaces that should be curved, or trees that all tend to move in the same direction at the same time, or just skipping things completely like deciding to not bother with shadows. There’s lots of tricks and shortcuts that have been developed over the years. And then there’s that fact that computers have gotten faster so games can consider it possible to include details that would have been impossible years ago. It’s harder to do these calculation in a game than it is in a motion picture. A game has a game loop that’s very sensitive to timing. A movie can take all the time you need to draw each image. It might take years to record and edit a major motion picture. But it takes you exactly 1 minute to play a game for 1 minute. And in that 1 minute of game time are 60 seconds that need 60 frames in order to look good. That’s 3600 frames that need to be drawn in 1 minute. Then there are games that simplify things on purpose. I mean, if the whole world is made out of squares, then it really simplifies a lot of calculations. I’ve always said that if you can’t get something perfect, then people will notice. Unless you make it so obviously imperfect that you can say you did it that way on purpose. Okay, I’m getting a bit off topic here. I wanted to explain some math terms today that wi
October 2, 2018
I just got back from CppCon 2018 in Bellevue Washington. And since this is a podcast where I teach you how to program, I thought I’d share something that I learned at the conference. It was a great conference with full days that went from 8 in the morning to usually 10:30 at night for five straight days. And then there were classes before and after the conference. There were so many choices for presentations to attend that it was tough to choose. It was packed with people. I think there were over 1,200 people attending. But at the same time, it was as smooth as you can imagine. The organizers deserve amazing credits. Even with all the people, I never had trouble finding a good spot. Sometimes I would sit up front. And sometimes I would sit at a table in the back of the room. One of my favorite talks was from Nicolai Josuttis. This is something that I’ve been aware of since I first started programming C++. There’s a lot of different ways to declare a variable and initialize that variable so it has a value. This explanation really needs text for you to be able to see the actual code. So I won’t be able to describe everything from the presentation. I’ll stick to the big ideas. In a couple weeks, more or less, you should be able to watch the full presentation on YouTube. It’s called “The Nightmare of Initialization in C++”. Probably the main thing to understand is that in C++ if you have a method that declares an int variable and gives that variable a name, then the value of that variable is undefined until you write a value first. If you just declare a variable and read from it without first providing a value, then you’re in undefined behavior. The value could be anything. The rules are changing all the time. Some of the things I learned from this talk were about how things change in C++17 vs. earlier versions of the language. You’ll also gain insight into some changes that might take effect in C++20. Listen to the full episode or read the full transcript below to learn more and make sure to watch the video once it’s published. Transcript And since this is a podcast where I teach you how to program, I thought I’d share something that I learned at the conference. It was a great conference with full days that went from 8 in the morning to usually 10:30 at night for five straight days. And then there were classes before and after the conference. There were so many choices for presentations to attend that it was tough to choose. Everything will be posted on YouTube later for you to watch. Which is good because unlike Hermione in Harry Potter, I didn’t have a time turner so that I could attend multiple talks at the same time. It took me over an hour just to plan out which talks I wanted to attend. I don’t know how many talks there were in total but the conference sometimes had about eight different talks going at the same time in different rooms. It was packed with people. I think there were over 1,200 people attending. But at the same time, it was as smooth as you can imagine. The organizers deserve amazing credits. Even with all the people, I never had trouble finding a good spot. Sometimes I would sit up front. And sometimes I would sit at a table in the back of the room. The largest meeting room was big enough to hold everybody at once with extra seats to spare. And I didn’t need binoculars to see the presentation. There were multiple projection screens available to watch from any seat in any of the rooms. All in all, it was an amazing conference and I’m still processing the things I learned. Which brings me to the topic of this episode. This podcast is all about teaching you how to code. It’s not just news and it doesn’t focus on interviews. There actually hasn’t been a single interview yet on this podcast. Not that I’m against interviews. But my list of things that I want to explain to you doesn’t seem t
September 17, 2018
Installing Linux, GCC, GDB, Git, CMake, LLVM, Clang, Boost, SFML, CodeLite, Sublime Text 3, And Dropbox On a $140 Lenovo ideapad 120S makes an ultra portable C++ programming laptop. Listen to the audio podcast to hear my story about how and why I decided to buy an 11 inch Lenovo ideapad 120S. This is the show notes page and here you’ll find the detailed step-by-step instructions that I promised in the podcast. I spent over a week researching and documenting everything I did to get this computer ready so that you can follow along and learn from what I’ve discovered. Maybe some of the instructions could be made similar or simplified more. I tried to make them as simple as possible. Most of these instructions came from other websites, from questions and answers in online forums, and from the product web pages. There were too many sources to keep track of. Some gave conflicting or wrong instructions. And some might have worked by themselves but had trouble with other steps I was doing. Here, you’ll find a full listing of all the steps and commands that I found to work well. And they should all work well together on this computer. Please let me know if I missed anything or if anything needs further explanation. Ready? Okay. Follow along and install Linux and all the development tools you’ll need to get started programming. Remove Windows 10 and install Linux instead Go through initial Windows setup and use the installed updating tools to update the computer BIOS. Download Kubuntu from https://kubuntu.org Create bootable USB drive Download UNetbootin from http://unetbootin.github.io Run UNetbootin and select the downloaded Kubuntu and the USB drive and make it bootable. Insert USB drive, restart the Lenovo ideapad, and press Fn-F2 repeatedly while the computer starts up until the BIOS screen appears. Change the boot order so that the computer will try booting from the USB drive first. Save changes and continue restarting the computer. Wait for Kubuntu to start and choose the option to install. Answer the basic setup questions and for the page where it asks how to format and partition the drive, select the guided option that uses the full drive. Useful configuration changes Open the Konsole terminal. Protect root folder from accidental deletion alias rm=’rm -preserve-root’ Setup nano as the default editor export editor=nano Install basic build tools and libraries Open the Konsole terminal. Install basic development tools. Allow apt-get to find and install additional software packages. sudo nano /etc/apt/sources.list remove the leading “# ” from near the end where it says to uncomment the following lines to enable partner content. Just uncomment the deb line so it looks like this: deb http://archive.canonical.com/ubuntu bionic partner sudo apt-get update sudo apt-get install build-essential ccache Install CMake sudo apt-get install cmake cmake-gui Install Git sudo apt-get install git gitg Install glogg log file viewer sudo apt-get install glogg Install Boost sudo apt-get install libboost-all-dev This installs the Boost header files to: /usr/include/boost And the Boost libraries to: /usr/lib/x86_64-linux-gnu Install SFML Install prerequisites. SFML installs okay without these but from what I’ve been able to tell, it might not be fully functional without these. These were already installed for me. Installing them directly marked them as a manual install sudo apt-get install libpthread-stubs0-dev sudo apt-get install libgl1-mesa-dev sudo apt-get install libx11-dev sudo apt-get install libxrandr-dev sudo apt-get install libfreetype6-dev sudo apt-get install libglew1.5-dev sudo apt-get install libjpeg8-dev sudo apt-get install libsndfile1-dev sudo apt-get install libopenal-dev sudo apt-get install libsfml-dev This installs the SFML header files to: /usr/include/SFML And the SFML libraries to: /usr/lib/x86_64-linux-gnu Add mor
September 3, 2018
In the end, it’s you vs. you. Is this about living or dying? It seems that this is a common inspirational quote used a lot in fitness clubs and weight loss programs. But I first saw it on a t-shirt this weekend. I was at one of my favorite places to eat, Aria Kabab in Queens, New York. I told the person that the quote was very true and he asked me how I interpreted the quote. He had a different interpretation. And it was interesting enough that I left thinking that I was going to discuss it with you for this week’s episode. Now, you might also see variations of this quote that tell you to make sure that you’re the winner. To me, this is misleading and goes against the basic message. The only way to lose is when we forget the basic message and start comparing ourselves to others or start thinking about ourselves as a different person. My interpretation is that life is all about improving ourselves and helping others improve as well. And the only true way to measure our progress is to look back and see how much we’ve each improved. You can’t measure progress against somebody else’s current status or even against another person’s improvement. The only thing that matters is that you’re getting better each day. Even a little bit of a gradual improvement will result in big changes over time. My friend at Aria said that I was the first person to comment on his shirt and had a different meaning in mind. While I took the phrase, in the end, figuratively, he took it to mean exactly what it implied. He said that when we die, everything we did up to that point is what we have to rely on. There’s no asking for help from anybody. Not our parents. Not our friends. We have only ourselves and our preparation. Listen to the full episode to hear my comments on how these two interpretations work together and some advice on how to structure your goals so they have the most meaning. Or you can read the full transcript below. Transcript It seems that this is a common inspirational quote used a lot in fitness clubs and weight loss programs. But I first saw it on a t-shirt this weekend. I was at one of my favorite places to eat, Aria Kabab in Queens, New York. I told the person that the quote was very true and he asked me how I interpreted the quote. He had a different interpretation. And it was interesting enough that I left thinking that I was going to discuss it with you for this week’s episode. Now, you might also see variations of this quote that tell you to make sure that you’re the winner. To me, this is misleading and goes against the basic message. The only way to lose is when we forget the basic message and start comparing ourselves to others or start thinking about ourselves as a different person. My interpretation is that life is all about improving ourselves and helping others improve as well. And the only true way to measure our progress is to look back and see how much we’ve each improved. You can’t measure progress against somebody else’s current status or even against another person’s improvement. The only thing that matters is that you’re getting better each day. Even a little bit of a gradual improvement will result in big changes over time. My friend at Aria said that I was the first person to comment on his shirt and had a different meaning in mind. While I took the phrase, in the end, figuratively, he took it to mean exactly what it implied. He said that when we die, everything we did up to that point is what we have to rely on. There’s no asking for help from anybody. Not our parents. Not our friends. We have only ourselves and our preparation. As I got to thinking about this, I realized the two meanings fit together well. There’s no winner or loser here. What it means is that we each have to keep a bigger goal in mind. We need to improve and measure our improvement against ourselves and at the same time, we need to make
August 20, 2018
Some people say that raw pointers are evil and should be avoided. Raw pointers are useful when used properly. This episode explains how to use raw pointers along with smart pointers and is taken from a recent game development session. I have a text-based role-playing adventure game that I’m working on with a main hero in the game. I want the hero to be able to move around. It wouldn’t be very adventurous if the hero had to stay in the same spot. This means I need to keep track of the hero’s location. Because this is a simple game, the location just needs an x and y coordinate. I decided to add a class that would manage multiple groups of properties. Grouping them together seemed like a good idea so it’ll be easier to understand an x property and a y property if they appear in a group called location. Listen to the full episode to understand where and why I chose to use unique_ptr to manage ownership of the groups and property values as well as how I used raw pointers when retrieving groups and property values. Or you can read the full transcript below. Transcript Raw pointers are useful when used properly. Avoiding them entirely would be like a home improvement store deciding to stop selling hammers because too many people were hitting their thumbs. If you use raw pointers the wrong way, then you will get hurt. It takes a little bit extra thought and knowledge that I’ll explain here in order to use them safely. Some languages have decided to remove pointers and I always felt that programmers were the ones to suffer. Specifically, it makes certain designs more clumsy when you try to avoid pointers or when you have no pointers available at all in your language. I’ll also be using examples in this episode from a recent game development session. These are the kinds of real-world applications that I explore in the game development sessions. You can register to attend an upcoming session by going to takeupcode.com and clicking on the Classes link at the top of the page. Each session is reasonably priced and you’ll find them available almost every Saturday. Here’s the scenario that led me to describe how to use raw pointers. Software changes over time and I’ve been known to completely change designs in just a few hours if needed. So the design that I’m about to describe will almost certainly change. I have a text-based role-playing adventure game that I’m working on with a main hero in the game. I want the hero to be able to move around. It wouldn’t be very adventurous if the hero had to stay in the same spot. This means I need to keep track of the hero’s location. Because this is a simple game, the location just needs an x and y coordinate. I have a Character class to represent the hero. Now I could just put a couple integer properties in the class for the x and y coordinates. But I know that I want the game to be extensible. So I’ll eventually need a flexible way to add properties that I don’t know about yet. One good way to do this is to start now. In other words, don’t add fixed properties now and then later try to add dynamic properties later that can change. Anytime you find yourself with special cases where you treat one thing differently than another, you’re just adding extra complexity to your design. In other words, even a simple solution paired up with a more complex solution will overall be more complicated than if everything just used the more elaborate solution. Consistency goes a long way to making something easy to understand and use. So I decided to add a class that would manage multiple groups of properties. Grouping them together seemed like a good idea so it’ll be easier to understand an x property and a y property if they appear in a group called location. Maybe there can be another group called health that will be used when I add the ability to fight monsters in the game. You should also notice that the d
August 6, 2018
You can join an actual game development session almost every Saturday. This schedule might change in the future. But until then, you can find me working on a video game almost every Saturday. I’ve brought together a lot of code that I’ve written over the past five years into a single library that I use in the game development sessions. There’s a lot in it with eight major components so far. Testing library. This lets you think about how you intend to use your code before you write it and then make sure it does what you expect. Logging library that lets you easily write information to a file as your application runs. Google’s Protocol Buffers lets you send and receive messages between different parts of your application. File library to manage reading and writing files. Configuration library that lets you store structured information in a text file. Event publishing and subscribing library that lets you define exactly what information you’ll send whenever something important happens in your application. Extension library is where new things can be added to your app or maybe existing things can be changed. Curses library lets you write text-based applications and helps hide some of the more difficult aspect of curses. You can read the full transcript of this episode below. Transcript This schedule might change in the future. But until then, you can find me working on a video game almost every Saturday. I actually write code a lot more than just Saturdays. The problem is that I never know in advance when that will be. For me, programming is relaxing. It’s what I do. I enjoy it and have been programming ever since about 1991. Before then, I was mainly into electronics. It wasn’t until 1991 when I needed to find a job quickly that I switched careers and started programming. At that time, I knew a little programming already but was still completely unprepared for what it was like to work on a large project. Or at least it seemed large to me then. It really wasn’t a very big project. There’s so many features that software is expected to have these days that even a small utility application to help you keep track of phone numbers would probably be bigger. Imagine for a moment that if I was unprepared over twenty five years ago, what it must be like today. I’ve yet to find any book or online tutorial that can prepare you. I’ve found that a lot of people even after reading some books and watching online videos for a week or more still have no idea where to begin. Are you in this situation? Do you have an idea for an application and no idea how to start? Or maybe you feel frustrated because there’s so much to do? What should you focus on first? One good thing about all the progress we’ve made over the last few decades is that our tools and libraries have also gotten better. Sure, they can seem complicated too. But we don’t have to write as much software as we used to. We can reuse code in libraries. I’ve brought together a lot of code that I’ve written over the past five years into a single library that I use in the game development sessions. There’s a lot in it with eight major components so far. • First is a testing library. This lets you think about how you intend to use your code before you write it and then make sure it does what you expect. It’s a single header file that you include and then you write what appear to be methods that use your code and then verify the results. It runs all your tests and prints out an organized summary of everything that passed and failed. You can group tests together and choose to run some or all of your tests each time. All of this fits in about 750 lines of code. • Next is a logging library that lets you easily write information to a file as your application runs. You can use this to keep track of what’s happening so that you know where to look for bugs. Many times, a log file will le
July 23, 2018
There’s a lot you can learn about programming. But do you need to know it all? I’ve been reading a lot about the Pareto principle. You’ve probably heard it as the 80/20 rule. It says that you get 80% of your results from just 20% of your effort. And it goes beyond that. It applies to anything with positive reinforcement. That’s where you get rewarded for doing well which causes you to do even better which results in an even bigger reward and it just keeps going. If we try to improve our skills evenly, then this rule applies and says that most of our efforts will result in small improvements overall. Those are the kinds of things you can focus on later. Spending more time learning the most critical skills in programming will lead to the most benefit. I think it’s a great way to start. Listen to this episode or read the full transcript below for advice on how this applies to you as you learn how to code. I recommend that you listen to some of the previous episodes that will help you the most. Transcript I’ve been reading a lot about the Pareto principle. You’ve probably heard it as the 80/20 rule. It says that you get 80% of your results from just 20% of your effort. And it goes beyond that. It applies to anything with positive reinforcement. That’s where you get rewarded for doing well which causes you to do even better which results in an even bigger reward and it just keeps going. If we try to improve our skills evenly, then this rule applies and says that most of our efforts will result in small improvements overall. Those are the kinds of things you can focus on later. Spending more time learning the most critical skills in programming will lead to the most benefit. I think it’s a great way to start. Now, it may not be exactly 80/20. That’s not really what this is all about. Don’t get too caught up in the numbers. There’s three main points to understand. • The first, I’ve already mentioned. This applies to anything with positive reinforcement. If you’re learning a new skill and seeing that you can write software that keeps getting better, that’s positive reinforcement. • The second is that 80/20 is just a guideline. Sometimes, it can be 70/30 or sometimes 95/5. • And the third is something I’ve only recently become aware of after reading the book 80/20 Sales and Marketing by Perry Marshall. In this book, the author describes how the 80/20 rule applies to itself. And to itself again and again as long as you have the numbers to support it. So if you get 80% of your results from just 20% of your effort, then you get 64% of your results from just 4% of your effort. That’s the 80/20 rule applied to itself. What’s this have to do with you? Well, if you’re learning how to program in school, chances are very high that you’ll be learning a little bit of everything. If you’re learning on your own, you might have already figured this out but probably struggle picking through all the topics and deciding how important each one is right now. And if you’re attending a bootcamp, then you’re getting swamped with a lot of information in a short time about a few topics. This podcast has always been focused on short topics with examples you can relate to. But I probably could do a lot better about helping you to pick out just the important things. Even if it just means that I call out what are the most important ideas in each episode. What do you think about this? I’d love to get your feedback and ideas. You can visit takeupcode.com and leave a comment at the bottom of episode 239. Just click on the menu at the top that says Podcast and then find episode 239. All the episodes have a comment form at the bottom where you can leave your thoughts and suggestions. You can even use your mobile phone to visit and leave a comment. This podcast is also different than a lot of podcasts out there. Each episode b
July 9, 2018
This is a real example of how the filesystem can be used to take over a WordPress website. It’s a really bad vulnerability. And it uses the filesystem! This is why I’ve been spending the last 16 episodes on this topic. If this doesn’t get you to sit up and take notice then I don’t know what will. Learning how to use the filesystem properly is absolutely critical for a programmer. What happened? What was wrong with WordPress that enabled such a bad vulnerability? Listen to the full episode to learn more or read the full transcript below. Transcript There was a recently discovered security vulnerability in WordPress that I want to explain in this episode. When you’re trying to figure out how severe a vulnerability is, there’s a few things to consider. • #1 How likely is the vulnerability to appear? If it only happens in some rarely used extension, then it probably won’t affect very many people. This example comes straight from core. That means it exists in the main parts of WordPress itself and affects every single WordPress website in the world. That’s about as severe as you can get. The only way to get more severe would be for the vulnerability to exist in the core of the operating system itself. But then it wouldn’t be a WordPress vulnerability. • #2 How difficult is it to exploit? If an attacker has to write code and even then there’s only a small chance to hit the vulnerability, then maybe it’s not so bad. In this case, it turns out to be very easy to exploit. Just a few clicks and uploading a simple video file is all it takes. Because it’s so simple, the severity of the vulnerability just went up again. And it was already high to begin with. • #3 What benefit does an attacker gain by exploiting the vulnerability? Something as simple as a denial of service attack is not as severe. Don’t get me wrong. Even a denial of service attack is bad. But it’s not as bad as an elevation of privilege attack. That’s where an attacker can use the vulnerability to gain more permissions and do things not normally allowed. At a similar level is information tampering where an attacker can change data and cause false or misleading information to appear. And one of the worst is information disclosure. This is the type of vulnerability you hear about in the news whenever a big retailer says that their systems were hacked and customer information was stolen. That’s really, really bad. In this particular case, we’re talking about an elevation of privilege attack. Okay, so this particular vulnerability exists in all WordPress sites, is easy to exploit, and results in an attacker being able to raise their privileges so high that they can just take over your site completely and leave the owner standing in the cold. It’s a really bad vulnerability. And it uses the filesystem! This is why I’ve been spending the last 16 episodes on this topic. If this doesn’t get you to sit up and take notice then I don’t know what will. Learning how to use the filesystem properly is absolutely critical for a programmer. What happened? What was wrong with WordPress that enabled such a bad vulnerability? It starts out with a perfectly reasonable feature in WordPress. You see, WordPress allows multiple roles and one of those roles is an editor. The job of an editor is to create content on a website and change pages when needed. Some of these changes involve images and videos which are referred to in WordPress as media. Now media files can have a thumbnail image. That’s an image that gets displayed, for example, in the spot where a video will be played. The thumbnail gets displayed before the video starts playing. This way, you can control what will appear on the page even before a visitor presses the play button. WordPress also allows editors to delete media files. Again, this is a perfectly valid feature. You don’t want to leave unuse
June 25, 2018
Avoid being predictable. This advice applies to almost everything you do as a programmer. This episode will focus on the filesystem and how being predictable can make it much easier for an attacker to gain control. We use files to store information and configuration. And we also use files to communicate. Especially between companies or departments within a company. Maybe you’re writing an application that needs to wait on some information that will be sent to you when it’s ready. It’s a lot of information so you agree with the other team that they can just write it all to a file and send it to you when it’s ready. Your application just needs to wait for the file to appear, open it, and start reading. The only question is where should the file be placed and what should it be named. This is where the problem of predictability comes in. Listen to the full episode for examples of how you can solve the predictability problem. You’ll learn why simple solutions are not enough and how you can use an HMAC or hashed message authentication code to help. You can also read the full transcript below. Transcript This advice applies to almost everything you do as a programmer. This episode will focus on the filesystem and how being predictable can make it much easier for an attacker to gain control. I remember once when living in Washington, the city was doing roadwork and they removed the center turn lane and replaced it with a median that cars could not cross. This was in a busy commercial street with lots of shops. I guess they were worried that the extra turning was causing too many accidents. It definitely inconvenienced me because I could no longer turn left directly into my favorite lunch place. I now had to drive further down the road and make a u-turn and come back. The interesting thing about this was the bank that was right next to where I went to eat. That bank was able to get the city to change their mind. And they had to open up a special turn lane just for the bank. Was it because the bank had enough money to pay for the changes? I’m sure it cost a lot to tear down the new median and put a turn lane back where cars used to be able to turn before the work began. The real reason why the bank was able to make the city reverse their decision did have to do with money. But not because the bank paid the city. It was because the bank was able to show that with the new turn restrictions in place, there was only a single route for an armored car to take in order to get to the bank. A single path that the armored cars would always be taking. Just think about that for a minute. If you were planning to set a trap for an armored car to steal the money inside, then wouldn’t you want to know which roads the armored car would be driving on? Normally, the exact path is kept secret and changes often. But when there’s only one path possible, then it’s no secret anymore. This story had a happy ending for me. I was able to use the new turn lane to turn into the bank, drive through their parking lot and then get back on the road for a quick hop into the restaurant. The bank might not have been too happy about me and all the other cars making use of their driveway to make a u-turn, but we weren’t allowed to make a direct u-turn so the bank was put to good use. The lesson here is that predictability leads to security vulnerabilities. So avoid them. How does this relate to filesystems? We use files to store information and configuration. And we also use files to communicate. Especially between companies or departments within a company. Maybe you’re writing an application that needs to wait on some information that will be sent to you when it’s ready. It’s a lot of information so you agree with the other team that they can just write it all to a file and send it to you when it’s ready. Your application just needs to wait for the file to appear, open it, and start readin
June 10, 2018
Run your program with the least permissions possible. Listen to the full episode to learn how this applies to your application and what role the filesystem has. We’re not talking about imaginary mind control beams anymore. This is real and something you need to be aware of when writing your code. All it takes is a simple link in the filesystem for an attacker to exploit. You can also read the full transcript below. Transcript You have a choice of how you want to run your program. And by that, I mean which user account will be associated with the running application and what permissions will it have? It’s usually a good idea to run with as little permissions as possible. Because an attacker has a goal in mind and doesn’t care how that goal is accomplished. As long as the attacker gets the desired outcome, then any available method to achieve that is open for use. Think of it like this. Imagine that an attacker has a secret mind control weapon that can be used to to take over one employee at your company. Do you think the target will be the junior assistant office manager? Or the company president? Now maybe the attacker doesn’t have an opportunity to use the mind control on the president and has no choice but to choose somebody else. If the junior assistant office manager falls under the control of the attacker, then any documents that person has access to will now be available to the attacker. And anything that was not granted to the office manager will remain unavailable to the attacker. The same thing applies to your application. Only we’re no longer talking about an imaginary mind control weapon. This is real. You must consider what will happen if an attacker manages to take over your application. Anything that your application can do will be available for the attacker. Now, you might wonder, so what? We’re not talking about people with unlimited ability to do things. We’re talking about an application with code that has already been written. A computer can only do what the code tells it to do. And since you didn’t write anything bad into your application, then so what if an attacker gains control. What’s the worst they could do? After all, you didn’t write anything into your application that tells it how to send documents to a foreign country. There’s at least three things to consider. First, what might seem like a perfectly normal feature in your application could actually be far worse when put to use in creative ways you never intended. Maybe your application doesn’t know how to send documents overseas. But it might know how to open documents and save them someplace else. Someplace that an attacker already has access to and can then download them and send the document anywhere. Second, you don’t know what intent the attacker really has. Your application might not be the ultimate goal but is just one step in a larger scheme. What might seem harmless by itself could be damaging when used together with other attacks. And third, along the same lines as the unknown intent. Maybe the attacker isn’t interested in stealing anything. Maybe the goal is to just add extra work to the computer so that it slows down to the point that it becomes unusable. If your application happens to be running on an important server which is handling the logins of all the company employees, then bringing that server down could cause everybody to be unable to login to their computers. This is called a denial of service attack. Once your application is under the control of an attacker, you’ll be glad that it has as few permissions as possible. Because anything your application can do will now be available to the attacker. I’ve mentioned already that an attacker can use code that you programmed into your application to do things unintended. But nobody puts code into their application that turns over control to an attacker. And since computers can only do wh
May 28, 2018
When it comes to security, it’s better to learn from examples. This episode explains a very important and simple piece of advice. Always test for things that you want instead of things you don’t want. You’ll need to understand the differences between an Ordinal string comparison vs. OrdinalIgnoreCase vs. InvariantCulture when deciding if filenames are what you think they are. Listen to the episode or read the full transcript below. Transcript Failure is a good thing when we learn from it. In fact, if we’re not failing, then we’re not trying new things. And because a lot of programming will be new to us, we can expect to fail a lot. Especially when we’re just getting started with programming. Now a normal failure might mean that your new design doesn’t work the way you expect. But some failures can be taken advantage of to cause something unexpected in your code. Or at least, unexpected to you. For the person taking advantage of the error, the behavior is exactly what an attacker wants. There’s a whole class of attacks that take advantage of the filesystem. These attacks can be caused by mistakes in how your code uses the filesystem. Under normal usage, you might never notice. Until, for example, an attacker sets up a few files with some special names. Let’s say that you need to write some code that uses the filesystem. And you’re worried that somebody could try to misuse your program in ways that should not be allowed. So you put checks in your code to prevent this. You even test it and sure enough, your code catches the problem and stops the misuse. The problem is that you’re still thinking like a regular user making mistakes. You need to be aware of different ways that an attacker can purposefully lead your application to do things you never expected would be possible. This is where it’s good to learn from examples. There’s so many ways that it’s hard to count how your code can be misled and allow some misuse to proceed. You really don’t want to have to learn each of these attacks the hard way. I’ll explain in this series of episodes some common mistakes that you can learn from. This episode will focus on filesystem name attacks. This is not a full security episode. There’s just too much for a single episode even after limiting the discussion to filesystems. Okay, the first attack you can avoid with some simple advice. Always test for things that you want instead of things you don’t want. Think of it like this. You have a path leading to your door that you want to make sure people walk on. And if somebody walks on the grass instead of the path, then you won’t answer the door. Seems simple enough right? My advice in this situation is to watch the path. But for some reason we’re wired to want to watch the grass instead. We see somebody walking on the grass and then the doorbell rings and we refuse to answer the door. That’s the normal behavior we build into our applications. And it works fine until a thief sneaks around the side of the house and under the window that we’re using to watch the grass. We hear the doorbell and think it must be okay because we didn’t see anybody walking on the grass. The really interesting part of this example though is that sometimes we still don’t understand and find more ways to avoid watching the path. Maybe we think that our grass watching abilities are limited so we make the window bigger and put up lights on the grass so nobody can sneak past. And it works. Until a thief climbs a tree, jumps onto the roof, and then drops down in front of the door and rings the bell again. The point is, anytime you have things you want to check for, make sure to check for them directly. Don’t try to eliminate all the things you don’t want to happen. Focus on the things you do want to happen. If you expect a file to have a certain name, then check the name
May 14, 2018
Journaling records extra information in case there are problems. If your computer loses power or maybe you’re saving your files to a removable drive and you eject the drive without notice, then you might lose your work. In order to prevent larger problems like this, filesystems go through checks to make sure they’re in good shape before you can use them. This check is sometimes called fsck in Linux or Mac and chkdsk in Windows. Journaling can help prevent this check and help the filesystem recover in case there are problems. But it might not help restore your data. Listen to the full episode or read the full transcript below to learn about different types of journals such as a meta-data journal, a data journal, and a write-on-copy journal. Transcript We normally think of our filesystems as a safe place to write information. After working on a document for hours, you want to be able to press save and feel good that your work will still be around when you need it. But the real story is this isn’t always what happens. If your computer loses power or maybe you’re saving your files to a removable drive and you eject the drive without notice, then you might lose your work. If that’s not bad enough, the initial problem if left uncorrected could lead to your entire filesystem becoming corrupt. This could cause you to lose information in other files completely unrelated to your recent work. In order to prevent larger problems like this, filesystems go through checks to make sure they’re in good shape before you can use them. One thing to understand is that the filesystem has different priorities than you might think. It wants to keep everything organized. Having two different files both think they own the same storage area on a disk is bad. It’s bad for your data too. But the filesystem is more concerned with the fact that the files are mixed up. This is what the system check is looking for. Some problems can be corrected easy if they’re discovered right away. Other problems might require you to make some decisions about what to keep and what to throw away. Journaling can help prevent this and help the filesystem recover in case there are problems. But it might not help restore your data. Journaling can help eliminate the need for a full check and find problems sooner. Think of it like this. Let’s say that you’re renting a house when some natural disaster happens. Maybe string winds tear the roof off the house. Or heavy rains cause flooding. Now the owner of the house has insurance which should help fix the house. You can think of this insurance like a journal. But what about your furniture and clothes? Your pictures and electronics? You need a different kind of insurance for these things. The journal won’t help you. This may not be the best example. Because it really depends on the type of journal. Some might be able to take care of everything. The point is, just like in real life where you have to pay attention to details of your insurance, you should also pay attention to the details of your filesystem journal. The first thing to find out is if you have a journal at all. Without a journal, if there are any problems, the operating system will need to do a full scan of the filesystem to check for errors when it starts back up. This could take a long time. It’s not like you can just look up and see a big hole in your roof. A large filesystem can have problems anywhere and it all has to be scanned. This can take minutes or even hours to complete. During this time, your computer is waiting and can’t finish mounting that filesystem. This could keep the entire startup sequence delayed. For your own personal computer, that’s bad enough. A server computer that your company relies on is worse if it can’t start up right away. The reason this process takes so long is that your filesystem has no idea what it was doing before it crashed. There could be one
April 30, 2018
The Take Up Code podcast needs your support! Listen to this episode for upcoming changes or you can also read the full transcript below. Transcript There are some changes coming to the Take Up Code podcast schedule that I wanted to explain. These changes will allow more in-depth episodes and will eventually lead to video episodes. There’s so many topics where you really need to see the code in order to understand it and that means video. I’ve done a lot so far with just audio and intend to continue for quite a while yet. The podcast needs to adapt and change in order to get to that point. If you listen to some of the early episodes, you’ll notice two things. First, I used to put in short sponsor segments while I looked for a sponsor. I used these segments to promote live classes. You can still sign up for live classes and this is a great way to enhance your learning. But I never found a good sponsor. I get sponsor requests all the time that I’ve so far declined because they wouldn’t add value for you. You might find these promotions annoying and I eventually stopped putting them in every episode. The other thing is the initial schedule was five days a week with a Q&A session on Fridays. This was a lot of work that I couldn’t keep up with and I changed the schedule to just 2 days a week. Eventually, I removed the questions and answers on Fridays and concentrated on a weekly episode where I could devote more time and go into more depth. About six months ago, I found out about Patreon and setup a page to offer bonuses in exchange for supporting the podcast with regular financial contributions. I’ve been creating an extra podcast episode each month for Patrons who contribute one dollar per month. But these bonus episodes have suffered because they only come once a month. It’s also a lot of work to make each episode and I can’t keep this up forever. What I’ve decided is to change the schedule of both the regular Take Up Code podcast and the Take Up Code Patron edition so that they’ll alternate each week. This change means that this podcast you’re listening to now will change to have a new episode every other week instead of every week. And the patron edition will go from a single episode each month to also one episode every other week. This will allow more in-depth episodes for patrons and give you even more incentive to become a patron. It should be a good balance that will allow both podcasts to thrive. The first topic that I’m planning to discuss on the patron edition will be how to use databases in your code. If your application needs to work with a lot of information, then using a real database makes your job a lot easier. You just need to know how to do this. And that’s what I’ll be explaining first. If you want to learn about this, then visit TakeUpCode.com and click the link at the top to become a patron. It only takes a dollar a month to get the bonus episodes. I was on my way to work recently when I was stopped by a person asking if I wanted to support a worthy cause for just a dollar a day. It really was a worthy cause. But a dollar a day adds up fast. If that charity had instead provided a way for me to choose how much to contribute, then I’d have signed up. And that’s exactly what Patreon allows. I also encourage you to support other creators on Patreon. You can see exactly who I’m supporting and this will continue to grow. The cost starts at just a dollar a month and you can choose how much you want to pledge. In return, the site provides a way for me to return value back to you. It really is a good system. It’s a lot better than putting sponsor segments in each episode. I set a goal of producing video episodes once there are at least 200 patrons. Until then, I posted about 5 hours of video from some classes that I recorded a few years ago. The video episodes are yours for a contribution of 5 dollars
April 23, 2018
Filesystems allow you to refer to your content with different names. You can usually get by just fine without linking files and directories. Until a situation arises where linking would help. A simple explanation of a link for right now is that it allows you to create multiple names for your files and directories so you can get to the content from different locations or through different paths. There’s different kinds of links that you’ll learn about in this episode. Listen to the full episode to learn about symbolic links and soft links, junction points, and hard links. You might be surprised that you use hard links all the time without doing anything special. Or you can read the full transcript below. Transcript You can usually get by just fine without linking files and directories. Until a situation arises where linking would help. Recognizing these situations and then knowing how to use linking will let your filesystem help you. If not, then you’ll just cause yourself more work. And if you ever come across a linked file without a full understanding, then you’ll be more likely to make a mistake. If you make a mistake manually, then you might be able to stop and fix it. But if you write a program that misuses linking, then the results can be much worse. A simple explanation of a link for right now is that it allows you to create multiple names for your files and directories so you can get to the content from different locations or through different paths. There’s different kinds of links that I’ll explain in a moment. First, why would you want different names? Won’t that just make things more complicated? Sure, it can. Imagine a phone directory with your friend’s name and number. Now create a bunch of fake names with the same phone number and you’ll make a mess of things. It’s enough to make anybody think that links are bad. And this is part of the problem. You need to learn how to use links properly and when. Because there are times when links will help and other times when they’ll just make things worse. A better example of where a link would help is this. Go back to the same phone directory and imagine you have a listing for a taxi company called Fred’s Town Cars. But you can never remember the name of the taxi company when you need it. It would help if you create a new entry called Taxi and instead of writing in a phone number, you just write the name of Fred’s Town Cars. Now whenever you need a taxi, you lookup taxi and find the actual company name. This also helps if Fred’s Town Cars goes out of business and you need to find another company. Once you create a new entry, just update the entry for Taxi to point to the new company. This system saves you time when you forget the actual company name. It’s a little more work to always go through the Taxi link entry. So you’d probably just use the link when you forget the name and otherwise go directly to the real phone entry. But imagine going to the Taxi entry and finding the contents of the real entry right away complete with the phone number. This is what a link in your filesystem would do. Sure, it points somewhere else but makes it seamless. Okay, now that you know that links can actually help in certain cases, it’s time to explore what kinds of links you can make. There are really only two kinds of links. Either symbolic links or hard links. I’m not sure but I think the name soft links was created because soft is the opposite of hard. It’s also a more common word than symbolic and easier to remember. Just know that a symbolic link and a soft link are the same thing. You can call them by either name but symbolic is the more official of the two. A symbolic link is just like the Taxi phone book entry we created. It has it’s own entry in the phone book and the contents of this entry just point to the name of the target of the link. It’s possible fo
April 16, 2018
Metadata provides information about your files. You might hear the prefix meta applied to other things. It really just adds a higher level to whatever it describes. So metadata is information about your data. It’s data that describes your data in the files. Metadata includes things such as when a file was created, when was it last changed, who is the author, etc. And depending on the type of file, there could be more. A picture or image file could have information about where and when the picture was taken, what camera was used, the dimensions, etc. Listen to the full episode for more information about where a filesystem might store these properties. This includes a description of a forking filesystem and alternate data streams. You can also read the full transcript below. Transcript You might hear the prefix meta applied to other things. It really just adds a higher level to whatever it describes. So metadata is information about your data. It’s data that describes your data in the files. If you refer to something like metaplanning, then this refers to something about how you plan. Maybe before creating an actual plan to do something, you need a higher level plan for how to create the real plan. In general, going meta just means to take something to a higher level or to go beyond. For example, metathinking is thinking about how our minds think. Back to filesystems, metadata includes things such as when a file was created, when was it last changed, who is the author, etc. And depending on the type of file, there could be more. A picture or image file could have information about where and when the picture was taken, what camera was used, the dimensions, etc. You can use this information to gain more insight into your files. And applications can use it to give you more ways to organize your files. So instead of just looking at a list of files and folders sorted by name, you can view them sorted by their original author name. The extra information is also called either properties or attributes. Sometimes you might also hear the term extended attributes. This metadata needs space somewhere. I mean, remembering if a file should be read-only needs at least a single bit to be set to either 0 or 1 and that bit needs to be saved somewhere. The same thing with the name of the author. But before we get into where this is stored, I want to clear up something about read-only. This sounds a lot like security. Should you be able to write to the file or just read. Well, it’s not really very secure. Sure the concept of allowing some people to write while others can only read is definitely important. But that’s not what this attribute controls. The read-only attribute doesn’t really protect anything. It’s more of a reminder to applications that a particular file should not be changed or deleted. Think of it like a sign placed on a door that says “No Entry” and compare that with an actual locked door. Anybody can ignore the sign and enter. But most people will behave and avoid going through the door. A lock is much more secure and will stop people from entering unless they either have the key, pick the lock, or break the door. So remember that almost any security system can be broken. My dad told me when I was young that locks were only there to keep honest people out. So from that sense, there’s no difference between a sign and a lock for a person with the skill and motive to break through. A sign is a really weak form of security lust like the read-only attribute. Okay, back to attributes and where they get stored. First, we have to consider that some attributes are so common to a filesystem that they can apply to all the files. These are the things most often called attributes. They tend to take up a fixed amount of space. Even the traditional Unix style security information could be implemented by a filesystem as attributes. The reason a fixed amount of space is important is then the at
April 9, 2018
There is a special type of filesystem used to swap memory. This is not something you’ll need to use directly. But since we’re talking about filesystems, now’s a good time to explain paging and swapping. Listen to the full episode to learn more details including an imaginary example that explains virtual memory and paging. You’ll also learn a bit about how the microprocessor enables virtual memory by going into protected mode. And a bit about random access memory or RAM. Putting all this together, you’ll understand how your computer can appear to have more memory than exists and what role the filesystem plays to enable all this. You can also read the full transcript below. Transcript This is not something you’ll need to use directly. But since we’re talking about filesystems, now’s a good time to explain paging and swapping. Depending on your operating system, this might be managed for you. I know that Linux users should have a partition with a Linux-swap filesystem setup. Other operating systems might give you the option for controlling paging or offer to manage everything for you. I’ll get to what paging is in just a moment. For now, just know that this is something the operating system needs to do sometimes when it gets low on memory. The benefit of having a dedicated partition for this is the operating system has one place to go when it needs more memory and doesn’t have to squeeze things into the same space you’re using to hold your important documents. Without a separate partition and dedicated filesystem, then the operating system will use a file that it creates. Usually, these files created by the operating system (and there are others), will be hidden from you so that you don’t accidentally delete them. The idea is that it also helps avoid clutter. However, one of the first things I do when setting up a new computer is to turn on the display of hidden and system files. I also choose to show filename extensions. Now, you might not be used to all this extra information. As a programmer, my advice is to start paying attention to these little details. And knowing what your operating system is doing with your filesystem definitely qualifies as something you should be aware of. Modern Windows operating systems make things a little more confusing with the addition of a swap file and a paging file. I haven’t done a lot of the new Windows App programming but from what I understand, the OS uses the swap file to hibernate the new Windows apps that you download from the Windows App Store when they’re not being used. Don’t get this confused with the swap partition in Linux. That’s more like the Windows paging file. Until Windows started making the distinction, I would normally use the terms swap and page to mean the same thing. Alright, let’s start with why a computer needs a swap partition or a paging file. I mentioned that it helps when the computer gets low on memory. Imagine this scenario, you have a clean desk. That’s already a stretch for me. Maybe you’re more tidy. I’ve got stuff all over my desk until I normally can’t see the surface anymore. But pretend for a moment that such a thing actually exists and you have a clean desk that can only hold let’s say 10 sheets of paper without any overlap. Since this is just imagination, we don’t want any paper to lay on top of another sheet. Let’s just call these pages. Now, what do you do when you need more than 10 pages? You could buy a bigger desk. That would be like installing more memory in your computer. But even then, you’ll eventually hit some limit to how many pages can fit on your desk. So for now, let’s assume we already have the biggest desk we can afford. And it will only hold 10 pages. A simple solution is to get a box that you can put on the floor that can hold pages you don’t need right now. You don’t wa
April 2, 2018
Access control lists provide more security options. The previous episode described the traditional security model used by Unix computers. This includes Linux and Mac computers as well. It’s a simple model that works really well. Make sure to listen to the previous episode for more information. The first time I came across a different system was with Windows NT. This stood for new technology and rewrote a lot of the early DOS-based operating system. Listen to the full episode or read the full transcript below for more details about NTFS security using access control lists (ACL), access control entries (ACE), and security descriptors (SD). Transcript The previous episode described the traditional security model used by Unix computers. This includes Linux and Mac computers as well. It’s a simple model that works really well. But it still requires you to divide everything into three viewpoints. What can the owner do? What can members of a group do? And what can everybody else do? Even the question of what are these things that can or can’t be done comes down to just read, write, and execute. Make sure to listen to the previous episode for more information. It’s a lot better than nothing. Early PCs had no concept of security at all. Maybe that’s because they were mainly used by a single person. They were, after all, personal computers. The first time I came across a different system was with Windows NT. This stood for new technology and rewrote a lot of the early DOS-based operating system. Even when Windows 95 was released, it was really little more than a nice user experience. It was a big step up from Windows 1, 2, and 3 where Windows was started after the computer started up with DOS. The Windows 95 line continued with Windows 98 and then Windows Me. All of these had little in terms of security. The filesystem was based on a system called FAT. The best thing about the FAT filesystem is that it’s old and simple. It has no security at all. The problem with Windows NT at the time was that it required a lot of memory to install and run. I remember trying to install it on a computer back in the early 1990’s and my computer didn’t have enough memory. It needed 16 MB. That seems tiny compared to today’s computers. But back then, I couldn’t afford a thousand dollars just for some extra memory. Windows NT 4 came along and computers were beginning to be commonly available and affordable that could run it. But it wasn’t until Windows 2000, and later Windows XP, that personal computers started getting better about security. And even then it wasn’t until Windows XP Service Pack Two that security became a top priority. Microsoft still had consumer oriented operating systems like Windows XP, and server oriented operating systems like Windows 2000 and Windows Server 2003. But they were very similar on the inside because they all came from Windows NT. Microsoft took Windows NT and kept making it better until it was applicable to personal tasks as well as serving the needs of many people. Once the older DOS based operating system ended with Windows Me, then Microsoft was able to focus on the NT line. Windows NT from the very beginning had a different security system than traditional Unix. And it took that security system beyond just the file system. Although the file system is where you’ll likely see it used most. Just remember that what you’re learning now is used in other places in Windows. It’s a very flexible system. Windows NT came with the NT filesystem or NTFS for short. And NTFS security is based on access control lists. The acronym is A C L and is pronounced akal. As its name implies, an ACL is a list. Each entry in the list is called an access control entry or ACE for short. There can be as many ACEs as you need. And each ACE defines a specific identity and what permissions should be allowed, denied, or audited. The identity is also referred to a
March 26, 2018
Security is a big part of filesystems. This episode will explain how traditional file system security works for Unix, or Linux, or Mac computers. They all follow a similar design. These operating systems could have another security system depending on the version. I’ll describe that system in another episode. You can read the full transcript of this episode below. Transcript But you can’t have a secure filesystem if you don’t understand how it works. This is one thing you’re bound to come up against when programming. Just like when you come home and need to unlock your house door. If you forget your key, you get locked out. The types of security problems you’ll be likely to face as a programmer are not usually the type where you forget the key. You’ll be more likely to face issues where you have to manipulate the locks, or pass your identity to other parts of your program, or even take on a different identity for a while. Let’s say you do forget your house keys for a moment. After calling a relative with spare set of keys or the locksmith, you might be interested in things you can do to prevent this from happening again. One solution is to just stop locking your door. Or hang the key from a chain next to the door on the outside so that anybody can use it. Would you consider doing this? Well, maybe if you live in a small rural town. But even the small towns are likely to lock their doors. I remember a restaurant from when I was a kid that had no locks on the doors. The place didn’t need locks because it never closed. Chances are, you want to keep your locks. So why does a common recommendation online to programming security questions advise you to set the security of your files or directory to 777? That’s for a Unix computer system anyway. For Windows, a slightly less common advice is to add everyone to the access control list. Both of these approaches are the equivalent of letting anyone use your keys anytime they want. The filesystem can’t help you if you give it specific instructions to let anyone in. It should always be your goal of identifying the absolute minimum privileges needed by only those who should have access at all. This episode will explain how traditional file system security works for Unix, or Linux, or Mac computers. They all follow a similar design. These operating systems could have another security system depending on the version. I’ll describe that system in another episode. Understanding this design will give you the ability to configure your files so that you have just the right amount of permissions. But first, why is this important? I mean, sure, we want to keep bad people and applications away from our information. But assuming you have a good reason to have access, why not just grant full access? Let’s say you arrive for work and walk in the front door. You might have a badge or maybe everybody already knows who you are. You have access. Does that mean you should have access to the company bank account too? What about the company plans for the next 5 years? Security is not a switch that gets turned on or off. There are levels. There are restricted areas. And for large organizations, there can be a lot of changes as people come and go and move from one department to another. Let’s start with you though. If you create a file, then it should probably belong to you. You should be able to open it again and make changes. You should be able to move it to a new folder or to delete it. And if the file is something that can be run like a script or an application, then you should be allowed to run it. Traditional Unix based filesystems divide security into read, write, and execute permissions. You can either read the file or not. And you can either write changes to the file or not. And you can either execute the file or not. Each of these switches can be turned on or off individually. Although it’s normal that if you can write
March 19, 2018
There are many different types of filesystems with different capabilities. Once you understand these capabilities, you’ll not only be able to select the proper filesystem for your needs but will understand, for example, how your computer knows when you download applications from the internet so it can warn you when you try to run them. At this point, each of these capabilities will seem unrelated to each other. In a way, they are. Think of them like individual features in a car. This episode will talk about file size limits and volume size limits. You can read the full transcript below. Transcript Knowing what these capabilities are will help you to understand which filesystem to use and how it can be used. This series will explain some common filesystem abilities. You’ll need this understanding to make any sense of one filesystem vs. another. Without it, you’ll be limited to whatever filesystem comes by default with your computer and probably won’t understand why you have problems transferring files from one computer to another. Once you understand these capabilities, you’ll not only be able to select the proper filesystem for your needs but will understand, for example, how your computer knows when you download applications from the internet so it can warn you when you try to run them. At this point, each of these capabilities will seem unrelated to each other. In a way, they are. Think of them like individual features in a car. We can talk about which cars have power steering, what it is, and how it helps you to park. We can also discuss anti-lock brakes, what they are, and how they help you to avoid accidents. Power steering and anti-lock brakes are unrelated except that they both describe capabilities that some cars have and others don’t. These are referred to as features. A car salesperson new to the business will first learn all the features and which ones exist on which cars in the lot. This is definitely a lot better than being clueless about the cars and only thinking in terms of colors and style. But that salesperson will make a lot more sales when the features can be explained in terms of benefits. Talking about how power steering help you to park is more of a benefit. It’s the benefits that you’re interested in when deciding which car to buy. You want to know how a feature can make your life easier or make your travel safer. I could go quickly through common filesystem features and even give you a quick overview of each one. And all that would fit into a single episode. But you’ll get more value from a more detailed explanation of each feature that explains the benefits to you. What will each of these features do for you? Before we get too far though, I want to ask your feedback about something. I started this podcast a couple years ago as a way to help you to learn how to program. Listening to audio is just one activity and you really need to actively program your own projects to really learn. Reading books, watching videos, taking classes, talking with other programmers, subscribing and reading programming magazines, all of these things are needed. There wasn’t a lot of actual teaching going on with audio podcasts at the time. Even today, most podcasts are based on interviews instead of specific topics designed to teach you how to program. Don’t get me wrong. Interviews are great. I listen to them too. But you need more than that. And I sponsored the podcast myself to let you know that I could help you with live classes. I got several offers from potential sponsors but declined them because their products didn’t seem like something you would get value from. Eventually, I found out about Patreon which is a service that provides a way for creators like myself to get paid for providing you with something of value. This can be almost anything. Anyway, I’d like to ask you for feedback about the value you get from this podcast. You see, I&#
March 12, 2018
Cylinder, Head, Sector or CHS vs. Logical Block Addressing or LBA give you two ways to find data on a disk. You’ll learn about these two methods in this episode because the terms come up now and then when talking about filesystems. They don’t really have anything to do with a filesystem itself. They describe two different ways to specify exactly where on a disk that information an be found. Listen to the full episode or read the full transcript below to hear one of my crazy examples where I compare CHS to book binding and then show how LBA is like a book’s page numbers. Transcript You’ll learn about these two methods in this episode because the terms come up now and then when talking about filesystems. They don’t really have anything to do with a filesystem itself. They describe two different ways to specify exactly where on a disk that information can be found. For that reason, they’re used by filesystems. And you should at least be familiar with the ideas. Let me start with this example to help explain the concepts. Have you ever tried making your own book? Or have you looked at books to see how the pages are bound together? You could start with a stack of paper and staple the pages along one side. This will hold the pages together but gets a lot more difficult as the number of pages increase. It also makes it difficult to open the book because the staples don’t let the binding bend very well. Instead if stapling directly through the pages, you get better results by folding the paper in half so that each sheet can form two pages. The staples then only need to go through half as many pages and the book is easier to open because the pages are already folded. Some magazines are made this way. Or instead of staples, maybe string is used to thread through the pages. Regardless, you’ll still be limited in how many pages you can bind like this. And the pages at the outside will have a less crisp fold. What about a writing pad? You know the kind with a cardboard back and pages glued together along either the top or side. The glue is designed to hold the pages until you want to tear one out. Then the page comes away fairly clean. There might be a little glue that breaks off and is still stuck to the page. But you don’t have to actually tear the paper itself to remove the page from the writing pad. Either of these methods has problems for a book. You want a lot of pages that are easy to flip through and probably want the pages to remain in place. What if you combine them. What if you first bind small groups of pages together with thread and then glue them together? The glue has more paper to hold on to with each group and the thread keeps individual pages from pulling out of the glue. The book itself is bound tight and it can be opened easy. Job done, right? Maybe for an empty book. But for a book with printing inside, you really need to print the pages before they get stitched and glued together. And this is where you need to know how many pages will make up each group in order to layout the pages for printing. Not all books will group sheets of paper together before binding them. I’ve seen a lot of paperback books that look like they just have individual pages glued together with a thicker layer of glue than a typical writing pad. You’ll probably find a lot more hardback books that follow this stitching strategy. When it’s all done though, do you want to number the pages by their group and then sheet number? No, you want consecutive page numbers because those are more natural. Now let me take this example and put it in similar terms of hard drives and floppy drives. Other than the fact you can remove a floppy disk, they’re quite similar to hard drives. And the same goes for CD and DVD drives. While other drive types could be different, it’s usually better to follow existing standards than try to create something new. A floppy disk has a single spinn
March 5, 2018
Dividing your disks into partitions allows you to use each partition for separate tasks. Listen to the full episode or read the full transcript below for more details including a description of the Master Boot Record (MBR) and GUID Partition Table (GPT) partitioning schemes. Transcript Would you buy a house that had a single cupboard in the kitchen with one giant shelf? No drawers to keep forks and spoons. Just one big storage space. What if you had to keep your clothes there too? And while at work or school, would you use a single roll of paper instead of separate sheets that can be stored in folders? We need to organize things and that goes beyond just sorting. We need to group things too. These groups can be used for very different things. As computer disks have grown in capacity over the years, the need to divide them into multiple groups has grown. This is called partitioning your disk. Each partition can then be used for different purposes. Maybe you want one partition to hold all the operating system files. Another partition can hold your applications. Another for data file you create. Another for log files that record useful information about what your computer is doing. Another for swap space that the operating system can use when the main memory gets low. The reasons are as plentiful as there are people to use computers. Now, dividing your disks is something that you’ll want to do from the very beginning. You don’t want to be creating new partitions later, or combining existing partitions into one, or resizing partitions. This would be like moving into a new house and realizing that your kitchen really needs to be twice as big. You probably should have chosen a different house or a different design if you’re building it new. Making partition changes is also something that you should do before using your computer. Sure, there are some exceptions and you might be able to make some changes later. But it’s a lot better to get this right in the beginning. You want to plan for reasonable future needs without going overboard. Remember that you can get along just fine with a single partition. So I’m not advising you to create partitions that you don’t really need. If you’re not already aware of the need for a separate partition, then you probably don’t need it. As a programmer though, you do need to be aware of the concept of partitions. Maybe you want to sometimes start up your computer with Windows and other times with Linux. You could buy two computers. Or you could use partitions to divide your hard drive into parts usable by Windows and other parts usable by Linux. And other parts can be shared. How you partition a disk will depend on which operating system you’re using and can change over time as well. Each operating system comes with applications that can do this for you. And sometimes, there are 3rd party tools you can install which might give you more control over the partitioning or an easier user interface. A lot of the tools that come with the operating systems are not known for being easy to use. You also might want to partition removable disks and storage devices. Especially as the capacity of these gets bigger. Just be aware that different operating systems might be okay with this while others might cause problems. For example, I think Windows will only let you access the first partition on a removable disk. Or maybe it’s an active partition where you can only choose one partition at a time. You could insert that same device into a Mac computer and get access to all the partitions. However you decide to partition your disks, all the information will be stored in a partition table. In addition to how you want to organize your partitions, you also need to choose which partitioning method to use. When I first started using computers, there was only one partitioning scheme called the master boot record or MBR for short. You might be familiar with the wor
February 26, 2018
How are filesystem organized with multiple drives? Whenever you insert a floppy disk, or a CD or DVD, or even a USB drive, the operating system will detect this event and make that drive letter available for use. So it’s not really the drive itself that makes a drive letter. But instead it’s the presence of a filesystem that makes a drive letter. If you have a floppy drive that’s empty, we might think of that as drive A. But you won’t have a drive A available for use until you insert a floppy disk that contains a filesystem and the operating system recognizes the filesystem. Make sure to listen to the full episode for more details about the shell and how this interacts with the filesystem. You’ll also learn about how you can control when information actually gets written to a filesystem through your application code by flushing buffers. You can also read the full transcript below. Transcript The solution that was included with DOS and later became part of Windows was to give each drive a letter. The first floppy drive was A and the second floppy drive was B. The first hard drive was C and other drives would follow. It’s possible to specify that a CD or DVD drive should be something other than the next available letter. And you can access network filesystems through drive letters too. This system gives you 26 possible drives. Although drives A, B, and C should really be reserved for floppies and the first hard drive. Whenever you insert a floppy disk, or a CD or DVD, or even a USB drive, the operating system will detect this event and make that drive letter available for use. So it’s not really the drive itself that makes a drive letter. But instead it’s the presence of a filesystem that makes a drive letter. If you have a floppy drive that’s empty, we might think of that as drive A. But you won’t have a drive A available for use until you insert a floppy disk that contains a filesystem and the operating system recognizes the filesystem. Let me be a bit more specific though. I’ve been referring to the operating system up till now. It’s probably time that I describe something called the shell. The shell is part of the operating system in the sense that you get a shell with the operating system. But it’s not part of the deep internals of the operating system. It’s like a shell that sits around the operating system. For most of us, the shell is what we see and what we think of as the operating system. It would be like how a company spokesperson can become famous and come to represent the company as a whole. But the spokesperson is not the company just like the shell is not the operating system. Some operating systems could even have different shells that you can either choose from or maybe install later. It’s like choosing a new theme. The entire look and feel of your computer can change with a new shell. With Windows, the shell makes up the desktop and the task bar. It also forms the file explorer you use to browse for files. And the file open dialogs. With a Mac and Linux, it forms the desktops and the launch bar and probably a lot more. In older text based operating systems such as DOS, there was a shell too that was used to manage the command prompts. With Linux and Mac terminal windows, you’ll still hear about the Bash shell and the Korn shell which are two popular command line shells. When you insert a floppy disk, or an optical disk, or a USB storage device, the operating system will be made aware of the new device. But it’s most likely the shell that figures out what to do with it. Many operating systems require that the filesystem that was just inserted must be mounted before it can be used. I remember when Linux was new, this mounting had to be done manually. There was a file that could be updated with instructions to do this automatically. It was still very much a manual process. Mounting the removable filesystem just
February 19, 2018
How are filesystem organized with multiple drives? Now that you know why you should learn how to use a filesystem in your programming, what do you need to know? Programming with a filesystem is different than just using your computer to open and close files. You need to understand how a filesystem works in even more details in order to include this ability in your programs. Depending on what you’re programming, you might need to know quite a bit. Even a simple program will expose you to error handling and exceptions, security, favorite locations, common dialogs, and much more. Listen to the full episode or read the full transcript below to learn more about some of the reasons that helped define how filesystems worked. Transcript Now that you know why you should learn how to use a filesystem in your programming, what do you need to know? Programming with a filesystem is different than just using your computer to open and close files. You might think you already know how to use a filesystem. It’s kinda hard to use a computer without knowing this. But you need to understand how a filesystem works in even more details in order to include this ability in your programs. Depending on what you’re programming, you might need to know quite a bit. Even a simple program will expose you to error handling and exceptions, security, favorite locations, common dialogs, and much more. I’ll be explaining how to use a filesystem in this series in your code. The operating systems will be Windows, Linux, and Mac. This is based a lot on my experience through the years which has mostly been on Windows with a bit of Linux. I first started using a Mac about 9 years ago so don’t have much experience with early Apple operating systems. My explanation might be a bit tilted in favor of what I know about most. In many ways, a Linux filesystem and a Mac filesystem are similar. They might look different to you as you use the computer but this gets back to the differences between using a computer vs. programming a computer. Windows filesystems are very different while Linux and Mac are more closely aligned. Before Windows came along, IBM and Microsoft worked together to create an operating system for personal computers. Back then, using disk drives of any kind was still new. Personal hard drives were very rare. I didn’t get my first hard drive until probably a year after I got my first computer. Even then, it was unreliable and would overheat. I had to keep it outside of my computer with the cables running through the back of the computer. And I pointed a small fan at the hard drive to help keep it cool. The whole setup looked like a mess but it mostly worked. It was possible back then to use a computer without inserting any floppy disk or running any operating system. When the computer started, it would look for a disk and if none was found, then it would start running a BASIC interpreter. BASIC is a programming language where you give each line a number and then you can refer to other places in your code by using the line numbers. It was possible to turn on a computer, type in a few lines of code, and print your name over and over on the screen. Maybe you could even use some colors assuming the monitor was a color monitor. Many monitors back then used a black screen with green text. That’s all. When color monitors came out, they were still limited to about 16 colors. But at least the normal text was then white on a black screen. The computer could display 25 lines and 40 columns of text on the monitor. I remember when I was even younger and my family got an Apple II computer. I don’t really consider this part of my computer experience because all I really did on the computer was practice some typing. Yes, I taught myself how to type which is probably why to this day, I still have to look at the keyboard in order to type properly. It always amazes me when I talk to another programmer and they turn their head to
February 12, 2018
Understanding how to use the filesystem will allow you to add common and expected features to your apps. Listen to the full episode for more insight into filesystems. And make sure to subscribe to the podcast from within your podcast app to get new episodes automatically. You can also read the full transcript below. Transcript How many times have you needed to save your work? Maybe you’re writing a document and need to save it so that you can continue working on it later. I don’t know anybody that can write more than a few pages perfectly the first time and then have no need of that document after printing it. Even emailing your work requires it to be saved somewhere. And documents aren’t the only thing that needs to be saved. Maybe you’re playing a game and want to save your progress so you can continue playing later. Now you could just leave everything as is in memory. Just pause the game or leave the document open. Then come back to it whenever you want. That works until you lose power. Or until some bug causes the application to crash. And then there’s the question of size. Modern games are much too big to fit everything into memory at once. Maybe a word processor can fit everything into memory including a full novel that you’re writing. But that’s because even the longest novel is insignificant in size compared to all the data needed by an immersive game world. What about pictures and video? It wouldn’t be very good if you couldn’t do anything with a picture except look at it right after it was taken. We need to save things to a permanent storage location that we can rely on to exist after turning off a device or a computer. This has been possible for so many years that it’s just expected. Nobody really considers it optional anymore. It would be like buying a car with an optional air conditioner. A long time ago, cars didn’t have air conditioners. Or power steering. Or power windows that can be opened and closed with the press of a button. To this day, people still say to roll down the window. There was a time when computers came with optional disk drives. Some early computers didn’t even have this as an option. You would turn on the computer, do whatever you wanted, and lose everything when you turned it off. Some computers were designed to use a tape recorder to save your work. The same kind of tape recorder that people used to record and play voices and music. When I was a kid, I would wait patiently next to the stereo for a song to play that I liked and sit as quiet as possible while holding the tape recorder next to the speaker to record the song. The recording quality was terrible even when I could avoid dogs barking or birds chirping. The computers would emit a series of tones or beeping sounds whenever you wanted to save your work. The only good thing was that the recording was done through a cable instead of telling everybody to be quiet so you could save your work. It was still a long process with quite a few steps. And it was slow. I’m skipping over even earlier computers that used paper cards or rolls of paper tape to store information. They could punch holes in the paper and then read information back by looking for the holes. I just don’t have any direct experience with these computers. Early main frame computers did have the ability to store information on magnetic disks or magnetic tape. Some disks were removable and some were fixed. The tape was stored in large cartridges that could be loaded into even larger tape players. Some removable disks were larger than birthday cakes and were the type of thing that you might ask for help carrying. The removable disks became smaller and flexible and could fit inside a binder with regular papers. They were about 8 inches in diameter and kept inside a protective sleeve so that people could hold them without getting fingerprints on the actual magnetic surface. These types of disks bec
February 5, 2018
The code you write should follow a similar level of detail. I mentioned level of detail in an earlier episode about how to start building a video game. And there I was talking about how to get your game idea or any project idea to a level of detail where you can begin working. This episode is more of a follow up to last week’s episode where I explained how to watch out for differences. Listen to the full episode or read the full transcript below for more examples and how to fix your code so that it’s more readable and understandable. Transcript I mentioned level of detail in an earlier episode about how to start building a video game. And there I was talking about how to get your game idea or any project idea to a level of detail where you can begin working. This episode is more of a follow up to last week’s episode where I explained how to watch out for differences. Before we get too far though, I wanted to clarify the example that I used last week. I mentioned a bat. And in my mind, I was picturing the flying mammal type of bat that comes out when the sun sets to eat mosquitos and moths. But I also mentioned a baseball. Putting the two together might lead you to think of a baseball bat instead of the cute furry animal with pointy ears. If anything, this shows what I was talking about in episode 2 about why we need programming languages at all. Any natural spoken language is full of misunderstandings like this. I’d also like to mention that this podcast explains real programming topics and each episode is dedicated to a single topic. As much as possible anyway. That means that any episode from episode zero up to whatever is the current episode are all relevant. You can listen to any episode to gain insight and improve your skills in programming. If you listen to the earlier episodes, they all had sponsor advertising. But I never found a good sponsor that you would benefit from so I decided to sponsor the show myself. I still get offers to advertise on the show and turn them down usually because the product is not related to programming. Most of the early episodes promote live classes. Right now, the best way for you to participate in live classes with me is to become a sponsor of the podcast and select a reward level that includes live programming sessions. This is where you can participate as we build a game. You get to see how to approach problems and how to write code that does what you want. Just visit takeupcode.com and click on the link at the top to become a patron. Today, I’m explaining how to watch out for differences in the level of detail in your code itself. All this talk of earlier episodes reminds me that I haven’t used cooking in my examples in a while. Imagine that you’re following a recipe to bake bread. And it explains how to mix the ingredients into a bowl. But when the recipe gets to the flour, instead of telling you to add 2 cups of all purpose flour, the recipe gives you the steps needed to harvest the wheat and the steps needed to grind it into flour. Now these steps are definitely needed. But not when trying to bake bread. All the basic ingredients have to each go through their own production steps. And it makes a recipe completely unusable when it mixes levels of detail like this. In fact, the example I gave you is so ridiculous, that nobody would ever consider writing a recipe like this. But why then do we write code like this? I see it all the time. Even in my own code. Yes, I have to be careful about this too. We all do. I’ll be writing a method with lots of detailed instructions and right in the middle will be a call to another method that wraps up other instructions. Don’t get me wrong. I’m not suggesting that you avoid putting code into methods. All I’m saying is that the code becomes more readable and more understandable when it’s all at a similar level of detail. So instead of writing ten lines of detailed code followed b
January 29, 2018
Finding differences will help you make sense of your code. We’re fairly good at spotting things that are different. But how good are you at thinking of different ways that something can be similar or different? That’s an important skill you need to develop in order to become a better programmer. Listen to the full episode or read the full transcript below for examples. And if you’d like to participate in programming sessions where I work through issues like what I described in this episode, you can become a patron of the podcast and select your reward level. Transcript Differences will creep into your code as you think of new things it needs to do. It happens to all of us. And if you don’t recognize them, the differences will turn your code into a jumbled mess. There can be different ways to think about things so you have to examine your code from different viewpoints to find things that are similar and things that are different. There’s a popular children’s show called Sesame Street that sometimes shows a game called “One of these things is not like the others.” At least that what I think it’s called. It’s been a while since I watched it. You have four pictures and need to figure out which one is not like the others. Let’s say there’s a picture of a baseball, a man, a bird, and a bat. Which one is not like the others? Most kids will choose the baseball because all the others are pictures of living things while the baseball is not alive. But this is where you can develop your programming skills by thinking of other ways that things are alike. Maybe you said the man is not like the others because the others start with the letter b. This is accurate but not the best programming reason because names don’t usually define behavior. Look for differences in behavior more than other things. Maybe man could be different than the others because all the others fly. But does a baseball really fly? Not really, it gets thrown instead. And while it’s not that easy to toss a man, it can be done. You could think about the baseball being unlike the others because the others can move on their own. That’s similar to being alive. It would make more sense though if the bird was replaced with a picture of a motor. The point is that you can sometimes find multiple similarities and differences. These will change how you think about your code and will affect your design. Getting to the right level of similarities will allow you to solve basic problems once and then reuse that solution in other parts of your code. Then you can focus on just the new differences and not worry about things you’ve already figured out. Think for a moment about our bodies. We’re made up of various organs and systems. Is our skin similar or different than our arm muscles? They seem very different but actually contain a lot in common. If you were programming something like this, you might start out with different classes for skin and muscle since they seem so different. But eventually, you’ll realize that both need food and oxygen and the ability to grow. This is where you can start going down the wrong path if you don’t recognize the similarities. All of our organs are made of cells that are specialized but actually very similar. Even plants are made of plant cells. The cells all perform the same basic functions but can be adapted slightly for skin, muscle, bone, etc. They all have the ability to absorb nutrients through the cell wall and divide and grow. This is where you can benefit by writing code that does the common functionality once and reusing it in all the different places that need it. As an another example, consider the game that I’m working on. I wanted a configuration file to hold some of the data that defines the basic behavior and settings of the game. The configuration file uses properties that each have a name and a value. That’s alrea
January 22, 2018
Resource allocation is initialization or RAII for short may be hard to pronounce but will help you write better and simpler code. Listen to this episode for an example that should help explain why RAII is an important technique to help us simplify our code so that we don’t have to manually clean up resources when we’re done. You can also read the full transcript below. Transcript There’s usually some tradeoff you need to consider when programming. Not everything has a single best way to do something and usually that means you have choices. Each choice will help you in some way and cause problems in another. One of the best known choices is between good, fast, and cheap. Pick any two. • If you want something made well that’ll last and you want it quick, then it won’t be cheap. • If you don’t want to sacrifice the quality and have a limited budget, then you’ll have to wait because you won’t get it soon. • Or if you want something as soon as possible and don’t want to spend a lot of money, then you should expect problems with the quality. There’s a tradeoff with RAII just like anything else. But the problems it helps you solve are well worth the extra code needed. And most of the time, you don’t have to write this extra code. You just need to be aware of the situation and know how to use RAII to your advantage. I’ve talked about this briefly in episodes 55 and 127. Listen to them for more information. In order to make full use of RAII, you’ll need a language like C++. I say like C++ even though C++ is the only language I know about that makes full use of RAII. But since there are hundreds of programming languages, it’s possible that you can use this technique in other places. Languages with garbage collection are not going to use RAII to its full extent. That’s because you really need a language that defines the lifetime of objects and especially the exact moment that their destructors will be called in order to make full use of RAII. Listen to episodes 17 through 22 for more information about object-oriented programming, constructors, and destructors. Imagine this scenario. You’re about to leave your house to go to work but want to fix something to eat first. So you crack open an egg into a frying pan and set it on the stove to cook. Then to save time, you start getting ready for work. The phone rings and you answer it. Just a robot sales call. But it distracts you just enough that you forget all about your egg, finish getting ready for work and leave to catch the 9am bus. You have a nagging feeling that you’re forgetting something but can’t quite remember what. You remember the egg only when you get home and open the door and smoke pours out. The whole house smells really bad. There was no fire but it’s hard to breath until you get all the windows open to vent out the smoke and smell. Your frying pan is warped and there’s nothing recognizable about the egg anymore. All of this happened because you forgot to turn off the stove. Maybe it was also caused by the phone call. But it comes down to this. Anytime we have to remember to do something important either in real life or in programming, we can expect mistakes like this to happen. What if there was a new type of stove that would shut itself off when it detected that nobody remembered it was on? Maybe it could detect if nobody was inside the house and turn off on its own? In order for this to work properly, the stove would need to turn itself off right away. It wouldn’t help much if you forgot to turn off the stove, the stove also recognized that nobody was home, but then it waited for a few extra hours before finally deciding that it should react. It needs to react right away in order to prevent burning. And this is where garbage collected languages struggle. There’s no fixed time when you can rely on your resources being cleaned up. It might happ
January 15, 2018
Why is C++ such a good choice for writing games? The C++ language is used for many types of projects requiring speed, scale, and responsiveness. It’s also a great choice for video games. Why? The C++ language is more towards the low level of language abstraction but not all the way. And it’s because of this that a lot of people think that C++ is not used much anymore. That it’s been put aside in favor of higher level languages. What about languages like Python or Javascript? Or Java or C#? They all have their use. It’s not like one language is better than another. That would be like asking which is better, a hammer or a tape measure? So which language should you use? It really depends on the type of game that you’re building. But there’s a big advantage that C++ has over other newer languages that attempt to be easier to write. It all has to do with timing and how C++ allows you to write code that’s more deterministic than other languages due to the lack of garbage collection in C++. Listen to the full episode for more details, or you can also read the full transcript below. Transcript The C++ language is used for many types of projects requiring speed, scale, and responsiveness. It’s also a great choice for video games. Why? Well, video games are written in many languages from assembly to graphical symbols you can snap together. The languages usually range from low level such as assembly to high level such as the graphical. I saw a game design product at Target recently that consisted of a grid of squares. It looked like you place colored markers on the squares to define the background of a game. Yellow squares resulted in a coin in the game, blue squares caused water to appear, and brown were used for the ground and floating platforms. It was a simple system that promised you the ability t design your own game. Not a bad idea, really. The only problem is that it looked like you would be limited in the types of games you could design. If you think about the languages available and rank them according to the level of abstraction, then the plastic squares on a grid would be at one end and assembly on the other end. The types of games you can create will be limited at one end and boundless at the other. The C++ language is more towards the low level but not all the way. And it’s because of this that a lot of people think that C++ is not used much anymore. That it’s been put aside in favor of higher level languages. What about languages like Python or Javascript? Or Java or C#? They all have their use. It’s not like one language is better than another. That would be like asking which is better, a hammer or a tape measure? The difference between construction tools and languages though is that you can write a game with just a single language. You can’t build a house using just a hammer. So which language should you use? It really depends on the type of game that you’re building. You can build a 2D game fast with Javascript that will run in a browser window. And maybe more. I’m not an expert with this so can’t say for sure. But I do know that Javascript is getting faster and more capable. Python is a language that I’ve started learning about and using a bit. I haven’t tried using it for anything graphical. And for me, anyway, it starts getting hard to understand as the size of the program gets larger. I’ve mentioned before that a game can get large and complicated quick. You really need some good libraries or a game framework to help you build anything more than a trivial game. There’s several 2D game engines available and some very popular 3D game engines. Unity is a powerful 3D game engine designed to be used with the C# language. And Unreal is another powerful 3D game engine designed to be used with C++. If you want to use Python or Java or any other language, then you should probably find a game engine that supports
January 8, 2018
Work on the toughest problems first. And if you can’t solve them, then find a way around. Remember to always keep sight of what’s important. And right now, that’s to finish your game. Don’t get sidetracked with problems. But don’t ignore them either. Listen to the full episode to learn how to identify problems early and some real examples to demonstrate how you can apply this advice to your project. You can also read the full transcript below. Transcript I remember a story that I heard a long time ago. I don’t remember the specifics anymore but it went something like this. There were three adventurers on a mission to deliver a message and they came across a strange wall in the middle of the forest that was blocking their path. There was a locked door in the wall. One of the adventurers, tried to pick the lock and gave up. The other one tried to smash the lock but it was too strong and also gave up. The last adventurer realized that the lock and even the door was not the problem and cut some small trees to make a ladder to go over the wall. Remember to always keep sight of what’s important. And right now, that’s to finish your game. Don’t get sidetracked with problems. But don’t ignore them either. My advice is to identify the big problems as soon as possible. And then either solve them or find a way around. Unlike the three adventurers, you have a secret weapon that you can use at any time. If you can’t solve the problem and the wall is too high to go over and too long to go around, you have the power to just make the wall disappear. Getting rid of part of your game might seem drastic, and it probably is. But it’s better to find out and make these types of decisions early. If you skip over something because it seems hard, that doesn’t make the problem go away. All it does is give you time to write more code that will depend on the missing piece. Then when you finally get around to working on it, you still have the same problem. Only now, you’ll be more committed and less able to change your design. You may find that you no longer have the secret weapon of just removing the wall because too much of your project now depends on its existence. By exploring these unknown parts early when they’re just ideas, you can try to solve them or work around them. In the story, this would be to either pick the lock or smash the door open. If you find a solution like this, then great. But if not, then try to find another way around the problem. This would be like jumping over the wall. And if that also doesn’t work out, then make the decision to remove that part of the game. How do you find these difficult areas early on? By going wide instead of deep. What I mean is that you should avoid working on some aspect of your game until it’s perfect before moving on to the next part. Instead, work on just the pieces you need to get something running from beginning to end. Then go back and revisit parts to make them each a little better. Let me make this a little clearer with an example. Let’s say that you start off with an opening and closing. I’m talking very basic. A title screen with the game name and a button to begin play. Follow that up with an empty screen that says “Action”. Even though there’s nothing really happening yet. That’s okay. Then provide some way to end the game. You’re done with this part and ready to move on. Maybe you decide to work on to the environment of your game next. What kind of setting will your game be in? Buildings? Outdoors? Get just enough of this working so that it exists. Maybe start out with a single room with a floor and four walls. That’s it. This part can replace the empty “Action” screen. Don’t add doors or tables or lamps yet. Okay maybe a single light if you really need one. Then move on to the controls. How will your character move around.
January 1, 2018
How is a video game different than any other application? Building a video game will help you understand how to build any type of application. It’s a fun way to learn how to program. But how are video games different? And will understanding these differences help you to build better games? Yes, listen to the full episode or read the full transcript below to learn about event-driven programs and how this is different from a game loop. Transcript I’ve mentioned in this series that building a video game will help you understand how to build any type of application. It’s a fun way to learn how to program. But how are video games different? And will understanding these differences help you to build better games? Yes, and I’ll explain some of the differences here. I can’t explain all the differences because there’s lots of ways to program. If you’re writing software to control a toy robot micro controller, that’s very different than writing software that controls food or drug manufacturing. And these are different than writing software to keep track of your sleep patterns. Writing software that runs deep inside your computer operating system is also different than writing a word processor. I’ll focus on a simple user mode application compared to a simple game both running on a modern computer operating system. The application will have a graphical user interface, or GUI for short, which means there’s windows, buttons, edit boxes, etc. and you use the mouse to point and click. I’ll sometimes call this type of application a gooey instead of GUI. The game is also graphical but uses fewer things like buttons and focuses more on a single window with custom graphics. When I say user mode application, I mean an application with no special privileges that you start normally. This includes just about any program you install and run on your computer. It does not include things like device drivers that the operating system gives extra permissions to be able to interact with your computer’s hardware. Most GUI applications spend their time waiting for events. There’s an event loop that runs over and over and each time, the application asks the operating system if there are any events that need to be processed. Every time you move the mouse, the operating system is sending your application mouse moved events. Whenever you press a keyboard key, the operating system sends your application key pressed events. If you resize your application window, you get window resize events. The operating system sends lots of events that your application needs to handle or sometimes ignore. The point is that a GUI application waits for the operating system to let it know what’s happening and responds appropriately. Have you ever had an application either get too busy or confused so that it stops responding? The window will go blank white or show leftover images from other windows. The title bar might say “not responding”. And you have to force the application closed usually losing any unsaved work. This is what happens when an application stops handling the events that the operating system is sending to it. Sometimes, a poorly designed application will stop processing events for a while to do something else. Maybe it needs to request information from another computer and makes a blocking call to get that information. A blocking call is where the thread making the call stops to wait for the call to complete. This will result in an application that looks like it’s stopped responding to events. All it needs, other than a better design, is just a little more time to complete. The main thing to understand is that when writing an event-driven application, you need to respond to events quickly. There’s no specific timeline. Just don’t do anything that you think might take a long time to complete inside the event loop. Each time your application handles an ev
December 25, 2017
We all want to think big. But to get there, we need to think small. I’ve talked about this a few times, most recently in a 4 part series called, “Your Guide To Computer Programming.” Listen to episodes 166 through 169 for more information. I’ll go into a little more detail here about a minimum viable product or MVP for short. You might think of sports most valuable player when I say MVP. This has nothing to do with sports but knowing what your software MVP is will definitely increase your chances of creating a star. Listen to the full episode to learn more about minimum viable products and for an example of what MVP I choose for the text-based adventure game. You can also read the full transcript below. Transcript By this time, you’ve taken your vague idea and started filling in the details. You’ve gone past simple games and are ready to work on your big idea. In many ways, this is probably the hardest thing of all. What you need to do is figure out the absolute minimum your game can do that will still be fun and interesting. I’ve talked about this a few times, most recently in a 4 part series called, “Your Guide To Computer Programming.” Listen to episodes 166 through 169 for more information. I’ll go into a little more detail here about a minimum viable product or MVP for short. You might think of sports most valuable player when I say MVP. This has nothing to do with sports but knowing what your software MVP is will definitely increase your chances of creating a star. Normally, we think that the way to succeed is to surpass customer’s expectations, to create something so grand that no competitor can come close, to put all the final touches on a product until it’s perfect. Or if you want to succeed in your career, then you need to work extra hard, commit all your time and energy to your job, and go that extra mile. Why with all this thought about going beyond, would I suggest something that meets some minimum level. It seems to go against everything we’ve been taught. I mean, did your parents ever sit you down and tell you that you were doing too much and needed to slow down? That your grades were too high and you should aim for lower grades instead? Nobody ever suggests that we need to aim lower. And I’m not suggesting that either. Creating a minimum viable product is not about cutting corners and producing sloppy work. Just the opposite, actually. It takes time to build software and when you only have a limited schedule to work with, then you need to decide where to spend that time and energy. Trying to do too many things with your software will spread you too thin. Putting in another feature will take time away from fixing problems with features already included. This is why you actually end up with a higher quality product when you can focus your efforts where it really matters. And there’s another reason you should focus on an MVP. Things change. And you won’t know what customer’s really find valuable until your get their direct feedback. If you spend too much time on features you think are important only to find out later that the work was wasted, then not only did you delay getting feedback, you now need to backtrack to work on the things you should have been working on. This is why an MVP fits into an agile methodology. You work on the smallest thing possible that has value to your customers, get feedback faster, and can use that feedback to figure out what to work on next. How do you determine what you should focus on first? That’s the hard part. Because it’s natural for us to want to create something bigger and better than anything else. You need to pick just one thing though. How you pick this one thing is up to you. Maybe you surveyed your potential customers and they responded with a clear answer. Maybe you’ve identified a flaw that exists in other similar products. However you decide, the poi
December 18, 2017
You can take advantage of libraries and frameworks. Listen to the full episode to learn how libraries are different from frameworks and where game engines fit into all this. You can also read the full transcript below. Transcript Don’t try to do everything yourself. There’s some really good libraries and frameworks that you can use for free or pay only when your game is successful. Again, this applies to any software project. If there’s code that you need to write to get your project to do something interesting, then there’s a good chance that somebody else has already written the code that you can use. Need to play some sound effects during your game? There’s code available to do that already. Need to connect your game to other computers or to server computers to coordinate multiple players? There’s code for that already. Need to load image files and draw the images to the screen. Yep, there’s definitely code for that already. This is the type of code that you don’t want to be writing anyway. It has nothing to do with the specific story in your game. It has nothing to do with how your game is played. Or what rules you decide are important. You need to be focused on the things that make your game unique and fun to play. There’s enough work for that already. Avoid writing code that not only has somebody else already written but has probably done a better job. Now, that’s not to say you couldn’t do just as good of a job. but there’s usually a lot of little details involved that we don’t normally think about until that becomes our focus. None of us has the time or energy to become expert in everything. I might have told this story before but it fits well here. I used to have a book about electrical engineering. It was an old book from the early 1900’s. I forget now if it was 1913 or maybe 1906. Somewhere around that time. The interesting thing is that this book contained all the world’s knowledge about electrical engineering at that time. There was even a chapter about how to pour concrete! I studied electrical engineering in college and I can saw that there were no classes about concrete or general construction. But back in the early 1900’s, knowing how to pour concrete was needed for electrical engineers when placing utility poles in the ground. Or maybe when anchoring transformers to the ground. Today, there’s no way a single book can cover a broad subject such as electrical engineering. There’s too much for a single person to learn at all no matter how many books are involved and no matter what topic. We have to specialize. We have to pick a narrow niche and become really good at that one thing. When it comes to programming, niches such as sound processing, video processing, and networking all have experts who’ve studied the problems and have written libraries that hide all the details so it looks easy from the outside. That’s perfect. If you try to do all this yourself, you may not finish at all. And if you do, your code probably won’t be able to accomplish nearly as much. And it’ll probably have bugs caused by not spending enough time to learn all the details. When you have code that you include in your project to help you with a focused need such as playing audio in your game, this is called a library. We normally think of libraries as a place containing lots of books. A software library will contain classes and methods you can use in your code just as if you had written the classes and methods yourself. You might need to adapt a little to the author’s way of thinking. Maybe the library names the methods with different uppercase letters than what you use in the rest of your code. Maybe the author has an interesting way of passing method arguments that’s different than your own style. And things get more involved when you start using multiple libraries and each library has its own
December 11, 2017
What role will data play in your game? It doesn’t matter what type of application you’re building. Data will be important. You need to decide what parts will be driven by data and what will be driven by code. Now, it would be possible to specify in code that a tree should be located at some location. Maybe the constructor for the tree class takes coordinates right from the beginning. There’s probably going to be lots of trees in the game. So the code could go through a loop and read coordinates from an array of data points specified in the code. This is using data but listen to the full episode for a better way. You can also read the full transcript below. And if you like this podcast and want more, then you can select a reward level at Patreon. Every patron gets access to a special episode each month and you can even help choose the topic. Click the link at the top of the page to “Become a Patron.” Thank you! Transcript It doesn’t matter what type of application you’re building. Data will be important. You need to decide what parts will be driven by data and what will be driven by code. But first, why is this important? I mean, you’re programming so shouldn’t everything be written in code? And what do I mean by having parts of your application driven by data? Data by itself is just a bunch of numbers or maybe some strings, dates, and flags that can tell if something is true or false. You can’t build an application of any kind with just data. You wouldn’t be able to make any sense of it. There needs to be code. But you don’t have to do everything in code. As an example, consider the maps that I described in the previous episode. These aren’t the map data structure but a map showing the location of towns, roads, trees, and mountains in a game. Now, it would be possible to specify in code that a tree should be located at some location. Maybe the constructor for the tree class takes coordinates right from the beginning. There’s probably going to be lots of trees in the game. So the code could go through a loop and read coordinates from an array of data points specified in the code. This is using data but I’ll explain a better way in just a moment. Another way using just pure code is to calculate the coordinates each time a tree is created. This could be done using a random number generator and you would end up with trees spread through your map as if you had manually specified the placement of each tree. The player probably won’t notice the difference. Unless, of course, you manually placed trees in a recognizable pattern. It would be hard to duplicate a specific pattern using only a random number generator. If you want some trees to be lined up neatly in a row, then you’ll have to either place them there by specifying their coordinates or write code that takes a line and a spacing and drops trees onto the line at regular points. The problem with all this is that code a lot more difficult to change than just changing some list of numbers. If your trees are placed in your world by code and you want to rearrange them, then you have to write new code just for that purpose. But instead, if your code just loops through a list of coordinates and reads the values where each tree should be placed, then it’s easier to rearrange the trees. I mentioned just now that you could put this list of coordinates in your source code. You can declare an array of ints and give that array a bunch of values that you type right into your source code. This is certainly a lot better than writing thousands of methods like createTreeAtFrontGate, createTreeAtGardenCenter, createTreeAtGardenLeftEntrance, etc. Instead you have a method called createTrees that takes as one of its parameters an array of x and y coordinates. Each coordinate would be an integer number and you give the entire list of coordinates to the method and it just goes through each coo
December 4, 2017
How do you make your idea more specific? It’s hard to make progress on a vague idea. This reminds me of a popular book called Getting Things Done that says we don’t work on projects, we work on tasks. If you have a lot of unfinished tasks on your do-to list, maybe it’s because they’re not actionable. It causes us more stress and internal struggle when we keep reminding ourselves about these projects but don’t take the time to list out the actual work needed. The same thing applies to programming. Building a game is hard enough. You don’t need to add more problems by continuing to think of it as a single task. Listen to the full episode or read the full transcript below for more examples and some advice for knowing when you’ve reached a level that can be coded. Transcript I like to use game development in a lot of examples because it’s fun and helps keep things interesting. You can use the concepts I’m explaining here for any type of software project. This episode will give you some tips for making your idea concrete. That’s just a way to say an idea is specific. It’s hard to make progress on a vague idea. This reminds me of a popular book called Getting Things Done that says we don’t work on projects, we work on tasks. If you have a lot of unfinished tasks on your do-to list, maybe it’s because they’re not actionable. One example from the book was cleaning the garage. Is there a specific action you can take that will result in a clean garage? If so, then that should be your task. For example, sweeping the floor is something you can do. Most likely, you’ll need to do several things. By being very clear about what those things are, they become actionable. And some actions might depend on others. Maybe you need to buy a broom before you can sweep the floor. It causes us more stress and internal struggle when we keep reminding ourselves about these projects but don’t take the time to list out the actual work needed. The same thing applies to programming. Building a game is hard enough. You don’t need to add more problems by continuing to think of it as a single task. You might hear some people say that you need to create a game design document or GDD for short. My opinion is that’s not very agile. It might work if you’ve built a similar game before. But for most of us, we need to accept that things will change because we don’t have all the answers at the beginning. Spending time writing a document can be valuable but it’s hard to avoid working on a design that will later be thrown away because it’s not needed anymore. If you do create a document, then I recommend keeping to just one or two pages at first. Programming in many ways is more of an art than science. It’s not at all like what a civil engineer goes through when designing a bridge. If you try to enforce a document just because you’ve spent so much time on it, then you’re falling victim to the sunk-cost fallacy. I’ve mentioned the sunk-cost fallacy before. Listen to the QA Friday episode from 2016-Jul-22 for more information. When I started the text-based game, I knew that there would be a map of some kind. It’s a top-down game so the view always needs a map. Now, thinking terms of a map is like thinking about cleaning a garage. Even this is too vague. You can’t program a map. So I started listing out what could appear on the map. At first, this was a jumbled mess of ideas. That’s actually a good way to start. Just get everything written down that you can think of and then start looking for patterns and similarities. This led to questions like: • Is there any difference between a forest and a bunch of trees? • What about between a road and a path? • Should I call something a desert or just show a bunch of sand? • Is there more to a town than just a bunch of buildings? • How will the game deal with unk
November 27, 2017
You have a vague idea for a new video game. Where do you begin? I’m not a painter but I have to imagine that this is similar to any creative work of art. Where do you begin? A lot of people get stuck here and never make progress. You have to start somewhere. It’s got to be a hard thing to paint. What do you do if you make a mistake? I’m sure some things can be covered up. If the paint is still wet, then you might be able to scrape it off the canvas and try again. Like I said, I’m not a painter so I don’t know. These are just my thoughts. And it’s got to be a lot harder to cover up a mistake once the paint has dried. This is one of the reasons that I like software development. It’s a lot easier to recover from mistakes. And we can start a new project by copying some code from an earlier project. Imagine starting a painting where the basic structure is copied from another painting. You can bring over the best parts and leave out anything that doesn’t apply or was a mistake. Of course, there’s a lot more to beginning a new video game project than just this. And there’s a lot more than I can include in just one episode. Listen to the full episode or read the full transcript below to learn more and make sure to subscribe to the podcast, so you’ll automatically get a new episode delivered to your podcast app each week. Transcript I’m not a painter but I have to imagine that this is similar to any creative work of art. Where do you begin? A lot of people get stuck here and never make progress. You have to start somewhere. You could begin by researching and learning everything you can. If you want to paint, then maybe you could learn all about colors. Then study all the famous paintings to learn their style. Then take drawing classes. You might find that you end up doing anything except painting. You tell yourself that you’re not ready yet. There’s still more to learn. And after spending months or even years preparing, most people just give up. It’s too hard. Or they lose interest. And for those who do finally squeeze some paint out of the tube and swirl it around and mix it with other colors and then dip the brush and apply that first stroke of paint, the experience can be exhilarating. Yet strangely, a lot more give up here too. Their first attempt at making a masterpiece looks nothing like the paintings in the museums. Maybe they’re just not cut out to be a painter. It’s got to be a hard thing to paint. What do you do if you make a mistake? I’m sure some things can be covered up. If the paint is still wet, then you might be able to scrape it off the canvas and try again. Like I said, I’m not a painter so I don’t know. These are just my thoughts. And it’s got to be a lot harder to cover up a mistake once the paint has dried. This is one of the reasons that I like software development. It’s a lot easier to recover from mistakes. And we can start a new project by copying some code from an earlier project. Imagine starting a painting where the basic structure is copied from another painting. You can bring over the best parts and leave out anything that doesn’t apply or was a mistake. If you’re just starting programming and this is your first game ever, then my advice is to start out with a simpler game. Go as simple as possible. I’m talking about something like tic-tac-toe or wordguess. Listen to episodes 13, 14, and 15 for more details. You can also get a 5-day email course that shows you how to build a word guessing game by going to takeupcode.com/wordguess or by texting the single word, wordguess, to the short number 44222. There’s no right answer to how to begin writing a video game or any software project. But you have to get started and break open that tube of paint early on. Let your initial mistakes happen while you still expect them to happen and you’ll be less disap
November 20, 2017
When is it okay to switch to a different project? This is something that I struggle with all the time. I have so many ideas and so little time. There’s no way that I can get to everything. But it gets worse. Because new ideas keep arriving all the time. This episode is about some of the insights I’ve learned about how to finish a project and when to walk away. This is a balance that you’ll have to figure out for yourself. I can only share my thoughts and what’s worked for me. Listen to the full episode to hear my insights and learn what you can do to get more things finished. You can also read the full transcript below. Transcript This is something that I struggle with all the time. I have so many ideas and so little time. There’s no way that I can get to everything. But it gets worse. Because new ideas keep arriving all the time. I’m definitely not the type of person who has to finish everything that I start. And I’m okay with that. But just like how I have to watch my weight, I also recognize that I have to be careful about starting a new project. This episode is about some of the insights I’ve learned about how to finish a project and when to walk away. This is a balance that you’ll have to figure out for yourself. I can only share my thoughts and what’s worked for me. First of all, we really do need to finish things. I don’t mean they need to be complete. Hardly anything is ever fully complete and will change over time. You have to get that first version done enough so it can be released. This is hard and one thing that will help is to focus on the absolute minimum that you can provide that still has value to somebody. If you’re going to take a break from a project, getting past that first finish line is one of the best places to aim for. Even if you have to change your list of features, it’s much better to deliver a smaller set of features at a high quality than more features that may not be needed. Let your customers tell you what they want next. This leads to multiple finish lines. Completing a project that nobody else sees or knows about is normally not a good thing to do either. You’ll get the most benefit when you make it your goal to not only finish a project but release it as well. What about ongoing projects? Do all projects have to have a complete state? This podcast is a good example of an ongoing project. There’s no end in sight. In fact, my list of possible future topics just keeps growing. The way I’ve found that works best is to be in constant release mode. I make a point to write, record, and release a new episode each week. To me, it doesn’t matter if a project has a definite end or is ongoing, the key is to get something done and get it in the hands of a customer as quick as possible. If you do decide to stop work on something, make sure it’s a conscious decision. Put the previous project away. As long as you leave it out, then it’ll just lead to a sense of overwhelming and depression. If you’re worried that you might forget about a good idea unless you start work on it right now, then do what I do and keep a list of future projects. It’s okay to spend an hour or so to write down your thoughts so you can come back later. And if you decide that the new project is better or more important than something you’re already working on, then it helps to list reasons for the change. The whole point is to make a decision one way or the other. I’ve mentioned something called the sunk-cost fallacy before. Listen to the QA Friday episode from 2016-Jul-22 for more information. The main idea of the sunk cost fallacy is that we often let past events and decisions drive our future. If you’re almost done with a project and a new idea comes along, just make sure to ask yourself if the new project can wait a bit. If you can finish the current project and release it, then that’s
November 13, 2017
Cascading Style Sheets let you manage how your HTML looks so you can keep your HTML focused on the content. To get the most benefit from cascading style sheets, you need to start with the HTML. Make sure that you’ve done four things: Create meaningful HTML with all the proper tags. If you’re writing an article, then use an article tag. Listen to episode 198 about semantic meaning for more information. Don’t worry about styling your HTML directly. If you display it in a browser now, it’ll look boring and plain. That’s actually good because it’ll let you do all the styling in the CSS files. By the way, if you’ve ever visited a website and the content was all jumbled up with a plain background and simple black text, then what likely happened is that the CSS files failed to load. Maybe the web server was too busy at that moment. Usually, refreshing the page will help unless there’s a bigger problem. Identify important single elements in your page. If you have a single search button and maybe a single login form, then make sure they have unique identity attributes. Identify the common groups of elements with class attributes. These don’t have to be unique and elements can have more than one class. The class attribute itself can’t be repeated inside an element. But it can have multiple values inside the value quotation marks. Each class name should be separated with a space. This means that you can’t include spaces in your class names or you’ll end up declaring separate classes for each word. Listen to the previous episode for more information about CSS especially if you want to better understand the difference between content and presentation. Continue listening to this episode to learn more about how CSS applies styling to specific parts of your HTML using rules that consist of selectors and descriptors. You can also read the full transcript below. Transcript To get the most benefit from cascading style sheets, you need to start with the HTML. Make sure that you’ve done four things. • First, create meaningful HTML with all the proper tags. If you’re writing an article, then use an article tag. Listen to episode 198 about semantic meaning for more information. • Second, don’t worry about styling your HTML directly. If you display it in a browser now, it’ll look boring and plain. That’s actually good because it’ll let you do all the styling in the CSS files. By the way, if you’ve ever visited a website and the content was all jumbled up with a plain background and simple black text, then what likely happened is that the CSS files failed to load. Maybe the web server was too busy at that moment. Usually, refreshing the page will help unless there’s a bigger problem. • Third, identify important single elements in your page. I’ll explain elements in just a moment. If you have a single search button and maybe a single login form, then make sure they have unique identity attributes. • And fourth, identify the common groups of elements with class attributes. These don’t have to be unique and elements can have more than one class. The class attribute itself can’t be repeated inside an element. But it can have multiple values inside the value quotation marks. Each class name should be separated with a space. This means that you can’t include spaces in your class names or you’ll end up declaring separate classes for each word. Listen to the previous episode for more information about CSS especially if you want to better understand the difference between content and presentation. Alright, elements. I’ve left this topic out for long enough. I might sometimes say tag when I mean element. The two concepts are similar. Episode 196 describes how markup works and introduces tags. I’ll summarize just a bit here so you can understand the differences between a tag and an element. Tags usua
November 6, 2017
Cascading Style Sheets let you manage how your HTML looks so you can keep your HTML focused on the content. I’ll explain how to use cascading style sheets, or CSS, to handle the presentation while your HTML can then focus on the content. How does all this work and why do you need CSS to do it? Listen to the full episode or read the full transcript below to learn more. And if you like this episode and want more, you can click the link at the top of the page to become patron and choose your reward level. Transcript Have you ever seen an all-in-one tool? A hammer that dispenses nails, uses the handle to measure, and even has a built-in light so you can work in the dark? Okay, I’ve never seen one quite like that before but you know what I’m talking about. Tools like this might be somewhat useful but a well-made hammer that does just one thing will do a better job. The same thing applies to HTML. The difference is that you get to choose how you use it. Will you use HTML like an unbalanced hammer that does everything and keeps breaking or will you use it for just one thing and let it do that one thing exceptionally well? I’ll explain how to use cascading style sheets, or CSS, to handle the presentation while your HTML can then focus on the content. First, what do I mean by content and presentation? Let’s say you have a web page for a blog article. All the text in the article, the images, even the comments make up the content. The author information, title, links to other pages are also content. Now how that content looks is presentation. Is the title bigger than the article text? Bold? What color? The placement of the content is also part of the presentation. So is it centered? Is an image on the left side of the page or on the right? Some aspects of the presentation can change too. Do you want an image to get bigger when the user moves the mouse over it? That’s presentation. How does all this work and why do you need CSS to do it? CSS hasn’t always been available and web pages were able to be presented just fine before. But this gets back to the all-in-one tool. If you mix your presentation in with your content, then whenever you want to change the way your site looks, you’ll have to change all your HTML. If you have hundreds or thousands of HTML pages, this becomes too difficult and time consuming. Not to mention error prone. But there’s another benefit to how CSS works that’s not possible when using only HTML. Even if you can get your HTML looking exactly the way you want it, you can’t add layers to it so that you can have it look one way and then another by overriding the presentation. This is what the C in CSS means. Cascading styles allow you to start with broad rules about how your HTML should look and change those rules as you get more specific. You might be able to say that you want all hyperlinks to have a certain look but hyperlinks inside paragraphs should be treated special and look a bit different. You don’t have to throw away everything about how hyperlinks should look. You can change as much as you want whenever the situation calls for it. This is why I wanted to explain trees and hierarchies before continuing with HTML and CSS. I’ll explain more in part 2 of this episode. Listen to the previous episodes to learn more about trees. Instead of styling a paragraph directly in the HTML, you can write a rule in CSS that specifies how all paragraphs should look. Then if you want certain paragraphs to look different, think about what’s special about them. Do some paragraphs have special meaning in your page? This special meaning is content and belongs on the HTML file. How that special meaning translates into special presentation belongs in the CSS. In order to use CSS effectively, you have to start with the HTML and make sure that it identifies HTML tags with meaning. This starts with first choosing the right tags in the first place. Don&#
October 30, 2017
An abstract syntax tree can help your code make sense of what a user provides. Listen to the full episode as I describe how to build an abstract syntax tree starting with a simple idea and then how that idea needs to change. You can also read the full transcript below. Transcript Have you ever had somebody give you instructions that were all jumbled up and barely made any sense? Maybe they would forget things and go back to an earlier point to clarify. Or maybe they would give you instructions that were unnecessary. A good way to make sure you understand is to try to make sense of what the other person is saying and then repeat the instructions. You can make things more organized and your friend will be amazed at how simple and straightforward the instructions have become. In a way, what you’re doing is creating an abstract syntax tree. Usually we think of something abstract as being hard to visualize and understand. Something that has no form and is more of an idea than anything else. Well, I’m not sure of the origin of the term abstract syntax tree, but the way I understand it is that you’re building a very specific tree that abstracts your code away from the confusing world of information provided. So instead of thinking of them as abstract, syntax trees, I think of them as abstract syntax, trees. Notice where I put the mental pause. To me, it’s the syntax that’s abstract and then the tree comes along and makes things better. Let’s say that I ask you to solve 5 + 3 * 2. You could add 5 and 3 to get 8 and then multiply by 2 to get 16. Or you could first multiply 3 by 2 which gives 6 and then add 5 to get 11. Given just the original formula of 5 + 3 * 2, the correct way to do this is to realize that multiplication has a higher order of precedence than addition and should be done first. That means 11 is the correct answer. You can change this by adding parentheses around 5 + 3. Since parentheses have a higher order of precedence than multiplication, then the 5 + 3 will be done first and the answer will be 16. What happens if you add parentheses around the 3 * 2 part? Well, all this says is that parentheses has a higher order of precedence than addition. The parentheses won’t change anything since the multiplication already has a higher order of precedence than addition. You can still add them if you want in case you want to be extra specific. But they’re not needed. Once you understand the order that things should be done, whether by using parentheses or not, you can build an abstract syntax tree which will make it clear exactly what should be done. I’ll walk you through the design considerations and you’ll learn how your understanding of a problem can change over time. Let’s examine the normal case without any parentheses in this episode. You’ll need code that can read the input provided. This is called the parser. The parser cares about things like parentheses and should also catch errors. So if the formula said 5 + + 3 * 2, then the parser should return an error because the extra plus sign doesn’t make any sense. Now it may not return an error right away the moment it sees the second plus sign. But it should eventually figure out that something’s not right. Okay, the first thing that parser can do is add the 5 to a stack. Because the parser needs to read the input in a single direction, it doesn’t know what to do with a 5 just yet. So it remembers it by adding it to a stack of values. Listen to the previous episode for more information about stacks. This is where you can learn to start thinking like a programmer by coming up with rules to follow. As humans, we know that the processing just began and that nothing came before the 5. We also know that there’s more to this problem than just the 5. This knowledge can trip us up when programming. Because remember the computer is just following exactly what we tell it to do. We never t
October 23, 2017
You can use a stack when you need to remember something and only ever need the last thing. If you need to access any item in a collection at any time, then a stack is not going to work. I didn’t explain stacks before because in a way, it’s like a restricted vector. Make sure to listen to the earlier episodes 39 through 46 for more information about other collections. You’ll want to use a stack whenever you need to stop what you’re doing, remember everything so you can come back to your paused task later, and then go do something else. Make sure to listen to the full episode or read the full transcript below for examples and more details. And if you like these episodes, consider supporting the podcast by becoming a patron. The link is at the top and bottom of this page. For just $1 per month, you can get an additional podcast episode available only to patrons. The first patron episode begins Nov-2017. Transcript If you need to access any item in a collection at any time, then a stack is not going to work. I didn’t explain stacks before because in a way, it’s like a restricted vector. Make sure to listen to the earlier episodes 39 through 46 for more information about other collections. You’ll want to use a stack whenever you need to stop what you’re doing, remember everything so you can come back to your paused task later, and then go do something else. In a way, a stack is sort of unfair. Imagine if a restaurant used a stack to keep track of arriving guests to determine who gets a table next. You reach a restaurant called The Full Stack and find it almost empty. But the receptionist carefully takes your name and let’s you know that you’re first in line. But before you get a table, some more guests arrive. And then some more. You’re really glad that you beat the crowd. But then why haven’t you been seated yet? Maybe they forgot about you. It happens. So you go back to the receptionist who tells you not to worry, you’re still first in line. Then you notice something. A person wearing a green jacket arrives, signs in, and almost immediately gets called for a table. What’s going on? You go back to the receptionist who explains that the restaurant is called The Full Stack because of their innovative new registration system that uses a stack. With this new system, the last guest to arrive is the next to get a table. Obviously, The Full Stack restaurant won’t be in business very long. But that doesn’t mean that a stack is useless. There are times when it’s exactly what you need. A stack gives you two basic operations, push and pop. When you call push, you’re adding something to the top of the stack. Think of it like a deck of cards. Pushing will place a new card on top of the stack. The other operation is pop and this removes whatever is currently on top of the stack. Now a deck of cards will let you pick up several cards at once and remove a card from the middle. A stack won’t let you do this. Not because it can’t. After all, a stack will probably just be using a vector to store its items. That means that it has access to get to any item in the vector. All of this is private to the stack though. As far as you’re concerned, you can only work with the top of the stack. When that’s all you need or want anyway, then why use a vector when you can use a stack with just the methods you need and nothing else? Episode 39 explains the array collection which is similar to a vector. The reason I’m discussing stacks now is because you need to understand them in order to understand another type of tree. I was going to discuss abstract syntax trees and was about to refer you to the earlier episode about stacks when I realized there was no episode about stacks yet. Because stacks never need to add or remove items from the beginning or middle, then they don’t have to worry about shifting items around. A stack can
October 16, 2017
What other things can trees help you to solve? When thinking about trees, I usually put them in two groups. The first are trees with arbitrary structure. The second group of trees have a well defined structure. Listen to the full episode or read the full transcript below for more details and examples. And if you’re interested to see actual code for things like this, then consider supporting the Take Up Code podcast on Patreon. Once we reach the video goal, I’ll start making short videos that show code. A tree will make for a good video and will be included at some point. Just click on the link at the top to Become a Patron. For a dollar a month, you can get access to extra podcast episodes. Transcript When thinking about trees, I usually put them in two groups. All trees are composed of nodes with a clear concept of parent nodes and child nodes. One node in the tree serves as the root and has no parent. The child nodes can have their own child nodes. Some trees might be limited in how many child nodes any particular parent node can have or where nodes can be placed. It’s these limitations that I use to group trees. The first are trees with arbitrary structure. This is like the grocery store categorization from episode 203. You get to decide where things exist in the tree. Or that can also mean that somebody using your app gets to decide on the tree structure. I mean, an outline tool wouldn’t be very useful if it came with one and only one outline built-in. The user needs to be able to create their own outlines and you may want to keep track of the data as a tree inside your app. The benefit of this type of tree is that things stay exactly where you put them. Have you ever had a messy room but still knew where everything was? Different types of things such as papers, books, clothing, money, and even your phone are exactly where you put them. There’s no need to compare things. They are where they are and that’s all. You can put things in this type of tree when the placement needs to be completely under your control. It’s the placement that determines the parent child relationship. By placing your phone on your desk, the phone becomes a child of the desk. There’s order. But it’s only understandable to you or to the person using your app. Usually, this type of tree is creative and allows an unlimited number of items to be placed under each node. I say under because usually when drawing a diagram of what a tree looks like, child items are drawn under the parent. Your code will need to have some way to figure out the type of each item but the tree itself will need to treat everything the same. How can you treat everything the same? How can you treat all the things in a messy room as if they were all the same? Simple. Just find some concept that everything shares. For the messy room, and all the things I listed, about the only thing I can think of that all these things share is that they’re all physical objects. Money might be an abstract concept but a coin or a dollar bill is a physical thing. Everything in that messy room has a name, a color, a size, a weight, and materials that it’s made from. When you want to store a variety of items like this, then you can have a class representing physical objects and it’s this class that the tree knows about. For an outline app, each item is just a block of text. Or if you want a more full-featured outlining app where the user can add links to web pages, audio notes, pictures, etc. then you’ll want to do something similar to the messy room and create a class to represent the general concept of an outline node. It’s up to you then if you want to use inheritance or some other mechanism to represent the specific types of content that can be added to the outline. The point for all these is that the tree holds a structure that gets built with few or no rules at all. When I was first learning about programming and e
October 9, 2017
Have you ever created something and then thought about how bad it was? What did you do? Most of us would hide it or even destroy it. Or maybe just keep working on it trying to make it perfect. I struggle with this all the time. It’s really hard to release something. But that’s exactly what you need to do. Let other people see it and try it. It won’t be perfect but instead of fixing what you think needs to change, let others tell you what they would like changed. This is already hard enough. But you want to know what’s even harder? Try coming back to something you worked on years ago. Would you still be able to resist the urge to just make a few changes first? This is an episode where I describe this and how I handled it. Listen to the full episode or read the full transcript below for more details. And don’t forget to subscribe to the podcast on your favorite podcast app on your phone so that you’ll get new episodes delivered to you automatically. Transcript Back in 2013, I decided to start teaching programming. A few things came together then which prompted the decision. I’d been using the C# language to program since about the year 2000. Before that and up to about 2003, was C++. And I realized that the C++ language had recently went through some much needed changes. This is known as C++11. And more changes were coming in 2014 which became known as C++14. Now we’ve got C++17 and eventually C++20. The C++ language was getting its groove back and I wanted to keep up-to-date. When I’m learning something, one of the things I like to do is teach it to others. That’s when you realize how much you actually know about a topic. So I decided to teach C++. I also like video games. Although I rarely get much time to play. Why not fix that by creating video games and using the code to teach at the same time? What should I call this effort? Well, since my favorite type of game is fantasy role playing games with swords and magic, I came up with the name Fantasy Development, or just FantasyDev for short. The next question was who should I teach and then how? I wanted to help somebody move into development who might not have thought such a thing was possible. Somebody who already knew a few things about computers. Just not how to program them. People doing technical support seemed like the right fit. They already have a position with a company and know the development team. All they need is to learn how to program and some confidence to approach the hiring manager for an interview. I knew that the worst thing I could do was to go off on my own and produce the ultimate programming course in isolation. To lock myself away until it was complete and announce it to the world. Why would this be a bad idea? Well, we need feedback. Would an airline pilot be able to come anywhere close to landing a plane at the destination by starting out with a general idea of where the plane needs to go and then never looking out the window and never looking at the gauges? Absolutely not! The plane would never even find the runway to takeoff at all. I needed to conduct the classes live with real students who could ask questions. So that’s what I did. And I recorded the classes so that I could turn the videos into an online course. I did this for about nine months holding a two hour class every other Saturday afternoon. It was a lot of work. First, I had to prepare two hours of material. To give you an idea, I can sometimes spend two hours or more just preparing my thoughts for a ten minute podcast. Don’t get me wrong, I’m not complaining. I enjoy it and actually learn from the experience. But it’s still a lot of work. Then, of course, is the class itself. My voice at first could barely keep going for two hours. And I sounded scratchy for a day or so later. Then, there was the unexpected task of editing the videos. I’m not talking about removing stray sounds. That’s actu
October 2, 2017
Why should you consider using trees? You can find more information about trees in some of the earlier episodes. I’ll try to not repeat the same things here. Episodes 41 and 42 discuss binary trees and left-child right-sibling trees. Episode 54 explains recursion and uses a tree in the examples. And episode 66 explains the composite design pattern which can be thought of as a tree. Listen to these episodes for more details. Trees are great at organizing items. Anytime you have a situation where organization can start out in broad terms and then get more specific, then a tree is great. Listen to the full episode for more examples and insight, or you can also read the full transcript below. And don’t forget to sign up to be a patron of the podcast by clicking the button at the bottom of the page and selecting your reward level. It doesn’t cost much and you can get some awesome benefits such as actual code reviews to help you write better code. Who knows, maybe you might even find out that your code should be using a tree or something else instead. Transcript You can find more information about trees in some of the earlier episodes. I’ll try to not repeat the same things here. Episodes 41 and 42 discuss binary trees and left-child right-sibling trees. Episode 54 explains recursion and uses a tree in the examples. And episode 66 explains the composite design pattern which can be thought of as a tree. Listen to these episodes for more details. A lot of the earlier episodes break about halfway through for a sponsor message. That sponsor is Take Up Code and I used the time to promote live classes. I still organize live classes and that’s a great way for you to supplement your training. Some topics are best explained with actual code instead of just words. There’s a new way that you can get some great extra benefits and help support this podcast at the same time. I just setup a Patreon account with several reward levels for you to choose from. You can get design reviews of your project ideas, code reviews, and participate in game development sessions each month. You can find a link to the Patreon page at the bottom of each Take Up Code website page. There’s also a chance for you to win a free hour of tutoring. And you’ll have the best chances of winning the tutoring right now when the number of patrons is small. I call it tutoring, but really, the main thing is that you can get an hour of some serious experience applied to your project. So visit takeupcode.com today, click on the button to become a patron, and select your reward level. I thank you for your support. Alright back to trees. Instead of going into more theory about how trees work, at least for now, it’s good to ask why you would want to use a tree in the first place. What problems do trees help you to solve? And what difficulties would you face if you tried to avoid them? Trees are great at organizing items. Anytime you have a situation where organization can start out in broad terms and then get more specific, then a tree is great. Maybe you have a store that sells items. You can group them into big top-level groups such as food, furniture, and tools. Then each of these can be further divided into smaller and smaller groups. So maybe you have food, then vegetables, then grains, and finally wheat. Or you can approach the problem from the other direction and think about where you could put a ruler. It’ll be in tools, certainly. But where in tools? Well, that depends on how many different kinds of tools you have or think you might need to organize. If the only tools that your store sells are rulers and saws, then maybe it doesn’t matter and you can just put them both in tools and be done. But when you start getting so many tools that it becomes hard to find what you’re looking for, then that’s when you need to add extra organization levels to your tree. Maybe you can start by splitting all the tool
September 25, 2017
Before exploring HTML and CSS further, you’re going to need to understand graphs, trees, and hierarchies. These concepts apply throughout programming and are not limited to just HTML and CSS. But as I was trying to figure out what topic to explain next to you, I realized that you’re going to need to understand these topics in order to master HTML and CSS. You’ll be glad you took the time to understand these when you encounter them again in your code. All trees are actually graphs. But not all graphs can be called trees. There are four special conditions that a graph must follow in order to be considered a tree: There can be no cycles in a tree. Every vertex represents a node that is the root of a subtree. . Every two nodes in a tree are connected by exactly one path. . A tree is fully connected and has exactly one less edge or connection than nodes. So how do hierarchies fit into all this? A hierarchy is a tree with a couple extra properties: The first is inheritance either up or down the hierarchy. The second property of hierarchies is that they consider roles. Make sure to listen to the full episode for more details and examples and subscribe to the podcast so you’ll get future episodes automatically. You can also read the full transcript below. Transcript These concepts apply throughout programming and are not limited to just HTML and CSS. But as I was trying to figure out what topic to explain next to you, I realized that you’re going to need to understand these topics in order to master HTML and CSS. You’ll be glad you took the time to understand these when you encounter them again in your code. Let’s get started. There’s a lot to cover and as I was brainstorming, my notes quickly filled up several pages. This episode will be an introduction focused mainly on comparing graphs with trees, and then with hierarchies. I’ll go into more details in future episodes. I always like to learn new topics by comparing and contrasting them together and with what I already know. You might also benefit from this. Our brains work by associating things together. We think of something and that brings up other thoughts of things similar in some way. This makes it easier to remember something if there’s many different ways to get to whatever it is you’re trying to remember. So whenever you want to learn something new, it’s always a good idea to link it into your thoughts in many different ways. Thinking about how something relates to things you already know either through similarities or through differences is a great way to improve how fast you can learn something. It’ll also improve your ability to remember it later. That’s why I like to give you examples of things you can relate to when explaining new concepts. You might forget some of the details and that’s okay. You can always look those up later when needed. Having a firm grasp of the basic concepts is important though to help guide you as you refresh yourself on the details. The topics today are actually very related to everything I’ve just said. That’s probably why I went off on that sidetrack. Whenever I think of how things are related, I think of how our memories work on relations. And graphs, trees, and hierarchies are all about relations. A graph is the most general way to relate things. A good example is a map of world countries in Europe or of the states in a map of the United States. Think of how the countries are positioned so they touch one another. In order to go from one country to another, you can either go straight there or you can take a winding path through many countries. You might even pass through a particular country many times on your journey. And with modern airline travel, you can even go from one country to another even if they don’t share a border. Each country in this example is called a vertex in a graph. The connections between countries either di
September 18, 2017
Now that you can generate HTML, why would you ever want to go back to the old way of unchanging HTML? It takes some amount of work to generate HTML. I’m not talking about the work to program this. Make sure to listen to the previous episode for more information. I’m talking about the work that the computer itself needs to do in order to generate HTML. You might think your computer is busy when it’s starting up an application or when uploading or downloading files, but this is called input/output or just IO for short. The computer might be busy but the processor itself will usually be just sitting around waiting for the application to be read from your hard drive or for your files to be sent over the communication lines. IO can slow down what you’re trying to do but it still leaves the processor with time to cool down. For a normal request, the CMS will generate HTML and send to the visitor. The web server forgets all about the HTML that was just sent. If another visitor lands on the same page, then the same work needs to be done all over again. Anytime you find yourself writing or using code that does anything over and over again, that’s a good opportunity to cache the results. And setting up a reasonable cache system in your CMS will help your web server survive a massive increase in visitors. That extra work needed to generate HTML pages may not be much but if your site suddenly gets popular and you get millions of visitors, then your web server just won’t be able to keep up with the total extra work and your whole website will go down. Caching HTML pages for regular visitors will save a lot of work when they would have all gotten the same HTML files anyway. Listen to the full episode for more details including advice on when and how to invalidate the cache so that visitors will be able to get updated web pages. You can also read the full transcript below. Transcript It takes some amount of work to generate HTML. I’m not talking about the work to program this. Make sure to listen to the previous episode for more information. I’m talking about the work that the computer itself needs to do in order to generate HTML. We don’t feel this work because we’re not the ones running the code. The computer is doing all the work and other than sometimes noticing when the fan needs to turn on, we normally don’t think about how much stress we place on a computer. Maybe that’s because normally, we don’t require much from our personal computers. Just writing email or browsing the web leaves your computer idle most of the time. You can be the world’s fastest typist and the computer will still be sitting around waiting for each key to be pressed. Watching a DVD will put your computer under more pressure but it can still easily handle the work. Now, if you want to see your computer struggle, then try creating your own video. There’s a lot of work involved in rendering a video. You can also try compiling a large computer program. It all comes down to this. Your computer will be the most busy whenever it has to create something that needs a lot of calculations. You might think your computer is busy when it’s starting up an application or when uploading or downloading files, but this is called input/output or just IO for short. The computer might be busy but the processor itself will usually be just sitting around waiting for the application to be read from your hard drive or for your files to be sent over the communication lines. IO can slow down what you’re trying to do but it still leaves the processor with time to cool down. Generating HTML has the potential to be heavily IO bound but it does need some amount of work from the processor. It shouldn’t require too much work. And the time it needs to wait around for database calls to complete so it has the basic information it needs to put the HTML files together is more than enough to let
September 11, 2017
A modern website is more than just a collection of some HTML pages. If all you have is some basic information that you want to make available for the world to see, then you can create HTML files and put them in your website directory. You might have other files to put on the server too such as images and cascading style sheets. You can build a website like this and each time you add a new HTML file, you’ll have to link it into your website by finding an existing HTML file that you can modify to place a hyperlink to your new file. This is a lot of work and as your site gets bigger, the chances are greater that you’ll make a mistake and end up with broken links. These are links that no longer point to a valid file. If all you have is a few pages, then maybe this is all you need. But there’s two big problems with this type of website beyond just the extra work of trying to keep everything linked together. Both problems come back to the need to be able to offer different content to different visitors. That means the web server needs to be able to send different HTML files to different visitors. How do you do this? There’s nothing in HTML that allows this. Listen to the full episode or read the full transcript below for more information and how a language like PHP solves this by generating HTML for your website visitors. Transcript You can still build a website by connecting a server computer to the Internet with a fixed IP address and then running web server software on that computer. Most of the time, all this is done for you already when you sign up for web site hosting. All you have to do is place some HTML files in the directory provided for you. Or if you have more control over the server, you might need to do this part yourself and create the directories and configure the web server to start listening for requests. I’ll explain how this works in a future episode. For now, all you need to know is that the web server receives a request for a particular URL and knows where to find the files so it can return whatever was requested. If all you have is some basic information that you want to make available for the world to see, then you can create HTML files and put them in your website directory. You might have other files to put on the server too such as images and cascading style sheets. You can build a website like this and each time you add a new HTML file, you’ll have to link it into your website by finding an existing HTML file that you can modify to place a hyperlink to your new file. This is a lot of work and as your site gets bigger, the chances are greater that you’ll make a mistake and end up with broken links. These are links that no longer point to a valid file. If all you have is a few pages, then maybe this is all you need. But there’s two big problems with this type of website beyond just the extra work of trying to keep everything linked together. The first problem is this type of website offers the same content to every visitor. Maybe that’s okay for a restaurant website that just wants to post a menu online. Everybody can see the same menu. But it’s not going to work for an online banking website where each visitor expects to see account information specific to them. Or an online store where visitors want to interact with the store and buy things and expect to see a history of just the items they’ve bought. Anytime you want to let visitors view custom information, or create an account, or interact with other users, then a fixed set of HTML files will no longer work. The other problem is more for your convenience. Anytime you want to change or update your website, you don’t want to have to make changes to HTML files directly. And I’m not just talking about the difficulty of keeping everything linked together. You’ll either have to edit the HTML files directly on the server or edit them on your local computer and then upload the
September 4, 2017
You’ll learn how to use HTML to format your text into headings, paragraphs, and lists in this episode. Why do you need HTML to format your documents? Why not just use a text editor to write whatever you want to appear on a web page and save it in a plain text file? Will this work? And what problems will you encounter if you try this? First of all, it will work. Sort of. You can create content that you want to display and put that content on a web server. With a text file, you’ll be able to display separate paragraphs of text and you can even use tabs to indent some text. That’s about all the formatting you can do. Want a section break between topics? Well, you can always type in a bunch of dashes or maybe equal signs if you want to be extra fancy. Want a bulleted list of items? Well, you can always start each paragraph with a star character. That sort of looks like a bullet point, right? Want different sizes of text? Different colors? Different placement? Want links so visitors can navigate to other pages? Sorry, the browser just won’t interpret your text file like this. You’ll need to use HTML to add formatting and you can listen to the full episode to learn how to format headings, paragraphs, and lists. You can also read the full transcript below. Transcript Why do you need HTML to format your documents? Why not just use a text editor to write whatever you want to appear on a web page and save it in a plain text file? Will this work? And what problems will you encounter if you try this? First of all, it will work. Sort of. You can create content that you want to display and put that content on a web server. The web server doesn’t care or know anything about the content. Or, I should say that it doesn’t have to know anything about the content. Sometimes, you do want the web server to get involved and open your files and change them around before sending them to a browser when requested. I’ll explain when this is useful in a future episode. You have to remember that the way the World Wide Web works is on demand. Servers, don’t just start sending you web pages on their own. You have to first open a browser and visit a web page. Visiting a web page really just means that your browser makes a request for a file from a server at a particular URL and then displays the contents of the requested file once it arrives. Listen to episode 156 for more information about URLs. When your browser receives a file, it has to know what to do with that file. And for some types of files, it will have no idea what to do with them. The only thing a browser can do with a file type that it doesn’t recognize is to offer to save it on your local computer for you. Who knows, maybe you have another application that can make some sense of the file and open it. All the browsers I’ve seen know how to open and display simple text files. And most can even go as far as opening PDF files. A PDF file is a common and popular way to save your files so they can be opened by other people who may not have the same application used to create the file. Browsers can also display image files. They do this all the time anyway when images are placed inside web pages so it makes sense that a browser should also be able to display an image file directly. So if you wanted to, you could save your information that you want to present to the world as a plain text file, or as a PDF, or as an image. Images don’t have to be things you take with a camera. Just think about all the small text based images you see on Facebook. Let’s go over these options to see why HTML might not be such a bad option after all even if it does have a lot of strange angle brackets all over the place. First of all is expectation. People just expect HTML files when visiting a web page. If you instead provide just text files, then your page will look very strange. You’ll be able to display separate paragraphs of text and yo
August 28, 2017
Does markup have any specific meaning that can be understood? You already know about the html tag which identifies an html document. And the head and body tags that also define well understood areas. But how does the rest of an HTML document specify meaning? Or does it? HTML 4.01 goes a long way to separate content from presentation. Prior to that, you would have to provide markup to specify how you wanted a document to look. The browser already knows how to present certain aspects such as headers and lists. But what if you want to display some text alongside your main text? Some text that relates to the main text and helps a reader understand maybe with an example or some historical story explaining extra information? With HTML 4, you can use cascading style sheets to present this additional information so it stands apart from the main text. One of the benefits of using HTML 5 is that you have access to more tags that are designed to mean something. You can still use div and span. But now instead of creating a div element with an id attribute equal to navigation where you can put all the main navigation links on your page, you can just use a tag called nav directly. This adds extra meaning to your document and allows browsers to recognize the main navigation area. Listen to the full episode or read the full transcript below for more information, and be sure to subscribe to the podcast with your podcast app on your phone or computer to get episodes delivered to you automatically each week. Transcript You already know about the html tag which identifies an html document. And the head and body tags that also define well understood areas. But how does the rest of an html document specify meaning? Or does it? Html 4 goes a long way to separate content from presentation. Prior to that, you would have to provide markup to specify how you wanted a document to look. The browser already knows how to present certain aspects such as headers and lists. But what if you want to display some text alongside your main text? Some text that relates to the main text and helps a reader understand maybe with an example or some historical story explaining extra information? With html 4, you can use cascading style sheets to present this additional information so it stands apart from the main text. You do this with a tag called div or maybe span. These are tags meant to enclose other content usually so you can provide special styling that controls how the content will look. Div is a block-level tag while span is an inline-level tag. The difference between the two affects how content is positioned relative to other content. A block-level tag such as div will occupy its own line or multiple lines and use as much width as it can. While an inline-level tag such as span will use only as much width as it needs and is meant to fit in with other content without taking up its own line. A lot of html 4 markup uses div and span tags to divide the content into areas that can be styled and positioned differently. The problem is that divs and spans have no meaning. They can be identified through the attributes id and class, as well as their type, either div or span, and where they fit in the overall structure of the html document. But the problem still remains that a div or a span itself adds little to the meaning of the html document. This is one of the benefits of using html 5. You have access to more tags that are designed to mean something. You can still use div and span. But now instead of creating a div element with an id attribute equal to navigation where you can put all the main navigation links on your page, you can just use a tag called nav directly. This adds extra meaning to your document and allows browsers to recognize the main navigation area. You might wonder why couldn’t browsers just interpret a div tag with an id attribute equal to navigation as the main navigation area? How does introducing a new tag called nav help? They seem equivalen
August 21, 2017
You need to know more than how HTML tags work. There’s a structure that HTML documents should follow. Now that you know how HTML tags work from the previous episode, you can use that to create your own HTML pages. This episode will describe what makes an HTML file and also give you some history of HTML that you’ll need in order to understand how these tags can change. Listen to the full episode or you can also read the full transcript below. Transcript Now that you know how HTML tags work from the previous episode, you can use that to create your own HTML pages. This episode will describe what makes an HTML file. You start out an HTML file with a doctype declaration and this is followed with the html tag. The html tag forms the root of your document and surrounds everything else. You’ll find two main tags inside the html tag and these are head and body tags. Before I can explain the doctype, html, head, and body, you’re going to need some history. HTML has gone through several versions and this affects how you create an HTML document and how you write these four parts. I’m not going to try describing each version of HTML and all the differences between them. Instead, I’ll give you enough information that you can use to explore more details if you want. The major versions have been: • HTML 1.0: This was the original HTML released in 1991 and was just a document describing the tags available. • HTML 2.0: Was the first standard and was released in 1995. Companies wanted more and better websites than the standard could give and the browsers started offering custom tags. This meant that websites would not always work correctly if visitors used a different browser. I remember lots of websites back then that had messages saying “Best viewed with Microsoft Internet Explorer” or sometimes “Best viewed with Netscape Navigator”. Even today, I’ll sometimes try using a website with Safari and run into problems. Usually, switching to Firefox will fix the issue. • HTML 3.0 and HTML 3.2: Tried to fix the problems of too many custom browser tags but HTML 3.0 was too ambitious and could not gain support. HTML 3.2 came out in 1996 and scaled back some of the requirements that were in 3.0. • HTML 4.0 and HTML 4.01: First appeared in 1997 soon after HTML 3.2 and there were some minor changes in 4.0 which resulted in HTML 4.01 releasing in 1999. This version allowed web developers to specify how they wanted to migrate from previous specifications, either strict, transitional, or frameset. The older versions of HTML mixed markup with presentation and HTML 4.0 provided a new way to define how things should look, in other words, the presentation, by using style sheets. This is called cascading style sheets, or CSS, because of the way the presentation rules flow from one definition to another. I’ll explain CSS in a future episode. The migration choices allowed web developers to move into HTML 4.0 slowly. • XHTML 1.0: Came out in 2000 as a way to represent HTML 4.01 in XML. Both HTML and XML share a lot of similarities with HTML traditionally allowing web developers more flexibility and overlooking some sloppy HTML. XHTML tried to fix this by enforcing more rules about what’s valid. • HTML 5: First came out in 2008 because work on a new XHTML 2.0 was taking too long. The new XHTML version was dropped in favor of HTML 5. That brings us up to the present day. Most browsers today will support HTML 4 and HTML 5. Older browsers will have trouble with HTML 5. And now that you have this history in mind, you’ll be able to understand the differences in the four parts of an HTML document that I started explaining, the doctype, the html tag, the head tag, and the body tag. Let’s start with the doctype. This is the first line in an HTML document. It’s purpose is to let the browser know that this really is an HTML document. And for HTML 4, it also lets the browser know h
August 14, 2017
How does HTML markup enable you to create web pages? You’ll understand how HTML works after listening to this episode but styling and scripting will be explained in other episodes. Let’s start at the beginning. HTML stands for the Hypertext Markup Language and is just a text document that your browser knows how to display. You could write a program yourself that displays HTML if you want to. The point though is that the HTML document itself looks nothing like a web page. It’s just a text document with markup. Markup itself is just a way to add extra information into a document that describes the content or provides extra meaning. It’s a way for you to provide extra information to the browser, and it looks for tags. Listen to the full episode to learn how tags work, how they can be nested, how they can have additional information called attributes, and some examples. You can also read the full transcript below. Transcript You’ll understand how HTML works after listening to this episode but styling and scripting will be explained in other episodes. Let’s start at the beginning. HTML stands for the Hypertext Markup Language and is just a text document that your browser knows how to display. You could write a program yourself that displays HTML if you want to. The point though is that the HTML document itself looks nothing like a web page. It’s just a text document with markup. There are no colors, headings in larger fonts, images, or clickable hyperlinks leading to other files. It’s just a text file that usually ends with a dot html extension. Some older files might end with a dot htm extension. Don’t get me wrong, you can’t just rename any text file so it ends with the correct extension and call it an HTML file. The content must be written to follow some rules. Just like programming languages have a syntax that must be followed, HTML is the same. This is because the browser needs to be able to understand the contents. Syntax is just the rules that define what is valid text so that an application like a web browser can read the text without any misunderstanding. If you use some other application as a tool to create HTML documents, then you may not need to worry about this structure. It’s not hard to learn and knowing how to write HTML files by hand gives you a deeper understanding of what it means to create web pages. HTML has roots in another markup specification called SGML which stands for the Standard Generalized Markup Language. HTML is really just an implementation of SGML. The first line in an HTML file is a bit different and is there to let the browser know that this really is an HTML file. It looks a bit different because it was designed to follow the rules of SGML. The first line in an HTML file is called the document type declaration. I’ll come back to this line later. For now though, I’ve mentioned markup languages, but what does this mean? This is the way HTML actually works. Markup itself is just a way to add extra information into a document that describes the content or provides extra meaning. When we were in school, some teachers would ask for our written reports to be formatted so that blank lines would be placed between each written line. This gave room for the teacher to write comments or instructions. Usually in red ink. This is markup. The teacher would let you know about spelling mistakes, fragmented sentences, confusing text, etc. The markup was rarely something good. A lot of markup meant a bad grade. HTML markup is not for bad things. It’s a way for you to provide extra information to the browser. Because the browser doesn’t know how to scan for red ink. It looks for markup in another way. It looks for tags. Tags usually come in pairs with a starting tag and an ending tag that you put around the text you want to markup. Tags are designed to stand out in your document which means that you can’t have regular te
August 7, 2017
You can use HTML to present information or build web pages. HTML stands for Hypertext Markup Language which is a bit unfortunate because it gives the impression that this is a programming language. It’s not. The most important part of the name is markup. To me, it’s even more important than hypertext which provides a way for one HTML document to refer to another HTML document or even to another location in the same HTML document. You can create HTML that has no links or references to anywhere else. But you can’t create HTML without markup. We need some way to organize extra information. Some way to mix the text you want with how that text will be displayed as well as all the other things that can be included. Even something as simple as making a word bold needs to be specified. Listen to the full episode to learn more about how HTML relates to the Internet and some history about Tim Berners-Lee who created HTML and the World Wide Web. You can also read the full transcript below. Transcript HTML stands for Hypertext Markup Language which is a bit unfortunate because it gives the impression that this is a programming language. It’s not. The most important part of the name is markup. To me, it’s even more important than hypertext which provides a way for one HTML document to refer to another HTML document or even to another location in the same HTML document. You can create HTML that has no links or references to anywhere else. But you can’t create HTML without markup. Before we get too far, though, let’s think about how we like to organize text and information. I’ll explain more details about HTML in another episode. When writing text, we normally want it to be easy to read. We want it well organized. And there should be pictures and diagrams, maps and charts, columns and numbered or bulleted lists, doodles and colors. And there should be large and small text, special characters and symbols, backgrounds, borders, and shading, tables of contents and indexes, mathematical formulas and artwork, and more. You get the idea. Making something that’s easy to read involves a lot more than just organizing our thoughts. Books and magazines do this and the work isn’t done when an author finishes a manuscript, or a reporter completes an interview, or a scientist writes about some discovery. The possibilities are even more elaborate with electronic media. Now we can include sound and video, animations and expanding sections, tabs to switch pages, forms to let readers type in their own information, reformatting for different sizes, detecting and responding to different devices and phones, updating and gathering new and updated information, and even more. We need some way to organize all this extra information. Some way to mix the text you want with how that text will be displayed as well as all the other things that can be included. Even something as simple as making a word bold needs to be specified. Now, if you just want to handwrite something, you can draw whatever you want on paper. You can put the text wherever you want with whatever color of ink you want. You can make it as big or as small as you want. You can include sketches, maps, diagrams, and charts. You can draw boxes around sections. You can bind the pages into a book and include page numbers. In short, you can make a one-of-a-kind masterpiece. To make another one means starting all over again. Or the pages could be transferred to blocks of wood and carved by hand to make stamps that could print hundreds of copies. Each page would need to be carved like this which could take years. This was how books used to be made. The invention of moveable type helped. This allowed individual letters to be made into stamps that would transfer ink onto paper. Each letter stamp or type could be placed next to others to fill up a page. This was a lot faster than carving but lost a lot of flexibility. Maps and diagrams would still need to
July 31, 2017
What criteria do you use to determine if somebody is faking their skills as a teacher? You can’t rely on awards or certifications. Sure, these things can help. But they’re not completely accurate. When you ask a question, how do you know that you’re getting the very best answer? And when somebody explains how to do something, how do you know if the explanation is good? There’s two aspects of this. The first thing to consider is if an instructor knows the material directly. Has the instructor done this sort of work before? Experience plays a big part but you also need to consider the quality of the experience. I see this all the time on resumes where a person will claim maybe ten years of experience. Is that ten years of continuous improvement and skill development? Or is it one year that’s been repeated ten times. Don’t get me wrong. There’s nothing bad about becoming the best, most highly qualified person in a narrow range of skills. Bruce Lee once said that he had no fear for somebody who practiced ten thousand kicks once. But that he feared the person who had practiced one kick ten thousand times. In this case, doing the same thing over and over actually makes a person better. But what people sometimes put on their resume is when they’ve been coasting for the last nine years and stopped improving a long time ago. That’s when one year of experience repeated ten times stops being a good thing. The next thing to consider is the teaching skills of an instructor. Just because a person knows something doesn’t mean that person knows it well enough to teach it to you. It’s said that one of the best ways to learn something is to try teaching it. I face this problem all the time because I taught myself how to program, I never went through a traditional computer science curriculum. There’s a lot of details that I’ve managed to avoid over the years with no problems. Anytime I needed that detail when working on a project, I would look up the information as needed. Teaching requires more preparation. Especially when trying to anticipate questions. That’s when the learning really begins. Listen to the full episode for an example that demonstrates what I think is the best way to judge a person’s teaching skills. You can also read the full transcript below. Transcript You can’t rely on awards or certifications. Sure, these things can help. But they’re not completely accurate. When you ask a question, how do you know that you’re getting the very best answer? And when somebody explains how to do something, how do you know if the explanation is good? There’s two aspects of this. The first thing to consider is if an instructor knows the material directly. Has the instructor done this sort of work before? Experience plays a big part but you also need to consider the quality of the experience. I see this all the time on resumes where a person will claim maybe ten years of experience. Is that 10 years of continuous improvement and skill development? Or is it 1 year that’s been repeated 10 times. Don’t get me wrong. There’s nothing bad about becoming the best, most highly qualified person in a narrow range of skills. Bruce Lee once said that he had no fear for somebody who practiced 10 thousand kicks once. But that he feared the person who had practiced 1 kick 10 thousand times. In this case, doing the same thing over and over actually makes a person better. But what people sometimes put on their resume is when they’ve been coasting for the last nine years and stopped improving a long time ago. That’s when 1 year of experience repeated ten times stops being a good thing. Somebody who has no clue what they’re doing will not make a good teacher. Even if that person has the best curriculum and the best certifications. Because the moment you have a question that falls outside the material, the instructor
July 24, 2017
My dad recently said that he noticed a lot more police activity recently. He lives in a small rural town and told me that kids now days either leave or go to jail. There’s lots of small towns that used to have a factory in a nearby town where people could go to work. Some of those have closed or reduced the number of people they need. Even the factories that are still doing good just don’t need as many workers. They need skilled workers. People who understand technology and,yes, people who know how to code. The problem is that there’s no longer a path to get these skills by entering the company as a regular worker. You used to be able to operate machines and after a while understand how they worked. You could either advance through management or as a highly skilled operator. This was enough to support a family and build a good career. The management route is still open but even that usually requires some amount of advanced skills that you don’t normally gain through regular labor. All of this is contributing to what my dad was talking about. His point was that if the kids don’t leave the small towns, then there’s no opportunity for them to gain the skills they need. They fall behind and eventually get desperate enough to consider theft. That is, assuming they don’t get trapped in drugs first. I remember when my sister graduated from that small town high school. She told me that she would do well because she was one of the top students in the school. I told her it was not enough. Unless she was one of the top students in the country, that achievement would not carry her very far. Maybe it would have been enough to be a good student in a small town once. You could get a decent starting position in a local company or factory and make a good living. But that false sense of accomplishment usually ends fast once these students try to compete for good jobs at bigger and more centralized companies. Now the companies have a wider selection of people to choose from. And if there’s one thing I can promise you, it’s this. There will always be somebody else smarter than you, harder working than you, and luckier than you. Don’t try to fight that. It’s a losing battle. The only measure of success that means anything is how well you improve and advance yourself each day. Don’t compare yourself with others. This is what my dad meant when he said that kids need to leave in order to avoid jail. At least in order to avoid being seen in the local jail. My opinion is that just leaving town is not enough. Just like being a top student in a small school is not enough. If the small town jobs are no longer enough to provide you with the skills you’ll need, then you have to take responsibility to develop those skills yourself. The public schools are not able to meet this need. They’re more interested in passing tests. They don’t teach you how to solve problems. One of my favorite books is “How To Solve It: Modern Heuristics” and it shows the best example I’ve seen that explains why schools struggle to teach kids real problem solving abilities. The example is a simple math question taken from a grade school math book. The type of question that kids solve in a couple minutes during a test. It took me almost an hour to solve it. That’s not to say that I’m rusty with math. The real problem is that question is actually quite hard when taken out of the chapter of the math book where it came from. What I mean is that the math book contains chapters each teaching a specific topic. And the questions at the end of each chapter are designed to make use of the material in the chapter. So the students naturally apply the techniques they just learned to solve the problem. It becomes a much more difficult problem when you don’t know what approach to take. This is why public education does a poor job of preparing kids for real life. When you ha
July 17, 2017
Where is the best place for you to get the skills you need to get a high-tech job, to advance your career, or to just satisfy your desire to improve? You’re not going to find a specific answer in this episode to the question of what’s best for you. The reason is that we’re all different and have different needs, desires, and starting points. We also learn differently. There is no single best place for everybody to get coding skills. What I’ll explain in this episode is how I think about this topic and hopefully give you some things to think about as you make your own decisions. I recently read an article about Dev BootCamp announcing that they will be accepting their last cohort and closing business at the end of this year. The term cohort is a common way to describe a group of students that all start an intensive training program at the same time. The news about Dev BootCamp shutting down got me to thinking about this industry and seemed like a good topic this week. There’s several variations of bootcamps teaching slightly different technologies but from what I’ve seen, they all have the following four things in common: Bootcamps usually focus on web technologies and call this full-stack development. What this means is that students learn about everything needed to build an interactive website. There’s HTML and CSS for displaying and formatting the web pages. There’s JavaScript to add actions and behavior to the web pages. There’s languages like Ruby or PHP that run on the servers and that prepare the web pages to be sent to the website visitors. And there’s databases to store information on the server. All of these technologies build on one another and the idea is that by learning all of them, you can become a full-stack developer. Bootcamps usually enroll several students as a group for an intense, multi-week program. The days are long and leave no time for anything else. You need to be committed because students are expected to keep up with the fast pace. The programs will mix lectures with hands-on work. Bootcamps usually have students work on projects that can be demonstrated at the end to show everything that was learned. Bootcamps usually charge about a thousand dollars per week. Some want this money paid in advance and charge even more if you need to split it into multiple payments. Some offer financial aid. Some offer partial refunds if you can’t find a job. And some don’t charge anything until you get a job. Personally, I’m not a big fan of bootcamps for most situations. I think the structure makes it hard for students to afford them. You would have to leave your current job for 2 months or more. For most people, this means quitting their current job. And at the same time, either pay or commit to paying anywhere from 8 to 16 thousand dollars. This is, however, a lot less than you might pay for a Bachelor’s degree. So it seems like a good deal. I mean, you’d probably have to quit your job in order to attend college full time too. And the option to skip college, pay a fraction of the cost, and finish in a couple months instead of a few years, is very compelling. The reason I’m not a big fan is because of that time. It takes time to learn something well. Our brains need time to grow into our skills. Without that time, most people will quickly forget everything they learned. It would be different if bootcamp students were already programmers familiar with some of the technology and just wanted an intensive program to learn a few pieces and how to apply this new skills in the larger web development picture. But to take a person who knows nothing about programming and expect them to learn an entire stack of technologies in such a short amount of time is where I think bootcamps are going wrong. When I went to college, I studied electrical engineering and thought that I was already on a fast track because my college finished i
July 10, 2017
Programming involves change and managing that change is the only way to make sense of it. You’ll learn about the staging area in this episode and how that affects your commits. Git actually has three areas where it keeps your files. The most visible of these is called the working directory. The second area is the staging area. This is where files go when you add them and before they get committed. The third area is the archive area. I’m not sure if this area has an official name or not so that’s how I refer to this area. This is the area where Git holds all the versions of your files as they existed through each commit. Every time you commit changes, you’re updating the archive area with the latest changes. And the archive area continues to hold all the older versions of your files. Listen to the full episode to learn more especially how to avoid committing empty files that you create through your integrated development environment. You can also read the full transcript below. Transcript You’ll learn about the staging area in this episode and how that affects your commits. Normally, you don’t have to worry about the staging area. But some aspects of Git will be confusing without this understanding. Imagine the work you do by changing your files as if you were packing bags for a trip. Now you could take each bag out to your car right away but that may not be the most efficient way to load your car. It’s better to leave each bag where it is first and then take them all out to a loading area where you can then load them into your car. In other words, you stage them or prepare them first before finally loading them. Git actually has three areas where it keeps your files. The most visible of these is called the working directory. This is the area you see when you browse your files and is where you can open them and make changes to them. This is the area that you’re used to. When you check out a different branch, this is the area that gets updated with the files that match that branch. Many people don’t even think about the other two areas in Git. The working directory is so visible and is where you do your work that many people don’t even consider the possibility that there could be other areas. The second area is the staging area. This is where files go when you add them and before they get committed. When you create a new file in your project, it’ll initially show up as an untracked file in your working directory. You tell Git that you’d like to track changes to this file by adding it. What actually happens is that adding the file makes a copy of the file in your staging area. This is enough to let Git know that the file is tracked even though it hasn’t yet been committed. The third area is the archive area. I’m not sure if this area has an official name or not so that’s how I refer to this area. This is the area where Git holds all the versions of your files as they existed through each commit. Every time you commit changes, you’re updating the archive area with the latest changes. And the archive area continues to hold all the older versions of your files. Now, these areas can get confusing when a file exists in more than one at the same time. Let’s start out with the simple case of a new file. The new file will exist in your working directory. If it’s someplace outside of your working directory, then it doesn’t relate to this Git repo at all. Git only works with files that are anywhere inside the directory structure of your project repo. Okay, so you have a new file. If you run the command “git status”, then Git will tell you that there is an untracked file in your working directory. Any commit you make at this point will not affect that file. It will remain untracked. And if you delete the file, then it’s gone forever as far as Git is concerned. That file will not be found anywhere in your Git h
July 3, 2017
Programming involves change and managing that change is the only way to make sense of it. You’ll learn about submodules in this episode and how that enables you to reference code from other repositories. There’s a concept in programming called refactoring. I could spend several episodes about this one topic and will in future episodes. For now though, I’ll just say that you normally don’t want to repeat code. In other words, you don’t want similar or even the same source code spread out in multiple places in your project. That’s because if you ever need to change this code or fix a bug, then you need to make sure to change each location. It’s too easy to miss places. What you need is a way to use code from another repo inside your own repo. And Git has two options available for you. Listen to the full episode or read the full transcript below to learn about Git subtrees and Git submodules and why I prefer submodules. Transcript You’ll learn about submodules in this episode and how that enables you to reference code from other repositories. There’s a concept in programming called refactoring. I could spend several episodes about this one topic and will in future episodes. For now though, I’ll just say that you normally don’t want to repeat code. In other words, you don’t want similar or even the same source code spread out in multiple places in your project. That’s because if you ever need to change this code or fix a bug, then you need to make sure to change each location. It’s too easy to miss places. If instead that code was in a single place, and exposed as a class or even just a single method, then it can still be used in multiple places. But the code itself is now in a single place. Any changes or bug fixes can be made directly to the one spot. That’s a great way to design code to be reused throughout your project. It can be so useful that you might find yourself wanting to use the code in other projects too. Then what do you do? One option is to just copy the code into your new project and then make sure that it’s used from just that single location. You’ll soon realize that all you’ve done is take the same old problem and just made it bigger. You still have to remember all the other projects that might be using your code when it comes time to fix a bug. Another option is to just put all your projects in one big Git repository. That’s not a very good idea either. Maybe the code you want to reuse isn’t even your code. Maybe it already exists in another Git repository and you want to be able to benefit from any enhancements or bug fixes done to the original code. You don’t want to be copying it to your repository even if the license says that you can. What you need is a way to use code from another repo inside your own repo. And Git has two options available for you. I’m only going to briefly mention the first option and really should mention this option last because I’m not a big fan of using subtrees. The only reason to mention subtrees first is so we can move past it quickly. Git allows you to copy the code from another repo and include the files and folders as if they were part of your own repo. Any commits you make can include changes to your files as well as the files in the code that you’re reusing. It’s a simple solution that you don’t have to think about too much. It just works. But there’s a catch. When it comes time to update your borrowed code to pick up any bug fixes or maybe you want to contribute a few of your own changes back to the original repo, it becomes hard to separate your commits. Subtrees make it harder to update changes by pushing extra work onto the person doing the merging. I’ve seen professional software development teams use subtrees like this before and they ended up just giving up on merging and decided to only make changes t
June 26, 2017
Programming involves change and managing that change is the only way to make sense of it. You will learn about distributed repositories in this episode and how that enables you to work differently. The file renaming and copying techniques that I described earlier form a crude form of version control but even more important is the fact that everything is local. All the backups are on your computer. That makes it difficult to share them with other people. Maybe you could instead put the files on another computer that other people also have access to. That’s really what makes a computer a server instead of a client workstation. Anytime you have a computer designed to perform some service and make that service available for other computers to use, such as serving files, you turn that computer into a server. Listen to the full episode to understand how Git makes use of servers to store repositories in a central location but at the same time treats all repos as essentially the same. You can also read the full transcript below. Transcript You’ll learn about distributed repositories in this episode and how that enables you to work differently. The file renaming and copying techniques that I described earlier form a crude form of version control but even more important is the fact that everything is local. All the backups are on your computer. That makes it difficult to share them with other people. Maybe you could instead put the files on another computer that other people also have access to. That’s really what makes a computer a server instead of a client workstation. Anytime you have a computer designed to perform some service and make that service available for other computers to use, such as serving files, you turn that computer into a server. It’s possible to turn your own computer into a server. A server doesn’t always have to be an expensive and powerful computer sitting in a rack in an air-conditioned room with rows of other computers. Any time you have a computer connected to a network and it makes some service available for other computers to use, then you have a server. Now, you wouldn’t want to use your personal computer for a server for a variety of reasons, but the point is that you could if you really wanted to. One important aspect that makes a good server is availability. Since you don’t know when somebody will want to use the services offered by a server computer, it should be ready to accept requests at any time. You don’t normally turn servers off at the end of each day and you rarely even want to restart them. A good version control system should be available for your entire team to use from each team member’s computer. And almost all version control systems can be run on a server computer so they’ll be available for use anytime somebody needs them. But there’s a big difference in how some of these systems are designed. The traditional way is more like taking your private backup files and placing them on a server so they’ll be available from a single location. The system will likely make copies of the specific versions of each file that you want to work with on your local computer. It’s just faster to have the files sitting on your own computer than to always have to send the contents over the network anytime you want to read or open a file. Some version control systems even try to get very elaborate by making your files appear to be copied locally but they really don’t exist on your own computer until the moment you try to access them. It doesn’t really matter though if your version control system actually makes copies of the files on your local computer or just seems to do this. Because if you ever lose the network connection to that server, then you’ll lose access to any files that you don’t already have. This also means you lose access to other versions of your files. So if you’re working on a laptop c
June 19, 2017
Programming involves change and managing that change is the only way to make sense of it. You’ll learn about branching and what it means to commit your changes in this episode. Git is more than a system that allows you to checkout a file, make some changes, and then check it in again. That’s how libraries work. And when the book you want to read is already checked out by somebody else, you have to wait. Libraries also treat each book separately. Programming is different. First of all, the bits that make up a file can be copied as many times as you have hard drive space with no real limit to how many people can be working on a file at any time. And secondly, you’re most likely going to need to work with several files each time you make a change. For a large project and a large change, you might need to work with hundreds of files at a time. Git can handle all of this and it encourages you to make smaller changes and record those changes often. This makes tracking changes easier. The last thing you want is for your version control system to have an initial commit and then six months later a giant commit with a comment that says everything is now ready to release version 1.0 of your software. That’s exaggerating things quite a bit. And I’m also getting ahead of myself. Listen to the full episode to learn about branching, committing changes, and how you can use branches to manage your work. You can also read the full transcript below. Transcript You’ll learn about branching and what it means to commit your changes in this episode. Git is more than a system that allows you to checkout a file, make some changes, and then check it in again. That’s how libraries work. And when the book you want to read is already checked out by somebody else, you have to wait. Libraries also treat each book separately. Programming is different. First of all, the bits that make up a file can be copied as many times as you have hard drive space with no real limit to how many people can be working on a file at any time. And secondly, you’re most likely going to need to work with several files each time you make a change. For a large project and a large change, you might need to work with hundreds of files at a time. Git can handle all of this but it encourages you to make smaller changes and record those changes often. This makes tracking changes easier. The last thing you want is for your version control system to have an initial commit and then six months later a giant commit with a comment that says everything is now ready to release version 1.0 of your software. That’s exaggerating things quite a bit. And I’m also getting ahead of myself. Let’s go back to the beginning. I’ve worked with other version control systems before that would allow you to check out a file to make changes. The system would actually change every file in your project to be read-only and make you check out a file before it would allow you to save your changes. Many editors were perfectly happy to allow you to open these read-only files and even make changes to the file. I would sometimes forget to check out the file first and would be reminded when I tried to save my changes. That’s when the editor would complain that it couldn’t write the changes to a read-only file on disk. That’s also when I would switch over to the version control system to check out the file. As long as nobody else had changed the file, this was okay. But if somebody else had changed the file, then when I would check it out, my local copy of the file on disk would be updated with the latest changes. But those changes would not be included in what my editor was ready to write back to disk. Because I had no way to know what the changes were or how they might conflict with what I was about to write, I would usually choose to abandon my work and start over again. That’s not fun. Sometimes, if I had a lot of changes,
June 12, 2017
Programming involves change and managing that change is the only way to make sense of it. You’ll learn about merging in this episode. With this knowledge, you can take your source code control system to a new level by going beyond just managing old versions. You’ll be able to try different things and incorporate just the pieces you want. And you’ll know how to work in a team. Merging is not the same as how traffic merges together on the road. There are two separate streams of cars that have no relation to each other that merge on a highway. The cars find openings to fit in and hopefully the other cars will be nice enough to allow those openings. Merging source code is different. You start out with something common. This is an older version of your file. That version of the file that’s common is what allows Git to figure out how to do the merging. Most of the time, you don’t have to do anything special. Listen to the full episode or read the full transcript below for a simple example of merging files. And don’t forget to subscribe to the podcast on iTunes, Google Play, Stitcher, or almost any other podcast directory. Subscribing lets you receive new episodes as they’re released. Transcript You’ll learn about merging in this episode. With this knowledge, you can take your source code control system to a new level by going beyond just managing old versions. You’ll be able to try different things and incorporate just the pieces you want. And you’ll know how to work in a team. Merging is not the same as how traffic merges together on the road. There are two separate streams of cars that have no relation to each other that merge on a highway. The cars find openings to fit in and hopefully the other cars will be nice enough to allow those openings. Merging source code is different. You start out with something common. This is an older version of your file. That version of the file that’s common is what allows Git to figure out how to do the merging. Most of the time, you don’t have to do anything special. Let me give you an example. Let’s say you start out with a file containing three lines of text, a, b, and c. That just means you created this file by typing the letter a, then the enter key, then the letter b and the enter key, and then the letter c and the enter key. Each letter is on it’s own line. A very simple file. It’s not programming source code but I can describe this a lot better than real source code. Listen to the previous episode for more information about text files. This file is going to form our starting point. You open the file and change the first line to aa instead of just a. You like that change, so you save the file and commit your changes in Git. I’ll explain what it means to commit your changes in another episode. For now, just know that committing your changes means that you let your version control software know that you’re done making changes and it can store the current version of the file where it’ll be kept safe. Now maybe this change you did to the first line is going to take some time to test. When programming, it’s always a good idea to test your changes to make sure they work as expected. I know, this is not a real programming file I’m explaining. Just pretend for a moment that changing the first line to aa is a big deal and could have unintended consequences. That doesn’t mean it’s a bad change. It’s just going to take a while to make sure everything’s okay. While you’re busy testing your changes, your manager lets you know about a critical bug affecting customers that has to be fixed right away. You need to drop everything and fix this new issue right away. You eventually track the problem down to the third line in the same file and realize that it really should have been cc instead of just c. Let me make one thing clear that may not be obvious right
June 5, 2017
Programming involves change and managing that change is the only way to make sense of it. It’s more than history. As your projects get bigger and especially when you have a team of software developers all working on the same project files, a version control system is absolutely critical. This is either called version control or source code control. Both mean the same thing. How does it work? And how can you use it? That’s what I’ll begin explaining in this episode. Specifically, I’ll be discussing my favorite system called Git. We won’t actually discuss Git in this episode. There’s a bit of background material to explain first about the differences between text files and binary files. Listen to the full episode to learn more about the differences between text files and binary files. You can also read the full transcript below. Transcript It’s more than history. As your projects get bigger and especially when you have a team of software developers all working on the same project files, a version control system is absolutely critical. This is either called version control or source code control. Both mean the same thing. How does it work? And how can you use it? That’s what I’ll begin explaining in this episode. Specifically, I’ll be discussing my favorite system called Git. That’s spelled G i t. We won’t actually discuss Git in this episode. There’s a bit of background material to explain first about the differences between text files and binary files. I’ve mentioned version control many times in previous episodes and you might want to listen to episodes 142 about comments and episodes 166 through 169 which are a guide to computer programming. Before I explain how to use a version control system, let’s look at how you might keep track of files yourself. I’ve done this before and you’ve probably done similar things. If you only have one file, it’s a little easier but still a chore. Maybe you have a budget that you save to a file on your computer. If you keep updating the file each month then either the previous month’s information will get deleted or changed or if you want to keep all that information, then the file will grow until it gets too large to work with. Then you’ll face the same decision to start deleting old information from past months. Instead of either of these two options, maybe you decide to start saving the budget with a new name each month. This keeps your file size small and lets you keep as many previous months as you want. But soon you find yourself scrolling through all these files. Your directory starts filling up. So you move some of the old files into an archive folder. This is really what a version control system does for you. Only it does it better by managing all the work for you, keeping even smaller files archived so you use less space, and lets you compare changes. One thing you should be aware of is that any version control system works great with text files. So you can use it to manage more than just source code. Binary files are a bit different. But wait a minute, aren’t computers based on binary? Yes, and a text file is composed of binary bits just like any file. What makes a file a text file is that it contains sequences of binary codes that have meaning separated every now and then by new lines. All that means is that a text file contains characters that you typed split into one or more lines. Each character that you type could be stored in the text file differently depending on how it’s encoded. And it gets more complicated if the text contains something like Chinese characters. Listen to episode 107 about chars and bytes and episodes 114 through 116 about strings for more information. The encoding doesn’t really matter here. The bytes still represent the characters you typed no matter how they’re stored. The new line character can also be different
May 29, 2017
Hey, I need to wait around for a package to be delivered next Friday. Can you cover for me if I take your shift on Saturday? We all have things that need to get done and sometimes that means we have to be someplace other than at work. And it’s amazing how often this involves just waiting. Waiting for the phone to ring. Waiting for the mail or a package to be delivered. Or waiting for a certain time when you can pick up your kids from school. What do you do when you’re supposed to be at work? Well, if you have a job where you really do have to be at some location, then you don’t have a lot of options. But more and more, employers are realizing that the need for employees to be sitting at their desk in the office is not real. It’s a left-over custom that’s fading fast and really just means that your manager is too lazy to judge your performance unless you’re within sight. Some companies have no office at all and everybody works from home. They do very well and this trend is taking hold. The best employees are motivated as well as being good at their job. Once you’re motivated, you’ll find ways to get things done and don’t need a manager watching your every move. The only question remaining is do you have the skills required to get one of these jobs? I’d like to stop here a moment to make clear that you don’t have to have a job that can be done anywhere in order to be happy and motivated. I’ve worked in a factory before making integrated circuits and loved it. I was always on time for my shift to start and would often get so caught up with what I was doing that I’d look around and realize that everybody had already left for lunch. Listen to the full episode to learn directly from a friend of mine who works remotely. I had the chance to interview him and included the dialog in this episode. Or you can also read the full transcript of the episode below. Transcript We all have things that need to get done and sometimes that means we have to be someplace other than at work. And it’s amazing how often this involves just waiting. Waiting for the phone to ring. Waiting for the mail or a package to be delivered. Or waiting for a certain time when you can pick up your kids from school. What do you do when you’re supposed to be at work? Well, if you have a job where you really do have to be at some location, then you don’t have a lot of options. But more and more, employers are realizing that the need for employees to be sitting at their desk in the office is not real. It’s a left-over custom that’s fading fast and really just means that your manager is too lazy to judge your performance unless you’re within sight. Some companies have no office at all and everybody works from home. They do very well and this trend is taking hold. The best employees are motivated as well as being good at their job. Once you’re motivated, you’ll find ways to get things done and don’t need a manager watching your every move. The only question remaining is do you have the skills required to get one of these jobs? I’d like to stop here a moment to make clear that you don’t have to have a job that can be done anywhere in order to be happy and motivated. I’ve worked in a factory before making integrated circuits and loved it. I was always on time for my shift to start and would often get so caught up with what I was doing that I’d look around and realize that everybody had already left for lunch. These were twelve hour shifts from 7 am to 7 pm. There was no concept of working from home. Of course I had to be present at the factory in order to do my job. And I had fun. There were some times like holding my breath while scrubbing the inside of a large dome lid that I could stand up inside that weren’t the most pleasant. It involved a lot of quick ducking in and out so I wouldn’t have to breath the f
May 22, 2017
We normally think of something as either a conductor of electricity or an insulator. Transistors are semi-conductors which means that their ability to conduct electricity can be controlled. There’s an older video I made that explains DC analysis of transistors that you can watch if you visit Facebook.com/ElectronicThinking. Let’s examine conductors and insulators first. Every time you use a cloth to pick up something hot, you’re using an insulator. In this case a heat insulator. And the reason we use metal skillets and pots is because metal conducts heat. It all comes to this. A conductor allows something to move from one place to another and an insulator stops this movement. Silicon and a few other elements are a bit different though. Silicon is normally an insulator of electricity. But it can be turned into a conductor by adding impurities. This is called doping and it involves hitting the silicon with some fast moving elements such as boron which then embed themselves inside the silicon. In order for anything to conduct electricity, it has to contain ions which are positive or negative charged atoms. By carefully choosing what elements to inject into the silicon and how many, we can introduce atoms that can either easily supply extra electrons or accept electrons. It’s the electrons that move around. That’s the charge. By injecting boron for example, it’ll pull an electron from a nearby silicon atom which creates a positive charged silicon ion. And by injecting arsenic, it’ll provide an extra electron to a nearby silicon atom creating a negative charged silicon ion. There are two basic types called NPN and PNP transistors. They consist of three alternating doped sections of silicon which is why there are two types. Each transistor has three connections each leading to one of the N or P sections. The connections are called the emitter, base, and collector. Because of how the sections are made, the transistor will initially not conduct any current from the emitter to the collector. But by raising the voltage at the base above a certain threshold until current starts to flow through the base, it has the effect of causing a larger amount of current to flow through the emitter and collector. This allows a transistor to operate as an amplifier. Listen to the full episode to learn how transistors can operate as switches and why this is needed by computers. Or you can also read the full transcript below. Transcript Transistors are semi-conductors which means that their ability to conduct electricity can be controlled. A full explanation of how this is done is probably too difficult to explain with audio only. There’s an older video I made that explains DC analysis of transistors that you can watch if you visit Facebook.com/electronicthinking. I used to make videos explaining electrical engineering and some of those are still available on Facebook if you go directly to the Electronic Thinking page. What I’ll describe here are the concepts and how transistors relate to computer programming. Let’s examine conductors and insulators first. Every time you use a cloth to pick up something hot, you’re using an insulator. In this case a heat insulator. And the reason we use metal skillets and pots is because metal conducts heat. It all comes to this. A conductor allows something to move from one place to another and an insulator stops this movement. Normally a material such as metal or wood or glass or plastic will be either a conductor or an insulator or somewhere in-between. It doesn’t change. It is possible for a material like metal to be a good conductor of both heat and electricity but an insulator of other things like light. We haven’t yet figured out how to make transparent aluminum. The point is when deciding whether something is a conductor or an insulator, you have to ask what’s being moved. Silicon and a few other elements are a bit different tho
May 15, 2017
Unlike microprocessors, microcontrollers can be used all by themselves. If you’re building a computer, then go ahead and use a microprocessor. But almost anything else that’s not entirely mechanical will probably need a microcontroller. Maybe even several. If it has buttons, then it can use a microcontroller. If it monitors temperature, or light, or position, then it can use a microcontroller. If it records information, or drives a display, or communicates with another device, then it can use a micro controller. A microcontroller is really just a single chip containing a microprocessor, memory, and input and output ports. Most microcontrollers will have more components such as analog-to-digital converters, comparators, pulse-width modulation, and communications. What you’re not going to find on a microcontroller are address lines or data lines. These are all contained inside the microcontroller. What’s exposed to the outside world is ready for you to use. Listen to the full episode to learn more about the additional features as well as some examples of how you can use a microcontroller. You can also read the full transcript below. Transcript If you’re building a computer, then go ahead and use a microprocessor. But almost anything else that’s not entirely mechanical will probably need a microcontroller. Maybe even several. If it has buttons, then it can use a microcontroller. If it monitors temperature, or light, or position, then it can use a microcontroller. If it records information, or drives a display, or communicates with another device, then it can use a microcontroller. Make sure to listen to the previous episode about microprocessors. I try not to repeat things as much as possible and instead will refer you to other episodes. I’m going to compare microcontrollers with microprocessors to help you understand microcontrollers better. A microcontroller is really just a single chip containing a microprocessor, memory, and input and output ports. Most microcontrollers will have more components such as analog-to-digital converters, comparators, pulse-width modulation, and communications. What you’re not going to find on a microcontroller are address lines or data lines. These are all contained inside the microcontroller. What’s exposed to the outside world is ready for you to use. Let’s say that you want to control some lights by turning them on and off in some interesting pattern. All you have to do is figure out which ports you want to use and connect each port to a light. This assumes that the lights can be driven directly from the microcontroller. If the lights need more current than the microcontroller can supply, then you might need to use other components such as transistors. I’ll explain transistors in a future episode. Each port is a pin on the microcontroller and can be configured to be an output port or an input port. To control things such as lights, you’ll want to use output ports. If you want to monitor a switch or a button to know when somebody pushes it, then you can can connect the button to a port configured as an input port. The biggest difference between ports and data lines relates to timing. Data lines on a microprocessor constantly send and receive data that has to be timed exactly. Ports though maintain their values when configured for output until your code decides to change the value. And input ports are ready to handle that button press at any time. You can connect a microcontroller to the lights so that when a port value is high, then the light is on and when the port value is low, then the light is off. What about all those other features that microcontrollers usually have included? First let’s look at the memory. There’ll be two different kinds of memory. One is flash memory. That’s where the microcontroller holds the code that you write. You program a microcontroller just like a microprocessor. But instea
May 8, 2017
What are microprocessors and how have they changed? The first thing to understand is that a microprocessor by itself is useless. It can’t do anything without other components such as memory, communications, port controllers, display drivers, etc. All these are integrated circuits. There’re called integrated circuits, or ICs, because all the transistors are bundled together on a single piece of silicon that’s packaged inside a piece of plastic with connections exposed so it can connect with other ICs. The ICs are also sometimes called chips. Computers sometimes refer to a central processing unit or CPU. Think of a microprocessor as a CPU on a single integrated circuit. It still acts as the brains of the device and it coordinates the activities of all the other ICs. Probably the most critical component that a microprocessor relies on, other than a good supply of power anyway, is the clock. You’ve heard about computers running at some gigahertz speed or another. This is the clock speed. Computers didn’t always run this fast. Listen to the full episode for more information about clocks and how the microprocessor can read and write information from memory. Or you can also read the full transcript below. Transcript I’ve explained some of this in episodes 3 and 4 so make sure to listen to them for more information. This episode will help you understand the microprocessor from an electronic angle. The recent electronics episodes will also help. The first thing to understand is that a microprocessor by itself is useless. It can’t do anything without other components such as memory, communications, port controllers, display drivers, etc. All these are integrated circuits. There’re called integrated circuits, or ICs, because all the transistors are bundled together on a single piece of silicon that’s packaged inside a piece of plastic with connections exposed so it can connect with other ICs. The ICs are also sometimes called chips. I’ll explain transistors in another episode. I wanted to bring the focus back to programming for this episode so you don’t feel like this podcast has lost its direction. This is a programming podcast and learning about electronics will help you become a better programmer. Microprocessors used to have about 2 thousand transistors in the 1970’s and it’s gone up dramatically since then. The more transistors a processor has, the more it can do. Your smart phone has a microprocessor and it probably has 2 to 3 billion transistors. A high end graphics card also has a graphical processor and today might have as many as 15 billion transistors. Computers sometimes refer to a central processing unit or CPU. Think of a microprocessor as a CPU on a single integrated circuit. It still acts as the brains of the device and it coordinates the activities of all the other ICs. Probably the most critical component that a microprocessor relies on, other than a good supply of power anyway, is the clock. You’ve heard about computers running at some gigahertz speed. This is the clock speed. Computers didn’t always run this fast. The original IBM personal computers had a clock of 4 megahertz. And they had a turbo button that could increase the speed to 8 megahertz. A modern computer will likely have a clock speed of 2 to 3 gigahertz. A clock signal is nothing more than a voltage that goes from zero volts to whatever high voltage level your system is using and then back to zero volts, and then back to high. It does this very fast and regularly. The key to a good clean clock signal is that it should be regular. In other words, it shouldn’t remain high for some period of time and then low for a different period of time. And when it goes high again, it should remain high for the same length of time. Each time the clock signal goes high and then low and back to the same spot is called a cycle. And counting how many times each second it does th
May 1, 2017
You can use resistors to divide voltage. A circuit with just some resistors may not seem very interesting but you can learn something. If you put two resistors in-line with each other, then the total resistance will be the sum of each resistor. This type of arrangement is called in series. You can learn more by listening to the previous episode about series vs. parallel. While you can think of multiple resistors in series as being equivalent to a single larger resistor they have an interesting property that will divide the voltage. Since they’re in series, there’s only one path for current to flow so that means that the current will be the same through each resistor. The total resistance will determine this current. And each resistor will share a portion of the voltage. If you have two resistors and they’re both the same value, then each will share half the voltage. But if one resistor is larger, then it will carry more of the voltage. You can use this in designs where you want to adjust maybe the volume or brightness or speed of something. You can use a variable resistor called a potentiometer or pot for short. Most knobs that have a minimum and maximum amount they can be turned are actually variable resistors. Now if you have a newer device that has knobs that can turn as much as you want, then these are not potentiometers. Listen to the episode or you can also read the full transcript below. Transcript Make sure to listen to recent earlier episodes especially about voltage, current, and resistance. This episode builds on that. Let’s start with something basic. You should never connect a 5 volt supply voltage directly to ground. Or whatever voltage level you’re working with. This is called a short. Because you provided a shortcut path for all the current to flow through instead of the rest of your circuit. Sometimes you might want to short out a portion of your circuit but never the whole thing. Not only will your circuit stop working, but you could damage the power supply, blow out fuses, and many other undesirable effects. Current will always take the path of least resistance. And a short has almost no resistance. The power supply will try to maintain its voltage level and that means it’ll have to push a lot of current through a short circuit. It may not be able to keep up. You can damage batteries and start fires. Always make sure that there’s a proper amount of resistance between your positive and negative power supply terminals. Or between 5 volts and ground in many cases. A circuit with just some resistors may not seem very interesting but you can learn something. If you put two resistors in-line with each other, then the total resistance will be the sum of each resistor. This type of arrangement is called in series. You can learn more by listening to the previous episode about series vs. parallel. While you can think of multiple resistors in series as being equivalent to a single larger resistor they have an interesting property that will divide the voltage. Since they’re in series, there’s only one path for current to flow so that means that the current will be the same through each resistor. The total resistance will determine this current. And each resistor will share a portion of the voltage. If you have two resistors and they’re both the same value, then each will share half the voltage. But if one resistor is larger, then it will carry more of the voltage. You can use this in designs where you want to adjust maybe the volume or brightness or speed of something. You can use a variable resistor called a potentiometer or pot for short. Most knobs that have a minimum and maximum amount they can be turned are actually variable resistors. Now if you have a newer device that has knobs that can turn as much as you want, then these are not potentiometers. A potentiometer is really just a fixed resistor that has a sliding terminal that can be moved up and down t
April 24, 2017
Have you ever wondered why batteries sometimes need to be inserted in alternating directions? A typical electronic circuit has lots of components connected together with wires. How these connections are made is important and can lead to very different results depending on what’s being connected. If you put two resistors in-line with each other, then the total resistance will be the sum of each resistor. This type of arrangement is called in series. Electronic components don’t care about how they’re arranged in a circuit or which direction they’re facing. The only thing that matters is how they’re connected. If current has to pass through multiple resistors, then they’re in series with each other and the total resistance will be the sum of all of the resistors. In effect, they all act like a single resistor. If current can pass through any of multiple resistors, then they’re in parallel to each other and the total resistance will be lower than the smallest resistor. How much lower depends on how many resistors and their values. What you do is add the reciprocals of each resistance and then take the reciprocal of that sum to get the total resistance. A reciprocal of a number is just 1 divided by the number. So the reciprocal of 5 is 1 divided by 5. The reciprocal of 10 is 1 divided by 10. A good calculator will even have a button just for this purpose. It’ll be labelled as 1 over X. The important thing to remember is that placing resistors in series increase the total resistance and placing them in parallel lowers the total resistance. What about capacitors? They can also be placed in series or in parallel. Do they behave the same way? They actually are just the opposite. If you put multiple capacitors in series, then the end result is as if you replaced them all with another capacitor where the plates are spaced further apart. This lowers the total capacitance. And putting multiple capacitors in parallel is like increasing the size of the plates. That will increase the capacitance. So when you have capacitors in series, you calculate the total capacitance just like resistors in parallel by adding the reciprocals and then taking the reciprocal of that. And capacitors in parallel add their capacitance just like resistors in series. Listen to the full episode to understand how batteries behave in series and parallel. You can also read the full transcript of the episode below. Transcript A typical electronic circuit has lots of components connected together with wires. How these connections are made is important and can lead to very different results depending on what’s being connected. In this episode you’ll learn about series and parallel connections with resistors, batteries, and capacitors. Make sure to listen to recent episodes to get the most out of this episode. Let’s start with a simple circuit with just a battery and a couple resistors. That’s not a very useful circuit. But knowing where to place resistors, of what value, and what the result will be is useful. If you put two resistors in-line with each other, then the total resistance will be the sum of each resistor. This type of arrangement is called in series. Imagine a narrow hallway that makes it difficult for people to walk. This is like a resistor. If you then add another hallway so that in order to reach your destination you have to walk through both hallways, then they’re in series and the total resistance is the sum of both hallways. But what if these narrow hallways are placed so they both leave the starting room through different doors and they both arrive at the same destination. Now to get to your destination, you no longer have to walk through both hallways but can take your pick. If you have a lot of people, then some people will use the first hallway and some will use the second. The hallways can be said to be in parallel in this case. They don’t actually have to be physic
April 17, 2017
Do you know how your touch screen works? In this episode, you’ll learn about an important electrical effect called capacitance that can be used like batteries, to control timing, and even to detect touches. Listen to the full episode for more explanation about how capacitance can be used to detect when and where a person touches a screen. Or you can also read the full transcript below. Transcript In this episode, you’ll learn about an important electrical effect called capacitance that can be used like batteries, to control timing, and even to detect touches. Capacitance is the ability to store a charge. Not like how a battery produces charge through a chemical reaction but by storing positive and negative charge directly. Let’s say you have a piece of metal. You can push extra electrons into the metal or draw electrons out creating either a negative or positive charge. But at some point it gets harder to move the charge. Think of an empty bus that you try to fill with people. At first, it’s easy for people to board but soon the bus becomes crowded and people start resisting other people getting too close. It doesn’t matter what shape the bus is just like it doesn’t matter what shape the metal is. You can fit more people on the bus though if they all cooperate and don’t mind being so close. But what can you do about electrons? A positive or negative charge creates a static electric field which will attract opposite charge just like how opposite magnetic fields attract each other. We can use this to pack electrons tighter and to remove more electrons. All we need to do is fill one piece of metal with positive charge and another with negative charge. Then to get more charge, put the two pieces of metal close together but not touching so that the static electric field can reach into the other piece of metal and help pull more of the opposite charge into the other side. Both sides will end up helping fill the other side with charge. But there’s only so much that an electric field can help and it gets weaker the farther away you go. Because the shape doesn’t matter, we can make the pieces of metal flat so more area can be placed next to the other side. Because the sides are flat, they’re called plates. That’s all that really goes into making a capacitor. I mentioned that the sides shouldn’t touch because if they do, then the stored charge will equalize between the two sides and maybe ruin the capacitor. There’s a separator in capacitors called the dielectric. It’s really just a material that can stop direct current from flowing while letting electric fields pass easily. This material can even be air. Capacitance is measured in farads and a one farad capacitor will be able to store one coulomb of charge and produce one volt between the two plates. Most capacitors are much smaller than a farad and are measured in microfarads which are millionths of a farad or picofarads which are billionths of a farad. But it is possible, especially with modern manufacturing to make large capacitors of a farad or more. If you ever need to open an electronic device you need to be careful of large capacitors because even if the device is unplugged, the capacitors can still hold a tremendous amount of charge. This charge is ready to move immediately and doesn’t need to wait for a chemical process to produce more charge. I’ve been shocked with capacitors before and my whole arm ached for a week. Capacitors can also be filled with charge rapidly. Again, there’s no need to wait for any chemical reaction. At the speed that modern computers operate, it’s possible for some integrated circuits to need more power than can travel from the power supply fast enough. Capacitors can act like little storage units spread throughout the printed circuit boards. They can even be placed inside integrated circuits to help make sure that power is available whenever i
April 10, 2017
Moving charge produces a magnetic field and a moving magnetic field produces current. First of all, if you have charge moving through a wire, then there’ll be a magnetic field that develops around the wire. You’ve probably seen experiments with iron shavings and how they form lines on a piece of paper when a magnet is placed under the paper. The lines go from one end of the magnet to the other in 3 dimensions. Even though the paper only shows 2 dimensions, the magnetic lines still go all around the magnet from one end to the other. The iron pieces line up with the magnetic field and arrange themselves in lines. What kind of lines do you think would appear around a wire if you were to do the same experiment? Here’s where it’s a little different. You’re not going to see the same kinds of lines because the magnetic field doesn’t form along the wire. It forms around the wire. The way this effect is normally used is by coiling the wires in lots of loops all in the same direction. This causes the magnetic field to bend around so that it’s going one direction inside the loops and the other direction outside the loops. It also concentrates the magnetic field and you can get a noticeable magnetic effect with current flowing through the looped wire. This is called an electromagnet because it produces a magnetic field only when electricity is flowing. Listen to the full episode or read the full transcript below to learn about how this effect can be used by computers as well as to change AC voltages. Transcript The most important part of that description is moving. If you only remember one thing from this episode, let that be it. There’s some more details that I’ll explain as well as how this effect can be used. First of all, if you have charge moving through a wire, then there’ll be a magnetic field that develops around the wire. You’ve probably seen experiments with iron shavings and how they form lines on a piece of paper when a magnet is placed under the paper. The lines go from one end of the magnet to the other in 3 dimensions. Even though the paper only shows 2 dimensions, the magnetic lines still go all around the magnet from one end to the other. The iron pieces line up with the magnetic field and arrange themselves in lines. What kind of lines do you think would appear around a wire if you were to do the same experiment? Here’s where it’s a little different. You’re not going to see the same kinds of lines because the magnetic field doesn’t form along the wire. It forms around the wire. If you were to poke a hole in the paper and stick the wire through the paper, then you might be able to see some magnetic lines appearing in circles around the wire. I haven’t tried this experiment so don’t know how much current is needed before you can see anything. The way this effect is normally used is by coiling the wires in lots of loops all in the same direction. This causes the magnetic field to bend around so that it’s going one direction inside the loops and the other direction outside the loops. It also concentrates the magnetic field and you can get a noticeable magnetic effect with current flowing through the looped wire. This is called an electromagnet because it produces a magnetic field only when electricity is flowing. If you then put a piece of iron or steel which has iron in it inside the coils, then it can pull the metal and hold it inside the coils. Or if the metal is fixed in place but the coil is allowed to move, then the coil can be held in place around the metal. And by adjusting the amount of current, you can control the strength of the magnetic field. This is how speakers work inside your computer. The coil is attached to a springy surface such as paper and as the current is adjusted it causes the coil to move back and forth. This also moves the paper which pushes on the air. As the paper pushes on the air, it cau
April 3, 2017
Do you know where the nearest power plant is? Direct current is easy to understand because there’s a constant voltage that wants to push charge through a circuit in a single direction. But if DC is so simple, why does the world use AC to power our homes and offices? Back in the late 1800’s this was not decided at all and depending on where you lived, you might actually have DC supplied to your home. The reason AC finally won is because of two reasons. First, we don’t want high voltages in our houses. 240 volts in some parts of the world is high enough. And second, electric companies are in business to make money and that means they don’t want to waste resources by losing power in the power lines. If power is being used anywhere, the electric company wants somebody else to be paying for it. They don’t want to be paying themselves to warm up birds perched on the lines. Make sure to listen to the full episode for the full explanation of how AC solved these issues. You can also read the full transcript below. Transcript In the last episode, I started explaining some simple electronics that will help you become a better programmer. This episode builds on that by explaining the reasons why the world uses alternating current instead of direct current. They’re usually abbreviated as AC and DC. Direct current is easy to understand because there’s a constant voltage that wants to push charge through a circuit in a single direction. That doesn’t mean that the charge will always flow in that direction such as when charging a battery, you sort of overpower the battery and force the charge to flow back into the battery. But in general, DC is fairly easy to deal with. So if DC is so simple, why does the world use AC to power our homes and offices? Back in the late 1800’s this was not decided at all and depending on where you lived, you might actually have DC supplied to your home. The reason AC finally won is because of two reasons. First, we don’t want high voltages in our houses. 240 volts in some parts of the world is high enough. And second, electric companies are in business to make money and that means they don’t want to waste resources by losing power in the power lines. If power is being used anywhere, the electric company wants somebody else to be paying for it. They don’t want to be paying themselves to warm up birds perched on the lines. Let me fill in some missing pieces here. First, you need to know a little about power. I’m talking about power in a specific technical electrical sense and not as in how we normally say something like, “That machine’s really powerful.” Power is defined as voltage times current and is measured in watts. When you add time to this, you get a watt-hour which is a unit of energy. If you use one watt of power for an entire hour, then you’ve used one watt-hour of energy. The electric company will bill you in terms of kilowatt-hours which are 1000 watt-hours. If you listen to last week’s episode, then you’ll also know that voltage is equal to current times resistance. What resistance am I talking about? The power lines are made of aluminum or copper because they conduct electricity very well. But they still have a small amount of resistance. And that resistance increases as the line gets longer. This means that the farther away you live from the power plant, the higher the resistance will be. It’s also the one thing that’s fairly constant. What I mean is that while, sure, the electric company can install new power lines made of some new material with a lower resistance, they don’t do this every day. Once power lines are installed, they remain for years. Now if we combine the two formulas and rearrange things a bit, we get power equals current squared times resistance. That’s important because it means that current is much more important when calculating power than resi
March 27, 2017
Knowing some basic electronics helps you become a better programmer. You might have seen warning signs that say “Danger: High Voltage” But do you know what voltage really is? You’ve probably used batteries until they’re dead. But do you know what that means? I’ve talked about high voltages representing binary ones and low voltages representing binary zeros. What are these voltages? Is high voltage in a computer the same as high voltage at a construction site? The way I first learned to think about voltage was using water and pipes as an example. You might think that water is voltage but that’s not quite right. Water will flow from a high place to a low place because of gravity and if you restrict this flow by making it go through pipes, then it’ll build up pressure. This is why towns build water towers to raise water high in the air. It provides a reservoir of water with a natural tendency to create pressure. The water itself in this example relates to charge. The pressure is voltage. The flow of the water is current. And the pipes not only resemble wires but also act as a source of resistance. Let me explain each of these a little more. Listen to the full episode for a more detailed explanation of charge, voltage, current, resistance, as well as Ohm’s Law and how they relate to each other. You can also read the full transcript below. Transcript You might be wondering why I would talk about electronics. This is a podcast about programming and I mean to keep that focus. However some understanding of electronics can actually help you become a better programmer. Especially if you’re programming robots, or 3D printers, or whatever invention you’re working on. Programming is becoming more and more important. And the best programmers will be the ones who can apply their skills beyond the computer and smart phone. I studied electrical engineering in college not only because it was fun and interesting but because I knew that it would allow the most flexibility with my career. I knew that I could continue with electronics or become a programmer. Going the other way is much harder. But exploring just a little electronics is not that difficult. I’ll stick to the basic concepts that I think will help you the most. You might have seen warning signs that say “Danger: High Voltage” But do you know what voltage really is? You’ve probably used batteries until they’re dead. But do you know what that means? I’ve talked about high voltages representing binary ones and low voltages representing binary zeros. What are these voltages? Is high voltage in a computer the same as high voltage at a construction site? The way I first learned to think about voltage was using water and pipes as an example. You might think that water is voltage but that’s not quite right. Water will flow from a high place to a low place because of gravity and if you restrict this flow by making it go through pipes, then it’ll build up pressure. This is why towns build water towers to raise water high in the air. It provides a reservoir of water with a natural tendency to create pressure. The water itself in this example relates to charge. The pressure is voltage. The flow of the water is current. And the pipes not only resemble wires but also act as a source of resistance. Let me explain each of these a little more. Let’s start with charge? Atoms have electrons with negative charge orbiting a nucleus of protons with positive change and neutrons with neutral charge. Atoms have the same number of electrons as protons which cancels the charge and the atom as a whole has no charge. But if you take away some electrons or add some extra electrons, then the atom becomes an ion. Charge is measured in coulombs and it takes 6.242 x 10 to the 18th power number of electrons to get 1 coulomb of negative charge. You can also have the same number of protons to get 1 coulomb of
March 20, 2017
How do you send multiple messages across a single channel? Multiplexing is a topic that applies most to communications but it also applies to computer networks. It’s an advanced topic that I won’t be able to fully explain in this podcast. But you will understand the basic concepts. Imagine that you want to send multiple messages consisting of a series of bits but at some point in the network there’s only a single wire to transmit signals. One option is to devote the communication channel to one message at a time. You’ll need to hold the other messages for as long as it takes. This is probably not a very good idea though. Multiplexing is just a way for you to share a limited communication channel across different messages and purposes. Whatever technique is used to multiplex the messages, there needs to be something on the other side called a demultiplexer. Listen to the full episode, or read the full transcript below, for the full explanation where I use cars and traffic lights as examples. Transcript Multiplexing is a topic that applies most to communications but it also applies to computer networks. It’s an advanced topic that I won’t be able to fully explain in this podcast. But you will understand the basic concepts. Imagine that you want to send multiple messages consisting of a series of bits but at some point in the network there’s only a single wire to transmit signals. This might seem like an unlikely situation but I’m just simplifying things. All networks will have some maximum capacity they can support. It’s easier to think about a single wire first, and once you understand, then you can apply that knowledge to real situations. This actually happens all the time with electronics. There’ll be times when you want to send messages to different destinations and have only a single wire. One option is to devote the communication channel to one message at a time. You’ll need to hold the other messages for as long as it takes. This is probably not a very good idea though. Imagine if you wanted to drive to the grocery store but get stuck at the first traffic light. It just stays red because everybody going the other way is going to work. And the sign says that your light will remain red the whole time until everybody going to work the other way has passed. You’re not going to be very happy. That’s the whole purpose of traffic lights. To share a single intersection between cars that want to go in different directions. This is multiplexing. To be more accurate, it’s time based multiplexing. And you can do the same thing when sending information. You can either switch between messages after every bit or you can give each message a little more time and maybe switch after every byte or more. This is like the difference between stop signs that let single cars through an intersection vs. traffic lights that let multiple cars through. Multiplexing is just a way for you to share a limited communication channel across different messages and purposes. Whatever technique is used to multiplex the messages, there needs to be something on the other side called a demultiplexer. You don’t really have this concept in traffic lights because the entire car gets to go through the intersection. When we’re talking about computers or electronics though, the size of the data being multiplexed is usually smaller than the whole message. Imagine if traffic lights were designed to slice your car into little pieces before letting each piece through the intersection. This is where you’d need a demultiplexer to put the car back together on the other side. What actually happens in electronics is a little different. The bits arrive on their own wires, go through a multiplexer which pushes the bits across a shared channel, and then a demultiplexer on the other side separates the bits and puts them back on their own wires. As long as we’re talking about
March 13, 2017
How do you correct errors once you identify them? I’ve explained a lot already about error detection. Make sure to listen to the last several episodes for more information. Detecting errors is the first step and the most important. I mean, if you don’t know that something went wrong, then you’re not even going to try fixing it, right? If you’re sending a file over a network and you detect an error, usually, the easiest way to correct the error is to throw away what you received and ask for the sender to retransmit the part that was bad. You shouldn’t need to start over from the beginning unless the data you’re sending is so small that it already fits in a single packet of data. What if you can’t retransmit the data? Either because it’s gone or impractical to transmit again. Maybe there’s a single source of data that’s being sent to hundreds or thousands of recipients in real time. You can’t expect the sender to stop and retransmit information each time a recipient complains that it didn’t receive the correct information. One thing to consider is what effect would this have on the recipient. Is it okay to just ignore the problem? If you’re sending audio, then maybe you can ignore some data without the listener even noticing. You can do this as long as you have some data before and after the error. That’s because even though you may not know the exact missing value or values, you can probably guess what the data would likely have been. Another technique you can use to correct errors uses Hamming codes that have enough Hamming distance between them that you can guess which value was likely sent. Make sure to listen to the full episode for examples and more explanation. There’s even an example of how our brains do error correction everytime we look at something. Or you can also read the full transcript below. Transcript I’ve explained a lot already about error detection. Make sure to listen to the last several episodes for more information. Detecting errors is the first step and the most important. I mean, if you don’t know that something went wrong, then you’re not even going to try fixing it, right? If you’re sending a file over a network and you detect an error, usually, the easiest way to correct the error is to throw away what you received and ask for the sender to retransmit the part that was bad. You shouldn’t need to start over from the beginning unless the data you’re sending is so small that it already fits in a single packet of data. What if you can’t retransmit the data? Either because it’s gone or impractical to transmit again. Maybe there’s a single source of data that’s being sent to hundreds or thousands of recipients in real time. You can’t expect the sender to stop and retransmit information each time a recipient complains that it didn’t receive the correct information. One thing to consider is what effect would this have on the recipient. Is it okay to just ignore the problem? If you’re sending audio, then maybe you can ignore some data without the listener even noticing. You can do this as long as you have some data before and after the error. That’s because even though you may not know the exact missing value or values, you can probably guess what the data would likely have been. Let me give you an example. Let’s say that I send you the values 1, 2, 3, then an error causes you to throw away the next value. After that, you get the values 5 and 6. This is an easy example because all the values you did get form a straight line and it’s likely that the missing value would be 4. Just imagine listening to somebody counting and you sneeze right when they say 4. You could fill in the missing 4 with no problem. Now, it’s always possible that the other person made a mistake and counted 1, 2, 3, 8, 5, 6. And this shows that correct
March 6, 2017
How do you stop an attacker from just changing a hash? In the previous episode, I explained how hashes give you the best error detection even when under a direct attack. But the best hash function by itself is not enough. This episode will explain step by step how an attacker can defeat simple attempts to protect data and what you can do about it. Make sure to listen to the full episode where I describe how another hash creates something called an HMAC and how it can be used to prevent length extension attacks. Or you can also read the full transcript below. Transcript In the previous episode, I explained how hashes give you the best error detection even when under a direct attack. But the best hash function by itself is not enough. This episode will explain step by step how an attacker can defeat simple attempts to protect data and what you can do about it. Let’s start with this scenario: You’re designing a game that allows a player to login and then issue instructions to a central server that tell the server where to move the player’s character. If you were playing this game, would you want your opponents to be able to issue commands as if the commands came from you? Not only would the game be unfair, nobody would want to play anymore once the vulnerability became known. So you need to design the game server so it won’t accept any false or malicious commands from other players. If you’re only worried about detecting accidental errors made during transmission of the instructions as the messages travel to the server computer, then you could use a hash. Just create a hash of each instruction and send that along with each instruction. The server can then perform the same hash, compare them, and ask for the instructions to be retransmitted if the computed hash doesn’t match the hash that was sent. This means that your game must remember commands for at least a short while in case they need to be sent again. There are things you can do that would allow the server to sometimes correct an error on its own without asking for the data to be sent again. That’s a whole other topic and I’ll explain error correction in a future episode. The problem with sending a simple hash is that an attacker can send commands intended to disrupt another player’s character. All that attacker has to do is send a command that causes the other character to jump off a cliff and the attacker wins the game. The server accepts the command because it has a valid hash and therefore could not possibly have been accidentally changed during transit. How do we fix this? One of the most important things to realize about security is that there are boundaries that define what’s trusted vs. everything else outside of the boundary that’s not trusted. At some point, something has to be trusted or you might as well go back to designing a single user game that can only be played on a single computer. Then if that user wants to cheat, no problem. The game will quickly become boring though. There’s very little you can do by trying to add security to the player’s computer. It has to be considered outside of the security boundary and therefore a source of possible attacks. Alright, so back to the game design. Maybe your first thought is to add a MAC or a message authentication code instead of a simple hash. A MAC is really nothing more than a hash of some secret key along with the message. The hash function doesn’t have to change and produces the same type of output. Just adding a key to the message results in a different hash value. So where does this key come from? It has to come from the server because that’s inside the trusted zone. In other words, without realizing it, when players agree to play your game, what they’re actually saying is that they agree to trust your server to make sure that the game is fair. They’re not going to trust some other player’s computer.
February 27, 2017
If you receive some information, how do you know if it’s intact or has been changed? You use a hash in a similar way to a checksum by including it along with the data. If you want to verify that the data is correct, recalculate the hash and compare. There are many ways to calculate a hash. This episode will describe two broad categories of hash functions, non-cryptographic hash functions and cryptographic hash functions. You can create or use hash functions that avoid accidental collisions or sometimes don’t worry much at all about collisions. I was at a pharmacy recently and noticed behind the counter was space to hold prescriptions that were waiting to be picked up. Each prescription was placed in a paper bag with what looked like the first two letters of the person’s last name. That’s a hash function. Not very complicated, but still a hash function. Two letters gives you 26 times 26 for a total of 676 possible hash values. There’s many reasons this is not a very good hash function for general use including the fact that it’s not very random. This means that some hash values will be more common than others. And I don’t know anybody who’s last name begins with double Q’s. But for the pharmacy, using the first two letters of a person’s last name works great. It’s a good hash function for their needs. There’s no need for anything more complicated or elaborate. Other hash functions could be more complicated and make use of thousands or millions or even more possible hash values. These are all non-cryptographic hash functions because while they can help detect accidental errors, they won’t help protect your information against attacks done on purpose. A non-cryptographic hash function is designed to meet your application’s needs assuming you don’t have to worry about your hash values being used by an attacker. For that, you need a cryptographic hash function. Listen to the whole episode for more information about well-known cryptographic hash functions MD5, SHA-1, SHA-2 (including SHA-256 and SHA-512), and SHA-3. You can also read the full transcript below. Transcript You might want to listen to episode 43 about hash tables. It’s a different way to use hashes but I explained several properties of hashes that apply even here to error detection. I’ll assume you already know what I’m talking about when I refer to hash collisions. You use a hash in a similar way to a checksum by including it along with the data. If you want to verify that the data is correct, recalculate the hash and compare. There are many ways to calculate a hash. This episode will describe two broad categories of hash functions, non-cryptographic hash functions and cryptographic hash functions. Before that, though, why are hash functions sometimes better than checksums? One reason is checksums can’t detect if extra zero values are inserted or if some portions of the data are swapped. Let’s say you have a simple checksum that really does add bytes. If you have a short message with the values 5 and 3, then the sum is 8. But what’s 5 plus 3 plus zero? Still 8. What’s 5 plus 0 plus 3? Still 8. What about 3 plus 5? Still 8. Depending on how you’re calculating the hash, it could detect these types of errors. You can create or use hash functions that avoid accidental collisions or sometimes don’t worry much at all about collisions. I was at a pharmacy recently and noticed behind the counter was space to hold prescriptions that were waiting to be picked up. Each prescription was placed in a paper bag with what looked like the first two letters of the person’s last name. That’s a hash function. Not very complicated, but still a hash function. Two letters gives you 26 times 26 for a total of 676 possible hash values. There’s many reasons this is not a very good hash function for general use including the fact that
February 20, 2017
If you receive some information, how do you know if it’s intact or has been changed? I’m going to continue explaining how you can detect errors in this episode. Make sure to listen to the previous episode also. And the best option is to subscribe to the podcast through your podcast application so you’ll be sure to get episodes automatically as soon as they’re published. This is a simple episode but don’t be fooled. I actually learned something myself while preparing this. Something very basic about math. I’ve said many times that you don’t need to know a lot about math in order to program and I’ll always try to simplify and reduce the amount of math that’s needed. This episode will contain a lesson in logic and another brief math lesson. The actual subject of checksums will then use these techniques. What I’m going to explain about logic is easy but you might want to make sure to listen to the Q&A Friday episode from 2015-Dec-18 first about logic operators. And you should be able to follow along the math lesson with a basic ability to do long division. Before we get into that, why are checksums used and what are they? A checksum is another way to detect errors. This could help you detect errors when reading, writing, or receiving and sending information. The previous episode explains parity and you can use parity along with checksums if you want. Neither of these will help you detect errors made on purpose where an attacker has tried to hide the evidence. They’re easy to get around and really only good for detecting errors caused by random events or noise. Using a checksum is not as complicated as using cryptography. I’ll explain cryptography in future episodes. Checksums have an advantage similar to parity; they’re easy and fast to calculate. The word checksum usually refers to the result of the calculation. It’s an extra piece of information that gets added onto your data that does as the name suggests. It allows you to check the sum. I’ll describe two different ways to create a checksum in this episode, longitudinal parity check and Fletcher checksum. Listen to the full episode or read the full transcript below. Transcript I’m going to continue explaining how you can detect errors in this episode. Make sure to listen to the previous episode also. And the best option is to subscribe to the podcast through your podcast application so you’ll be sure to get episodes automatically as soon as they’re published. This is a simple episode but don’t be fooled. I actually learned something myself while preparing this. Something very basic about math. Now, I come across things that I don’t know all the time. But this one, wow, was like learning some new aspect about one plus one equals two. I’ve said many times that you don’t need to know a lot about math in order to program and I’ll always try to simplify and reduce the amount of math that’s needed. This episode will contain a lesson in logic and another brief math lesson. The actual subject of checksums will then use these techniques. What I’m going to explain about logic is easy but you might want to make sure to listen to the Q&A Friday episode from 2015-Dec-18 first about logic operators. And you should be able to follow along the math lesson with a basic ability to do long division. Before we get into that, why are checksums used and what are they? A checksum is another way to detect errors. This could help you detect errors when reading, writing, or receiving and sending information. The previous episode explains parity and you can use parity along with checksums if you want. Neither of these will help you detect errors made on purpose where an attacker has tried to hide the evidence. They’re easy to get around and really only good for detecting errors caused by random events or noise. Imagine you have a device to ch
February 13, 2017
If you receive some information, how do you know if it’s intact or has been changed? Let me make this point clear from the beginning. Error detection only lets you detect errors. It doesn’t correct them. You have to provide other means to fix any errors. Usually this just means trying again. Parity works by including an extra bit for a small fixed number of data bits. You might want to include a parity bit for every byte or eight bits. This means that if you want to send a parity bit for every eight data bits, then you’ll really be sending and receiving nine bits instead of eight. The other option is to take a data bit away. Maybe you need to send information through a connection that can only support a fixed number of bits. You can’t just add an extra bit. So instead, what you do is devote one of the bits as the parity bit. This leaves you with one fewer bits to use for your actual data. Okay, so how does parity actually work? It sets or clears the parity bit in order to make the total number of bits with the value of 1 be either even or odd. Setting a bit just means to make its value one. And clearing a bit just means to make its value zero. Listen to the full episode or read the full transcript below for more details on parity. Transcript When I was little, my school teacher asked the class to form a line and relay a message from one kid to the next. Everybody thought it was funny that the message at the end was nothing like how it started. Some kids would forget parts, some would leave parts out because they thought it wasn’t important, and some would add new things based on what they thought they heard. It’s amazing how closely programming resembles real life. I know I say that a lot. But it’s true! You might think a computer won’t forget things, or choose to leave things out. And how could a computer make up it’s own story? Well, these things do happen. And we need a way to detect them. Let me make this point clear from the beginning. Error detection only lets you detect errors. It doesn’t correct them. You have to provide other means to fix any errors. Usually this just means trying again. Where can errors enter your application? It’s easy to understand where the errors come from in a line of kids. How about computers? Computers are a lot more reliable today than they used to be and they’re getting better. I remember when hard drives had a sticker that listed all the bad sectors. Those were places on the disk known to have defects. The worst part was the label had empty spots. Room to add your own bad sectors. I would run utilities every few months that would scan the entire disk. It would write data and make sure the same data could be read back again. Sometimes a value would be written and a different value read back. That was a bad sector and would have to be avoided because it was unreliable. Over time as I found new spots on the disk that were bad, I would write down the locations on the sticker. Even though we don’t have to go through this anymore, there can still be errors when reading or writing data. Usually, once data is loaded into a computer, it’ll stay there. But nothing is absolute. It’s possible for data in memory to fail to be written properly or even to change. Not likely, but possible. You’re much more likely to get errors when sending information from one computer to another. I’ve been talking about this a lot since episode 159. And we have protocols designed to deal with errors. But so far, I haven’t described how to actually detect when an error occurs. Let’s start with a simple example. You want to send two binary bits and they’re both zeros. What possible results can you expect? Well, first of all, you might actually get what was sent. But how do you know that it’s correct? What if you receive 01 instead? Was that what was sent? What if you only receive a single 0? Or mayb
February 6, 2017
Why should you learn how to program? What is programming? What specific steps can you take? How can you apply programming? While there’s many ways to apply programming outside of getting computers to do what you want, it’s even more important if you’re dealing with software. If you’re a manager in a software company, then your insight will enable you to hire better programmers. If you’re selling software, then you’ll really have an advantage. And if you’re writing a high-tech thriller, then it’s likely that one of the main characters will need some coding skills. I don’t blame you if you’ve taken a programming course before and either didn’t like it or didn’t understand it. Many courses focus on the wrong things and dive too deep into theory. Or maybe the course is too much of an overview or introduction that leaves you unsure how to proceed on your own. I’ve said many times that programming is a journey. You don’t start out with a blank page and write an application from start to finish. To me, you shouldn’t learn everything from start to finish either. That would be like trying to learn how to speak a language by learning words in alphabetical order. Instead, focus on important topics that you need. That doesn’t mean to ignore everything except the current function. Remember that I recommend starting each project with a quick look around to see if there are any better tools, technologies, or ways to do things than what you might already know. But what you don’t need is to spend years in college before ever trying to write your first program. Take action and start. My advice is to find something simple that you currently do manually. Something you understand well and that would benefit you if it could be automated. Don’t start out thinking you’ll create the next office word processing software or the next blockbuster game. Listen to the full episode for more guidance including a short introduction to agile development. You can also read the full transcript of the episode below. Transcript Programming can help you no matter what goals you have. If you’re planning to become a manager, you can use programming to help you keep track of inventory, hours, scheduling, tasks, or money. If you’re planning to become a master salesperson, a better understanding of programming will help you make better use of technology resulting in an advantage that a lot of other salespeople will overlook. Even if your goal is to write the next best-selling novel, learning more about programming will add realism that will be noticed. While there’s many ways to apply programming outside of getting computers to do what you want, it’s even more important if you’re dealing with software. If you’re a manager in a software company, then your insight will enable you to hire better programmers. If you’re selling software, then you’ll really have an advantage. And if you’re writing a high-tech thriller, then it’s likely that one of the main characters will need some coding skills. I want to keep this episode focused on how you can apply programming as a programmer though. I don’t blame you if you’ve taken a programming course before and either didn’t like it or didn’t understand it. Many courses focus on the wrong things and dive too deep into theory. Or maybe the course is too much of an overview or introduction that leaves you unsure how to proceed on your own. I’ve said many times that programming is a journey. You don’t start out with a blank page and write an application from start to finish. To me, you shouldn’t learn everything from start to finish either. That would be like trying to learn how to speak a language by learning words in alphabetical order. Instead, focus on important topics that you need. That doesn’t mean to ignore ever
January 30, 2017
Why should you learn how to program? What is programming? What specific steps can you take? How can you apply programming? This episode shares the following major aspects you can consider and it allows you to think about these from two different viewpoints – either starting a new project or joining an existing project that’s already established. Platform – have you considered the differences between a native application vs. a web application? Or maybe you just need a script or you can combine two or more existing solutions together. Configuration – how will you allow your application to adapt to environment differences, respond to administrative control, and allow users to provide their own preferences? Extensibility – will you allow your application to grow and change based on enhancements or new adaptations? Testing – how will you ensure that your code works as expected? Data storage – where and how will your application store information? Versioning – how will your application deal with different development versions and eventually different customer versions? Documentation – how will you deal with both documentation for internal development as well as for customers? Version control – what systems and tools will you use to keep track of your source code? How are changes reviewed and approved? Bug and issue tracking – how will you keep track of work items, customer requests, and bugs? How will you identify and troubleshoot bugs when they do happen? Requirements – how will you keep track of what the customer actually requires and map that back to individual features and changes? Communications – How will the various components send and receive messages. Listen to the full episode or you can also read the full transcript below. Transcript There’s different ways I could go with this episode and my first thought is to encourage you to be consistent, curious, and to experiment with specific goals. In other words, take action right away and get started and then don’t stop. Maintain a steady pace with your learning and even if you spend just an hour a week, you’ll be surprised at how far you’ll progress after three to four months. It also helps if you get involved with others learning how to program because you’re sure to face resistance from friends and even family. It’s hard to change and we naturally resist change within ourselves and in the people we know. I’ll be starting the live weekend classes again once things settle down a bit more from the move to New York. Right now, my weekends are still occupied arranging things. This is a great way for you to get the support you need to begin programming or take your skills to a new level. I’ve already went over these topics in early episodes. And while I’ll surely discuss them again in the future, for today, I want to explain some different specific steps you can take. Let’s divide this episode into two halves. In the first half, I’ll share steps you can take to help you program a new project. One you haven’t started yet but already have an idea. In the second half, I’ll share some steps that will help you be more productive when starting on a project that’s already quite far along. You can use recommendations from either of these extremes to fit your specific needs. Both of these halves could be further divided based on your current skill level and experience and even by the expected size of the project when completed. I’m not going to go into all of that and will instead focus on what a more experienced programmer might consider. Don’t worry, if you’re just starting out, I’ll also recommend a couple places to start. Okay, you have an idea. I’m going to assume this is something you can at least get started on by yourself. It’s a whole different story if you need a team of programmers
January 23, 2017
Why should you learn how to program? What is programming? What specific steps can you take? How can you apply programming? To be a good programmer, it doesn’t take a lot of math. Instead, you need to be able to break larger ideas and processes like how to play tic-tac-toe into small steps. Imagine you were trying to explain tic-tac-toe to a small child. Then take a step back and imagine that you’re watching yourself explain this to a small child. Where do you begin? Be alert for all the steps. You don’t just start putting X’s and O’s down on the paper. You first need to ask if the child wants to play. Then you can begin explaining the rules and eventually playing. There will usually be some parts you forgot about. What happens? The child will either ask or make a wrong move that you then have to explain. Maybe you forgot to mention that once you write a letter in a box, that it becomes unavailable for the other person to use. Seems obvious, right? Until the child draws an X on top of your O and claims victory. Even such a simple game is much easier to explain to a child than to a computer. That’s because the child can draw conclusions based on other games and life experiences and naturally understand things without being told. You don’t have that luxury with a computer. No matter how old a computer gets, it never develops any common sense at all. If you forgot to tell the computer about the same rule that you can’t make a move in a square that’s already occupied, then your game will likely crash. It’s a bug. The ability to program then, really comes down to how good you can be about planning for all the possible ways something can go wrong and writing instructions to either make sure they don’t happen in the first place or how to handle each situation if they do. The full episode explains more about programming and how you write the instructions that the computer will follow. Listen or read the full transcript below. Transcript The topic today is what is programming. Now, I already explained this in episode 2. I’ll try not to mention the same things and that early episode remains a good resource to help you understand programming. I’ve talked with a lot of people about programming. People working in retail stores, attending seminars, selling products door-to-door, and others who ask me how to program. There’s a widely held belief that programming is hard and beyond their ability or doesn’t apply so why should they bother. I’ve had people tell me that they could never program because they’re no good with math. Or they have goals to become a manager instead. Or they tried it once and didn’t get good grades. And some have said that they know how to program already and have built web pages. I’m going to talk about these things while describing what is programming. I hope that you’ll realize that it’s not as hard as you thought and that it really is necessary. Listen to the previous episode for more discussion about why you should learn how to program. First of all, you don’t need to know a lot of math in order to program. Unless, of course, you’re programming something that inherently uses math such as a library that calculates physics equations. That sort of thing just isn’t very common though. Even if you want to create a game that allows a player to launch annoyed avians through the air following a smooth arc, you might be surprised by just how little math you really need to know. Most of the time, all I really need to do is add or subtract things. Let’s say you want to simulate a ball thrown up in the air, slowing down gradually, and then falling back down again. It should speed up as it falls. Does this require trigonometry, calculus, or some physics formulas where you have to remember the gravitational constant? No. All it takes is to add a little bit of velocity each time you
January 16, 2017
Why should you learn how to program? What is programming? What specific steps can you take? How can you apply programming? Even if you already know how to program, maybe you can introduce your friends to this mini series of episodes and get them started. Give them a new opportunity. Programming is a lot easier and rewarding than a lot of people think and I put a lot of thought into organizing and preparing examples that you can relate to. You’ll understand over these four episodes why programming is important, what is programming, how to get started and steps to learn programming, and how to apply programming in a meaningful way. I’ll explain each of these topics in four parts. Why should you learn how to program? I could talk for hours about how programming changes and enhances your ability to think and solve problems. About how learning to program improves your ability to think more clearly. And about how learning how to program gives you the ability to create your own applications. But I’m instead going to focus on a more tangible benefit. It’s very simple. If you want to be able to find any kind of meaningful job, you’re going to need to know how to program. If you want to keep a good job, you’re going to need to know how to program. If you want to be able to support a family and have the same opportunities as your grandparents, then you’re going to need programming skills. It’s not enough anymore to just be able to use computers. The full episode explores this topic more and will help you understand why learning how to program is critical to your future. It doesn’t matter what you do now or plan to do. You need to learn how to program. Listen or read further for the full transcript below. Transcript It’s been a while since I talked about topics like this. Even if you already know how to program, maybe you can introduce your friends to this mini series of episodes and get them started. Give them a new opportunity. Programming is a lot easier and rewarding than a lot of people think and I put a lot of thought into organizing and preparing examples that you can relate to. You’ll understand over these four episodes why programming is important, what is programming, how to get started and steps to learn programming, and how to apply programming in a meaningful way. I’ll explain each of these topics in four parts. Let’s dive right in. Why should you learn how to program? I could talk for hours about how programming changes and enhances your ability to think and solve problems. About how learning to program improves your ability to think more clearly. And about how learning how to program gives you the ability to create your own applications. But I’m instead going to focus on a more tangible benefit. It’s very simple. If you want to be able to find any kind of meaningful job, you’re going to need to know how to program. If you want to keep a good job, you’re going to need to know how to program. If you want to be able to support a family and have the same opportunities as your grandparents, then you’re going to need programming skills. It’s not enough anymore to just be able to use computers. I can help ease your journey. I’ve been there. I taught myself how to program. And I’ve studied how to teach things. I try to come up with examples that you can relate to and then show you how those examples represent programming concepts. We can’t walk through actual code in the podcast and that’s why I also offer live classes. The podcast is focused more on the ideas and concepts and the live classes are focused on real gaming projects. Some of my examples might be a bit strange at times and looking back, I agree. All I can say is that we remember strange things better than boring things. Just imagine for a moment what you’re life will be like if you don’t learn how to program. I can’
January 9, 2017
How does one application communicate with another application? So far, in the last several episodes, I’ve explained how to identify and find computers on a network, how to establish connections, how to think about communication in terms of seven layers, and a few different protocols. There are many more protocols. And there are many different types of networks not based on the internet protocol. Many of the concepts still apply and once you understand all of these things, you should be able to understand completely different ways to transport information between computers. But there’s one final piece that I haven’t described yet. I’ve never actually seen or heard of a computer itself that wants to talk to another computer. It’s always software running on a computer that does the communicating. And computers can run many different programs at once. Each running program is called a process. So what we really need to understand is how one process can communicate with another process. That’s the topic of today’s episode. Specifically, this episode describes how to communicate using sockets over an IP network. Since computers can run multiple processes, just routing communication packets to the right computer isn’t enough. We need some way to specify what process should receive the information. And that’s where ports come in. Think of it like this, when you send a letter to someone, you don’t just put the address, you also put a name on the envelope. The post office doesn’t really need the name to deliver the letter. Sure, they might check it just to make sure. But really, all the post office needs is the address. This is like the IP address is all that’s needed to deliver a packet to the right computer. But once it reaches the destination, the port acts like the name. The port lets the computer know which process is interested to receive the data. Sockets are resources provided by the operating system or drivers installed as part of the operating system. You may have a library called sockets or a library that uses something called sockets. This is a common name for network programming over an IP network. A socket is a concept that represents a communication channel with another computer. Make sure to listen to the full episode to learn how to use sockets and ports when writing networking software. And if you subscribe to this podcast in iTunes or other podcast directory, then you’ll get future episodes delivered automatically. You can also read the full transcript below. Transcript So far, in the last several episodes, I’ve explained how to identify and find computers on a network, how to establish connections, how to think about communication in terms of seven layers, and a few different protocols. There are many more protocols than I described here. And there are many different types of networks not based on the internet protocol. Many of the concepts still apply and once you understand all of these things, you should be able to understand completely different ways to transport information between computers. But there’s one final piece that I haven’t described yet. While it’s great that you know all of this, I’ve never actually seen or heard of a computer itself that wants to talk to another computer. It’s always software running on a computer that does the communicating. And computers can run many different programs at once. Each running program is called a process or sometimes an application. I tend to think of an application as the software itself. Like what you buy from the store. And a process is the running instance of an application. Sometimes, I might mix these terms up. But in general, a process is not something you buy. A process is software that’s running on your computer. So what we really need to understand is how one process can communicate with another process. That’s the topic of today&#8
January 2, 2017
You’ll learn more about the strengths of the SCTP, TCP, and UDP protocols by comparing them. The audio recording has much more detail about the following five questions. Is the protocol connection oriented? Both SCTP and TCP are but UDP does not establish connections. Is the data transfer reliable? In a way, this is related to the first question. I already said that UDP is not reliable. And both SCTP and TCP offer reliable data transfer. Are the data packets ordered? TCP guarantees that a receiver will receive packets in the order they were sent. UDP makes no guarantee at all about order. SCTP lets you choose. Is the protocol message based? With UDP, you’re sending packets of self-contained information. You have to because there’s no ordering and no connection to relate one message to the next. With TCP, you establish a connection and then just start sending data. SCTP acts more like UDP in this sense because it preserves message boundaries. Does the protocol support flow control and congestion control? Both SCTP and TCP support flow control and congestion control. UDP does not help with either of these. Listen to the full episode for more details or you can also read the full transcript below. Transcript The previous episode introduced the SCTP protocol and explained a couple big problems that it solves. Make sure to listen to that episode first as well as some of the other recent episodes. For this episode, I’m going to just ask 5 questions and talk a little about each one while comparing the three protocols. We learn things by establishing relationships with other concepts and my goal here is to give you many different ways to relate these protocols with each other. You should end up understanding all of them even more. #1 Is the protocol connection oriented? Both SCTP and TCP are but UDP does not establish connections. This is why UDP is easier and quicker to send information. But because there’s no connection, it’s like yelling information out a window and hoping somebody will hear you. SCTP uses a more security conscious connection than TCP. A common problem with TCP connections is that they can be misused in what’s called a SYN flooding attack. It works like this: you want to establish a connection with a server computer so you send a synchronize message to the server. This is often just called a SYN message. The server goes ahead and gets the connection ready and sends a SYN-ACK message and then waits for you to reply with just an ACK message. This is called a 3-way handshake because it takes three messages to setup the connection. But what if you either don’t send the third message or it gets lost? Well, the server will wait a while just in case the third message is a bit delayed. But while the server is waiting, it keeps the connection ready for you. That open connection uses some amount or resources on the server. What if a bad person sends a bunch of SYN messages? Enough to cause the server to run out of memory or start turning away other visitors? This is a denial of service attack cause by a flood of SYN messages. SCTP fixes this by introducing a 4-way handshake that uses signed cookies to prove the identity of the original request and also doesn’t hold connections open until the proper replies have been made. #2 Is the data transfer reliable? In a way, this is related to the first question. I already said that UDP is not reliable. And both SCTP and TCP offer reliable data transfer. This means that when you send information, both SCTP and TCP will keep trying to send any packets that get lost or are damaged. But SCTP has another trick here. Maybe you have some information that’s more like a regular status update. If you miss an update, then it’ll be retried. But do you still need to keep retrying when the next update is ready? If something new comes along that replaces an old packet, then if that old packet is still having problems, it’s b
December 26, 2016
SCTP is another protocol like TCP and UDP with aspects of both. Your computer may not support SCTP yet and there’s always the chance this protocol will fail to gain enough support. I’m explaining it in this episode mainly so you’ll understand that the world is bigger than just TCP and UDP. All of these are just software protocols that establish standard ways for computers and devices to communicate. That means new protocols can be designed anytime. SCTP stands for stream control transmission protocol and I’ll focus this episode on two of the main differences and benefits as compared with TCP and UDP. Listen to the full episode for more details or you can read the full transcript below. Transcript Your computer may not support SCTP yet and there’s always the chance this protocol will fail to gain enough support. I’m explaining it in this episode mainly so you’ll understand that the world is bigger than just TCP and UDP. All of these are just software protocols that establish standard ways for computers and devices to communicate. That means new protocols can be designed anytime. You need to be careful if you think you need a new protocol. It’s always a good idea to search first to see if anything already exists that will meet your needs. Sometimes, you won’t find anything. What’s already available might be close but just lacking that one critical capability that you need. SCTP started out like this from some telecom companies who were looking for a protocol that would meet the needs that the phone companies have built up over the years. They wanted a protocol that would run on IP. The two main existing options are TCP and UDP. Make sure to listen to episodes 158, 159, and 160 for more information. Even though SCTP started out as a protocol designed for telephones, it can be used outside of that domain. The problem though is a general lack of support. Let’s say you decide to create a new spoken language. You already now how to speak several but know you can create a whole new language that will be better than any other. You work hard and finally know how to speak the new language. But until other people also know how to speak the language, all you can really do is talk to yourself. So it is with SCTP. It has some really useful capabilities but until it gets wider support from both computer operating systems and the routers that direct network traffic, you might have trouble with it. You can always install software or write your own to handle SCTP traffic on your computer but it’s a whole different story when it comes to getting hardware devices to understand it. SCTP stands for stream control transmission protocol and I’ll focus this episode on two of the main differences and benefits as compared with TCP and UDP. This will help you to understand the major highlights and give you enough information to decide if you need to investigate more. Then next week, I’ll follow up with other differences and benefits of SCTP. The first main problem is called head-of-line blocking. Have you ever stood in line at a bank or anywhere when there’s one a single person available to serve people? I know I have and sometimes wonder if anybody in front of me is going to have a difficult problem. I hope they all have everything ready and can take their turn quickly. But sometimes, there’s a person in line with a whole packet of papers, unorganized, who could take an hour. The whole line comes to a complete stop while this person blocks everything. That’s head-of-line blocking. Relating this back to TCP, if a packet gets lost or damaged, then the other packets can continue to arrive but the processing will stop while that problem packet is retransmitted. If all the packets are related to each other, then there’s nothing you can do. You need that missing packet. But what if the other packets are not related? When I’m waiting in line, I&#82
December 19, 2016
The OSI model will help you understand how computers communicate. This is just a model that helps us understand how things work. Not everything has to fit exactly into one of these layers and maybe you might design something that doesn’t fit perfectly. That’s okay. Here is a summary of each of the layers. Make sure to listen to episodes 158 through 161 as well as this episode for more details. Physical layer is responsible for making sure that individual binary data can be transmitted and received. Data link layer is responsible for making sure that computers and devices can recognize each other and send and receive multiple bits of data. Network layer helps by routing information through multiple computers to reach the final destination. Transport layer adds reliability and flow control. Session layer adds longer communications through sessions. Presentation layer translates information between formats that an application expects to and from whatever format is needed for the communication. Application layer covers everything in an application. Listen to the full episode for more or you can read the full transcript below. Transcript I’ve already been explaining how to communicate with other computers and introduced the OSI model in the previous episode. You’ll get the most benefit from this episode if you first make sure to listen to episodes 158, 159, 160, and 161. As a quick review, you’ve learned how the OSI model describes communication between computers or other devices by focusing on seven layers that each build on each other. In other words, the lowest layer provides very basic functionality that is used by the next layer which adds new abilities. This is just a model that helps us understand how things work. Not everything has to fit exactly into one of these layers and maybe you might design something that doesn’t fit perfectly. That’s okay. Layer one is the physical layer and is responsible for making sure that individual binary data can be transmitted and received. Layer two is the data link layer and is responsible for making sure that computers and devices can recognize each other and send and receive multiple bits of data. Layer three is the network layer and helps by routing information through multiple computers to reach the final destination. Layer four is the transport layer and adds reliability and flow control. This episode continues explaining the remaining layers 5, 6, and 7. Layer five is the session layer and adds longer communications. Think of it like this. When you walk up to a friend and start talking, what’s the first thing you say? You should probably start with a polite greeting, right? Your friend also responds. Maybe you then comment about something your friend is doing or just mention something that seems remarkable. In other words, the two of you start conversing. Back and forth. Even when the conversation turns to more important issues and then back again, it’s still an exchange of thoughts and ideas. When you’re done, you both say goodbyes. That whole conversation is a session. And that’s what this layer provides. You need to have some way to group multiple messages together. Imagine the trouble it would cause if halfway through your conversation with your friend, you remembered something important and just stopped talking in the middle of a sentence and walked away. Your friend wouldn’t be too happy with you. Layer six is the presentation layer. What kind of presentation is needed for communications? Of all the layers, I always felt this one has the strangest name. In order to understand it, you have to first have some experience building well-designed user interfaces. Let’s say that you have an application that displays some dates. It doesn’t matter for this example where the dates appear or what they mean. The important part is that different users want to view dates in different formats. Some want the
December 12, 2016
A MAC address is a physical address unique to your computer. Think of it like this: you want to send a letter to your friend so you put your friend’s mailing address on the envelope. This is good enough at first. But right before the post office puts your letter in your friend’s mailbox, the address gets changed to you friend’s fingerprint instead. This is because computers don’t have a simple mailbox where letters and other messages can be delivered until somebody goes to check the mail. But why switch from an address to a fingerprint in the first place? The reason is because there are different layers to the communication. I won’t go into all the details, but in 1984 there was a standard document that was published called the Open Systems Interconnection Reference Model, or just the OSI model for short. This document describes a design that consists of seven layers. Each layer is responsible for specific functionality. And in order to get something running such as browsing the internet, you need pieces from each of these seven layers. I’ve already described IP which exists in layer 3 of this document and both TCP and UDP which can both be found in layer 4. I didn’t want to go right into this document because it would seem too much like a bunch of theory. But now that you understand a few distributed computing concepts, it’s time to describe where everything fits in the OSI model. Listen to the full episode for a description of the first four layers as well as why MAC addresses are needed and how they fit into the OSI model. Or you can also read the full transcript below. Transcript I explained IP addresses in episode 158. You should also listen to episodes 159 and 160 before this episode. An IP address is a virtual address because it can change. When communicating with other computers, we need something that won’t change. Something that’s unique. Think of it like this: you want to send a letter to your friend so you put your friend’s mailing address on the envelope. This is good enough at first. But right before the post office puts your letter in your friend’s mailbox, the address gets changed to you friend’s fingerprint instead. This is because computers don’t have a simple mailbox where letters and other messages can be delivered until somebody goes to check the mail. But why switch from an address to a fingerprint in the first place? The reason is because there are different layers to the communication. I won’t go into all the details, but in 1984 there was a standard document that was published called the Open Systems Interconnection Reference Model, or just the OSI model for short. This document describes a design that consists of seven layers. Each layer is responsible for specific functionality. And in order to get something running such as browsing the internet, you need pieces from each of these seven layers. I’ve already described IP which exists in layer 3 of this document and both TCP and UDP which can both be found in layer 4. I didn’t want to go right into this document because it would seem too much like a bunch of theory. But now that you understand a few distributed computing concepts, it’s time to describe where everything fits in the OSI model. Let’s start with layer one. This is the physical layer. Now I know. I started out this episode saying that a MAC address is a physical address. That’s a different kind of physical. Layer one is concerned about really physical things such as the wires connecting your computer to the internet. Or if you connect wirelessly, then the first layer is concerned with things such as the frequency of the radio waves and how they’re formed. With wires, this layer is concerned about voltages and currents. We live in a noisy world. And I’m not talking about all the extra noise I hear these days in New York from car horns and police sirens. I&#8217
December 5, 2016
Sometimes speed and simplicity are more important than reliability. This episode expands on the concepts introduced in the previous episode. If you haven’t already, make sure to listen to episode 159 about TCP. Both TCP and UDP are based on the internet protocol, or IP. UDP stands for User Datagram Protocol. Going back to the previous example of sending physical envelopes to somebody far away, let’s say that instead of sending a document split into many small envelopes, you instead need to send daily status reports. Each status report is small and the contents don’t matter much if a few get lost. As long as most of your status reports arrive, then your friend will be happy. Because of this, there’s no need for a complicated system where you number your reports. You’ll be sending reports at a regular interval and if they arrive out of order of go missing, then the receiver can just catch up later. You both have a lot less work to do. All you have to do is send the reports. You no longer have to wait for any replies or need to be ready to resend missing or damaged reports. And the receiver no longer needs to send any acks or hold up processing while waiting for a missing or damaged report. It’s still important to know if a report has been damaged along the way. And UDP does provide a way to detect if a message has arrived safely or not. The difference between UDP and TCP though is that if a damaged message arrives with UDP, then it just gets thrown away. Listen to the full episode for more explanation and examples of when you might want to use UDP. Or you can also read the full transcript below. Transcript This episode expands on the concepts introduced in the previous episode. If you haven’t already, make sure to listen to episode 159 about TCP. Both TCP and UDP are based on the internet protocol, or IP. UDP stands for User Datagram Protocol and this will be a short episode today because this protocol is much simpler to explain. Going back to the previous example of sending physical envelopes to somebody far away, let’s say that instead of sending a document split into many small envelopes, you instead need to send daily status reports. Each status report is small and the contents don’t matter much if a few get lost. As long as most of your status reports arrive, then your friend will be happy. Because of this, there’s no need for a complicated system where you number your reports. You’ll be sending reports at a regular interval and if they arrive out of order of go missing, then the receiver can just catch up later. You both have a lot less work to do. All you have to do is send the reports. You no longer have to wait for any replies or need to be ready to resend missing or damaged reports. And the receiver no longer needs to send any acks or hold up processing while waiting for a missing or damaged report. It’s still important to know if a report has been damaged along the way. And UDP does provide a way to detect if a message has arrived safely or not. The difference between UDP and TCP though is that if a damaged message arrives with UDP, then it just gets thrown away. Think of it like getting a torn piece of junk mail yourself. It goes straight into a shredding pile or into the trash. With TCP, a damaged message would put a hold on the entire process while the sender is notified of the problem and both sides work to arrange the safe delivery of the damaged message. UDP is a good choice anytime you need to send a quick message or request to another computer. If the other computer needs to reply, then the same mechanism can be used. You don’t need to arrange anything more complicated than this. Let’s say you want to send a message asking for the IP address of a given name. This can be done with UDP. Listen to episode 158 for more information about IP addresses. The reason this works well with UDP is because your request is small and can fit
November 28, 2016
Knowing where to send information through IP is not enough. You have to know how to reliably send information too. What is TCP and why is it needed? Imagine for a moment that you need to send a very large package by postal mail. The package is just a bunch of papers so it’s not like you’re trying to send a single bulky item. Even so, let’s assume that the package is going to a different country that has unreliable service, especially for big items. And let’s also assume that the stamps are free. How would you send this? Well, you could put everything in one big box and just send it. All those papers are an important document, so you make arrangements that the person you’re sending it to will send you a reply. The reply is very small so has a good chance of making it back but even that is not guaranteed. Okay, you send the package and get no response. Did it arrive? Or did the reply get lost? You don’t know. I’m going to call the reply an acknowledgement or just ack for short. Since you got no reply, you decide to send the whole thing again. And again, you get no ack. What you need is reliable delivery of information and that’s the main purpose of TCP. You need to be able to break the information into small pieces which is easy for a document with multiple pages. It’s also easy for electronic information. That’s because it doesn’t matter what you’re sending. It could be a single large presentation or a picture. Or it could be a document. All of these can be and actually need to be translated into a series of one’s and zero’s anyway. We can just divide these bits into smaller groups just like how a line of people waiting to be let into a store can be let in in groups. Make sure to listen to the full episode for how TCP relates to the problem of sending many pages of a document through an unreliable mail service. Or you can also read the full transcript below. There are several problems that need to be solved including missing packets, packets arriving out of order, duplicate packets, flow control, and error detection. Transcript In the last episode, I explained IP, or Internet Protocol. Along with this, you’ll commonly need to work with TCP, or Transmission Control Protocol. Together, these two are referred to as TCP/IP which is pronounced as just TCPIP. But what is TCP and why is it needed? Imagine for a moment that you need to send a very large package by postal mail. The package is just a bunch of papers so it’s not like you’re trying to send a single bulky item. Even so, let’s assume that the package is going to a different country that has unreliable service, especially for big items. And let’s also assume that the stamps are free. How would you send this? Well, you could put everything in one big box and just send it. All those papers are an important document, so you make arrangements that the person you’re sending it to will send you a reply. The reply is very small so has a good chance of making it back but even that is not guaranteed. Okay, you send the package and get no response. Did it arrive? Or did the reply get lost? You don’t know. I’m going to call the reply an acknowledgement or just ack for short. Since you got no reply, you decide to send the whole thing again. And again, you get no ack. You know the address of the person you’re trying to send the document to. That’s similar to an IP address. You realize that you need a better system for sending large documents. And that’s the purpose of TCP. Now TCP is actually rather complicated. It’s more than I can explain in this podcast without putting you to sleep. So instead, I’m going to continue using the mail example to explain the main concepts. What you need is reliable delivery of information and that’s the main purpose of TCP. You need to be able to break the information into small pieces which
November 21, 2016
Any computer or device that wants to communicate with the Internet Protocol needs an IP address to uniquely identify the device. And some devices could have multiple IP addresses. There needs to be at least one IP address for each network card or interface that the computer or device uses to connect. For example, you could have a single computer with three network cards, two wired, and one wireless. Each one of these would need at least one IP address and could have more. This episode will explain two types of IP addresses, version 4 and version 6. I’m not sure what happened to versions 1, 2, 3, or 5. Version 4 has been in use since the beginning of the internet and version 6 is struggling to gain acceptance. Normally, version 4 is called IPv4 and version 6 is called IPv6. We’re going to have to all move to version 6 eventually just because we’re running out of version 4 addresses. The biggest problem with IPv4 addresses is there are so few of them. You might think that 4 billion addresses are a lot and that’s just what the early designers thought too. That’s just not enough for every computer in the world to have it’s own address though. We’ve managed to stretch IPv4 addresses a lot over the years. While researching this episode, I checked on the current state of IP addresses remaining that haven’t been assigned yet. You might still be able to get some IPv4 addresses in Africa but the rest of the world is already out of luck. We no longer divide addresses into class A, B, or C ranges because the size differences between the ranges is just too much that it led to a lot of addresses being wasted. Imagine it like this. Let’s say that the grocery store only sells eggs in containers of ten, a hundred, or a thousand eggs. If you need to make an omelet with 15 eggs and can only purchase one container, then you have no choice but to buy a hundred. Maybe you can use the other 85 eggs but you’ll probably waste a few. Another method that’s been used very well to extend addresses has been to stop assigning public IP addresses to each computer in a company or in your home. It’s these public IP addresses that we’re running out of. It’s more common for a computer to look for a service called the Dynamic Host Configuration Protocol or DHCP for short. This is a service that can run on a router or even on a dedicated computer. When your computer joins a network, then it can look for this service and ask it for an IP address. This address is temporary and can change if the computer is restarted. Listen to the full episode for more ways that we’ve managed to extend the usefulness of IPv4 and how IPv6 can help. You can also read the full transcript below. Transcript And some devices could have multiple IP addresses. There needs to be at least one IP address for each network card or interface that the computer or device uses to connect. For example, you could have a single computer with three network cards, two wired, and one wireless. Each one of these would need at least one IP address and could have more. This episode will start tying together various distributed computing concepts that I’ve been explaining over the last several previous episodes. If you want the best chance to understand what all this means, make sure that you listen to episodes 155, 156, and 157. I’ll need at least another future episode to finish and maybe more. This episode will explain two types of IP addresses, version 4 and version 6. I’m not sure what happened to versions 1, 2, 3, or 5. Version 4 has been in use since the beginning of the internet and version 6 is struggling to gain acceptance. Normally, version 4 is called IPv4 and version 6 is called IPv6. We’re going to have to all move to version 6 eventually just because we’re running out of version 4 addresses. I’m getting a bit ahead of myself though. Let me start with the basics of IPv4.
November 14, 2016
Why do we need a system for managing domain names? Imagine for a moment what the Internet would be like without a domain name system. It would be just like a phone number. If I had to create an audio commercial for Take Up Code and couldn’t use takeupcode.com, well, I’d probably have to repeat my IP address a lot in order for you to remember it. Do you think you could remember to visit 45.33.99.108? It’s actually less digits than a typical phone number but they’re completely random as far as a customer is concerned. At least phone numbers have similar beginnings for local numbers. That type of address of 4 numbers separated by dots is called an Internet Protocol address or just IP address for short. Specifically, it’s an IPv4 address. There are newer IPv6 addresses but they’re bigger and much more complicated. I’ll talk about IP addresses in a future episode. For now, just think of them like a phone number. When you press those numbers on a phone, you get connected to whoever you’re trying to reach. And like the phone number has an easier way to remember the number by using words, so IP addresses also have matching domain names. When you see a domain name like www.takeupcode.com, what may not be immediately obvious is that it’s divided into a hierarchy that begins on the right with com, then goes to takeupcode, and finally, to www. There can be many more levels but 3-4 is common. The whole point of a hierarchical name like this is to identify a specific computer on the network. Of course, if you already know the network address, then you could just use that directly. But DNS gives you some added benefits beyond just giving you an easier name to remember. Your browser usually starts by asking your operating system to resolve the name. The operating system needs to be connected to a network somehow and as part of joining that network, there will usually be a computer responsible for resolving names somewhere on the network. This is known as a name resolver or sometimes simply as a DNS server. The name resolver could either be specified directly with its IP address or assigned dynamically when your computer joins the network. The name resolver will start with the root name servers. You might think this means the com part, but as far as DNS is concerned, there’s an extra dot that comes after the com. This is the root and there are several root servers that can respond to requests. These servers will have no idea where to find www.takeupcode.com but can tell you where to go to get answers for any com names. So the name resolver gets an address for a com name server and it asks for www.takeupcode.com. The com server also has no knowledge of this but it does have some glue that tells your name resolver where it can find a name server with more information. You see, whenever you register a domain name, you don’t register the name directly for some server IP address where you intend to setup shop. You register the domain and provide a couple name servers. One name server is a backup. These name servers are usually provided by your registrar but you could setup your own if you want. Your local name resolver now has an address for a name server and asks it for www.takeupcode.com. In this case, it has an answer. And this is called an authoritative answer. If there had been more nesting of names, then the process might sometimes need to continue. At each point, the local name resolver gets closer to finding out the address of the name it’s trying to resolve. There’s some more details included in the audio so make sure to listen. Or you can also read the full transcript below. Transcript I like to listen to talk radio sometimes while driving. Yes, I do listen to other things besides podcasts. Only sometimes, and I usually go back to podcasts because of the commercials. It’s worse than TV. I wouldn’t mind so much if the advertisements were related to t
November 7, 2016
It’s almost a tongue twister to say them all. Do you know what they all mean? Let’s take URI one step at a time and at the end, you’ll understand how best to describe where information such as web pages can be found. The whole point though about this is that it applies beyond just web pages. You’ll have a solid understanding of how to describe where almost anything can be found. The first part is Uniform. This means that you can describe completely different kinds of resources that might have very different mechanisms. Just take web pages vs. emails as an example. The URI document describes a uniform way to represent these and other types. But types of what though? Here’s where things get really vague. We’re talking about resources and these can be almost anything. A web page is a resource. But so is an online service that provides high scores for a game. And you can even describe resources that are in the real world and have nothing to do with computers at all, such as a library book. If you thought that was vague, the term identifier is even more so. This is whatever is needed to uniquely refer to one thing vs. something else. It can change depending on what type of thing you’re trying to identify. And it might not even be a single thing. Maybe it can identify a group of things where the group itself is important somehow. But probably the strangest part of an identifier is that there doesn’t actually have to be anything located or found at whatever is identified. It could just be an idea or a concept. All that really matters is that it has some kind of identity, whatever that means. URIs are interpreted consistently no matter where you are but that doesn’t mean that they provide the same result. The RFC 3986 document describes http://localhost as an example. No matter where you are in the world, this always means the same thing. It refers to the computer itself. Each computer will interpret this URI to mean itself. The way that URIs are able to handle such variety is because they start out with what’s called a scheme. The “http” in http://localhost is the scheme. This says that what follows should adhere to rules specifying valid http addresses. If you wanted to represent a phone number as a URI, then it would begin with “tel:” And an email address would begin with “mailto:” Make sure to listen to the entire episode to understand what are URLs and URNs as well as when to use them. Or read the full transcript below. Transcript RFC 3986 says that: ◦ A Uniform Resource Identifier (URI) is a compact sequence of characters that identifies an abstract or physical resource. You can read this document online by searching for RFC 3986. RFC stands for “Request for Comments” and 3986 is the specific number that the IETF has given this document. But what’s IETF? Well, if you visit www.ietf.org, you’ll find their goal is to make the internet work better. That’s a very big goal. IETF stands for the Internet Engineering Task Force and they help create standard documents that describe things like URIs. Now you might wonder why we need such complicated documents to describe simple concepts. All I can say is that there really are a lot of small details that do need to be documented. And if small details are not documented, then they have a way of being interpreted differently each time a developer needs to work with them. In fact, even with such specific documentation, people still get confused. Some people say that we shouldn’t worry so much and just call everything a URI. I know, I haven’t yet described what all these URLs, URNs, URIs are. I’ll get to that. I wanted to first give you some perspective on what all this is about and where you can find out more. There’s no way that I can describe all the details in one of these official documents. At least not if I want you to stay awake. Just lo
October 31, 2016
There’s more than just two letters difference. In fact, you can’t really compare them at all. But you can use them together. HTML stands for Hypertext Markup Language. A well formatted HTML document though is really nothing more than a special XML document that uses certain tags. It starts out with an opening tag called html and ends with a closing html tag. Inside this, you’ll find a section enclosed with tags called head and another section enclosed with tags called body. Most of what you see in your web browser is inside the body section. You can surround text with p tags to create paragraphs, h1 tags to create a large heading, a tags to create a link that points to another HTML document, and img tags to display images. The browser uses these tags and many more to figure out how to display the document. It doesn’t display the tags themselves and instead you can think of the tags as instructions to the browser. You can create an HTML file in a text editor and save it locally on your computer. Then you can open it with your browser to view it. While this works, it’s not the way we normally get HTML files into our browsers. We normally visit web sites and what’s really happening is that the browser is requesting HTML files as well as other files from the web site. Once it has the files, it can display them. And that’s where HTTP comes into the picture. HTTP stands for Hypertext Transfer Protocol. This defines how HTML and other files are transferred to and from computers. This episode describes the following five aspects of HTTP with some examples along the way. HTTP is based on a series of requests and responses. HTTP identifies computers and files on those computers with URLs. HTTP defines methods or verbs as they’re sometimes called that you specify in your request. HTTP defines well known status codes. HTTP is stateless. Make sure to listen to the full episode or read the full transcript below for more details and some examples. Transcript Before getting too far into distributed computing, I thought it would be good to explain some basics for how one of the most distributed network works, the World wide Web or WWW. There’s a lot more to this than I can explain in this episode. For now, I just want to focus on two things, HTML and HTTP. Why should you be interested? What are they? How are they used? And how do they influence distributed computing? HTML and HTTP work together to form the backbone of the world wide web. And that forms a huge distributed computing network. A lot of people who are learning to code are introduced to HTML and CSS. I’ll explain CSS in a future episode. The main thing is that these are not programming languages. They’re ways to format and present information. In other words, it’s just data with some instructions for how that data should look when presented in a web browser. You can add some JavaScript and then you have the ability to program. HTML stands for Hypertext Markup Language. And this probably lends some credibility to this being a language. A well formatted HTML document though is really nothing more than a special XML document that uses certain tags. It starts out with an opening tag called html and ends with a closing html tag. Inside this, you’ll find a section enclosed with tags called head and another section enclosed with tags called body. Most of what you see in your web browser is inside the body section. You can surround text with p tags to create paragraphs, h1 tags to create a large heading, a tags to create a link that points to another HTML document, and img tags to display images. The browser uses these tags and many more to figure out how to display the document. It doesn’t display the tags themselves and instead you can think of the tags as instructions to the browser. You can create an HTML file in a text editor and save it locally on your computer. Then you can open it with your browse
October 24, 2016
If you haven’t already, make sure to listen to the previous episode 153 about XML. Many of the concepts that I described there apply to JSON as well. JSON stands for JavaScript Object Notation and comes from the JavaScript language. But even so, it’s a good choice for representing data in any language. If you’re using JavaScript, there is a method you can call to read JSON. This method is called eval which is short for evaluate. However, I don’t recommend that you call this method because it can run code just as easy as read data. You’re better off using a library that has the ability to parse JSON data as just data. This will be the approach you’ll take with any other programming language anyway. Why should you consider using JSON? Well, you can use JSON, or XML, or any of several other techniques anytime you need to store and retrieve, or send and receive information. First of all, XML can do everything that JSON can do and then some. And JSON comes really close to being able to match XML. There are a few things that XML can do that JSON can’t such as embedding comments inside the XML, or validating that the XML adheres to a valid format. But even then, don’t be surprised if the standards change and evolve so that JSON fully matches XML. To me, it really just comes down to a choice between which formatting you like best. Usually though, JSON will be shorter just because you don’t have to worry about ending each XML tag with a duplicate ending tag. So what is JSON? I’m not going to try describing the syntax. That would involve telling you where to put commas, colons, and quotation marks. I’ll stick to the concepts. And there are two main concepts. The first is name value pairs. This is a simple concept and really just means that a value has an associated name. If we’re building an adventure game and the hero has a health of 100 and a speed of 5, then both of those values have a name. The value doesn’t have to be so simple. It could be a string, a number, true or false, have no value at all, an array, or represent an object that has it’s own name value pairs. Each of these named values is in no particular order. The second concept has to do with arrays that I just mentioned as one of the value types. An array is actually ordered, so if an item comes before another item, then that means something. At least it means something as far as JSON is concerned. Think of array values just like the first concept of named values only without the name. With an array, it’s the order that identifies values. Make sure to listen to the full episode for an example of how you might use JSON to store information about characters. Or you can also read the full transcript below. Transcript If you haven’t already, make sure to listen to the previous episode 153 about XML. Many of the concepts that I described there apply to JSON as well. JSON stands for JavaScript Object Notation and comes from the JavaScript language. But even so, it’s a good choice for representing data in any language. If you’re using JavaScript, there is a method you can call to read JSON. This method is called eval which is short for evaluate. However, I don’t recommend that you call this method because it can run code just as easy as read data. You’re better off using a library that has the ability to parse JSON data as just data. This will be the approach you’ll take with any other programming language anyway. Why should you consider using JSON? Well, you can use JSON, or XML, or any of several other techniques anytime you need to store and retrieve, or send and receive information. First of all, XML can do everything that JSON can do and then some. And JSON comes really close to being able to match XML. There are a few things that XML can do that JSON can’t such as embedding comments inside the XML, or validating that the XML adheres to a valid
October 17, 2016
XML was designed to solve two main purposes. To allow information to be stored and transported and to allow both humans and computers to read and modify the information. Listen to the episode or read the full transcript below to learn more about how information was described and transferred before XML. As for XML itself, let’s say you want to record a phone number in XML. You could start out with an opening tag called phone. The tag name is readable and clearly identifies the intent. It’s also surrounded by opening and closing angle brackets. You know, the less than and greater than symbols. After this opening tag and the brackets comes the actual phone number. The phone number can be formatted however you want. You could even include enough numbers to add a calling card if you want. There’s no need to worry about running out of a fixed and defined number of characters. Unless of course, that’s how you want it. It’s up to you. At the end of the phone number comes a closing tag that matches the opening tag’s name. This makes it really easy to spot where a phone number begins and where it ends. Inside the opening tag, you can add what are called attributes. These are really nothing more than a name and a value. Maybe you could have an attribute called type and set its value to the string mobile. Need another phone number? No problem, just start a new opening tag called phone, put any attributes that describe the phone number inside the opening tag, then put the phone number, and close it with a matching tag at the end. And program that consumes XML doesn’t read fields located at specific starting and ending locations. Instead it looks for these tags. This means you can add new tags or even leave some out if they’re optional. You get to decide how to format your information and that format becomes part of the overall XML document. Transcript I remember working for a bank once a long time ago and helped develop an electronic banking application. There was a lot of information that had to be sent back and forth between the bank’s computers and the customer’s computer running the banking application. It wasn’t much different from an ordinary online banking website that you can log into today with any bank. But back then, it was new. I want to focus the episode today on how data can be formatted and described and compare one way to do this, XML, with how I remember organizing data back then. This is useful for distributed computing. After all, if you’re going to process information on multiple computers, you’re going to need some way to get that information from one computer to another. This is also useful though anytime you need to organize information into a format that you can later make sense of. Back when I was working on the banking application, there were documents that described the format of information. But let’s go even further back in time. How did businesses operate before there were any computers at all? This might seem simple but I’ll tie it all together in just a moment. Forms on paper were used. Actually, they’re still used these days and probably will be for a long time. I’m talking about papers with boxes and labels inside the boxes that describe where to write your name, address, phone number, and if you’re buying something, then the inventory name, description, cost per item, how many you want, total cost, taxes, shipping, and grand total. A company would send a purchase order with information like this filled out to some supplier. The supplier would need to read this and make sense of what the customer wants. Remember that the customer is sending a form designed by the customer and the supplier may be seeing this form for the very first time. The supplier might decide to go ahead and ship the purchased items along with an invoice or a bill requesting payment. This invoice would be printed on its own form.
October 10, 2016
You might be more familiar with APIs than SOA but they had another meaning not very long ago. The full episode tells how I used to program for DOS and how that is different from using APIs. Make sure to listen and subscribe in iTunes to get future episodes too automatically. You can also read the full transcript of the episode further below. A big part of learning how to program Windows was actually learning about event-driven programming. But that’s another topic. A lot of the event-driven details are hidden from you these days with modern languages and programming platforms. If you ever need to program like this, then when you’re not sending event messages to various windows, you’ll be calling methods built into the operating system. Actually, even sending messages means that you’ll need to call a system method to send the message. All of these methods and the messages too are the documented way that an application can interact with Windows. All of this ability to work with the operating system is called the Application Programming Interface or just API for short. If you write your own application that allows others to write code to interact with your application, then you’re providing your own API. An API really just means whatever mechanism is used by another application to programmatically make requests and send and receive information. This is different from a GUI which is the Graphical User Interface. Or as it’s often known today as just the UI which is the User Interface. The user interface, whether graphical or not, is how a user interacts with your application. And that’s different from how a programmer writes another application to use your application. Programmers use APIs. Sometimes these APIs might be referred to as low-level APIs or system APIs to distinguish them from a newer meaning that’s grown popular in the last several years. It’s common now for API to mean something very different. When you want to write an application to interact with a web service, you’re getting into the newer meaning. Let’s say you wanted to write an application to gather tweets from Twitter and present them in some cool new way. How are you going to get the tweets in the first place? You’ll need to ask Twitter for them. But you’re not going to make a call directly into some method running in some dynamically linked library in some server operated by Twitter. Instead, you request permission from Twitter to be able to make web service requests on behalf of some Twitter user. The new meaning of APIs usually means that you’ll be making REST calls and getting back either XML or JSON formatted information. All of that will need to be in a future episode. Transcript I remember when I was first learning how to program professionally. I was working for a small company in Singapore and the product was ready to ship. Some early customers asked a similar question, “Did we have a Windows version?” You see, the product I first helped build was written for DOS. I wanted to learn how to program for Windows and bought the Software Development Kit or SDK from Microsoft in Singapore. They didn’t even know what it was at the time so I was definitely one of the first to explore this new way of programming. But before I get to that, let me explain a bit about how things were done up to then. That was a long time ago and I might have forgotten some things. But what I do remember was anytime I needed to make a request from DOS. I guess I should also explain what DOS was. It stood for Disk Operating System. Yeah, having a floppy disk in your computer was a big thing back then. And the disks really were floppy, too. This was before the stiffer 3 and a half inch disks became popular. DOS was a text-based operating system and was responsible running the computer just like a modern operating system such as Windows. All commands had to be typed. There was no poi
October 3, 2016
As you learn more about something, a strange thing happens. It becomes obvious how much more there is to still be learned. This is not a new idea. It’s been around and quoted in many different forms for thousands of years. And it just keeps going. It’s not like after a few weeks of studying something, you’ll be able to list out all the things that you have left. You’ll have a list. That’s for sure. But then each item on your list will lead to several more and they’ll each lead to several more. It doesn’t end. I like that. And I can certainly vouch that after learning how to program for the last 25 years, I have a long way to go. A person just beginning to learn something is more likely to feel confident about their skills than another person a little further along who is starting to realize the full picture. To give you a very real example of today’s topic even for me after 25 years, I recently started thinking about all the things that I still need to complete in the game library I’m working on. This is code that I’m preparing for a five day workshop to help you go from beginner to having your own game in a week’s time. There’s no way that you’ll be able to understand everything in just a week. But just like how you can learn how to drive a car in a week even though you may not know yet how to change the oil yourself, I still believe you can learn how to use my library to build your own game in a week even though you may not be ready to even acknowledge the existence of the variadic template publisher subscriber code. When I first came up with the idea to organize this workshop, I thought I could have everything ready in about a month. Maybe two. And hold the workshop in august or September. Well, it’s October already and how far along is the library? It’s actually quite far along. It can manage some intricate details for you and make them seem as easy as just pressing the gas pedal in a car. But I have to acknowledge one big reality. It’s not done yet. And if there’s one thing I’ve come to accept over the last several month, it’s how much more work still remains. I just posted a short video on Facebook that shows some of the capabilities of the library so far. You can find this at Facebook.com/TakeUpCode. I’ll be adding more videos that document the progress to this page. It’s a 2D side scroller with an animated character that can move around on some tiles, jump, and change the animation depending on what the character is doing. You might wonder what all the fuss is about if you see it. After all, it’s not nearly as flashy or polished as a blockbuster game. That’s not the intent. It’s a library that you can use to build your own game and learn how to program at the same time. Listen to the full episode for more or you can read the full transcript below. Transcript This is not a new idea. It’s been around and quoted in many different forms for thousands of years. And it just keeps going. It’s not like after a few weeks of studying something, you’ll be able to list out all the things that you have left. You’ll have a list. That’s for sure. But then each item on your list will lead to several more and they’ll each lead to several more. It doesn’t end. I like that. And I can certainly vouch that after learning how to program for the last 25 years, I have a long way to go. I choose this topic today because I wanted to explore with you one aspect of this never-ending journey to knowledge. You see, as you learn more and realize that you can continue learning more, it also means that there’s more I can teach you. I remember once when I was learning Karate and my Sensei told me that he might notice a student doing a hundred things wrong but would only mention a couple at a time. Why is that? First of all, if we get too much of anything, it beco
Loading earlier episodes...
    15
    15
      0:00:00 / 0:00:00