Quotes from the Chief Engineer and I

(warning: the following story is about matrices.)

Today in AP Computer Science my teacher was lecturing us about how when creating a matrix, for example Matrix[3][3], the first set of brackets is rows and the second is columns. While this is usually convention, it is not actually how a matrix will work as the way we draw arrays, like the one above:
[0,0][0,1][0,2]
[1,0][1,1][1,2]
[2,0][2,1][2,2]
Is just a way for us to visualize, and not how they are actually created in the computer, as my teacher so believes. That is why I could draw the above like this:
[0,0][1,0][2,0][0,1][1,1][2,1][0,2][1,2][2,2]
or even this:
[0,0][0,1][0,2]
/////////////////[1,0][1,1][1,2]
//////////////////////////////////[2,0][2,1][2,2]
or even if I so choose I could draw it like this:
[0,0][1,0][2,2]
[0,1][1,1][2,1]
[0,2][1,2][2,2]
After a heated debate with my teacher over whether or not a computer actually builds out an array in the ordered fashion like this:
[0,0][0,1][0,2]
[1,0][1,1][1,2]
[2,0][2,1][2,2]
We decided to just dropped it. But now to the point of the post. My Chief Engineer and I were discussing the above designs and how all of them will work because you’re drawing an imaginary things and it doesn’t matter if you draw the cells as gummi bears it will work when I turn to him and say **“People don’t care about convention so long as you comment it enough!” (-Lord Supreme Programmer Isaac and Chief Enginerr Robert, 2/25/15)
**So if there is a lesson to be learned it is comment your code, kids. Even though good code should speak for itself.

How members of an array are stored and accessed is a function of the programming language. It is not something one should worry or argue about since the language will reference and de-reference everything for you. “Row” and “Column” mean nothing to the compiler. Notation has nothing to do with the physical location since memory is laid out so one accesses word-sized elements in sequence. In C and C++ matrices and arrays are really done with pointer arithmetic - google it.

That is exactly what we said! We were trying to convince our teacher that you don’t actually store these numbers in little ordered cells! We could say that when you create a Matrix]] the first brackets are potatoes and the second are tomatoes and it would still work. It really frustrates me that my so called AP Computer Science teacher hasn’t taught this since haskell, had to learn Java over the summer (he pronounces it as Jaiva, it can get irritating), and said, and I quote, “Java is the most popular programming language because three billion devices sounds like a lot”. He just makes me want to smash my head into a wall. At least he got us 4 megabyte jumpdrives!

It sounds like your teacher is a bit behind the times…

Don’t worry, they will actually hold a surprising amount of documents. For just some simple Java programs they would work pretty well, but thankfully they were 4gb.

I think you mean “Pascal”. And C/C++ (counted together) is far and away the most popular programming language.

Paskell sounds like an odd mix of Pascal and Haskell. That could be interesting…

Sorry, typo. I meant Haskell. Only other language he knows. And the quote about Java was from him, probably one of the funniest things he’s said as it reminded me of the quote from the Java install.

That would be weird. Have you ever used Chicken or LOLCODE? They look really ridiculous.

Wait. They still make them that size?!? Seriously, google doesn’t show up when I search that size.

I remember winning a 64mb drive in college for a CAD competition about 9 years ago. THAT was a big deal.

Well here was the order of events:

  1. He asks if they still make firesticks
  2. I explain to the class what a firestick is
  3. He asks if they would be useful or if we would prefer storing them in the “Lightning Cloud”
  4. He says that we will buy 4mb firesticks from Circuit City.
  5. He shows up with 4gb jumpdrives he bought for $25 a piece. 25 dollars. Where did he find them so expensive???
  6. We explain to my teacher how a gigabyte and megabyte are different.

When I was in school, I got a free 32mb with a $1500 dell laptop, score!

OP, it’s crazy how quickly people can fall behind the times without even knowing it. Pick your battles in this kind of situation as some will never be won with either knowledge or wisdom. Might as well offer a coffee and talk about the weather instead.

I remember buying a 128 MB drive. This was about when they finally became “good”, and it was on sale for the same price as a 64 MB version (at least $20).

It’s not like he is behind the times, he has a MacBook Air and a nice desktop for class, but the old desktop plugged into the archaic projector is just hilarious. I don’t know what the plug is called, but it is larger than a VGA! God, it looks ridiculous!

Sometimes, the older technology JUST WORKS. And that is what is important in the long run. And it wasn’t too long ago that FRC used 37-pin ports (like, last year–and there’s still the MXP).

I believe you were looking at some form of serial or parallel port. Probably a many-pin one. VGA, if I’m not mistaken, is another form of serial port. You use serial ports on a near-daily basis if I’m not mistaken–on the Universal Serial Bus (USB).

(Incidentally, I had to boot up a Windows 2000 computer last night. Why, you ask? Because it can run program X. Program X serves a key function in this application. Old technology? Yep. Does it JUST WORK? Yep, unless someone turns it off…)

True.

It is not something one should worry or argue about…

Unless you’re trying to write efficient linear algebra algorithms. Then you better know whether your language is row major or column major.

I would disagree that you shouldn’t care about how elements of a multidimensional array are stored. Knowledge of the underlying structure in physical memory can make a significant difference in performance of code.

Say you have a matrix that you are representing as a 2D array:
|a b c |
|d e f |
|g h i |

C/C++ structures this in row-major order. This means that the elements are physically arranged sequentially in memory in this order:

a, b, c, d, e, f, g, h, i

Fortran structures this in column-major order. Physically, they are represented as:

a, d, g, b, e, h, c, f, i

Each element is at a particular “address” in memory, which is usually expressed as a hexadecimal number. The elements of the array will be stored sequentially. This means that if element ‘a’ is stored at 0x1AFF3114, then (in C/C++) element ‘b’ will be stored at 0x1AFF3115, ‘c’ at 0x1AFF3116, and so on. In Fortran, ‘d’ would be at 0x1AFF3115, ‘g’ at 0x1AFF3116, ‘b’ at ‘0x1AFF3117’ and so on.

Why does this matter? It is much faster to access elements sequentially than nonsequentially for most physical storage media, sometimes even orders of magnitudes faster. It won’t make much of a difference for simple problems with 3x3 or other small matrices, but when dealing with very large matrices with thousands or even millions of elements (which appear in many real engineering problems, for example, the matrices created by FEA software-) it becomes very important.

As a result, it is useful to know what order your programming language lays out its multidimensional arrays in memory, and to write your algorithms to access them in sequential order when possible.

There’s absolutely nothing wrong with the old tech. I have a computer in the basement that runs Windows ME. Does it function correctly? No. Does it turn on and do funny things? Oh absolutely.
The other day I had to go find an IEEE-1200 to preferably USB or VGA or anything that would work with an old printer. Just imagine the look on the guy at RadioShack’s face when I asked for one. He asked me what VGA was!

We were arguing over whether or not the computer stores them right next to each other in the matrix like I laid it out. The question on the quiz he gave was “True or false: The first set of brackets in a two dimensional array are columns, the second two are rows” and he put the answer as false. But that isn’t really true, even if it is “convention” as he says. Which is why my Chief Engineer Rob Bob the Corncob and I said “no one cares about convention if you comment it enough” because if you comment it out the wazoo they’ll know what you mean!

If you have to comment your code out the wazoo, because you are breaking the conventions, you might be doing something wrong…