Code Ninja
Byte
8 bits. This is used nowadays more out of convention (we've always done it this way), but originally it was because 8 bits was the minimum amount of data needed to store one character, A-Z, 0-9, ~!@#$%^&*(), upper/lower case. If you use Notepad in Windows, which is very basic, you can see how every character you type makes the file exactly one byte larger. If you type, "test" it will be 4 bytes big.
Structured Data Types
A collection of other variables, similar to an object. But whereas an object can hold a variable called "name" with a value "John," a structured data type like an array can only store information in numbered slots. So, array slot 1 (typed array[1]) could equal "John" but you couldn't find "John" by asking for array["name"]. It saves memory where labels aren't needed.
Computer Theory
A computer uses 0/1, off/on, true/false. Humans use words. Originally programmers really actually did program in pure binary. The original NASA spacecrafts that put HUMANS ON THE MOON, were hard coded in binary, and not even digitally but physically with copper wires on metal poles/switches. But, humans are lazy, so we've made it easier and easier. This is called making "higher" programming languages. The lowest level is binary (01110111 000011101 11111111), then "machine code" which is almost as hard as binary "ADD 01110111 000011101," than the higher level languages like Java ( var x = 1; x++;). The compiler turns your easy to read code into machine code based on your specific machine. Your operating system (chromeOS, Android, iOS, Windows, Linux) then compiles that machine code into binary for your actual processing hardware (CPU,GPU).
Internet/Server/Network
A network is just connecting two or more computers together so they can send data back and forth. The Internet is just connecting your one computer to every other bajillion computers connected to the Internet in a massive network. We all connect to servers, which are specialized computers that people don't really use for fun, they are just the traffic controllers that help our computers get around, and they store all the data for websites and videos on Youtube, and they do a lot of calculating work because they are generally crazily more powerful than our computers. They also convert www addresses like www.youtube.com into the actual computer address which is a bunch of numbers (e.g. 64.112.37.124, etc).
object
A reference data type that stores several other variables (numbers, logic, words) and functions (instructions).
Boolean (logic) Operations
AKA boolean algebra. Logic operations. AND (&&), OR (||), NOT (!) ...... either a test of two boolean variables directly, or a combination test of two comparison tests....
Java Data
ALL Java variables (data) is statically typed, meaning you MUST tell Java the TYPE and its NAME/LABEL before you can use it.
+=
Also like ++, but you can choose the number to change it by, so if x was 1, then x += 3 (same as x = x + 3), so x is now 4, than 7,10,13,16.... ((( BTW, this creates an "arithmetic" pattern)))
Exceptions/Events
An input a program detects, as they happen (keyboard button click, mouse click, mouse move, etc)
&& (AND)
BOTH must be TRUE to be TRUE...... so if x == true and y == true, then x && y is true..... or if x =3, y=5, then (x<5) && (y<10) is true. but if x == true and y == false, than x && y would be false.
Control Flow, how
Basically just a series of basic tests using logic and comparison operators on variables. IF, THEN, ELSE // DO THIS UNTIL SOMETHING IS TRUE // UNTIL THIS BIGGER THAN THAT // WHILE THIS IS FALSE // UNTIL var x IS 100
Control Flow, more
Because computers are not smart in the way humans are, you can't assume they know ANYTHING, because they don't. They can seem smart because they can test data and change their flow MILLIONS of times a SECOND.
Number Data Types
Computers are lazy, and take shortcuts in calculating to save time and energy, just like we do. But it's better to tell the computer what shortcuts to take instead of it guessing. So, for numbers, if you want it to add 2 + 2, you could use numbers like this: 2.0000000000 + 2.0000000000, but why? Tell the computer to ignore decimals if you won't need them. Or, for "strings" (words), if you wanted to make a sentence as "Mr. Dude " + "like pizza." you could tell the computer to put it in a box capable of holding 1000 letters, but why? That 1000 letter slot, or that number with ten decimals slot, needs a LOT of memory. Even if you only put 2 in it instead of 2.0123456789. It's also harder for the program to add those big slots.
Ending statements
End all statements with a semi colon, ;
OOP
Enter objects. Programmers seem to like to make this some magical impossible concept, but all you're doing is storing a chunk of code in some spot, so if you ever have to use it again, you can "point" your program back to it so you don't have to type it again. It also makes it easier to remember or figure out what's going on (like when a bug/glitch happens and you have to figure out what you meant a month ago when you typed some code. Peter.walk(north) is much easier than a bunch of random variables and numbers. This is also what encapsulation and modularity means. Once you figure something out and test it, don't ever do it again. Just point to it. Less work, less errors, less headaches.
Java Syntax
Every programming language is different. You have to use ITS OWN SYNTAX to not get glitches. Every Java program is nested inside at least one class and at least one function, called "main." Any Class or Function/Method is put inside of curly brackets { }. Any code line ends with a semi-colon " ; " Any string must be surrounded by quotes " " All variables must be given a specific data type and name. Arrays/collections by numbers are enclosed in square brackets [ ] You MUST use the operators talked about before, for comparisons, arithmetic, logic.
Binary Memory
Everything is based on binary, memory simply holds something in one of two positions, one stands for on, the other for off.
Gigabyte
GB - 1024 MB - Binary equivalent of a billion bytes. Two hours of HD video is roughly 5GB.
Comparison Operators
Greater than (>), Less than (<), Greater than or equal to (>=), Less than or equal to (<=), equal to (==). Just tests for numbers as to whether one is bigger, smaller, or equal to another number
Events
In essence, a program runs in a "main" loop that cycles forever (until you quit) several 1000 times per second. In each loop, it has several tests, "if (keyboard = pressed) then.....
Scope
In order to save memory, when a language compiles your code, it is trying to always recover as much memory as possible. It does this by releasing whatever saved "space" at whatever memory location (address) it made when you declared a variable. If you only need a variable for one function, and not the whole program, the compiler will add code to the machine code it's creating to tell your computer to both scoot over and make memory for a new variable you declared, and then to throw away that variable and "free" up that space for the next variable, when your function is completed. When you declare things, you can tell Java how long to let your thing "live" usually either "public/global" or "local"
Data
Information like words, numbers, True/False, collections, instructions, or references to other data.
I/O
Input/Output - The user/you/gamer INPUTs into the computer program, the program OUTPUTs back to them.
Exponentiate/exponents
Just a shortcut for writing repeated multiplications. So, 2^3 means multiply 2 by itself 3 times, 2 * 2 * 2 = 8.... 4^5 = 4 * 4 * 4 * 4 * 4 ( = 1024). .....also this is just an easier way to say (x *= x) * number..... x=2, x *= x is.... 2 * 2
Object
Just a variable for other variables. A storage place for variables, so a Person object has variables for numberLegs, numberArms, colorEyes, gender, etc. It typically also has several functions. This is just like a recipe. The ingredients are variables, the instructions are the functions. Within objects, variables are called properties and functions are called methods.
Kilobyte
KB - 1024 bytes. NOTE - even though it uses the prefix "kilo-" just like the metric system, because computers use binary instead of base-10 numbering (base-10 is what we use 0-9), computer scientists just picked the closest number to 1000 calculated from an exponent/power of 2. 2^10 = 1024. There are other words for an actual 1000 bytes, but I don't think anyone actually cares that much about it. At least on a personal level. The differences can be meaningful in massive business applications where wasted space is wasted money.
Input
Keyboard, touches, mouse movement/clicks, the scanner at the grocery store, sensors detecting a color, etc.
--
Like ++, but change the variable by one LESS. so if x is 5, then x-- == 4, then 3,2,1,0,-1,-2....
*=, /=
Like +=, but multiplying or dividing instead (((BTW, this creates a "geometric" pattern, where each next number is MULTIPLIED/DIVIDED by a number ///// versus the arithmetic pattern, where each next number is ADDED/SUBTRACTED"
-=
Like +=, but subtracting by a number instead
Upload Speed
Like download, but instead how fast the Internet can get a file FROM YOUR computer. It's generally much slower than download speeds, because down or up loads require "bandwidth" to the internet, and our computers are taking a lot more than it's giving, because we pretty much only give basic data like who we are and what we're doing and the rest of our privacy, and downloading videos and games from the Internet
Megabyte
MB - 1024 KB - The binary equivalent of a million bytes. A three minute song on Spotify is about 30-60 MB.
!=
NOT equal to, this is using the nomenclature from the logic operator !/Not, to the equals sign. Is 5 != 6? yes/true/correct. is 5 != 5? Nope, it IS equal to five. So, it's a wide test saying is this variable ANYTHING besides what your comparing it to?
Bit
One bit is one switch for either on or off. This is the smallest possible unit for memory or calculations.
Programming Syntax
Programming code is like math, you have to be EXTREMELY CAREFUL of what you type. ANY error AT ALL will crash the program or make it run incorrectly and cause you to have to endlessly read through thousands of lines of codes for HOURS trying to figure out the ONE FREAKING SEMI-COLON YOU FORGOT SOMEWHERE. Ahem. This is because all a programming language is is a set of commands and operations that a COMPILER (in Java's case, or an INTERPRETER for something like Javascript) turns into extremely basic binary commands that a computer can understand. The compiler/interpreter TRANSLATES our language into the computer's language. This is because humans like to use words and symbols, but since a computer is just a billion light switches, it can literally only understand either on or off (BTW, in reality, our brains are actually basically the same. We have neurons instead of transistors, but they are either on or off, and the combination of our billions of neurons being on or off is how we think and do stuff).
Collection Operations
Similar to Word operations, cutting, pasting, joining, or converting collections of data.
Word Operations
Smush two strings together (join/concatenate), use (+). You can also cut out the beginning, end, or middle of strings using String Object methods (functions/instructions).
Word Data Types
So the user can tell the program something using words, and the program can tell the user with words. Because no regular human wants to read "01101001 00100000 01101100 01101001 01101011 01100101 00100000 01100100 01101111 01100111 01110011" instead of "i like dogs"
Array collections closures
Surround array definitions with square brackets [ ]
Objects and Function Closures
Surround object, function, and class code with curly brackets { }
Terabyte
TB - 1024 GB - Binary for a trillion bytes.
Control Flow
The actual instructions for the program. A program is just a recipe. The ingredients are the variables, it's everything that will make the food, but by themselves they won't magically turn into bread. The instructions, preheat the oven, warm the water, mix the yeast, add sugar and flour, stretch the dough out, etc) is the Control Flow. But instructions by themselves are useless too. How hot should the oven be (byte number), how long should it bake (byte), what type of flour (string), how many cups of flour (byte).
Download Speed
The amount of data your computer can get off the internet per second. Nowadays MB/second is the norm, and GB/s is available though probably wasteful for most people because nothing is that big. Original modems were bytes/second and when I was a youngin it was KB/s, and yes it felt crappy and slow and painful even when it was brand new. You watched pictures load in lines, it look like 2 minutes to get a small picture. Downloading music that sounded like music literally took hours, and so we would download MIDI versions which is basically 8-bit versions of regular songs. Today we like that because it sounds cool or whatever, but back then it was desperation and sadness.
Exception/Event Handler
The code which both "listens" for events, and does something when it "hears" it.
Data Types
The different kinds of information. Important for coding because trying to change one type of data the wrong way will glitch out. E.g. "tree" / "cloud" = glitch; 2 * dictionary = glitch. So it also tells the computer what kind of operations you can do on it.
Order of math operations
The order you calculate an expression in, Parenthesis, Exponents, Multiply/Divide, Add/Subtract. Remember by saying, "Please Excuse My Dear Aunt Sally." All this means is if you have the expression, 1 * (2^2 + 3) - 2, you know how to break it down into easy chunks. First, find anything in parenthesis and do the rest of the operations there first. If there is something in parenthesis INSIDE of other parenthesis, do THOSE first. Once you find the smallest set of parenthesis, do E, M/D, and A/S there. So back to 1*(2^2+3)-2, do (2^2+3) first. Exponents are next, so 2^2, which is the same as 2*2, which is 4. Now, you have (4+3), which is 7. Now you go back up and have 1*(7)-2. There's no more parenthesis or exponents, so multiply/divide is next, so 1*7 which is 7. Now you have 7-2, which is 5. The answer is five. This is also nice because evidently you can absolutely BLOW people's minds on Facebook with this abiliity. As long as you notice that the second bunch of bananas is now FOUR instead of THREE in the first picture...... >:O
Data Operations
The things you can do to your data. give me minecraft mods.
Reference Data Types
These are just pointers to additional data stored somewhere else on the computer/Internet, like Objects.
Logic Data Types
These are used to control a program, and they use different operators than numbers do. They are called BOOLEANs.
Local Scope
Things only stay alive in the block they were made in, whatever that function or class that is. Make your variables as local as possible so they die and free up space as much as possible. The more memory your computer has, the better and faster it'll be.
Global Scope
Things stays alive, taking up space, for the ENTIRE program. If you make everything global/public, you'll quickly create a memory leak and break it.
Arithmetic Operations
Things to do to numbers. Math. Add(+), subtract (-), multiply *, divide(/), exponentiate(^), equal (=). Note - java requires you type the symbols as shown here (+ - * / = )
Function
This holds instructions. You define what variables it needs (parameters), what results it gives back (returns), and how it turns those parameters into those results.
=
This is NOT like what you learn in school. It is NOT a comparison or statement like in normal math. In Java, the = sign CHANGES variables. So, if x was 1, and then you type, "x = 3" you just CHANGED the variable x to 3. It is no longer 1. Furthermore, you can change the variable relative to itself, so if x is 1 again, instead of saying x = 2, you could say x = x + 1 instead, which tells the computer/Java to change x to whatever x was before plus one more, x = 1 + 1 = 2. If you do it again, now, x = 2 + 1 = 3, then 4,5,6,7....
++
This is a shortcut math operator that's the same as x = x + 1. This was made because incrementing (adding arithmetically) by one is VERY common in programming, particularly for "for" loops. This also a type of notation called "postfix."
For Loop
This is a shortcut method to make a specific type of do loop because it's so common. You tell your program to do a loop a SPECIFIC NUMBER of times, like, say ten times. SYNTAX - for (variable start point, escape condition for variable, action on variable so it gets closer to its escape) { your code}. E.g. for ( byte i = 0; i <= 10, i++ ) will do your code 11 times, starting at 0, and adding one (i++) each time until i is no longer <= 10. Note, since it started at 0, and goes until 11 (not 10) it'll run 11 times.
Class
This is a special kind of object, it's like a "parent" object, from which you can make several "children." So, if you only needed ONE person object, don't bother making a class, but if you are going to make TEN person objects, make a generic Person Class, which is kind of like a function to create objects, and then for each individual person object, you call the class function (called a constructor) passing the parameters (arguments when you're passing it TO a function), so cooper = Person("Cooper", "boy", 9);
Loops
This is just another tactic people invented to minimize the amount of code they have to type, and to make fixing bugs easier later. The main types are For Loops and Do Loops. Whenever you make a loop you must ALWAYS create an escape for the program, or it'll get stuck forever. E.g. Do { x++; } while (x > 0); if x started at 1, it'll only get bigger and will forever and always be greater than 0, so it'll keep adding up x until you break the program or it crashes because you took all the memory because x is now 17 google's big.
Do Loop
This is the most basic type of loop, that all others build on in some way. It says to do the code between the curly brackets { } while or until some condition is met. You could say do this code while x < 10, and add x each cycle until it reaches 10, or do this loop until something is true using boolean logic. A Do Loop will do the code inside at least once even if the condition to escape was already true. A variant is a "while" loop where it tests first, then does the code, so if the escape condition is already true, it won't run the code inside it ever. SYNTAX --- do { //your code; } while (condition);
Recursion
This refers to a special kind of function, a recursive function. This is a tricky one. A recursive function is a function that calls.... itself. This creates a "stack" of functions, in this case, the same function. So, recursiveX function() { for(i=0,i<5,i++){ recursiveX(); } } means that the function called recursiveX will go through a loop five times, and every time it will call itself, so on the first cycle, when i is still 0, it will call itself to start new, on a higher level in the line of things for the program to do, starting over. That new one will run until it's finished, then go back to the lower ordered function. This is a a bad example, because just like loops, you need to have limits and escapes to it so that the program doesn't get stuck doing the same thing FOREVER, or exponentially using more memory until the computer can't do anything else (memory leak), or it creates more functions on its stack (function queue) than the language allows (stack overflow). This can somehow result in certain programming actions be much easier for the computer.
! (NOT)
This tests if the opposite of the value or comparison would be TRUE, aka is it false? ...... when x = 3, !(x<1) would return true, because x is NOT less than 1 so it would be false, and !(NOT) is testing if it is in fact FALSE, and since it is, it tells you TRUE.
|| (OR)
This tests just needs to find a TRUE anywhere. So, if x is true OR y is true than the test is true, if (x || y) { true }
boolean
True or False. That's it. It's like this because computers are basically just a pair of eyes that can look at 1 billion light switches, and tell you which ones are on.
OOP, addl
Two major ideas here.... objects and functions
Object-Oriented Programming
When computers were first created, programs were simply long lines of code, over and over again. If you made a huge calculation at the beginning, and needed to do it again later, you would have had to write ALL of the code over again. Bummer.
Defining Things
When defining something (called declaring it) every object, class, variable, or collection must state what kind of obj/var/etc it is (integer, text, float, etc), and it must have a name.
Whole/Decimal Numbers
Whole numbers have NO decimal points, aka no fractions allowed! /// Decimal numbers allow, well, decimals. All the decimals. Which takes a lot more memory. Think about this, a whole number variable of 1 or 2 needs only hold two possible numbers. But a decimal variable of 1 or 2 includes ANY possible combination of decimals in between, 1.0001, 1.0002, 1.1763250178658732; they're can literally be infinite numbers between 1 and 2! poop disintery
Output
Words on the screen, a picture or change of a picture (you move the mouse left, and you look left in the game), a printer, sound, etc.
+ - * /
You know these from school already. Just of note, in Java, you MUST use * to multiply, and / to divide.
Number Data Types in Java
byte, short, int, long, float, double
double
decimal number // about fifteen decimal places (0.123456789012345) // 64-bit
float
decimal number // about six decimal places (0.123456) // 32-bit
==
equal to.... is this variable equal whatever you're comparing to? is 5 == 6? No... is 5 == 5? Yes! .......// in Java, if you want to know if two numbers/strings/booleans/objects are the same, you MUST use two equal signs ( == ), because just one equal sign ( = ) is a math operation which CHANGES the variable to whatever you want.
>
greater than. is 5 > 3? yes, is 5 > 6? No. is 5 > 5? ....nope.
>=
greather than or equal to..... is 5 >= 5? yep.
if then else example
if (cooperWants === burrito) { giveBurrito(); } else if (cooperWants === chicken) { giveChicken; } else { giveSushi; }
<=
less than or equal to, to the rescue! a modified test, said to be inclusive, is number1 < number2 or the same as it? is 3 <= 3? yes, yes it is.
<
less than, is 3 < 5? yes. is 3 < 2? No. is 3 < 3? No, actually, it's equal to.
if (condition)
the condtion can either be true or false. You use logic and comparison operators to test. When x = 1 and y = 10, you can test if x is bigger than y: if (x < y).....
char
variable to hold a SINGLE letter, like 'c' or 'd'
string
variable to hold a collection of characters, like "cat" or "dog" or "I like dogs. Don't you?"
else
when the if (condition) is False, the program will SKIP the then/true code, and do this code instead. Likewise, if (condition) is true, the program will do the then code and SKIP the else code. Unlike then, in java, you DO type Else..... if (condition) { code for true } else { code for false }
then
when the if (condition) is true, the program will do the code you put there, and ONLY if it's true. if it's false, it will SKIP that code. Thus, you enable the program to change what it does while it is running. In java, you do NOT type THEN, you open a curly bracket pair after if (condition) and put the code there. aka if (condition) { do this }
byte
whole number // -127 to 128 // 8-bit memory slot
int
whole number // -2^31 to 2^31 - 1 // 32-bit memory slot
long
whole number // -2^63 to 2^63 - 1 // 64-bit memory slot
short
whole number //-32,768 to 32,767 // 16-bit memory slot
else if
you can string together several if tests in a row, using else if. This is called NESTING. So, if (condition) is false, it will skip the first { } and do ANOTHER test, if that test === true, than it will do THAT code, otherwise it'll do the else code, or another else if test, or simply move on if that's it. So, if (condition) { do if true } else if (condition) { do if now true } else if { ok do if this is true } else { if nothing else just do this }