N
nroberts
Not red herrings, a real observation about idioms in different languages.
Well, that we agree on. It seems you were uninterested in reading the
explanation.
Okay, let's start from the top.
Imagine that there IS only one programming language, ever: C. And ask
the question:
I want to represent a number of items, each of which has several
traits. Should I represent these as an array of structures, or
as several arrays (possibly stored in a higher level structure)?
It seems pretty clear to me that, in C, the answer is nearly always the
former. In cases where there's an overwhelmingly strong reason to do it
the other way, such as working on a vector processor where it is *VITAL*
that all x be in one block of contiguous memory, and all y in another
block of contiguous memory, it's a lot of work and very easy to get it
wrong.
That constitutes a clear bias towards one way of approaching things.
Now what if there were other languages? Imagine, if you will, a language
in which the native data structure is a 2D array, in which both rows and
columns are primary objects which can be manipulated easily.
What type are the columns? If "any" then how does this language store
arbitrary length strings in this matrix? "It just does," is not an
answer since the very fallacy of what you're claiming is right here in
this detail.
In a language
like this, you might find that the degree of bias towards viewing things
one way rather than another was weaker. It might even be so weak that
it wasn't really obvious that doing things one way rather than the other
created a distinction you could perceive in code.
What happens when we want to work in 3d? Should I keep an array of
these things or one of these things full of arrays? Do you really
mean to assert that the answer to this question is not, "It depends on
what you want to represent and how you want to manipulate it?" If
not, then you've not proven your case.
If you'd read even the most recent posts here you'd be aware of this
issue already.
Think of, say, C's way of looking at arrays, where clearly each row is
an object, but each column is not an object. Now contrast this with, say,
the scripting language for a spreadsheet program, in which "column A"
and "row 1" are both primary objects.
Basically you are proposing a matrix in which you can access any value
in it based on any ordering of the keys. OK. This is a new
abstraction that has nothing to do with arrays or structures and it is
going to be useful for its own distinct cases that are not entirely
congruent, though there is some overlap, with those of structures and
arrays. For one thing, all the contents must be of the exact same
type or we're talking about some sort of fantasy language that works
via. fairy dust or something.
As I said before, it is absurd to talk about a "bias in C toward
arrays of structures" by stipulating some foreign abstraction that
works differently, is useful for different problems, etc...
Would it make sense to you if I asserted that C has a bias toward
using arrays by pointing out the existence of linked lists and binary
trees? What if I show you iterators from C++ that let you treat them
as the same, something that's much more difficult in C?
Would it make sense to you if I asserted that C has a bias toward
arrays by pointing out that one could think up a language in which
everything was a variable and no complex data types existed?
Would it make sense to you if I asserted that C has a bias toward
array based formula calculations by asserting the existence of
"language X" in which I could assign an arbitrary formula to variable
f, and then simply use it's inversion by calling f' when in C the
easiest method is probably to calculate slices and then do a search?
Essentially that's what your argument boils down to.
How about if I assert that C has a bias toward named variables if I
assert a language in which calling "rand()" and dereferencing it will
get me the value I'm trying to get, no matter what it is, every time?
Assuming you say 'no' to those, and I don't see how you can't, why
does it make sense to you then to assert that C has a bias toward
arrays of structures by stipulating the hypothetical existence of a
matrix structure that works via some unspecified, mysterious logic??
This matrix also does nothing to respond when there really is a
logical hierarchy to the data being described, as has been stipulated
in every example and argument in the conversation to date. Even when
a special "language" was created in which one could gain access to
individual data fields in our blob we ended up with an interface in
which our entities' individual features were grouped together in a
single chunk representing an entire entity rather than visa-versa.
Even though we could access items through a syntax that didn't care if
the underlying data type was completely backward or even spread
randomly through memory, the logical grouping was static, concrete,
and obvious.
So I put it to you that:
1. It is entirely meaningful to talk about C having a bias towards one
way of doing things rather than another, without any need to refer to
other languages or tools.
Great assertion, now show it.
2. C in fact has a bias towards arrays of structures, rather than
structures of arrays, just as it has a bias towards arrays of rows
rather than arrays of columns.
Great assertion. You've done even LESS to show this. In fact, you're
introducing entirely new, unsupported assertions here.
3. Other languages do not always have as strong a bias.
Name one.