Kids, Code, and Computer Science
s ' d l r o r W e t e u p Th m o C t es n s i h e c l a M p t s le l a Sim m he S t t u O k Chec
February 2020
$6.00 $6.00 USD
Could YOU Be a Programmer? 5 Questions To Ask Yourself “In the Middle" Not Bad, For a Girl! Create Some Really Shady Graphics
beanz magazine February 2020: Volume 7 Issue 4 Issue 454 (online) & 310 (print) ISSN: 2573-3966 (online) ISSN: 2573-3958 (print) beanz Magazine© is published bi-monthly, six times a year, online at http://beanzmag.com and in print. A print + online magazine subscription includes online access to all articles, with links to let you explore topics in more detail. SUBSCRIBE: visit http://beanzmag. com/subscribe or email us for checks/ invoices. We’re also available through EBSCO, Discount Magazine, WT Cox, Magazine PTP, and many other subscription services. ONLINE MAGAZINE ACCESS: send your email address to hello@beanzmag.com and we’ll set you up. Published by Owl Hill Media, LLC 378 Eastwood Rd, Woodmere, NY 11598 Email: hello@beanzmag.com Phone: (646) 553-3390 POSTMASTER: Send address changes to Owl Hill Media, LLC, 378 Eastwood Rd, Woodmere, NY 11598. Periodicals postage paid at Woodmere, NY and other mailing offices Copyright Owl Hill Media, LLC with all rights reserved except as noted. Images are copyrighted by their creators, as noted with each story both online and in print. Publisher/Editor/Webmaster: Tim Slavin Staff Writers: Amy S. Hansen, Simon Batt, Patricia Foster, Bonnie Roskes, Clarissa Littler, Jennifer Newell, Les Pounder, Paul Seal, Erin Winnick, Tim Slavin Contributors: David Dodge, Jay Silver, Jeremy Kubica, Colleen Graves, Daniel Fenjves, Ali Hagen, Emeline Swanson, Jean-Francois Nguyen, Madeleine Slavin, Tim McGuigan Back Office Magic: Wendy Garrison Copy Editor: Eileen Seiler Art Director: Kelley Lanuto Webmistress: Patricia Foster COVER IMAGE: ANGELINA LITVIN, UNSPLASH
Publisher’s Note I hope the new calendar year is going well for you! Since we began this magazine in 2013, there’s been national and international efforts to teach students software programming. Worst case, it’s solely to get a high-paying job. Best case, learning how to code helps you understand the technology we use every day. The interesting questions: What about people not interested to learn coding? Should they still learn to code? Definitely, insofar as coding helps demystify technology. But there are lots of other ways to be involved in technology beyond coding. We publish articles about SketchUp, for example, for people interested in building things on a screen. And we feature people and technology where coding or using software is a byproduct, to inspire readers who might want to work with NASA’s small cube satellites or create fashion with 3D printers. I’m also intrigued that what makes a good software programmer —curiosity, patience, persistence, openness, humor—are the same things that bring success in any field. Learning how to code, and learning computer science, can help a person learn these basic success skills. It’s what we cover in this issue and in this magazine over time. This issue includes some great articles about finding computational thinking in the wild, using Python to create Mad Libs, a website that uses technology to track ships sailing around the world, and much more. We hope you enjoy this issue and learn a little bit more about how technology works.
Tim Slavin, Publisher beanz Magazine beanz magazine (as Kids, Code, and Computer Science magazine, our earlier title) is a winner of Parents’ Choice, Tillywig, and Academics’ Choice awards: http://beanzmag.com/awards
Our Mission beanz magazine is a bi-monthly online and print magazine about learning to code, computer science, and how we use technology in our daily lives. The magazine includes hard-to-find information, for example, a list of 40+ programming languages for education, coding schools, summer tech camps, and more. While the magazine is written to help kids ages 8 and older learn about programming and computer science, many readers and subscribers are parents, teachers, and librarians who use the articles to learn alongside their young kids, students, or library patrons. The magazine strives to provide easy to understand how-to information, with a bit of quirky fun. Subscribers support the magazine. There is no advertising to distract readers. The magazine explores these topics: Basics of programming and where to learn more, Problem solving and collaboration, Mathematical foundations of computing and computer science, Computational thinking, Recognizing and selecting computer devices, and the Community, global, and ethical impacts of technology.
February 2020
History "I Thinks My Human Needz a Laff!"
4 5 6 8 9 10 14 16
History How Did Lightguns Work? Notebook Where the Heck Am I? Programming Python Mad Libs Concepts Fire! Notebook Ahoy! SketchUp Frosty Is In the House! In the Middle Cover Story That Computor Is a Woman Puzzles Binary Patterns
tidbitz bitz
18 It's a Gas! 18 In the Know 18 Actually, This IS Rocket Science 19 It's Greek to Me! 19 What Is AI? 19 3D Printing in Space
12
Concepts Cover Story Could YOU Be a Programmer?
20 21 22 24 25 26 27 28
Concepts Cover Story Finite Automata: The Smallest Machines Concepts Just 0's and 1's Programming Cover Story 3D/RGB/GL Tech In Real Life Smarter Streetlights Concepts The Latest Version Programming Hmm, Which Language Should I Learn? Puzzles Sailors, Monkeys, and Coconuts Parents and Teachers Computational Thinking In the Wild
cool beanz! IT'S A CONTEST!
beanz is giving away a Sphero RVR robot, coding books, Scratch cards, and lots of other cool STEAM stuff. Check out www.beanzmag.com on February 15, 2020 for more info. We want to hear from you! Look here and online for your fellow beanz-ers and all the cool things they do. Send your thoughts about beanz, ideas, art, photos of projects, poems, whatever, to cool@beanzmag.com.
contents
advanced
intermediate
beginner
2
scribe b u s / m ag.co m z n a e b http://
History
2
y ! M ff s a k L n a i h z T d I e e N n a Hum
BY TIM SLAVIN
Who among us hasn't spent lots of time looking at funny cat videos and memes online? You've probably seen the popular "cheezburger cat" meme. Animal photos plus text can make for some really fun (and silly) humor about nearly any topic. Even computer programming. Memes mix photographs with text. People then post memes online or send them to friends via email or text. Perhaps you've even created some memes of your own. Memes gained popularity when websites and email became common in the 1990s. Some memes are sweet, like the one Microsoft posted with an adorable kitten saying "your code looks purrrrrrfect", as if kittens can recognize good code! Other memes use a common image, then switch out the text. Of course, cats don't have the attention span required to read then debug code, which is what makes the meme so silly. Why cats, specifically? No one knows, but they're funny. Another kind of meme mixes two photos together, for example, to describe the two common feelings software programmers experience as they work: total joy and happiness after their code actually works . . . and despair when they have no idea how to fix their code. Some poke fun at another common experience for programmers: developing a perfectly simple software application only to watch users completely misunderstand how to use it! Programmers often use reference books from O’Reilly, a book publisher specializing in making books that explain technology. Their book covers often feature a drawing of an animal. Naturally, then, there are memes that play off these book covers to describe common problems programmers face. For example: there are memes about trying stuff until something works; blaming the user if code doesn’t work; and changing code to see what happens. Still other memes play with common terms like Escape key. While we humans know pressing the Escape key (usually) stops a computer process like loading a web page, it’s possible a cat might think pressing the Escape key would get them out of a bad or boring situation. It’s silly and funny. It's memorable. It’s a meme! It might be fun to find a silly image and add text. Memes are funny because they poke fun at shared experiences to which everyone can relate. It's a way we can laugh and think, "we're all in this together!" b
NERINGA-SIDLAUSKAITE, UNSPLASH
3
History
4
BY SIMON BATT
How Did Lightguns Work?
Today, virtual reality systems allow us to become part of the game. Unfortunately, they take a lot to set up. You need all sorts of boxes and sensor bars for the virtual reality headset to know where you are. With the Oculus Quest you can experience virtual reality without extra stuff, but even that needs four cameras on the headset itself. It may be surprising to hear, then, that in the 1980s people were shooting bad guys on their television screens, like in VR games. There were no extra bars or boxes. You'd just plug in a gun controller and shoot the enemies on screen. So how did people work out that technology long before virtual reality was a thing? There were a few different takes on making a gun that can shoot things on-screen, but the ones that made it into the homes of people around the world were called “lightguns.” They used light in a clever way to detect where the player was aiming. To achieve this little trick, the game and the gun had to work together. The game would show bad guys on the screen, and the
player would point the lightgun at an enemy and press the trigger. When this happened, the gun told the game that the player has fired the gun. The game and the gun worked together to figure out where the player was actually aiming. This was before sensor bars, so there was no way to tell where the actual gun was pointing. Fortunately, there was a way the game and the gun could work it out. The first method that was used was employed by the Nintendo Zapper. When the player pulled the trigger, the game made the screen completely black. Then, it put a white box over the first enemy, and asked the gun if it could see the box using its light detector. If it couldn’t, it moved onto the next target until the gun registered a hit. If no hits were registered, the game assumed the player had missed every target. This is useful if you just want to tell if the player shot an enemy or not, but what if you want to let them shoot anywhere on the screen? To fix this, lightgun technology made another Digital Game Museum advancement. This was introduced in the GunCon, which was the next step up from the Zapper. Instead of highlighting the enemies with white boxes, the screen would draw a line
Tell your parents that their childhood toy is now in a museum. They'll love that!
of tiny white boxes in a line across the television screen. It would then continue down the screen until the whole thing was white. While it did this, the gun would count how long it took until it saw the line of white boxes go past its field of vision. The game would ask the gun how long it took for it to see the white line, then compare it to where the line was at that time. That’s where the gun was pointed. For both of these methods all this happened very, very quickly. The player would only see the screen flashing white. This was very handy for the game developers because the white flash looked just like a gun firing. It’s amazing to think about how game developers managed to achieve so much with the technology they had back in the ‘80s. Who knows—maybe something similar to the lightgun will make a return in the future. b
KURT BAUSCHARDT, FLICKR. INSET IMAGE FROM THE DIGITAL GAME MUSEUM, FLICKR
People create technology to solve problems. Street addresses, for example, solve the problem of finding people in order to deliver mail and packages, as well as provide medical services and proof of residency to vote. However, half the people who live in urban areas around the world do not have an address. The area may be so crowded that an address has to be more specific than older postal codes might allow. Additionally, many people live and work in locations that are too remote to have a precise address. The lack of an address can be dangerous as well as inconvenient. Plus codes are a new solution that uses longitude and latitude to fix locations. Google Maps has
recently included plus codes in their search results. Plus codes are open source: anyone can use them without a license fee. A global plus code has 10 possible characters, with a plus sign before the last two characters. The first four characters are an area code followed by a six character local code. The local code describes the neighborhood and the building, an area of roughly 14 x 14 meters, about the size of half a basketball court. Each global plus code uses these two parts—an area code and local code—to locate a larger region and then find the precise location within that region. If the location is within or near a town, the area code isn't needed. In rural locations, if the nearest town is
up to 25 kilometers away, the area code also isn't needed. Instead, the local code can be used together with the town name. For additional precision, an optional character can be used to improve accuracy to roughly 3 x 3 meters, about the size of a small car! You can find your plus code by going online to https://plus. codes/map. The global plus code for the Taj Mahal, for example, is 7JVW52GR+2V. The area code is 7JVW and the local code is 52GR+2V. The Wolfe Creek Crater in Western Australia is literally in the middle of nowhere but it has a global plus code 5QG9RQHW+75. And the Eiffel Tower in busy Paris has a global plus code 8FW4V75V+8Q. b
You Are Here: 5QG9RQHW+75
IMAGE OF WOLF CREEK CRATER, AUSTRALIA, BY STEPHAN RIDGWAY, FLICKR
5
Notebook
Where the Heck Am I?
BY TIM SLAVIN
Programming
6
s b i L d a M n o h t y P
BY PATRICIA FOSTER
Have you ever played "MadLibs"? That's the game where you ask your friends for random words and fill them into the missing spaces in a story. Since they don’t know what the story’s about until you read it aloud at the end, the result is often wonderful and silly. Traditional MadLibs are done with paper and ink. But now that we’re in the digital age, we can recreate the game with some simple Python code, and reuse each MadLib over and over. An Example
To get you inspired, here’s a quick little story: It was pizza day at school, and Jamie was super excited for lunch. But when she went outside to eat, a bird stole her pizza. Jamie chased the bird all over school. She climbed, jumped, and ran through the playground. Then she tripped on her shoelace and the bird escaped. Luckily, Jamie's friends were willing to share their pizza with her. Here's the same story in a MadLibs format: It was ___(FOOD)___ day at school, and ___(NAME)___ was super ___(ADJECTIVE)___ for lunch. But when she went outside to eat, a ___(NOUN)___ stole her ___(FOOD)___. ___(NAME)___ chased the ___(NOUN)___ all over school. She ___(VERB1)___, ___(VERB2)___, and ___(VERB3)___ through the playground. Then she tripped on her ___(NOUN)___ and
m! ibs.co MadL t u o Check
the ___(NOUN)___ escaped. Luckily, ___(NAME)___ friends were willing to share their ___(FOOD)___ with her. Now there's a lot more potential for shenanigans. Getting Started
Open up your browser and navigate over to www.repl.it. Click the blue '+ new repl' button in the top left corner. Select ‘Python’ from the Language Menu and hit 'create repl'. Time to write your story! Make it as short or as long as you like. You can either write the story normally and then blank out keywords, or just jump straight to the MadLibs version. The Code
To make sure our program treats the story as text, and not code, we need to surround it with quotation marks. Then we can store it in a variable called 'story': A Next, we cut out all the "blank spaces" and replace them with variables. Words that are repeated, like Jamie or pizza, use the same variable, but otherwise each variable name must be unique. Using descriptive names (like 'noun1', or 'name2', or 'pizza') will help you remember what each one represents. The variables are placed into the text like so:
"It was " + food + " day at school, and " This is the trickiest part. You need to make sure that you have a '+' sign before and after each variable. You also need to make sure that each snippet of story starts and ends with quotation marks. If you're missing a quotation mark, the color of your text will be off, as shown in blue here: B
B
Escaping Characters
Stringing together text and variables isn't always easy. What if you have dialogue in your story, and you need to use quotation marks? If you just write the quotes normally, then you throw off the delicate balance between text and code. The solution is to put a backslash (\) in front of each "text" quotation mark, to separate them from "code" quotation marks. We call this "escaping" a character. Don't worry—the backslash won't appear when you actually display the text. name + " said \"Hi! My name is " + name + ".\"" PS: a forward slash (/) is not quite the same as a backslash. (\) PPS: Too confusing? You can use single quotes for your dialogue.
A
7
Prompting
In Python, we can use the "input" function to prompt a player for information. The text inside the function's brackets is displayed in the console, where the user types their answer. food = input("Enter a type of food: ") To get all the necessary words for your MadLib, you need to add a similar line for every variable. In the code editor, these prompts go above the story section. C
D
C
Finally, we end our program by displaying the finished story with the “print” function. print(story)
tiny DOG
Time To Play!
Click the green 'run' button. You should see your first prompt appear in the right-hand console. If so— great! Gather friends and have them answer each prompt until the story is finished, and the delightful result is displayed onscreen. If you get some sort of 'SyntaxError' message, double check that you've added all the necessary quotation marks and '+' signs. Another common error is misspelling variable names (NameError). This one's a little trickier, because you won't get an error message until you're deep in the code: D If it feels like a lot to take in, start with simple sentences that have one or two variables. You can always work your way up to longer, wackier, and more complex stories once you've mastered the basics. Have fun, and happy hacking! b
SMELLY lightb
ulb
candyl
and
picture
hot do
sneezi
gs
ng
jumpin
g
polar b
ears waving
table
eardru
superm
arket
annoyi
ng
m
fern throwi
ng
ground
22 bill
hogs
ion
s
Concepts
8
BY SIMON BATT
Fire!
Did you know that computers have what’s called a “firewall”? Don’t worry, it’s not going to burn you or your computer. In fact, firewalls for computers don’t have anything to do with fire. A firewall is a very important part of your computer’s security. That’s because it looks at all the data coming in and going out, and finds anything that looks off or bad. If something doesn’t look right, it blocks that connection and protects your computer. When you use the computer to connect to stuff outside of it (like going on the internet), your computer sends the data through what’s called a “port.” It’s worth imagining this as a place where a boat docks and loads or unloads its cargo. It's a point of entry. If a port doesn’t have any security, everything runs smoothly as long as every boat plays by the rules. If boats use the ports to deliver cargo and people, and nothing shady happens, then everything is fine. Unfortunately, things aren’t always fine. What if ships try to smuggle in illegal goods in their cargo? Maybe even pirates can dock and cause trouble. The best way to stop this is to check each incoming boat to ensure its sailors and cargo are all legal. This is what a firewall does for your computer’s ports. It checks if all the connections being made are behaving and doing well, and blocks anything that’s unwanted. For the firewall to do its job, it needs “rules” to work with. Computers can’t work well with concepts, such as “draw a cat” or “what does happiness feel like?” They do, however, work very well with logic-based rules. As such, a firewall has a lot of rules that it applies to data going in or out to see if it’s allowed or not. When you install a new program that uses the internet, the firewall may not know what to do with it. That’s why you’ll sometimes see a pop-up from your firewall asking you if it’s okay to let the program to connect to the internet. You usually add an exception to the firewall’s list of rules to allow the program to connect to the internet. Now you can see why it’s important to have a firewall turned on when you’re surfing the internet. As you browse, connections are being made on your computer’s ports, and data is traveling in and out of them. A firewall helps keep nasty people from getting access to your computer through these ports, so be sure to turn it on while you surf. So, a computer firewall is sort of like a wall and has nothing to do with fire. But if that’s true, why does it have that name in the first place? You may be surprised to know that the term ‘firewall’ actually comes from building construction. Builders sometimes separate buildings or parts of a building with a big wall made of materials that can’t catch fire, such as concrete. That way, if a fire breaks out, it can't spread past the wall. This is similar to the computer firewall, which stops viruses and hackers from getting past the wall into the computer. While builders use them to protect homes, you should use your own to protect your computer from hackers and viruses. b
Tens of thousands of ships sail out on the oceans and in harbors all over the world. How do people keep track of them all? Imagine you need something from a boat that is supposed to arrive today or later this week from faraway. You could wait on the docks for days. AIS (Automatic Identification System) is a technology ships use to broadcast data to identify themselves to other ships. The data includes the location and name of their ship. Stations around the world capture ship data. Websites like MarineTraffic.com collect that information and display it on maps. Shipping companies also use AIS data to know when their ships will arrive. People like me who love to be near water and watch boats use MarineTraffic.com to find out what ships are arriving and departing in a harbor. And if there’s a mysterious ship, the website helps look up details about that ship, including where it was built and where it’s going next. If you want to follow boats, the website is easy to use. Go to the MarineTraffic.com website. On their home page, there’s lots of little boat shapes in green, red, blue, and grey. Hover your mouse over a shape to see details about a ship. Click on a shape to see a popup with details about the ship. If you sign up for free with a parent’s email address, there are even more features to enjoy. The Explore link at the top center of their website provides a dropdown list of different ways to explore data about boats, harbors and lighthouses. I found the Oliver Hazard Perry, a three-masted sailing ship docked in Newport Harbor, which I visited last summer. The website includes lots of photos people have taken of the ship sailing in open water. If you search for FDNY, you can see all the boats used by the New York City Fire Department. Once you find ships you like to follow, the website lets you create your own fleet. MarineTraffic.com is a great example of using technology to solve problems, like how to keep ships from crashing into each other and tracking ships as they travel oceans and rivers. It’s a bonus that people who love boats also can use the website to identify ships as they sail past. b TOMAS WILLIAMS, UNSPLASH
9
Notebook
Ahoy!
BY TIM SLAVIN
SketchUp
10
BY BONNIE ROSKES
Frosty Is In the House! If you can't get outside to make a real snowman, the next best thing to do is model one! We'll create the three spheres for the body, then we'll find the decorating objects. First off, you'll see Helen. She isn’t needed, so press E for the Eraser, and click on any of Helen’s edges. A Press C for the Circle tool, click the origin (where the three axes meet) to place the center, and draw a circle of any size on the “ground.” B We need one more circle. While still in the Circle tool, tap (don’t hold) the Left or Right arrow, which orients the circle to be vertical. For this circle, place its center at the origin as before, and make this circle smaller than the one on the ground. C We’ll use these two circles to make the first snowball sphere. Press the Spacebar for the Select tool. Click the larger circle to select it: either the circle’s edges or the circle face. D Open the Push/Pull flyout toolbar and click the Follow Me icon. E Click the smaller, vertical circle. F Follow Me spins one circle around the other, making a sphere. Use the Eraser to remove the larger circle. G This sphere should be white. Right-click on the sphere and choose Reverse Faces. Now the gray face is inside, and white faces outward. Keep the sphere selected. H Snowballs aren’t perfectly round. Press the S key for the Scale tool, and click and drag the top green box (called a “drag handle”) down a bit, to flatten the sphere. I Make the sphere into a group, so that it won’t interfere with the other objects. Press the Spacebar for the Select tool, and triple-click (click three times fast) on the sphere. This selects the sphere’s face and all of its hidden edges. Then right-click on any part of the sphere and choose Make Group.
Keep the group selected. J The middle part of the snowman will be a smaller copy of this sphere. Press M for the Move tool, and tap (don’t press) the Ctrl key (PC) or Option key (Mac). To make the copy, click anywhere in blank space to start, then move the mouse straight up —make sure you see “On Blue Axis.” Click again to end when there is some overlap between the two spheres. Keep the copied sphere selected. K To shrink this sphere, press S for Scale. Drag one of the top corner drag handles, while keeping the Ctrl or Option key pressed. This keeps the scaling centered. L (This last step would be different if the spheres were not groups—the two spheres would stick to each other and scaling the top sphere would change the bottom one.) Repeat the last few steps for the third snowball (the head): copy the newer sphere straight up, and use Scale with the Ctrl/Option key to make the top sphere a bit smaller. M The body is finished, so find objects to decorate the snowman. You could model anything you want from scratch, but there are millions of models already uploaded to SketchUp’s 3D Warehouse. Click the Components icon on the right side of the SketchUp screen. At the top is a search field, where you can enter, for example, “eyeballs.” N When you see one you like, click it. This will download the object, attach it to your cursor, and you can “drop” it wherever you click in the model. The problem is that while sometimes they’re perfect, often they’re the wrong size or have extra objects you don’t need. In this example, the eyeball I chose is WAY too big. O The Scale tool is what’s needed to make a model the right size. But then
the trick is moving the object into place. The way to do this is to move an object in several steps, each time going in one of the axis directions, and always clicking in blank space. For example, in this head-on view, I can move the eyeball left or right, always sticking to the green direction, to bring it close to the head. P Then I would change to a side view, and move the eyeball in the red direction, to the front of the head. Q Remember the blue direction as well, and after a few careful moves in a few different views, the eyeball will land where it needs to go. R To copy the eyeball, use the Move tool with the Ctrl/Option key, and again, be sure to use an axis direction and click only in blank space. S A model you find may need to be turned, like this carrot (for the nose). Right after a model is brought in, the Move tool is automatically active. You move objects with this tool and also rotate. When you move your cursor to the top of an object that’s facing the wrong way, and hover over one of the red “plus” signs, the protractor appears and you can click and spin. T Then, move the carrot into place. U After bringing in a top hat, it can be rotated side-to-side when the cursor is placed along the front. This is how to give the hat a little tilt. V Once tilted, move in red, green, and blue directions to place it just right, a bit to the side of the head. W If you want buttons down the front, each button will need to be rotated to be parallel to the curve of each snowball. X In this example, in addition to eyes, nose, hat, and buttons, I found twigs for the arms, as well as a bow tie. Each of these objects needed to be scaled down to size, and moved into place using several different views. Y b
A
H
O
V
B
I
P
W
C
J
Q
X
D
K
R
Y
E
L
S
F
M
T
G
N
U
SketchUp is a free program for 3D modeling. Find SketchUp Make at https://www. sketchup.com/ download/all. The free, web-based version of SketchUp can be found online at https://app.sketchup. com/app.
11
Concepts
12
e B U O Y d l ? r u e Co m m a r g o r P a
BY TIM SLAVIN
There's a lot of talk that everyone on the planet should be a programmer, but this raises the question, "What does it take to be a programmer?" While almost anyone can learn to program a computer, not everyone has the interest or learning skills needed to succeed in the field long term. For example, curiosity or lack of curiosity is a huge reason people succeed or fail at programming. Coding and Computer Science is a vast field of knowledge that one could spend a lifetime exploring, the same way some people spend lifetimes exploring how to create music or repair cars or teach children. Here are five questions to ask yourself that will help you determine if programming could be a viable topic for you to pursue and some things you’ll need to do if you want to be a programmer. b
1.
Are You Curious About Programming? This one is easy. If you’ve typed a few lines of code and seen your code processed, then you know whether or not that impressed you. Typing code and seeing it run becomes addictive to programmers. Like many things people do, programming is about solving problems. You might be curious about how people build houses but not curious about how computers operate. A person curious about programming most likely will be successful with programming. Problems in programming are of two types, how the code helps someone solve their problems and bugs that will crop up during coding. Both types require patience, research, and curiosity.
2.
Can You Work on Your Own? If a person is curious about software programming, it’s likely they can happily spend hours working on problems by themselves. They won’t need someone to sit and help them solve every problem. To code, programmers need an internet connection and a search engine and maybe a few reference books. When they find a problem, they search the error message online or look up details of a language.
3.
13
Does Thinking Bore You? You might solve a problem by jumping right into it. Most of the time, however, you should take at least a moment to understand a problem and what resources are available to solve it. If you’re curious about programming and the larger topic of computer science, it’s unlikely you’ll be bored when a problem appears. Instead, the problem might spur excitement and interest to think about all possible solutions. And joy when you think of a solution and it actually works!
5.
Do You Know Everything? There are reasons people resist change, or the possibility that they might be wrong. They often lack humility, and get defensive if they are wrong. But having humility, the ability to welcome feedback, and an open mind are required to be successful, especially with a complex topic like programming. It might take practice to welcome being wrong or to accept help. But it’s always useful to accept one solution and then ask yourself what other solutions might work as well, or better. Often, there are a number of ways to code a solution to a programming problem. Good programmers understand that in the future they will read their code and see its faults. They know they will keep learning more efficient ways to code. However, programmers also know they often have to accept a "good enough" solution if a perfect solution isn’t obvious. Solving a problem today is sometimes more valuable than perfection.
PAUL INKLES, FLICKR
4.
Are You Detailed Oriented? There's a common saying, "The devil is in the details." That holds true especially for programming. It’s important to be attentive to details so that your code will be as efficient as possible. Often that means writing less code. But it also means organizing code to be readable and easily understood by anyone. Successful programmers rarely deal with problems caused by small syntax details like a missing semicolon. Instead, they get tripped up by subtleties in a programming language, for example, how dates are retrieved and displayed.
14
s i r o t u p m o C t a h T n a m o aW
In the Middle: A Deeper Dive Into Everyday Stuff
BY TIM SLAVIN
ENIAC (Electronic Numerical Integrator and Computor) was the first successful electronic and digital computer designed to calculate ballistic trajectories during World War II. The work involved often complex calculations. Because the calculations were considered clerical work, it was thought to be suitable for women. So, six women were hired to use their math skills to program the computer. Their job title was Computor. They called themselves The First Programmers Club. These women learned to program ENIAC before they had access to it. They used the blueprints to define rewiring and mechanical switches needed to calculate trajectories step by step. ENIAC weighed 30 tons, used 200 kw of power, 18,000 vacuum tubes, 1500 relays, and hundreds of thousands of resistors, capacitors, and inductors. The computer was 80 feet (24 meters) long. On the 50th anniversary of ENIAC's successful launch, most of these women were not included or recognized, despite their critical work programming the computer to perform its calculations. Kathy Kleiman, a programmer in the 1980s, founded the ENIAC Programmers Project to document the contributions and successes of these six women and other early women programmers. While much of the hardware design and construction of ENIAC involved men, women played a dominant role in learning how to operate the computer to perform calculations. Several of these women went on to contribute to computing for decades. Here are short biographies for the six original ENIAC programmers, as well as for Adele Goldstine. Ms. Goldstine wrote the original operations guide for the computer and trained some the programmers. Kay McNulty Mauchly Antonelli
Born in Ireland, Kay and her family moved to Philadelphia when she was 3. Kay took every math course offered in high school and college, and graduated with a math major. After college she worked for the US Army at the University of Pennsylvania, then was hired to program ENIAC. She married one of the co-inventors of ENIAC, John Mauchly. She helped him with the software designs for the BINAC and UNIVAC computers.
TERREN IN VIRGINIA, ENIAC AT THE SMOTHSONIAN, WASHINGTON, D.C., FLICKR
Betty Holberton
On her first day of college, a math professor asked if she would be better off at home raising children. Holbertson switched her major to journalism, one of the few careers open to women in the 1940s, because it let her explore subjects that interested her. She found a job with the US Army at the University of Pennsylvania calculating ballistic missle trajectories. She was hired as one of the original ENIAC programmers based on her work and led the team. Holbertson went on to work with Grace Hopper developing COBOL and FORTRAN, two early critical programming languages.
15 Ruth Lichterman Teitelbaum
After graduating from Hunter College in New York City with a Bachelor of Science degree in Mathematics, Teitlebaum was hired to work with Kay Antonelli, Bartik, and other women at the University of Pennsylvania for a US Army project. Her work led to work programming the ENIAC computer. She eventually trained the next generation of ENIAC programmers when the computer was moved to the Aberdeen Proving Ground in Maryland in 1948. Marilyn Wescoff Meltzer
Ruth Lichterman Teitelbaum, left; Marilyn Wescoff Metlzer, right
Betty Jean Jennings Bartik, left; Frances Bilas Spence, right
A graduate of Temple University in Philadelphia, Wescoff was hired to do weather calculations for the US Army at the Moore School of Engineering, part of the University of Pennsylvania. She was hired because she knew how to operate an adding machine! In 1943, she was hired to perform ballistic trajectory calculations, then hired in 1945 as one of the original six ENIAC Programmers, or Computors. Betty Jean Jennings Bartik
Betty Jean graduated from Northwest Missouri State Teachers College in 1945 as the only math major. She got a job with the US Army and worked at the University of Pennsylvania as one of the ENIAC computors. She married William Bartik, an engineer working at the university. Betty Jean helped convert ENIAC from manual computing (setting dials and changing cables) to stored program computing. She also worked on the BINAC and UNIVAC computers. After taking time off to raise her family, she worked as a technology editor for a publishing company. She also documented the contributions of the early ENIAC programmers. Frances Bilas Spence
A native of Philadelphia, Bilas majored in mathematics with a minor in physics at Chestnut Hill College where she met Kay Antonelli, another of the original ENIAC programmers. She was hired by the University of Pennsylvania to work on the US Army funded project to calculate ballistics trajectories by hand. She was then picked as one of six women to program the new ENIAC. In 1947, she married Homer Spence, an Army electrical engineer assigned to ENIAC. Adele Goldstine
Goldstine wrote the first complete technical description for ENIAC. She also worked with Jean Bartik to convert the ENIAC to use stored instructions, instead of needing new programming every time it was used. She earned a Masters in Mathematics at the University of Michigan, where she married Herman Goldstine who was involved in the construction of ENIAC. Ms. Goldstine taught at the University of Pennsylvania and trained some of the original ENIAC programmers.
b
Puzzles
16
BY JENNIFER NEWELL
Binary Patterns Look at the following list of numbers. Do you notice a pattern, from right to left, that creates the next number in this sequence? 1, 2, 4, 8 What number do you think comes next? If you guessed 16, you have an idea how binary numbers work. Binary numbers are made up of only two digits, either a 0 or a 1. The position of the zeroes and ones determines the value of each 0 or 1. For example, 1101 is a binary number. The values of each 0 and 1 depends on where it is located, counting from the right hand number.
FIONA HENDERSON, FLICKR
8 4 2 1—Value based on position, right to left 1 1 0 1—0 or 1 in position, right to left In this example, to determine the value of 1101, we would add up the values based on the position of each 1 digit. There is a 1 in the 8, 4, and 1 value positions. Because 8 + 4 + 1 = 13, the value of 1101 is 13. Adding up numbers from this list— 1, 2, 4, 8, 16—we can make any number from one to thirty one. Why 31? Add 16 + 8 + 4 + 2 + 1 in our list! Can you guess the binary number for 31? It’s a 1 in every position counted right to left: 11111 or 16 + 8 + 4 + 2 + 1. Take a look at the chart below: Chart A 16
8
4
2
1
1
1
0
1
Total
If we add up the value above each cell with a 1 in it we get 13 (8+4+1). Let’s try another one. Add up the values above each box with a 1 below. Chart B
BRENDON HOLDEN, FLICKR
16
8
4
2
1
1
1
1
1
0
Total
If you got 30, you’re right! Although computers perform all sorts of complex tasks, a computer only knows whether or not electricity is passing through part of a circuit within it. The cells with a 1 represent where there is electricity, and the cells with 0 represent where there is none. Take a look at the updated chart below. This time each yellow box is marked with a 1 and each green box with a 0.
16
8
4
2
1
Total
0
1
0
0
1
9
In binary, the number 9 (8 +1) is represented by 1001. The leading zero is not written as it simply indicates that no number beyond eight was used in the calculation. If we do the same for the number 30, we will find that it’s binary representation is 11110 (16 + 8 + 4 + 2), reading and counting from left to right.. For some extra binary fun, challenge yourself to decode the binary boxes to the right. GWEN, FLICKR
Instructions: Each row of each table represents a number in binary form, using zeros and ones. Add up the numbers in the top row that correspond to each shaded box. Find the sum in the key at the bottom of the page, and replace it with the corresponding letter to decode the answer to each riddle. I am an odd number. Take away a letter and I become even. What number am I? Hint: The first row of the table has the 16, 2, and 1 columns with a 1. Adding these up we get 19 (16 + 2 + 1). In the key below, we see that 19 corresponds to the letter “s”. So the first letter of the answer is “s”. The second row has the 4 and 1 columns have a 1 for a sum of 5 (“e”), and so on. 16
8
4
2
1
Total
letter
1
0
0
1
1
19
s
0
0
1
0
1
5
e
1
0
1
1
0
0
0
1
0
1
0
1
1
1
0
I'm tall when I'm young, and I'm short when I'm old. What am I? (The blackened row indicates space between words.) JEFF GOLDEN,, FLICKR
16
8
4
2
1
0
0
0
0
1
Total
0
0
0
1
1
0
0
0
0
1
0
1
1
1
0
0
0
1
0
0
0
1
1
0
0
0
0
1
0
1
letter
You see me once in June, twice in November, but never in May. What am I?
PETE, FLICKR
K E Y
16
8
4
2
1
1
0
1
0
0
Total
0
1
0
0
0
0
0
1
0
1
0
0
1
1
0
0
0
1
0
1
1
0
1
0
0
1
0
1
0
0
0
0
1
0
1
1
0
0
1
0
0
0
1
0
1
letter
1
2
3
4
5
6
7
8
9
10
11
12
13
a
b
c
d
e
f
g
h
i
j
k
l
m
14
15
16
17
18
19
20
21
22
23
24
25
26
n
o
p
q
r
s
t
u
v
w
x
y
z
If you fill in each shaded box in the charts above with a one and each blank box with a zero, you will see how each sum is represented in binary form! b For more about binary numbers, check out the story on page 21 in this issue.
17
18
tidbitz
In the Know
It's a Gas!
Do you know me? You should!
Many women have contributed to science, technology, engineering, and math. The Women You Should Know website has colorful posters highlighting a number of women. Posters can be downloaded for printing and posting in a classroom or at home. There are also biographies of each person. Bonus: the posters are created by women artists from around the world. b
https://womenyoushouldknow.net/ downloadable-stem-role-models-posters/
IMAGE OF DR. HAYAT SINDI FROM WOMENYOUSHOULDKNOW.NET
IMAGE FROM HTTPS://SVS.GSFC.NASA.GOV
This amazing video models carbon dioxide flows around the earth over a year. When trees and plants bloom, NASA data shows how plants absorb this human-generated CO2 and how autumn and winter wind patterns disperse the gas. The model is a computer software program that runs on mainframe computers using data from NASA satellites. While the video shows actual data for 2006, the model also can project the impact of future CO2 emissions. b https://svs.gsfc.nasa. gov/11719
Actually, This IS Rocket Science
NASA has a new online and mobile app game called Rocket Science: Ride to Station. You can explore how the resupply missions for the space station operate. Pick a vehicle—either a Boeing Starliner or SpaceX Crew Dragon— choose one of three missions (out of nine missions possible), choose your crew from real astronauts in the NASA program, build your rocket, launch, then dock with the space station. It’s a lot of fun, educational, and nine missions should keep you busy! b https://www.nasa.gov/stem-ed-resources/rocket-science-ride-tostation.html https://rocketsciencec2e.ksc.nasa.gov/ https://www.nasa.gov/specials/ccp-press-kit/main.html
RICHARD MORTEL, FLICKR
It's Greek to Me!
Computers are perfect for deciphering languages because they can look for patterns in text, and compare similar patterns between languages. Human languages have words that appear in patterns. Each pattern of appearances is unique to each word. Each word can be thought of as a vector within a space, and the vectors obey mathematical rules that the machine can use to map out languages and compare them to each other. The machine finds similar patterns between languages without ever having to know what the actual words mean. Researchers at MIT and Google’s AI lab have created software that uses this concept and automatically deciphers even long-lost languages, starting with the Linear B language, an encoded version of ancient Greek, as well as Ugaritic, an early form of Hebrew. Another long-lost language, called Linear A, has yet to be deciphered and remains a puzzle for linguists. The researchers are hopeful their software can finally decipher Linear A, which would be a huge accomplishment. b https://www.technologyreview. com/s/613899/machine-learninghas-been-used-to-automaticallytranslate-long-lost-languages/
What Is AI?
Most people are confused when they hear or read about AI or artificial intelligence, machine learning, and other topics about smart computers that can (supposedly) think for themselves. The University of Helsinki and Reaktor have created an online course, Elements of AI, that explore all things related to artificial intelligence. Their "What is AI?" chapter can be understood by anyone, regardless of their experience with tech. Other chapters become more advanced, as they dig into different aspects of AI. If you sign up, there are exercises you can do to test what you’ve learned. b https://course.elementsofai.com/ https://www.elementsofai.com/
3D Printing in Space The US Air Force recently had a contest to encourage companies to create rocket engines and launch vehicles. Launcher, a company in Brooklyn, NY, created their Engine-2 rocket engine as a single 3D printed piece of copper alloy. Their website has interesting photos, and a video showing how they IMAGE OF ENGINE-2 FROM created and then tested LAUNCHERSPACE.COM their rocket engine. (Notice all the software used throughout their design, build, and test process: someone wrote all that software!) b https://launcherspace.com/engine-2 https://www.youtube.com/watch?v=7pXEf0wHU1Y https://3dprintingindustry.com/news/launcher-sets-test-firedate-for-rocket-engine-with-largest-3d-printed-combustionchamber-164820/ https://www.popularmechanics.com/space/rockets/a29833666/3dprint-rocket-engine-combustion-chamber/
19
Concepts
20
BY CLARISSA LITTLER
Finite Automata: The Smallest Machines Computer scientists like to study kinds of computers. But “computer” doesn’t only mean an object like a desktop or smartphone. "Computer" simply means "something that computes." So the computers scientists study include a bunch of different theoretical machines that are simulated with just a pen and paper, each with different abilities and restrictions on what they can do. These range from the mighty Turing machine, a nearly century old pen & paper “computer” that has infinite memory, to the tiniest machines called finite automata. Finite automata are so simple that we can build and simulate one with just a few circles and lines drawn on paper. All a finite automata is capable of is processing a series of inputs one after the other and then responding “yes” or “no”. Here's our first example, which is a finite automata that answers the question "is this binary number even?"
You can “run” this machine with a pen and paper. We start at the circle on the left with the arrow pointing into it and then feed the machine one input at a time. In this case, those inputs are digits of the binary number. (For a refresher on binary numbers, check out the sidebar on page 21.) For each input, follow
the arrows between the different circles, or states. If, after we've eaten all the digits of the number, we're in a double circle then the answer is "yes". If we're in only a single circle the answer is "no". The logic of this automata is that if a binary number ends in a 0 then the number is even, but if it ends in a 1 the number is odd. Let's try an example. Run the automata on the input "1010", which is 10 in decimal. You start in the "odd" state and the first character is a 1, so you loop back into the "odd" state. The next character is a 0, so you move into the "even" state. The next character is a 1, so you move back into the "odd" state. The last character is a 0, so you move into the "even" state and stop. This means the number is even! To test yourself, try a few other binary numbers like "111", which is 7 in decimal, or "11010" which is 26 in decimal. What else are finite automata good for? They're used "under the hood" of a lot of software as very efficient ways to calculate the answers to all sorts of questions like "Does this email address end with either '.com' or '.org'?" which is solved by the following automata. Note the use of the “*” symbol as a shorthand for “any character” rather than drawing a separate loop for every letter, number, and symbol. Or this one that tests a solution to a
Legend of Zelda-style maze where you have to move through a specific set of exits or get sent backwards.
These automata are all just pen and paper simulations of machines, but you can implement them inside any programming language. They’re used all the time for efficiently executing regular expressions, which are a popular tool for searching and matching text. Computer scientists have another interest in finite automata. We like to know how much power different models of computation have. This means we don't just want to know what it can do but what it can't do. To that end, see what goes wrong if you try to write a finite automata that answers the question "is this word a palindrome?". What’s the simplest feature you could add to a finite automata that would let it answer the question? That's our introduction to finite automata, the simplest kind of computing machine we can define. They're shockingly powerful for how simple they are and even more shockingly close to being real computers. Try writing some and seeing what you can do! b
21
BY TIM SLAVIN
Concepts
Just 0's and 1's When you see a letter A on your computer screen, did you know the computer doesn’t actually use the letter A? Instead, it uses a unique string of numbers 01000001 for A. This is called a binary number because it uses two numbers, 0 and 1, to represent the letter A. Computers transport, calculate, and translate binary numbers because computer hardware circuits only have two electrical states, on or off. These two states can be represented as zero (off) or one (on). All letters of the alphabet, numbers, and symbols are converted to unique eight (or more) character binary numbers as you use software on your computer. You can explore binary numbers without diving deeply into how computers translate unique binary numbers into letters, numbers, and characters. Here’s how binary numbers work. First, each position in a string of ones and zeroes represents a power of 2. A zero means no value is counted. A one means the value of a power of 2 is added to your total number. The value of the power of 2 depends on the position of the one in the string. A binary number value is calculated by adding up the power of 2 values, working from right to left. The two-digit binary number 1 1 has a value of 3. How do we know this? The left 1 is in the position with a power of 2 value of 2, while the right 1 is in the position with a value of 1. Here are the steps to take to figure out the value of the binary number 1 1. 1
1
Write a binary number 1 or 0 in each cell
2
1
Position Value (as a power of 2)
2
1
Write the value of each 1, then write the total here: 2 +
1 = 3
Using this same method, we can figure out that the three-digit binary number 1 1 0 equals 6 (4 + 2): 1
1
0
Write a binary number 1 or 0 in each cell
4
2
1
Position Value (as a power of 2)
4
2
Write the value of each 1, then write the total here:
What’s a "power of 2" number? It’s creating a sequence of numbers by multiplying each number by 2 and starting with the number 1. So, 1x2 = 2, 2x2 = 4, 4x2 = 8, onwards. Power of 2 values, therefore, are 1, 2, 4, 8, 16, 32, 64, and really onwards until infinity. In 1703, Gottfried Leibniz published a paper that describes binary numbers, and in 1937 the computer scientist Claude Shannon was the first to suggest all electronic data can be reduced to one unit, either on or off. These units are called binary digits or bits. Shannon took Leibniz’s idea and an earlier idea developed by the French mathematician George Boole, about algebra and a theory using two values, and used these ideas to quantify and measure the data that flowed across the US AT&T telephone networks. b For more about binary numbers, check out the story on page 16 in this issue.
POST-SOFTWARE, FLICKR
4 + 2 = 6
Programming
22
3D/RGB/GL
BY CLARISSA LITTLER
Want to create amazing 3D graphics with code? Here's how! To start, let's look at how programs turn code into graphics. Your screen is made of pixels: about 2 million of them for a 1080p screen. Each pixel can display one of millions of possible colors by combining red, green, and blue light together. The job of the graphics card is to tell each of these pixels exactly what color goes in each pixel, and it does this in a few steps. 1. The program sends a description of the scene to the graphics card, in the form of a bunch of objects defined as tiny tiny triangles. 2. The program tells the graphics card how to take the description of the scene and rotate and move it around relative to the "camera" that the player is looking through. 3. The graphics card calculates how all these objects relate to pixels on the screen. 4. The program finally tells the graphics card all the textures, lights, and colors of all the objects and it calculates the color in each pixel. This is the fragment shading phase. So, we've said that you "write code" that tells the graphics card to do all of these things. Does that mean you can just write some Python code and talk directly to the graphics card? Not exactly. You're going to need a special software library. Which library you need depends on what kind of system you want your program to run on. You'll use • OpenGL for Linux, Windows, or Android phones • Metal for Mac OSX or iOS ANDRES RODRIGUEZ, FLICKR
• DirectX if you're a Windows programmer who doesn't want to use OpenGL • Vulkan if you're an OpenGL programmer who doesn't want to use OpenGL • WebGL if you want your graphics code to run in the browser No matter how you swing it, that's a lot. Each of those is a pretty big thing to learn in its own right. Let's take a shortcut to doing 3D graphics by programming only the fragment shading phase we talked about earlier. For this kind of programming, we’ll use the language GLSL—the OpenGL Shading Language—on the site Shadertoy Shadertoy is a free website that handles a bunch of WebGL setup for you so all you need to do is write your fragment shader. GLSL is a pretty big topic, so we're going to talk about just a few concepts.
First, in Shadertoy, you write code that calculates the color of each pixel on the screen. You can use the position of the pixel on the screen for this calculation as well as all sorts of other properties: the position of your mouse; how much time has passed since the program started; or input from the microphone. Here's an example that makes pixels redder as you move towards the right of the screen, greener as you move up the screen, and bluer depending on how loud you are (you do have to enable iChannel0 as the microphone by clicking on it at the bottom of the screen)
23
void mainImage( out vec4 fragColor, in vec2 fragCoord ) { vec2 uv = fragCoord/ iResolution.xy; float heck = texture(iChannel0,vec2(uv.x,0.25)).x; vec3 col = vec3(uv.x,uv.y,heck);
Here are two really great resources to learn more: 1. This YouTube series: https://www.youtube.com/ playlist?list=PLGmrMu-IwbguU_ nY2egTFmlg691DN7uE5 2. The Book of Shaders: https://thebookofshaders.com/
// Output to screen fragColor = vec4(col,1); } What else can you do in Shadertoy? What can't you do? You can create randomly generated landscapes, render 3D models of objects, create interactive art pieces, or even practice graphical effects like fire or smoke. What you learn about GLSL in Shadertoy is applicable in all sorts of graphics programs or game development environments. The Shadertoy interface
and you will want to check the GLSL documentation at https:// www.khronos.org/opengl/wiki/ OpenGL_Shading_Language With these in hand you'll quickly be making awesome 3d art in no time! b
Tech in Real Life
24
BY SIMON BATT
Smarter Streetlights Have you ever wondered how a street light works? If you’ve ever seen them turn on, you know that it doesn’t involve someone walking down a street and turning on all the lights. They all seem to magically know when it’s dark outside, and turn on automatically. Street lights monitor how light it is outside and decide for themselves when to turn on and off. They achieve this by using what’s called a “photocell”—that’s smart-speak for a photoelectric cell. Photoelectric cells love light. They’re designed so that, when light falls on their surface, they allow electricity to pass through them easier. When the cell doesn’t receive any light, it tightens up the electrical resistance and stops electricity flowing as easily. Using this photoelectric cell, we can detect if it’s light out, and how light it is. There’s a problem, however; the cell is doing the opposite of what we want to achieve! When it’s light out, the cell lets energy through easily, but that’s when we want the light to be off. Likewise, the cell stops energy passing through when it’s dark, but that’s when we need to power a bulb! As a result, it’s not a good idea to just use the cell for turning the light on and off. A circuit in a street light instead uses a switch that watches the photoelectric cell closely and reacts depending on what it’s doing. So, when it gets dark and the photoelectric cell stops electricity flowing through it, the switch can note that and turn the light on. In a way, street lights are pretty smart. They already know when to turn themselves on and off. Did you know, however, that they’re going to get even smarter in the future? Scientists are thinking of ways that street lights can become part of the future of “smart cities". For example, there’s a street light that’s in development called the BrightSites. Not only will it detect when the sun goes down, but it can also monitor the quality of the air for pollution. They’ll also use their tall height to act as Wi-Fi and 4G antennas to help people connect easier. They can use cameras to detect traffic, and even display information via signs. A lot more exciting than the street lights we have now. Now if you see the street lights blink on at night-time, you’ll now know that it’s because the humble street light is a lot smarter than you may first think. Not only that, but they’ll be even smarter when smart cities take off. b
ARTEM KOVALEV, UNSPLASH
IMAGES, TOP: MICHAEL R PERRY, FLICKR; CENTER IMAGES: SUZANNE D WILLIAMS, UNSPLASH; BOTTOM: RENEE GRAYSON, FLICKR
Nobody writes perfect complete software the first time they sit down to code. Many times, the best results happen when you design and code an application then put your work aside and do it all over again. It's sort of like writing a first draft of a story, and then going back to the beginning and editing it. Coding an application two times gives programmers more insight into the problems they’re trying to solve with code. Starting all over again, adding features, and fixing software bugs results in multiple versions of a software application. Keeping track of which version a person has a problem with is important. You also don’t want to put out a new version of your software that fixes a problem that someone else already fixed in an earlier version. Software, therefore, uses numbers to keep track of versions. There are different ways to ensure code is the latest and best version. What’s a version number? If you use the Google Chrome web browser, go to chrome://settings/help, or, click the three stacked dots at the far right of the URL bar in Google Chrome. Then click Help, then click About Google Chrome. This displays Settings page with the software version number. Doing this on my browser shows Version 78.0.3904.108 (Official Build) (64-bit). What does that mean? Using a method called semantic versioning, the 78, 0, 3904, and 108 tell a lot about when this browser version was created and how this version relates to past (and future) versions. This is an example of MAJOR. MINOR.PATCH pattern used to track versions of most major software. A major version is one that doesn’t work with past versions, in whole or part. A release with backwards compatible changes is a minor release. And a release with backwards compatible bug fixes is a patch release. Therefore, my Google Chrome browser version 78.0.3904.108 translates to the 78th major release of the browser, with no minor releases so far and 108 patch releases to the 3904th patch release. Whew! While semantic versioning makes sense, not every company uses this method. Microsoft, for example, created Windows 3, 95, 98, 7, 8, and 10, among other versions. Using versions for your software projects is good practice and helps people who use your software. They want to know they have the latest version. b
25
Concepts
The Latest st Version
BY TIM SLAVIN
Programming
26
BY TIM SLAVIN
Hmm, Which Language Should I Learn? If you wanted to learn a programming language, where would you begin? The answer depends on what you want to do and what interests you about programming. As for me, every so often I think that I should stop writing about technology and instead learn software programming and be a programmer. I’ve been writing about software that uses Java and Groovy, a scripting language that fits well with Java. And there’s some Kotlin tossed in. If I do switch to programming instead of writing, I'll probably learn those languages. If you want to play with programming to see what it’s like, then Python is a great place to start. It’s an easy-to-read language yet has enough structure to teach you what to look for when coding. The repl.it website, this magazine, and many books and online sites have Python tutorials to help you become familiar with the basics of programming and Python. Scratch and products like Sphero are also good places to start. A Sphero robot (sphero.com) lets you program with block code. You can then see how that code translates to a simple programming language. If you’re more serious about programming, or you’ve played with simple programming and want to learn more, then Python will also work for you. People use Python for machine learning and business software. Plus, the Python language is mature with lots of features. If you’re curious about the internals of computer hardware and software, then you might explore Assembly and C. These complex languages translate the 1s and 0s of computer hardware into data used JUAN RUMIMPUNU, UNSPLASH
by operating systems and software interfaces. Most serious programmers learn Java and/or C# (called C sharp) or C++. The latter two are Microsoft technologies. Java works on many operating systems including Windows. All are heavily used in business. The last option is a little quirky. Believe it or not, there are still COBOL software applications in use. It’s possible you could learn a language from 1959 and still get a job programming! The COBOL language is still under development. And there’s at least one online emulator (so you can practice without installing software) and an editor optimized for COBOL. Whatever language you decide to start with, it’s important to learn by doing. Create small applications using what you learn. Use online forums like Stack Exchange and any search engine to look up error messages and find solutions to problems you encounter. Find tutorials and books that show how to create applications. Find online emulators to practice your language. And, if you become serious about programming, set up a page on Github to upload your coding projects to show people who might hire you to create software. I find programming to be both solitary and social. Coding is usually done alone, but defining and solving problems often involves people working together. If you decide to try coding, whatever language you choose, hopefully you’ll enjoy both working on your own and with others. b
This puzzle mixes math and coding. Plus, you can go online to try the code yourself. In his book The Colossal Book of Mathematics: Classic Puzzles, Paradoxes, and Problems, Martin Gardner simplified a classic question about monkeys and coconuts. His simplified version goes as follows: “Three sailors come upon a pile of coconuts. The first sailor takes half of them plus half a coconut. The second sailor takes half of what is left, plus half a coconut. The third sailor also takes half of what remains, plus half a coconut. Left over is exactly one coconut, which they toss to the monkey. How many coconuts were in the original pile? If you arm yourself with 20 coconuts, you will have ample material for a trial-and-error solution.” To get a feel for the problem, let’s guess that the sailors collect 9 coconuts. That means the first sailor takes half of 9 (4.5) plus .5 more for a total of 5 coconuts. How many coconuts are left for the second sailor? Well, that would be the total minus what Sailor 1 took, 9 – 5 = 4. The second sailor takes half of the 4 (2) plus ½ more, making 2.5. That means he leaves 4 – 2.5, or 1.5 coconuts for the 3rd sailor. Finally, Sailor 3 takes half of 1.5 (.75) plus 0.5 coconuts, for a total of 1.25. If Sailor 3 started with 1.5 IMAGES FROM RAWPIXEL, FLICKR
coconuts and took 1.25 coconuts, there is ¼ of a coconut left. But that is problematic since the question says that at this point we should have exactly one whole coconut remaining to toss to the monkey. We could make a second guess, and then possibly a third and so on until we end up with 1 coconut for the monkey. But there's a better way to solve this.. Mr. Gardner recommends arming oneself with 20 coconuts, implying the answer is no more than 20, but how about we arm ourselves with a little code as well? Since we understand the process of dividing up the coconuts for each sailor, we can write a program to do the calculations for us. We will still need to make a guess, but the computer can do the calculations and tell us if our next guess should be higher or lower. We’ll give this a try in Python. This program gets us the answer, but leaves plenty of room for improvement. If you have a bit of programming experience, you can challenge yourself to rewrite them with fewer lines of code, or by defining functions. The answer might be much more than 20, so you’ll probably want a program that makes all the guesses for you. Here’s the process in pseudocode:
Guess a number Divide it by 2 and add ½ Subtract the answer from our original guess Repeat the process two more times And here’s the pseudo-code written in Python 3 code to try at the repl.it website: #our first guess is 17, you can replace 17 with your own guess total = float(17) #we want to figure out how many coconuts all 3 sailors get, so we need to loop through the algorithm 3 times. You can replace the numbers in range(1,4) with any two numbers that are 3 apart. for i in range(1,4): sailorTakes = total/2 + .5 print(“Sailor”,i, “takes”, sailorTakes) remaining = total - sailorTakes total = remaining print(“There are”, total, “left”) print(“-------------------”) if(total == 1): print(“You got it!”) elif(total > 1): print(“Guess a smaller number”) else: print(“Guess a bigger number”) b
27
Puzzles
Sailors, Monkeys, and Coconuts
BY JENNIFER NEWELL
Parents and Teachers
28
BY TIM McGUIGAN
Teaching the Basics of AI
Computational Thinking in Using Computational Thinking to solve problems is one of technology’s great super powers. This mental skill is great for tackling thorny problems both big and small. However, sometimes my students have difficulty grasping how to apply these skills to the outside world. So, when I recently introduced Computational Thinking to my 6th grade students, I explained that we can use these tools to solve problems that exist not only in our classroom, but also in our own backyards. Using a computer as a part of the solution is certainly an aspect of Computational Thinking, although as they would find out, most of the “heavy lifting” happens between their ears (and on scrap paper). Originally born out of the need to break down problems before
feeding them into the limited computers of the 1950s and 60s, Computational Thinking is certainly not a new concept. It was first mentioned as an educational tool in the groundbreaking book, Mindstorms, by Seymour Papert in 1980. However, there has been a recent resurgence in teaching problem-solving methods in schools. While these cognitive skills are helpful for robotics challenges, I felt like my students’ understanding existed only within the walls of my classroom. So this year, I asked them to begin solving problems using these methods in the world outside of our computer lab. Decomposition is a form of Computational Thinking where a large problem gets broken down into smaller and smaller problems. The point of decomposition is to
take something that as a whole seems daunting and reduce it to a series of easy-to-solve problems. So, one offline activity I assigned was decomposing the gargantuan task of making a peanut butter and jelly sandwich. This classic exercise in process-oriented thinking asks students to organize tasks, identify sub-problems, and make calls on what problems are fully decomposed. Most of my students didn’t see making a sandwich as a problem to begin with, so this was a perfect task to decompose. This year, I gave them the added challenge of decomposing this problem to the point that a three or four-year old could execute it. I even encouraged a few to test out their processes on younger siblings and report back their findings. Most of the
29
the Wild students were able to figure out that collecting materials was the first sub problem, although some missed this point and focused more on bread, peanut butter, and jelly. In the end, no students were able to report back that a younger sibling effectively built a sandwich from their instructions alone. However, all was not lost. I found that students’ thinking around decomposing problems was sharper after encountering a few peanut butter disasters at home. After another lesson on Algorithms, I assigned homework to play a few games of TicTac-Toe with friends or family. Simple games such as this can be a great foray into thinking computationally. Algorithmic design is a complicated topic for an 11-or 12-year old to master. That said, many kids as young
LARS PLOUGHMANN, FLICKR
as five or six begin learning how algorithms work through playing Tic-Tac-Toe. Young people realize from an early age that it is a game governed by a simple set of rules which in turn drives their decision making. So, I gave my students the task of playing Tic-Tac-Toe while recording their decisions on a flowchart. To make things simpler, I gave them the task of flowcharting only the games where they went first. Mapping out these decisions into a flowchart takes some effort, but I assured them that doing so would guarantee they would never lose a game of Tic-Tac-Toe again. From the amount of erasing and rewriting that happened, it looked like it took a few tries to figure out what would work best in each situation. However, I had a few students report back that
they were making the same three decisions over and over again. This was exactly the type of revelation I was looking for, and it was a perfect segue into talking about iterations and looping. In the end, I had a few students figure out an effective algorithm for Tic-TacToe, and we were able to crowdsource a no-fail algorithm for future games. There are many more ways that Computational Thinking can be applied in the real world. From walking routes to sorting socks, there are teachable moments everywhere. Furthermore, these unplugged and offline activities help reinforce the concept that problem-solving methods are not just for the Computer Science classroom, but a systematic way to begin tackling the problems that arise every day. b
“Computers are good at following instructions, but not reading your mind.”
—Donald Knuth
Thank you for reading this issue of beanz ! Check out the links below to read stories from this issue online with links to learn more. "I Thinks My Human Needz a Laff!" http://beanzmag.com/ memes-for-programmer How Did Lightguns Work? http://beanzmag.com/ video-game-light-guns Where the Heck Am I? http://beanzmag.com/ plus-code-addresses Python Mad Libs http://beanzmag.com/ python-mad-libs
Could YOU Be a Programmer? http://beanzmag.com/ /5-programming-skills
Smarter Streetlights http://beanzmag.com/ smart-street-lights
That Computor Is a Woman http://beanzmag.com/ the-first-computors
The Latest Version http://beanzmag.com/ software-versions-syntax
Binary Patterns http://beanzmag.com/ /binary-riddles
Hmm, Which Language Should I Learn? http://beanzmag.com/ choose-programminglanguage
tidbitz http://beanzmag.com/ newswire-tidbitz-february-2020
Fire! http://beanzmag.com/ firewalls
Finite Automata: The Smallest Machines http://beanzmag.com/ finite-automata
Ahoy! http://beanzmag.com/ marinetraffic-website
Just 0's and 1's http://beanzmag.com/ what-are-binary-numbers
Frosty Is In the House! http://beanzmag.com/ sketchup-snowman
3D/RGB/GL http://beanzmag.com/webgl
Sailors, Monkeys, and Coconuts http://beanzmag.com/ sailors-coconuts-monkeys Computational Thinking In the Wild http://beanzmag.com/ computational-think-in-wild ribe! Subsc
http://beanzmag.com/subscribe