# How to Code : All Hype No Hard A Guide for Biochemists Basic Instructions Before Coding Earth Programming is not terribly complicated. It has a reputation for being this impenetrable, super complex, big brain thing. That's software engineering. Here, we're going to talk about programming : the task of making the computer do stuff. In programming, there are only 3 operations and 5 parts. This is in the same way that all the colors on your screen are made up of 3 numbers. You can get as fancy as you want mixing them up but, at the end of the day, you'll come back to these fundamentals. # 3 Operations We can get data. We can calculate values. We can set data. That is the entirety of programming. Even fancy things, like generating 3d mesh terrain from satellite images, are just getting, caluclating, and setting individual values. Hold to this promise like your mast in a storm. # 5 Parts Generally, programming languages include these 5 basics. 1. #includes - a way to access code in other files 1. variables - a way to store values for later recall 1. functions - a way to group lines of code for reuse 1. main() - a standard entrypoint into the program's execution, a starting place 1. constants - the ability to calculate using non-variable data, such as a literal number 100 or the word "dongetto" That's it. All the books, the schooling, the tutorials, and the industry at large are about doing these things smarter and better. Once you know how to do these things at all, you can write any program. The rest is just improving over time. ------ # Chapter 1 : main() Your entry point will depend on your programming language and where you intend to run the program (Windows/Linux/PS5/a helicopter). Most commonly, this will be main(). The code you write inside this function will execute line by line until there's nothing left to do or an error occurs. Understanding this is critical to figuring out where you went wrong. If you use some fancy stack of existing tools, you'll need to figure out where exactly ~your~ code begins running. In Godot, for example, every node has an _update() function that runs every frame. It also has _physics_update(), _input(), and _ready(). Knowing which of these runs when is part of learning that tech stack. When you write your own programs, you'll decide what runs when by ordering and controlling it in main(). # Chapter 2 : variables & constants int a = 47; //give me a variable named a, 8 bytes long, and store the number 47 in it string a = "fruitcake"; //give me a variable named a, give me one byte for every letter, and store the sequence 'f' 'r' 'u' 'i' 't' 'c' 'a' 'k' 'e' starting at a A variable is a portion of memory that we store data inside. We reference that storage by a name. Each variable will generally (but not always) be associated with a type. Types tell us what we can and can't expect to do with the data inside. We can expect an integer to be fine to use in math calculations. We cannot expect the string "fruitcake" to mean anything in the line b = a / 2 + 7. Constants refer to the numbers 2 and 7 in the above example. Constants for any data type can be used. In the example, a = "fruitcake", "fruitcake" is a constant. No storage memory is set aside for it and the value is only used inline. # Chapter 3 : functions Functions are for organizing code. You could write out, line by line, the logic needed to evaluate whether a character is dead in every single place that it's needed. You could also just write a function to return whether it's dead. That's it. It just makes life easier. Anything you write a lot or you feel would be more clear, if it were replaced by a function name, shove into a function. Think of a board game. There might be several ways to win or lose. When that happens, you don't want to write out the logic for resetting the board in each instance. You want to call reset_board() and be done with it. Functions are also great for when the logic is likely to change later. You can change it in one place instead of many. # Chapter 4 : #includes and getting data Includes allow us to access code in other files. Most often you'll include libraries that you did not write. The functions they provide seem magical, but rest assured that they are also just getting/calculating/setting data. We use libraries so that we don't have to tediously solve all the edge cases of every operation we want to do. Imagine you want to calculate how much time has passed without using any external library. However, it's also daylight savings, leap day, and your CPU is lagging out. You want some turbo nerd in Siberia to have already worked through all the unforeseen edge cases for you. So, you import his library and call his function. Programming is all about creating progressive barriers beyond which you don't need to immediately know how the magic happens. Digging into those details can be fun and interesting, but save it for non-production time. # Chapter 5 : calculating data Calculating data has two meanings. One is that we can literally just do math and store it to a value. int a = age / 2 + 7. The right side of this is calculating what a will be set to. We can also evaluate things. if( age < myAge / 2 + 7) will evaluate down to true or false. This will allow us to act upon those realities. It is common for functions to do these evaluations and then return a final result. bool is_too_old(age) { return (age > 25); } # Chapter 6 : setting data near and far Setting data is a bit of a vaguery. The pixels on your screen are controlled by an array of values somewhere on your system. Your operating system will determine where it's stored, how you can set it, and limitations on the formatting. However, if you can figure out where to set those pixels, you can display anything on your screen, because it's just data. Setting standardized data blocks that are used by other programs is how everything works. From screens, to networking, and even SMS notifications. Some program sits and watches a pipe for incoming data. When there is data in the pipe, it parses it into something meaningful and then sets the data on its own device to do something useful, like showing a notification. It's all a long chain between the user and setting data someplace. Building good chains is software engineering. Building any chain is sufficient. # Chapter 7 : putting it all together So, if we want to write a python program that reacts to seeing a number on screen, what do we need to do? We want to find a library that can interact with the pixel array that is the screen (get data). We want to compare that array to our target array and see if what we want is there (calculate data). Then, we put some value into a file (set data). # Chapter 8 : conclusion This guide has been intentionally vague. Whatever programming language you choose to pick up will follow these rules. Confident that you understand the structure of a program, you can now focus on just learning the syntax and picking out some libraries. Study beyond that is entirely academic engineering stuff. Worthwile and interesting, but at no point will it be revolutionary and unlock an ability that you don't already have. Godspeed. Your next stop : https://www.youtube.com/watch?v=wCho_BdpdyY (not mine)