On 17/01/2013 12:30, Jeff Nowakowski wrote:
On 01/15/2013 08:29 PM, H. S. Teoh wrote:

It's paradoxical that a 1D (i.e. linear) representation is more useful
for capturing the complexity of programming as opposed to, say, a 2D
graphical representation

Typical code is 2d because of line-oriented statements and indented
block structure. Reading a truly linear file of code in 1d would be
quite a nightmare.

It depends on how you look at it.

Mathematically, a curve is considered a one-dimensional object, regardless of whether the space in which it is embedded has two, three or more dimensions. (I'm ignoring fractals here for simplicity.) If you consider the shape of the indented block structure to be a curve, then it's still one-dimensional in this respect.

And in most languages, a program/module is essentially just a sequence of tokens, and as such is one-dimensional. We might look at it in a two-dimensional form, but this two-dimensional layout means nothing as far as the program structure and semantics are concerned. And again, you could think of it as a curve, passing from the beginning of each line to the end and then to the beginning of the next line.

OTOH, because we tend to view code in a two-dimensional form, and even rely on line breaks and block indentation to make code readable, I can understand people thinking of code as 2D.

And there are languages in which the code structure is inherently two-dimensional, e.g. Befunge.

Stewart.

Reply via email to