Hello Everyone, I have been programming for quite a while. I apologize if my English isn’t that great, but my native languages are Spanish and Português.
I have studied programming and languages for a very long time, but I still have some doubts.
I basically understand if not everything a lot, but I struggle to put those ideas into play.
First I want to walk you down my thought process,
IF AT ANY TIME YOU BELIEVE I AM WRONG OR WHAT I AM SAYING MAKES NO SENSE, PLEASE BY ALL MEANS CORRECT ME.
Programming is easy in theory.
It’s just four basic mathematical calculations done to values. They are addition, subtraction, multiplication, and division. Division is subtraction in series and multiplication is addition in series.
To the computer everything is a number.
Everything is binary. In fact, text, strings, etc. are all composed of binary numbers. If there is not a numeric value associated to something such as an offset, variable, memory direction, value, etc. which the computer can use to make a decision, it is basically worthless, as even strings have their values such as length, comparing characters which understood by the computer to be binary digits.
Memory is examined in bits by powers of 4 as it equals either 4 binary values such as 0011 or just one hexadecimal values which would be something such as:
- 2 bits
- 4 bits(one hex value)
- 8 bits(a byte/2 hex values)12
- 16(2 bytes/4 hex values such as 0xFFFF = 111111111111111)
- 32(4 bytes or 8 hex values 0xFFFFFFFF = 11111111111111111111111111111111)
Variables are just houses with directions for data.
A function uses there houses to implement one of the four fundamental operations**(+,-,*,/)** on each other to produce something or alter.
A class, Object, and Instance are just a group of variables (values subjected to change) with specialized processes (processes which are used to alter or produce a value from others or through itself) which are fused together by an individual provided they have a basic logical connection. This logical connection is determined by the user. For example, even if it is bad practice I can technically have an A object and B object work together and share a variable or process which is concerned with something. Both do it in a different way (I understand Polymorphism and related subjects of operator overloading) but because in essence, following this simple map:
instance (unrelated object) -> object (implementation of a class) -> class (grouped variables and functions) -> function (grouped variables with rules) -> variables (values with names) -> value (calculative number)
anything can really be logically paired because everything can share a numeric value with something else.
Object, Instance, Function, and Variable names have no real or subjective importance to the machine. This is just so that the programmer has an easier time understanding everything. A variable named a, thisvariable, complexAndLongVariable, x, hg, cool, etc. are all the same to a computer, it is just a location, when I analyze code I disregard it. In a sense the value is more important because it’s what is being calculated, no?
Data structures come in two distinct flavors, either solo or paired. Since as proven above everything is a number which is a value that can be calculated or operated on, a “data structure” only holds this through a proxy such as a memory direction or to us, its variable name, which is why the names are inherently unimportant. These are solo data structures such as
x = 1
y = 2
z = x + y
They only hold a single value.
Paired is the same thing to a computer, but to us it seems as if they are connected or grouped together such as in a hash, array, string, tree, etc.
a = [1,2,3,4,5,6,7]
These values are all under the “umbrella” named a, but they exist independently and can be altered by either making a new array with an altered value, or by changing the value directly (depends on the programming language).
After considering my form of thinking, then how can I apply this theory to better develop and create something in practice?
I always think out my code in a pseudocode fashion, but it seems that I struggle doing this. I practice daily too.
I mean, I think the naming of certain variables or functions make it confusing because they abstract the underlying processes which make it difficult for you to understand.
Let me show you, my dear viewer, a concrete example of what I mean when I struggle.
squaredbit = (u64) ((((u64) ~0LL) >> 1) & ~(((u64) ~0LL) >> 2));
This is one example from the link above.
I understand you are storing a value, but what the hell do all of those parenthesis do? I understand it is to separate the code, and in fact it looks as if the values which are identifiable are being NOT operated, shifted 1 or 2 bits to the right individually and ANDed together.
I guess I just don’t understand the logic behind doing this?
u16 spicnt = T1ReadWord(MMU.MMU_MEM[ARMCPU_ARM7][(REG_SPICNT >> 20) & 0xff], REG_SPICNT & 0
This is another thing, so the output of a function named T1ReadWord is stored as a number which has other variables being calculated either by shifting 20, ANDing 11111111, etc.
Pretty much if anything is looked at for long enough, it is just putting a value in a memory and calculating off of it and further expanding on that single variable, am I wrong to think this is what programming is?
A = 1
B = A * 2
C = A * B + A
D = C + B + A + A
E = D + B + B + A +D * C
F = D * A * B * E * C * A
on… and on… and on… till it becomes something like this…
Z = A + 1 * (B/C) + G (J ~ S) S * T
- V + K * Q
I believe that predefined functions are also things I struggle with because I might to understand something, fundamentally as another person. To understand terms such as Heap and Stack or even Array in English was a nightmare. I still refer to it by their names in my native language. Could language be a factor in this?
Could syntax or grammar be the issue?
Has anyone else faced a problem like mine before?
Theoretically, I am really good at this, but practically I am useless because of something I have yet to understand.
Thank you, please link me anything you may have to assist me in my endeavors.