r/processing • u/idkkwhattousername • May 07 '21
Please explain it like Im five
Ive spent two months watching and rewatching my lecture slides for this stupid coding class, and nothing makes sense. What the hell is a variable?? What do arrays do?? What is an interval??
So please can someone explain this hell like Im 5 because Im this close to dropping out due to stress and just taking an automatic fail
10
u/javiermdvc May 07 '21
I would say watch Daniel Shiffman, he is a great teacher and has plenty of videos on YT. There is great fun in programming (specially in programs like Processing) if you find a project that motivates you! Push through the learning curve and you may love it :)
2
u/MiloCowell May 07 '21
Its ok. Stay calm and find some Youtube playlist on programming basics. You'll pick it up
2
u/Wootai May 07 '21
Variables: Variables are a way of storing data that your code uses in more 'english friendly' format. If perhaps you had a number in your code that represented the age of a person you would create a Variable named "age" and assign it a number, like 18. So later in your code if you need to know, or use the age in you can instead of writing the number each time, refer back to the variable named age that the number is assigned to.
Variables are also 'mutable', meaning they can be assigned values, and those values can change. Because of this property, they are often used in 'loops'. In loops, a variable will be used to count the number of times a loop has been executed and checked before exiting.
Arrays: Arrays are a kind of variable that are also ways of storing multiple pieces of data in a list-like structure ("lists" are a different data type in some languages, python for example, so to avoid confusion down the line, we will refer to these as 'list-like') As a list-like structure, an array stores data in a particular order, and each item in that list-like structure can be accessed by checking the index of the array. So, an array may contain a list of numbers like [2, 4, 9, 16, 52, 47, 12]. To access the data in the array, you use [] with the index of the data you want, starting from 0. In the example Array[0] gets the value "2" and Array[4] gets "52".
Interval: Not sure what this is in the context of your class, but best guess is an interval is one cycle through a loop. Each time a loop is executed in your code it performs its task as one interval, then goes back to the beginning and does it again. If you had a simple loop like:
for(int interval = 0; interval < 10, interval++){
println(interval+1);
} Each interval is one execution through the loop. The loop will print a number to the console, then add 1 to the interval and start over, printing the next number.
1
u/thudly May 07 '21
This series by Kevin Drumm is good too. It's not Java code, but the visual aids he uses are helpful for learning the basics of programming in general.
https://www.youtube.com/watch?v=N7nw2jjnCnQ&list=PLTd6ceoshpremSFQxYM4L0p4Q6hR-4e4J&index=3
1
u/algoritmarte May 07 '21 edited May 07 '21
Variable: you can think it like a "drawer" with a "label" (the name of the variable). The value of a variable is the content of the drawer (for simplicity a certain number of balls).
Suppose that you have an infinite amount of balls available to put in the drawers. The assignment instruction:
A = 5
==> is equivalent to: put five balls into the drawer A
A = A + 3
==> is equivalent to put 3 more balls into drawer A (which will contain at the end 8 balls)
B = A + 2
==> no matter how many balls are already in drawer B; put in drawer B exactly the number of balls contained in drawer A plus 2 more balls; at the end drawer B will contain 10 balls; drawer A will still contain 8 balls (the instruction does not alter the number of balls of drawer A)
A = B
==> no matter how many balls are already in drawer A (actually 8 balls); put in drawer A exactly the number of balls contained in drawer B; at the end both A and B will contain 10 balls.
Let me know if this help ... and I'll try to explain "Arrays" :-)
22
u/AColdFloor May 07 '21
https://www.youtube.com/watch?v=2VLaIr5Ckbs&list=PLzJbM9-DyOZyMZzVda3HaWviHqfPiYN7e
No single reddit reply is going to help you, watch these videos, get stuck in, make some demo projects.