POV-Ray : Newsgroups : povray.off-topic : code readability Server Time
14 Oct 2026 18:52:38 EDT (-0400)
  code readability (Message 1 to 50 of 73)  
Goto Latest 50 Messages Next 23 Messages >>>
From: Halbert
Subject: code readability
Date: 26 Jun 2008 14:11:00
Message: <4863dbb4$1@news.povray.org>
I, for one, find it much easier to read C++ code which is braced like this:

if(somecondition == 0)
{
    // do some stuff
}
else
{
    // do something else
}


As opposed to

if(somecondition == 0) {
    // do some stuff
}
else {
    // do something else
}

Why doesn't the rest of the world understand that?


--
H²


Post a reply to this message

From: Warp
Subject: Re: code readability
Date: 26 Jun 2008 14:16:18
Message: <4863dcf2@news.povray.org>
Halbert <hal### [at] gmailcom> wrote:
> Why doesn't the rest of the world understand that?

  Because Brian Kernighan and Dennis Ritchie used the latter style in their
famous book, and because they are God, every C (and consequently C++) coder
must obey the same standard.

-- 
                                                          - Warp


Post a reply to this message

From: Darren New
Subject: Re: code readability
Date: 26 Jun 2008 14:29:26
Message: <4863e006$1@news.povray.org>
Halbert wrote:
> I, for one, find it much easier to read C++ code which is braced like this:
> Why doesn't the rest of the world understand that?

Different languages encourage different indentation schemes, based on 
the details of syntax.  I use different indenting for C and Pascal, for 
example.

I tend to prefer indenting where the things in one column are 
sequentially executed. So if I have an if, an assignment, and a while 
loop, I'll tend to want to indent things so there are only three lines 
in that column, rather than including all the noise words. E.g.,

void codestuff() {
   int i;
   if (i == j) {
      do this thing;
      do that thing;
      }
   j += 1;
   while (j < 23) {
      do another;
      }
   }
void morecode() {
   }

Having things like switch (especially with fallthrus) and else sometimes 
messes up the patterns, depending on just how you manage it. I figure 
the fewer rules you need to learn to indent, the easier it is to learn it.

if (i == j) {
   stuff;
   morestuff;
} else if (yadda) {
   another stuff
   extra stuff;
} else {
   thing one
   thing two
   }


That looks kind of ugly, but it also stands out as matching "my" rules 
in many ways. Doing it as
if (i == j) {
   stuff
   }
else if (j == 3) {
   stuff
   }
else {
   thing
   }

looks nicer, and also kind of works out with the "things in the same 
column should be executed sequentially" rule. It also looks nicer when 
you have "begin" and "end" instead of { and }  :-)

-- 
Darren New / San Diego, CA, USA (PST)
  Helpful housekeeping hints:
   Check your feather pillows for holes
    before putting them in the washing machine.


Post a reply to this message

From: Gail Shaw
Subject: Re: code readability
Date: 26 Jun 2008 14:40:07
Message: <4863e287@news.povray.org>
"Halbert" <hal### [at] gmailcom> wrote in message
news:4863dbb4$1@news.povray.org...
> I, for one, find it much easier to read C++ code which is braced like
this:
>
> if(somecondition == 0)
> {


> if(somecondition == 0) {
>     // do some stuff

Whereas I find the first far too spread out to be able to read easily and
use the second as my standard code layout in C-like languages

> Why doesn't the rest of the world understand that?
>

Because the rest of the world doesn't necessarily agree with you?


Post a reply to this message

From: Warp
Subject: Re: code readability
Date: 26 Jun 2008 15:02:06
Message: <4863e7ae@news.povray.org>
Gail Shaw <initialsurname@sentech sa dot com> wrote:
> Whereas I find the first far too spread out to be able to read easily

  Compactness does not imply readability. On the contrary.

-- 
                                                          - Warp


Post a reply to this message

From: Gail Shaw
Subject: Re: code readability
Date: 26 Jun 2008 15:14:12
Message: <4863ea84@news.povray.org>
"Warp" <war### [at] tagpovrayorg> wrote in message
news:4863e7ae@news.povray.org...
> Gail Shaw <initialsurname@sentech sa dot com> wrote:
> > Whereas I find the first far too spread out to be able to read easily
>
>   Compactness does not imply readability. On the contrary.

I never said it did.
I said that I find the first too spread out to read easily and that I prefer
the second as *I* personally find it easier to read.

If you prefer the former, more power to you. Just don't expect me to code
the same way.


Post a reply to this message

From: Halbert
Subject: Re: code readability
Date: 26 Jun 2008 15:28:43
Message: <4863edeb$1@news.povray.org>
It's true that its only a preferance I personally have. The rest of the 
world doesn't have to agree with me. I just like the way the braces all line 
up and make visually clear the beginning and end of each code block. Its 
easier for me to see than matching of the ending brace with the associated 
expression at the top of the block.
I have been quietly living with that gripe in the back of my mind for the 
last 18 or 19 years. Now that it's out in the open, I feel much better.


-- 
H²


Post a reply to this message

From: Gail Shaw
Subject: Re: code readability
Date: 26 Jun 2008 15:39:00
Message: <4863f054@news.povray.org>
"Halbert" <hal### [at] gmailcom> wrote in message
news:4863edeb$1@news.povray.org...
> It's true that its only a preferance I personally have. The rest of the
> world doesn't have to agree with me.

Everyone's entitled to their prefered way of doing things. Life would be
boring if we all agreed on everything

> I have been quietly living with that gripe in the back of my mind for the
> last 18 or 19 years. Now that it's out in the open, I feel much better.

Good.


Post a reply to this message

From: Warp
Subject: Re: code readability
Date: 26 Jun 2008 15:41:01
Message: <4863f0cd@news.povray.org>
Gail Shaw <initialsurname@sentech sa dot com> wrote:
> Life would be boring if we all agreed on everything

  I disagree.

-- 
                                                          - Warp


Post a reply to this message

From: stbenge
Subject: Re: code readability
Date: 26 Jun 2008 15:47:59
Message: <4863f26f@news.povray.org>
Halbert wrote:
> I, for one, find it much easier to read C++ code which is braced like this:
> 
> if(somecondition == 0)
> {
>     // do some stuff
> }
> else
> {
>     // do something else
> }

I, for more than one, do not.

> As opposed to
> 
> if(somecondition == 0) {
>     // do some stuff
> }
> else {
>     // do something else
> }

To me, the latter method is much more like POV-Ray than the first 
method. I learned POV first, so I guess that's why I do it.

Since most of the code I write is never seen by another poor soul, you 
won't find me bending backwards to tailor it for the "posh" crowd.

> Why doesn't the rest of the world understand that?

I kinda feel bad for the one guy who had to see my C++ code. At least it 
was relatively short :)

Sam


Post a reply to this message

From: Mike Raiford
Subject: Re: code readability
Date: 26 Jun 2008 15:53:34
Message: <4863f3be@news.povray.org>
Warp wrote:
> Gail Shaw <initialsurname@sentech sa dot com> wrote:
>> Whereas I find the first far too spread out to be able to read easily
> 
>   Compactness does not imply readability. On the contrary.
> 

Case in point:

n=(i<12&&j>=i)?(sqrt(z)*y+j):(y+j*i);

vs

if( i < 12 && j >= i )
{
     n = sqrt(z) * y + j;
}
else
{
     n = y + j * i;
}

;)


Post a reply to this message

From: Mike Raiford
Subject: Re: code readability
Date: 26 Jun 2008 15:56:34
Message: <4863f472$1@news.povray.org>
stbenge wrote:
> Halbert wrote:
>> I, for one, find it much easier to read C++ code which is braced like 
>> this:
>>
>> if(somecondition == 0)
>> {
>>     // do some stuff
>> }
>> else
>> {
>>     // do something else
>> }
> 
> I, for more than one, do not.
> 
>> As opposed to
>>
>> if(somecondition == 0) {
>>     // do some stuff
>> }
>> else {
>>     // do something else
>> }
> 
> To me, the latter method is much more like POV-Ray than the first 
> method. I learned POV first, so I guess that's why I do it.
> 

I learned POV first, too. But for C/C++ code, the second example seems 
foreign. I much prefer the first example.

But it's kind of like saying you prefer a room painted hunter green, 
while I'd prefer forest green.

The only thing I'll say is that if there are coding standards in place, 
follow the standard your organization uses.


Post a reply to this message

From: Warp
Subject: Re: code readability
Date: 26 Jun 2008 15:57:01
Message: <4863f48d@news.povray.org>
Mike Raiford <mra### [at] hotmailcom> wrote:
> Case in point:

> n=(i<12&&j>=i)?(sqrt(z)*y+j):(y+j*i);

  Of course spaces could help readability a bit. Like:

n = (i < 12 && j >= i) ? (sqrt(z)*y + j) : (y + j*i);

-- 
                                                          - Warp


Post a reply to this message

From: Orchid XP v8
Subject: Re: code readability
Date: 26 Jun 2008 16:09:33
Message: <4863f77d$1@news.povray.org>
Halbert wrote:
> I, for one, find it much easier to read C++ code which is braced like this:
> Why doesn't the rest of the world understand that?

No idea.

Annoying, isn't it??



The other thing that annoys me is Java's insistance on using camal case 
but with a lowercase first letter.

   lower_case_with_underscores is just fine.

   CamalCaseWithoutUnderscores is also fine.

   thisIsJustUnspeakablyHorrid!!

   EIFFEL_IS_WORSE_IN_THIS_REGARD...

Annoyingly, Haskell copies Java's incorrect use of camal case...

-- 
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*


Post a reply to this message

From: Halbert
Subject: Re: code readability
Date: 26 Jun 2008 16:21:37
Message: <4863fa51@news.povray.org>
How about Microsoft's engineers starting the whole Hungarian Notation 
convention with Windows programing. (like lpstrFilePath or iRecursion, etc.) 
There seems to be no set standard to it. While the intention is good,  a 
beginner may have wonder why some variables have names like lpszDemung or 
lpfnCBack.

--
H²


Post a reply to this message

From: stbenge
Subject: Re: code readability
Date: 26 Jun 2008 16:52:16
Message: <48640180@news.povray.org>
Mike Raiford wrote:
> The only thing I'll say is that if there are coding standards in place, 
> follow the standard your organization uses.

If I worked for an organization, I would definitely change my style. Of 
course if I were programming for a living, I would probably go to school 
where they would teach me how to write code that people could decipher :)

Sam


Post a reply to this message

From: Orchid XP v8
Subject: Re: code readability
Date: 26 Jun 2008 16:56:38
Message: <48640286$1@news.povray.org>
stbenge wrote:

> Of 
> course if I were programming for a living, I would probably go to school 
> where they would teach me how to write code that people could decipher :)

Don't count on it! ;-)

-- 
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*


Post a reply to this message

From: Darren New
Subject: Re: code readability
Date: 26 Jun 2008 17:20:37
Message: <48640825$1@news.povray.org>
Halbert wrote:
> How about Microsoft's engineers starting the whole Hungarian Notation 
> convention with Windows programing. 

Actually, this makes a lot of sense for C *when done right*.

The point was not to repeat in the variable name the types that you 
declared to the compiler. The point was to repeat in the variable name 
the types you CANNOT declare to the compiler.

If you have
   int line_width;
   int line_height;
   int page_height;
   int line_count;
   int pixel_count
the expressions
   page_height = line_count * line_height
and
   page_height = line_count * line_width
and
   pixel_count = page_height * line_width
and
   pixel_count = page_height * page_height
are equally type-correct as far as C is concerned, but two are nonsense.

So you declare
   int wLineWidth;
   int hLineHeight;
   int hPageHeight;
   int hwPixelCount;
   int lineCount;

Then you can write
   hPageHeight = hLineHeight * lineCount;
   hPageHeight = wLineWidth * lineCount; // Obvious nonsense!
   hwPixelCount = hLineHeight * wLineWidth; // Looks good
   hwPixelCount = hLineHeight * hPageHeight; // Nonsense!

Even picking nonsense variable names other than the notation will tell 
you that it's nonsense. If you see
   hSize = count * hQuantity; // Probably OK
   wSize = hQuantity * count; // Probably bogus

That was the idea of "Hungarian notation". Not that you should replicate 
what the compiler already knows, but distinguish types that the compiler 
can't, because you're using a language whose compiler was designed to 
fit into a PDP-11's memory.

-- 
Darren New / San Diego, CA, USA (PST)
  Helpful housekeeping hints:
   Check your feather pillows for holes
    before putting them in the washing machine.


Post a reply to this message

From: Sabrina Kilian
Subject: Re: code readability
Date: 26 Jun 2008 17:53:59
Message: <48640ff7$1@news.povray.org>
Halbert wrote:
> How about Microsoft's engineers starting the whole Hungarian Notation 
> convention with Windows programing. (like lpstrFilePath or iRecursion, etc.) 
> There seems to be no set standard to it. While the intention is good,  a 
> beginner may have wonder why some variables have names like lpszDemung or 
> lpfnCBack.
> 
> --
> H²
> 
> 

I do camel case with lowercase leading letters in my code. It's just how 
I name functions. Classes, objects, templates, etc get a leading capital 
letter, so do most instances of objects in C++.

Last group project class I was in, one teammate complained about it. He 
liked code written his way only, and since I was the debugger of the 
group he really didn't like my edits. He told me I could use any other 
convention I liked, but I was not to state with a leading lowercase 
without a reason. I offered to start with lowercase letters for 
Hungarian Notation. Very quickly, my normal method of naming was allowed 
to remain untouched.

It was sad that I had to explain why I was laughing and he was panicking 
to the third member of our group.


Post a reply to this message

From: Eero Ahonen
Subject: Re: code readability
Date: 26 Jun 2008 18:25:01
Message: <4864173d@news.povray.org>
Warp wrote:
> 
>   I disagree.
> 

Good, 'cause you're wrong.

-- 
Eero "Aero" Ahonen
    http://www.zbxt.net
       aer### [at] removethiszbxtnetinvalid


Post a reply to this message

From: stbenge
Subject: Re: code readability
Date: 26 Jun 2008 18:26:45
Message: <486417a5@news.povray.org>
Orchid XP v8 wrote:
> stbenge wrote:
> 
>> Of course if I were programming for a living, I would probably go to 
>> school where they would teach me how to write code that people could 
>> decipher :)
> 
> Don't count on it! ;-)

I should take *some* C++ courses, considering my near-total confusion 
when trying to use Irrlicht recently... I'm pretty much clueless when it 
comes to classes and such.


Post a reply to this message

From: Stephen
Subject: Re: code readability
Date: 26 Jun 2008 19:54:46
Message: <m1b86415b67sqdojgmt2b46f0uu930up14@4ax.com>
On Fri, 27 Jun 2008 01:26:58 +0300, Eero Ahonen
<aer### [at] removethiszbxtnetinvalid> wrote:

>Warp wrote:
>> 
>>   I disagree.
>> 
>
>Good, 'cause you're wrong.

I can't help but agree with you.
-- 

Regards
     Stephen


Post a reply to this message

From: Stephen
Subject: Re: code readability
Date: 26 Jun 2008 19:58:51
Message: <39b864d8vq6a336ve630j2rkpgovcpfm33@4ax.com>
On Thu, 26 Jun 2008 21:56:40 +0100, Orchid XP v8 <voi### [at] devnull>
wrote:

What happened to you? I thought that you were coming for a drink
tonight?
-- 

Regards
     Stephen


Post a reply to this message

From: Jim Charter
Subject: Re: code readability
Date: 26 Jun 2008 20:14:59
Message: <48643103$1@news.povray.org>
Halbert wrote:
> 
> Why doesn't the rest of the world understand that?
> 

But they do understand.  Each in his own way.


Post a reply to this message

From: Leroy Whetstone
Subject: Re: code readability
Date: 26 Jun 2008 23:48:53
Message: <48644299.3050707@joplin.com>
I'm a rebel I use both ways and other ways.
If the 'if' condition is short I put it all line.
if it's a little longer maybe the line below

Readable is minor compared to the total lack of documentation people use 
in their C and c++ programs.


Post a reply to this message

From: scott
Subject: Re: code readability
Date: 27 Jun 2008 03:19:49
Message: <48649495@news.povray.org>
> I, for one, find it much easier to read C++ code which is braced like 
> this:

Me too, that's how I code and how I code in POV too.  I think it looks much 
nicer spaced out like that, I think of the braces as a way to force a line 
of white-space (apart from the brace character, obviously) above and below 
blocks of code.


Post a reply to this message

From: Invisible
Subject: Re: code readability
Date: 27 Jun 2008 05:06:15
Message: <4864ad87@news.povray.org>
Stephen wrote:

> What happened to you? I thought that you were coming for a drink
> tonight?

Oh.

I thought I said I'd check whether I'm available and get back to you? 
[Which admittedly I never did...]

Turns out I had to move furnature around instead. Sorry about that...

-- 
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*


Post a reply to this message

From: Stephen
Subject: Re: code readability
Date: 27 Jun 2008 05:47:46
Message: <5pd964tqt0ev1988cec5cskuiv58g3q5rr@4ax.com>
On Fri, 27 Jun 2008 10:06:14 +0100, Invisible <voi### [at] devnull> wrote:

>Stephen wrote:
>
>> What happened to you? I thought that you were coming for a drink
>> tonight?
>
>Oh.
>
>I thought I said I'd check whether I'm available and get back to you? 
>[Which admittedly I never did...]
>
>Turns out I had to move furnature around instead. Sorry about that...

Good job we waited in the pub ;)
-- 

Regards
     Stephen


Post a reply to this message

From: Invisible
Subject: Re: code readability
Date: 27 Jun 2008 05:49:55
Message: <4864b7c3$1@news.povray.org>
>> Oh.
>>
>> I thought I said I'd check whether I'm available and get back to you? 
>> [Which admittedly I never did...]
>>
>> Turns out I had to move furnature around instead. Sorry about that...
> 
> Good job we waited in the pub ;)

Oh well - I hope you lot enjoyed yourselves even if I didn't. Heh. ;-)

-- 
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*


Post a reply to this message

From: Tim Nikias
Subject: Re: code readability
Date: 27 Jun 2008 09:13:31
Message: <4864e77b$1@news.povray.org>
Gail Shaw wrote:
[...]

> Whereas I find the first far too spread out to be able to read easily and
> use the second as my standard code layout in C-like languages

Heh, that reminds me... Some guy actually wrote code like this:

if (DoNot == 0)
{



	DoThis = true;



} else {



	DoThis = false;



}


This was a few years back and on old university monitors, so he didn't 
actually have much more than 10 commands TOTAL on screen at any given 
time. How you keep an overview over the entire algorithm in that manner 
is lost on me, and obviously on him, too: he didn't get his code working 
in three weeks.

Regards,
Tim


Post a reply to this message

From: Eero Ahonen
Subject: Re: code readability
Date: 27 Jun 2008 09:40:30
Message: <4864edce$1@news.povray.org>
Tim Nikias wrote:
> 
> Heh, that reminds me... Some guy actually wrote code like this:
> 

Somehow those variables remind me of what I've decided I'll do at work 
some day, when I'll have a place where it fits:

if (!successful) {
	try_harder();
}

> Regards,
> Tim


-- 
Eero "Aero" Ahonen
    http://www.zbxt.net
       aer### [at] removethiszbxtnetinvalid


Post a reply to this message

From: Mike the Elder
Subject: Re: code readability
Date: 27 Jun 2008 09:45:00
Message: <web.4864ee92b4d9c1875a8888d90@news.povray.org>
Warp <war### [at] tagpovrayorg> wrote:
> Gail Shaw <initialsurname@sentech sa dot com> wrote:
> > Whereas I find the first far too spread out to be able to read easily
>
>   Compactness does not imply readability. On the contrary.
>
> --
>                                                           - Warp

IBELIEV
ETHATIN
THISCAS
EIAMCOM
PELLEDT
OAGREEW
ITHYOU!


BEST
REGA
RDSM
IKEC


Post a reply to this message

From: Invisible
Subject: Re: code readability
Date: 27 Jun 2008 09:47:37
Message: <4864ef79$1@news.povray.org>
Warp wrote:

>   Compactness does not imply readability. On the contrary.

I'd say that there is only a fairly weak correlation (positive or 
negative) between compactness and readability.

   x = 2*y*y*y - 3*a*b

is much more readable than

   t1 = y*y
   t2 = y*t1
   t3 = 2*t2
   t4 = a*b
   t5 = 3*t4
   t6 = t3-t5

despite being much more compact. Counter-examples in the opposite 
direction are not hard to find either.

-- 
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*


Post a reply to this message

From: Mike Raiford
Subject: Re: code readability
Date: 27 Jun 2008 10:29:01
Message: <4864f92d@news.povray.org>
Invisible wrote:

> is much more readable than
> 
>   t1 = y*y
>   t2 = y*t1
>   t3 = 2*t2
>   t4 = a*b
>   t5 = 3*t4
>   t6 = t3-t5
> 
> despite being much more compact. Counter-examples in the opposite 
> direction are not hard to find either.

Hey ... that looks familiar.

... I think someone here used to write code exactly like that! 0.o


Post a reply to this message

From: Mike Raiford
Subject: Re: code readability
Date: 27 Jun 2008 10:29:35
Message: <4864f94f$1@news.povray.org>
Stephen wrote:
> On Fri, 27 Jun 2008 01:26:58 +0300, Eero Ahonen
> <aer### [at] removethiszbxtnetinvalid> wrote:
> 
>> Warp wrote:
>>>   I disagree.
>>>
>> Good, 'cause you're wrong.
> 
> I can't help but agree with you.

I disagree.

Everyone's wrong!


Post a reply to this message

From: Mike Raiford
Subject: Re: code readability
Date: 27 Jun 2008 10:31:41
Message: <4864f9cd$1@news.povray.org>
Eero Ahonen wrote:
> Tim Nikias wrote:
>>
>> Heh, that reminds me... Some guy actually wrote code like this:
>>
> 
> Somehow those variables remind me of what I've decided I'll do at work 
> some day, when I'll have a place where it fits:
> 
> if (!successful) {
>     try_harder();
> }
> 
>> Regards,
>> Tim
> 
> 

try
{
    AcheiveYourGoals();
}
catch(DidntSucceedException ex)
{
   TryAgain();
}

:p


Post a reply to this message

From: Mike Raiford
Subject: Re: code readability
Date: 27 Jun 2008 10:33:58
Message: <4864fa56$1@news.povray.org>
stbenge wrote:

> If I worked for an organization, I would definitely change my style. Of 
> course if I were programming for a living, I would probably go to school 
> where they would teach me how to write code that people could decipher :)

Write code that others can decipher? Why would you do a thing like that? ;)

Everyone knows that if you code for a living, you code for job 
security... you wouldn't want the janitor to take your job, would you? :D

(Of course, I'm joking .... it doesn't work well in a team environment 
to code for job security)


Post a reply to this message

From: Mike Raiford
Subject: Re: code readability
Date: 27 Jun 2008 10:38:20
Message: <4864fb5c$1@news.povray.org>
Halbert wrote:
> How about Microsoft's engineers starting the whole Hungarian Notation 
> convention with Windows programing. (like lpstrFilePath or iRecursion, etc.) 
> There seems to be no set standard to it. While the intention is good,  a 
> beginner may have wonder why some variables have names like lpszDemung or 
> lpfnCBack.

There seems to be two standards, one which describes type: lpszString 
and one that defines function (sort of): instead of iOptions, it's fOptions.

You don't know how many times I've looked at a function signature, and 
seen fSomething on something that should receive bits and wondered why 
the hell they want a float, only to look a bit to the left and see that 
it is indeed an integer.


Post a reply to this message

From: Invisible
Subject: Re: code readability
Date: 27 Jun 2008 10:39:56
Message: <4864fbbc$1@news.povray.org>
Mike Raiford wrote:

> try
> {
>    AcheiveYourGoals();
> }
> catch(DidntSucceedException ex)
> {
>   TryAgain();
> }


try
{
   AchieveYourGoals();
}
catch (Failure e)
{
   CallAirStrike();
}

// With appologies for Murphy...

-- 
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*


Post a reply to this message

From: Eero Ahonen
Subject: Re: code readability
Date: 27 Jun 2008 11:34:04
Message: <4865086c$1@news.povray.org>
Mike Raiford wrote:
> 
> try
> {
>    AcheiveYourGoals();
> }
> catch(DidntSucceedException ex)
> {
>   TryAgain();
> }
> 
> :p

Would be great, too :). The thing about my code is that at work we have 
this department-wide habit that if someone says "this doesn't work" or 
"I can't do this" oslt, the first answer is usually "try harder".

-- 
Eero "Aero" Ahonen
    http://www.zbxt.net
       aer### [at] removethiszbxtnetinvalid


Post a reply to this message

From: Warp
Subject: Re: code readability
Date: 27 Jun 2008 11:41:11
Message: <48650a17@news.povray.org>
Invisible <voi### [at] devnull> wrote:
> I'd say that there is only a fairly weak correlation (positive or 
> negative) between compactness and readability.

>    x = 2*y*y*y - 3*a*b

  The context was really a multilined program source code, not a
mathematical formula, which your line really is.

  Mathematical formulae can often be written compactly because they
a) aren't really program code, and b) there's an established syntax
to write it compactly.

-- 
                                                          - Warp


Post a reply to this message

From: Invisible
Subject: Re: code readability
Date: 27 Jun 2008 11:50:16
Message: <48650c38$1@news.povray.org>
Warp wrote:

>   The context was really a multilined program source code, not a
> mathematical formula, which your line really is.
> 
>   Mathematical formulae can often be written compactly because they
> a) aren't really program code, and b) there's an established syntax
> to write it compactly.

Perhaps you forget, the very word "computer" means "device for 
performing mathematical calculations". ;-)

Having programmed with Haskell for a while now, I would contest the 
"programs aren't mathematics" assertion. Having played with mathematics 
for even longer, I would contest the "established syntax" assertion too! 
[Rather, there are several incompatible and variously ambiguous syntaxes 
for writing any particular mathematical construct...]

Regardless, I would assert that how "readable" something is depends on 
how well it maps to your underlying mental processes - which is rather 
independant of the compactness or otherwise of the code. ;-)

-- 
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*


Post a reply to this message

From: Invisible
Subject: Re: code readability
Date: 27 Jun 2008 11:52:31
Message: <48650cbf$1@news.povray.org>
Mike Raiford wrote:

> Hey ... that looks familiar.
> 
> ... I think someone here used to write code exactly like that! 0.o

It's certainly what the compiler transforms your code into - this is 
what machines derived from the design of Turing expect. But it is not 
necessarily how humans think. ;-)

-- 
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*


Post a reply to this message

From: Gail Shaw
Subject: Re: code readability
Date: 27 Jun 2008 12:49:28
Message: <48651a18@news.povray.org>
"Eero Ahonen" <aer### [at] removethiszbxtnetinvalid> wrote in message
news:4864edce$1@news.povray.org...
> Tim Nikias wrote:
> >
> > Heh, that reminds me... Some guy actually wrote code like this:
> >
>
> Somehow those variables remind me of what I've decided I'll do at work
> some day, when I'll have a place where it fits:
>
> if (!successful) {
> try_harder();
> }

My honours project at university had a line of code in it

while (!hellFrozenOver) {
...


Post a reply to this message

From: stbenge
Subject: Re: code readability
Date: 27 Jun 2008 13:26:06
Message: <486522ae@news.povray.org>
Mike Raiford wrote:
> stbenge wrote:
> 
>> If I worked for an organization, I would definitely change my style. 
>> Of course if I were programming for a living, I would probably go to 
>> school where they would teach me how to write code that people could 
>> decipher :)
> 
> Write code that others can decipher? Why would you do a thing like that? ;)
> 
> Everyone knows that if you code for a living, you code for job 
> security... you wouldn't want the janitor to take your job, would you? :D

Around here it is highly unlikely that a janitor would know how to 
program a computer, let alone operate one. This isn't to say people 
around here are stupid or anything. They are just generally 
computer-illiterate.

> (Of course, I'm joking .... it doesn't work well in a team environment 
> to code for job security)

A bit off-topic, but this reminds me of a guy I worked with at the 
travel nurse agency. The man worked in the 'computer engineering' 
section, along with the manager. His job, as far as I could tell, was to 
keep the computers running smoothly, and to archive lists of available 
or potentially available nurses. Now maybe I'm missing something here, 
but do you really need your own server for that kind of work? Can't you 
do those things with conventional computers and storage? Why did we even 
need a server when there were only about zero or three people making 
travel reservations at any given time? I wonder things these because the 
'computer engineer' seemed very self-important, an active preserver of 
personal job security. He even cast a contentious look one time when I 
helped a lady with her computer's resolution! Odd situation at any rate.

Sam


Post a reply to this message

From: Orchid XP v8
Subject: Re: code readability
Date: 27 Jun 2008 14:22:02
Message: <48652fca$1@news.povray.org>
Gail Shaw wrote:

> My honours project at university had a line of code in it
> 
> while (!hellFrozenOver) {
> ...

...you realise that when hell freezes over, your program is going to 
fail in an undefined way, right? (YHF bug?)

-- 
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*


Post a reply to this message

From: Gail Shaw
Subject: Re: code readability
Date: 27 Jun 2008 15:09:28
Message: <48653ae8@news.povray.org>
"Orchid XP v8" <voi### [at] devnull> wrote in message
news:48652fca$1@news.povray.org...
>
> ...you realise that when hell freezes over, your program is going to
> fail in an undefined way, right? (YHF bug?)
>

In the case of that piece of code, it would just not do anything on that
fateful day
The loop in question was the program's main activity loop (Distributed VR
system)


Post a reply to this message

From: andrel
Subject: Re: code readability
Date: 27 Jun 2008 16:09:25
Message: <4865492A.20706@hotmail.com>
Mike Raiford wrote:
> Warp wrote:
>> Gail Shaw <initialsurname@sentech sa dot com> wrote:
>>> Whereas I find the first far too spread out to be able to read easily
>>
>>   Compactness does not imply readability. On the contrary.
>>
> 
> Case in point:
> 
> n=(i<12&&j>=i)?(sqrt(z)*y+j):(y+j*i);
> 
> vs
> 
> if( i < 12 && j >= i )
> {
>     n = sqrt(z) * y + j;
> }
> else
> {
>     n = y + j * i;
> }
> 
> ;)
I'd like to see the specification that gave rise to that snipped of code. ;)


Post a reply to this message

From: Darren New
Subject: Re: code readability
Date: 27 Jun 2008 16:29:17
Message: <48654d9d$1@news.povray.org>
Invisible wrote:
> Perhaps you forget, the very word "computer" means "device for 
> performing mathematical calculations". ;-)

Actually, it means "person whose job it is to do the arithmetic." Only 
after they automated it did it refer to a machine. :-)

-- 
Darren New / San Diego, CA, USA (PST)
  Helpful housekeeping hints:
   Check your feather pillows for holes
    before putting them in the washing machine.


Post a reply to this message

From: andrel
Subject: Re: code readability
Date: 27 Jun 2008 16:29:47
Message: <48654DF0.3030004@hotmail.com>
Gail Shaw wrote:
> "Eero Ahonen" <aer### [at] removethiszbxtnetinvalid> wrote in message
> news:4864edce$1@news.povray.org...
>> Tim Nikias wrote:
>>> Heh, that reminds me... Some guy actually wrote code like this:
>>>
>> Somehow those variables remind me of what I've decided I'll do at work
>> some day, when I'll have a place where it fits:
>>
>> if (!successful) {
>> try_harder();
>> }
> 
> My honours project at university had a line of code in it
> 
> while (!hellFrozenOver) {
> ...
> 
> 
was that before or after Lordi won?


Post a reply to this message

Goto Latest 50 Messages Next 23 Messages >>>

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.