Back to the Basics
A lot of problems comes from a confused mind, polluted with unnecessary concepts, memorized sayings and long words.
To understand how to program we must understand (to some extent) the basics of how the mind works.
The good idea will be to understand how the mind evolve. We can assume that a development of a child mimics the development of a whole spices (which is, unfortunately, not true).
Presumably at first there were some mental constructs - inner representation of a distinct chunk of sensory input. We have seen something, and we could distinguish it from the rest of the input. Then it gets a name. It is not a word, it is a sound. This is a Tom. (and much much later, if ever - it is a cat).
Tom is not a word - there is no language yet, no visual representation of compound sounds (words). It is just a sound - a chunk of an audio sensory input, associated (linked) with a chunk of a visual sensory input. This (is) Tom.
There is no distinct objects yet: a child cannot grasp that this particular chunk of video sensory input is some distinct, unique entity, separated from the rest of the world, leave alone all those famous classifications - animal - cat - Tom) but there are already an associations (between chunks of visual and audio perceptions.
All I'm trying to say is that associations (references) comes before symbols. And they are so natural to us, that everything was build on top of them.
Pointers, not classes is the most natural concept to us.
It is good to understand that our raw sensory input (from all channels) first gets transformed into some inner representation, encoded and stored into a short-term memory (a buffer) and only then becomes available to, say, high level brain circuitry. Now it could be processed - tagged and indexed.
This is, of course, very rough and primitive model, but what we want to grasp is a common patterns, not the details of underlying machinery, which are irrelevant and infinitely complex.
Now lets say that, at the very basic level, a name is a sound associated (linked) with a mental representation (a picture).
This is before any language! Sounds are not words yet. They are just sounds. Our ancestors (and our children) first has associated sounds, but no formal language. Animals still have no language, but, of course, they have audio-video sensory input associations.
They probably have linked lists - chains of associations.
Much later a name will become a symbol, associated with a sound and with several corresponding mental picture. Some intermediate representation. This is how the brain become 're-wired' with a natural language acquisition.
Lets say we grow our own inner dictionaries (hash-tables) between symbols and its meaning.
These symbols will be represented by words - the building blocks of a natural language.
Associations, references, links are the very essence of our minds, a language is a most recent innovation.)
(Lisp is the most natural programming language, built out of the most essential and natural concepts. Scheme is the harmonized, balanced Lisp.)
There are few very basic concepts:
- A symbol is a compound sound associated with a mental object.
- A name is a word for a symbol.
- A word is a natural language representation.
- A reference is an anonymous, direct association to an object.
These are basic building blocks of our mind and of Lisp. From these anything else could be build, including all those categories, classes, object, etc.
We have symbols and pointers, thus we have naming and referencing.
Why all this?
When we need to to find out what an unknown word means we use dictionary.
To use a name we need to perform a look-up to get its meaning. We need the meaning itself, not its label.
Accessing objects by name is a process of interpreting symbols.
Accessing objects directly, bypassing symbol lookups, is compilation.
In a computer everything is a number.
- A pointer is an anonymous number, an offset, an address.
- A symbol is a tag, an index, a name of a pointer.
- A representation of a symbol is another number.
- In a computer everything is a number.
3 is a symbol, associated with our mental representation of a concept of number 3 and computer in-memory representation of it, which is binary 10.
Programming is a process of manipulating symbols and pointers - indirect and direct references.
We need pointers, they are the most essential thing, we cannot throw them away. All the ugliness, messiness and confusion of Java and the likes comes from that very wrong decision to forget about pointers. This is ignorance, this is the cause of suffering.)
Programming has nothing to do with Virtual Machines or Classes or Methods or Design Patterns. Some management has. Programming has everything to do with symbolic manipulations. Engineering is all about references (pointers).
There is a programming language called Scheme, which should be studied first, to get the proper understanding of what is programming (Deep inside in Scheme almost everything is a pointers. This is why it is so natural).
After mastering those great languages all that other programming stuff is of no difficulty.