BlogBook Programming Wisdom - iRihttp://www.jerf.org/iri/blogbook/programming_wisdomShortcuts to Better Programming.en-usTue, 04 Dec 2007 16:59:23 -0000 The Money Value Function http://www.jerf.org/iri/post/2827 <p>I've loosely defined the value function (link) to only compare two "things", without further specifying what "things" it can take, because some things we put in there (like <tt>CloseToFamily</tt>) are fundamentally non-numeric properties. But some people have their own specializations of this value function. One that almost nobody will admit to using, but a lot of people live by, is the Money value function. This function takes just one argument and returns a single concrete number with the unit "Dollars" (or relevant local currency).</p> <p><a href="http://www.jerf.org/iri/post/2827">Read the rest...</a></p> jerf@jerf.org (jerf)Tue, 04 Dec 2007 16:59:23 -0000http://www.jerf.org/iri/post/2827Programming Emotional Value http://www.jerf.org/iri/post/2826 <p>When I was a child, I wanted to be like Spock. For those few who do not know whom I mean, <a href='http://en.wikipedia.org/wiki/Spock'>Spock</a> was the science officer on the star ship Enterprise in the famous 1960's sci-fi television show <a href='http://en.wikipedia.org/wiki/Star_Trek'><i>Star Trek</i></a>. His claim to fame was being half-human and half-Vulcan. Vulcans were an alien race who are so naturally violent that they felt themselves forced to renounce their emotions and turn to a life of pure logic, lest they extinguish themselves in endless war. A common misconception is that Vulcans have no emotions; they do, but they rigidly suppress them.</p> <p>Spock's major character arc involved a conflict between his "human side" and his "Vulcan side", between "emotions" and "logic". During the television series, he had chosen to attempt being pure Vulcan/logical, but he met with less success than he would have liked. Something never made clear was whether this was purely a personal issue or if perhaps being only half-Vulcan made it somehow biologically more difficult to live with the Vulcan philosophies and disciplines. (Most likely even the writers themselves were conflicted over their interpretation of this.)</p> <p>Spock's initial choice reflects a common view of emotions, that they are intrinsically opposed to logic, unpredictable and uncontrollable, that you are forced to choose either the cold, cruel world of logic, or the squishy, utterly irrational world of emotion and feeling, but that ne'er the twain shall meet. This is view can be seen in our most ancient literature, where the fiery passions of somebody's loins are routinely contrasted with their cold, austere logical mind.</p> <p>What <b>absolute garbage</b>!</p> <p><a href="http://www.jerf.org/iri/post/2826">Read the rest...</a></p> jerf@jerf.org (jerf)Wed, 17 Oct 2007 13:19:27 -0000http://www.jerf.org/iri/post/2826Programming On Values http://www.jerf.org/iri/post/2822 <p>When we make a judgment, we are saying that one thing has a larger value than another. We have a <i>value function</i> in our brains that takes two arguments and returns whether the first is less than, equal to, or greater than the other. As cruel or as crazy as it may sound, that function can take any two things and compare them; we have to make decisions like <tt>Value(CoolJob, CloseToFamily)</tt> all the time.</p> <div class='sidebar_right'>For my purposes, I merely want a concrete term to talk about "value functions" with, but it's interesting to consider the characteristics of the function. Is it a <a href='http://en.wikipedia.org/wiki/Total_order'>full ordering</a>, or a <a href='http://en.wikipedia.org/wiki/Partially_ordered_set'>partial ordering</a>? A partial ordering seems more likely, but then implies there may be cycles, which would have to be resolved by a higher-order value function if you ever faced the corresponding choice. Yet a total ordering doesn't seem likely either. So it's probably simply <i>inconsistent</i>, which if you know anything about humans isn't too surprising. Making sure to think about your choices explicitly may help you avoid or minimize the inconsistencies, which it is probably safe to say are bad in practice.</div> <p>Many people have an instinctive revulsion to the idea that such a value function exists, but it is important to understand that it does, no matter how much you'd like to avoid it. If you are in an improbable situation where you are forced to chose which of your children lives, you will have to make a choice. Refusing to choose is itself a choice, and is a piece of your value function.</p> <p>In programming, as in life, people often end up using a value function provided by somebody else, rather than actually deciding what they value and what gets them the most with their resources.</p> <p>Many people are peddling value functions. When someone advocates a methodology, they are also selling you on the value function which their methodology theoretically maximizes. When someone advocates a language or platform, they are selling you the value function where their language or platform has more value than any other.</p> <div class='sidebar_left'>I glibly use the phrase ``your true value function'' here without defining it. What exactly is your true value function? Well, if you'll pardon yet more glibness, I think that's a bit beyond the scope of this work. Some things can only be discovered for yourself, no?</div> <p>The correspondence of these value functions to your true value function varies widely. If you use a value function that is greatly at odds with your true value function, you will invariably end up with less true value than you could have gotten. Simple proof: If you choose something you accidentally overvalued, then you pay the <a href='http://en.wikipedia.org/wiki/Opportunity_cost'>opportunity cost</a> on the additional value of what you should have chosen. If you undervalue something, you are likely to end up choosing something else incorrectly and getting less than you should. If you choose poorly enough, you may end up with negative value, even discounting opportunity cost.</p> <p>It's one thing to choose Java because it's the best choice for you. Maybe you value the cross-platform support. Maybe there's a Java-only library you can buy that gets you closer to the goal in one step than you can get in any other language; that can be valuable. Maybe all of your developers already know Java and that outweighs the costs it has. </p> <p>It's quite another to choose it because "everybody uses Java", without analysis. Java's got some serious disadvantages, too; are you so willing to accept them without thought?</p> <p>As you might get from the somewhat slanted tone of the last two paragraphs, I think the "use it because everybody else is using it" heuristic is one of the worst value functions you can adopt. Life's just not that easy.</p> <p>I can also now re-express the goal of this book more precisely. My goal is not to try to provide you a value function; my goal is to help you build your own. Step one is realizing you need one. Some elements of my personal value function will shine through in this work, but that is because it is unavoidable (and therefore I don't try to hard), not because I truly want you to adopt mine. One of the important ways I can do that is help you consciously think about your value functions.</p> jerf@jerf.org (jerf)Thu, 11 Oct 2007 16:22:42 -0000http://www.jerf.org/iri/post/2822Programming What Is Programming? http://www.jerf.org/iri/post/2814 <p>What is programming?</p> <p>When you first start programming, the answer is painfully obvious: Programming is making the computer do what you want.</p> <p>Duh, right?</p> <p>However, if you have any aptitude for it at all, you will rapidly get to the point where making the computer do what you want really isn't that hard. Oh, you may be betrayed by your environment, your libraries, even your hardware sometimes, and you never get to the point where you are immune to the multi-day debugging sessions, but in general, getting the computer to do what you want ceases to be a challenge.</p> <p>The true challenge of programming is learning to <i>want the right things</i>, and then <i>how to obtain those things</i>, beyond the mere first-order consideration of "does it run right now?"</p> <p>When you work on the same product for three years, you will learn to want maintainable code. Writing code that works is easy; learning how to write maintainable code is a worthy challenge.</p> <p>When you start work on a project that has fifty man-years already put into it, you will learn to want code that is properly documented. Learning exactly what "properly documented" truly entails is a worthy challenge.</p> <p>When a project exceeds the size that one person can comfortably hold in their head, you will learn to want code that is conceptually clean and easy to come back to; a worthy challenge.</p> <p>And so on, for a number of worthy challenges.</p> <p>If only it were so easy as "making the computer do what we want"!</p> <p>Programmers that can make computers do things are a dime a dozen. Programmers that have learned to <i>want the right things</i> are unusual.</p> jerf@jerf.org (jerf)Tue, 02 Oct 2007 14:03:14 -0000http://www.jerf.org/iri/post/2814Programming Judging Tradeoffs http://www.jerf.org/iri/post/2821 <p>The core point of the entire Programming Wisdom <a href='http://www.jerf.org/iri/blogbook/'>blogbook</a>.</p> <p><a href="http://www.jerf.org/iri/post/2821">Read the rest...</a></p> jerf@jerf.org (jerf)Mon, 01 Oct 2007 15:27:16 -0000http://www.jerf.org/iri/post/2821Programming