This post is made in the hopes that some answers might be found for the following questions related to variables as a concept and in practice. This is by no means an exhaustive list of questions, but hopefully they generate discussion. A number of these questions may come across as pedantic, especially given the “black box” methodology where we don’t need to know how things work. Others might display a lack of fundamental understandings. By no means to I expect any one person to have all of these answers (although if you do, nice!), but I would encourage anyone willing to approach them to do so with the goal in mind of promoting and rewarding curiosity for new learners by entertaining the questions, even if they seem foolish, for those who want to know.
According to Techopedia.com, “[v]ariables generally have four attributes: an identifier, data location, type and value.” How might one define each of these four attributes, and why does it matter that variables possess these attributes?
Variables stand in place of data, but “data” itself is a somewhat vague term, so what can “data” be? In other words, what sort of data is any given variable able to hold, and what is it unable to hold?
For example, it might seem obvious that the variable ‘x’ could be assigned to something like an integer value of 5, but could ‘x’ hold more than numeric values?
Could we say things like:
x = “Hey, Bob”, where x is meant to hold characters (or possibly alphanumeric values)
x = draw(), where ‘x’ is meant to hold an entire function (or possibly a function’s value)
x= Bird, where ‘x’ is meant to hold the class ‘Bird’ (or possibly the value of a class)
and so on?
If so, how and when might it become useful to use variables to hold different types of data?
- Is there a limit to the amount of things that a variable can be assigned to? If it is possible to assign more than one thing to the same variable, when might it be appropriate to do so?
By extension, is there a limit to how much memory space a variable can take up once something is assigned to it? If possible, what might make a variable take up more space?
The idea of “built-in variables” is one that comes up almost immediately when learning in Processing, and it might be similar in other languages. What exactly is the difference between “built-in” variables and regular variables? Is it possible for a user to build their own variables into Processing, and if so, how and when might it be useful to do so?
Knowing that variables can exist as “built-in” features of a programming language, can variables also exist in other ways? One might come across terms like “local variable,” “global variable,” and so on, which seems to suggest that variables can have different types/states/ways-of-existing, so what might those be? What do these different sorts of variables mean in the broader context of programming?