Code is always data, this is true, but data is not always code....
Top tries to use the fact that code is data and data can be code to say the distinction is meaningless and useless. That's the flaw in his argument. Even if code and data are the same thing, it's still useful to distinguish between the two.
See DataEqualsCodeDependsOnContext
Question: Is DNA data or code?
MuAnswer. DNA is a chemical. Data and code are imaginary abstractions.
while(print((A,T,G,C)[rand 4])){}// how to make a human :-)
This debate hits LaynesLaw so fast it's silly.
Well, definition is indeed a part of it, but viewing code as data can change one's perspective on how software is or can be designed. If you focus on the data part, then you will see more opportunities for DeclarativeProgramming. To a compiler/interpreter a program is just data. The C/I converts programming code into internal data structures, usually a bunch of lists, sets, stacks, or maps with pointers to each other. Your code is essentially a data structure in the end. This may at first seem irrelevant, but it is not. Think of a code-centric GUI API/framework versus a declarative one. Under the declarative GUI system, an interpreter-like engine (AKA "browser", "windowing system") "runs" the declarations in a manner not that much different than an interpreter running programming code. The original declarative GUI layout may be specified as code, such as XML, or via an IDE that builds a hidden structure, similar to VB's approach.
Since ObjectsAreDictionaries (maps), or at least can be viewed as maps, an OOP program is essentially a little (non-relational) database. Whether it "is" a data structure or can be viewed as a data-structure, but also viewed as code is not that important. The important thing is that they are interchangeable viewpoints. Which form you "see" it as is a mental preference issue. In practice I would often rather use relational structures than a web of maps. Thus, the two somewhat orthogonal open questions are which view is preferred (code or data structures), and what type of data structuring discipline to use (relational or navigational). Maybe data and code are not "the same thing", but rather interchangeable. Although interchangeable can perhaps mean they are the same thing. But the important thing is that we agree they are interchangeable viewpoints for essentially the same information.
Our difference really seems to be that I prefer a data-centric view for a much higher percentage of a given project than you do, and I prefer a relational setting for the data-represented info over a navigational one. The debate is not really about what is or what is not, but what we prefer. Agreed? Once we agree on that, then we can go to the next step of fighting over which is better :-) -- top
I concede. Data and code are the same thing. In the interest of Once and only once, we should eliminate one or the other. I suggest we eliminate all data; it is the same as the code and therefore superfluous. Now that we are agreed, there is no point to further discussion of data; it is the same as code so we just don't need it.
Assuming you are serious, my point is that as humans sometimes we prefer a data-centric viewpoint and sometimes a code-centric viewpoint. There is no single viewpoint that makes every person happy for every situation. I suppose we could randomly select a "prototype" human and kill off everyone else with a different preference in order to satisfy OnceAndOnlyOnce, but Hitler Oriented Programming has fallen out of style.
What is there to prefer? We have declared them the same. We are comparing apples to apples, brand X to brand X. Code is data is data is code.
Then I do not understand "we should eliminate one or the other". You cannot eliminate one without killing the other if they are equivalent. Perhaps you meant eliminating the viewpoint of one or the other?
There are not two viewpoints to discuss. The terms are identical so there is no point reason to use both terms. If the term "data" is important, then let's eliminate the term code.
Just because somethings are identical does not mean they cannot have different names for different forms. If data is printed out in a columnar format, we call it "a report". If it is copied in it's native format onto another disk, we call it a "binary dump".
If code and data are identical, what reason is there to use different names? What is the basis to determine which name is to be used?
I think the biggest distinction is that how data is presented is mallable, while code is pretty static. One does not "re-sort" code expressions in a code viewer, for example. But filtering or sorting a dictionary array or table to look at it differently is common-place. Code is sort of "stuck in space" the way it was created.
One does not "re-sort" data expressions in a word processor, either. Filtering or sorting code in an IDE is common place. What characteristics identify data that is mallable versus data that is "pretty static"?
If your IDE is parsing code and shifting it around, then you are essentially converting code to data, processing it, and then converting it back to code. I suppose this introduces another possible distinction: You generally don't "parse" data, at least not as heavily. The more complex the parsing needed, the more code-centric it probably is.
However, we agreed code and data are identical, so what does it mean to convert "code" to "data" and vice-versa? How can one tell the difference between data mode and code mode?
There are conventions we tend to call "data" and conventions we tend to call "code". We could instead say, 'convert from format X to format Y because I want to see/use it in format Y for various reasons.' It's a communications shorthand that may not necessarily have rigor. A UsefulLie if you will.