<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>I, Engineer &#187; Programming</title>
	<atom:link href="http://blog.unreasonable.com/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.unreasonable.com</link>
	<description>engineering is a way of life</description>
	<lastBuildDate>Wed, 25 Feb 2015 02:27:52 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.0.38</generator>
	<item>
		<title>Don&#8217;t blink.</title>
		<link>http://blog.unreasonable.com/dont-blink/</link>
		<comments>http://blog.unreasonable.com/dont-blink/#comments</comments>
		<pubDate>Tue, 13 Jan 2015 03:28:27 +0000</pubDate>
		<dc:creator><![CDATA[lubkin]]></dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Usability]]></category>

		<guid isPermaLink="false">http://blog.unreasonable.com/?p=588</guid>
		<description><![CDATA[Blinking is notorious as the least justifiable behavior on a web page. (But don&#8217;t blame Lou Montulli, who came up with the idea.) It&#8217;s also]]></description>
				<content:encoded><![CDATA[<aside class="postimage"><a href="http://php.net/manual/en/language.types.boolean.php#100628" title="Usability problem in context"><img src="http://blog.unreasonable.com/wp-content/uploads/2015/01/php01b.jpg" width="300" height="405" alt="" /></a></aside>
<section>Blinking is notorious as the least justifiable behavior on a web page. (But don&#8217;t blame Lou Montulli, who <a href="http://gizmodo.com/5903827/the-humble-origins-of-the-html-blink-tag">came up with the idea</a>.)</p>
<p>It&#8217;s also <a href="http://www.oxforddictionaries.com/us/definition/english/blinking title="Oxford definition">British slang</a> for <em>annoying</em>.</p>
<p>I just looked up something in the <a href="http://php.net/manual/en/">online documentation</a> for PHP. Pages are generally clean and usable as they appear in the browser, although there are a few poor practices if you look at the underlying HTML.</p>
<p>However. Take a look at <a href="http://php.net/manual/en/language.types.boolean.php">a typical page.</a> Below each formal section are (often useful) comments. Try moving the focus down the page different ways&mdash;scrolling, moving the mouse, page down. One comment at a time appears in dark colors. The other comments are pale and washed out until you move the focus to them. Then, over 0.4 seconds, they become opaque and readable.</p>
<p>And most of the goodwill from how well thought-out the rest is is squandered. </p>
<p>There is no reason to make text unreadable. And less still to waste the user&#8217;s time as they&#8217;re made readable. </p>
<p>Since transitions are new to CSS3, my guess is that programmers were playing. As they had in 1994 with <code>&lt;blink&gt;</code>.</p>
<p>Playing is fine. </p>
<p>Then someone in the room has to say it&#8217;s great to know we can do this if we ever need it. But we don&#8217;t now. So take it out.</section>
]]></content:encoded>
			<wfw:commentRss>http://blog.unreasonable.com/dont-blink/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Programming without coercion</title>
		<link>http://blog.unreasonable.com/programming-without-coercion/</link>
		<comments>http://blog.unreasonable.com/programming-without-coercion/#comments</comments>
		<pubDate>Mon, 29 Dec 2014 21:27:19 +0000</pubDate>
		<dc:creator><![CDATA[lubkin]]></dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.unreasonable.com/?p=234</guid>
		<description><![CDATA[One of my core values is clarity. Clarity in what you think, what you write, what you say. In programming, this means clarity in your code. What you write should equally make sense to compilers and people. I remember one program. What they used to call dusty deck, after the... <a href="http://blog.unreasonable.com/programming-without-coercion/" class="readmore">Read more</a>]]></description>
				<content:encoded><![CDATA[<aside class="postimage"><a href="http://www.amazon.com/gp/product/0201485672/ref=as_li_tl?ie=UTF8&#038;camp=1789&#038;creative=9325&#038;creativeASIN=0201485672&#038;linkCode=as2&#038;tag=unreasonablesoft&#038;linkId=V6K4JHKP3ACE4KNQ" title="Refactoring: Improving the Design of Existing Code (on Amazon)"><img src="http://blog.unreasonable.com/wp-content/uploads/2014/12/refactoring-martin-fowler.jpg" width="196" height="250" class="bordered"/></a></aside>
<section>One of my core values is clarity. Clarity in what you think, what you write, what you say. In programming, this means clarity in your code. What you write should equally make sense to compilers and people.</p>
<p>I remember one program. What they used to call <em>dusty deck</em>, after the deck of punched cards they were on. Dusty from years sitting on a shelf. It had one constant for two very different purposes. The equivalent of using <em>foo</em> for both the range of values for the month and for the hour in a date-time because they both happen to be 12. Lots of luck in Israel, where the Hebrew calendar (1..13) and military time (0..23) are often used.</p>
<p><span id="more-234"></span></p>
<p>Your intentions should always be clear to the engineer who has to work on your code after you. Or port it to another language or another operating system. And to the compiler that has to generate valid instructions.</p>
<p>Don&#8217;t rely on implicit type conversion, with the possible exception of upsizing, e..g., upsizing an <code>int</code> to a <code>long</code>.</p>
<p>Your programming language might have standardized rules for what happens if you write <code>7 + "5"</code>. Which, by the way, may not be the same as if you write <code>"7" + 5</code>. Don&#8217;t rely on this without an awfully good reason. That it works now is no guarantee it works everywhere and everywhen or will be obvious to whoever looks at your code.</p>
<p>Don&#8217;t rely on how an empty string or a zero or NULL pointer is treated in a Boolean context. Explicitly convert it to Boolean so that your intent is clear and your code isn&#8217;t dependent on language minutiae. You need to <em>know</em> what <code>if (object)</code> does, if only because the language has idioms other people will use. But <code>if (object != NULL)</code> is clearer.</p>
<p>Like most rules, there are exceptions, and it&#8217;s a judgment call. If the language generates a Boolean value for <code>a || b</code>, then you might as well make it <code>a || bool(b)</code>.</p>
<p>But if the result of <code>||</code> is the actual value of the first operand that doesn&#8217;t evaluate to FALSE, then you have the useful idiom:</p>
<p class="blogcode"><code>result = maybe_empty || "default value";</code></p>
<p>Which is more graceful than:</p>
<p class="blogcode"><code>result = (object != NULL) ? object : "default value";</code></p>
<p>Also, if you&#8217;re working on code that follows an established style, follow the style not the rule. There&#8217;s a higher rule: <strong>Standard is better than better.</strong></p>
</section>
]]></content:encoded>
			<wfw:commentRss>http://blog.unreasonable.com/programming-without-coercion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Check the price tag</title>
		<link>http://blog.unreasonable.com/check-the-price-tag/</link>
		<comments>http://blog.unreasonable.com/check-the-price-tag/#comments</comments>
		<pubDate>Fri, 26 Dec 2014 15:35:03 +0000</pubDate>
		<dc:creator><![CDATA[lubkin]]></dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[databases]]></category>
		<category><![CDATA[distributed computing]]></category>

		<guid isPermaLink="false">http://blog.unreasonable.com/?p=389</guid>
		<description><![CDATA[On The West Wing, in &#8220;Guns Not Butter,&#8221; Charlie&#8212;who I see as the series&#8217; protagonist&#8212;tries to reach a pal to ask him a simple question and triggers a memo from the Secretary of Defense, CC&#8217;ed to the Joint Chiefs and the Secretary of State. Delegation is a basic principle of... <a href="http://blog.unreasonable.com/check-the-price-tag/" class="readmore">Read more</a>]]></description>
				<content:encoded><![CDATA[<aside class="postimage"><a href="http://www.imdb.com/title/tt0745627"><img src="http://blog.unreasonable.com/wp-content/uploads/2014/12/charlie-young.jpg" width="231" height="350" /></a></aside>
<section>On The West Wing, in &#8220;Guns Not Butter,&#8221; Charlie&mdash;who I see as the series&#8217; protagonist&mdash;tries to reach a pal to ask him a simple question and triggers a memo from the Secretary of Defense, CC&#8217;ed to the Joint Chiefs and the Secretary of State.</p>
<p>Delegation is a basic principle of engineering. Do what you need and don&#8217;t tell you the details.</p>
<p>But sometimes you need the details.</p>
<p>Would you like me to arrange for someone to pick you up? It would be my pleasure. Did I not mention that we&#8217;ll charge your account $2,500 for the service? I&#8217;m sorry, but you should have asked.<span id="more-389"></span></p>
<p>It&#8217;s very convenient if you can invoke a remote procedure call as if it were a local call to a page in memory. Or access a file across the Internet with the same <code>fopen()</code> call as you&#8217;d use for one on an attached hard disk.</p>
<p>Not so much as the cost rises a thousand- or a billion-fold.</p>
<p>A great deal of effort has gone into trying to shield programmers from learning the data definition, manipulation, stored procedure, and query languages of the DBMS their system is built on.</p>
<p>Why bother? They&#8217;re not that hard to learn and get good at.</p>
<p>More importantly, there are common situations where switching from shipping the data across to analyze in your program and analyzing it in a stored procedure within a database server process drops the cost in network traffic from terabytes to a few KB.</p>
<p>Don&#8217;t bend down to pick up pennies. But understand the implications of what you do well enough to know if there&#8217;s serious money involved.</section>
]]></content:encoded>
			<wfw:commentRss>http://blog.unreasonable.com/check-the-price-tag/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Emacs, also a way of life</title>
		<link>http://blog.unreasonable.com/emacs-also-a-way-of-life/</link>
		<comments>http://blog.unreasonable.com/emacs-also-a-way-of-life/#comments</comments>
		<pubDate>Mon, 22 Dec 2014 22:53:16 +0000</pubDate>
		<dc:creator><![CDATA[lubkin]]></dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[editing]]></category>
		<category><![CDATA[emacs]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://blog.unreasonable.com/?p=236</guid>
		<description><![CDATA[If you&#8217;ve programmed or been a sysadmin on UNIX or Linux, you&#8217;ve undoubtedly already taken sides in emacs versus vi. You won&#8217;t be convinced to switch to the other text editor. It&#8217;s like trying to persuade someone to flip allegiance between the Red Sox and the Yankees. If you haven&#8217;t,... <a href="http://blog.unreasonable.com/emacs-also-a-way-of-life/" class="readmore">Read more</a>]]></description>
				<content:encoded><![CDATA[<aside class="postimage"><a href="http://www.amazon.com/gp/product/0596006489/ref=as_li_tl?ie=UTF8&#038;camp=1789&#038;creative=9325&#038;creativeASIN=0596006489&#038;linkCode=as2&#038;tag=unreasonablesoft&#038;linkId=LO7DGESD7QVRNGLB"><img border="0" src="http://blog.unreasonable.com/wp-content/uploads/2014/12/large-emacs.jpg" width="189" height="250"  title="Learning GNU Emacs, 3rd Edition on Amazon" class="bordered"></a></aside>
<section>If you&#8217;ve programmed or been a sysadmin on UNIX or Linux, you&#8217;ve undoubtedly already taken sides in <a href="http://www.slate.com/articles/technology/bitwise/2014/05/oldest_software_rivalry_emacs_and_vi_two_text_editors_used_by_programmers.html" title="The Oldest Rivalry in Computing (Slate Magazine)">emacs versus vi</a>. You won&#8217;t be convinced to switch to the other text editor. It&#8217;s like trying to persuade someone to flip allegiance between the Red Sox and the Yankees. </p>
<p>If you haven&#8217;t, be aware that <a href="http://www.gnu.org/software/emacs/" title="GNU Emacs project">GNU Emacs</a> is a very powerful text editor that probably runs on any computer you&#8217;ve ever edited a file on or ever will. Although calling it a text editor is a profound understatement. It could as easily be considered a software development environment (IDE), an office suite, or a personal information manager (PIM).</p>
<p><a href="http://www.amazon.com/gp/product/0596006489/ref=as_li_tl?ie=UTF8&#038;camp=1789&#038;creative=9325&#038;creativeASIN=0596006489&#038;linkCode=as2&#038;tag=unreasonablesoft&#038;linkId=66VRRKM7Q4N7X57G"><i>Learning GNU Emacs, 3rd Edition</i></a> is an excellent way to get started. Yes, the book was last revised in 2004. But even the 1991 first edition is still useful—one of the strengths of Emacs is that the basics are stable.<span id="more-236"></span></p>
<p>For that matter, the commands I learned ten years before that still work. I have been using some form of Emacs for over thirty years. As a tool, it&#8217;s an old reliable. With a handle worn down to comfortably fit my hand perfectly. I&#8217;ll bring it up here when I think of something to share that&#8217;s especially useful or satisfying.</p>
<p>One problem is terminology. Emacs has different terms and notation than you may be used to. Although, like Time Lords, we were there first. I&#8217;ll elaborate as we go. But a few essentials first. </p>
<p>Every one of the thousands of commands available has a name. The command to move to the previous line is called <code>previous-line</code>. As such, you can run it by <code>&lt;Esc&gt; x previous-line &lt;Enter&gt;</code>. Since it&#8217;s frequently used, and you&#8217;d never get any work done if you had to type all that, it comes <em>bound</em> to the key-combination <code>&lt;Ctrl&gt;+p</code>. And if your keyboard has arrow keys, it&#8217;s <em>also</em> bound to &#8593;.</p>
<p>If you don&#8217;t like that, you can change it. Switch the key-combination to something easier for you to remember. Or take a command you use often that doesn&#8217;t have a key-combination and assign it to one.</p>
<p>When discussing Emacs, though, refer to the standard key assignments. And remember, a command&#8217;s real name is the text version, not the key assignment.</p>
<p>Also, the way key assignments are written are different. <code>C-p</code> is what PC users know as <code>&lt;Ctrl&gt;+p</code>. <code>S-p</code> is <code>&lt;Shift&gt;+p</code>. <code>M-p</code> is <code>&lt;Alt&gt;+p</code>. (The M is for &#8216;meta.&#8217;) </p>
<p>And they can be combined: <code>C-S-p</code>, <code>C-M-p</code>, <code>M-S-p</code>, or <code>C-M-p</code>, or even <code>C-M-S-p</code>.</p>
<p>If you&#8217;re ever confused, the command <code>M-x apropos</code> helps you find commands whose name includes your search term, e.g. searching on <em>capitalize</em> reports <code>capitalize</code>, <code>capitalize-region</code>, <code>capitalize-word</code>, <code>capitalized-words-mode</code>, and <code>cua-capitalize-rectangle</code>. You can even search by regular expression if you feel like showing off.</p>
<p>The command <code>M-x describe-key</code> (bound by default to <code>C-h k</code>) tells you what, if anything, a key or key/mouse combination will do. After entering the command, you&#8217;ll be prompted to use the key or mouse/key combination you&#8217;re curious about. But be aware that <code>describe-key</code> distinguishes between the different keys that have the same labels.</p>
<p>For example, the * above the 8 in the main keyboard is considered a different key from the * that&#8217;s on a numeric keypad (where its Emacs name is <code>kp-multiply</code>). I&#8217;ve chosen to use the keypad keys for different purposes, e.g., in my setup the keypad&#8217;s * inserts a &bull; instead of an asterisk.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.unreasonable.com/emacs-also-a-way-of-life/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Beware of strange faces in dark dingy places</title>
		<link>http://blog.unreasonable.com/strange-faces/</link>
		<comments>http://blog.unreasonable.com/strange-faces/#comments</comments>
		<pubDate>Wed, 17 Dec 2014 15:06:00 +0000</pubDate>
		<dc:creator><![CDATA[lubkin]]></dc:creator>
				<category><![CDATA[Interviewing]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.unreasonable.com/?p=42</guid>
		<description><![CDATA[I&#8217;ve been on job interviews where the interviewer writes the equivalent of char *(*(*a[])())() on the whiteboard and asks what it declares. I usually answer that I could probably figure it out but I&#8217;m not going to try. If we, smart as we are, have to scrunch forehead to decipher... <a href="http://blog.unreasonable.com/strange-faces/" class="readmore">Read more</a>]]></description>
				<content:encoded><![CDATA[<p>I&#8217;ve been on job interviews where the interviewer writes the equivalent of <code>char *(*(*a[])())()</code> on the whiteboard and asks what it declares.</p>
<p>I usually answer that I could probably <a href="http://cdecl.ridiculousfish.com/?q=char+*%28*%28*a[]%29%28%29%29%28%29">figure it out</a> but I&#8217;m not going to try.</p>
<p>If we, smart as we are, have to scrunch forehead to decipher a line of code, it&#8217;s probably a mistake to have written it that way.</p>
<p>If it&#8217;s unclear to you now, it will probably be less clear when you look at it again in six months. Less clear to the engineer who has to fix it after you&#8217;ve moved on. That way lies bugs.</p>
<p>Further, if the code relies on an advanced or obscure feature, who says that feature works correctly? It&#8217;s probably also a confusing facet of the language for whoever wrote the compiler code. And their interpretation might not match what the standard actually requires. Or how the authors of another compiler interpret it.</p>
<p>Let alone whether you can readily translate your approach into another language. Which is handy.</p>
<p>Sometimes a complicated construct really is the best solution. When it is, write as clear a comment as you can that explains what it does, why it&#8217;s correct, and why apparent alternatives wouldn&#8217;t have worked.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.unreasonable.com/strange-faces/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
