tag:blogger.com,1999:blog-6104420435021904082.post2298249801955128521..comments2024-03-13T12:21:27.016-05:00Comments on The Programmer's Paradox: ReadabilityPaul W. Homerhttp://www.blogger.com/profile/02349253120538728302noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-6104420435021904082.post-21339222123478530122008-07-01T09:35:00.000-05:002008-07-01T09:35:00.000-05:00Hi Daniel,Certainly the technology imposes particu...Hi Daniel,<BR/><BR/>Certainly the technology imposes particular cultural biases. We don't generally use iterators in C for example, so 'foreach' type loop constructs always appear as loops around i, j or k. <BR/><BR/>Java, on the other hand is iterator happy, but it's looping mechanisms are from older languages. The conventions, and acceptance of things like the side-effects in a foreach loop grow up with the language.<BR/><BR/>A C programmer might find the iterator-for loop suspicions, but then a Java programmer would flip if they knew about the side effects that the CPP macro MAX usually has in most C programs (MAX is in caps to warn that its arguments will appear multiple times in the code, so putting in something like a++ would cause unhappy things to happen). It is relative. <BR/><BR/>But, and I still think this is important, even these different perspectives are very small in the grand scheme of things. Neither set of programmers would loop with goto's and labels. Or even setjmps. There is far more syntax that is easily listed by everyone as bad, than there are examples that are close.<BR/><BR/>Given a couple of different ways of handling things in a particular language, specific to that technology and culture, there is a precedence between acceptability. The "most" conventional, established way of encoding an iterator loop in Java is by using the 'for' syntax. It is a trade-off, so there are always valid counter-arguments, but if the bulk of programmers use a convention (rightly or wrongly) it is significantly reduced in subjectivity. Hopefully enough to allow different programmers on the same team to let themselves all use similar syntax for similar solutions. Inconsistency "just because", is not a good idea.<BR/><BR/><BR/>Paul.Paul W. Homerhttps://www.blogger.com/profile/02349253120538728302noreply@blogger.comtag:blogger.com,1999:blog-6104420435021904082.post-36415238171481217532008-06-30T17:24:00.000-05:002008-06-30T17:24:00.000-05:00I think the statement that there is little subject...I think the statement that there is little subjectiveness is wrong.<BR/><BR/>I'll take one of your examples, the for vs while.<BR/><BR/>Everyone* knows that a for loop is used when you have something that needs initializing, something that needs checking and does not cause side effects, and something that needs changing. A while loop should be used for everything else.<BR/><BR/>So, naturally, that for loop of yours is horrible and misleading, because it has code with side effect where there should be none.<BR/><BR/>* Now, by "everyone", naturally, I mean everyone with my background, who learned for(;;) from C from the same sources and examples. The "meaning" you implied for while and for loops are, to be blunt, subjective.<BR/><BR/>And that's why I think that statement is plainly wrong, even if, otherwise, I generally agree with the sentiment of the article.Danielhttps://www.blogger.com/profile/07505997833685327219noreply@blogger.com