MagallanoX Ответов: 2

Теория и практика программирования


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:

 1. 2 bits 
 2. 4 bits(one hex value)  
 3. 8 bits(a byte/2 hex values)12 
 4. 16(2 bytes/4 hex values such as 0xFFFF = 111111111111111) 
 5. 20 
 6. 24 
 7. 28 
 8. 32(4 bytes or 8 hex values 0xFFFFFFFF = 11111111111111111111111111111111)
 9. 36

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**
etc.
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.
Link:
 <https://github.com/TASVideos/desmume/blob/master/desmume/src/MMU.cpp>

    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?
For example:

 1. A = 1 
 2. B = A * 2 
 3. C = A * B + A 
 4. D = C + B + A + A 
 5. E = D + B + B + A +D * C 
 6. F = D * A * B * E * C * A 
 7. on.. and on... and on... till it becomes something like this... 
 8. 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 endeavours.


Что я уже пробовал:

Пожалуйста, помогите мне.
Спасибо.
Я пытался читать все виды книг, но я борюсь.

0x01AA

Прежде всего, забудьте, что "все двоично". Это "только" путь истории. Схемы, разработанные в начале с 0 вольтами для двоичного 0 и 5 вольтами для одного (основание 2).
Но может быть также система, которая работает с-5 вольт, 0 вольт и 5 Вольт, и она закончится в системе, основанной на 3.

Есть еще столько всего, о чем стоит упомянуть. Мне нравятся твои мысли ;)

KarstenK

Компьютер-это машина, которая имеет дело с 1 и 0 как "включено" и "выключено". Каждое высшее абстрагирование-это модель человека. Читайте о "гастрольной машине". Мы, люди, используем языки программирования, чтобы сказать компьютеру, что он должен делать. Он начинается с "Добавить 1 к 1 и распечатать это число" ;-)

2 Ответов

Рейтинг:
0

OriginalGriff

К сожалению, это неправильный тип форума для этого: он сводится к полной работе наставника, и мы действительно не настроены на это вообще, и у большинства из нас нет времени.


0x01AA

А 5. Мне нравится этот вопрос.

Рейтинг:
0

Greg Utas

Цитата:
Имена объектов, экземпляров, функций и переменных не имеют реального или субъективного значения для машины. Это делается только для того, чтобы программисту было легче все понять.
Верно, но это не уникально для компьютеров. Это просто создание более высоких уровней абстракции, чтобы люди, знакомые с предметной областью (музыка, теннис, экономика...), могли вести эффективные дискуссии.

Цитата:
Чтобы понять такие термины, как куча и стек или даже массив на английском языке был кошмар. Я до сих пор называю его их именами на своем родном языке. Может ли язык быть фактором в этом?
Думаю, ты прав. Если бы я столкнулся с этими терминами на языке, в котором я недостаточно свободно владею, я думаю, что отреагировал бы точно так же.

И я думаю, что ваш английский довольно хорош!