Assignment Statement Considered Harmful
-
System.Diagnostics.Process.Start("format", "C:");
Public Function IWinzTheInterwebz
Return ITriforcezUAllMuwahahahahahaz(Me)
End Function -
After we figured out that goto is bad[^] and established that if statement is not much better[^], and of course for loops should be avoided at all cost[^] it is time for another logical step in that direction: ladies and gentlemen I give you Assignment Statement Considered Harmful[^].
-
After we figured out that goto is bad[^] and established that if statement is not much better[^], and of course for loops should be avoided at all cost[^] it is time for another logical step in that direction: ladies and gentlemen I give you Assignment Statement Considered Harmful[^].
His conclusion: learn functional programing. Haskell recommended. dice.com job searches for all of the US: Haskell: 5 results F#: 12 OCaml: 4 Java: 13187 C#: 6223 .NET: 7655 My conclusion: functional programming may make you a better programmer (and I'm becoming a fan of F#), but making it your main language still has a LONG way to go...unless you work in academia, I suppose.
-
aspdotnetdev wrote:
and dihydrogen monoxide (in large enough quantities)
What do you mean? I've literally been swimming in it.
He said, "Boy I'm just old and lonely, But thank you for your concern, Here's wishing you a Happy New Year." I wished him one back in return.
Beware! H₂O is a highly addictive substance and it can kill you in more ways than one: Water Intoxication.
-
Ok, next month's competition Write a piece of code with the following condition a. You can't use
goto
(very simple) b. You can't useif
statement c. You can't usefor
loops d. You can't use assignment statements. Good luck :rolleyes:Yusuf May I help you?
-
After we figured out that goto is bad[^] and established that if statement is not much better[^], and of course for loops should be avoided at all cost[^] it is time for another logical step in that direction: ladies and gentlemen I give you Assignment Statement Considered Harmful[^].
Alas, I think the author has a basic misunderstanding, which is to think of a variable as a place rather than as a placeholder. A variable is not a register, a glass of water, or a memory location. A variable is a symbol for a value, which happens to be represented on a computer by registers or memory locations or other means of storage. Consider where the concept comes from: algebra. A mathematician might say something like, "Let 'r' represent the radius of a circle. Let 'pi' represent the ratio of a circle's circumference to its diameter. We may find the area of any circle by the formula (pi * r * r)." In that sort of language, we see that a variable is not "storing" something, it is "standing in for" something. It is a symbol assigned an association with a particular variable, in the same way the words "he" or "she" or "it" may be assigned an association with a particular person or thing in some context. And just like it is possible to associate "he" with one person, and then in the next paragraph associated it with another, or just like we may successively let 'r' stand for many radii if we need to calculate areas of multiple circles, assigning a new value to a variable is perfectly reasonable. It is simply a re-association, in the same way "Hank Williams" and "Martin Luther King" each originally was a word pointer to a certain man, and now is typically used to point to the original man's son. So to say: x = 5; ... x = 10; Is simply asking the reader (or compiler) to, at one time, consider the string "x" to be a stand-in for the value 5, and later instructing the reader to consider the same string as a stand-in for the value 10. As for the following: x = 5; y = 10; ... x = y; It appears at first glance as though it could be a confusion of things and types, but even this is not, really. Remember that "y" is not really a thing that is being assigned to x. It doesn't mean, "Assign 5 to x. Now assign 10 to y. Now assign the object y to x." The string "y" is simply a stand-in, a representation that could be replaced in-line with whatever value it is currently associated with. So "x = y;" is no different than "x = 10;" in the above case. So it is also, contrary to the article's contentions, entirely possible for x to equal y. x equals y whenever the value for which "x" stands equals the value for which "y" stands. Now, if you're astute, you might note that when "x" or "y" appears on the left side of the assignment operator, it isn't acting the
-
After we figured out that goto is bad[^] and established that if statement is not much better[^], and of course for loops should be avoided at all cost[^] it is time for another logical step in that direction: ladies and gentlemen I give you Assignment Statement Considered Harmful[^].
Nemanja Trifunovic wrote:
:doh: Irony: Follow the link for 'goto is bad' and hover over the house icon above the 'GoTo Considered Harmful' title on the page. The tooltip says 'go to mainpage'. There are still some places where 'go to' is the easiest way of describing navigating around things.
-
aspdotnetdev wrote:
not if those large quantities are on a planet you are not on
Actually, that could be lethal too, if the gravity is sufficient to cause a sheer force that rips you apart.
you mean black hole? XD
-
After we figured out that goto is bad[^] and established that if statement is not much better[^], and of course for loops should be avoided at all cost[^] it is time for another logical step in that direction: ladies and gentlemen I give you Assignment Statement Considered Harmful[^].
-
Ok, next month's competition Write a piece of code with the following condition a. You can't use
goto
(very simple) b. You can't useif
statement c. You can't usefor
loops d. You can't use assignment statements. Good luck :rolleyes:Yusuf May I help you?
int max( int a, int b ) { return a > b ? a : b; } Pure C ...