<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Posts on Free Range Bits</title>
    <link>https://freerangebits.com/posts/</link>
    <description>Recent content in Posts on Free Range Bits</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-us</language>
    <lastBuildDate>Mon, 24 Feb 2025 12:23:47 +0100</lastBuildDate>
    <atom:link href="https://freerangebits.com/posts/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Automatic Theme Switching in Emacs</title>
      <link>https://freerangebits.com/posts/2025/02/emacs-light-dark/</link>
      <pubDate>Mon, 24 Feb 2025 12:23:47 +0100</pubDate>
      <guid>https://freerangebits.com/posts/2025/02/emacs-light-dark/</guid>
      <description>&lt;img alt=&#34;Screenshot showing both a light and dark theme applied.&#34; src=&#34;light-dark.png&#34;&gt;&#xA;&lt;p&gt;I&amp;rsquo;m a dark theme nerd.  Partially because of the hacker aesthetic, but&#xA;mostly because I prefer to work in dark environments and light themes&#xA;turn computer screens into floodlights.&lt;/p&gt;&#xA;&lt;p&gt;However, in well lit rooms (or when working outdoors) dark themes&#xA;become completely unreadable.  Such is the case in my office during&#xA;the morning hours.  Naturally, I figured out how to change the system&#xA;theme from the command line, immediately updating running GTK and Qt&#xA;applications.  The next step was getting Emacs to respond to the same&#xA;event.&lt;/p&gt;&#xA;&lt;h2 id=&#34;theme-switching-and-d-bus&#34;&gt;Theme Switching and D-Bus&lt;/h2&gt;&#xA;&lt;p&gt;Linux and other Unix-like operating systems use &lt;a href=&#34;https://www.freedesktop.org/wiki/Software/dbus/&#34; target=&#34;_blank&#34;&gt;D-Bus&lt;/a&gt; for&#xA;interprocess communication.  Applications can use D-Bus to register&#xA;methods and properties which can be accessed and monitored from any&#xA;D-Bus client.  For example, to find out whether the system is&#xA;currently using a light or dark theme, call the&#xA;&lt;code&gt;org.freedesktop.portal.Settings.Read&lt;/code&gt; method from the command line&#xA;using the &lt;code&gt;dbus-send&lt;/code&gt; tool:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;dbus-send --session --print-reply &lt;span style=&#34;color:#ae81ff&#34;&gt;\&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;&lt;/span&gt;  --dest&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;org.freedesktop.portal.Desktop &lt;span style=&#34;color:#ae81ff&#34;&gt;\&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;&lt;/span&gt;  /org/freedesktop/portal/desktop &lt;span style=&#34;color:#ae81ff&#34;&gt;\&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;&lt;/span&gt;  org.freedesktop.portal.Settings.Read &lt;span style=&#34;color:#ae81ff&#34;&gt;\&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;&lt;/span&gt;  string:org.freedesktop.appearance string:color-scheme&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This command will print &lt;code&gt;1&lt;/code&gt; when the system is using a dark theme and&#xA;&lt;code&gt;2&lt;/code&gt; when using a light theme (plus some other stuff you can ignore).&lt;/p&gt;&#xA;&lt;p&gt;With that information in hand we need to get Emacs to do two things:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Call this method when starting up and set its theme to match the&#xA;system, and&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Monitor the &lt;code&gt;color-scheme&lt;/code&gt; property and change its theme&#xA;automatically when the system theme changes.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;h2 id=&#34;emacs-groundwork&#34;&gt;Emacs Groundwork&lt;/h2&gt;&#xA;&lt;p&gt;In order to get Emacs to change its theme we&amp;rsquo;ll need a way to store&#xA;our preferred dark and light themes, and a way to change the current&#xA;theme based on the results of a D-Bus call:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-lisp&#34; data-lang=&#34;lisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;(defvar pjones:dark-theme &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;ef-maris-dark&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Default dark theme.&amp;#34;&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;(defvar pjones:light-theme &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;ef-maris-light&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Default light theme.&amp;#34;&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;(defun pjones:theme-from-dbus (value)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Change the theme based on a D-Bus property.&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;VALUE should be an integer or an arbitrarily nested list that&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;contains an integer.  When VALUE is equal to 2 then a light theme&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;will be selected, otherwise a dark theme will be selected.&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (load-theme (&lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt; (&lt;span style=&#34;color:#a6e22e&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;2&lt;/span&gt; (&lt;span style=&#34;color:#a6e22e&#34;&gt;car&lt;/span&gt; (flatten-list value)))&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                  pjones:light-theme&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                pjones:dark-theme)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              &lt;span style=&#34;color:#66d9ef&#34;&gt;t&lt;/span&gt;))&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You might be wondering what &lt;code&gt;flatten-list&lt;/code&gt; is for.  It turns out that&#xA;D-Bus gives two different types of answers depending on how you&#xA;requested a property.  When invoking a D-Bus method, the result comes&#xA;back to Emacs as a list.  For example, when requesting the current&#xA;color scheme using the &lt;code&gt;Read&lt;/code&gt; method the response will be &lt;code&gt;(1)&lt;/code&gt; or&#xA;&lt;code&gt;(2)&lt;/code&gt; depending on whether the current system theme is dark or light.&lt;/p&gt;&#xA;&lt;p&gt;However, when the property changes and D-Bus notifies clients that are&#xA;listening for change events, Emacs sees the property as a nested list.&#xA;In this case the color scheme value will be &lt;code&gt;((1))&lt;/code&gt; or &lt;code&gt;((2))&lt;/code&gt;.  The&#xA;call to &lt;code&gt;flatten-list&lt;/code&gt; ensures that both of these situations look the&#xA;same to the callback function (&lt;code&gt;pjones:theme-from-dbus&lt;/code&gt;).&lt;/p&gt;&#xA;&lt;p&gt;The only thing left is to convince Emacs to set its theme using&#xA;information from D-Bus.&lt;/p&gt;&#xA;&lt;h2 id=&#34;using-d-bus-from-within-emacs&#34;&gt;Using D-Bus from within Emacs&lt;/h2&gt;&#xA;&lt;p&gt;It should come as no surprise that Emacs ships with its own D-Bus&#xA;library.  To find out what the current color scheme is we can call the&#xA;&lt;code&gt;Read&lt;/code&gt; method using &lt;code&gt;dbus-call-method-asynchronously&lt;/code&gt;.  And then to be&#xA;notified when the system theme changes we can use&#xA;&lt;code&gt;dbus-register-signal&lt;/code&gt; to be notified when the &lt;code&gt;SettingChanged&lt;/code&gt; event&#xA;is emitted.  The arguments to these functions are a bit crazy but they&#xA;mirror those given to the &lt;code&gt;dbus-send&lt;/code&gt; tool.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-lisp&#34; data-lang=&#34;lisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;require&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;dbus&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;;; Set the current theme based on what the system theme is right now:&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;(dbus-call-method-asynchronously&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;   &lt;span style=&#34;color:#e6db74&#34;&gt;:session&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;org.freedesktop.portal.Desktop&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;   &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;/org/freedesktop/portal/desktop&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;   &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;org.freedesktop.portal.Settings&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;   &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Read&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;   &lt;span style=&#34;color:#a6e22e&#34;&gt;#&amp;#39;&lt;/span&gt;pjones:theme-from-dbus&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;   &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;org.freedesktop.appearance&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;   &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;color-scheme&amp;#34;&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;;; Register to be notified when the system theme changes:&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;(dbus-register-signal&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;   &lt;span style=&#34;color:#e6db74&#34;&gt;:session&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;org.freedesktop.portal.Desktop&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;   &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;/org/freedesktop/portal/desktop&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;   &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;org.freedesktop.portal.Settings&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;   &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;SettingChanged&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;   (lambda (path var value)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     (when (and (&lt;span style=&#34;color:#a6e22e&#34;&gt;string-equal&lt;/span&gt; path &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;org.freedesktop.appearance&amp;#34;&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                (&lt;span style=&#34;color:#a6e22e&#34;&gt;string-equal&lt;/span&gt; var &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;color-scheme&amp;#34;&lt;/span&gt;))&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;       (pjones:theme-from-dbus value))))&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;That&amp;rsquo;s it.  Switching the system color scheme should now cause Emacs&#xA;to update its theme too.  And when Emacs starts it should&#xA;automatically set its theme to match the system theme.&lt;/p&gt;&#xA;&lt;h2 id=&#34;command-line-theme-switching&#34;&gt;Command Line Theme Switching&lt;/h2&gt;&#xA;&lt;p&gt;I mentioned earlier that I figured out how to change the system theme&#xA;using the command line.  The most reliable way that I have found so&#xA;far is to use &lt;code&gt;gsettings&lt;/code&gt;, which also emits the &lt;code&gt;SettingChanged&lt;/code&gt; event&#xA;via D-Bus:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;gsettings set org.gnome.desktop.interface color-scheme prefer-dark&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;gsettings set org.gnome.desktop.interface gtk-theme Adwaita-dark&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;# or&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;gsettings set org.gnome.desktop.interface color-scheme prefer-light&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;gsettings set org.gnome.desktop.interface gtk-theme Adwaita&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The second invocation of &lt;code&gt;gsettings&lt;/code&gt; (changing the GTK theme) isn&amp;rsquo;t&#xA;strictly necessary.  However, I configured Qt to use the GTK theme and&#xA;this is the only way I could get Qt applications to also change their&#xA;color scheme as they don&amp;rsquo;t appear to respect the &lt;code&gt;color-scheme&lt;/code&gt;&#xA;setting.&lt;/p&gt;&#xA;&lt;p&gt;I also wrapped these commands up in XDG desktop entries so I could&#xA;invoke them from tools like Rofi.&lt;/p&gt;&#xA;&lt;h2 id=&#34;appendix-gtk-and-qt-themes&#34;&gt;Appendix: GTK and Qt Themes&lt;/h2&gt;&#xA;&lt;p&gt;It probably matters how I configured GTK and Qt, although these don&amp;rsquo;t&#xA;have anything to do with Emacs.  Basically, GTK is set to use the&#xA;&lt;code&gt;Adwaita-dark&lt;/code&gt; theme, and Qt is configured to use its &lt;code&gt;gtk3&lt;/code&gt; engine&#xA;which should follow the current GTK theme.  This works for almost all&#xA;Qt applications, although some refuse to update to the light theme.&lt;/p&gt;&#xA;&lt;p&gt;All of my GTK/Qt settings are done using &lt;a href=&#34;https://github.com/nix-community/home-manager&#34; target=&#34;_blank&#34;&gt;Home Manager&lt;/a&gt; in &lt;a href=&#34;https://github.com/pjones/desktop-scripts/blob/trunk/home/theme.nix&#34; target=&#34;_blank&#34;&gt;this&#xA;file&lt;/a&gt;.&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>Patching Instead of Pinning</title>
      <link>https://freerangebits.com/posts/2024/01/patch-instead-of-pin/</link>
      <pubDate>Sat, 06 Jan 2024 11:44:19 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2024/01/patch-instead-of-pin/</guid>
      <description>&lt;p&gt;In &lt;a href=&#34;https://freerangebits.com/posts/2023/12/gnupg-broke-emacs&#34;&gt;a previous post&lt;/a&gt; I showed how to work around a deadlock&#xA;between GnuPG and Emacs.  As a brief recap, GnuPG 2.4.1 introduced a&#xA;change in its output which breaks a protocol that Emacs relied on, so&#xA;I pinned GnuPG to version 2.4.0 on my system to avoid the bug.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&#34;https://github.com/DamienCassou&#34; target=&#34;_blank&#34;&gt;Damien Cassou&lt;/a&gt; reached out to me and expressed a&#xA;preferred way of dealing with this issue: patch the current version of&#xA;GnuPG so it doesn&amp;rsquo;t contain the bug.  This means we get to keep any&#xA;bug fixes and security updates in the most recent version without&#xA;having to suffer with the deadlock bug.&lt;/p&gt;&#xA;&lt;p&gt;I&amp;rsquo;m going to demonstrate how to apply a patch to GnuPG in nixpkgs, but&#xA;before that let&amp;rsquo;s review the Nix code for pinning GnuPG to version&#xA;2.4.0.&lt;/p&gt;&#xA;&lt;h2 id=&#34;pinning-the-gnupg-package&#34;&gt;Pinning the GnuPG Package&lt;/h2&gt;&#xA;&lt;p&gt;In the last post we looked at three different options for pinning&#xA;GnuPG:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;A nixpkgs overlay to replace GnuPG globally&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Replace the version of GnuPG that shows up in the system &lt;code&gt;PATH&lt;/code&gt;&#xA;via the NixOS module&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Replace the version of GnuPG that shows up in the user&#xA;environment via the Home Manager module&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;My preference was for the last option, using Home Manager:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-nix&#34; data-lang=&#34;nix&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;{ pkgs }:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;{&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  programs&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;gpg&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;package &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; pkgs&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;gnupg&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;overrideAttrs (orig: {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    version &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;2.4.0&amp;#34;&lt;/span&gt;;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    src &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; pkgs&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;fetchurl {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      url &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;mirror://gnupg/gnupg/gnupg-2.4.0.tar.bz2&amp;#34;&lt;/span&gt;;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      hash &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;sha256-HXkVjdAdmSQx3S4/rLif2slxJ/iXhOosthDGAPsMFIM=&amp;#34;&lt;/span&gt;;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    };&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  });&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;}&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;However, I didn&amp;rsquo;t really explain what was going on in that Nix code.&#xA;I&amp;rsquo;d like to give that a try now.&lt;/p&gt;&#xA;&lt;h2 id=&#34;overriding-nix-packages&#34;&gt;Overriding Nix Packages&lt;/h2&gt;&#xA;&lt;p&gt;One way to think about a package written in Nix is as a set of&#xA;attributes.  (Of course, this isn&amp;rsquo;t true, but it&amp;rsquo;s a useful analogy&#xA;and allows us to continue without having to talk about lazy evaluation&#xA;and fixpoints.)  These attribute sets are immutable so we can&amp;rsquo;t change&#xA;them.  But what we can do is build new packages from existing ones.&lt;/p&gt;&#xA;&lt;p&gt;This is done with the &lt;code&gt;overrideAttrs&lt;/code&gt; function, which allows us to&#xA;create a new package by replacing attributes in an existing package.&#xA;The argument to &lt;code&gt;overrideAttrs&lt;/code&gt; is a function that is given the&#xA;existing attributes and should return replacement attributes.&lt;/p&gt;&#xA;&lt;p&gt;In the Nix code above that pins GnuPG to version 2.4.0, I replaced the&#xA;&lt;code&gt;version&lt;/code&gt; and &lt;code&gt;src&lt;/code&gt; attributes.  The result is a new package based on&#xA;the existing GnuPG 2.4.1 package, except that the upstream source code&#xA;is now coming from the GnuPG 2.4.0 tarball.&lt;/p&gt;&#xA;&lt;p&gt;This won&amp;rsquo;t always work, but it does in this case because GnuPG 2.4.0&#xA;and 2.4.1 are so similar.  If I tried to update the GnuPG package by&#xA;replacing its source code with that of the Linux kernel things&#xA;wouldn&amp;rsquo;t turn out so nicely.&lt;/p&gt;&#xA;&lt;p&gt;The most interesting thing about &lt;code&gt;overrideAttrs&lt;/code&gt; is that we can&#xA;replace &lt;em&gt;any&lt;/em&gt; package attribute we want.  I&amp;rsquo;ve used this to great&#xA;effect over the years: adding shell commands to the end of install&#xA;scripts, changing compiler flags, installing files that were missed by&#xA;&lt;code&gt;make install&lt;/code&gt;, to name a few.&lt;/p&gt;&#xA;&lt;p&gt;And of course, we can use this to apply patches to the source code&#xA;before building.&lt;/p&gt;&#xA;&lt;h2 id=&#34;patching-the-package-instead&#34;&gt;Patching the Package Instead&lt;/h2&gt;&#xA;&lt;p&gt;Nix packages have an optional &lt;code&gt;patches&lt;/code&gt; attribute which is a list of&#xA;patch files to apply to the source code before building.  And thanks&#xA;to &lt;code&gt;overrideAttrs&lt;/code&gt; we can add patches to that list:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-nix&#34; data-lang=&#34;nix&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;final: prev:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;{&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  gnupg_plus_960877b &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; prev&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;gnupg&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;overrideAttrs (orig: {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    patches &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; (orig&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;patches or [ ]) &lt;span style=&#34;color:#f92672&#34;&gt;++&lt;/span&gt; [&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      (prev&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;fetchurl {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        url &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;https://github.com/gpg/gnupg/commit/960877b10f42ba664af4fb29130a3ba48141e64a.diff&amp;#34;&lt;/span&gt;;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        sha256 &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;0pa7rvy9i9w16njxdg6ly5nw3zwy0shv0v23l1mmi0b7jy7ldpvf&amp;#34;&lt;/span&gt;;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      })&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    ];&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  });&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;}&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This example is an overlay and is straight &lt;a href=&#34;https://github.com/pjones/tilde&#34; target=&#34;_blank&#34;&gt;out of my Nix&#xA;configuration&lt;/a&gt;.  It creates a &lt;a href=&#34;https://github.com/pjones/tilde/blob/4fb2d93c2fc475e48b457dd3b4ddda9f18fa0ea8/pkgs/overlay.nix#L31&#34; target=&#34;_blank&#34;&gt;new package&lt;/a&gt;&#xA;(&lt;code&gt;gnupg_plus_960877b&lt;/code&gt;) from the exiting &lt;code&gt;gnupg&lt;/code&gt; package by replacing&#xA;the &lt;code&gt;patches&lt;/code&gt; attribute with one that includes the fix for the&#xA;deadlock bug.&lt;/p&gt;&#xA;&lt;p&gt;I ensure that I&amp;rsquo;m including patches from the package I&amp;rsquo;m modifying by&#xA;using the original patches list (&lt;code&gt;orig.patches&lt;/code&gt;), or if that&amp;rsquo;s&#xA;missing, an empty list.  Then I append (&amp;quot;&lt;code&gt;++&lt;/code&gt;&amp;quot;) a list with one&#xA;element which uses &lt;code&gt;fetchurl&lt;/code&gt; to get the patch I want.&lt;/p&gt;&#xA;&lt;p&gt;The only thing left to do is tell Home Manager to use this new&#xA;package:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-nix&#34; data-lang=&#34;nix&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;{ pkgs }:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;{&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  programs&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;gpg&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;package &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; pkgs&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;gnupg_plus_960877b;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;}&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&#34;conclusion&#34;&gt;Conclusion&lt;/h2&gt;&#xA;&lt;p&gt;Nix and nixpkgs make it very easy to alter an existing package thanks&#xA;to the &lt;code&gt;overrideAttrs&lt;/code&gt; function.  Using nixpkgs overlays we can even&#xA;replace a package globally throughout the package set.&lt;/p&gt;&#xA;&lt;p&gt;Sometimes we may want to alter a package&amp;rsquo;s &lt;code&gt;src&lt;/code&gt; attribute to&#xA;downgrade (or upgrade) it to another version.  In this case we took&#xA;&lt;a href=&#34;https://github.com/DamienCassou&#34; target=&#34;_blank&#34;&gt;Damien Cassou&amp;rsquo;s&lt;/a&gt; advice and applied a patch to the&#xA;exiting GnuPG package.&lt;/p&gt;&#xA;&lt;hr&gt;&#xA;&lt;p&gt;&lt;strong&gt;Update (February 23, 2024)&lt;/strong&gt;: GnuPG 2.4.4 has been released and it&#xA;contains the patch mentioned in this post.  In other words, GnuPG&#xA;2.4.4 and Emacs work nicely together once again.&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>Archiving in Org Mode</title>
      <link>https://freerangebits.com/posts/2024/01/archiving-in-org-mode/</link>
      <pubDate>Thu, 04 Jan 2024 12:45:09 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2024/01/archiving-in-org-mode/</guid>
      <description>&lt;p&gt;As some of you may know, I practically live inside &lt;a href=&#34;https://freerangebits.com/tags/emacs/&#34;&gt;Emacs&lt;/a&gt;.&#xA;And like a lot of Emacs users a good portion of that time is spend in&#xA;&lt;a href=&#34;https://orgmode.org/&#34; target=&#34;_blank&#34;&gt;org-mode&lt;/a&gt;, a package that is hard to describe due to its&#xA;overwhelming large number of features.&lt;/p&gt;&#xA;&lt;p&gt;One of the many ways I use org-mode is to implement a Getting Things&#xA;Done (GTD) workflow.  That is, managing all of the projects that I&amp;rsquo;m&#xA;trying to push forward as well as all of the routine recurring tasks&#xA;that I have to deal with on a daily basis.&lt;/p&gt;&#xA;&lt;p&gt;The issue that every org-mode user eventually has to wrestle with is&#xA;what to do with all those completed projects and obsolete tasks.  For&#xA;some projects the obvious answer is to simply delete them.  This is&#xA;especially true if you&amp;rsquo;re using a version control system to track your&#xA;org-mode files.  But if you regularly need to refer to completed&#xA;projects/tasks (i.e. &amp;ldquo;what was that crazy query I ran last time?&amp;rdquo;)&#xA;then archiving is a better option.&lt;/p&gt;&#xA;&lt;h2 id=&#34;archiving-options-in-org-mode&#34;&gt;Archiving Options in org-mode&lt;/h2&gt;&#xA;&lt;p&gt;In org-mode, archiving is the process of moving a subtree somewhere&#xA;else when it&amp;rsquo;s no longer needed&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;.  The destination for an&#xA;archived subtree is taken from the &lt;code&gt;org-archive-location&lt;/code&gt; variable.&lt;/p&gt;&#xA;&lt;p&gt;By default, org-mode will move the subtree to another file whose name&#xA;is derived from the name of the current file by appending &amp;ldquo;&lt;code&gt;_archive&lt;/code&gt;&amp;rdquo;&#xA;to the name, but before the extension.  That said, like everything in&#xA;Emacs, the options for configuring the archive destination are&#xA;virtually limitless.&lt;/p&gt;&#xA;&lt;p&gt;A really common way to configure archiving is to use a dedicated file,&#xA;usually &lt;code&gt;archive.org&lt;/code&gt;.  Whether you use a single archive file or the&#xA;default strategy of using a file named after the current one, you will&#xA;ultimately run into the same problem, huge unwieldy org-mode files.&lt;/p&gt;&#xA;&lt;p&gt;I think there&amp;rsquo;s a better way to archive projects and tasks: use a lot&#xA;of small files.  Specifically, when I archive a subtree in org-mode I&#xA;send the subtree to the current day&amp;rsquo;s journal entry.&lt;/p&gt;&#xA;&lt;h2 id=&#34;using-the-org-roam-journal&#34;&gt;Using the org-roam Journal&lt;/h2&gt;&#xA;&lt;p&gt;I maintain my personal knowledge base in org-mode thanks to&#xA;&lt;a href=&#34;https://www.orgroam.com/&#34; target=&#34;_blank&#34;&gt;org-roam&lt;/a&gt;.  One of its features is the ability to manage&#xA;journal entries.  The journal system in org-roam is simply a&#xA;collection of subtrees in a one-file-per-day organization scheme.  In&#xA;other words, each day gets a new org-mode file and throughout the day&#xA;I add headings to the file in order to record certain events.&lt;/p&gt;&#xA;&lt;p&gt;When I archive a subtree from somewhere in my vast collection of&#xA;notes, org-mode stores it in one of my journal files.  The specific&#xA;journal file used is based on the date chosen from a prompt when I run&#xA;the following archiving function:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-emacs-lisp&#34; data-lang=&#34;emacs-lisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;(defun pjones:org-archive-subtree-to-daily (&lt;span style=&#34;color:#66d9ef&#34;&gt;&amp;amp;optional&lt;/span&gt; _find-done)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Arhive the current subtree to the roam daily file.&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (interactive)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (require &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;org-roam&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (when-let* ((today (save-excursion&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                       (org-roam-dailies-goto-date &lt;span style=&#34;color:#66d9ef&#34;&gt;nil&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;d&amp;#34;&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;                       (&lt;span style=&#34;color:#a6e22e&#34;&gt;buffer-file-name&lt;/span&gt;)))&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              (org-archive-location&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;               (&lt;span style=&#34;color:#a6e22e&#34;&gt;concat&lt;/span&gt; today &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;::* Archived From %s&amp;#34;&lt;/span&gt;)))&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (org-archive-subtree &lt;span style=&#34;color:#ae81ff&#34;&gt;0&lt;/span&gt;)))&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You can tell org-mode that you want this to be your archiving function&#xA;by setting &lt;code&gt;org-archive-default-command&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-emacs-lisp&#34; data-lang=&#34;emacs-lisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;(custom-set-variables&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#f92672&#34;&gt;&amp;#39;&lt;/span&gt;(org-archive-default-command &lt;span style=&#34;color:#a6e22e&#34;&gt;#&amp;#39;&lt;/span&gt;pjones:org-archive-subtree-to-daily))&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;After which you can archive the current subtree with the normal key&#xA;binding &amp;ldquo;&lt;code&gt;C-c C-x C-a&lt;/code&gt;&amp;rdquo;.  This leaves &amp;ldquo;&lt;code&gt;C-c C-x C-s&lt;/code&gt;&amp;rdquo; alone if you&#xA;want to use the built in system which relies on&#xA;&lt;code&gt;org-archive-location&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;(Note: I have both daily and monthly journal files.  To avoid being&#xA;asked which one I want to archive to I pass &amp;ldquo;&lt;code&gt;d&lt;/code&gt;&amp;rdquo; as the second&#xA;argument to &lt;code&gt;org-roam-dailies-goto-date&lt;/code&gt;.  This bypasses the prompt&#xA;and goes directly to the daily journal file.)&lt;/p&gt;&#xA;&lt;h2 id=&#34;conclusion&#34;&gt;Conclusion&lt;/h2&gt;&#xA;&lt;p&gt;I find it easier to manage many small files verses a small number of&#xA;huge files.  To avoid a massive &lt;code&gt;archive.org&lt;/code&gt; file I archive subtrees&#xA;into my org-roam journal.  This makes it a lot easier to find what I&amp;rsquo;m&#xA;looking for and provides a bit of context when found.  And it pairs&#xA;perfectly with &lt;a href=&#34;https://github.com/dajva/rg.el&#34; target=&#34;_blank&#34;&gt;&lt;code&gt;rg-project&lt;/code&gt;&lt;/a&gt; and&#xA;&lt;a href=&#34;https://github.com/minad/consult&#34; target=&#34;_blank&#34;&gt;&lt;code&gt;consult-ripgrep&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;div class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;&#xA;&lt;hr&gt;&#xA;&lt;ol&gt;&#xA;&lt;li id=&#34;fn:1&#34;&gt;&#xA;&lt;p&gt;You can also tag the current subtree with the &lt;code&gt;ARCHIVE&lt;/code&gt;&#xA;tag which darkens the heading and keeps the tree collapsed.  This can&#xA;be done with the &lt;code&gt;org-toggle-archive-tag&lt;/code&gt; function or the &amp;ldquo;&lt;code&gt;C-c C-x a&lt;/code&gt;&amp;rdquo; key binding.&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;/div&gt;&#xA;</description>
    </item>
    <item>
      <title>Pinning GnuPG with nixpkgs</title>
      <link>https://freerangebits.com/posts/2023/12/gnupg-broke-emacs/</link>
      <pubDate>Sun, 31 Dec 2023 10:49:30 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2023/12/gnupg-broke-emacs/</guid>
      <description>&lt;p&gt;GnuPG 2.4.1 was released all the way back in May but I failed to&#xA;notice until I upgraded to NixOS 23.11 a few weeks ago.  And I only&#xA;noticed because Emacs froze when I tried to save an encrypted file.&#xA;It didn&amp;rsquo;t take me long to realize it was due to a &lt;a href=&#34;https://dev.gnupg.org/T6481&#34; target=&#34;_blank&#34;&gt;change in&#xA;GnuPG&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;h2 id=&#34;emacs-and-encrypted-files&#34;&gt;Emacs and Encrypted Files&lt;/h2&gt;&#xA;&lt;p&gt;When working with encrypted files Emacs goes to great lengths to&#xA;ensure the unencrypted cleartext is never written to the file system.&#xA;It does this by invoking GnuPG directly and communicating with it&#xA;using pipes.  Thus, to write to an encrypted file, Emacs sends the&#xA;cleartext down the pipe and GnuPG writes the encrypted contents to a&#xA;file.&lt;/p&gt;&#xA;&lt;p&gt;Just before Emacs sends the cleartext down the pipe to GnuPG it waits&#xA;for GnuPG to signal that it&amp;rsquo;s ready to read cleartext.  The problem&#xA;with GnuPG (versions 2.4.1 through 2.4.3) is that it sends this signal&#xA;&lt;em&gt;after&lt;/em&gt; it reads from standard input.  In other words, both Emacs and&#xA;GnuPG are waiting for one another at the same time, resulting in a&#xA;classic I/O deadlock.&lt;/p&gt;&#xA;&lt;h2 id=&#34;the-workaround&#34;&gt;The Workaround&lt;/h2&gt;&#xA;&lt;p&gt;The Emacs maintainers &lt;a href=&#34;https://debbugs.gnu.org/cgi/bugreport.cgi?bug=63256&#34; target=&#34;_blank&#34;&gt;consider this situation&lt;/a&gt; a bug in GnuPG.&#xA;And after a few days the GnuPG maintainers &lt;a href=&#34;https://dev.gnupg.org/rG960877b10f42ba664af4fb29130a3ba48141e64a&#34; target=&#34;_blank&#34;&gt;fixed the bug&lt;/a&gt;.  It&#xA;will be part of GnuPG 2.4.4 release.  Until then the solution is to&#xA;downgrade GnuPG.  The Emacs &lt;code&gt;PROBLEMS&lt;/code&gt; file says:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;The only known workaround is to downgrade to a version of GnuPG&#xA;older than 2.4.1 (or, in the future, upgrade to a newer version&#xA;which solves the problem, when such a fixed version becomes&#xA;available).&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;h2 id=&#34;pinning-packages-in-nixpkgs&#34;&gt;Pinning Packages in nixpkgs&lt;/h2&gt;&#xA;&lt;p&gt;This presents the perfect opportunity to demonstrate several ways that&#xA;nixpkgs ecosystem allows us to solve the problem of downgrading a&#xA;package, sometimes called package pinning.&lt;/p&gt;&#xA;&lt;p&gt;The easiest solution is to use an &lt;em&gt;overlay&lt;/em&gt;, a function that takes the&#xA;current package set and returns a new package set.  The overlay below&#xA;replaces the &lt;code&gt;gnupg&lt;/code&gt; package with one pinned at version 2.4.0:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-nix&#34; data-lang=&#34;nix&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;final: prev:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;{&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  gnupg &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; prev&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;gnupg&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;overrideAttrs (orig: {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    version &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;2.4.0&amp;#34;&lt;/span&gt;;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    src &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; prev&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;fetchurl {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      url &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;mirror://gnupg/gnupg/gnupg-2.4.0.tar.bz2&amp;#34;&lt;/span&gt;;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      hash &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;sha256-HXkVjdAdmSQx3S4/rLif2slxJ/iXhOosthDGAPsMFIM=&amp;#34;&lt;/span&gt;;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    };&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  });&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;}&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Notice that the overlay function actually takes two arguments.  The&#xA;second argument (&lt;code&gt;prev&lt;/code&gt;) is the previous package set, the one we want&#xA;to alter.  Since overlays can be chained together we may be&#xA;manipulating the original package set or one from a previous overlay.&lt;/p&gt;&#xA;&lt;p&gt;Sometimes we need access to the package set the way it will be after&#xA;all overlays have been applied.  For example, wanting to use a&#xA;dependency from a later overlay in the current overlay.  In this case&#xA;the first argument (&lt;code&gt;final&lt;/code&gt;) comes in handy, it&amp;rsquo;s the final package&#xA;set after all overlays have been applied.  (This is possible thanks to&#xA;Nix being a lazy language and the use of &lt;a href=&#34;https://en.wikipedia.org/wiki/Fixed-point_combinator&#34; target=&#34;_blank&#34;&gt;fixpoints&lt;/a&gt;.)&lt;/p&gt;&#xA;&lt;h2 id=&#34;livin-la-vida-gentoo&#34;&gt;Livin&amp;rsquo; La Vida Gentoo&lt;/h2&gt;&#xA;&lt;p&gt;Unfortunately, using an overlay to pin GnuPG comes at a cost.  It&#xA;turns out that GnuPG is a dependency in &lt;em&gt;a lot&lt;/em&gt; of packages.  This&#xA;means that after applying the overlay, nixpkgs will determine that all&#xA;of those packages need to be rebuilt, and we won&amp;rsquo;t be able to take&#xA;advantage of the binary cache (because the cache was built with GnuPG&#xA;2.4.1).&lt;/p&gt;&#xA;&lt;p&gt;I don&amp;rsquo;t have the patience of a Gentoo user and compiling a ton of&#xA;packages from source isn&amp;rsquo;t my idea of a good time.  Besides, it&amp;rsquo;s a&#xA;terrible use of the power grid.  Thankfully, we have other options.&lt;/p&gt;&#xA;&lt;h2 id=&#34;the-nixos-module&#34;&gt;The NixOS Module&lt;/h2&gt;&#xA;&lt;p&gt;If you use NixOS then the easiest way to install and configure GnuPG&#xA;is via the NixOS module:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-nix&#34; data-lang=&#34;nix&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;{&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  programs&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;gnupg&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;enable &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;true&lt;/span&gt;;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;}&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The NixOS module also has a &lt;a href=&#34;https://search.nixos.org/options?query=programs.gnupg&#34; target=&#34;_blank&#34;&gt;&lt;code&gt;package&lt;/code&gt; option&lt;/a&gt; so users&#xA;can override the GnuPG package.  Taking the overlay code from above we&#xA;can write our own NixOS module and load it into our system&#xA;configuration (via the normal &lt;code&gt;imports&lt;/code&gt; list mechanism):&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-nix&#34; data-lang=&#34;nix&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;{ pkgs }:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;{&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  programs&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;gnupg&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;package &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; pkgs&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;gnupg&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;overrideAttrs (orig: {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    version &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;2.4.0&amp;#34;&lt;/span&gt;;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    src &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; pkgs&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;fetchurl {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      url &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;mirror://gnupg/gnupg/gnupg-2.4.0.tar.bz2&amp;#34;&lt;/span&gt;;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      hash &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;sha256-HXkVjdAdmSQx3S4/rLif2slxJ/iXhOosthDGAPsMFIM=&amp;#34;&lt;/span&gt;;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    };&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  });&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;}&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Similar to the overlay method, pinning GnuPG through the NixOS module&#xA;affects the version of GnuPG in the system &lt;code&gt;PATH&lt;/code&gt;.  But unlike with&#xA;overlays, other packages still see the original version of GnuPG.&#xA;Since we&amp;rsquo;re not infecting other packages with a changed GnuPG, nothing&#xA;needs to be recompiled.&lt;/p&gt;&#xA;&lt;p&gt;Now, I&amp;rsquo;m &lt;a href=&#34;https://github.com/pjones/tilde&#34; target=&#34;_blank&#34;&gt;a very happy user of NixOS&lt;/a&gt;, but this isn&amp;rsquo;t my&#xA;preferred solution.  And, of course, it doesn&amp;rsquo;t work at all for&#xA;non-NixOS users.  The last way we&amp;rsquo;ll look at pinning GnuPG works for&#xA;any nixpkgs user and also doesn&amp;rsquo;t suffer from the overhead of the&#xA;overlay technique.&lt;/p&gt;&#xA;&lt;h2 id=&#34;the-home-manager-module&#34;&gt;The Home Manager Module&lt;/h2&gt;&#xA;&lt;p&gt;I&amp;rsquo;m a huge fan of &lt;a href=&#34;https://github.com/nix-community/home-manager&#34; target=&#34;_blank&#34;&gt;Home Manager&lt;/a&gt;.  It allows nixpkgs&#xA;users take all the awesomeness of NixOS to other Linux distributions&#xA;and even to closed operating systems like &lt;a href=&#34;https://github.com/LnL7/nix-darwin/tree/master&#34; target=&#34;_blank&#34;&gt;macOS&lt;/a&gt;,&#xA;&lt;a href=&#34;https://github.com/nix-community/nix-on-droid&#34; target=&#34;_blank&#34;&gt;Android&lt;/a&gt;, and even &lt;a href=&#34;https://github.com/nix-community/NixOS-WSL&#34; target=&#34;_blank&#34;&gt;Windows&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;The Home Manager module for GnuPG is very similar to the NixOS module&#xA;and also includes a &lt;a href=&#34;https://nix-community.github.io/home-manager/options.xhtml#opt-programs.gpg.package&#34; target=&#34;_blank&#34;&gt;&lt;code&gt;package&lt;/code&gt; option&lt;/a&gt;.  That means we&#xA;can pin GnuPG in our user environment similar to how the NixOS module&#xA;allowed us to pin it at the system level.  The following Nix code can&#xA;be loaded into your Home Manager configuration through the normal&#xA;&lt;code&gt;imports&lt;/code&gt; list mechanism, just like with NixOS modules:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-nix&#34; data-lang=&#34;nix&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;{ pkgs }:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;{&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  programs&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;gpg&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;package &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; pkgs&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;gnupg&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;overrideAttrs (orig: {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    version &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;2.4.0&amp;#34;&lt;/span&gt;;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    src &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; pkgs&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;fetchurl {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      url &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;mirror://gnupg/gnupg/gnupg-2.4.0.tar.bz2&amp;#34;&lt;/span&gt;;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      hash &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;sha256-HXkVjdAdmSQx3S4/rLif2slxJ/iXhOosthDGAPsMFIM=&amp;#34;&lt;/span&gt;;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    };&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  });&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;}&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&#34;a-warning-about-other-workarounds&#34;&gt;A Warning About Other Workarounds&lt;/h2&gt;&#xA;&lt;p&gt;It&amp;rsquo;s important to point out that the correct solution to this problem&#xA;between Emacs and GnuPG is to fix &lt;em&gt;GnuPG&lt;/em&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I&amp;rsquo;ve seen people on social media sites like Reddit suggesting a hack&#xA;to Emacs to resolve the problem.  Specifically, people are putting the&#xA;following in their Emacs configuration:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-elisp&#34; data-lang=&#34;elisp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;fset&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;epg-wait-for-status&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;ignore&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Don&amp;rsquo;t do this!&lt;/strong&gt;  This is not a valid fix and may lead to file&#xA;corruption when reading/writing encrypted files.&lt;/p&gt;&#xA;&lt;p&gt;This bit of hackery replaces the &lt;code&gt;epg-wait-for-status&lt;/code&gt; function with&#xA;one that ignores its arguments and always returns &lt;code&gt;nil&lt;/code&gt;.  That&#xA;function is used throughout the EPG library in Emacs, not just when&#xA;writing files through GnuPG.  Again, &lt;em&gt;please don&amp;rsquo;t do this&lt;/em&gt;.&lt;/p&gt;&#xA;&lt;h2 id=&#34;conclusion&#34;&gt;Conclusion&lt;/h2&gt;&#xA;&lt;p&gt;We&amp;rsquo;ve looked at three different ways of pinning a package in&#xA;nixpkgs:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Using an overlay function.&lt;/p&gt;&#xA;&lt;p&gt;This is usually my go-to solution.  But in this case GnuPG is&#xA;used in so many other packages that it caused massive rebuilds.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Pinning via the NixOS &lt;a href=&#34;https://search.nixos.org/options?query=programs.gnupg&#34; target=&#34;_blank&#34;&gt;&lt;code&gt;programs.gnupg.package&lt;/code&gt;&lt;/a&gt;&#xA;option.&lt;/p&gt;&#xA;&lt;p&gt;This works by only changing the version of GnuPG installed in the&#xA;system &lt;code&gt;PATH&lt;/code&gt;.  If you use NixOS (and not Home Manager) this is&#xA;the way to go.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Pinning via the Home Manager&#xA;&lt;a href=&#34;https://nix-community.github.io/home-manager/options.xhtml#opt-programs.gpg.package&#34; target=&#34;_blank&#34;&gt;&lt;code&gt;programs.gpg.package&lt;/code&gt;&lt;/a&gt; option.&lt;/p&gt;&#xA;&lt;p&gt;This is my preferred solution because it works nearly everywhere&#xA;thanks to Home Manager.  It replaces the version of GnuPG in your&#xA;user &lt;code&gt;PATH&lt;/code&gt;, leaving the system &lt;code&gt;PATH&lt;/code&gt; and the rest of nixpkgs&#xA;alone.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;&lt;a href=&#34;https://www.latacora.com/blog/2019/07/16/the-pgp-problem/&#34; target=&#34;_blank&#34;&gt;Like many others&lt;/a&gt;, my frustration with GnuPG is nearing&#xA;its breaking point.  Over the last 20 years I&amp;rsquo;ve sent/received no more&#xA;than a handful of encrypted emails.  My use of GnuPG at this point is&#xA;limited to encrypting files in my &lt;a href=&#34;https://www.passwordstore.org/&#34; target=&#34;_blank&#34;&gt;password store&lt;/a&gt; and signing&#xA;Git commits.  It&amp;rsquo;s becoming less clear why I put up with the burden of&#xA;managing my GnuPG key and the occasional upgrade problem.&lt;/p&gt;&#xA;&lt;p&gt;Perhaps I&amp;rsquo;ll finally switch to &lt;a href=&#34;https://github.com/FiloSottile/age/&#34; target=&#34;_blank&#34;&gt;age&lt;/a&gt; over the next major holiday&#xA;break.  (I probably won&amp;rsquo;t find the time, but here&amp;rsquo;s hoping for the&#xA;best.)&lt;/p&gt;&#xA;&lt;hr&gt;&#xA;&lt;p&gt;&lt;strong&gt;Update (January 6, 2024)&lt;/strong&gt;: A better solution may be to patch the&#xA;current version of GnuPG so it doesn&amp;rsquo;t have the deadlock bug.  I&#xA;explore that option &lt;a href=&#34;https://freerangebits.com/posts/2024/01/patch-instead-of-pin&#34;&gt;in this post&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Update (February 23, 2024)&lt;/strong&gt;: GnuPG 2.4.4 has been released and&#xA;fixes the problems mentioned in this post.&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>Why the world needs Haskell</title>
      <link>https://freerangebits.com/posts/2013/07/why-haskell/</link>
      <pubDate>Tue, 09 Jul 2013 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2013/07/why-haskell/</guid>
      <description>&lt;p&gt;This is a technical review of Haskell and why software developers&#xA;should care about functional programming.  For a non-technical review&#xA;of why your company should be using Haskell you might want to watch&#xA;&lt;a href=&#34;http://www.youtube.com/watch?v=Fqi0Xu2Enaw&#34; target=&#34;_blank&#34;&gt;this introduction to Haskell video&lt;/a&gt; by FP Complete.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;TL;DR:&lt;/strong&gt; Writing high-quality, bug-free software isn&amp;rsquo;t easy.&#xA;&lt;a href=&#34;https://freerangebits.com/tags/haskell/&#34;&gt;Haskell&lt;/a&gt; (and similar languages) provide the programmer with the&#xA;tools necessary to get closer than ever before.  By removing entire&#xA;categories of bugs (such as those caused by null pointers and nil&#xA;objects, type coercions, accidental mutation, etc.) and introducing a&#xA;powerful type system, programmers can write better code in the same&#xA;amount of time (and often less) than more traditional languages.&lt;/p&gt;&#xA;&lt;h2 id=&#34;null-pointers-and-undefined-values&#34;&gt;Null Pointers and Undefined Values&lt;/h2&gt;&#xA;&lt;p&gt;The code we write eventually executes in the real world and things&#xA;don&amp;rsquo;t always go as we would like.  Network connections drop while&#xA;you&amp;rsquo;re reading from sockets, disk space goes to zero while writing to&#xA;files, and people trip over power cables while balancing huge cups of&#xA;double foam lattes.&lt;/p&gt;&#xA;&lt;p&gt;These are exceptional situations that we don&amp;rsquo;t have much control over&#xA;and which we have to deal with gracefully.  But what about errors that&#xA;we do have control over?  You know, the exceptions we create as&#xA;programmers every day when we dereference a null pointer or call a&#xA;method on a nil object.  These types of errors should be completely&#xA;unacceptable yet they plague production systems all the time.&lt;/p&gt;&#xA;&lt;p&gt;Sometimes undefined values propagate up from bad database constraints,&#xA;null columns that leak right out of our data types as nil objects or&#xA;null pointers.  This is just one symptom of a larger problem, the&#xA;widespread design idiom that overloads nil to stand in for failure,&#xA;missing values, and the inability to compute a value.  When compared&#xA;to raising an exception this seems very reasonable indeed.  But is it?&lt;/p&gt;&#xA;&lt;p&gt;There are 3 alternatives when a function can either return a valid&#xA;result or a nil object:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Test the result of every function to make sure it&amp;rsquo;s valid.  Of&#xA;course this leads to verbose code that sucks to write and when a&#xA;programmer is feeling a bit lazy it&amp;rsquo;s easy to leave out.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Pretend that the function always returns valid data and use it&#xA;without checking.  I&amp;rsquo;m surprised how often this happens (I&amp;rsquo;m&#xA;certainly guilty of it) and that most languages can&amp;rsquo;t detect this&#xA;and slap us right across the face like we deserve.  This happens&#xA;a lot in object oriented scripting languages where we chain a&#xA;bunch of method calls together, any one of which may return nil.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Use a complete hack such as the &lt;a href=&#34;http://api.rubyonrails.org/classes/Object.html#method-i-try&#34; target=&#34;_blank&#34;&gt;try method&lt;/a&gt; from&#xA;Ruby on Rails which obscures the source of the problem, leaving&#xA;it for someone else to deal with.  This seems to be a popular&#xA;favorite these days.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Of course the correct approach is method 1 but it comes at a cost.  In&#xA;order handle this situation properly we have to write a bunch of&#xA;boilerplate code and we&amp;rsquo;re forced to make decisions about what to do&#xA;in the event a function actually returns nil.  Often the only sensible&#xA;thing to do is propagate the failure up the call stack which is why&#xA;method 3 is so popular.&lt;/p&gt;&#xA;&lt;p&gt;It&amp;rsquo;s also why ruthless testing and 100% test coverage have become so&#xA;important in mainstream languages.  But even with 100% test coverage&#xA;you can&amp;rsquo;t be sure that your code will work correctly if a function&#xA;unexpectedly returns nil unless you&amp;rsquo;re also mocking things out or&#xA;using fuzz testing.  That&amp;rsquo;s a lot of extra work and most of us don&amp;rsquo;t&#xA;go to such great lengths.  Have no fear my friends, there&amp;rsquo;s a better&#xA;way.&lt;/p&gt;&#xA;&lt;p&gt;Haskell has a solution to this problem that is both simple and&#xA;elegant.  First and foremost there&amp;rsquo;s no such thing as null or nil.  If&#xA;a function is declared as returning an integer then the compiler won&amp;rsquo;t&#xA;let it return anything else&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;.  If you&amp;rsquo;re brave and try to&#xA;return anything that isn&amp;rsquo;t an integer the code won&amp;rsquo;t compile and the&#xA;day will be saved.&lt;/p&gt;&#xA;&lt;p&gt;If a function needs to either return a valid value or the absence of&#xA;one it&amp;rsquo;s easy to encode that using the type system which then allows&#xA;the compiler to verify that the programmer is dealing with the missing&#xA;value.  If it&amp;rsquo;s not explicitly dealt with the code won&amp;rsquo;t compile.&#xA;We&amp;rsquo;ll get more into using the Haskell type system to our advantage in&#xA;the next section.&lt;/p&gt;&#xA;&lt;p&gt;This entire class of run-time errors is completely eliminated in&#xA;Haskell for free, at compile time.  After you&amp;rsquo;ve been using Haskell&#xA;for a bit of time you&amp;rsquo;ll be paranoid and frustrated when using&#xA;languages that have nil values or null pointers because the&#xA;responsibility to deal with all those potentially missing values sits&#xA;squarely on &lt;em&gt;your&lt;/em&gt; shoulders.  Those languages don&amp;rsquo;t help you out one&#xA;bit in this regard.&lt;/p&gt;&#xA;&lt;h2 id=&#34;what-has-your-compiler-done-for-you-lately&#34;&gt;What Has Your Compiler Done for You Lately?&lt;/h2&gt;&#xA;&lt;p&gt;As a programmer it&amp;rsquo;s likely you know at least a handful of programming&#xA;languages and there&amp;rsquo;s one in particular you gravitate towards.  It&amp;rsquo;s&#xA;also likely that over the years languages have come into and gone out&#xA;of your favor.  Think of your current favorite language, what makes it&#xA;different than your previous favorite language?&lt;/p&gt;&#xA;&lt;p&gt;I&amp;rsquo;ve noticed a pattern in myself, I tend to toggle between lower level&#xA;and higher level languages.  I love the raw power and control of the&#xA;lower level static languages such as C++, but after a bit of time the&#xA;verbosity of the language and the amount of code to get something&#xA;simple done starts to wear on me and I switch to a high-level dynamic&#xA;language like Ruby.&lt;/p&gt;&#xA;&lt;p&gt;With higher level languages it feels like you can get more done with&#xA;significantly less code and the development cycle of writing code and&#xA;running it becomes so much easier and faster.  The experience is&#xA;really enjoyable until things start to go wrong in production because&#xA;stupid typos and nil objects that somehow slipped through testing.&#xA;That&amp;rsquo;s when I start to long for a static language with a compiler that&#xA;can catch silly mistakes well before anything is deployed to&#xA;production.&lt;/p&gt;&#xA;&lt;p&gt;From the perspective of a software developer it&amp;rsquo;s a zero-sum game.&#xA;All the gains I think I&amp;rsquo;m getting from a dynamic high-level language&#xA;are eventually eroded by all the test writing and general care that&amp;rsquo;s&#xA;necessary to have confidence that things aren&amp;rsquo;t going to blow up in a&#xA;user&amp;rsquo;s face.  And all the hand-holding, nudging, and extra code needed&#xA;in a static low-level language just to get the same amount of work&#xA;done can be infuriating.&lt;/p&gt;&#xA;&lt;p&gt;The obvious solution is a hybrid language, one that is abstract enough&#xA;that you can work faster and write less code and at the same time uses&#xA;a static type system with a compiler that can catch stupid typos and&#xA;enforce design choices at compile time.  In the world of functional&#xA;programming, languages like this are plentiful and Haskell happens to&#xA;be one of them.&lt;/p&gt;&#xA;&lt;p&gt;Haskell has a very strong static type system.  Every expression has a&#xA;type and the way expressions are used is fully checked at compile time&#xA;to ensure type safety.  If you&amp;rsquo;ve used a static type system before you&#xA;might have just thrown up in your mouth and had flashbacks of&#xA;spoon-feeding the compiler type annotations and extra code that it&#xA;should have been able to figure out for itself.  Have no fear, Haskell&#xA;has an excellent type inference system which means you get type safety&#xA;without having to explicitly tell it what you&amp;rsquo;re up to all the time.&lt;/p&gt;&#xA;&lt;p&gt;But type inference isn&amp;rsquo;t all that special really.  Heck, even C++11&#xA;has the &lt;code&gt;auto&lt;/code&gt; keyword that allows the type of a variable to be&#xA;inferred by the compiler.  What you should take away from this,&#xA;however, is that Haskell provides a lot of type safety at compile time&#xA;without placing any additional burdens on the programmer.  Type&#xA;inference is just one example.&lt;/p&gt;&#xA;&lt;p&gt;The type system in Haskell is quite a bit more powerful than in most&#xA;languages.  If you haven&amp;rsquo;t been exposed to a language like Haskell you&#xA;probably haven&amp;rsquo;t thought about how to use the type system to make code&#xA;safer or how to enforce design decisions at compile time but that&amp;rsquo;s&#xA;exactly what Haskell programmers do every day.&lt;/p&gt;&#xA;&lt;p&gt;Consider again the topic of null pointers and nil objects.  What can&#xA;you (and the compiler especially) gather from the following C++&#xA;function prototype&lt;sup id=&#34;fnref:2&#34;&gt;&lt;a href=&#34;#fn:2&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;2&lt;/a&gt;&lt;/sup&gt;?&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-cpp&#34; data-lang=&#34;cpp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;User&lt;span style=&#34;color:#f92672&#34;&gt;*&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;get_user_by_name&lt;/span&gt; (&lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; std&lt;span style=&#34;color:#f92672&#34;&gt;::&lt;/span&gt;string &lt;span style=&#34;color:#f92672&#34;&gt;&amp;amp;&lt;/span&gt;name);&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;I see a function that returns a pointer to a &lt;code&gt;User&lt;/code&gt; object.  Had it&#xA;returned a reference I could be somewhat assured that it won&amp;rsquo;t fail at&#xA;run time (but it could still throw an exception.)  Setting aside the&#xA;ambiguity of who&amp;rsquo;s responsible for memory management in this case,&#xA;it&amp;rsquo;s probably safe to assume that this function can potentially return&#xA;a null pointer.&lt;/p&gt;&#xA;&lt;p&gt;The C++ compiler doesn&amp;rsquo;t make a distinction between a valid &lt;code&gt;User&lt;/code&gt;&#xA;pointer and a null pointer, it doesn&amp;rsquo;t even spit out a warning if you&#xA;try to dereference a known null pointer, and it certainly doesn&amp;rsquo;t&#xA;force the programmer to test the pointer to see if it&amp;rsquo;s &lt;code&gt;NULL&lt;/code&gt;.  This&#xA;is a case of &amp;ldquo;the programmer knows best&amp;rdquo; even when the compiler can&#xA;see otherwise.  I don&amp;rsquo;t know about you but when I&amp;rsquo;m writing production&#xA;software and the compiler can potentially detect a mistake I&amp;rsquo;ve made I&#xA;want to know about it.&lt;/p&gt;&#xA;&lt;p&gt;There are two popular ways to write this function in Haskell.  The&#xA;first clearly tells the compiler and the programmer that this function&#xA;might not return a valid &lt;code&gt;User&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-haskell&#34; data-lang=&#34;haskell&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;getUserByName&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;::&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;String&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;-&amp;gt;&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;Maybe&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;User&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And the following means that the function can either return a string&#xA;containing an error message or a valid &lt;code&gt;User&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-haskell&#34; data-lang=&#34;haskell&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;getUserByName&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;::&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;String&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;-&amp;gt;&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;Either&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;String&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;User&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And here&amp;rsquo;s the kicker, this is all done in the type system.&#xA;Programmers who don&amp;rsquo;t know Haskell might be tempted to think that&#xA;&lt;code&gt;Maybe&lt;/code&gt; and &lt;code&gt;Either&lt;/code&gt; are language keywords or some sort of type&#xA;qualifier for the compiler but they&amp;rsquo;re just data types that happen to&#xA;be in the standard library.&lt;/p&gt;&#xA;&lt;p&gt;The closest comparison to C++ that comes to mind is the union type.&#xA;Take the &lt;code&gt;Either&lt;/code&gt; type in Haskell, implemented in C++ it would be a&#xA;union with two fields, a string and a user.  Since it&amp;rsquo;s a union only&#xA;one of the fields can be used at once and the programmer has to work&#xA;out which one can be accessed.  In Haskell it&amp;rsquo;s not so ambiguous, it&amp;rsquo;s&#xA;actually not ambiguous at all.&lt;/p&gt;&#xA;&lt;p&gt;In both Haskell examples above the compiler won&amp;rsquo;t let you directly&#xA;access the &lt;code&gt;User&lt;/code&gt; object because it might not even be there.  You have&#xA;to write a little more code to handle the case where the function&#xA;failed to return a user.  This might seem like extra work for the&#xA;programmer but in reality it doesn&amp;rsquo;t work out that way.  Haskell even&#xA;provides some syntactic sugar that allows you to chain function calls&#xA;of this nature together so that the first failure stops the chain,&#xA;sort of like the &lt;code&gt;try&lt;/code&gt; method mentioned earlier, but with much more&#xA;flexibility.&lt;/p&gt;&#xA;&lt;p&gt;If the Haskell type system can be used to encode information like&#xA;&amp;ldquo;&lt;em&gt;this function might return a user but it also might return nothing&lt;/em&gt;&amp;rdquo;&#xA;can you imagine what else you could use it for?  What about &amp;ldquo;&lt;em&gt;this&#xA;function only accepts validated user input&lt;/em&gt;&amp;rdquo; or something we&amp;rsquo;ll go&#xA;over in the next section &amp;ldquo;&lt;em&gt;this function does I/O&lt;/em&gt;&amp;rdquo;.&lt;/p&gt;&#xA;&lt;p&gt;What this boils down to is that you can clearly articulate invariants&#xA;using the Haskell type system and then know that the compiler will&#xA;confirm that no programmer has broken the rules.  It also means that&#xA;the compiler acts as an automated test system for type related parts&#xA;of the code.  Now that&amp;rsquo;s a level of confidence you&amp;rsquo;re probably not&#xA;used to, at least not yet.&lt;/p&gt;&#xA;&lt;h2 id=&#34;side-effects-and-spaghetti&#34;&gt;Side Effects and Spaghetti&lt;/h2&gt;&#xA;&lt;p&gt;I&amp;rsquo;ve spent a large portion of my career using object oriented&#xA;programming languages to great effect.  The ability to manage the&#xA;complexity of large projects by segmenting code into classes and&#xA;hiding implementation details through encapsulation and abstraction&#xA;has proved to be very helpful.  Certainly more so than the&#xA;abstractions in procedural languages.&lt;/p&gt;&#xA;&lt;p&gt;Over the last few years something started bothering me and other&#xA;object oriented practitioners, the fact that sending a single message&#xA;to an object might change its state in several non-obvious ways.  This&#xA;led, in part, to conventions such as the&#xA;&lt;a href=&#34;http://en.wikipedia.org/wiki/Single_responsibility_principle&#34; target=&#34;_blank&#34;&gt;single responsibility principle&lt;/a&gt;.  In my opinion, however, this&#xA;problem strikes at the heart of OOP (and more generally imperative&#xA;programming.)&lt;/p&gt;&#xA;&lt;p&gt;You might not think about it very often but a method call can do any&#xA;of the following:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Alter instance variables for the current object either directly&#xA;or by invoking other instance methods that do so.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Change the state of any of its parameters.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Modify class variables, global variables, or any other variable&#xA;that might be in scope.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Perform I/O (open files, write to a socket, communicate with&#xA;another application, launch missiles, etc.)&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;The point is, going by the laws of encapsulation an object should be a&#xA;black box that provides an interface and when calling a method you&#xA;only care that it performs its promised task.  You don&amp;rsquo;t really know&#xA;what other magic it&amp;rsquo;s doing behind the scenes and you really shouldn&amp;rsquo;t&#xA;care.  Except that if you don&amp;rsquo;t know then you can&amp;rsquo;t write robust code&#xA;because you can&amp;rsquo;t be sure what a method is &lt;em&gt;capable&lt;/em&gt; of doing.&lt;/p&gt;&#xA;&lt;p&gt;When invoking a method you know what inputs it takes (parameters) and&#xA;what outputs it produces (return values) but you don&amp;rsquo;t necessarily&#xA;know what its side effects are going to be.  If fact, invoking the&#xA;same method over and over again may produce different results and may&#xA;alter the outside world in different ways.  None of this information,&#xA;however, is conveyed by the signature of the method.  Most languages&#xA;leave it up to the programmer to document these side effects in one&#xA;way or another.&lt;/p&gt;&#xA;&lt;p&gt;This all makes for a big mess.&lt;/p&gt;&#xA;&lt;p&gt;Consider global variables, for a very long time now they have been the&#xA;black sheep of the family, and for good reason.  But what really makes&#xA;global variables different than instance variables?  Sure, instance&#xA;variables have a much smaller scope, but in the context of all the&#xA;code that makes up a single class don&amp;rsquo;t they essentially cause the&#xA;same problems?  Have you ever written a method that failed because&#xA;some other method accidentally screwed up the value of an instance&#xA;variable?&lt;/p&gt;&#xA;&lt;p&gt;There&amp;rsquo;s a big difference between passing in an invalid parameter to a&#xA;method and the object having an invalid internal state.  The former is&#xA;fairly easy to track down while the latter can be just like hunting&#xA;for a bug involving a global variable.  Instance variables in big&#xA;classes also tend to create spaghetti code where side effects are hard&#xA;to trace.&lt;/p&gt;&#xA;&lt;p&gt;With the ability to indirectly (and often accidentally) change the&#xA;state of any object and affect the outside world in any way, it&amp;rsquo;s like&#xA;we&amp;rsquo;re living in the wild west of programming.  While side effects are&#xA;absolutely necessary for our programs to do anything useful, we need a&#xA;way to manage them much better than we do, especially in imperative&#xA;languages.&lt;/p&gt;&#xA;&lt;p&gt;Let&amp;rsquo;s start by partitioning side effects into two buckets, mutable&#xA;state and the ability to interact with the outside world (A.K.A. I/O).&#xA;We&amp;rsquo;ll tackle how Haskell handles these starting with the latter.&lt;/p&gt;&#xA;&lt;p&gt;Communicating with the outside world presents several problems, the&#xA;least of which is changing the environment in a way that can&amp;rsquo;t easily&#xA;be undone (deleting a file, sending a network packet, etc.)  By&#xA;default Haskell doesn&amp;rsquo;t allow any of these but instead provides a&#xA;special I/O compartment or an escape hatch if you will.&lt;/p&gt;&#xA;&lt;p&gt;The bridge to the outside, unpredictable world in Haskell is through a&#xA;data type called &lt;code&gt;IO&lt;/code&gt;.  And since &lt;code&gt;IO&lt;/code&gt; is a data type we can use the&#xA;power of the type system to enforce this so-called compartment!  In&#xA;other words, a function can&amp;rsquo;t perform I/O unless its return type is&#xA;the &lt;code&gt;IO&lt;/code&gt; data type.  Here&amp;rsquo;s a simple example:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-haskell&#34; data-lang=&#34;haskell&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;getLine&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;::&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;IO&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;String&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The &lt;code&gt;getLine&lt;/code&gt; function reads a single line of characters from standard&#xA;input.  It doesn&amp;rsquo;t take any parameters and returns an &lt;code&gt;IO&lt;/code&gt;&#xA;type&lt;sup id=&#34;fnref:3&#34;&gt;&lt;a href=&#34;#fn:3&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;3&lt;/a&gt;&lt;/sup&gt;.  The function&amp;rsquo;s type contains enough information to&#xA;convey to the programmer that it might produce side effects.  As a&#xA;bonus feature it conveys the same information to the compiler which&#xA;can make better optimization choices for functions that don&amp;rsquo;t have&#xA;side effects.&lt;/p&gt;&#xA;&lt;p&gt;This is so important that I want to say it one more time, you can&amp;rsquo;t do&#xA;any I/O in Haskell unless your function returns an &lt;code&gt;IO&lt;/code&gt; type.  That&#xA;also means that any function that uses an &lt;code&gt;IO&lt;/code&gt; function must also be&#xA;itself an &lt;code&gt;IO&lt;/code&gt; function, which is why the &lt;code&gt;main&lt;/code&gt; function is of type&#xA;&lt;code&gt;IO&lt;/code&gt;.  Theoretically you could write all of your functions this way&#xA;but you&amp;rsquo;d totally miss out on the benefits of compartmentalized I/O.&lt;/p&gt;&#xA;&lt;p&gt;Getting back to the other major kind of side effects, mutations,&#xA;Haskell has a simple solution to this one as well, they&amp;rsquo;re not allowed&#xA;outside of the I/O compartment.  In practice this isn&amp;rsquo;t an issue&#xA;because mutations are very rare in Haskell.  If you need to change one&#xA;field of a record you just create a copy with the changes applied.&#xA;The Haskell optimizer and garbage collector remove any of the&#xA;downsides you might be thinking of.&lt;/p&gt;&#xA;&lt;p&gt;Haskell does not have variables in the sense that you&amp;rsquo;re used to,&#xA;which is a good thing.  It means that everything you need to know&#xA;about a function can be gleaned from its type signature.  You don&amp;rsquo;t&#xA;have to worry that it might change something you&amp;rsquo;re not aware of or&#xA;affect the outside world behind your back.&lt;/p&gt;&#xA;&lt;p&gt;More importantly, you can&amp;rsquo;t accidentally mutate something.  Yet&#xA;another class of problems completely eliminated and the only thing you&#xA;have to do is slightly change the way you write code.&lt;/p&gt;&#xA;&lt;h2 id=&#34;haskell-is-hard-to-learn-right&#34;&gt;Haskell is Hard to Learn, Right?&lt;/h2&gt;&#xA;&lt;p&gt;There&amp;rsquo;s definitely some truth to Haskell&amp;rsquo;s reputation as a language&#xA;that&amp;rsquo;s hard to learn.  Fortunately it&amp;rsquo;s less about Haskell and more&#xA;about us.  As imperative programmers we bring a lot of baggage to&#xA;Haskell.  We expect to mutate variables, do I/O at will, and work with&#xA;very simplistic type systems.&lt;/p&gt;&#xA;&lt;p&gt;Then there&amp;rsquo;s the whole imperative vs. declarative issue to deal with.&#xA;Haskell is a high-level language, very high-level in fact.  In the&#xA;imperative programming world even the highest level languages still&#xA;require the programmer to structure code as a sequence of steps to&#xA;execute on a CPU.  In functional declarative languages like Haskell&#xA;you write your algorithms similar to how they are structured in&#xA;mathematics and let the compiler work out how to translate that into a&#xA;series of steps.  Often the Haskell compiler can generate binaries&#xA;that are close to if not as fast as hand written C.&lt;/p&gt;&#xA;&lt;p&gt;All of this adds up to Haskell being very different than we&amp;rsquo;re used&#xA;to.  At this point in my career I can usually learn a new programming&#xA;language in a few hours and write production quality code in about a&#xA;week.  The way I&amp;rsquo;ve learned to assimilate programming languages is by&#xA;comparison.  Ruby and C++ are more similar than they are different so&#xA;using what I know about C++ greatly reduced the cost of learning Ruby.&lt;/p&gt;&#xA;&lt;p&gt;Haskell is a very different beast.  It approaches programming from a&#xA;completely different angle.  It&amp;rsquo;s almost like learning to program all&#xA;over again.  Thankfully it&amp;rsquo;s not as bad as it sounds.&lt;/p&gt;&#xA;&lt;p&gt;Hopefully I&amp;rsquo;ve demonstrated why Haskell is important and why you&#xA;should take the time to learn it, even if it seems difficult at times.&lt;/p&gt;&#xA;&lt;p&gt;It&amp;rsquo;s often said that learning Haskell will make you a better&#xA;programmer no mater which language you choose to use.  I&amp;rsquo;m a firm&#xA;believer in that.  I&amp;rsquo;d be surprised, however, if Haskell doesn&amp;rsquo;t&#xA;become your new favorite language.&lt;/p&gt;&#xA;&lt;h2 id=&#34;learn-haskell&#34;&gt;Learn Haskell&lt;/h2&gt;&#xA;&lt;p&gt;For those of you who want to learn more I&amp;rsquo;ve compiled a recommended&#xA;reading list and study resources at the bottom of &lt;a href=&#34;https://freerangebits.com/tags/haskell/&#34;&gt;this&#xA;page&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;h2 id=&#34;updates-and-discussion&#34;&gt;Updates and Discussion&lt;/h2&gt;&#xA;&lt;p&gt;If you want to discus this article head over to &lt;a href=&#34;http://www.reddit.com/r/programming/comments/1hxs02/why_the_world_needs_haskell/&#34; target=&#34;_blank&#34;&gt;reddit&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;div class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;&#xA;&lt;hr&gt;&#xA;&lt;ol&gt;&#xA;&lt;li id=&#34;fn:1&#34;&gt;&#xA;&lt;p&gt;You can, however, return an undefined value which when&#xA;evaluated will terminate the program.  Haskell programmers use this to&#xA;stub out parts of the program during development and they&amp;rsquo;re easy to&#xA;detect during a production build.&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li id=&#34;fn:2&#34;&gt;&#xA;&lt;p&gt;Reddit user LampCarpet points out that this isn&amp;rsquo;t&#xA;idiomatic C++ code and that competent C++ programmers know better than&#xA;to return raw pointers or let null pointers go unchecked.  I don&amp;rsquo;t&#xA;think that changes the fact that even competent programmers make&#xA;mistakes and working with raw pointers is still &lt;a href=&#34;https://github.com/search?l=C%2B%2B&amp;amp;q=null&amp;#43;pointer&amp;amp;type=Issues&#34; target=&#34;_blank&#34;&gt;very popular&lt;/a&gt; with C++ programmers.&amp;#160;&lt;a href=&#34;#fnref:2&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li id=&#34;fn:3&#34;&gt;&#xA;&lt;p&gt;More accurately, &lt;code&gt;getLine&lt;/code&gt; returns an I/O action that&#xA;when performed yields a string.&amp;#160;&lt;a href=&#34;#fnref:3&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;/div&gt;&#xA;</description>
    </item>
    <item>
      <title>Parsing with Haskell and Attoparsec</title>
      <link>https://freerangebits.com/posts/2013/06/parsing-with-haskell/</link>
      <pubDate>Wed, 26 Jun 2013 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2013/06/parsing-with-haskell/</guid>
      <description>&lt;p&gt;If you&amp;rsquo;re a &lt;a href=&#34;https://freerangebits.com/tags/haskell/&#34;&gt;Haskell&lt;/a&gt; programmer and haven&amp;rsquo;t gotten around to using&#xA;the wonderful &lt;a href=&#34;http://hackage.haskell.org/package/attoparsec&#34; target=&#34;_blank&#34;&gt;Attoparsec&lt;/a&gt; library this video will give you a much&#xA;needed kick in the pants.  For those of you who haven&amp;rsquo;t taken the&#xA;plunge with Haskell it might be interesting to see how straight&#xA;forward it is to write high performance parsers with Haskell.&lt;/p&gt;&#xA;&#xA;&lt;div style=&#34;position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;&#34;&gt;&#xA;  &lt;iframe src=&#34;https://player.vimeo.com/video/69176607&#34; style=&#34;position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;&#34; title=&#34;vimeo video&#34; webkitallowfullscreen mozallowfullscreen allowfullscreen&gt;&lt;/iframe&gt;&#xA;&lt;/div&gt;&#xA;&#xA;&lt;p&gt;The video also includes a short discussion on the major differences&#xA;between &lt;a href=&#34;http://hackage.haskell.org/package/parsec&#34; target=&#34;_blank&#34;&gt;Parsec&lt;/a&gt; and &lt;a href=&#34;http://hackage.haskell.org/package/attoparsec&#34; target=&#34;_blank&#34;&gt;Attoparsec&lt;/a&gt;.  They have very similar APIs&#xA;which can make it hard for newcomers to decide which library to use.&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>Learn to read and write Scheme expressions</title>
      <link>https://freerangebits.com/posts/2013/04/expressions/</link>
      <pubDate>Mon, 29 Apr 2013 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2013/04/expressions/</guid>
      <description>&lt;p&gt;With this article you&amp;rsquo;ll begin your journey with the &lt;a href=&#34;https://freerangebits.com/tags/scheme/&#34;&gt;Scheme&lt;/a&gt;&#xA;programming language by first learning how to read and understand&#xA;expressions and then how to write them.  When you reach the end of&#xA;this article you&amp;rsquo;ll be ready to group your expressions into larger&#xA;components such as functions.&lt;/p&gt;&#xA;&lt;p&gt;It will be most helpful if you follow along with the article using one&#xA;of the free Scheme interpreters such as &lt;a href=&#34;http://www.call-cc.org/&#34; target=&#34;_blank&#34;&gt;Chicken Scheme&lt;/a&gt; or&#xA;&lt;a href=&#34;http://racket-lang.org/&#34; target=&#34;_blank&#34;&gt;Racket&lt;/a&gt;.  Both are easy to install and support all the popular&#xA;operating systems (Windows, Mac, and Linux).  If you don&amp;rsquo;t have a&#xA;preference I recommend you &lt;a href=&#34;http://wiki.call-cc.org/platforms&#34; target=&#34;_blank&#34;&gt;download the Chicken Scheme installer&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;h2 id=&#34;building-programs-from-smaller-pieces&#34;&gt;Building programs from smaller pieces&lt;/h2&gt;&#xA;&lt;p&gt;Expressions are the fundamental building blocks of a programming&#xA;language.  As a programmer you&amp;rsquo;ll spend a great deal of your time&#xA;combining expressions together in order to build larger components&#xA;that eventually make up an entire application just like when you&#xA;create buildings from small toy bricks.&lt;/p&gt;&#xA;&lt;p&gt;Usually, however, programmers will spend some time thinking about the&#xA;application they are going to write and how it should fit together as&#xA;a whole before they start dealing with the smaller details like&#xA;expressions, this is called top-down design.  This article series uses&#xA;the opposite approach to teach programming, namely bottom-up.&lt;/p&gt;&#xA;&lt;p&gt;Using a bottom-up approach we&amp;rsquo;ll start with the smaller components&#xA;(i.e. expressions) and work our way up to more complicated programming&#xA;structures.  For now I just want you to be aware that taking an idea&#xA;for a big application and jumping directly to writing expressions in a&#xA;programming language without first thinking about how things fit&#xA;together might be a recipe for trouble.&lt;/p&gt;&#xA;&lt;h2 id=&#34;breaking-apart-a-simple-scheme-expression&#34;&gt;Breaking apart a simple Scheme expression&lt;/h2&gt;&#xA;&lt;p&gt;Let&amp;rsquo;s start with the example code from the &lt;a href=&#34;https://freerangebits.com/posts/2013/03/first-language/&#34;&gt;previous article&lt;/a&gt; which&#xA;added two numbers together.  I&amp;rsquo;ll continue to use simple arithmetic&#xA;throughout this article since it gives us common ground to start from,&#xA;but you should keep in mind that expressions in Scheme can do more&#xA;than just simple mathematical operations.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-scheme&#34; data-lang=&#34;scheme&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;(+ &lt;span style=&#34;color:#ae81ff&#34;&gt;2&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;3&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;In Scheme an expression is actually a list of items, much like a&#xA;grocery list or a to-do list.  A list in Scheme begins with an opening&#xA;parenthesis, ends with a closing parenthesis, and in between contains&#xA;one or more items separated from one another with whitespace.  In the&#xA;list above there are 3 items (often referred to as elements or&#xA;members):&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&#34;expr.jpg&#34; alt=&#34;Example Expression&#34;&gt;&lt;/p&gt;&#xA;&lt;p&gt;There&amp;rsquo;s not much more to it than that.  Pretty simple right?&lt;/p&gt;&#xA;&lt;h2 id=&#34;evaluating-simple-expressions&#34;&gt;Evaluating simple expressions&lt;/h2&gt;&#xA;&lt;p&gt;An expression is pretty useless just sitting there on your screen&#xA;unless you actually make it do something.  Making an expression&#xA;perform its task is called evaluation.  Let&amp;rsquo;s evaluate this expression&#xA;in a Scheme interpreter.  If you&amp;rsquo;re a good student you installed&#xA;Chicken Scheme as instructed at the beginning of the article.  Open a&#xA;terminal window and run the &lt;code&gt;csi&lt;/code&gt; tool.  You should see the &lt;code&gt;#;1&amp;gt; &lt;/code&gt;&#xA;prompt which means &lt;code&gt;csi&lt;/code&gt; is waiting for you to enter an expression.&lt;/p&gt;&#xA;&lt;p&gt;Type in our example expression from above (don&amp;rsquo;t forget the&#xA;parentheses) and then press enter/return.  The &lt;code&gt;csi&lt;/code&gt; tool should&#xA;evaluate the expression and print out the result (&lt;code&gt;5&lt;/code&gt;), after which it&#xA;will return you to a new prompt and wait for your next expression.&lt;/p&gt;&#xA;&lt;p&gt;When expressions are evaluated they will either return a result,&#xA;produce a side effect (e.g. draw a rainbow), or both.  Even though&#xA;drawing rainbows is fun we&amp;rsquo;ll focus on expressions that return a&#xA;result like our example expression that takes some numbers and returns&#xA;their sum.  Let&amp;rsquo;s break apart how our expression is evaluated.&lt;/p&gt;&#xA;&lt;p&gt;Do you remember that an expression in Scheme is a list of items?  The&#xA;first item in the list (known as the head of the list, or more&#xA;technically, the &amp;ldquo;car&amp;rdquo; of the list) is special.  When the expression&#xA;is being evaluated the interpreter begins by looking at the first item&#xA;of the list which should be the name of a function.  We&amp;rsquo;ll get into&#xA;functions in the next article but for now you can think of a function&#xA;as a task that you can ask Scheme to execute for you.&lt;/p&gt;&#xA;&lt;p&gt;With the example expression we&amp;rsquo;ve been working with so far, the first&#xA;item of the list is &lt;code&gt;+&lt;/code&gt;, the name of the function that adds&#xA;numbers. The remaining items of the list (known as the tail of the&#xA;list, or more technically the &amp;ldquo;cdr&amp;rdquo; of the list) are given to the &lt;code&gt;+&lt;/code&gt;&#xA;function as &lt;em&gt;arguments&lt;/em&gt;, in this case the numbers you want to add&#xA;together.&lt;/p&gt;&#xA;&lt;p&gt;Arguments are the inputs to the function.  Each function defines what&#xA;it wants for arguments (and some don&amp;rsquo;t want any).  If you read the&#xA;documentation for the &lt;code&gt;+&lt;/code&gt; function you&amp;rsquo;d find that it wants one or&#xA;more numbers as its arguments.  Most programming languages come with a&#xA;set of predefined functions and allow you to define your own.  Again,&#xA;we&amp;rsquo;ll get to that in the next article.&lt;/p&gt;&#xA;&lt;p&gt;After an expression is evaluated it is replaced with its result.&#xA;Don&amp;rsquo;t worry if that doesn&amp;rsquo;t make sense just yet, it will become clear&#xA;in the next section when we start to put expressions together to form&#xA;more complicated building blocks.&lt;/p&gt;&#xA;&lt;h2 id=&#34;combining-expressions-to-form-complex-expressions&#34;&gt;Combining expressions to form complex expressions&lt;/h2&gt;&#xA;&lt;p&gt;To spice things up a bit, pretend you&amp;rsquo;re a school teacher faced with&#xA;grading a rather large stack of homework sheets.  Your student aid&#xA;already marked the incorrect answers but she didn&amp;rsquo;t calculate the&#xA;percentages that the students are expecting to see.&lt;/p&gt;&#xA;&lt;p&gt;Let&amp;rsquo;s write a Scheme expression to calculate the score for the first&#xA;student&amp;rsquo;s worksheet.  There are a total of 15 questions and the first&#xA;student correctly answered 12.  The arithmetic is pretty simple,&#xA;divide 12 by 15 and multiple the result by 100:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-scheme&#34; data-lang=&#34;scheme&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;(* &lt;span style=&#34;color:#ae81ff&#34;&gt;100&lt;/span&gt; (/ &lt;span style=&#34;color:#ae81ff&#34;&gt;12&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;15&lt;/span&gt;))&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Don&amp;rsquo;t panic, let&amp;rsquo;s work through this expression step by step.&lt;/p&gt;&#xA;&lt;p&gt;First look at the parentheses, do you see that there are two lists in&#xA;the code above?  The second list is inside the first, that is to say&#xA;one is nested inside the other.  Both lists begin with the name of a&#xA;function (&lt;code&gt;*&lt;/code&gt; is the name of a function that multiples its arguments&#xA;and &lt;code&gt;/&lt;/code&gt; is the name of the function that divides its first argument by&#xA;its second argument).&lt;/p&gt;&#xA;&lt;p&gt;When evaluating compound expressions like the one above the&#xA;interpreter will first evaluate the inner-most expression.  In our&#xA;case that&amp;rsquo;s the expression that does the division.  If you evaluate&#xA;the inner expression in &lt;code&gt;csi&lt;/code&gt; you&amp;rsquo;ll find that the result is &lt;code&gt;0.8&lt;/code&gt;&#xA;(12/15 = 0.8).&lt;/p&gt;&#xA;&lt;p&gt;Once you have the result of the inner expression you can replace it&#xA;with its resulting value:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-scheme&#34; data-lang=&#34;scheme&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;(* &lt;span style=&#34;color:#ae81ff&#34;&gt;100&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;0.8&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now you&amp;rsquo;re left with a single expression and we already know how to&#xA;evaluate those.&lt;/p&gt;&#xA;&lt;p&gt;Unfortunately the only thing we&amp;rsquo;ve managed to do is turn Scheme into a&#xA;boring calculator and haven&amp;rsquo;t really made grading papers any easier.&#xA;Come to think of it, we&amp;rsquo;ve actually made it harder to grade papers&#xA;because we have to hand type these weird nested Scheme expressions,&#xA;repeating two of the numbers for each worksheet we grade.&lt;/p&gt;&#xA;&lt;p&gt;Not to worry though, we&amp;rsquo;ll improve this quite a bit in the next&#xA;article.  The important thing is that you&amp;rsquo;ve learned about expressions&#xA;and how to put them together to accomplish more complicated tasks.&lt;/p&gt;&#xA;&lt;h2 id=&#34;list-items-atoms-and-constants&#34;&gt;List items, atoms, and constants&lt;/h2&gt;&#xA;&lt;p&gt;Before we wrap up let&amp;rsquo;s take a closer look at those things I&amp;rsquo;ve been&#xA;calling list items.  Did you notice from the code above that lists can&#xA;contain other lists?  Technically speaking lists are made up of atoms&#xA;and/or other lists.  An atom is anything that is not a list, so all&#xA;the numbers and function names we&amp;rsquo;ve been using as list items are&#xA;considered atoms.&lt;/p&gt;&#xA;&lt;p&gt;More specifically, the numbers are called &lt;em&gt;numeric constants&lt;/em&gt; because&#xA;they can&amp;rsquo;t change (they are said to be hard-coded).  Besides being&#xA;constant values, numbers and text that are hard-coded are also&#xA;referred to as literals.&lt;/p&gt;&#xA;&lt;p&gt;While literal values in your code are useful there&amp;rsquo;s another way to&#xA;get values into a running program, things called variables.  With&#xA;variables you essentially have a placeholder that you&amp;rsquo;ll fill in later&#xA;when your program is running.  Variables can be given values by asking&#xA;the user a question, reading the current time from the computer&amp;rsquo;s&#xA;clock, communicating with another computer, etc.&lt;/p&gt;&#xA;&lt;p&gt;Scheme (like most programming languages) has support for different&#xA;types of values.  We&amp;rsquo;ve already seen numbers and identifiers (e.g. &lt;code&gt;+&lt;/code&gt;&#xA;and &lt;code&gt;*&lt;/code&gt;).  Using the following table, experiment with the Scheme&#xA;interpreter you installed.  You can type the examples directly into&#xA;something like &lt;code&gt;csi&lt;/code&gt; and it should give you back the value you&#xA;entered.&lt;/p&gt;&#xA;&lt;table&gt;&#xA;&lt;thead&gt;&#xA;&lt;tr&gt;&#xA;&lt;th style=&#34;text-align:left&#34;&gt;Type&lt;/th&gt;&#xA;&lt;th style=&#34;text-align:left&#34;&gt;Description&lt;/th&gt;&#xA;&lt;th style=&#34;text-align:left&#34;&gt;Literal Examples&lt;/th&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/thead&gt;&#xA;&lt;tbody&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&#34;text-align:left&#34;&gt;Integer&lt;/td&gt;&#xA;&lt;td style=&#34;text-align:left&#34;&gt;Whole numbers&lt;/td&gt;&#xA;&lt;td style=&#34;text-align:left&#34;&gt;&lt;code&gt;-1&lt;/code&gt;, &lt;code&gt;0&lt;/code&gt;, and &lt;code&gt;5&lt;/code&gt;&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&#34;text-align:left&#34;&gt;Real&lt;/td&gt;&#xA;&lt;td style=&#34;text-align:left&#34;&gt;Fractional numbers&lt;/td&gt;&#xA;&lt;td style=&#34;text-align:left&#34;&gt;&lt;code&gt;10.1&lt;/code&gt; and &lt;code&gt;0.8&lt;/code&gt;&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&#34;text-align:left&#34;&gt;Character&lt;/td&gt;&#xA;&lt;td style=&#34;text-align:left&#34;&gt;A single textual character&lt;/td&gt;&#xA;&lt;td style=&#34;text-align:left&#34;&gt;&lt;code&gt;#\a&lt;/code&gt;, &lt;code&gt;#\b&lt;/code&gt;, and &lt;code&gt;#\c&lt;/code&gt; (the first 3 letters of the English alphabet)&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&#34;text-align:left&#34;&gt;String&lt;/td&gt;&#xA;&lt;td style=&#34;text-align:left&#34;&gt;A sequence of characters&lt;/td&gt;&#xA;&lt;td style=&#34;text-align:left&#34;&gt;&lt;code&gt;&amp;quot;Hello World!&amp;quot;&lt;/code&gt;&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&#34;text-align:left&#34;&gt;Boolean&lt;/td&gt;&#xA;&lt;td style=&#34;text-align:left&#34;&gt;True and False&lt;/td&gt;&#xA;&lt;td style=&#34;text-align:left&#34;&gt;&lt;code&gt;#t&lt;/code&gt; is true, &lt;code&gt;#f&lt;/code&gt; is false&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&#34;text-align:left&#34;&gt;List&lt;/td&gt;&#xA;&lt;td style=&#34;text-align:left&#34;&gt;A list of values&lt;/td&gt;&#xA;&lt;td style=&#34;text-align:left&#34;&gt;&lt;code&gt;&#39;(1 2 3)&lt;/code&gt;&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;p&gt;There are a few other types of values that Scheme supports but we&#xA;won&amp;rsquo;t be getting into those just yet.  With the list of types above&#xA;you can write complex and expressive programs.  And don&amp;rsquo;t worry too&#xA;much about literals, types, and variables right now.  With more&#xA;practice and through this series you&amp;rsquo;ll develop an intuition for using&#xA;them.&lt;/p&gt;&#xA;&lt;p&gt;Programs and values go hand in hand.  From an abstract point of view&#xA;programs are things that take some input values, translate those&#xA;values, and then produce some sort of output based on those translated&#xA;values.&lt;/p&gt;&#xA;&lt;h2 id=&#34;conclusion-and-next-steps&#34;&gt;Conclusion and next steps&lt;/h2&gt;&#xA;&lt;p&gt;In Scheme expressions are represented as lists that are delimited by&#xA;parentheses and the items of the list are separated using whitespace.&#xA;The first item in the list is the name of a function to execute and&#xA;the remaining items are the arguments to that function.&lt;/p&gt;&#xA;&lt;p&gt;When you nest an expression inside another expression the inner&#xA;expression needs to be evaluated before the outer.  You can think&#xA;about evaluation as the act of replacing an expression with its&#xA;resulting value.&lt;/p&gt;&#xA;&lt;p&gt;In the next article we&amp;rsquo;ll look at how to group a set of expressions&#xA;together to form a larger building block, a function.  For now I&amp;rsquo;ll&#xA;leave you with a teaser of what we&amp;rsquo;ll be working on next.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-scheme&#34; data-lang=&#34;scheme&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;(&lt;span style=&#34;color:#66d9ef&#34;&gt;define &lt;/span&gt;grade&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  (&lt;span style=&#34;color:#66d9ef&#34;&gt;lambda &lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;correct&lt;/span&gt; total)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    (* &lt;span style=&#34;color:#ae81ff&#34;&gt;100&lt;/span&gt; (/ correct total))))&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;grade&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;12&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;15&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If you&amp;rsquo;re interested in following this series of articles I recommend&#xA;that you &lt;a href=&#34;https://freerangebits.com/posts/index.xml&#34;&gt;subscribe to the RSS feed&lt;/a&gt; or keep an eye on the&#xA;&lt;a href=&#34;https://freerangebits.com/series/learn-to-program/&#34;&gt;Learn to Program&lt;/a&gt; section of this site.&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>Picking your first programming language</title>
      <link>https://freerangebits.com/posts/2013/03/first-language/</link>
      <pubDate>Sun, 24 Mar 2013 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2013/03/first-language/</guid>
      <description>&lt;p&gt;When teaching an introductory programming course an overwhelming&#xA;majority of the boot camps and instructors (including myself) have&#xA;made the mistake of starting with a popular object-oriented language&#xA;such as &lt;a href=&#34;https://freerangebits.com/tags/ruby/&#34;&gt;Ruby&lt;/a&gt; or &lt;a href=&#34;https://freerangebits.com/tags/javascript/&#34;&gt;JavaScript&lt;/a&gt;.  I love these languages and&#xA;eventually they are something students should learn but they&amp;rsquo;re not a&#xA;good choice as a &lt;em&gt;first&lt;/em&gt; language.  The same can be said for most&#xA;programming languages, especially &lt;a href=&#34;https://freerangebits.com/tags/object-oriented/&#34;&gt;object-oriented&lt;/a&gt; languages.&lt;/p&gt;&#xA;&lt;h2 id=&#34;learning-to-program-incrementally&#34;&gt;Learning to program incrementally&lt;/h2&gt;&#xA;&lt;p&gt;Object-oriented programming languages like &lt;a href=&#34;https://freerangebits.com/tags/objective-c/&#34;&gt;Objective-C&lt;/a&gt; and&#xA;&lt;a href=&#34;https://freerangebits.com/tags/java/&#34;&gt;Java&lt;/a&gt; don&amp;rsquo;t make good first languages due to the extra layers of&#xA;&lt;a href=&#34;https://freerangebits.com/tags/abstraction/&#34;&gt;abstraction&lt;/a&gt;.  Of course, these same abstractions are what make&#xA;programming in these languages more productive for the experienced&#xA;software developer, but they add unnecessary difficulties when you&#xA;approach them as your first programming language.  You can&amp;rsquo;t isolate&#xA;the basics of programming and ignore the abstractions, they slap you&#xA;in the face and force you to deal with them.&lt;/p&gt;&#xA;&lt;p&gt;When you strip away the abstractions, learning to program works best&#xA;as an incremental process, just like learning the sciences and the&#xA;arts.  Vincent van Gogh spent a great deal of time perfecting his&#xA;drawing and shading skills before even considering the use of color.&#xA;The same should go for programming, you need to start with the&#xA;fundamentals and build your way up.  Only then can you understand and&#xA;appreciate programming languages with advanced abstractions.&lt;/p&gt;&#xA;&lt;p&gt;Given that the languages all the cool kids are using don&amp;rsquo;t lend&#xA;themselves well as a first language, what should a new student learn&#xA;instead?  If you&amp;rsquo;re familiar with past computer science curriculum my&#xA;suggestion won&amp;rsquo;t come as a surprise: &lt;a href=&#34;https://freerangebits.com/tags/scheme/&#34;&gt;Scheme&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;h2 id=&#34;a-small-rich-and-consistent-language&#34;&gt;A small, rich, and consistent language&lt;/h2&gt;&#xA;&lt;p&gt;You don&amp;rsquo;t have to look very far in the history of many universities to&#xA;find a time when &lt;a href=&#34;https://freerangebits.com/tags/scheme/&#34;&gt;Scheme&lt;/a&gt; was the teaching language of choice, but&#xA;that has mostly gone the way of the dodo, being supplanted by more&#xA;&amp;ldquo;modern&amp;rdquo; languages such as &lt;a href=&#34;https://freerangebits.com/tags/java/&#34;&gt;Java&lt;/a&gt;.  This is a real shame&#xA;considering my points above and that Scheme and other dialects of Lisp&#xA;are still a relatively popular language in the real world of&#xA;programming (&lt;a href=&#34;http://clojure.org/&#34; target=&#34;_blank&#34;&gt;Clojure&lt;/a&gt; being another one of them.)&lt;/p&gt;&#xA;&lt;p&gt;What is it that makes &lt;a href=&#34;https://freerangebits.com/tags/scheme/&#34;&gt;Scheme&lt;/a&gt; such a good teaching language?&#xA;Scheme is a high-level language like &lt;a href=&#34;https://freerangebits.com/tags/ruby/&#34;&gt;Ruby&lt;/a&gt; and &lt;a href=&#34;https://freerangebits.com/tags/java/&#34;&gt;Java&lt;/a&gt;.  This&#xA;means that beginners don&amp;rsquo;t have to take a boring detour to learn about&#xA;computer hardware, registers, pointers, etc.  Unlike other popular&#xA;high-level languages Scheme is relatively minimalistic, that is it&#xA;doesn&amp;rsquo;t have all the extra layers of abstraction that can get in the&#xA;way of learning the basics.&lt;/p&gt;&#xA;&lt;p&gt;For example, take a look at this snippet of code written in Scheme and&#xA;see if you can figure out what it does:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-scheme&#34; data-lang=&#34;scheme&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;(+ &lt;span style=&#34;color:#ae81ff&#34;&gt;2&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;3&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Obviously this adds 2 and 3 together.&lt;/p&gt;&#xA;&lt;p&gt;I know what you&amp;rsquo;re thinking, you can do this in &lt;em&gt;any&lt;/em&gt; programming&#xA;language and it would look more natural.  And you&amp;rsquo;d be right of&#xA;course, in nearly every other language the code would be &lt;code&gt;2 + 3&lt;/code&gt;.&#xA;However, once you understand how the above &lt;a href=&#34;https://freerangebits.com/tags/scheme/&#34;&gt;Scheme&lt;/a&gt; works you&amp;rsquo;ve&#xA;learned quite a bit about the language and the basics of programming&#xA;in general.&lt;/p&gt;&#xA;&lt;p&gt;You can&amp;rsquo;t say that about most other languages because the various&#xA;special cases that are part of the syntax (functions vs. operators,&#xA;infix vs. prefix, statements vs. expressions, etc.).  When learning to&#xA;program using &lt;a href=&#34;https://freerangebits.com/tags/scheme/&#34;&gt;Scheme&lt;/a&gt; you don&amp;rsquo;t have to worry about all that,&#xA;effectively postponing more advanced syntax until you&amp;rsquo;re ready.&lt;/p&gt;&#xA;&lt;h2 id=&#34;making-programming-fundamentals-approachable&#34;&gt;Making programming fundamentals approachable&lt;/h2&gt;&#xA;&lt;p&gt;Getting back to the &lt;a href=&#34;https://freerangebits.com/tags/scheme/&#34;&gt;Scheme&lt;/a&gt; example code from above, it looks&#xA;weird at first glance.  This is because Scheme doesn&amp;rsquo;t have any&#xA;special syntax for arithmetic.  No rules with a bunch of exceptions.&#xA;When you reach that moment where you understand that this example code&#xA;is an invocation of a function named &lt;code&gt;+&lt;/code&gt; and that it expects a list of&#xA;numbers as its arguments, you can apply that knowledge to call any&#xA;other function.  That&amp;rsquo;s it.  Adding numbers, launching missiles, and&#xA;setting variables all use the same syntax.&lt;/p&gt;&#xA;&lt;p&gt;And guess what, defining your own function is nearly as simple as the&#xA;example code because the same rules apply, it&amp;rsquo;s a simple extension of&#xA;the same syntax.  This is another reason why &lt;a href=&#34;https://freerangebits.com/tags/scheme/&#34;&gt;Scheme&lt;/a&gt; is so great&#xA;as a teaching language, the rules are easy to understand and&#xA;completely consistent throughout.  Best of all, these rules can be&#xA;taught incrementally.&lt;/p&gt;&#xA;&lt;p&gt;So what are these programming basics and fundamentals that I keep&#xA;talking about?  I&amp;rsquo;m going to save that for the next article but in the&#xA;meantime I&amp;rsquo;ll point you towards some popular &lt;a href=&#34;https://freerangebits.com/tags/scheme/&#34;&gt;Scheme&lt;/a&gt; resources.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;&lt;a href=&#34;http://www.call-cc.org/&#34; target=&#34;_blank&#34;&gt;Chicken Scheme&lt;/a&gt; might have a funny name but it&amp;rsquo;s a complete&#xA;Scheme system under active development.  It&amp;rsquo;s small, fast, and fun&#xA;to use.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;&lt;a href=&#34;http://racket-lang.org/&#34; target=&#34;_blank&#34;&gt;Racket&lt;/a&gt; is a popular programming language in the Scheme family&#xA;geared towards learning but powerful enough to write&#xA;commercial-grade software.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;One of the best computer science books of all time is&#xA;&lt;a href=&#34;http://mitpress.mit.edu/sicp/&#34; target=&#34;_blank&#34;&gt;Structure and Interpretation of Computer Programs&lt;/a&gt;.&#xA;It&amp;rsquo;s &lt;a href=&#34;http://mitpress.mit.edu/sicp/full-text/book/book.html&#34; target=&#34;_blank&#34;&gt;available for free&lt;/a&gt; and uses Scheme.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Another book that teaches Scheme is &lt;a href=&#34;http://htdp.org/&#34; target=&#34;_blank&#34;&gt;How to Design Programs&lt;/a&gt;&#xA;which is also &lt;a href=&#34;http://htdp.org/2003-09-26/&#34; target=&#34;_blank&#34;&gt;free&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;next-steps&#34;&gt;Next steps&lt;/h2&gt;&#xA;&lt;p&gt;Over the course of the next few months I&amp;rsquo;ll dig deeper into topics&#xA;covering how to become a programmer using &lt;a href=&#34;https://freerangebits.com/tags/scheme/&#34;&gt;Scheme&lt;/a&gt;.  If you&amp;rsquo;re&#xA;interested in following the series I recommend that you&#xA;&lt;a href=&#34;https://freerangebits.com/posts/index.xml&#34;&gt;subscribe to the RSS feed&lt;/a&gt; or keep an eye on the&#xA;&lt;a href=&#34;https://freerangebits.com/series/learn-to-program/&#34;&gt;Learn to Program&lt;/a&gt; section of this site.&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>JavaScript as a virtual machine?</title>
      <link>https://freerangebits.com/posts/2013/01/javascript-as-a-vm/</link>
      <pubDate>Thu, 03 Jan 2013 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2013/01/javascript-as-a-vm/</guid>
      <description>&lt;p&gt;When languages that compile/translate to JavaScript first started&#xA;becoming popular I rolled my eyes and kept on using JavaScript.&#xA;Adding a layer of indirection on top of an already high-level language&#xA;seemed like adding a spork to a picnic basket already stocked with a&#xA;full set of flatware.&lt;/p&gt;&#xA;&lt;p&gt;You might be able to make the same argument when comparing C to&#xA;assembly, and maybe I&amp;rsquo;m just an old fart yelling at those damn&#xA;&lt;a href=&#34;https://freerangebits.com/tags/coffeescript/&#34;&gt;CoffeeScript&lt;/a&gt; kids to get off my lawn.  Is JavaScript really that&#xA;bad?&lt;/p&gt;&#xA;&lt;p&gt;I&amp;rsquo;ll agree that implicit type conversion is a naught little feature&#xA;but if you know about it then you should also know how to prevent it.&#xA;Personally, I think once you actually learn JavaScript and&#xA;&lt;a href=&#34;https://freerangebits.com/tags/prototypes/&#34;&gt;prototype based programming&lt;/a&gt; it&amp;rsquo;s a pretty decent&#xA;language.  And since you have to debug the generated JavaScript and&#xA;not the higher level language you might as well just learn JavaScript.&lt;/p&gt;&#xA;&lt;p&gt;But then I started coming across projects like &lt;a href=&#34;http://fay-lang.org/&#34; target=&#34;_blank&#34;&gt;Fay&lt;/a&gt; and&#xA;&lt;a href=&#34;https://github.com/kripken/emscripten/wiki&#34; target=&#34;_blank&#34;&gt;Emscripten&lt;/a&gt; which allow &lt;em&gt;existing&lt;/em&gt; languages to be translated to&#xA;JavaScript.  Why is that important?  Consider being able to share code&#xA;from your server-side application (classes, data types, validation)&#xA;with your front-end code.  That&amp;rsquo;s a pretty cool idea.&lt;/p&gt;&#xA;&lt;p&gt;Over the holiday break I read an interesting article (which I can&amp;rsquo;t&#xA;for the life of me find now) in which the author suggests that we&#xA;think about JavaScript as very verbose bytecode for a virtual machine&#xA;built into every web browser.  That makes a bit of sense, at least&#xA;until browsers actually support some sort of universal bytecode&#xA;interpreter.&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>Unix cheat sheets</title>
      <link>https://freerangebits.com/posts/2012/09/unix-cheat-sheet/</link>
      <pubDate>Mon, 17 Sep 2012 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2012/09/unix-cheat-sheet/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;http://www.catonmat.net/&#34; target=&#34;_blank&#34;&gt;Peteris Krumins&lt;/a&gt; is at it again with two *nix cheat sheets&#xA;that should help you explore your Unix-like system:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&#34;http://www.catonmat.net/blog/gnu-coreutils-cheat-sheet/&#34; target=&#34;_blank&#34;&gt;GNU Coreutils Cheat Sheet&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;http://www.catonmat.net/blog/util-linux-cheat-sheet/&#34; target=&#34;_blank&#34;&gt;Util-Linux Cheat Sheet&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Not too long ago I &lt;a href=&#34;whatisthere.sh&#34;&gt;wrote a shell script&lt;/a&gt; that gives you a&#xA;brief description of every tool in your &lt;code&gt;PATH&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;#!/bin/sh&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;whatisthere &lt;span style=&#34;color:#f92672&#34;&gt;()&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;{&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#66d9ef&#34;&gt;for&lt;/span&gt; dir in &lt;span style=&#34;color:#e6db74&#34;&gt;`&lt;/span&gt;echo $PATH | sed &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;s/:/ /g&amp;#39;&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;`&lt;/span&gt;; &lt;span style=&#34;color:#66d9ef&#34;&gt;do&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;for&lt;/span&gt; file in $dir/*; &lt;span style=&#34;color:#66d9ef&#34;&gt;do&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      base&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;`&lt;/span&gt;basename $file&lt;span style=&#34;color:#e6db74&#34;&gt;`&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      desc&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;`&lt;/span&gt;whatis $base 2&amp;gt;&amp;amp;1&lt;span style=&#34;color:#e6db74&#34;&gt;`&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#f92672&#34;&gt;[&lt;/span&gt; $? -eq &lt;span style=&#34;color:#ae81ff&#34;&gt;0&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;]&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;&amp;amp;&amp;amp;&lt;/span&gt; echo $desc&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;done&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#66d9ef&#34;&gt;done&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;}&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;whatisthere | sort | less -SR&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; The electronic version of &lt;a href=&#34;http://linuxcommand.org/tlcl.php&#34; target=&#34;_blank&#34;&gt;The Linux Command Line&lt;/a&gt;&#xA;has been released for free under a creative commons license.  Thanks&#xA;for the tip &lt;a href=&#34;https://plus.google.com/101319091398494687950&#34; target=&#34;_blank&#34;&gt;Norman&lt;/a&gt;.&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>Being explicit with your code</title>
      <link>https://freerangebits.com/posts/2012/04/explicit-code/</link>
      <pubDate>Tue, 17 Apr 2012 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2012/04/explicit-code/</guid>
      <description>&lt;p&gt;Christian Heilmann has a &lt;a href=&#34;http://christianheilmann.com/2012/04/16/of-parser-fetishists-and-semi-colons/&#34; target=&#34;_blank&#34;&gt;well reasoned gripe&lt;/a&gt; for&#xA;developers omitting semicolons in JavaScript:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Why would any intelligent person want to make it harder for others&#xA;to understand what they&amp;rsquo;ve done, keep booby-traps in their code that&#xA;will cause errors or deliberately write in a way that might make&#xA;others stumble? Is this some kind of code-trolling I don&amp;rsquo;t get?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I have the same exact complaints when people don&amp;rsquo;t use parentheses in&#xA;their Ruby code.  You can argue all day about your reasoning but when&#xA;you run your code through &lt;code&gt;ruby -w&lt;/code&gt; you&amp;rsquo;ll see all sorts of warnings&#xA;about ambiguous code.&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>RubyGem Version Specifiers</title>
      <link>https://freerangebits.com/posts/2012/04/gem-versions/</link>
      <pubDate>Tue, 03 Apr 2012 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2012/04/gem-versions/</guid>
      <description>&lt;p&gt;When writing an application in Ruby it&amp;rsquo;s likely that you&amp;rsquo;ll make use&#xA;of several open source libraries that come packaged as &lt;a href=&#34;http://docs.rubygems.org/&#34; target=&#34;_blank&#34;&gt;RubyGems&lt;/a&gt;.&#xA;But do you know which versions of those gems are getting loaded into&#xA;your application?  Will all versions work with your application?&lt;/p&gt;&#xA;&lt;p&gt;It doesn&amp;rsquo;t matter if you are loading gems into your application&#xA;directly using &lt;code&gt;require&lt;/code&gt; statements or using a tool like &lt;a href=&#34;http://gembundler.com/&#34; target=&#34;_blank&#34;&gt;Bundler&lt;/a&gt;,&#xA;you should always use version specifiers to future proof your&#xA;application.&lt;/p&gt;&#xA;&lt;h2 id=&#34;using-version-specifiers&#34;&gt;Using Version Specifiers&lt;/h2&gt;&#xA;&lt;p&gt;It&amp;rsquo;s often tempting to load a library without regard for which version&#xA;you are about to use:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-ruby&#34; data-lang=&#34;ruby&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;# In your application&amp;#39;s source code&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;require(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;nokogiri&amp;#39;&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;# Or, in a Bundler Gemfile&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;gem(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;nokogiri&amp;#39;&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;But that&amp;rsquo;s equivalent to using the following version specifiers:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-ruby&#34; data-lang=&#34;ruby&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;# In your application&amp;#39;s source code&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;gem(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;nokogiri&amp;#39;&lt;/span&gt;, &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;&amp;gt;= 0.0&amp;#39;&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;require(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;nokogiri&amp;#39;&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;# Or, in a Bundler Gemfile&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;gem(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;nokogiri&amp;#39;&lt;/span&gt;, &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;&amp;gt;= 0.0&amp;#39;&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;As you can see, version specifiers are comprised of a version operator&#xA;and a version number.  Omitting the version specifier or using the&#xA;&lt;code&gt;&amp;gt;=&lt;/code&gt; version operator is almost always a bad idea.&lt;/p&gt;&#xA;&lt;p&gt;The code above means that you&amp;rsquo;ll happily use any version of&#xA;the Nokogiri gem.  But is that a true statement?  Will your code&#xA;really work with any version?  What about really old versions of&#xA;Nokogiri?  What about the version of Nokogiri that&amp;rsquo;s going to be&#xA;released in 2 years?&lt;/p&gt;&#xA;&lt;p&gt;It&amp;rsquo;s easy to imagine a situation where you upgrade a gem to support a&#xA;new application and in the process break an old application.  If the&#xA;older application had a restrictive version specifier it would keep&#xA;working as long as you had a compatible version of the gem installed.&lt;/p&gt;&#xA;&lt;p&gt;I said it&amp;rsquo;s &lt;em&gt;almost&lt;/em&gt; always a bad idea to use &lt;code&gt;&amp;gt;=&lt;/code&gt; because there&amp;rsquo;s at&#xA;least one legitimate use for it.  RubyGems allows you to give more&#xA;than one version specifier and Bundler supports this as well:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-ruby&#34; data-lang=&#34;ruby&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;gem(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;nokogiri&amp;#39;&lt;/span&gt;, &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;&amp;gt;= 1.0.0&amp;#39;&lt;/span&gt;, &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;&amp;lt; 2.0.0&amp;#39;&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Which means that you&amp;rsquo;ll take any version of Nokogiri starting at 1.0.0&#xA;but not 2.0.0 or higher.  Combining version specifiers like this gives&#xA;you a lot of control over which version is going to be loaded into&#xA;your application, but it&amp;rsquo;s a bit cumbersome.  If all you want to do is&#xA;restrict a gem to a specific major release (e.g. 1.x but not 2.x) then&#xA;you can use the pessimistic version operator (&lt;code&gt;~&amp;gt;&lt;/code&gt;).&lt;/p&gt;&#xA;&lt;h2 id=&#34;the-pessimistic-version-operator&#34;&gt;The Pessimistic Version Operator&lt;/h2&gt;&#xA;&lt;p&gt;The pessimistic version operator (&lt;code&gt;~&amp;gt;&lt;/code&gt;) allows you to state that your&#xA;application works with future versions of a gem in a safe way.  Of&#xA;course this only works if the author of that gem introduces changes&#xA;that break backward compatibility in a predictable way (e.g. going&#xA;from version 1.0.0 to 1.0.1 doesn&amp;rsquo;t break your application).&lt;/p&gt;&#xA;&lt;p&gt;For example, if you trust that the authors of the Nokogiri gem won&amp;rsquo;t&#xA;break backwards compatibility until version 2.0.0 you can load the gem&#xA;using the pessimistic version operator:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-ruby&#34; data-lang=&#34;ruby&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;gem(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;nokogiri&amp;#39;&lt;/span&gt;, &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;~&amp;gt; 1.0&amp;#39;&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;But, if you only trusted them to maintain backwards compatibility in&#xA;the 1.5.x releases you could specify the version as:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-ruby&#34; data-lang=&#34;ruby&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;gem(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;nokogiri&amp;#39;&lt;/span&gt;, &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;~&amp;gt; 1.5.0&amp;#39;&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The pessimistic version operator can be controlled by how specific you&#xA;make the version number.  It works by stripping off the last digit you&#xA;specify and incrementing the remaining version.  So 1.5.0 becomes 1.6&#xA;and 1.0 becomes 2.0.  It then restricts the version of the gem&#xA;starting with the version you specified up to but not including the&#xA;incremented version.  Here are some examples:&lt;/p&gt;&#xA;&lt;table&gt;&#xA;&lt;thead&gt;&#xA;&lt;tr&gt;&#xA;&lt;th style=&#34;text-align:left&#34;&gt;Pessimistic Version&lt;/th&gt;&#xA;&lt;th style=&#34;text-align:left&#34;&gt;Range Restriction&lt;/th&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/thead&gt;&#xA;&lt;tbody&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&#34;text-align:left&#34;&gt;&lt;code&gt;gem(&#39;nokogiri&#39;, &#39;~&amp;gt; 1.0&#39;)&lt;/code&gt;&lt;/td&gt;&#xA;&lt;td style=&#34;text-align:left&#34;&gt;&lt;code&gt;gem(&#39;nokogiri&#39;, &#39;&amp;gt;= 1.0&#39;, &#39;&amp;lt; 2.0&#39;)&lt;/code&gt;&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&#34;text-align:left&#34;&gt;&lt;code&gt;gem(&#39;nokogiri&#39;, &#39;~&amp;gt; 1.5.0&#39;)&lt;/code&gt;&lt;/td&gt;&#xA;&lt;td style=&#34;text-align:left&#34;&gt;&lt;code&gt;gem(&#39;nokogiri&#39;, &#39;&amp;gt;= 1.5.0&#39;, &#39;&amp;lt; 1.6.0&#39;)&lt;/code&gt;&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&#34;text-align:left&#34;&gt;&lt;code&gt;gem(&#39;nokogiri&#39;, &#39;~&amp;gt; 1.5.3&#39;)&lt;/code&gt;&lt;/td&gt;&#xA;&lt;td style=&#34;text-align:left&#34;&gt;&lt;code&gt;gem(&#39;nokogiri&#39;, &#39;&amp;gt;= 1.5.3&#39;, &#39;&amp;lt; 1.6.0&#39;)&lt;/code&gt;&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;h2 id=&#34;available-operators&#34;&gt;Available Operators&lt;/h2&gt;&#xA;&lt;p&gt;RubyGems provides a complete set of version operators that allow you&#xA;to specify which versions of a gem your application can work with.  If&#xA;you don&amp;rsquo;t use an operator and just use a version number you lock your&#xA;application to that specific version, it&amp;rsquo;s shorthand for using the&#xA;equal (&lt;code&gt;=&lt;/code&gt;) operator.&lt;/p&gt;&#xA;&lt;p&gt;Here&amp;rsquo;s a list of the of the operators supported in RubyGems:&lt;/p&gt;&#xA;&lt;table&gt;&#xA;&lt;thead&gt;&#xA;&lt;tr&gt;&#xA;&lt;th style=&#34;text-align:left&#34;&gt;Operator&lt;/th&gt;&#xA;&lt;th style=&#34;text-align:left&#34;&gt;Meaning&lt;/th&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/thead&gt;&#xA;&lt;tbody&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&#34;text-align:left&#34;&gt;&lt;code&gt;=&lt;/code&gt;&lt;/td&gt;&#xA;&lt;td style=&#34;text-align:left&#34;&gt;Equal to (default)&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&#34;text-align:left&#34;&gt;&lt;code&gt;!=&lt;/code&gt;&lt;/td&gt;&#xA;&lt;td style=&#34;text-align:left&#34;&gt;Not equal to&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&#34;text-align:left&#34;&gt;&lt;code&gt;&amp;gt;&lt;/code&gt;&lt;/td&gt;&#xA;&lt;td style=&#34;text-align:left&#34;&gt;Greater than&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&#34;text-align:left&#34;&gt;&lt;code&gt;&amp;gt;=&lt;/code&gt;&lt;/td&gt;&#xA;&lt;td style=&#34;text-align:left&#34;&gt;Greater than or equal to&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&#34;text-align:left&#34;&gt;&lt;code&gt;&amp;lt;&lt;/code&gt;&lt;/td&gt;&#xA;&lt;td style=&#34;text-align:left&#34;&gt;Less than&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&#34;text-align:left&#34;&gt;&lt;code&gt;&amp;lt;=&lt;/code&gt;&lt;/td&gt;&#xA;&lt;td style=&#34;text-align:left&#34;&gt;Less than or equal to&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&#34;text-align:left&#34;&gt;&lt;code&gt;~&amp;gt;&lt;/code&gt;&lt;/td&gt;&#xA;&lt;td style=&#34;text-align:left&#34;&gt;Pessimistically greater than or equal to&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;</description>
    </item>
    <item>
      <title>Ruby/Rails Compatibility Matrix</title>
      <link>https://freerangebits.com/posts/2012/03/ror-compatibility/</link>
      <pubDate>Wed, 14 Mar 2012 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2012/03/ror-compatibility/</guid>
      <description>&lt;p&gt;I found myself needing to figure out which versions of Ruby on Rails&#xA;run under which versions of Ruby.  I couldn&amp;rsquo;t find a compatibility&#xA;chart so I put this together:&lt;/p&gt;&#xA;&lt;table&gt;&#xA;&lt;thead&gt;&#xA;&lt;tr&gt;&#xA;&lt;th style=&#34;text-align:left&#34;&gt;Rails Version&lt;/th&gt;&#xA;&lt;th style=&#34;text-align:left&#34;&gt;Possible Ruby Versions&lt;/th&gt;&#xA;&lt;th style=&#34;text-align:left&#34;&gt;Recommended Ruby Version&lt;/th&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/thead&gt;&#xA;&lt;tbody&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&#34;text-align:left&#34;&gt;1.0&amp;ndash;2.1&lt;/td&gt;&#xA;&lt;td style=&#34;text-align:left&#34;&gt;1.8.6&lt;/td&gt;&#xA;&lt;td style=&#34;text-align:left&#34;&gt;1.8.6&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&#34;text-align:left&#34;&gt;2.2&lt;/td&gt;&#xA;&lt;td style=&#34;text-align:left&#34;&gt;1.8.6 or 1.8.7&lt;/td&gt;&#xA;&lt;td style=&#34;text-align:left&#34;&gt;1.8.7&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&#34;text-align:left&#34;&gt;2.3&lt;/td&gt;&#xA;&lt;td style=&#34;text-align:left&#34;&gt;1.8.6, 1.8.7, or 1.9.1&lt;/td&gt;&#xA;&lt;td style=&#34;text-align:left&#34;&gt;1.8.7&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&#34;text-align:left&#34;&gt;3.0&amp;ndash;3.2&lt;/td&gt;&#xA;&lt;td style=&#34;text-align:left&#34;&gt;1.8.7, 1.9.2, or 1.9.3&lt;/td&gt;&#xA;&lt;td style=&#34;text-align:left&#34;&gt;1.9.3&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td style=&#34;text-align:left&#34;&gt;4.0&amp;ndash;&amp;hellip;&lt;/td&gt;&#xA;&lt;td style=&#34;text-align:left&#34;&gt;1.9.3 or 2.0.x&lt;/td&gt;&#xA;&lt;td style=&#34;text-align:left&#34;&gt;2.0.x&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;p&gt;&lt;strong&gt;Updated:&lt;/strong&gt; &lt;a href=&#34;http://weblog.rubyonrails.org/2013/2/25/Rails-4-0-beta1/&#34; target=&#34;_blank&#34;&gt;Rails 4.0 adds support for Ruby 2.0&lt;/a&gt;.&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>Ruby&#39;s catch/throw, goto&#39;s little brother</title>
      <link>https://freerangebits.com/posts/2012/03/ruby-goto/</link>
      <pubDate>Fri, 09 Mar 2012 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2012/03/ruby-goto/</guid>
      <description>&lt;p&gt;Last week Pat Shaughnessy discovered that there&amp;rsquo;s a pre-processor&#xA;definition in the Ruby 1.9 source code to&#xA;&lt;a href=&#34;http://patshaughnessy.net/2012/2/29/the-joke-is-on-us-how-ruby-1-9-supports-the-goto-statement&#34; target=&#34;_blank&#34;&gt;enable goto and label statements&lt;/a&gt; in a rather ugly&#xA;way:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;The &lt;code&gt;__goto__&lt;/code&gt; statement will cause the MRI Ruby 1.9 interpreter to&#xA;jump up to the &lt;code&gt;__label__&lt;/code&gt; statement on the first line, since they&#xA;both refer to the same symbol &lt;code&gt;:loop&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I don&amp;rsquo;t think there&amp;rsquo;s much use for &lt;code&gt;goto&lt;/code&gt; in a language like Ruby&#xA;considering that it&amp;rsquo;s garbage collected and you can release resources&#xA;using closures and &lt;code&gt;ensure&lt;/code&gt; blocks.  However, if you&amp;rsquo;re dying to play&#xA;with this, why not use goto&amp;rsquo;s little brother, &lt;code&gt;catch&lt;/code&gt; and &lt;code&gt;throw&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-ruby&#34; data-lang=&#34;ruby&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;class&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;Test&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#66d9ef&#34;&gt;def&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;foo&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;throw&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;:label&lt;/span&gt;, &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;foo&amp;#34;&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;should never get here&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#66d9ef&#34;&gt;end&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#66d9ef&#34;&gt;def&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;bar&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;bar&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#66d9ef&#34;&gt;end&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;end&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;test &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;Test&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;new&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;puts(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;foo -&amp;gt; &amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;catch&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;:label&lt;/span&gt;) {test&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;foo})&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;puts(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;bar -&amp;gt; &amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;catch&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;:label&lt;/span&gt;) {test&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;bar})&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;There&amp;rsquo;s not much to know about &lt;code&gt;catch&lt;/code&gt; and &lt;code&gt;throw&lt;/code&gt;.  You give a symbol&#xA;and a block to &lt;code&gt;catch&lt;/code&gt;, which acts like a goto label.  Any code that&#xA;uses &lt;code&gt;throw&lt;/code&gt; in that block, no matter how deep, will unwind and cause&#xA;the &lt;code&gt;catch&lt;/code&gt; block to terminate, returning the value given to throw.&lt;/p&gt;&#xA;&lt;p&gt;You can nest multiple &lt;code&gt;catch&lt;/code&gt; and &lt;code&gt;throw&lt;/code&gt; expressions using different&#xA;values for the label symbol.  Here&amp;rsquo;s another example:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-ruby&#34; data-lang=&#34;ruby&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;def&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;thrower&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#ae81ff&#34;&gt;10&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;times &lt;span style=&#34;color:#66d9ef&#34;&gt;do&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;|&lt;/span&gt;i&lt;span style=&#34;color:#f92672&#34;&gt;|&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#ae81ff&#34;&gt;10&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;times &lt;span style=&#34;color:#66d9ef&#34;&gt;do&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;|&lt;/span&gt;j&lt;span style=&#34;color:#f92672&#34;&gt;|&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      $stdout&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;puts(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;#{&lt;/span&gt;i&lt;span style=&#34;color:#e6db74&#34;&gt;}&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;.&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;#{&lt;/span&gt;j&lt;span style=&#34;color:#e6db74&#34;&gt;}&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#66d9ef&#34;&gt;throw&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;:label&lt;/span&gt;, j) &lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt; i &lt;span style=&#34;color:#f92672&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;2&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;and&lt;/span&gt; j &lt;span style=&#34;color:#f92672&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;2&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;end&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#66d9ef&#34;&gt;end&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;end&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;val &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;catch&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;:label&lt;/span&gt;) &lt;span style=&#34;color:#66d9ef&#34;&gt;do&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  thrower&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#66d9ef&#34;&gt;raise&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;should never get here&amp;#34;&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;end&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;$stdout&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;puts(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;val is &lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;#{&lt;/span&gt;val&lt;span style=&#34;color:#e6db74&#34;&gt;}&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description>
    </item>
    <item>
      <title>Fun stuff for Friday Feb. 24</title>
      <link>https://freerangebits.com/posts/2012/02/fun-friday-24/</link>
      <pubDate>Fri, 24 Feb 2012 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2012/02/fun-friday-24/</guid>
      <description>&lt;p&gt;It&amp;rsquo;s Friday, and an especially good one at that.  At least for me&#xA;since it marks the start of a much needed vacation.  Hopefully this&#xA;weekend will be good for everyone, and what better way to kick it off&#xA;than some fun and geeky articles and videos.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;If you&amp;rsquo;re in the market for a new keyboard and think you want to&#xA;create one yourself, look no further than the&#xA;&lt;a href=&#34;http://humblehacker.com/keyboard/&#34; target=&#34;_blank&#34;&gt;Humble Hacker Keyboard&lt;/a&gt;.  This thing looks very cool.&#xA;And if you think the layout is a bit crazy then you need to watch&#xA;&lt;a href=&#34;http://www.youtube.com/watch?v=9yg3s77nAMQ&#34; target=&#34;_blank&#34;&gt;this video&lt;/a&gt; of Tim Tyler&amp;rsquo;s keyboard. Via &lt;a href=&#34;http://hackaday.com/2012/02/16/microswitch-keyboard-gives-those-lazy-thumbs-a-workout/&#34; target=&#34;_blank&#34;&gt;Hack a Day&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Nathan Rice posted some pictures comparing&#xA;&lt;a href=&#34;http://machinegestalt.posterous.com/if-programming-languages-were-cars&#34; target=&#34;_blank&#34;&gt;programming languages to cars&lt;/a&gt; which is cute.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Eric Moritz put together a list of books that&#xA;&lt;a href=&#34;http://eric.themoritzfamily.com/books-every-self-taught-computer-scientist-should-read.html&#34; target=&#34;_blank&#34;&gt;every self-taught developer should read&lt;/a&gt;.  It seems&#xA;like a pretty reasonable list.  Of course, I would add&#xA;&lt;a href=&#34;http://pragprog.com/the-pragmatic-programmer&#34; target=&#34;_blank&#34;&gt;The Pragmatic Programmer&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;There&amp;rsquo;s a fairly interesting article over at the BBC about&#xA;&lt;a href=&#34;http://www.bbc.co.uk/news/magazine-16964783&#34; target=&#34;_blank&#34;&gt;the myth of the eight-hour sleep&lt;/a&gt;.  For whatever reason&#xA;I&amp;rsquo;ve found that software developers seem to be interested in sleep&#xA;patterns and sleep experiments.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Longtime fans of Apache will be glad to hear that version 2.4&#xA;&lt;a href=&#34;http://www.apache.org/dist/httpd/Announcement2.4.html&#34; target=&#34;_blank&#34;&gt;has been release&lt;/a&gt; with some interesting features and&#xA;performance changes that match up with Nginx.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Finally, you may want to &lt;a href=&#34;https://www.eff.org/deeplinks/2012/02/how-remove-your-google-search-history-googles-new-privacy-policy-takes-effect&#34; target=&#34;_blank&#34;&gt;remove your search history&lt;/a&gt;&#xA;from Google before their new privacy policy goes into effect on&#xA;3/1.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;As always, have a wonderful weekend.  Recharge your batteries and&#xA;prepare yourself for a return to hacking on Monday.&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>Fun stuff for Friday Feb. 10</title>
      <link>https://freerangebits.com/posts/2012/02/fun-friday-10/</link>
      <pubDate>Fri, 10 Feb 2012 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2012/02/fun-friday-10/</guid>
      <description>&lt;p&gt;This is going to be fun.  I haven&amp;rsquo;t written a Fun Friday article this&#xA;year and my queue of things to share is sizable.  To top it off, I&#xA;haven&amp;rsquo;t been keeping my self-imposed quota of at least one article a&#xA;day, so my general queue of articles to comment on has grown out of&#xA;control.  This post will contain some fun things I want to share as&#xA;well as a few backlogged articles that are pretty interesting.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Want to relive the fun of rebooting older operating systems?&#xA;&lt;a href=&#34;http://www.therestartpage.com/&#34; target=&#34;_blank&#34;&gt;The Restart Page&lt;/a&gt; has you covered.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Developers are religious about the text editor they use, that&amp;rsquo;s no&#xA;surprise.  Need to vent your anger for &lt;a href=&#34;http://www.eclipse.org/eclipse/&#34; target=&#34;_blank&#34;&gt;Eclipse&lt;/a&gt;?  Look no further&#xA;than &lt;a href=&#34;http://www.ihateeclipse.com/&#34; target=&#34;_blank&#34;&gt;I Hate Eclipse&lt;/a&gt;.  If you&amp;rsquo;re looking for a new&#xA;text editor &lt;a href=&#34;http://www.sublimetext.com/blog/articles/sublime-text-2-beta&#34; target=&#34;_blank&#34;&gt;Sublime Text 2 Beta&lt;/a&gt; is out.  Oh, and&#xA;&lt;a href=&#34;https://freerangebits.com/tags/emacs/&#34;&gt;Emacs&lt;/a&gt; is the one true editor.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Parse has found an interesting way to filter through resume&#xA;overload often accompanied by job postings.  To apply you have to&#xA;&lt;a href=&#34;https://www.parse.com/jobs&#34; target=&#34;_blank&#34;&gt;submit JSON to their API&lt;/a&gt;.  Smart.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Ash Moran wrote an article to help you &lt;a href=&#34;http://blog.patchspace.co.uk/why-you-shouldnt-hire-more-developers&#34; target=&#34;_blank&#34;&gt;get your crap together&lt;/a&gt;&#xA;instead of just throwing more developers at the problem.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;If you&amp;rsquo;re not up on your &lt;code&gt;diff&lt;/code&gt; and &lt;code&gt;patch&lt;/code&gt; ninja skills&#xA;&lt;a href=&#34;http://www.cocoanetics.com/2011/12/how-to-make-and-apply-patches/&#34; target=&#34;_blank&#34;&gt;this article&lt;/a&gt; walks you through creating and&#xA;applying patches.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Do you find the Java syntax to be too verbose?  Eleftheria&#xA;Drosopoulou says &lt;a href=&#34;http://www.javacodegeeks.com/2012/01/why-i-like-verbosity-of-java.html&#34; target=&#34;_blank&#34;&gt;she likes the verbosity of Java&lt;/a&gt; because&#xA;it forces you to understand the code you are using.  I can see&#xA;where she&amp;rsquo;s coming from but I think the verbosity of the syntax&#xA;actually impedes its readability.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Speaking of Java, Marc Kuo has wrote a series of articles about&#xA;why he loves &lt;a href=&#34;http://common-lisp.net/&#34; target=&#34;_blank&#34;&gt;Common Lisp&lt;/a&gt; and hates Java.  &lt;a href=&#34;https://kuomarc.wordpress.com/2012/01/27/why-i-love-common-lisp-and-hate-java/&#34; target=&#34;_blank&#34;&gt;Part 1&lt;/a&gt; and&#xA;&lt;a href=&#34;http://kuomarc.wordpress.com/2012/02/02/why-i-love-common-lisp-and-hate-java-part-ii-code-examples/&#34; target=&#34;_blank&#34;&gt;Part 2&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;&lt;a href=&#34;http://jgneuf.wordpress.com/2011/12/20/all-programmers-are-self-taught/&#34; target=&#34;_blank&#34;&gt;All Programmers Are Self-Taught&lt;/a&gt; is short post&#xA;about how a computer science education doesn&amp;rsquo;t actually teach you&#xA;how to program.  I tend to agree but the author is still a&#xA;student, so maybe he needs to take a few more classes.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;That should give you plenty to read over the weekend.&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>Using Haskell to improve your C&#43;&#43;</title>
      <link>https://freerangebits.com/posts/2012/02/haskell-cxx/</link>
      <pubDate>Mon, 06 Feb 2012 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2012/02/haskell-cxx/</guid>
      <description>&lt;p&gt;I find myself drawn more and more to &lt;a href=&#34;http://www.haskell.org/&#34; target=&#34;_blank&#34;&gt;Haskell&lt;/a&gt;.  Any language that&#xA;helps a developer write solid code without making you feel like you&amp;rsquo;re&#xA;using training wheels is a huge plus in my book.  Functional&#xA;programming has also opened my eyes to all sorts of pitfalls with&#xA;imperative programming.&lt;/p&gt;&#xA;&lt;p&gt;Even if you&amp;rsquo;re put off by Haskell or functional programming there&amp;rsquo;s a&#xA;lot you can learn and both can have a positive influence on your&#xA;imperative programming skills.  At least that&amp;rsquo;s what they say.&lt;/p&gt;&#xA;&lt;p&gt;The folks over at Valletta Ventures have a &lt;a href=&#34;http://vallettaventures.com/post/17090296373/haskells-effect-on-my-c-exploit-the-type-system&#34; target=&#34;_blank&#34;&gt;short blog post&lt;/a&gt;&#xA;about how their C++ code has changed for the better after thinking&#xA;about problems functionally:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;There is no doubt that time spent playing with Haskell has taught me&#xA;to exploit the type system when coding in C++, but the most lasting&#xA;effect may be when I abandon C++ altogether.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I would have liked to see a &lt;em&gt;lot&lt;/em&gt; more code and a more complete&#xA;discussion on how functional thinking can improve imperative code.  As&#xA;I dig deeper into Haskell I&amp;rsquo;ll post some thoughts on how it&amp;rsquo;s making&#xA;my daily imperative programming better or just different.&lt;/p&gt;&#xA;&lt;p&gt;If you haven&amp;rsquo;t exposed yourself to Haskell yet I highly recommend&#xA;watching &lt;a href=&#34;http://ontwik.com/haskell/simon-peyton-jones-a-taste-of-haskell/&#34; target=&#34;_blank&#34;&gt;A Taste of Haskell&lt;/a&gt; the next time you have 3 hours to&#xA;completely geek off.  Make sure you download the slides and follow&#xA;along.&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>Rails 4.0 will drop support for Ruby 1.8.7</title>
      <link>https://freerangebits.com/posts/2012/02/rails-drops-ruby18/</link>
      <pubDate>Thu, 02 Feb 2012 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2012/02/rails-drops-ruby18/</guid>
      <description>&lt;p&gt;Back in 2010 when Ruby on Rails 3.0 was released the core team&#xA;&lt;a href=&#34;http://guides.rubyonrails.org/3_0_release_notes.html#rails-3-requires-at-least-ruby-1-8-7&#34; target=&#34;_blank&#34;&gt;dropped&lt;/a&gt; support for Ruby 1.8.x except for version 1.8.7.&#xA;With 4.0 scheduled for a release sometime in the Summer of 2012 all&#xA;versions of Ruby 1.8 will &lt;a href=&#34;http://weblog.rubyonrails.org/2011/12/20/rails-master-is-now-4-0-0-beta&#34; target=&#34;_blank&#34;&gt;officially be dropped&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;There&amp;rsquo;s not a lot of details about what we&amp;rsquo;re going to include in&#xA;Rails 4.0 yet as the primary purpose for bumping the major version&#xA;number is to drop Ruby 1.8.7 support.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;This coincides with the Ruby core team &lt;a href=&#34;https://freerangebits.com/posts/2011/10/ruby-18/&#34;&gt;dropping support for 1.8&lt;/a&gt;&#xA;this Summer as well.&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>Why estimating is hard</title>
      <link>https://freerangebits.com/posts/2012/01/estimating/</link>
      <pubDate>Tue, 31 Jan 2012 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2012/01/estimating/</guid>
      <description>&lt;p&gt;Software developers are notoriously bad at estimating, to the point&#xA;where project managers and bosses regularly double or even triple our&#xA;estimates.  Tools like calculating developer velocities help average&#xA;out these errors but also tend to cover them up.  So why is it so hard&#xA;to estimate development work?&lt;/p&gt;&#xA;&lt;p&gt;Diego Basch &lt;a href=&#34;http://diegobasch.com/why-software-development-estimations-are-regu&#34; target=&#34;_blank&#34;&gt;hits the nail on the head&lt;/a&gt; in his opposition to the&#xA;idea that we get better at estimating over time because we&amp;rsquo;re doing&#xA;the same sort of things over and over again:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Real software development is about doing something that you&amp;rsquo;ve never&#xA;done before. That&amp;rsquo;s why all stupid analogies about routine real-life&#xA;stuff break.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;As a freelance software developer I tend to do a lot of the same&#xA;things over and over again but with small changes in the details.&#xA;This has probably given me a false sense of being a good estimator.  I&#xA;think I need better problems to solve.&lt;/p&gt;&#xA;&lt;p&gt;Speaking of estimating, if software developers are so bad at&#xA;estimating why do managers and stakeholders think they are so much&#xA;better?  How often does your boss/client suggest that your current&#xA;task should only take you 30 minutes?  What insight do they have that&#xA;we don&amp;rsquo;t?&lt;/p&gt;&#xA;&lt;p&gt;I used to work in the cube next to my manager.  I would hear him on&#xA;the speakerphone with other managers committing me to tasks and giving&#xA;them estimates.  This guy could barely use a computer yet here he was&#xA;saying stuff like &amp;ldquo;that should take a day&amp;rdquo;.&lt;/p&gt;&#xA;&lt;p&gt;Maybe that&amp;rsquo;s why we have such a bad reputation for estimating.&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>Fixing programming by besting current languages</title>
      <link>https://freerangebits.com/posts/2012/01/besting-declarative-programming/</link>
      <pubDate>Thu, 26 Jan 2012 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2012/01/besting-declarative-programming/</guid>
      <description>&lt;p&gt;Jon BeltranDeHeredia&amp;rsquo;s rant on &lt;a href=&#34;http://jonbho.net/2012/01/24/i-want-to-fix-programming/&#34; target=&#34;_blank&#34;&gt;why programming is broken&lt;/a&gt; has&#xA;turned into a very interesting thought experiment.  First, Jon&#xA;describes why he thinks programming is broken:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Every step of the way, in every statement, line of code, function&#xA;call or sequence-point, if you want to write good code, you need to&#xA;think about all the different possible states of the whole&#xA;program. This is invisible and impossible to&#xA;define. Provably. Always. In all existing languages. That&amp;rsquo;s the&#xA;reason 100% code-coverage unit-testing doesn&amp;rsquo;t guarantee bug-free&#xA;code, and it never will. This is also the reason bad programmers&#xA;don&amp;rsquo;t become good: they just can&amp;rsquo;t think about all those possible&#xA;cases in a structured way.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Then he describes his vision for a new programming language that looks&#xA;like the love child of Haskell and Prolog.&lt;/p&gt;&#xA;&lt;p&gt;If you&amp;rsquo;re looking for something geeky to spend your free time on I&#xA;suggest taking some ideas from the comments on Jon&amp;rsquo;s article.  Readers&#xA;are posting links to all sorts of interesting things such as&#xA;executable specifications, the failures of Prolog, proof management&#xA;systems, and the 4GL fiasco.&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>I took some programming in school != programmer</title>
      <link>https://freerangebits.com/posts/2012/01/amateur-programming/</link>
      <pubDate>Tue, 24 Jan 2012 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2012/01/amateur-programming/</guid>
      <description>&lt;p&gt;How often does a boss/client tell you they have a good sense of how&#xA;long something should take because they &amp;ldquo;took some programming in&#xA;school&amp;rdquo;.  I can&amp;rsquo;t tell you all the times I&amp;rsquo;ve picked up a train wreck&#xA;project written by someone who &amp;ldquo;knew enough to be dangerous&amp;rdquo;.  Being&#xA;good with a computer or taking a Java course in college does not make&#xA;one a programmer.&lt;/p&gt;&#xA;&lt;p&gt;Yossi Kreinin has a more &lt;a href=&#34;http://www.yosefk.com/blog/why-programming-isnt-for-everyone.html&#34; target=&#34;_blank&#34;&gt;thoughtful rant&lt;/a&gt; in his article:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;When something useful can not be done quickly and isn&amp;rsquo;t the average&#xA;person&amp;rsquo;s idea of fun, it becomes the business of professionals - or&#xA;hardcore hobbyists indistinguishable from professionals.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;In my experience most non-programmers don&amp;rsquo;t have the perseverance to&#xA;really understand something when things get tough.  They&amp;rsquo;re more&#xA;interested in the end result than the process.  All of the good&#xA;programmers I know enjoy the process just as much as the end result.&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>2012 seems to be the year for learning to code</title>
      <link>https://freerangebits.com/posts/2012/01/learn-to-code/</link>
      <pubDate>Mon, 02 Jan 2012 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2012/01/learn-to-code/</guid>
      <description>&lt;p&gt;If your new year&amp;rsquo;s resolutions include learning how to write code, or&#xA;if that one buddy who keeps talking about learning to program is still&#xA;bugging you, this might be your lucky year.&lt;/p&gt;&#xA;&lt;p&gt;Mike Gehard thinks you should start with the &lt;a href=&#34;https://freerangebits.com/tags/ruby/&#34;&gt;Ruby&lt;/a&gt; programming&#xA;language so he &lt;a href=&#34;http://msgehard.github.com/ruby-learning/&#34; target=&#34;_blank&#34;&gt;created an outline of assignments&lt;/a&gt; that will put&#xA;you on the right path:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Welcome to my attempt at coming up with a reproducible outline that&#xA;will allow any non-programmer to become a software developer in the&#xA;Ruby programming language and get a job writing web applications&#xA;using the Ruby on Rails framework.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Pulkit Arora put together a &lt;a href=&#34;http://pulkitarora.wordpress.com/2011/03/12/91-ways-to-become-the-coolest-developer-in-the-world/&#34; target=&#34;_blank&#34;&gt;similar outline&lt;/a&gt; last year that is&#xA;much more exhaustive than Mike&amp;rsquo;s.  It&amp;rsquo;s probably safe to say that&#xA;Pulkit&amp;rsquo;s list is more like a software developer&amp;rsquo;s road map.&lt;/p&gt;&#xA;&lt;p&gt;Finally, the developers behind &lt;a href=&#34;http://www.codecademy.com/&#34; target=&#34;_blank&#34;&gt;Codecademy&lt;/a&gt; are at it again, this&#xA;time with &lt;a href=&#34;http://codeyear.com/&#34; target=&#34;_blank&#34;&gt;Code Year&lt;/a&gt;, a site that sends you a weekly&#xA;interactive lesson designed to teach you how to program.  There&#xA;doesn&amp;rsquo;t seem to be much more information than that, so take the plunge&#xA;and type in your email address.&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>Hashing algorithm vulnerable to denial of service</title>
      <link>https://freerangebits.com/posts/2011/12/hash-table-dos/</link>
      <pubDate>Thu, 29 Dec 2011 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2011/12/hash-table-dos/</guid>
      <description>&lt;p&gt;It&amp;rsquo;s likely that the hashing algorithm in your favorite language is&#xA;vulnerable to a &lt;a href=&#34;http://arstechnica.com/business/news/2011/12/huge-portions-of-web-vulnerable-to-hashing-denial-of-service-attack.ars&#34; target=&#34;_blank&#34;&gt;denial of service attack&lt;/a&gt;.  While Perl fixed this&#xA;forever ago, other languages have been caught with their pants down:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&amp;hellip; the flaw affects a long list of technologies, including PHP,&#xA;ASP.NET, Java, Python, Ruby, Apache Tomcat, Apache Geronimo, Jetty,&#xA;and Glassfish, as well as Google&amp;rsquo;s open source JavaScript engine&#xA;V8. The vendors and developers behind these technologies are working&#xA;to close the vulnerability, with Microsoft warning of &amp;ldquo;imminent&#xA;public release of exploit code&amp;rdquo; for what is known as a hash&#xA;collision attack.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;There&amp;rsquo;s already a new release of Ruby &lt;a href=&#34;http://www.ruby-lang.org/en/news/2011/12/28/denial-of-service-attack-was-found-for-rubys-hash-algorithm/&#34; target=&#34;_blank&#34;&gt;that fixes the&#xA;vulnerability&lt;/a&gt;, ruby 1.8.7-p357.  Ruby 1.9.x is not vulnerable to&#xA;this attack.&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>Java is dead, long live Java</title>
      <link>https://freerangebits.com/posts/2011/12/openjdk/</link>
      <pubDate>Wed, 21 Dec 2011 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2011/12/openjdk/</guid>
      <description>&lt;p&gt;If you only caught the headline from the recent &lt;a href=&#34;http://www.omgubuntu.co.uk/2011/12/java-to-be-removed-from-ubuntu-uninstalled-from-user-machines/&#34; target=&#34;_blank&#34;&gt;OMGUbuntu&lt;/a&gt;&#xA;article about Java being removed from Ubuntu, you may want to catch&#xA;the &lt;a href=&#34;http://blogs.computerworlduk.com/simon-says/2011/12/why-java-isnt-dead-on-ubuntu/index.htm&#34; target=&#34;_blank&#34;&gt;whole story&lt;/a&gt; from Simon Phipps:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Java is not being removed from Ubuntu. OpenJDK is the open source&#xA;version Java, is developed primarily by Oracle, is becoming the&#xA;reference implementation and is available in Ubuntu. The Sun-Java&#xA;packages under the DLJ were a temporary stop-gap we put in place&#xA;before Java was liberated as GPL. Removing these packages is just&#xA;housekeeping.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I guess Java lives on.&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>Fun stuff for Friday Dec. 16</title>
      <link>https://freerangebits.com/posts/2011/12/fun-friday-16/</link>
      <pubDate>Fri, 16 Dec 2011 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2011/12/fun-friday-16/</guid>
      <description>&lt;p&gt;The holiday season is in full swing and for a lot of people this&#xA;Friday marks the start of a long vacation.  To celebrate while keeping&#xA;your mind sharp, here are a few things to check out over the weekend:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;If you missed it, Python was &lt;a href=&#34;http://www.blog.pythonlibrary.org/2011/12/07/python-voted-best-programming-language-3-years-running/&#34; target=&#34;_blank&#34;&gt;voted best language&lt;/a&gt; for the&#xA;third year running by readers of &lt;a href=&#34;http://www.linuxjournal.com/slideshow/readers-choice-2011?page=27&#34; target=&#34;_blank&#34;&gt;Linux Magazine&lt;/a&gt;.  C++ was&#xA;the runner up, which sort of makes sense.  A lot of C++ developers&#xA;embed Python in their applications.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;&lt;a href=&#34;http://macromates.com/&#34; target=&#34;_blank&#34;&gt;TextMate&lt;/a&gt; (the popular Mac OS X text editor) is getting a&#xA;refresh with 2.0-Alpha out.  Matt Gemmell wrote &lt;a href=&#34;http://mattgemmell.com/2011/12/13/dear-textmate/&#34; target=&#34;_blank&#34;&gt;a letter to&#xA;TextMate&lt;/a&gt; explaining why their affair had to end.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Speaking of Mac OS X, the crew over at &lt;a href=&#34;http://welovemacruby.com/&#34; target=&#34;_blank&#34;&gt;We Love MacRuby&lt;/a&gt;&#xA;is trying to persuade Apple to support MacRuby on iOS.  If you&amp;rsquo;d&#xA;like to write iOS applications using Ruby you should head over to&#xA;their site and join the campaign.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;David Tchepak, like a lot of software developers, has decided to&#xA;move away from good ol&amp;rsquo; QWERTY and try &lt;a href=&#34;http://colemak.com/&#34; target=&#34;_blank&#34;&gt;Colemak&lt;/a&gt; instead.  He&#xA;wrote an &lt;a href=&#34;http://www.davesquared.net/2011/12/daves-not-so-excellent-typing-adventure.html&#34; target=&#34;_blank&#34;&gt;interesting article&lt;/a&gt; about how the transition has&#xA;been going.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;John Larson wrote a &lt;a href=&#34;http://blog.jpl-consulting.com/2011/12/why-i-will-never-feel-threatened-by-programmers-in-india/&#34; target=&#34;_blank&#34;&gt;thought provoking essay&lt;/a&gt; about cheap&#xA;software development labor (mostly overseas).  As a freelance&#xA;software developer I can attest to having to rewrite a lot of&#xA;software that was originally developed overseas.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Some videos to watch: The micromouse &lt;a href=&#34;http://www.youtube.com/watch?v=CLwICJKV4dw&#34; target=&#34;_blank&#34;&gt;won a maze race&lt;/a&gt;&#xA;in 4 seconds.  Of course, it previously had exposure to the maze&#xA;for training (via &lt;a href=&#34;http://hackaday.com/2011/12/02/micromouse-wins-2011-maze-race-in-under-4-seconds/&#34; target=&#34;_blank&#34;&gt;Hack a Day&lt;/a&gt;).  &lt;a href=&#34;http://www.youtube.com/watch?v=z2j69eI9ob8&#34; target=&#34;_blank&#34;&gt;This hexabot&lt;/a&gt;&#xA;looks like a Jellyfish (via &lt;a href=&#34;http://hackaday.com/2011/12/12/sphere-morphing-hexabot-is-a-mechanical-jellyfish/&#34; target=&#34;_blank&#34;&gt;Hack a Day&lt;/a&gt;).  And finally, a&#xA;lizard &lt;a href=&#34;http://www.youtube.com/watch?v=WTpldq3myV0&#34; target=&#34;_blank&#34;&gt;uses its tongue&lt;/a&gt; to play a touchscreen game (via&#xA;&lt;a href=&#34;http://kottke.org/11/12/lizard-squashes-ants-in-touchscreen-game&#34; target=&#34;_blank&#34;&gt;kottke&lt;/a&gt;).&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Have an excellent weekend!&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>PostgreSQL as a key-value store</title>
      <link>https://freerangebits.com/posts/2011/12/postgresql-kv-store/</link>
      <pubDate>Tue, 13 Dec 2011 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2011/12/postgresql-kv-store/</guid>
      <description>&lt;p&gt;I just read an &lt;a href=&#34;http://blog.creapptives.com/post/14062057061/the-key-value-store-everyone-ignored-postgresql&#34; target=&#34;_blank&#34;&gt;interesting article&lt;/a&gt; about using &lt;a href=&#34;http://www.postgresql.org/&#34; target=&#34;_blank&#34;&gt;PostgreSQL&lt;/a&gt;&#xA;as a key-value store using the &lt;a href=&#34;http://www.postgresql.org/docs/9.1/static/hstore.html&#34; target=&#34;_blank&#34;&gt;hstore&lt;/a&gt; module:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Yes I know you are really happy with your &amp;ldquo;persistent&amp;rdquo; Key Value&#xA;store. But did anybody notice hstore that comes along Postgresql. I&#xA;find Postgresql to be a really great RDBMS that has been ignored all&#xA;the time.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Okay, maybe the English in this article isn&amp;rsquo;t that great, but if you&#xA;haven&amp;rsquo;t looked into hstore before it might spark your interest.&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>Improving your skills by reading commits</title>
      <link>https://freerangebits.com/posts/2011/12/commit-learning/</link>
      <pubDate>Wed, 07 Dec 2011 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2011/12/commit-learning/</guid>
      <description>&lt;p&gt;Pat Shaughnessy has a great idea for people looking to improve their&#xA;Ruby skills, &lt;a href=&#34;http://patshaughnessy.net/2011/12/6/learning-from-the-masters-some-of-my-favorite-rails-commits&#34; target=&#34;_blank&#34;&gt;study commits&lt;/a&gt; to Rails:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;There are plenty of examples of elegant code, cool testing&#xA;techniques and great new features in Rails if you go and look for&#xA;them, but what impressed me the most were the small things. Like the&#xA;small, in-between notes and simple harmonies in the midst of a large&#xA;symphony, the Rails commits that caught my eye were tiny changes&#xA;made by the Rails core team that were easy to miss, but that showed&#xA;their real passion and love for Rails.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Pat highlights some of his favorite commits and even takes a closer&#xA;in-depth look a few of the good ones.&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>VendorKit: bundler for Objective-C</title>
      <link>https://freerangebits.com/posts/2011/12/vendorkit/</link>
      <pubDate>Mon, 05 Dec 2011 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2011/12/vendorkit/</guid>
      <description>&lt;p&gt;Having trouble maintaining dependencies in your Objective-C&#xA;application?  Love the way &lt;a href=&#34;http://gembundler.com/&#34; target=&#34;_blank&#34;&gt;Bundler&lt;/a&gt; deals with Ruby Gem&#xA;dependencies?  You may want to take a look at &lt;a href=&#34;http://vendorkit.com/&#34; target=&#34;_blank&#34;&gt;VendorKit&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;VendorKit makes the process of using and managing libraries in iOS&#xA;easy. VendorKit is modeled after Bundler. VendorKit streamlines the&#xA;installation and update process for dependent libraries. It also&#xA;tracks versions and manages dependencies between libraries.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Bundler has driven me to insanity more times than I care to admit, but&#xA;VendorKit could be a real lifesaver.&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>Fun stuff for Friday Dec. 2</title>
      <link>https://freerangebits.com/posts/2011/12/fun-friday-02/</link>
      <pubDate>Fri, 02 Dec 2011 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2011/12/fun-friday-02/</guid>
      <description>&lt;p&gt;I&amp;rsquo;m slowly getting back on track after taking an extended holiday last&#xA;week and then catching a cold this week.  Needless to say, I&amp;rsquo;m pretty&#xA;happy that it&amp;rsquo;s Friday, and I have a whole bunch of fun stuff to&#xA;share, so let&amp;rsquo;s get to it.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;&lt;a href=&#34;http://hackerbuddy.com/&#34; target=&#34;_blank&#34;&gt;Hackerbuddy&lt;/a&gt; has relaunched with a bunch of improvements and some&#xA;new features.  Full details in &lt;a href=&#34;http://hackerbuddy.com/posts/2&#34; target=&#34;_blank&#34;&gt;this article&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Doom 3 was &lt;a href=&#34;http://www.omgubuntu.co.uk/2011/11/doom-3-is-open-sourced/&#34; target=&#34;_blank&#34;&gt;open sourced&lt;/a&gt; and there&amp;rsquo;s already&#xA;&lt;a href=&#34;http://fabiensanglard.net/doom3_macosx/index.php&#34; target=&#34;_blank&#34;&gt;instructions&lt;/a&gt; on how to build it on a Mac using Xcode.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Google Code Search is getting &lt;a href=&#34;http://googleblog.blogspot.com/2011/10/fall-sweep.html&#34; target=&#34;_blank&#34;&gt;shut down&lt;/a&gt; on Jan. 15, 2012.&#xA;Miguel de Icaza &lt;a href=&#34;http://tirania.org/blog/archive/2011/Nov-29.html&#34; target=&#34;_blank&#34;&gt;compares alternatives&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Users of the beautiful &lt;a href=&#34;http://mbostock.github.com/protovis/&#34; target=&#34;_blank&#34;&gt;Protovis&lt;/a&gt; visualization library that are&#xA;making the switch to &lt;a href=&#34;http://mbostock.github.com/d3/&#34; target=&#34;_blank&#34;&gt;D3&lt;/a&gt; (its replacement) might want to take a&#xA;look at Luke Francl&amp;rsquo;s &lt;a href=&#34;http://www.recursion.org/d3-for-mere-mortals/&#34; target=&#34;_blank&#34;&gt;D3 for Mere Mortals&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Have you seen the new web API gateway from eBay that they&amp;rsquo;re&#xA;calling &lt;a href=&#34;http://ql.io/&#34; target=&#34;_blank&#34;&gt;ql.io&lt;/a&gt;?  Apparently it uses a SQL-like syntax and allows&#xA;you to communicate with multiple web APIs in the same call.  Oh,&#xA;and it&amp;rsquo;s not just for eBay APIs.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;I must absolutely make myself a &lt;a href=&#34;http://fredr096.tumblr.com/post/12791440033&#34; target=&#34;_blank&#34;&gt;Jabba the Cupcake&lt;/a&gt; (via&#xA;&lt;a href=&#34;http://boingboing.net/2011/11/27/jabba-the-cupcake.html&#34; target=&#34;_blank&#34;&gt;Boing Boing&lt;/a&gt;).&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;I&amp;rsquo;m a mechanical pencil nerd and the &lt;a href=&#34;http://www.wired.com/geekdad/2011/11/kuru-toga-the-ultimate-geek-tool/&#34; target=&#34;_blank&#34;&gt;Kuru Toga&lt;/a&gt; is a must have.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Have a great weekend!&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>HAML users repent before it&#39;s too late</title>
      <link>https://freerangebits.com/posts/2011/12/haml-is-unforgivable/</link>
      <pubDate>Thu, 01 Dec 2011 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2011/12/haml-is-unforgivable/</guid>
      <description>&lt;p&gt;I used to have a coworker that would constantly bug me about how&#xA;awesome &lt;a href=&#34;http://haml-lang.com/&#34; target=&#34;_blank&#34;&gt;HAML&lt;/a&gt; is, but whenever I looked at HAML code all I saw was&#xA;noise.  Brandon Keepers has done &lt;a href=&#34;http://opensoul.org/blog/archives/2011/11/30/haml-the-unforgivable-sin/&#34; target=&#34;_blank&#34;&gt;a much better job&lt;/a&gt; at&#xA;explaining why you should avoid HAML:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;I agree that HAML is easier to write than HTML, simply because it&#xA;involves less typing. But I feel it is infinitely harder to&#xA;read. While the indentation makes it easy to see the nesting, the&#xA;extremely overloaded synax requires careful attention to each line.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;In my opinion, if you hate writing HTML a much better option is&#xA;&lt;a href=&#34;https://freerangebits.com/posts/2011/10/zen-coding/&#34;&gt;Zen Coding&lt;/a&gt;.&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>Seven databases in seven weeks</title>
      <link>https://freerangebits.com/posts/2011/12/seven-databases/</link>
      <pubDate>Thu, 01 Dec 2011 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2011/12/seven-databases/</guid>
      <description>&lt;p&gt;If you enjoyed Bruce Tate&amp;rsquo;s book &lt;a href=&#34;http://pragprog.com/book/btlang/seven-languages-in-seven-weeks&#34; target=&#34;_blank&#34;&gt;Seven Languages in Seven Weeks&lt;/a&gt;&#xA;you might also enjoy &lt;a href=&#34;http://pragprog.com/book/rwdata/seven-databases-in-seven-weeks&#34; target=&#34;_blank&#34;&gt;Seven Databases in Seven Weeks&lt;/a&gt; by Eric&#xA;Redmond and Jim Wilson:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Data is getting bigger and more complex by the day, and so are your&#xA;choices in handling it. From traditional RDBMS to newer NoSQL&#xA;approaches, Seven Databases in Seven Weeks takes you on a tour of&#xA;some of the hottest open source databases today.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Tate&amp;rsquo;s book also sparked a whole bunch of &lt;a href=&#34;https://github.com/search?langOverride=&amp;amp;q=seven&amp;#43;languages&amp;amp;repo=&amp;amp;start_value=1&amp;amp;type=Repositories&#34; target=&#34;_blank&#34;&gt;Github repositories&lt;/a&gt;&#xA;with the code people write as they make their way though the book.&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>Don&#39;t be affraid to learn vi or emacs</title>
      <link>https://freerangebits.com/posts/2011/11/learn-vi/</link>
      <pubDate>Wed, 23 Nov 2011 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2011/11/learn-vi/</guid>
      <description>&lt;p&gt;Over at the &lt;a href=&#34;http://robots.thoughtbot.com/&#34; target=&#34;_blank&#34;&gt;thoughtbot blog&lt;/a&gt; there&amp;rsquo;s an article about the&#xA;&lt;a href=&#34;http://robots.thoughtbot.com/post/13164810557/the-vim-learning-curve-is-a-myth&#34; target=&#34;_blank&#34;&gt;myth of the vim learning curve&lt;/a&gt;.  I think everything said&#xA;about &lt;a href=&#34;https://freerangebits.com/tags/vim/&#34;&gt;vi/vim&lt;/a&gt; can equally be applied to &lt;a href=&#34;https://freerangebits.com/tags/emacs/&#34;&gt;Emacs&lt;/a&gt;.  The path to&#xA;getting up and running isn&amp;rsquo;t as daunting as you might think:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Go to your shell and type &lt;code&gt;vimtutor&lt;/code&gt;. The tutorial that&amp;rsquo;s presented&#xA;is excellent and you&amp;rsquo;ll be through it in no time. Once you&amp;rsquo;re done,&#xA;you&amp;rsquo;ll have the rudiments needed to get your work done. You won&amp;rsquo;t be&#xA;fast yet, no; but you&amp;rsquo;ll be competent.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;There&amp;rsquo;s a similar feature in Emacs.  To start the tutorial just type&#xA;&lt;code&gt;C-h t&lt;/code&gt; (that&amp;rsquo;s Control-h and then t).&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>Git workflows and configuration</title>
      <link>https://freerangebits.com/posts/2011/11/git-workflow/</link>
      <pubDate>Tue, 22 Nov 2011 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2011/11/git-workflow/</guid>
      <description>&lt;p&gt;If you&amp;rsquo;re new to &lt;a href=&#34;https://freerangebits.com/tags/git/&#34;&gt;Git&lt;/a&gt; or are looking for some branching workflow&#xA;guidance Kumar McMillan has put together an article about&#xA;&lt;a href=&#34;http://blog.mozilla.com/webdev/2011/11/21/git-using-topic-branches-and-interactive-rebasing-effectively/&#34; target=&#34;_blank&#34;&gt;topic branches and rebasing&lt;/a&gt; using Git:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;The nice thing about working in a topic branch is it&amp;rsquo;s isolated from&#xA;master and no one else is tracking that branch so I can use git&#xA;rebase to create the best commit before merging into master.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Need more detail? Yehuda Katz wrote an article last year that covers&#xA;&lt;a href=&#34;http://yehudakatz.com/2010/05/13/common-git-workflows/&#34; target=&#34;_blank&#34;&gt;his workflow&lt;/a&gt; compared to how someone would do the same tasks&#xA;with Subversion.&lt;/p&gt;&#xA;&lt;p&gt;Finally, to promote his &lt;a href=&#34;http://www.theint.ro/products/version-control-with-git&#34; target=&#34;_blank&#34;&gt;Git workshop&lt;/a&gt; Ben Hoskings wrote an&#xA;article explaining how to &lt;a href=&#34;http://www.theint.ro/blogs/outro/4649682-git-for-busy-people-see-what-youre-doing&#34; target=&#34;_blank&#34;&gt;configure git log&lt;/a&gt; to be more useful.&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>Simple code makes good software</title>
      <link>https://freerangebits.com/posts/2011/11/simple-code/</link>
      <pubDate>Mon, 21 Nov 2011 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2011/11/simple-code/</guid>
      <description>&lt;p&gt;Alex Obenauer has been &lt;a href=&#34;http://news.ycombinator.com/item?id=3255473&#34; target=&#34;_blank&#34;&gt;rustling some feathers&lt;/a&gt; with his&#xA;&lt;a href=&#34;http://blog.alexobenauer.com/stop-writing-good-code-start-writing-good-sof&#34; target=&#34;_blank&#34;&gt;recent article entitled&lt;/a&gt; &amp;ldquo;Stop writing good code; start writing&#xA;good software&amp;rdquo;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Do you really need a full objet-oriented API right now? Do you&#xA;really need to make a dozen interwoven classes, when it&amp;rsquo;s possible&#xA;just a hundred or so lines in one class will do fine? Can you do all&#xA;the same error checking and unit tests in a much smaller code base?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I think Alex should have used the title &amp;ldquo;Simple code makes good&#xA;software&amp;rdquo; and focused on the simple vs. elaborate code debate.  At&#xA;least that&amp;rsquo;s the theme I see just under the surface in his article.&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>Fun stuff for Friday Nov. 18</title>
      <link>https://freerangebits.com/posts/2011/11/fun-friday-18/</link>
      <pubDate>Fri, 18 Nov 2011 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2011/11/fun-friday-18/</guid>
      <description>&lt;p&gt;This past week has been a blur for me so I&amp;rsquo;m totally ready for the&#xA;weekend.  The kids and I have been making our way through the Alien&#xA;films and tonight we&amp;rsquo;re on number 3.  I don&amp;rsquo;t have fond memories of&#xA;the movie but I&amp;rsquo;m sure we&amp;rsquo;ll have fun.&lt;/p&gt;&#xA;&lt;p&gt;Hopefully you have some fun planned yourself and the links below will&#xA;help you kick off the weekend.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Anders Evenrud has released what he&amp;rsquo;s calling &lt;a href=&#34;http://anderse.wordpress.com/os-js/&#34; target=&#34;_blank&#34;&gt;OS.js&lt;/a&gt;, or what I&amp;rsquo;d&#xA;call an operating system emulator.  It almost looks like you VNC&#xA;into his Linux box, but nope, it&amp;rsquo;s all JS.  It even has apps&#xA;written for it.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;&lt;a href=&#34;https://freerangebits.com/tags/emacs/&#34;&gt;Emacs&lt;/a&gt; users who want to start using version 24 (to be released&#xA;this spring) should take a look at Bozhidar Batsov&amp;rsquo;s&#xA;&lt;a href=&#34;https://github.com/bbatsov/emacs-prelude&#34; target=&#34;_blank&#34;&gt;Emacs Prelude&lt;/a&gt;.  It&amp;rsquo;s a set of configuration files and&#xA;packages sort of like the &lt;a href=&#34;https://github.com/technomancy/emacs-starter-kit&#34; target=&#34;_blank&#34;&gt;Emacs starter kit&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Itching to write code nobody can read?  Back after a rather long&#xA;hiatus is the &lt;a href=&#34;http://www.ioccc.org/&#34; target=&#34;_blank&#34;&gt;International Obfuscated C Code Contest&lt;/a&gt;!&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Looking for a geeky way to put your keys away for the night?  Why&#xA;not build an &lt;a href=&#34;http://www.instructables.com/id/RJ-45-key-chain-and-rack&#34; target=&#34;_blank&#34;&gt;RJ45 key chain&lt;/a&gt;.  I recommend wiring it so you&#xA;can plug it right into a hub or switch.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Videos: Astronauts &lt;a href=&#34;http://www.youtube.com/watch?v=LEdYf4SGhuI&#34; target=&#34;_blank&#34;&gt;tripping and falling&lt;/a&gt; on the moon (via&#xA;&lt;a href=&#34;http://www.wired.com/geekdad/2011/11/astronauts-falling-on-the-moon/&#34; target=&#34;_blank&#34;&gt;GeekDad&lt;/a&gt;) and &lt;a href=&#34;http://www.youtube.com/watch?v=PNln_me-XjI&#34; target=&#34;_blank&#34;&gt;Simultaneous time lapse&lt;/a&gt; video of the&#xA;sky over 360 days (via &lt;a href=&#34;http://kottke.org/11/11/year-long-sky-time-lapse&#34; target=&#34;_blank&#34;&gt;kottke&lt;/a&gt;).&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Have a fun weekend!&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>Concurrency in Ruby 1.9</title>
      <link>https://freerangebits.com/posts/2011/11/ruby-concurrency/</link>
      <pubDate>Thu, 17 Nov 2011 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2011/11/ruby-concurrency/</guid>
      <description>&lt;p&gt;Ruby 1.9 introduced an additional concurrency mechanism called Fibers.&#xA;If you haven&amp;rsquo;t played with Fibers or still haven&amp;rsquo;t discovered Ruby&#xA;continuations William Morgan &lt;a href=&#34;http://masanjin.net/blog/fibers&#34; target=&#34;_blank&#34;&gt;has written an article&lt;/a&gt; that you&#xA;might want to take a look at:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Ruby 1.9 has both fibers and continuations. The two are often&#xA;mentioned in the same breath. They do vaguely similar-sounding&#xA;things, and are implemented in Ruby 1.9 with similar mechanics&#xA;underneath the hood, much as how continuations and threads were&#xA;implemented with the same underlying mechanics in Ruby 1.8.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Another way to deal with concurrency is with the Actor Model.  Mike&#xA;Perham demonstrates the Actor Model built into Rubinius in his&#xA;&lt;a href=&#34;http://blog.carbonfive.com/2011/04/19/concurrency-with-actors/&#34; target=&#34;_blank&#34;&gt;article on concurrency&lt;/a&gt;.  He also points to other resources for&#xA;using the Actor Model in Ruby.&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>The Objective-C object model</title>
      <link>https://freerangebits.com/posts/2011/11/objc-object-model/</link>
      <pubDate>Wed, 16 Nov 2011 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2011/11/objc-object-model/</guid>
      <description>&lt;p&gt;If you&amp;rsquo;re an Objective-C developer you can get a lot done without&#xA;understanding the C roots in Objective-C or the object model employed&#xA;by Objective-C.  In fact, trying to learn the object model can be&#xA;intimidating and confusing because some peculiar complexities.&lt;/p&gt;&#xA;&lt;p&gt;Even if it&amp;rsquo;s a little complex, it&amp;rsquo;s a worthy endeavor to learn the&#xA;Objective-C object model because you may end up needing to interact&#xA;with the Objective-C runtime someday, and understanding the object&#xA;model will be very useful in that situation.&lt;/p&gt;&#xA;&lt;p&gt;Grab a cup of tea or coffee and follow along with me while we explore&#xA;the Objective-C object model.&lt;/p&gt;&#xA;&lt;h2 id=&#34;objects-are-instances-of-a-class&#34;&gt;Objects are instances of a class&lt;/h2&gt;&#xA;&lt;p&gt;Sure, this may sound obvious, but it&amp;rsquo;s worth taking a few seconds to&#xA;really consider what it means when we say that an object is an&#xA;instance of a class.  Take the following code for example:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-objective-c&#34; data-lang=&#34;objective-c&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;NSString &lt;span style=&#34;color:#f92672&#34;&gt;*&lt;/span&gt;name &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  [NSString stringWithFormat:&lt;span style=&#34;color:#e6db74&#34;&gt;@&amp;#34;%@&amp;#34;&lt;/span&gt;, &lt;span style=&#34;color:#e6db74&#34;&gt;@&amp;#34;Peter&amp;#34;&lt;/span&gt;];&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This is a rather contrived example but it&amp;rsquo;s important to demonstrate&#xA;some of the moving parts in the Objective-C runtime.  When the code&#xA;above is executed we end up with a variable called &lt;code&gt;name&lt;/code&gt; that is an&#xA;instance of the &lt;code&gt;NSString&lt;/code&gt; class.  Please consider the following:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Objects (instances of a class) are used to hold state.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;An object&amp;rsquo;s state is held in its instance variables.  For example,&#xA;the &lt;code&gt;name&lt;/code&gt; object above owns some memory for storing the bytes&#xA;that make up the string &amp;ldquo;Peter&amp;rdquo;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;The &lt;code&gt;name&lt;/code&gt; object also contains a pointer back to its class&#xA;(&lt;code&gt;NSString&lt;/code&gt;) as part of its state.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;In Objective-C objects don&amp;rsquo;t contain any behavior, only state.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Classes contain behavior and do not contain any state.  The&#xA;behavior they hold is the methods that their instances can respond&#xA;to.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Let&amp;rsquo;s repeat that once again for clarity.  Objects are containers&#xA;that store state (instance variables) and classes are containers&#xA;that store behavior (methods).&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;To make this more concrete take a look at the following diagram:&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&#34;instance-graph.png&#34; alt=&#34;Object Method Dispatch&#34;&gt;&lt;/p&gt;&#xA;&lt;p&gt;The blue box represents the &lt;code&gt;name&lt;/code&gt; variable (an instance of the&#xA;&lt;code&gt;NSString&lt;/code&gt; class).  Using the diagram above let&amp;rsquo;s look at what happens&#xA;if you send the &lt;code&gt;length&lt;/code&gt; message to the &lt;code&gt;name&lt;/code&gt; variable:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-objective-c&#34; data-lang=&#34;objective-c&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;NSUInteger len &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; [name length];&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ol&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;The first thing that Objective-C does is ask the &lt;code&gt;name&lt;/code&gt; variable&#xA;which class it was instantiated from.  Since all the methods are&#xA;held in the class, that&amp;rsquo;s where it will start looking for the&#xA;&lt;code&gt;length&lt;/code&gt; method.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Since the class of &lt;code&gt;name&lt;/code&gt; object is &lt;code&gt;NSString&lt;/code&gt;, Objective-C goes&#xA;to the &lt;code&gt;NSString&lt;/code&gt; class and searches for the &lt;code&gt;length&lt;/code&gt; method.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;If Objective-C finds the &lt;code&gt;length&lt;/code&gt; method in the &lt;code&gt;NSString&lt;/code&gt; class&#xA;it will stop searching and execute the method that it found.&#xA;Otherwise it will continue searching the inheritance hierarchy&#xA;for the method.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;I should note that the process I&amp;rsquo;m describing has been simplified.&#xA;I&amp;rsquo;m not considering other places that methods could be stored&#xA;(e.g. Objective-C categories).&lt;/p&gt;&#xA;&lt;h2 id=&#34;classes-are-really-objects-too&#34;&gt;Classes are really objects too&lt;/h2&gt;&#xA;&lt;p&gt;Given that a class holds methods for its instances, you might be&#xA;wondering where class methods are stored.  Let&amp;rsquo;s look at the code that&#xA;created the &lt;code&gt;name&lt;/code&gt; variable again:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-objective-c&#34; data-lang=&#34;objective-c&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;NSString &lt;span style=&#34;color:#f92672&#34;&gt;*&lt;/span&gt;name &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  [NSString stringWithFormat:&lt;span style=&#34;color:#e6db74&#34;&gt;@&amp;#34;%@&amp;#34;&lt;/span&gt;, &lt;span style=&#34;color:#e6db74&#34;&gt;@&amp;#34;Peter&amp;#34;&lt;/span&gt;];&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;In the code above, the &lt;code&gt;stringWithFormat:&lt;/code&gt; message was sent to the&#xA;&lt;code&gt;NSString&lt;/code&gt; class.  Can classes receive messages, and if so where are&#xA;those methods kept?  In this case, the Objective-C syntax is covering&#xA;something up, it&amp;rsquo;s hiding the fact that &lt;code&gt;NSString&lt;/code&gt; is also an object.&lt;/p&gt;&#xA;&lt;p&gt;If &lt;code&gt;NSString&lt;/code&gt; is an object, that means that it must have been&#xA;instantiated from a class that is holding its methods.  This is true,&#xA;but before we dig into it let&amp;rsquo;s look at some more code:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-objective-c&#34; data-lang=&#34;objective-c&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;@interface&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;Person&lt;/span&gt; : &lt;span style=&#34;color:#a6e22e&#34;&gt;NSObject&lt;/span&gt; {}&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;+ (&lt;span style=&#34;color:#66d9ef&#34;&gt;void&lt;/span&gt;) &lt;span style=&#34;color:#a6e22e&#34;&gt;aClassMethod&lt;/span&gt;;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;- (&lt;span style=&#34;color:#66d9ef&#34;&gt;void&lt;/span&gt;) &lt;span style=&#34;color:#a6e22e&#34;&gt;anInstanceMethod&lt;/span&gt;;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;@end&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You&amp;rsquo;ve probably seen this many, many times.  But what is really going&#xA;on?&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;A new class is being declared, the &lt;code&gt;Person&lt;/code&gt; class.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;This class will be used to hold methods for instances.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;A second class is also being created behind the scenes.&#xA;Unfortunately this additional class has the same name (&lt;code&gt;Person&lt;/code&gt;)&#xA;but is referred to as the &lt;code&gt;Person&lt;/code&gt; metaclass.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;The &lt;code&gt;Person&lt;/code&gt; metaclass holds the class methods for the &lt;code&gt;Person&lt;/code&gt;&#xA;class.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;This can be very confusing because the same name is being used over&#xA;and over again.  Going back to our &lt;code&gt;name&lt;/code&gt; variable, we can say the&#xA;following:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;The &lt;code&gt;name&lt;/code&gt; object is an instance of the &lt;code&gt;NSString&lt;/code&gt; class.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;&lt;code&gt;NSString&lt;/code&gt; is an object instantiated from the &lt;code&gt;NSString&lt;/code&gt;&#xA;metaclass.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;If you send the &lt;code&gt;length&lt;/code&gt; message to the &lt;code&gt;name&lt;/code&gt; object, Objective-C&#xA;will go look for that method in the &lt;code&gt;NSString&lt;/code&gt; class.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;If you send the &lt;code&gt;stringWithFormat:&lt;/code&gt; message to the &lt;code&gt;NSString&lt;/code&gt;&#xA;object, Objective-C will go look for that method in the &lt;code&gt;NSString&lt;/code&gt;&#xA;metaclass.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Here&amp;rsquo;s another diagram:&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&#34;class-graph.png&#34; alt=&#34;Metaclass Method Dispatch&#34;&gt;&lt;/p&gt;&#xA;&lt;p&gt;This time the blue box represents the &lt;code&gt;NSString&lt;/code&gt; object.  Here&amp;rsquo;s the&#xA;creation of the &lt;code&gt;name&lt;/code&gt; object again:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-objective-c&#34; data-lang=&#34;objective-c&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;NSString &lt;span style=&#34;color:#f92672&#34;&gt;*&lt;/span&gt;name &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  [NSString stringWithFormat:&lt;span style=&#34;color:#e6db74&#34;&gt;@&amp;#34;%@&amp;#34;&lt;/span&gt;, &lt;span style=&#34;color:#e6db74&#34;&gt;@&amp;#34;Peter&amp;#34;&lt;/span&gt;];&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;When the &lt;code&gt;stringWithFormat:&lt;/code&gt; message is sent to the &lt;code&gt;NSString&lt;/code&gt; object&#xA;Objective-C will:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Ask the &lt;code&gt;NSString&lt;/code&gt; object for it&amp;rsquo;s class, which is the &lt;code&gt;NSString&lt;/code&gt;&#xA;metaclass.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;It will then start searching the &lt;code&gt;NSString&lt;/code&gt; metaclass for the&#xA;&lt;code&gt;stringWithFormat:&lt;/code&gt; method.  If it doesn&amp;rsquo;t find the method there&#xA;it will continue up the inheritance hierarchy.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Naturally, since the &lt;code&gt;NSString&lt;/code&gt; class inherits from the &lt;code&gt;NSObject&lt;/code&gt;&#xA;class, the &lt;code&gt;NSString&lt;/code&gt; metaclass inherits from the &lt;code&gt;NSObject&lt;/code&gt;&#xA;metaclass.&lt;/p&gt;&#xA;&lt;h2 id=&#34;wacky-nsobject-inheritance&#34;&gt;Wacky NSObject inheritance&lt;/h2&gt;&#xA;&lt;p&gt;If you&amp;rsquo;ve made it this far you can rest assured that you know enough&#xA;about the Objective-C object model to know a lot more about what&amp;rsquo;s&#xA;going on in your code at run time.  There&amp;rsquo;s just one more thing that&#xA;you may want to know: Why does it look like the &lt;code&gt;NSObject&lt;/code&gt; metaclass&#xA;inherits from the &lt;code&gt;NSObject&lt;/code&gt; class?  Because it does.&lt;/p&gt;&#xA;&lt;p&gt;Consider the following:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;The &lt;code&gt;NSObject&lt;/code&gt; class contains methods for its instantiated objects.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;The &lt;code&gt;NSObject&lt;/code&gt; metaclass contains methods for the &lt;code&gt;NSObject&lt;/code&gt; class&#xA;(i.e. &lt;code&gt;NSObject&lt;/code&gt; class methods).&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;The &lt;code&gt;NSObject&lt;/code&gt; metaclass inherits from the (non-meta) &lt;code&gt;NSObject&lt;/code&gt;&#xA;class.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Therefore, any instance methods defined for &lt;code&gt;NSObject&lt;/code&gt; will also&#xA;be in the search path as class methods for any Objective-C class.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;It&amp;rsquo;s a bit wacky, but if you look at the diagram above it should start&#xA;to make sense.&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>C&#43;&#43;11 move semantics and rvalue references</title>
      <link>https://freerangebits.com/posts/2011/11/cxx-move/</link>
      <pubDate>Tue, 15 Nov 2011 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2011/11/cxx-move/</guid>
      <description>&lt;p&gt;I stopped following the C++0x standardization process a long time ago,&#xA;so when C++11 was announced I delighted in some of the developments&#xA;that I had missed.  Then I saw &amp;ldquo;move semantics&amp;rdquo; and thought to myself&#xA;WTF?  Then I found this &lt;a href=&#34;http://stackoverflow.com/questions/3106110/can-someone-please-explain-move-semantics-to-me&#34; target=&#34;_blank&#34;&gt;stackoverflow answer&lt;/a&gt; and now I&amp;rsquo;m good.&#xA;There&amp;rsquo;s also &lt;a href=&#34;http://www2.research.att.com/~bs/C&amp;#43;&amp;#43;0xFAQ.html#rval&#34; target=&#34;_blank&#34;&gt;this section&lt;/a&gt; in the &lt;a href=&#34;http://www2.research.att.com/~bs/C&amp;#43;&amp;#43;0xFAQ.html&#34; target=&#34;_blank&#34;&gt;C++11 FAQ&lt;/a&gt;.&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>Remote pair programming in a terminal</title>
      <link>https://freerangebits.com/posts/2011/11/remote-pairing/</link>
      <pubDate>Mon, 14 Nov 2011 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2011/11/remote-pairing/</guid>
      <description>&lt;p&gt;Pair programming is becoming more popular due to the good old&#xA;terminal.  Instead of having to sit next to your coworker who had an&#xA;onion sandwich for lunch you can use terminal sharing from across the&#xA;office or the country.  And with services like &lt;a href=&#34;http://rubypair.com/&#34; target=&#34;_blank&#34;&gt;Ruby Pair&lt;/a&gt; that&#xA;connect people who want to pair program, knowing how to use a terminal&#xA;multiplexer is worth a few minutes of your time.&lt;/p&gt;&#xA;&lt;p&gt;The venerable choice for a terminal multiplexer is &lt;a href=&#34;http://www.gnu.org/s/screen/&#34; target=&#34;_blank&#34;&gt;GNU Screen&lt;/a&gt;.&#xA;Dalibor Nasevic has written an article with instructions on how to&#xA;&lt;a href=&#34;http://blog.siyelo.com/remote-pair-programming-with-screen&#34; target=&#34;_blank&#34;&gt;configure SSH and Screen&lt;/a&gt; to allow remote pair programming.  In&#xA;my opinion, a huge downside to using Screen is having to setuid the&#xA;process to enable multiuser mode.  A much better option is &lt;a href=&#34;http://tmux.sourceforge.net/&#34; target=&#34;_blank&#34;&gt;tmux&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;If you&amp;rsquo;re looking for a more modern terminal multiplexer that is much&#xA;easier to configure, tmux is the answer.  Joe Moore has &lt;a href=&#34;http://remotepairprogramming.com/remote-pair-programming-with-tmux-and-vim-the&#34; target=&#34;_blank&#34;&gt;an&#xA;article&lt;/a&gt; about using tmux with &lt;a href=&#34;https://freerangebits.com/tags/vim/&#34;&gt;Vim&lt;/a&gt; for pair programming, but&#xA;it&amp;rsquo;s really just a few simple commands:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;# Host&#xA;tmux -S /tmp/pairprog&#xA;&#xA;# Client&#xA;ssh pair-host&#xA;tmux -S /tmp/pairprog attach&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Remote pair programming with Screen or tmux is also a great excuse to&#xA;polish your &lt;a href=&#34;https://freerangebits.com/tags/vim/&#34;&gt;Vim&lt;/a&gt; or &lt;a href=&#34;https://freerangebits.com/tags/emacs/&#34;&gt;Emacs&lt;/a&gt; skills.&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>Fun stuff for Friday Nov. 11</title>
      <link>https://freerangebits.com/posts/2011/11/fun-friday-11/</link>
      <pubDate>Fri, 11 Nov 2011 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2011/11/fun-friday-11/</guid>
      <description>&lt;p&gt;Not only is it Friday, but here in the US it&amp;rsquo;s veterans day, which&#xA;means some of you might not even be working.  That reminds me, I&#xA;better go out and take the mail out of my mailbox since the post isn&amp;rsquo;t&#xA;running today.&lt;/p&gt;&#xA;&lt;p&gt;Here are some fun things to look at over the weekend:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;&lt;a href=&#34;http://www.zeromq.org/&#34; target=&#34;_blank&#34;&gt;ZeroMQ&lt;/a&gt; is an older project that I&amp;rsquo;ve just stumbled upon.  It&#xA;provides an API to just about any programming language for doing&#xA;distributed work using the actor model.  The cool thing is, the&#xA;same API works locally between threads and processes but can scale&#xA;up to processes on different machines.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;I had to rub my eyes and read the headline again, but it&amp;rsquo;s true,&#xA;Microsoft &lt;a href=&#34;http://samba.org/samba/news/developers/ms-patch.html&#34; target=&#34;_blank&#34;&gt;contributed patches&lt;/a&gt; to &lt;a href=&#34;http://samba.org/&#34; target=&#34;_blank&#34;&gt;Samba&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;For those of you who haven&amp;rsquo;t jumped ship to a &lt;a href=&#34;http://llvm.org/&#34; target=&#34;_blank&#34;&gt;different&#xA;compiler&lt;/a&gt; Anders Ahlström has &lt;a href=&#34;http://www.antoarts.com/the-most-useful-gcc-options-and-extensions/&#34; target=&#34;_blank&#34;&gt;compiled a list&lt;/a&gt; of the most&#xA;useful GCC options and extensions.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Did you know that you can &lt;a href=&#34;http://www.hodique.info/blog/2011/03/20/git_tip_url_rewriting&#34; target=&#34;_blank&#34;&gt;configure Git&lt;/a&gt; to pull from one&#xA;URL, but push to another?  It&amp;rsquo;s perfect for when you have a&#xA;submodule configured on a public read-only URL, but want to push&#xA;to a private read-write URL.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Videos to watch: my kids are going to love watching this super&#xA;slow motion video of a &lt;a href=&#34;http://www.youtube.com/watch?v=pbGz1njqhxU&#34; target=&#34;_blank&#34;&gt;bouncing water droplet&lt;/a&gt;, but they won&amp;rsquo;t&#xA;appreciate this watching old school &lt;a href=&#34;http://www.youtube.com/watch?v=gJ6APKIjFQY&#34; target=&#34;_blank&#34;&gt;video game deaths&lt;/a&gt; like I&#xA;do (via &lt;a href=&#34;http://kottke.org/11/11/classic-video-game-deaths&#34; target=&#34;_blank&#34;&gt;kottke&lt;/a&gt;).&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;</description>
    </item>
    <item>
      <title>Those Objective-C &#34;@&#34; Directives</title>
      <link>https://freerangebits.com/posts/2011/11/objc-at/</link>
      <pubDate>Thu, 10 Nov 2011 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2011/11/objc-at/</guid>
      <description>&lt;p&gt;Steffen Itterheim has &lt;a href=&#34;http://www.learn-cocos2d.com/2011/10/complete-list-objectivec-20-compiler-directives/&#34; target=&#34;_blank&#34;&gt;compiled&lt;/a&gt; a complete list of those&#xA;Objective-C &lt;code&gt;@&lt;/code&gt; compiler directives:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;I haven&amp;rsquo;t been able to find a list of all Objective-C @ compiler&#xA;directives in one place. We all know the keywords like @interface&#xA;and @implementation but others like @dynamic and @encode are lesser&#xA;known, and possibly even much less understood.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;You might also like this really nice &lt;a href=&#34;http://www.raywenderlich.com/4872/objective-c-cheat-sheet-and-quick-reference&#34; target=&#34;_blank&#34;&gt;Objective-C cheat sheet&lt;/a&gt;&#xA;from Ray Wenderlich.&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>The basics of good programming style</title>
      <link>https://freerangebits.com/posts/2011/11/good-code/</link>
      <pubDate>Wed, 09 Nov 2011 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2011/11/good-code/</guid>
      <description>&lt;p&gt;Isaac Taylor has &lt;a href=&#34;http://www.programmingmobile.com/2011/11/writing-code-that-doesn-suck.html&#34; target=&#34;_blank&#34;&gt;written an article&lt;/a&gt; that we&amp;rsquo;ve all probably&#xA;read before: the dos and don&amp;rsquo;ts of programming style.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Striving to write good code should be the goal of every Software&#xA;Developer. Writing code that is easily maintainable, robust, simple,&#xA;and makes sense is no easy task. It takes years of practice and&#xA;uncountable hours of time to become a good Programmer, and the job&#xA;is never really done.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Some of his advice is pretty standard (e.g. choose meaningful variable&#xA;names) but this one ruffled my feathers a bit: &amp;ldquo;Comment frequently&amp;rdquo;.&#xA;If the article&amp;rsquo;s comments are any indication, others feel the same&#xA;way.  A comment from reader MarchVeg sums it up:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Personally I don&amp;rsquo;t agree with comments, they are another thing to&#xA;maintain as the code changes over the years.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I find that comments tend to be the most brittle part of source code.&#xA;I would change Isaac&amp;rsquo;s recommendations for comments to:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Comment independent units of code such as classes and functions&#xA;as a form of documentation and a reminder to maintainers.  These&#xA;comments are more likely to be relevant over time since function&#xA;maintainers are free to change how they implement a certain task&#xA;but shouldn&amp;rsquo;t change a function so it does something entirely&#xA;different than calling code expects.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;If you find yourself needing to comment particularly complicated&#xA;lines of code try rewriting it first.  This is where tests can be&#xA;very helpful.  It&amp;rsquo;s alright if the code increases in size as long&#xA;as it becomes more clear and simple.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;I suppose my second point also goes against Isaac&amp;rsquo;s recommendation&#xA;that you shouldn&amp;rsquo;t &amp;ldquo;write 4 lines of code when 2 will do&amp;rdquo;, which I&#xA;also disagree with.  4 lines of simple idiomatic code always beat 2&#xA;lines of terse obfuscated code.  I&amp;rsquo;m sure what Isaac meant to say was&#xA;&amp;ldquo;don&amp;rsquo;t write overly verbose code when succinct code will do.&amp;rdquo;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; As it turns out, the actually author of the article above&#xA;isn&amp;rsquo;t Ilias Tsagklis, it&amp;rsquo;s Isaac Taylor.  Sorry about that Isaac!&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>A closer look at Redis</title>
      <link>https://freerangebits.com/posts/2011/11/redis/</link>
      <pubDate>Tue, 08 Nov 2011 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2011/11/redis/</guid>
      <description>&lt;p&gt;If you&amp;rsquo;re not familiar with &lt;a href=&#34;http://redis.io/&#34; target=&#34;_blank&#34;&gt;Redis&lt;/a&gt; it&amp;rsquo;s a key-value store that&#xA;gained popularity as a replacement for &lt;a href=&#34;http://memcached.org/&#34; target=&#34;_blank&#34;&gt;memcached&lt;/a&gt; due to its ability&#xA;to store and manipulate structured data (e.g. increment an integer,&#xA;get the union of two sets, etc.).  Redis is worth checking out if you&#xA;need a high performance, in-memory, key-value store with persistence.&lt;/p&gt;&#xA;&lt;p&gt;The &lt;a href=&#34;http://redis.io/topics/data-types-intro&#34; target=&#34;_blank&#34;&gt;fifteen minute introduction&lt;/a&gt; is particularly good:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;It&amp;rsquo;s not always trivial to grasp how this data types work and what&#xA;to use in order to solve a given problem from the command reference,&#xA;so this document is a crash course to Redis data types and their&#xA;most used patterns. [sic]&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Armed with data type information from the introduction you may want to&#xA;take a look at Karl Seguin&amp;rsquo;s &lt;a href=&#34;http://openmymind.net/2011/11/8/Redis-Zero-To-Master-In-30-Minutes-Part-1/&#34; target=&#34;_blank&#34;&gt;Zero to Master&lt;/a&gt; article:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;More than once, I&amp;rsquo;ve said that learning Redis is the most efficient&#xA;way a programmer can spend 30 minutes. This is a testament to both&#xA;how useful Redis is and how easy it is to learn. But, is it true,&#xA;can you really learn, and even master, Redis in 30 minutes?&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I found the article informative yet wanting.  There&amp;rsquo;s a part 2 but I&#xA;didn&amp;rsquo;t find that it added anything useful.&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>Managing debt buildup while developing</title>
      <link>https://freerangebits.com/posts/2011/11/debt/</link>
      <pubDate>Mon, 07 Nov 2011 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2011/11/debt/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;http://martinfowler.com/bliki/TechnicalDebt.html&#34; target=&#34;_blank&#34;&gt;Technical debt&lt;/a&gt; is one of those things that every developer knew&#xA;about before it had a proper name, but after &lt;a href=&#34;http://c2.com/~ward/&#34; target=&#34;_blank&#34;&gt;Ward Cunningham&lt;/a&gt;&#xA;coined the term we had a tool to drive conversation and encourage&#xA;decision makers to do the right thing.  It also gave us the ability to&#xA;evaluate how much technical debt was acceptable and even sometimes&#xA;necessary.&lt;/p&gt;&#xA;&lt;p&gt;In the real world, completely avoiding technical debt isn&amp;rsquo;t feasible,&#xA;but keeping it as low as possible is.  Chris Hartjes wants you to also&#xA;consider what he calls &lt;a href=&#34;http://www.littlehart.net/atthekeyboard/2011/11/03/infrastructure-debt/&#34; target=&#34;_blank&#34;&gt;infrastructure debt&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Infrastructure debt is debt that you build up because you have not&#xA;been paying attention to the process of creating the environments&#xA;your application will exist in and have not been paying attention to&#xA;the process of how your code gets from development into&#xA;production. In my opinion, infrastructure debt is much more&#xA;difficult to &amp;ldquo;pay off&amp;rdquo; than technical debt. Why? It is often very&#xA;difficult for people to understand that it even exists.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;It&amp;rsquo;s easy to see that there are all sorts of ways to accumulate debt&#xA;while writing software.  I&amp;rsquo;ve seen over and over again how&#xA;stakeholders create debt in their products, seemingly without even&#xA;realizing it, and without any help from the development team.  That&#xA;sort of debt is very hard for developers to pay back.&lt;/p&gt;&#xA;&lt;p&gt;It&amp;rsquo;s not impossible though and with more examples of how debt builds&#xA;and how to pay it down developers can educate themselves and the&#xA;stakeholders.&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>Fun stuff for Friday Nov. 4</title>
      <link>https://freerangebits.com/posts/2011/11/fun-friday-04/</link>
      <pubDate>Fri, 04 Nov 2011 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2011/11/fun-friday-04/</guid>
      <description>&lt;p&gt;It&amp;rsquo;s Friday again and here are some geeky things to cuddle up with as&#xA;the workday comes to an end and you start to dream of the weekend:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;The &lt;a href=&#34;http://laughingsquid.com/star-wars-alphabet/&#34; target=&#34;_blank&#34;&gt;Star Wars Alphabet&lt;/a&gt;.  Can you figure out all the&#xA;letters?&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;With &lt;a href=&#34;https://github.com/git/git/tree/master/contrib/git-jump&#34; target=&#34;_blank&#34;&gt;git-jump&lt;/a&gt; coming in the next release of &lt;a href=&#34;http://git-scm.com/&#34; target=&#34;_blank&#34;&gt;Git&lt;/a&gt; Emacs users&#xA;might want to &lt;a href=&#34;http://aaroncrane.co.uk/2011/11/git_jump_emacs/&#34; target=&#34;_blank&#34;&gt;take advantage of it&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Videos to watch: a helicopter-like &lt;a href=&#34;http://www.youtube.com/watch?v=pF0uLnMoQZA&#34; target=&#34;_blank&#34;&gt;flying sphere&lt;/a&gt; and a&#xA;cute little &lt;a href=&#34;http://www.youtube.com/watch?v=SqBw7XapJKk&#34; target=&#34;_blank&#34;&gt;bicycle riding robot&lt;/a&gt; (I love watching it&#xA;stop).&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;I&amp;rsquo;m sneaking this not-too-geeky video in here as well: a crazy&#xA;&lt;a href=&#34;http://www.youtube.com/watch?v=_Z3j3IIMCYs&amp;amp;hd=1&#34; target=&#34;_blank&#34;&gt;Bollywood car chase&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;As always, enjoy your Friday and have a great weekend.&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>Self-guided Ruby on Rails 3.1 Tutorial</title>
      <link>https://freerangebits.com/posts/2011/11/ror-example/</link>
      <pubDate>Fri, 04 Nov 2011 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2011/11/ror-example/</guid>
      <description>&lt;p&gt;One of the complaints about &lt;a href=&#34;http://rubyonrails.org/&#34; target=&#34;_blank&#34;&gt;Ruby on Rails&lt;/a&gt; that I hear most often&#xA;is its complexity, despite all the video tutorials showing how easy it&#xA;is to build a simple application in 5 minutes.  In reality, Rails was&#xA;a huge paradigm shift for web application development and even with&#xA;its complexity it&amp;rsquo;s a great platform.&lt;/p&gt;&#xA;&lt;p&gt;I&amp;rsquo;ve spent the better part of the last 6 years writing applications&#xA;using Ruby on Rails and people often ask me for my perspective on how&#xA;to bootstrap an application and best practices for using Rails.  I&#xA;also see a lot of people getting lost in the noise of scaffolding and&#xA;complicated tutorials.&lt;/p&gt;&#xA;&lt;p&gt;That&amp;rsquo;s why I decided to write an &lt;a href=&#34;https://github.com/devalot/ror-example&#34; target=&#34;_blank&#34;&gt;example application&lt;/a&gt; using&#xA;Ruby on Rails 3.1.  The application is on Github to make it easy to&#xA;get to, and takes advantage of source code control features like&#xA;branches so you can follow along as the application gains&#xA;functionality.&lt;/p&gt;&#xA;&lt;p&gt;I hope you enjoy this &lt;a href=&#34;https://github.com/devalot/ror-example&#34; target=&#34;_blank&#34;&gt;self-guided tutorial&lt;/a&gt; for Ruby on Rails&#xA;3.1.&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>The longevity of OS APIs vs. web APIs</title>
      <link>https://freerangebits.com/posts/2011/11/api-longevity/</link>
      <pubDate>Fri, 04 Nov 2011 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2011/11/api-longevity/</guid>
      <description>&lt;p&gt;Nick Bradbury makes a &lt;a href=&#34;http://nick.typepad.com/blog/2011/11/the-long-term-failure-of-web-apis.html&#34; target=&#34;_blank&#34;&gt;good point&lt;/a&gt; about the longevity of&#xA;operating system APIs compared to the more brittle APIs of the web:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;You might think you&amp;rsquo;re immune to this problem if you only integrate&#xA;with APIs created by large players such as Twitter, Facebook and&#xA;Google. But in recent years we&amp;rsquo;ve seen Twitter switch to a new&#xA;authentication system, Facebook deprecate FBML, and Google&#xA;discontinue several APIs. All of these changes have broken, or will&#xA;break, existing apps.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;</description>
    </item>
    <item>
      <title>Global Day of Coderetreat</title>
      <link>https://freerangebits.com/posts/2011/11/coderetreat/</link>
      <pubDate>Thu, 03 Nov 2011 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2011/11/coderetreat/</guid>
      <description>&lt;p&gt;Here in Colorado we&amp;rsquo;ve had a pretty regular helping of&#xA;&lt;a href=&#34;http://coderetreat.com/&#34; target=&#34;_blank&#34;&gt;Coderetreats&lt;/a&gt;.  And now everyone is going to&#xA;&lt;a href=&#34;http://coderetreat.com/global_day.html&#34; target=&#34;_blank&#34;&gt;do it on the same day&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Global Day of Coderetreat is a world-wide event celebrating passion&#xA;and software craftsmanship. We will spend the day practicing the&#xA;craft of software development using the [coderetreat format]&#xA;&lt;a href=&#34;http://coderetreat.com/&#34; target=&#34;_blank&#34;&gt;coderetreats&lt;/a&gt;. You can find out more information about the day on&#xA;the &lt;a href=&#34;http://blog.coderetreat.com/global-day-of-coderetreat&#34; target=&#34;_blank&#34;&gt;coderetreat blog&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;</description>
    </item>
    <item>
      <title>Learning the fundamentals of Scala</title>
      <link>https://freerangebits.com/posts/2011/11/learn-scala/</link>
      <pubDate>Wed, 02 Nov 2011 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2011/11/learn-scala/</guid>
      <description>&lt;p&gt;It seems to me that &lt;a href=&#34;http://www.scala-lang.org/&#34; target=&#34;_blank&#34;&gt;Scala&lt;/a&gt; has been popping up all over the place&#xA;in the last couple of years and I&amp;rsquo;m starting to see it in more and&#xA;more job descriptions.  If you&amp;rsquo;re new to Scala then Craig Tataryn has&#xA;a very well written &lt;a href=&#34;http://tataryn.net/2011/10/learning-scala-learn-the-fundamentals-first/&#34; target=&#34;_blank&#34;&gt;introduction&lt;/a&gt; to the fundamentals of Scala:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;What was the biggest mistake I made when I first started learning&#xA;Scala? I jumped in without looking. I felt I could just &amp;ldquo;pickup&amp;rdquo; the&#xA;language, like a C# developer might pickup Java. So the point I&amp;rsquo;m&#xA;trying to make is to start off in Scala by understanding some core&#xA;concepts. If you do, the veil of the Matrix is lifted and you start&#xA;to free your mind of the syntax which you aren&amp;rsquo;t yet used to.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I&amp;rsquo;m a little unnerved by the recent trend to implement new languages&#xA;on top of the JVM.  Is the JVM really that good?&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>Giving JavaScript another chance</title>
      <link>https://freerangebits.com/posts/2011/11/javascript/</link>
      <pubDate>Tue, 01 Nov 2011 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2011/11/javascript/</guid>
      <description>&lt;p&gt;JavaScript has been the subject of much public ridicule, and not just&#xA;for its name.  People have even written &lt;a href=&#34;https://freerangebits.com/posts/2011/10/google-dart/&#34;&gt;alternatives to&#xA;JavaScript&lt;/a&gt; that translate into JavaScript so they can run in&#xA;existing browsers.  Personally, I think JavaScript has some obvious&#xA;shortcomings but for the most part is a pretty usable language.&lt;/p&gt;&#xA;&lt;p&gt;Here are some recent JavaScript related articles that have come across&#xA;my radar that are worth checking out:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;&lt;a href=&#34;http://dailyjs.com/2011/10/31/misunderstandings/&#34; target=&#34;_blank&#34;&gt;Five Common JavaScript Misunderstandings&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;&lt;a href=&#34;http://killdream.github.com/blog/2011/10/understanding-javascript-oop/&#34; target=&#34;_blank&#34;&gt;Understanding JavaScript OOP&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;&lt;a href=&#34;http://james.padolsey.com/javascript/terse-javascript-101-part-1/&#34; target=&#34;_blank&#34;&gt;Terse JavaScript 101&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;And don&amp;rsquo;t forget about the seminal book: &lt;a href=&#34;http://shop.oreilly.com/product/9780596517748.do&#34; target=&#34;_blank&#34;&gt;JavaScript: The Good Parts&lt;/a&gt;.&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>More on code coverage metrics</title>
      <link>https://freerangebits.com/posts/2011/10/code-coverage/</link>
      <pubDate>Mon, 31 Oct 2011 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2011/10/code-coverage/</guid>
      <description>&lt;p&gt;After &lt;a href=&#34;https://freerangebits.com/posts/2011/10/testing-value/&#34;&gt;bashing code coverage metrics&lt;/a&gt; I came across an article&#xA;from Naresh Jain about &lt;a href=&#34;http://blogs.agilefaqs.com/2011/02/01/dont-be-seduced-by-code-coverage-numbers/&#34; target=&#34;_blank&#34;&gt;being seduced by code coverage numbers&lt;/a&gt;&#xA;and gaming the system:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;I once worked for a manager (a.k.a Scrum Master) who insisted that&#xA;we should have at least 85% code coverage on our project. If we did&#xA;not meet the targeted coverage numbers this sprint, then the whole&#xA;team would face the consequences during the upcoming performance&#xA;appraisals. In spite of trying to talk to her, she insisted. I would&#xA;like to believe that the manager had good intent and was trying to&#xA;encourage developers to write clean, tested code.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;My thoughts on code coverage have been expressed before, but Kevin&#xA;Rutkowski does a &lt;a href=&#34;http://blogs.catapultsystems.com/BA/archive/2011/05/20/metric-misuse-code-coverage.aspx&#34; target=&#34;_blank&#34;&gt;good job&lt;/a&gt; so I&amp;rsquo;ll use his words:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;The bottom line is that tests can easily be written that exercise&#xA;code without actually testing anything. So, when a team sets a&#xA;specific goal of 100% Code Coverage and has a tight deadline, it is&#xA;likely that a large number of those tests will be low quality.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;</description>
    </item>
    <item>
      <title>Fun stuff for Friday</title>
      <link>https://freerangebits.com/posts/2011/10/fun-friday-28/</link>
      <pubDate>Fri, 28 Oct 2011 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2011/10/fun-friday-28/</guid>
      <description>&lt;p&gt;I love Friday.  Everything seems to be slightly better and everyone&#xA;tends to have a better attitude.  Here in Colorado today is even&#xA;suppose to be the warmest day of the week!  The following tidbits are&#xA;some fun things to share with your geek friends instead of pretending&#xA;to work.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;&lt;a href=&#34;http://www.commitlogsfromlastnight.com/&#34; target=&#34;_blank&#34;&gt;Commit Logs From Last Night&lt;/a&gt; has some outrageous commit&#xA;messages and &lt;a href=&#34;http://whatthecommit.com/&#34; target=&#34;_blank&#34;&gt;What the Commit&lt;/a&gt; helps you pick a random one&#xA;for your next one character typo commit.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;&lt;a href=&#34;http://www.twilio.com/&#34; target=&#34;_blank&#34;&gt;Twilio&lt;/a&gt; is pretty interesting and with their recent launch in the&#xA;UK Richard Taylor has written an &lt;a href=&#34;https://moocode.com/posts/7-build-a-simple-twilio-customer-support-line-in-10-minutes&#34; target=&#34;_blank&#34;&gt;awesomely simple tutorial&lt;/a&gt;&#xA;that uses &lt;a href=&#34;http://www.sinatrarb.com/&#34; target=&#34;_blank&#34;&gt;Sinatra&lt;/a&gt; to create a call tree.  Even cooler, Mike&#xA;Szczys uses iPhone&amp;rsquo;s Siri to &lt;a href=&#34;http://hackaday.com/2011/10/24/giving-siri-the-keys-to-your-house/&#34; target=&#34;_blank&#34;&gt;voice control his house&lt;/a&gt; by&#xA;hacking the Arduino to receive text messages via Twilio.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;&lt;a href=&#34;http://www.titlescream.com/&#34; target=&#34;_blank&#34;&gt;Title Scream&lt;/a&gt; is an interesting site that catalogs&#xA;the start screens for 8- and 16-bit video games.  The title&#xA;screens are even animated.  Makes me want to start the NES&#xA;emulator.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Apparently HarperCollins came across a fairly large collection of&#xA;unpublished artwork from J.R.R. Tolkien while preparing the 75th&#xA;anniversary edition of The Hobbit.  The artwork is being published&#xA;in a new &lt;a href=&#34;http://www.amazon.com/Art-Hobbit-J-R-Tolkien/dp/0007440812&#34; target=&#34;_blank&#34;&gt;book&lt;/a&gt; (via &lt;a href=&#34;http://www.wired.com/geekdad/2011/10/the-hobbit-as-tolkien-saw-it/&#34; target=&#34;_blank&#34;&gt;GeekDad&lt;/a&gt;).&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;As always, enjoy your Friday and have a great weekend.&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>Garbage collection/reference counting in C&#43;&#43;11</title>
      <link>https://freerangebits.com/posts/2011/10/cxx-gc/</link>
      <pubDate>Thu, 27 Oct 2011 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2011/10/cxx-gc/</guid>
      <description>&lt;p&gt;There are plenty of people who criticize C++ for not having a standard&#xA;garbage collector.  Herb Sutter &lt;a href=&#34;http://herbsutter.com/2011/10/25/garbage-collection-synopsis-and-c/&#34; target=&#34;_blank&#34;&gt;explains why&lt;/a&gt; C++ doesn&amp;rsquo;t&#xA;support automatic mark-compact garbage collection but does have a&#xA;formal ABI for mark-sweep style collectors and supports reference&#xA;counting through the new &lt;code&gt;unique_ptr&lt;/code&gt;, &lt;code&gt;shared_ptr&lt;/code&gt;, and &lt;code&gt;weak_ptr&lt;/code&gt;&#xA;types.  The article&amp;rsquo;s comments help shed some light on a very&#xA;important C++ viewpoint: deterministic destructors are super helpful.&lt;/p&gt;&#xA;&lt;p&gt;The &lt;a href=&#34;http://www2.research.att.com/~bs/C&amp;#43;&amp;#43;0xFAQ.html&#34; target=&#34;_blank&#34;&gt;C++11 FAQ&lt;/a&gt; maintained by Bjarne Stroustrup contains more&#xA;information about the new automatic pointer types.&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>Don&#39;t do your own date/time calculations</title>
      <link>https://freerangebits.com/posts/2011/10/date-time/</link>
      <pubDate>Wed, 26 Oct 2011 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2011/10/date-time/</guid>
      <description>&lt;p&gt;Landon Dyer has a nice &lt;a href=&#34;http://www.dadhacker.com/blog/?p=1585&#34; target=&#34;_blank&#34;&gt;rant on date/time calculation&lt;/a&gt; over on&#xA;his blog:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;This is a class of problem that everyone knows is trivial. &amp;ldquo;Of&#xA;course I know how to do this,&amp;rdquo; you probably think to yourself, &amp;ldquo;This&#xA;is trivial, I can just code this thing up and have an early lunch.&amp;rdquo;&#xA;Trivial is the most dangerous word in all of computerdom, it&amp;rsquo;s a&#xA;misprounciation of &amp;ldquo;Evil&amp;rdquo;. Your blood should run cold if you hear it&#xA;spoken out loud, because the Gods will be listening carefully and&#xA;taking notes on how to screw you if they ever hear you say it.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;The comments make this article even more interesting with everyone&#xA;comparing their date/time war stories.&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>Keep learning and make mistakes</title>
      <link>https://freerangebits.com/posts/2011/10/keep-learning/</link>
      <pubDate>Mon, 24 Oct 2011 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2011/10/keep-learning/</guid>
      <description>&lt;p&gt;After reading a &lt;a href=&#34;http://www.wired.com/wiredscience/2011/10/why-do-some-people-learn-faster-2/&#34; target=&#34;_blank&#34;&gt;Wired article&lt;/a&gt; about why some people learn&#xA;faster than others, Davy Brion wrote &lt;a href=&#34;http://davybrion.com/blog/2011/10/developers-need-to-keep-challenging-themselves/&#34; target=&#34;_blank&#34;&gt;an article&lt;/a&gt; putting the&#xA;study in the context of software development and why we need to&#xA;continually challenge ourselves:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;It also kinda confirms what I&amp;rsquo;ve seen from fellow developers ever&#xA;since I graduated and started working. Every good developer I&amp;rsquo;ve met&#xA;isn&amp;rsquo;t afraid to make mistakes and sees mistakes as learning&#xA;opportunities. These people routinely challenge themselves by&#xA;learning something new. They also keep an eye on what other people&#xA;are doing to get better and they actively try to learn from people&#xA;they consider to be better than them.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Davy&amp;rsquo;s experiences resonate with my own.  I&amp;rsquo;m always tinkering with&#xA;something new.  From the outside I&amp;rsquo;m sure it looks like I have a very&#xA;short attention span, and that&amp;rsquo;s often what I tell people.&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>Fun stuff for Friday</title>
      <link>https://freerangebits.com/posts/2011/10/fun-friday-21/</link>
      <pubDate>Fri, 21 Oct 2011 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2011/10/fun-friday-21/</guid>
      <description>&lt;p&gt;Here&amp;rsquo;s some fun stuff to help boost the enjoyment of your Friday.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Remember those noisy 3.5&amp;quot; floppy drives?  Watch &lt;a href=&#34;http://www.youtube.com/watch?v=yHJOz_y9rZE&#34; target=&#34;_blank&#34;&gt;dueling&#xA;drives&lt;/a&gt; play the Imperial March, and read &lt;a href=&#34;http://silent.org.pl/home/2011/09/29/evil-floppy-drives-english-translation/&#34; target=&#34;_blank&#34;&gt;how it was done&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;You&amp;rsquo;ve probably seen the video of the levitating superconductor.&#xA;&lt;a href=&#34;http://io9.com/5850729/&#34; target=&#34;_blank&#34;&gt;This article&lt;/a&gt; explains how it works (with the video embedded&#xA;so you can watch it a few more times).&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;You can now pre-order &lt;a href=&#34;http://www.amazon.com/gp/product/1592406882/&#34; target=&#34;_blank&#34;&gt;The Geek Dad Book for Aspiring Mad&#xA;Scientists&lt;/a&gt; which promises to be a great way for you to share&#xA;your geekiness with your kids.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;If you missed it back in August, NPR compiled a list of the &lt;a href=&#34;http://www.npr.org/2011/08/09/139248590/top-100-science-fiction-fantasy-books&#34; target=&#34;_blank&#34;&gt;Top&#xA;100 Science-Fiction, Fantasy Books&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;Enjoy your Friday and have a great weekend.&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>Using regular expressions in C&#43;&#43;11</title>
      <link>https://freerangebits.com/posts/2011/10/cxx-regex/</link>
      <pubDate>Thu, 20 Oct 2011 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2011/10/cxx-regex/</guid>
      <description>&lt;p&gt;One of the major new features added to the &lt;a href=&#34;https://freerangebits.com/posts/2011/10/cxx11/&#34;&gt;recently released&#xA;C++11&lt;/a&gt; is support for regular expressions.  Sadly GCC doesn&amp;rsquo;t have&#xA;a working regex implementation yet, but &lt;a href=&#34;http://clang.llvm.org/&#34; target=&#34;_blank&#34;&gt;clang&lt;/a&gt; and Visual Studio&#xA;do.  If you&amp;rsquo;re looking for an introduction then the Solarian&#xA;Programmer has a two part tutorial to get you going:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Validating the user input was always a problem in C++, especially&#xA;when the user is supposed to enter a number. Each programmer was&#xA;forced to write his own error checking functions for numerical input&#xA;validation, basically it was no uniform syntax for checking the&#xA;correctness of the user input. Enter C++11 and regular expression!&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Start with &lt;a href=&#34;http://solarianprogrammer.com/2011/10/12/cpp-11-regex-tutorial/&#34; target=&#34;_blank&#34;&gt;part 1&lt;/a&gt; and finish off with &lt;a href=&#34;http://solarianprogrammer.com/2011/10/20/cpp-11-regex-tutorial-part-2/&#34; target=&#34;_blank&#34;&gt;part 2&lt;/a&gt;.&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>Write HTML/XML faster with Zen Coding</title>
      <link>https://freerangebits.com/posts/2011/10/zen-coding/</link>
      <pubDate>Thu, 20 Oct 2011 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2011/10/zen-coding/</guid>
      <description>&lt;p&gt;If you find yourself writing a lot of opening and closing tags by hand&#xA;you really should check out &lt;a href=&#34;http://code.google.com/p/zen-coding/&#34; target=&#34;_blank&#34;&gt;Zen Coding&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Zen Coding is an editor plugin for high-speed HTML, XML, XSL (or any&#xA;other structured code format) coding and editing. The core of this&#xA;plugin is a powerful abbreviation engine which allows you to expand&#xA;expressions&amp;ndash;similar to CSS selectors&amp;ndash;into HTML code.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;A very large variety of text editors are supported by the plug-in,&#xA;with alternative implementations for editors like Emacs and Vim.&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>Still looking for a language to learn this year?</title>
      <link>https://freerangebits.com/posts/2011/10/language-lists/</link>
      <pubDate>Wed, 19 Oct 2011 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2011/10/language-lists/</guid>
      <description>&lt;p&gt;It&amp;rsquo;s hard to believe the year is wrapping up, a constant reminder&#xA;being all the Christmas decorations on sale (next to the Halloween&#xA;decorations, which is weird).  If you&amp;rsquo;re looking for something to do&#xA;while taking all that copious holiday vacation time why not learn a&#xA;new programming language?  It sure beats listening to family members&#xA;argue over politics.&lt;/p&gt;&#xA;&lt;p&gt;To get you started Michael Fogus has written a couple of articles he&#xA;calls Perlis Languages:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;A Perlis Language is a programming language that I believe will&#xA;shake one&amp;rsquo;s views on software development to the core.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;The &lt;a href=&#34;http://blog.fogus.me/2011/08/14/perlis-languages/&#34; target=&#34;_blank&#34;&gt;first article&lt;/a&gt; contains an overview of 9 programming&#xA;languages, with the &lt;a href=&#34;http://blog.fogus.me/2011/10/18/programming-language-development-the-past-5-years/&#34; target=&#34;_blank&#34;&gt;second article&lt;/a&gt; covering an additional 14&#xA;(with brief mentions of another 12).&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>Sharing your private Git repositories</title>
      <link>https://freerangebits.com/posts/2011/10/git-server/</link>
      <pubDate>Tue, 18 Oct 2011 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2011/10/git-server/</guid>
      <description>&lt;p&gt;When I learned about branching and merging in Git a few years ago I&#xA;was hooked.  Then the honeymoon came to an end and I realized that&#xA;sharing a private repository with someone required giving them SSH&#xA;access.  Ouch!  Fortunately &lt;a href=&#34;https://github.com/&#34; target=&#34;_blank&#34;&gt;GitHub&lt;/a&gt; came along and solved the&#xA;problem well enough that the idea faded into the back of my mind.&lt;/p&gt;&#xA;&lt;p&gt;Then one day I needed to share a private repository with someone just&#xA;for fun and didn&amp;rsquo;t think that paying GitHub was justified.  I was&#xA;pleasantly surprised to see how many people have solved the private&#xA;repository access issue.&lt;/p&gt;&#xA;&lt;p&gt;If you&amp;rsquo;re looking to host your own private Git repository this list of&#xA;resources should get you started:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;&lt;a href=&#34;http://gitlabhq.com/&#34; target=&#34;_blank&#34;&gt;GitLab&lt;/a&gt; is a new open source project with features similar to&#xA;GitHub.  It has a nice looking user interface and repository&#xA;access control via SSH public keys.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;&lt;a href=&#34;https://github.com/sitaramc/gitolite&#34; target=&#34;_blank&#34;&gt;Gitolite&lt;/a&gt; is another open source project for administering a&#xA;centralized Git server with fine-grained access control.  It&#xA;doesn&amp;rsquo;t have a user interface so it&amp;rsquo;s purely for access control.&#xA;A similar project is &lt;a href=&#34;http://eagain.net/gitweb/?p=gitosis.git;a=summary&#34; target=&#34;_blank&#34;&gt;Gitosis&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;If you want something even simpler Richard Taylor has written an&#xA;article with instructions for&#xA;&lt;a href=&#34;https://moocode.com/posts/6-code-your-own-multi-user-private-git-server-in-5-minutes&#34; target=&#34;_blank&#34;&gt;setting up SSH to control access to Git&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;</description>
    </item>
    <item>
      <title>Challenge your text editor fu</title>
      <link>https://freerangebits.com/posts/2011/10/editor-golf/</link>
      <pubDate>Mon, 17 Oct 2011 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2011/10/editor-golf/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;http://www.igvita.com/&#34; target=&#34;_blank&#34;&gt;Ilya Grigorik&lt;/a&gt; has put together an excellent site called&#xA;&lt;a href=&#34;http://vimgolf.com/&#34; target=&#34;_blank&#34;&gt;VimGolf&lt;/a&gt; where developers host challenges to see who can complete&#xA;a task in &lt;a href=&#34;http://www.vim.org/&#34; target=&#34;_blank&#34;&gt;Vim&lt;/a&gt; with the fewest keystrokes.  Here&amp;rsquo;s an&#xA;&lt;a href=&#34;http://vimgolf.com/challenges/4d28637c4bcd032f1c00003d&#34; target=&#34;_blank&#34;&gt;example&lt;/a&gt; challenge:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Reformat long lines. Rearrange this ruby method call to put each&#xA;parameter on its own line. Could become a useful macro.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;You are given an input file and an output file with the goal to&#xA;provide the minimum number of keystrokes to convert the input file to&#xA;the output file.&lt;/p&gt;&#xA;&lt;p&gt;Vim not your cup of tea? &lt;a href=&#34;http://blog.twonegatives.com/&#34; target=&#34;_blank&#34;&gt;Tim Visher&lt;/a&gt; goes through the VimGolf&#xA;challenges with &lt;a href=&#34;http://www.gnu.org/s/emacs/&#34; target=&#34;_blank&#34;&gt;Emacs&lt;/a&gt; and posts &lt;a href=&#34;http://vimeo.com/timvisher&#34; target=&#34;_blank&#34;&gt;the results&lt;/a&gt; on Vimeo.  His&#xA;videos are great to watch if you want to improve your Emacs skills.&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>Reactions to Dart, 17k line Hello World</title>
      <link>https://freerangebits.com/posts/2011/10/dart-reactions/</link>
      <pubDate>Fri, 14 Oct 2011 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2011/10/dart-reactions/</guid>
      <description>&lt;p&gt;If you&amp;rsquo;ve been following all the chatter after Google&amp;rsquo;s Dart&#xA;announcement you know that reactions have been&amp;hellip; mixed?  No, not&#xA;really.  Besides the occasional and misguided praise for Dart as a&#xA;JavaScript killer, the majority of blog articles and comments are&#xA;critical of Dart and Google.&lt;/p&gt;&#xA;&lt;p&gt;Starting with a bit of humor, if you haven&amp;rsquo;t seen the 8-line Dart&#xA;version of Hello World translated into &lt;a href=&#34;https://gist.github.com/1277224&#34; target=&#34;_blank&#34;&gt;17k lines of JavaScript&lt;/a&gt;&#xA;it&amp;rsquo;s a fun read.  Of course the generated JavaScript from the Dart&#xA;translator includes all of the Dart libraries and isn&amp;rsquo;t optimized, so&#xA;it&amp;rsquo;s not an entirely fair look at Dart, but it is funny.  Optimizing&#xA;the JavaScript &lt;a href=&#34;http://jsperf.com/dart-hello-world-test-with-optimize/2&#34; target=&#34;_blank&#34;&gt;doesn&amp;rsquo;t help much&lt;/a&gt; either.  If you&amp;rsquo;re looking for a&#xA;better technical analysis of Dart, Rafaël Garcia-Suarez &lt;a href=&#34;http://blogs.perl.org/users/rafael_garcia-suarez/2011/10/why-dart-is-not-the-language-of-the-future.html&#34; target=&#34;_blank&#34;&gt;wrote a good&#xA;article&lt;/a&gt; on the subject.&lt;/p&gt;&#xA;&lt;p&gt;The criticism directed specifically at Google deals with Dart being&#xA;developed behind closed doors, with its open source status being more&#xA;for marketing than anything.  Brendan Eich (creator of JavaScript) has&#xA;&lt;a href=&#34;http://news.ycombinator.com/item?id=2983157&#34; target=&#34;_blank&#34;&gt;this to say&lt;/a&gt; about Google and Dart:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Innovating in the open and proposing early and often to standards&#xA;bodies are fine. Delayed-open-washing and increasing piles of&#xA;proprietary (open-source doesn&amp;rsquo;t matter) single-vendor code, which&#xA;implements features that are not ever proposed for standardization,&#xA;are not.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;</description>
    </item>
    <item>
      <title>Programming tips from a photographer</title>
      <link>https://freerangebits.com/posts/2011/10/photography-tips/</link>
      <pubDate>Thu, 13 Oct 2011 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2011/10/photography-tips/</guid>
      <description>&lt;p&gt;I&amp;rsquo;ve always rejected the term &amp;ldquo;Software Engineer&amp;rdquo; because I&amp;rsquo;ve met&#xA;very few people who write software like an engineer would.  To me&#xA;software development ebbs and flows between science and art, probably&#xA;like any creative endeavor.&lt;/p&gt;&#xA;&lt;p&gt;Certainly I&amp;rsquo;m not the first person to think this way.  People much&#xA;smarter than me, &lt;a href=&#34;http://www.paulgraham.com/&#34; target=&#34;_blank&#34;&gt;Paul Graham&lt;/a&gt; for example, have already&#xA;&lt;a href=&#34;http://www.paulgraham.com/hackpaint.html&#34; target=&#34;_blank&#34;&gt;written about this&lt;/a&gt;.  That&amp;rsquo;s why I pay attention when people in&#xA;other creative fields give advice.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&#34;http://www.chasejarvis.com&#34; target=&#34;_blank&#34;&gt;Chase Jarvis&lt;/a&gt; is one of those people, and he recently wrote&#xA;&lt;a href=&#34;http://blog.chasejarvis.com/blog/2011/10/ten-things-every-creative-person-must-learn/&#34; target=&#34;_blank&#34;&gt;10 Things Every Creative Person Must Learn&lt;/a&gt;.  It could have&#xA;been written for programmers, any of this sound familiar?&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Simple is good.  Almost every photo that is bad has too much&#xA;information. Outside of technical basics, the number one reason that&#xA;most photos fail is because there is no clear subject. Often this is&#xA;the case with design, film, fashion, you name it. Remove clutter,&#xA;remove distraction.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;One of my pet peeves is unnecessarily complex code.  Simple code&#xA;always beats clever code, with fewer opportunities for bugs.&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>Subversion 1.7 released, goodbye .svn pollution</title>
      <link>https://freerangebits.com/posts/2011/10/subversion-1-7/</link>
      <pubDate>Wed, 12 Oct 2011 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2011/10/subversion-1-7/</guid>
      <description>&lt;p&gt;The &lt;a href=&#34;http://subversion.apache.org/&#34; target=&#34;_blank&#34;&gt;Subversion&lt;/a&gt; team has been making steady improvements to&#xA;some of Subversion&amp;rsquo;s most criticized features, namely branching and&#xA;merging.  With the &lt;a href=&#34;http://subversion.apache.org/docs/release-notes/1.7.html&#34; target=&#34;_blank&#34;&gt;release of 1.7&lt;/a&gt; Subversion finally takes&#xA;care of all those darn &lt;code&gt;.svn&lt;/code&gt; directories:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;A key feature of the changes introduced in Subversion 1.7 is the&#xA;centralization of working copy metadata storage into a single&#xA;location. Instead of a .svn directory in every directory in the&#xA;working copy, Subversion 1.7 working copies have just one .svn&#xA;directory&amp;ndash;in the root of the working copy. This directory includes&#xA;(among other things) an SQLite-backed database which contains all of&#xA;the metadata Subversion needs for that working copy.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Besides the release notes, Jessica Thornsby&amp;rsquo;s&#xA;&lt;a href=&#34;http://blogs.wandisco.com/2011/10/11/top-new-features-in-subversion-1-7-wc-ng-pristines/&#34; target=&#34;_blank&#34;&gt;Top New Features in 1.7&lt;/a&gt; article is a great place to get&#xA;information along with her &lt;a href=&#34;http://blogs.wandisco.com/2011/10/07/whats-new-in-subversion-1-7/&#34; target=&#34;_blank&#34;&gt;What&amp;rsquo;s New&lt;/a&gt; video.&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>C&#43;&#43;11 is officially released, goodbye C&#43;&#43;0x</title>
      <link>https://freerangebits.com/posts/2011/10/cxx11/</link>
      <pubDate>Tue, 11 Oct 2011 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2011/10/cxx11/</guid>
      <description>&lt;p&gt;The ISO/IEC C++ committee &lt;a href=&#34;http://www.iso.org/iso/pressrelease.htm?refid=Ref1472&#34; target=&#34;_blank&#34;&gt;made the announcement&lt;/a&gt; that the latest&#xA;version of the official C++ standard (C++11) is done, the first major&#xA;change to C++ since 1998.  The announcement quotes &lt;a href=&#34;http://herbsutter.com/about/&#34; target=&#34;_blank&#34;&gt;Herb Sutter&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&amp;hellip;and now with C++11&amp;rsquo;s improvements that incorporate many of the&#xA;best features of managed languages, modern C++ code is as clean and&#xA;safe as code written other modern languages, as well as fast with&#xA;performance by default and full access to the underlying system&#xA;whenever you need it.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;However you feel about C++, there&amp;rsquo;s something to be said about being&#xA;an ISO standard and having a body of passionate people to guide a&#xA;language through the tricky waters of backwards compatibility.  I&#xA;remember installing a maintenance release of an interpreted language&#xA;in order to fix a bug and discovered later that this micro version&#xA;included a syntax change that wasn&amp;rsquo;t backwards compatible and broke&#xA;all my production code.  That was the beginning of the end for Perl&#xA;for me.&lt;/p&gt;&#xA;&lt;p&gt;So what&amp;rsquo;s new, and what changed in C++11?  Actually, &lt;a href=&#34;http://www2.research.att.com/~bs/C&amp;#43;&amp;#43;0xFAQ.html&#34; target=&#34;_blank&#34;&gt;the list of&#xA;changes&lt;/a&gt; is pretty long, including a new lambda syntax, regular&#xA;expressions, threading, and finally a resolution to the &lt;a href=&#34;http://en.wikipedia.org/wiki/C%2B%2B11#Right_angle_bracket&#34; target=&#34;_blank&#34;&gt;closing right&#xA;angle&lt;/a&gt; parsing ambiguity.  Danny Kalev wrote a &lt;a href=&#34;http://www.softwarequalityconnection.com/2011/06/the-biggest-changes-in-c11-and-why-you-should-care/&#34; target=&#34;_blank&#34;&gt;great article&lt;/a&gt;&#xA;back in June that covers some of the major changes in C++11.  There&amp;rsquo;s&#xA;also a &lt;a href=&#34;http://wiki.apache.org/stdcxx/C%2B%2B0xCompilerSupport&#34; target=&#34;_blank&#34;&gt;compiler compatibility chart&lt;/a&gt; to get you started.&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>Google&#39;s language for people who hate JavaScript</title>
      <link>https://freerangebits.com/posts/2011/10/google-dart/</link>
      <pubDate>Tue, 11 Oct 2011 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2011/10/google-dart/</guid>
      <description>&lt;p&gt;Poor JavaScript, first you get stuck with a terrible name, then years&#xA;of horribly busted implementations and web pages contaminated with&#xA;unrecognizable code, and now everyone hates your syntax.&lt;/p&gt;&#xA;&lt;p&gt;If you too are a JavaScript hater and &lt;a href=&#34;http://jashkenas.github.com/coffee-script/&#34; target=&#34;_blank&#34;&gt;CoffeeScript&lt;/a&gt; leaves a&#xA;sour taste in your mouth, &lt;em&gt;and&lt;/em&gt; you happen to love Java syntax, Google&#xA;gives you another option: &lt;a href=&#34;http://www.dartlang.org/&#34; target=&#34;_blank&#34;&gt;Dart&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;For client-site execution (in the web browser) Dart, like&#xA;CoffeeScript, is translated to JavaScript first.  But unlike&#xA;CoffeeScript, Dart also comes with a virtual machine for server-side&#xA;execution (without translation to JavaScript), which the Dart team&#xA;says will allow you to reduce context switching by allowing you to&#xA;write your entire application in a single language.&lt;/p&gt;&#xA;&lt;p&gt;Google is also proposing a new mime type &amp;ldquo;&lt;code&gt;application/dart&lt;/code&gt;&amp;rdquo; with the&#xA;hope that browsers will adopt execution of Dart directly without the&#xA;need to translate to JavaScript first.  It will be interesting to see&#xA;if Google has enough pull and Dart has enough of a following to&#xA;actually get browser makers to implement/include a Dart interpreter.&lt;/p&gt;&#xA;&lt;p&gt;After spending some time digging through the rather large&#xA;&lt;a href=&#34;http://code.google.com/p/dart/&#34; target=&#34;_blank&#34;&gt;source tree&lt;/a&gt; for Dart, it&amp;rsquo;s not clear to me how the DOM library&#xA;plans to deal with JavaScript compatibility issues between different&#xA;browsers (IE I&amp;rsquo;m giving you the evil eye).  CoffeeScript on the other&#xA;hand has an interesting position because it&amp;rsquo;s a superset of JavaScript&#xA;which means you can continue using your favorite JavaScript framework&#xA;(e.g. jQuery, Prototype, etc.).&lt;/p&gt;&#xA;&lt;p&gt;Better analysis from a Java perspective, with syntax examples, can be&#xA;found in Axel Rauschmayer&amp;rsquo;s &lt;a href=&#34;http://java.dzone.com/news/googles-dart-revealed&#34; target=&#34;_blank&#34;&gt;article on Dart&lt;/a&gt; from yesterday.&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>Unix toolbox: sed and awk</title>
      <link>https://freerangebits.com/posts/2011/10/sed-awk/</link>
      <pubDate>Mon, 10 Oct 2011 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2011/10/sed-awk/</guid>
      <description>&lt;p&gt;Chances are good that you&amp;rsquo;re developing software on a platform that&#xA;supports the Unix command line, even Microsoft platform developers&#xA;&lt;a href=&#34;http://www.cygwin.com/&#34; target=&#34;_blank&#34;&gt;have access&lt;/a&gt; to the Unix toolbox.  There&amp;rsquo;s a lot of power&#xA;and convenience to be found on the command line that can&amp;rsquo;t be&#xA;replicated in a GUI.&lt;/p&gt;&#xA;&lt;p&gt;If you&amp;rsquo;re manipulating text, which is what we do all day long, and&#xA;you&amp;rsquo;re not taking advantage of the Unix command line, you&amp;rsquo;re really&#xA;missing out on some huge productivity benefits.  But getting started&#xA;with tools such as &lt;code&gt;sed&lt;/code&gt; and &lt;code&gt;awk&lt;/code&gt; can be intimidating and the manual&#xA;pages aren&amp;rsquo;t very helpful for a beginner either.&lt;/p&gt;&#xA;&lt;p&gt;Here are some resources to get you going:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Bruce Barnett maintains a rather complete &lt;a href=&#34;http://www.grymoire.com/Unix/Sed.html&#34; target=&#34;_blank&#34;&gt;introduction to sed&lt;/a&gt; with a PDF &lt;a href=&#34;http://www.grymoire.com/Unix/SedChart.pdf&#34; target=&#34;_blank&#34;&gt;cheat sheet&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;If you like Bruce&amp;rsquo;s sed tutorial be sure to check out his equally&#xA;good &lt;a href=&#34;http://www.grymoire.com/Unix/Awk.html&#34; target=&#34;_blank&#34;&gt;awk tutorial&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Peteris Krumins wrote an article about &lt;a href=&#34;http://www.catonmat.net/blog/worlds-best-introduction-to-sed/&#34; target=&#34;_blank&#34;&gt;sed oneliners&lt;/a&gt; and a&#xA;&lt;a href=&#34;http://www.catonmat.net/blog/awk-book/&#34; target=&#34;_blank&#34;&gt;book about awk&lt;/a&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Joshua Thijssen has some &lt;a href=&#34;http://www.adayinthelifeof.nl/2010/12/11/sed-awk-examples/&#34; target=&#34;_blank&#34;&gt;practical examples&lt;/a&gt; of using awk to&#xA;mine data from an Apache log file.&lt;/li&gt;&#xA;&lt;li&gt;And there&amp;rsquo;s the &lt;a href=&#34;http://www.amazon.com/sed-awk-2nd-Dale-Dougherty/dp/1565922255&#34; target=&#34;_blank&#34;&gt;sed &amp;amp; awk&lt;/a&gt; book if you&amp;rsquo;re looking for a&#xA;complete text with examples.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;</description>
    </item>
    <item>
      <title>NewtonScript and other prototype-based languages</title>
      <link>https://freerangebits.com/posts/2011/10/newtonscript/</link>
      <pubDate>Fri, 07 Oct 2011 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2011/10/newtonscript/</guid>
      <description>&lt;p&gt;With news this week that Steve Jobs had passed away I took a moment to&#xA;reflect on my obsession with Apple products over the years and was&#xA;reminded of my passion for the &lt;a href=&#34;http://oldcomputers.net/apple-newton.html&#34; target=&#34;_blank&#34;&gt;Newton Message Pad&lt;/a&gt;.  Beyond&#xA;being a super cool gadget the MessagePad introduced me to&#xA;&lt;a href=&#34;http://en.wikipedia.org/wiki/Prototype_based&#34; target=&#34;_blank&#34;&gt;prototype-based languages&lt;/a&gt; through &lt;a href=&#34;http://en.wikipedia.org/wiki/Newtonscript&#34; target=&#34;_blank&#34;&gt;NewtonScript&lt;/a&gt;.&#xA;Strangely enough, it was Steve Jobs who canceled the Newton project in&#xA;1998 after his return to Apple.  I wasn&amp;rsquo;t too happy with him at the&#xA;time.&lt;/p&gt;&#xA;&lt;p&gt;In 1997, when I got my first MessagePad, I was splitting my time&#xA;between C++ and Perl.  Trying to learn NewtonScript twisted my brain&#xA;and the utter lack of proper NewtonScript debugging tools didn&amp;rsquo;t make&#xA;anything easier on me.  After I got the hang of things, however, I&#xA;really started to enjoy myself.  It seemed like I could write&#xA;sophisticated GUI applications with very little code, and absolutely&#xA;no design skill.&lt;/p&gt;&#xA;&lt;p&gt;NewtonScript was heavily influenced by &lt;a href=&#34;http://selflanguage.org/&#34; target=&#34;_blank&#34;&gt;Self&lt;/a&gt;, another&#xA;prototype-based language.  Self also influenced another&#xA;prototype-based language that has become very popular, JavaScript.&lt;/p&gt;&#xA;&lt;p&gt;What&amp;rsquo;s so different about prototype languages?  It might help to&#xA;consider that prototype-based languages are also referred to as&#xA;classless object oriented languages.  Class-based languages use&#xA;classes to distribute behavior to objects through types and&#xA;inheritance, whereas prototype-based languages do everything at the&#xA;object level, on a per-object basis.&lt;/p&gt;&#xA;&lt;p&gt;If you&amp;rsquo;re interested in playing with a prototype-based language&#xA;NewtonScript probably isn&amp;rsquo;t the way to go, but one of these more&#xA;active languages should pique your interest:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&#34;http://iolanguage.com/&#34; target=&#34;_blank&#34;&gt;Io&lt;/a&gt;: a tiny pure OO language&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;http://www.lua.org/&#34; target=&#34;_blank&#34;&gt;Lua&lt;/a&gt;: a popular embeddable scripting language&lt;/li&gt;&#xA;&lt;li&gt;And of course there&amp;rsquo;s &lt;a href=&#34;http://selflanguage.org/&#34; target=&#34;_blank&#34;&gt;Self&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;If you haven&amp;rsquo;t learned a new language this year maybe it should be a&#xA;prototype-based one.&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>Playing with Google Go</title>
      <link>https://freerangebits.com/posts/2011/10/google-go/</link>
      <pubDate>Thu, 06 Oct 2011 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2011/10/google-go/</guid>
      <description>&lt;p&gt;If you&amp;rsquo;re curious about Google&amp;rsquo;s &lt;a href=&#34;http://golang.org/&#34; target=&#34;_blank&#34;&gt;Go language&lt;/a&gt; but haven&amp;rsquo;t moved&#xA;past &amp;ldquo;hello world&amp;rdquo; you might be interested in playing with the new&#xA;interactive introduction to Go, &lt;a href=&#34;http://go-tour.appspot.com/&#34; target=&#34;_blank&#34;&gt;A Tour of Go&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;The tour is interactive. Click the Compile button now (or type&#xA;Shift-Enter) to compile and run the program on a remote server. The&#xA;result is displayed below the code.&lt;/p&gt;&#xA;&lt;p&gt;These example programs demonstrate different aspects of Go. The&#xA;programs in the tour are meant to be starting points for your own&#xA;experimentation.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;There&amp;rsquo;s also a &lt;a href=&#34;http://www.google.com/search?q=go&amp;#43;syntax&amp;amp;tbm=blg&#34; target=&#34;_blank&#34;&gt;long list of blog articles&lt;/a&gt; looking at the Go&#xA;syntax.  &lt;a href=&#34;http://blog.carbonfive.com/author/jcooper/&#34; target=&#34;_blank&#34;&gt;Jon Cooper&lt;/a&gt; recently wrote an article &lt;a href=&#34;http://blog.carbonfive.com/2011/10/04/explorations-in-go-a-dupe-checker-in-go-and-ruby/&#34; target=&#34;_blank&#34;&gt;exploring the&#xA;syntax of Go and Ruby&lt;/a&gt; by comparing a script written in both.&#xA;Personally, I&amp;rsquo;m a huge fan of Ruby syntax so I still have a way to go&#xA;in order to I warm up to the Go syntax.&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>Ruby Core Team: Dude, Ruby 1.8 is dead, really</title>
      <link>https://freerangebits.com/posts/2011/10/ruby-18/</link>
      <pubDate>Thu, 06 Oct 2011 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2011/10/ruby-18/</guid>
      <description>&lt;p&gt;I don&amp;rsquo;t know if I&amp;rsquo;ve let time get away from me or I&amp;rsquo;m just not as cool&#xA;as I used to be but I&amp;rsquo;m still using Ruby 1.8 most of the time.  The&#xA;last couple of years has seen a big push towards 1.9 and now the Ruby&#xA;Core Team is &lt;a href=&#34;http://www.ruby-lang.org/en/news/2011/10/06/plans-for-1-8-7/&#34; target=&#34;_blank&#34;&gt;getting serious about leaving 1.8 in the past&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Ruby&amp;rsquo;s core developers have been actively working on their new&#xA;version, 1.9, and they are about to release new 1.9.3. I have been&#xA;using 1.9 for years and now I cannot go back to the days without&#xA;it. Rich features. Faster execution. Rubygems integrated. Rails&#xA;works perfectly. I cannot but say it is totally wonderful. Everyone&#xA;please, use 1.9.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;If you haven&amp;rsquo;t made the transition to 1.9, here are a few links to get&#xA;you moving:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Bruce Williams&amp;rsquo; &lt;a href=&#34;http://www.scribd.com/doc/2589469/Migrating-to-Ruby-19&#34; target=&#34;_blank&#34;&gt;Migrating to Ruby 1.9&lt;/a&gt; presentation&lt;/li&gt;&#xA;&lt;li&gt;A &lt;a href=&#34;http://dablog.rubypal.com/2009/1/14/10-things-to-be-aware-of-in-moving-to-ruby-1-9&#34; target=&#34;_blank&#34;&gt;list of 10 things&lt;/a&gt; that David Black wants you to keep in mind&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;http://www.rubyinside.com/19walkthrough/&#34; target=&#34;_blank&#34;&gt;The Ruby 1.9 Walkthrough&lt;/a&gt; video ($16) by Peter Cooper&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;I guess I better start updating that Rails 1.2.6 app I have running in&#xA;production.&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>Don&#39;t write CPU intensive code in JS, duh</title>
      <link>https://freerangebits.com/posts/2011/10/nodejs-cpu/</link>
      <pubDate>Tue, 04 Oct 2011 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2011/10/nodejs-cpu/</guid>
      <description>&lt;p&gt;If you haven&amp;rsquo;t been following the flame war that ensued after Ted&#xA;Dziuba wrote his now famous &lt;a href=&#34;http://teddziuba.com/2011/10/node-js-is-cancer.html&#34; target=&#34;_blank&#34;&gt;Node.js is Cancer&lt;/a&gt; article you&amp;rsquo;re&#xA;missing out on some good fun.  Ted&amp;rsquo;s main point is that event-based&#xA;frameworks, specifically &lt;a href=&#34;http://nodejs.org/&#34; target=&#34;_blank&#34;&gt;Node.js&lt;/a&gt;, suffer from a poor&#xA;implementation that allows the main event loop to block if a handler&#xA;blocks.&lt;/p&gt;&#xA;&lt;p&gt;Tony Arcieri wrote &lt;a href=&#34;http://www.unlimitednovelty.com/2011/10/nodejs-has-jumped-shark.html&#34; target=&#34;_blank&#34;&gt;a great follow up&lt;/a&gt; covering the fact that&#xA;some people totally missed Ted&amp;rsquo;s point and even &lt;a href=&#34;https://github.com/glenjamin/node-fib&#34; target=&#34;_blank&#34;&gt;tried to solve the&#xA;example problem&lt;/a&gt; that Ted used in his article to demonstrate&#xA;the weakness in Node.js.&lt;/p&gt;&#xA;&lt;p&gt;The Node.js blog didn&amp;rsquo;t directly respond to Ted&amp;rsquo;s criticism but&#xA;instead decided to say &amp;ldquo;&lt;a href=&#34;http://blog.nodejs.org/2011/10/04/an-easy-way-to-build-scalable-network-programs/&#34; target=&#34;_blank&#34;&gt;don&amp;rsquo;t do that&lt;/a&gt;&amp;rdquo; in a roundabout&#xA;way:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Using Node does not mean that you have to write a video encoding&#xA;algorithm in JavaScript (a language without even 64 bit integers)&#xA;and crunch away in the main server event loop. The suggested&#xA;approach is to separate the I/O bound task of receiving uploads and&#xA;serving downloads from the compute bound task of video encoding. In&#xA;the case of video encoding this is accomplished by forking out to&#xA;ffmpeg. Node provides advanced means of asynchronously controlling&#xA;subprocesses for work like this.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Disclaimer: Using JavaScript server-side seems gross to me.&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>The diminishing returns of testing</title>
      <link>https://freerangebits.com/posts/2011/10/testing-value/</link>
      <pubDate>Mon, 03 Oct 2011 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2011/10/testing-value/</guid>
      <description>&lt;p&gt;I cringe when I hear people talking about the need to reach 100% test&#xA;coverage because the return on investment after making it to that&#xA;point is pretty low.  The true value in testing lies in the validation&#xA;that critical code functions properly and continues to do so after&#xA;features are added to the system.&lt;/p&gt;&#xA;&lt;p&gt;An article on the &lt;a href=&#34;http://bitroar.posterous.com/&#34; target=&#34;_blank&#34;&gt;BitRoar&lt;/a&gt; blog &lt;a href=&#34;http://bitroar.posterous.com/when-tdd-fails&#34; target=&#34;_blank&#34;&gt;has a lot more to say on this subject&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;I&amp;rsquo;m not saying TDD is a bad thing, but there are more tests than&#xA;unit tests, and there are more ways to verify software than&#xA;testing. If you choose a methodology without comparing it against&#xA;alternatives, if you claim that it works all the time without&#xA;evaluating the results, than you&amp;rsquo;re not doing engineering - you&amp;rsquo;re&#xA;practicing a religion.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;The article picks on TDD specifically but I think the premise applies&#xA;to all types of testing.&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>The path to being a better developer</title>
      <link>https://freerangebits.com/posts/2011/10/better-dev/</link>
      <pubDate>Mon, 03 Oct 2011 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2011/10/better-dev/</guid>
      <description>&lt;p&gt;There are plenty of blog articles about being a better software&#xA;developer like &lt;a href=&#34;http://www.dodgycoder.net/2011/10/how-to-become-better-programmer.html&#34; target=&#34;_blank&#34;&gt;this one by Dodgy Coder&lt;/a&gt; or &lt;a href=&#34;http://joshblog.net/2009/01/12/five-ways-to-become-a-better-software-developer/&#34; target=&#34;_blank&#34;&gt;this one by Josh&#xA;Tynjala&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Not entirely sure how to go from code monkey to code ninja? I don’t&#xA;have all the answers, of course, but each of these suggestions has&#xA;personally helped me improve my career and discover other talented&#xA;people that were definitely worth meeting.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;When it comes to becoming a better software developer the gold&#xA;standard for books is &lt;a href=&#34;http://pragprog.com/book/tpp/the-pragmatic-programmer&#34; target=&#34;_blank&#34;&gt;The Pragmatic Programmer&lt;/a&gt; by &lt;a href=&#34;http://www.toolshed.com/&#34; target=&#34;_blank&#34;&gt;Andrew&#xA;Hunt&lt;/a&gt; and &lt;a href=&#34;http://pragdave.pragprog.com/&#34; target=&#34;_blank&#34;&gt;David Thomas&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Straight from the programming trenches, The Pragmatic Programmer:&#xA;From Journeyman to Master cuts through the increasing specialization&#xA;and technicalities of modern software development to examine the&#xA;core process—what do you do, as an individual and as a team, if you&#xA;want to create software that’s easy to work with and good for your&#xA;users.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;If you haven&amp;rsquo;t read The Pragmatic Programmer then you&amp;rsquo;re really&#xA;missing out.  Personally, it was a huge inspiration for me to really&#xA;step up my game as a developer.  In fact, my copy of the book is&#xA;fairly shabby and looks as if it had been found in a cave near Israel.&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>Replacing master with another Git branch</title>
      <link>https://freerangebits.com/posts/2011/09/git-replace-master/</link>
      <pubDate>Fri, 30 Sep 2011 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2011/09/git-replace-master/</guid>
      <description>&lt;p&gt;If you&amp;rsquo;re like &lt;a href=&#34;http://www.dmo.ca/&#34; target=&#34;_blank&#34;&gt;Dave O&amp;rsquo;Neill&lt;/a&gt; and find yourself working on a Git&#xA;branch that has diverged from master to the point that a merge would&#xA;make Linus Torvalds cry, why not just replace master?  Dave provides&#xA;step by step instructions in &lt;a href=&#34;http://www.dmo.ca/blog/20080307124544/&#34; target=&#34;_blank&#34;&gt;this article&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Over time, master diverged significantly from the current&#xA;maintenance branch. Recently, we decided to rebase our development&#xA;work on the maintenance branch, but there were just too many ugly&#xA;conflicts to resolve. As we didn&amp;rsquo;t want to keep all of the code on&#xA;that branch anyway, the easiest solution was to rename our&#xA;2.63-branch to master and resume development there, cherry-picking&#xA;some of the useful things from the development branch.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;</description>
    </item>
    <item>
      <title>Google releases JS Test</title>
      <link>https://freerangebits.com/posts/2011/09/google-jstest/</link>
      <pubDate>Thu, 29 Sep 2011 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2011/09/google-jstest/</guid>
      <description>&lt;p&gt;While there&amp;rsquo;s certainly no shortage of &lt;a href=&#34;http://en.wikipedia.org/wiki/List_of_unit_testing_frameworks#JavaScript&#34; target=&#34;_blank&#34;&gt;testing frameworks&lt;/a&gt; for&#xA;JavaScript, the vast majority of them require you to run your tests&#xA;inside a web browser. If you&amp;rsquo;d rather test your JavaScript outside of&#xA;a browser (and don&amp;rsquo;t want to use something heavy like &lt;a href=&#34;http://code.google.com/p/rhinounit/&#34; target=&#34;_blank&#34;&gt;RhinoUnit&lt;/a&gt;)&#xA;Google&amp;rsquo;s newly released &lt;a href=&#34;http://code.google.com/p/google-js-test/&#34; target=&#34;_blank&#34;&gt;JS Test&lt;/a&gt; framework might be the&#xA;ticket.&lt;/p&gt;&#xA;&lt;p&gt;From the &lt;a href=&#34;http://google-opensource.blogspot.com/2011/09/introducing-google-js-test.html&#34; target=&#34;_blank&#34;&gt;announcement&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Google JS Test is a JavaScript unit testing framework that runs on&#xA;the V8 JavaScript Engine, the same open source project that is&#xA;responsible for Google Chrome&amp;rsquo;s super-fast JS execution&#xA;speed. Google JS Test is used internally by several Google projects,&#xA;and we&amp;rsquo;re pleased to announce that it has been released as an open&#xA;source project.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Keep in mind that since JS Test runs inside Google&amp;rsquo;s &lt;a href=&#34;http://code.google.com/p/v8/&#34; target=&#34;_blank&#34;&gt;V8&lt;/a&gt; your&#xA;JavaScript won&amp;rsquo;t have access to the DOM.  Google recommends you&#xA;refactor your JavaScript to use as little DOM as possible then mock&#xA;out the remaining DOM pieces using JS Test&amp;rsquo;s mocking facilities.&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>Understanding Ruby Singleton Classes</title>
      <link>https://freerangebits.com/posts/2008/09/ruby-singleton/</link>
      <pubDate>Mon, 15 Sep 2008 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2008/09/ruby-singleton/</guid>
      <description>&lt;p&gt;If you learned object oriented programming from one of the more static&#xA;languages such as C++ or Java, the dynamic nature of Ruby may seem&#xA;magical and elusive.  After running into the syntax dedicated to&#xA;meta-programming you may have been left scratching your head or at&#xA;least wondering what&amp;rsquo;s happening behind the scenes.  Singleton&#xA;classes, not to be confused with the singleton design pattern, can&#xA;easily be placed into this head scratching category.&lt;/p&gt;&#xA;&lt;p&gt;The name itself is confusing leading people to create alternative&#xA;names such as: object-specific classes, anonymous classes, virtual&#xA;classes, and eigenclasses.  Anonymous class is my favorite, but since&#xA;the source code to the Ruby interpreter uses the term singleton that&amp;rsquo;s&#xA;what I&amp;rsquo;m going to stick with.&lt;/p&gt;&#xA;&lt;p&gt;Truth be told, singleton classes aren&amp;rsquo;t really that difficult to&#xA;understand.  In this excerpt from my Accelerated Ruby workshop, I&#xA;remove the mystical fog surrounding the singleton class, and even&#xA;demonstrate how they can be useful in your day-to-day Ruby adventures.&lt;/p&gt;&#xA;&lt;h2 id=&#34;method-dispatching&#34;&gt;Method Dispatching&lt;/h2&gt;&#xA;&lt;p&gt;Before we dive into the mysterious singleton underground, let&amp;rsquo;s step&#xA;back for a quick refresher on dynamic dispatch in Ruby.  With each&#xA;method call, the Ruby interpreter needs to examine the inheritance&#xA;hierarchy of the receiver in order to find the method that will be&#xA;executed.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-ruby&#34; data-lang=&#34;ruby&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;foobar &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; Array&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;new&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;foobar&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;class &lt;span style=&#34;color:#75715e&#34;&gt;# =&amp;gt; Array&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;foobar&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;size  &lt;span style=&#34;color:#75715e&#34;&gt;# =&amp;gt; 0&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;In the last statement above, the &lt;code&gt;size&lt;/code&gt; method was called on the &lt;code&gt;foobar&lt;/code&gt;&#xA;object.  You can also say that the &lt;code&gt;foobar&lt;/code&gt; object was the receiver of&#xA;the &lt;code&gt;size&lt;/code&gt; message.  It&amp;rsquo;s the class of the receiver where the&#xA;interpreter will start its search for the &lt;code&gt;size&lt;/code&gt; method, which in this&#xA;case is the &lt;code&gt;Array&lt;/code&gt; class.&lt;/p&gt;&#xA;&lt;p&gt;If the &lt;code&gt;Array&lt;/code&gt; class doesn&amp;rsquo;t contain the &lt;code&gt;size&lt;/code&gt; method, the search&#xA;will continue up the hierarchy until it&amp;rsquo;s found.  If the method isn&amp;rsquo;t&#xA;found at the top of the hierarchy, the search is aborted, and the&#xA;receiver is sent the &lt;code&gt;method_missing&lt;/code&gt; message.  Luckily for us the&#xA;&lt;code&gt;Array&lt;/code&gt; class does indeed have a &lt;code&gt;size&lt;/code&gt; method and in the example&#xA;above, it returned zero.&lt;/p&gt;&#xA;&lt;p&gt;The diagram below illustrates how an object is connected to its class,&#xA;and how a class is connected to its parent class, also known as its&#xA;&lt;em&gt;super&lt;/em&gt; class.&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&#34;normal-array.jpg&#34; alt=&#34;Dynamic Dispatch Without Singletons&#34;&gt;&lt;/p&gt;&#xA;&lt;h2 id=&#34;enter-the-singleton-class&#34;&gt;Enter the Singleton Class&lt;/h2&gt;&#xA;&lt;p&gt;Instead of working our way through some wordy and complicated&#xA;description of what a singleton class is, let&amp;rsquo;s just dive right in and&#xA;see what it does.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-ruby&#34; data-lang=&#34;ruby&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;foobar &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; Array&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;new&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;def&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;foobar&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;size&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Hello World!&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;end&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;foobar&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;size  &lt;span style=&#34;color:#75715e&#34;&gt;# =&amp;gt; &amp;#34;Hello World!&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;foobar&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;class &lt;span style=&#34;color:#75715e&#34;&gt;# =&amp;gt; Array&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;bizbat &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; Array&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;new&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;bizbat&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;size  &lt;span style=&#34;color:#75715e&#34;&gt;# =&amp;gt; 0&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;As in the previous example, a new instance of the &lt;code&gt;Array&lt;/code&gt; class is&#xA;created and safely tucked away into a variable named &lt;code&gt;foobar&lt;/code&gt;.  Then,&#xA;without warning, we have a funny looking method definition.&lt;/p&gt;&#xA;&lt;p&gt;Ruby, being the flexible language that it is, allows you to explicitly&#xA;specify a receiver when defining methods.  That is, we can tell Ruby&#xA;what object will acquire the new method.  This syntax shouldn&amp;rsquo;t look&#xA;too unfamiliar, since it&amp;rsquo;s similar to the syntax used when creating&#xA;class methods.  However, in the case above, we&amp;rsquo;re adding a method to&#xA;the &lt;code&gt;foobar&lt;/code&gt; object.&lt;/p&gt;&#xA;&lt;p&gt;That&amp;rsquo;s right, that method definition above creates a method that only&#xA;exists for a single object, not for a class of objects.  As you can&#xA;see from the example code above, other objects of the &lt;code&gt;Array&lt;/code&gt; class do&#xA;not have this new &lt;code&gt;size&lt;/code&gt; method, they&amp;rsquo;re still using the one defined&#xA;in the &lt;code&gt;Array&lt;/code&gt; class.&lt;/p&gt;&#xA;&lt;p&gt;That cheeky little &lt;code&gt;foobar&lt;/code&gt; object has now been transformed to&#xA;something slightly different than what it was before.  How is this&#xA;possible?  What is it that makes this &lt;code&gt;foobar&lt;/code&gt; object so special that&#xA;it gets to have methods that no other object has?  If you said&#xA;&amp;ldquo;singleton class&amp;rdquo; you&amp;rsquo;d be correct.  When you add a method to a&#xA;specific object Ruby inserts a new anonymous class into the&#xA;inheritance hierarchy as a container to hold these types of methods.&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&#34;singleton-array.jpg&#34; alt=&#34;Dynamic Dispatch With Singletons&#34;&gt;&lt;/p&gt;&#xA;&lt;p&gt;This new singleton class in the &lt;code&gt;foobar&lt;/code&gt; inheritance hierarchy has&#xA;some special properties.  As mentioned before, the singleton class is&#xA;anonymous, it has no name and is not accessible through a constant&#xA;like other classes.  You are able, however, to access the singleton&#xA;class using some trickery but you can&amp;rsquo;t instantiate a new object from&#xA;it.&lt;/p&gt;&#xA;&lt;p&gt;Object instantiation is prevented by the interpreter for any class&#xA;that has a special singleton flag set on it.  This internal flag is&#xA;also used when you call the &lt;code&gt;class&lt;/code&gt; method on an object.  You would&#xA;expect that the singleton class is returned from that method call, but&#xA;in fact the interpreter skips over it and returns &lt;code&gt;Array&lt;/code&gt; instead.&lt;/p&gt;&#xA;&lt;p&gt;Another very interesting side effect of the singleton class is that&#xA;you can use the &lt;code&gt;super&lt;/code&gt; method from within your singleton method.&#xA;Looking back to the code above, we could have called the &lt;code&gt;super&lt;/code&gt;&#xA;method from inside the singleton method.  In that case, we would be&#xA;calling the &lt;code&gt;size&lt;/code&gt; method from the &lt;code&gt;Array&lt;/code&gt; class.&lt;/p&gt;&#xA;&lt;p&gt;Speaking of side effects, if you&amp;rsquo;re curious whether or not an object&#xA;has a singleton class, there is an introspective method called&#xA;&lt;code&gt;singleton_methods&lt;/code&gt; that you can use to get a list of names for all of&#xA;the singleton methods on an object.&lt;/p&gt;&#xA;&lt;p&gt;Finally, a word of caution.  Once you&amp;rsquo;ve created a singleton class for&#xA;an object you can no longer use &lt;code&gt;Marshal.dump&lt;/code&gt; on that object.  The&#xA;marshal library doesn&amp;rsquo;t support objects with singleton classes:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;&amp;gt;&amp;gt; Marshal.dump(foobar)&#xA;TypeError: singleton can&#39;t be dumped&#xA;        from (irb):6:in `dump&#39;&#xA;        from (irb):6&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Since some of the distributed programming libraries use the marshal&#xA;calls to move objects around machines you might run into the error&#xA;message above.  And now you know what it means.&lt;/p&gt;&#xA;&lt;h2 id=&#34;more-ways-to-skin-a-singleton&#34;&gt;More Ways to Skin a Singleton&lt;/h2&gt;&#xA;&lt;p&gt;It shouldn&amp;rsquo;t be surprising that Ruby has several ways to create a&#xA;singleton class for an object.  Below you&amp;rsquo;ll find no less than three&#xA;additional techniques.&lt;/p&gt;&#xA;&lt;h3 id=&#34;methods-from-modules&#34;&gt;Methods From Modules&lt;/h3&gt;&#xA;&lt;p&gt;When you use the &lt;code&gt;extend&lt;/code&gt; method on an object to add methods to it&#xA;from a module, those methods are placed into a singleton class.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-ruby&#34; data-lang=&#34;ruby&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;module&lt;/span&gt; Foo&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#66d9ef&#34;&gt;def&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;foo&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Hello World!&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#66d9ef&#34;&gt;end&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;end&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;foobar &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;[]&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;foobar&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;extend(&lt;span style=&#34;color:#66d9ef&#34;&gt;Foo&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;foobar&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;singleton_methods &lt;span style=&#34;color:#75715e&#34;&gt;# =&amp;gt; [&amp;#34;foo&amp;#34;]&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&#34;opening-the-singleton-class-directly&#34;&gt;Opening the Singleton Class Directly&lt;/h3&gt;&#xA;&lt;p&gt;Here comes the funny syntax that everyone has been waiting for.  The&#xA;code below tends to confuse people when they see it for the first time&#xA;but it&amp;rsquo;s pretty useful and fairly straightforward.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-ruby&#34; data-lang=&#34;ruby&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;foobar &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;[]&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;class&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;&amp;lt;&amp;lt;&lt;/span&gt; foobar&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#66d9ef&#34;&gt;def&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;foo&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Hello World!&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#66d9ef&#34;&gt;end&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;end&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;foobar&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;singleton_methods &lt;span style=&#34;color:#75715e&#34;&gt;# =&amp;gt; [&amp;#34;foo&amp;#34;]&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Anytime you see a strange looking class definition where the &lt;code&gt;class&lt;/code&gt;&#xA;keyword is followed by two less than symbols, you can be sure that a&#xA;singleton class is being opened for the object to the right of those&#xA;symbols.&lt;/p&gt;&#xA;&lt;p&gt;In this example, the singleton class for the &lt;code&gt;foobar&lt;/code&gt; object is being&#xA;opened.  As you probably already know, Ruby allows you to reopen a&#xA;class at any point adding methods and doing anything you could have&#xA;done in the original class definition.  As with the rest of the&#xA;examples in this section a &lt;code&gt;foo&lt;/code&gt; method is being added to the &lt;code&gt;foobar&lt;/code&gt;&#xA;singleton class.&lt;/p&gt;&#xA;&lt;h3 id=&#34;evaluating-code-in-the-context-of-an-object&#34;&gt;Evaluating Code in the Context of an Object&lt;/h3&gt;&#xA;&lt;p&gt;If you&amp;rsquo;ve made it this far it shouldn&amp;rsquo;t be shocking to see a singleton&#xA;class created when you define a method inside an &lt;code&gt;instance_eval&lt;/code&gt; call.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-ruby&#34; data-lang=&#34;ruby&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;foobar &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;[]&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;foobar&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;instance_eval &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;lt;&amp;lt;EOT&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&lt;/span&gt;  &lt;span style=&#34;color:#66d9ef&#34;&gt;def&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;foo&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Hello World!&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#66d9ef&#34;&gt;end&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;EOT&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;foobar&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;singleton_methods &lt;span style=&#34;color:#75715e&#34;&gt;# =&amp;gt; [&amp;#34;foo&amp;#34;]&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&#34;practical-uses-of-singleton-classes&#34;&gt;Practical Uses of Singleton Classes&lt;/h2&gt;&#xA;&lt;p&gt;Before you chalk this all up to useless black magic let&amp;rsquo;s tie&#xA;everything off with some practical examples.  Believe it or not, you&#xA;probably create singleton classes all the time.&lt;/p&gt;&#xA;&lt;h3 id=&#34;class-methods&#34;&gt;Class Methods&lt;/h3&gt;&#xA;&lt;p&gt;While some object oriented languages have class structures that&#xA;support both instance methods and class methods (sometimes called&#xA;static methods), Ruby only supports instance methods.  If Ruby only&#xA;supports instances methods where do all those class methods you&amp;rsquo;ve&#xA;been creating end up?  Why, the singleton class of course.&lt;/p&gt;&#xA;&lt;p&gt;This is possible because Ruby classes are actually objects&#xA;instantiated from the &lt;code&gt;Class&lt;/code&gt; class.  Their names are constants that&#xA;point to this object instantiated from the &lt;code&gt;Class&lt;/code&gt; class.  While this&#xA;object holds the instance methods for objects instantiated from it,&#xA;its so-called class methods are kept on a singleton class.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-ruby&#34; data-lang=&#34;ruby&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;class&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;Foo&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#66d9ef&#34;&gt;def&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;self&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;one&lt;/span&gt; () &lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;end&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#66d9ef&#34;&gt;class&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;&amp;lt;&amp;lt;&lt;/span&gt; self&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;def&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;two&lt;/span&gt; () &lt;span style=&#34;color:#ae81ff&#34;&gt;2&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;end&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#66d9ef&#34;&gt;end&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#66d9ef&#34;&gt;def&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;three&lt;/span&gt; () &lt;span style=&#34;color:#ae81ff&#34;&gt;3&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;end&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  self&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;singleton_methods &lt;span style=&#34;color:#75715e&#34;&gt;# =&amp;gt; [&amp;#34;two&amp;#34;, &amp;#34;one&amp;#34;]&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  self&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;class             &lt;span style=&#34;color:#75715e&#34;&gt;# =&amp;gt; Class&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  self                   &lt;span style=&#34;color:#75715e&#34;&gt;# =&amp;gt; Foo&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;end&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Two of the three methods defined in the code above are class methods,&#xA;and therefore go into a singleton class.  Left as an exercise for the&#xA;reader is the inheritance hierarchy for the object that the &lt;code&gt;Foo&lt;/code&gt;&#xA;constant references.&lt;/p&gt;&#xA;&lt;h3 id=&#34;test-mocking&#34;&gt;Test Mocking&lt;/h3&gt;&#xA;&lt;p&gt;Mocking is a popular testing technique that allows you to stub out&#xA;method calls for an object or class, forcing them to return a specific&#xA;value or ensuring that they are called a specific number of times.&#xA;While there are several good mocking libraries available for Ruby,&#xA;wouldn&amp;rsquo;t it be nice to know how they work?&lt;/p&gt;&#xA;&lt;p&gt;In the example below there is a &lt;code&gt;Foo&lt;/code&gt; class with two instance methods.&#xA;The &lt;code&gt;available?&lt;/code&gt; method is dependent on the results of the &lt;code&gt;status&lt;/code&gt;&#xA;method.  What do you do if you need to verify that the &lt;code&gt;available?&lt;/code&gt;&#xA;method works correctly given the varying results which the &lt;code&gt;status&lt;/code&gt;&#xA;method could return?  Mocking and singleton classes to the rescue.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-ruby&#34; data-lang=&#34;ruby&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;require &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;test/unit&amp;#39;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;class&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;Foo&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#66d9ef&#34;&gt;def&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;available?&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    status &lt;span style=&#34;color:#f92672&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#66d9ef&#34;&gt;end&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#66d9ef&#34;&gt;private&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#66d9ef&#34;&gt;def&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;status&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    rand(&lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#66d9ef&#34;&gt;end&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;end&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;class&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;FooTest&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;Test&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;::&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;Unit&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;::&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;TestCase&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#66d9ef&#34;&gt;def&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;setup&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    @foo &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;Foo&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;new&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#66d9ef&#34;&gt;end&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#66d9ef&#34;&gt;def&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;test_available_with_status_1&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;def&lt;/span&gt; @foo&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;status () &lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;end&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    assert(@foo&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;available?)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#66d9ef&#34;&gt;end&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#66d9ef&#34;&gt;def&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;test_available_with_status_0&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;def&lt;/span&gt; @foo&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;status () &lt;span style=&#34;color:#ae81ff&#34;&gt;0&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;end&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    assert(&lt;span style=&#34;color:#f92672&#34;&gt;!&lt;/span&gt;@foo&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;available?)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#66d9ef&#34;&gt;end&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;end&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&#34;conclusion&#34;&gt;Conclusion&lt;/h2&gt;&#xA;&lt;p&gt;Understanding the advanced aspects of the Ruby programming language&#xA;need not be difficult.  Hopefully singleton classes make a lot more&#xA;sense to you now and even seem somewhat useful.  You may have missed&#xA;it but hiding in the text above is also a rather shallow examination&#xA;of the object system that Ruby employs.&lt;/p&gt;&#xA;&lt;p&gt;I recommend that you continue your journey in that direction.  Hint:&#xA;see if your local library has a book on Smalltalk.&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>Behind the code: project planning</title>
      <link>https://freerangebits.com/posts/2008/07/project-planning/</link>
      <pubDate>Thu, 24 Jul 2008 00:00:00 -0700</pubDate>
      <guid>https://freerangebits.com/posts/2008/07/project-planning/</guid>
      <description>&lt;p&gt;In this new series of articles, Behind the Code, I&amp;rsquo;ll be looking at&#xA;the tools and processes that I&amp;rsquo;ve put into place to make me a more&#xA;efficient and effective developer.  I&amp;rsquo;m hoping to share my&#xA;experiences, and while doing that, refine the way I work using your&#xA;feedback.&lt;/p&gt;&#xA;&lt;p&gt;Today, I&amp;rsquo;ll be talking about project planning, the process of breaking&#xA;a project into tasks, and estimating the effort to complete those&#xA;tasks.  The artifacts generated during this process can then be used&#xA;to create a proposal for a client, cost estimations for your boss, or&#xA;even the start of your project documentation.&lt;/p&gt;&#xA;&lt;h2 id=&#34;file-formats-and-tools-matter&#34;&gt;File Formats and Tools Matter&lt;/h2&gt;&#xA;&lt;p&gt;If there&amp;rsquo;s one thing I&amp;rsquo;ve definitely learned the hard way, it&amp;rsquo;s that&#xA;the tools I use today aren&amp;rsquo;t necessarily the tools I&amp;rsquo;ll be using&#xA;tomorrow.  A better tool might come along, or I might be forced to use&#xA;another operating system where my preferred tools aren&amp;rsquo;t available.&lt;/p&gt;&#xA;&lt;p&gt;I avoid binary proprietary file formats like used car salesmen.  It&amp;rsquo;s&#xA;so important to me that it&amp;rsquo;s my first rule:&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Rule 1: Use plain text files when possible.&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;No matter which platform you&amp;rsquo;re using, you can read and work with text&#xA;files.  If you happen to use a platform with good command line&#xA;tools (anything Unix based), you have a powerful system available for&#xA;finding, searching, and transforming text files.&lt;/p&gt;&#xA;&lt;p&gt;Text files rock, and what&amp;rsquo;s the best tool to edit them?  Being a&#xA;developer, using a text editor shouldn&amp;rsquo;t be unfamiliar to you.  As a&#xA;matter of fact, it should be the tool that you&amp;rsquo;re most comfortable and&#xA;efficient with.  If there&amp;rsquo;s only one thing you can call yourself an&#xA;expert in, it should be in using your text editor.&lt;/p&gt;&#xA;&lt;h2 id=&#34;tools-for-project-planning&#34;&gt;Tools for Project Planning&lt;/h2&gt;&#xA;&lt;p&gt;There are several tools you can use to do project planning, all while&#xA;working with nothing more than plain text files.  My tool of choice is&#xA;&lt;a href=&#34;http://www.gnu.org/software/emacs/&#34; target=&#34;_blank&#34;&gt;Emacs&lt;/a&gt;, using the amazing &lt;a href=&#34;http://orgmode.org/&#34; target=&#34;_blank&#34;&gt;Org-Mode&lt;/a&gt; package.&lt;/p&gt;&#xA;&lt;p&gt;The tools that you pick will depend completely on you.  In this case,&#xA;the process is slightly more important than the tools.  Don&amp;rsquo;t get me&#xA;wrong though, a good tool can make a big difference in your workflow.&lt;/p&gt;&#xA;&lt;p&gt;I like &lt;a href=&#34;http://orgmode.org/&#34; target=&#34;_blank&#34;&gt;Org-Mode&lt;/a&gt; because it provides a lot of functionally, yet at&#xA;the end of the day everything is just plain text.  I can easily keep&#xA;my project files in a &lt;a href=&#34;http://git.or.cz/&#34; target=&#34;_blank&#34;&gt;revision control system&lt;/a&gt;, and use tools&#xA;like &lt;a href=&#34;http://www.ruby-lang.org&#34; target=&#34;_blank&#34;&gt;Ruby&lt;/a&gt; and &lt;a href=&#34;http://www.FreeBSD.org/cgi/man.cgi?query=grep&amp;amp;apropos=0&amp;amp;sektion=0&amp;amp;manpath=FreeBSD&amp;#43;7.0-RELEASE&amp;amp;format=html&#34; target=&#34;_blank&#34;&gt;grep&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;h2 id=&#34;breaking-a-project-into-features-and-tasks&#34;&gt;Breaking a Project Into Features and Tasks&lt;/h2&gt;&#xA;&lt;p&gt;The first step for planning a project is breaking it into smaller&#xA;pieces.  I like to create a shallow hierarchy, where I break a project&#xA;into features, and then take those features and break them down into&#xA;tasks.&lt;/p&gt;&#xA;&lt;p&gt;Features are usually the bigger chunks that your client or boss would&#xA;know by name.  Since features are big chucks, you can&amp;rsquo;t estimate them&#xA;correctly, or think clearly about their dependencies without breaking&#xA;them down further.&lt;/p&gt;&#xA;&lt;p&gt;By breaking a feature down into tasks, you virtually walk though the&#xA;implementation of that feature, thinking about dependencies and&#xA;potential problems that you&amp;rsquo;ll have along the way.&lt;/p&gt;&#xA;&lt;p&gt;While breaking a project into features and tasks, don&amp;rsquo;t think about&#xA;time estimates, &lt;em&gt;only process&lt;/em&gt;.  Work through the steps you would&#xA;actually perform to implement a feature in your mind, recording them&#xA;in your project plan as tasks.&lt;/p&gt;&#xA;&lt;p&gt;Below is screenshot from Emacs, showing the outline I&amp;rsquo;ve created for&#xA;a fictional social networking application.  Org-Mode allows me to fold&#xA;the outline at any level.  Here I&amp;rsquo;m viewing just the outline headings&#xA;that show two features, broken down into tasks.&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&#34;folded.jpg&#34; alt=&#34;Folded&#34;&gt;&lt;/p&gt;&#xA;&lt;p&gt;While I&amp;rsquo;m creating the feature and task breakdown, I leave myself&#xA;little notes just in case the headings are too vague and a few weeks&#xA;later I&amp;rsquo;m not sure what the hell I was talking about.&lt;/p&gt;&#xA;&lt;p&gt;Below is a fully expanded version of the outline from above, so you&#xA;can see the notes.  Later, these notes can be expanded and used as&#xA;project documentation or a client proposal.&lt;/p&gt;&#xA;&lt;p&gt;In Org-Mode, the tab key is used to expand or fold an outline.  This&#xA;makes it very easy to see just the part of the project plan that&#xA;you&amp;rsquo;re interested in.&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&#34;expanded.jpg&#34; alt=&#34;Expanded&#34;&gt;&lt;/p&gt;&#xA;&lt;h2 id=&#34;estimating-the-tasks&#34;&gt;Estimating the Tasks&lt;/h2&gt;&#xA;&lt;p&gt;As I mentioned before, a feature by itself is too vague to estimate.&#xA;But now that you&amp;rsquo;ve broken each of the features down into tasks, you&#xA;should have enough information to estimate the effort of actually&#xA;implementing those features.&lt;/p&gt;&#xA;&lt;p&gt;I&amp;rsquo;m not going to dive too deeply into the art of estimating in this&#xA;article.  That said, put your estimating cap on and let&amp;rsquo;s get to it.&lt;/p&gt;&#xA;&lt;p&gt;The best way to estimate your tasks is to begin with the first task,&#xA;and work through them one at a time.  I prefer to break my tasks down&#xA;into hours and minutes, usually in 30-minute increments.&lt;/p&gt;&#xA;&lt;p&gt;If you come across a task that will take more than a workday to&#xA;complete, you need to break the task down into more tasks.  It&amp;rsquo;s&#xA;important that your tasks are granular enough, I personally don&amp;rsquo;t like&#xA;my tasks to take more than 5-hours.  Along the same lines, any task&#xA;that takes less than 30-minutes, however, should be reviewed to ensure&#xA;it has been thought through enough.&lt;/p&gt;&#xA;&lt;p&gt;Below is a screenshot showing estimates assigned to each task.  I like&#xA;to switch Org-Mode into column view.  Org-Mode makes it easy to see&#xA;summations of task estimates using its handy column view mode, which&#xA;turns your hierarchical outline into a table.&lt;/p&gt;&#xA;&lt;p&gt;In this screenshot, I&amp;rsquo;ve assigned estimates to each task.  The&#xA;features now show the total estimates for their respective tasks,&#xA;leaving the top headline (the project name) with a total estimate for&#xA;the project.  Org-Mode automatically summed the time estimates for me,&#xA;I only assigned estimates to the tasks themselves (in purple below).&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&#34;columns.jpg&#34; alt=&#34;Columns&#34;&gt;&lt;/p&gt;&#xA;&lt;h2 id=&#34;presenting-the-project-plan&#34;&gt;Presenting the Project Plan&lt;/h2&gt;&#xA;&lt;p&gt;With your task estimates completed, you&amp;rsquo;ve collected enough&#xA;information to present a proposal to a client, or a project plan to&#xA;your boss.&lt;/p&gt;&#xA;&lt;p&gt;If you&amp;rsquo;ve been using a software tool to create your project plan, it&#xA;probably has an export feature.  Org-Mode can export your document to&#xA;HTML, LaTeX, and even a cleaned up ASCII text file.&lt;/p&gt;&#xA;&lt;p&gt;Even if you&amp;rsquo;re not using a tool with an export feature, you&amp;rsquo;re a&#xA;software developer right?  Write a script that will transform your&#xA;text file to something useful for your situation.&lt;/p&gt;&#xA;&lt;p&gt;As an example of a client proposal, I&amp;rsquo;ve exported the project file&#xA;into a cleaner &lt;a href=&#34;project-planning.pdf&#34;&gt;PDF file&lt;/a&gt; for my fictional client.  If&#xA;this were a real proposal, I would add additional notes, along with&#xA;details about the cost of the implementation.&lt;/p&gt;&#xA;&lt;h2 id=&#34;using-the-project-plan-during-implementation&#34;&gt;Using the Project Plan During Implementation&lt;/h2&gt;&#xA;&lt;p&gt;Why do all the work of creating a proposal, only to let it collect&#xA;dust?  When it comes time to implement the features that you created a&#xA;spec for, why not turn them into a to-do list?&lt;/p&gt;&#xA;&lt;p&gt;Using the Org-Mode ability to manage to-do lists, I turned the&#xA;estimated tasks into to-do items.  With Org-Mode I can &amp;ldquo;clock in&amp;rdquo; to a&#xA;task, which starts a timer.  When a task is complete, I mark it as&#xA;being done, and then I can compare the time I spent working to my&#xA;estimates.&lt;/p&gt;&#xA;&lt;p&gt;Below is a screenshot where I&amp;rsquo;ve completely expanded a finished task&#xA;so that you can see the meta-data that Org-Mode was adding to it when&#xA;I used the timer on a task and then marked it as complete.  You can&#xA;also see how a headline can be turned into a to-do item.&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&#34;tasks.jpg&#34; alt=&#34;Tasks&#34;&gt;&lt;/p&gt;&#xA;&lt;p&gt;It&amp;rsquo;s much more useful to switch back into column view for the&#xA;comparisons between my estimates and the clocked time.  The below&#xA;screenshot shows my outline back in column view, this time also&#xA;showing clock time summaries.&lt;/p&gt;&#xA;&lt;p&gt;This is a good example of how Org-Mode can collect the meta-data in&#xA;your text file and then present it to you in a more efficient way.&#xA;You can even edit the data in this table-like view, and Org-Mode will&#xA;do the right thing.&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&#34;clocked.jpg&#34; alt=&#34;Clocked&#34;&gt;&lt;/p&gt;&#xA;&lt;p&gt;In addition to column view, Org-Mode has several ways to generate&#xA;reports from your data.  I especially like the agenda view.&lt;/p&gt;&#xA;&lt;p&gt;With the agenda view, you can see which tasks you&amp;rsquo;ve scheduled for&#xA;specific days.  I find it very useful to spend a little bit of time at&#xA;the end of my day, and schedule which tasks I&amp;rsquo;ll be working on for the&#xA;following day.&lt;/p&gt;&#xA;&lt;p&gt;In the morning, I can review my agenda and start working with a clear&#xA;idea of what I should be doing.  This really helps with any tendency&#xA;to stall or procrastinate during the first hours of the day.&lt;/p&gt;&#xA;&lt;h2 id=&#34;article-artifacts-and-further-reading&#34;&gt;Article Artifacts and Further Reading&lt;/h2&gt;&#xA;&lt;p&gt;I chose to show screenshots above so you could get a feel for how a&#xA;good tool like Org-Mode can provide a nice interface for project&#xA;planning.  The nice thing about Org-Mode is that you&amp;rsquo;re just working&#xA;with a text file, and if you open that file in any other text editor,&#xA;it doesn&amp;rsquo;t look foreign.&lt;/p&gt;&#xA;&lt;p&gt;Below are links to files I created while writing this article.  Open&#xA;the project plan in your favorite text editor and compare it to the&#xA;screenshots above.  Try opening it in Emacs and see what happens.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&#34;project-planning.org&#34;&gt;The Plain Text Org-Mode File&lt;/a&gt; (Project File)&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;project-planning.pdf&#34;&gt;A PDF Client Proposal&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;If you&amp;rsquo;re looking for more information about Org-Mode, the main web&#xA;site is a great resource.  There is a fantastic manual, and a very&#xA;responsive mailing list if you have any questions.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&#34;http://orgmode.org&#34; target=&#34;_blank&#34;&gt;Org-Mode Web Site&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;http://www.youtube.com/watch?v=oJTwQvgfgMM&#34; target=&#34;_blank&#34;&gt;Org-Mode GoogleTalk&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;</description>
    </item>
  </channel>
</rss>
