From: Jim Carlock on
<randyhyde(a)earthlink.net> wrote:
> Actually, *most* people read faster, and with better
> comprehension, when working with short lines (though
> this is not an argument for manually insert line breaks
> everywhere; almost any decent newsreader is going to
> allow someone to adjust the width to their liking).

Oops, forgot to make a statement here.

That's true, Randy. The newspapers put everything in
small columns of text. Most magazines do it as well and
the books that fail to do this (usually those thesis papers
and technical manuscripts) tend to be harder to read, not
so much because of the content because of the width of
the text on the page. However, contentions might suggest,
that due to the preponderance (fixed indelibly and deeply)
in magazines and newspapers (and throughout the extent
of humanity), that scripts which interrupt the norm silently
present a signal which spontaneously stimulates anxiety.

Hope this helps.

Jim Carlock
Post replies to the group.


From: Frank de Groot on
<randyhyde(a)earthlink.net> wrote

> Every now and then, someone around here starts making the claim that
> having multiple statements per line is good programming style

Even though Betov was not exactly /polite/ to me recently, I have to
wholeheartedly agree with him on this point.

Multiple statements per line, when belonging logically together and aligned
in columns, greatly increase readability because they form a "logical unit"
and reduce the need for scrolling.

Whatever anyone writes it ittelevant, only logical arguments count.
It also doesn't matter that Betov isn't polite, the only thing that matters
is whether he's correct.

He's correct.


From: Dragontamer on

randyhyde(a)earthlink.net wrote:
> JGCASEY wrote:

> > As you can see from my posts I like short
> > lines, seven to eight words per line I find the
> > most comfortable to read. But that is me, I don't
> > claim everyone has this problem.
>
> Actually, *most* people read faster, and with better comprehension,
> when working with short lines (though this is not an argument for
> manually insert line breaks everywhere; almost any decent newsreader is
> going to allow someone to adjust the width to their liking).

Why, this is very true. Unfortunatly,
when lines get too short, people tend to read
much slower. A suitable balance

Is
much
better
than
one
extreme

to another extreme. IIRC, the "readability" rules measure how readable
something is
by how many syllables are across the screen. Something like 10-15
syllables is optimal
for a person to read (mind you; it is a magic number that I forgot
exactly, but the point
still remains)

This reminds me of the great Sans Serif vs Serif flamewars.
It turns out that the most "readable" IIRC, is whatever the
person was exposed to the most. Aka, if someone was
used to reading Sans Serif fonts, they would read
Sans Serif fonts faster than Serif fonts, and vice versa.

Past experiance trumps all other "measurements" IMO.
Aka, you should write code the way the next person will expect.

> > One thing I never liked about C and the other
> > languages that use the curly brackets { and } is
> > that visually the blocks of code did not pop out
> > for me without practice and even today some effort
> > despite indentation.
> >
> > Or maybe I am just visually handicapped in some way
> > which is why I have a problem with multiple statements
> > per line?
>
> Let's be clear on one thing. I am not saying that there is no one on
> this planet who won't find multiple statements per line to be more
> readable than putting them all on separate lines (at least, in certain
> circumstances). Human beings are quite adaptable and can often convince
> themselves that something is better when, in fact, it really isn't. Or
> maybe they can, with concerted effort, learn something so well that it
> really *is* better for them to see material presented in some
> particular format. If you're arguing that *you* might find some
> sequences easier to read if someone stuck multiple statements together
> on one line, who am I to argue with that?
>
> What I *am* saying, however, is that if you write code in this manner,
> because it's easier for you to read it that way, then the vast majority
> of the programmers out in the real world are going to have (more)
> difficulty reading your code than they otherwise would have. And the
> reason for that (beyond the fact that it's not something they're used
> to seeing) is summed up by McConnell's statement about reading top to
> bottom and left to right. Everything else is just a supporting role.
> It's the intertwining of the left->right and top->bottom that is the
> real problem.

So:

x
=
15
;

Is more readable than x = 15? :-p

(IIRC, that is synactically correct... C treats line breaks as
whitespace,
but I'd be damned if I ever tried to compile that)

Anyway; IIRC, all of Code Complete is basically guidelines; rules of
thumb,
and so forth. I really doubt that all rules apply to all circumstances.
Especially
when "statement" is so flexible in C. They can be as short as x++, and
as long as... however you want.

Now, you seem to think that "for" is a single statement... I consider
it
a statement composed of 3 smaller statements. Thats what it really
is...
indeed; I can probably convert much code into a single "for" loop
statement,
but I'd be darned if you'd consider it a *single* statement.

Example, something nice and easy:

int i=0;
int myarray[50];
while(i<50){
myarray[i] = i;
printf("%d\n", myarray[i]);
i++;
}

You can do that as:

int myarray[50];
for(i=0; i<50; myarray[i]=i, printf("%d\n",myarray[i]), i++);

(the array was thrown in there to purposely complicate the example :) )

Frankly speaking; the for loop is *not* one statement. I'd like to see
you
argue that it is :)

--Dragontamer

From: hutch-- on
Some of the stuff in this thread is laughable, the actual format of
different computer languages makes it nearly impossible to generalise.

A higher level language that can nest function calls in the normal
manner is obviously different from an assembler where the mnemonics for
opcodes are short words and each opcode performs a different task.

I have seen C code so badly written that you have to unwind the
function nesting to get it into a reasonably readable form,
particularly when it can be split across 4 or 5 lines of code and I
regularly see C code that does not symetrically match the indent of
braces so you have to carefully read the code layout to see where the
block starts and ends and this type of code is particularly difficult
to maintain or modify without getting bracketing errors.

At the other end of high level code, there is little point of a gaggle
of locally allocated return values when the function is capable of
accepting the nesting of another function with stuff like this pseudo
code.

Sendmessage(hWnd,WM_SETFONT,GetStockObject(ANSI_VAR_FONT),TRUE)

With mnemonic assembler code, the reverse situation is true, each
opcode has a known functionality of its own and bundling mnemonics on
the same line of code does not pick up the advantages of high level
code readability as it has a different structure.

Stacking mnemonics on the same line of code is something like stacking
independent high level functions on the same line, a confusing jumble
of junk that seriously reduces its readability for no performance gain
whatsoever.

The major factor to some of the noise you hear around ALA is that its
reasonably easy to impliment at a parsing level so its done and has a
big deal made about it as a "feature" rather than the blunder that it
is.

Anyone can write any code they like and if they can read it, fine but
to argue from the "I like it this way" to "this is a good idea" is
simply nonsense, readable code is not a mechanical theory of layout but
a consideration of who has to read it the next time. The value
judgement of its readability is not the author but the reader and here
jumbled piles of junk have a very bad track record.

Regards,

hutch at movsd dot com

From: sevagK on
Wow hutch,
This is the most constructive post you've made to ala in my memory!
What gives... Are you feeling okay?

-sevag.k
www.geocities.com/kahlinor