7: Into The Void.

Take Up Code - Un pódcast de Take Up Code: build your own computer games, apps, and robotics with podcasts and live classes

Categorías:

Understanding types is super critical to being able to program. Without this knowledge it would be like trying to go through life where everything you see and feel is unknown to you. If somebody points to a random spot in a computer’s memory and asks “What’s that? Do we need it anymore?” You can’t just pick it up and look at it. It’s just some binary bits. Some values. You don’t even know how many there are or if you’re looking at the beginning, middle, or end. You might even be looking at a spot in memory that has nothing. You can’t tell because even nothing has no meaning. What are these types that are available to you? It depends on the language. Here are 11 common types with a short description for each. Integer types represent whole numbers including zero. There will usually be several sizes of this basic type available that will fit in 8, 16, 32, or 64 bytes. Some common names are short, int, and long and the specific sizes are not always fully specified by a language. There are also signed and unsigned versions of the integer types that determine if negative values are allowed. Boolean types allow you to keep track of true and false values. Floating point types give you the ability to approximate decimal numbers including fractional values. Character types are very similar to the integer types because they only need whole numbers. The major difference is that these types use codes that map to character values. The codes are standardized and agreed on although there are multiple standards and it’s not always obvious which standard is being used. Void is a special type that means there is no type. String types are really just a collection of characters. There are enough special rules especially with various cultures and regions that will make you glad to have strings as their own type. Pointer types need another type to be complete. This other type could even be another pointer. Reference types act a lot like pointers but don’t look like them. Array types also need another type to be complete and define a collection of the other type. Custom types can be anything you want and are defined by including other built-in and custom types. Enumeration types are custom types that allow you to give meaningful names to values. Listen to the full episode or you can also read the full transcript below. Transcript Imagine picking up something and not knowing what it is. Go ahead and do this exercise right now while I’m talking. You reach up to a top shelf and feel something and take it down. You’ve never seen it before. Is it yours? Is there a label on it? You can start making guesses but how is this possible? What clues do you have? You don’t know what it is but you can still look at it and feel it. Let’s get specific. You know it’s not very heavy and looks to be made out of plastic. You can see it’s a light grey color. If it belongs to something else, then it probably resembles that other thing. So you start thinking about all the things you might have put on that shelf that had some grey plastic pieces and you remember an old vacuum cleaner that you sold last summer in a garage sale. Huh, guess you don’t need this anymore. So you throw it away. Now imagine a similar scenario but this time you get a call form work and the person wants to know if this “thing” from the top shelf is still needed or if it can be thrown out. You ask the obvious question, “What thing?” “I don’t know what it is,” the other person says. “I just called to ask you if I can throw it out.” “Well, can you describe it?” you ask. “John’s actually the one who found it. Not me. I forgot to ask him what it looked like before he left. He took it with him so I don’t have it. I told him that I’d call him back with your answer though.” “Okay, do you know exactly

Visit the podcast's native language site