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

<channel>
	<title>Incredible Vehicle</title>
	<atom:link href="http://incrediblevehicle.com/feed/" rel="self" type="application/rss+xml" />
	<link>https://incrediblevehicle.com</link>
	<description>(It&#039;s a blog.)</description>
	<lastBuildDate>Fri, 27 Apr 2012 03:50:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Learn Me a Haskell</title>
		<link>https://incrediblevehicle.com/2012/04/26/learn-me-a-haskell/</link>
		<comments>https://incrediblevehicle.com/2012/04/26/learn-me-a-haskell/#comments</comments>
		<pubDate>Fri, 27 Apr 2012 03:50:37 +0000</pubDate>
		<dc:creator>Matthew</dc:creator>
				<category><![CDATA[Coding]]></category>

		<guid isPermaLink="false">http://incrediblevehicle.com/?p=1135</guid>
		<description><![CDATA[I&#8217;ve been wanting for some time to delve into functional programming (FP). As I&#8217;m sure I&#8217;ve said eleventy-billion-and-one times, I got a taste of some FP patterns in Ruby and JavaScript, and Python to a lesser extent. Well, now I have: I&#8217;ve been reading Learn You a Haskell for Great Good!. Rationale The fewer lines [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been wanting for some time to delve into functional programming (FP). As I&#8217;m sure I&#8217;ve said eleventy-billion-and-one times, I got a taste of some FP patterns in Ruby and JavaScript, and Python to a lesser extent. Well, now I have: I&#8217;ve been reading <a href="http://learnyouahaskell.com/">Learn You a Haskell for Great Good!</a>.</p>

<p><span id="more-1135"></span></p>

<h3>Rationale</h3>

<p>The fewer lines of code there are, the fewer bugs you&#8217;re likely to have. Generally, if you can say a lot with fewer words, without loss of precision or intelligibility, it&#8217;s a good idea. It&#8217;s also a good idea to push complexity down by using language features or standard libraries to do the heavy lifting for you.</p>

<p>What I find attractive about functional programming patterns like higher order functions is that it allows you to push some of the complexity downward, into the language or standard libraries, without losing expressiveness. You can say more with fewer words. If we want to accumulate a list of even numbers between 1 and 20 in Java, it ends up looking something like this:</p>


<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">List<span style="color: #339933;">&lt;</span>Foo<span style="color: #339933;">&gt;</span> fooList <span style="color: #339933;">=</span> getFooList<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
List<span style="color: #339933;">&lt;</span>Foo<span style="color: #339933;">&gt;</span> fooBarList <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> List<span style="color: #339933;">&lt;</span>Foo<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>Foo f <span style="color: #339933;">:</span> fooList<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>f.<span style="color: #006633;">hasBar</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    fooBarList.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>f<span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>


<p>This example is a bit contrived, but not terribly so. Filtering a list of items is relatively common, and despite that, this has a lot of lines for such a simple, common operation.</p>

<p>Lest it seem like I&#8217;m picking on Java, I&#8217;ll show you a rough equivalent in Go:</p>


<div class="wp_syntax"><div class="code"><pre class="golang" style="font-family:monospace;">fooList := getFooList()
var fooBars []Foo
for _, f := range fooList {
  if (f.HasBar()) {
    fooBars = append(fooBars, f)
  }
}</pre></div></div>


<p>We have less boilerplate in terms of declaring variable types, but it&#8217;s still a lot of lines for filtering a list on a simple boolean test.</p>

<p>I pick on Python a lot, but this is extremely simple in Python:</p>


<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">foos = GetFooList<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
foo_bars = <span style="color: black;">&#91;</span>f <span style="color: #ff7700;font-weight:bold;">for</span> f <span style="color: #ff7700;font-weight:bold;">in</span> foos <span style="color: #ff7700;font-weight:bold;">if</span> f.<span style="color: black;">HasBar</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#93;</span></pre></div></div>


<p>This, I would say, is a nearly perfect ratio of lines-to-operations. You could even replace <code>foo_list</code> with <code>GetFooList()</code>, but let&#8217;s not get carried away. Ruby takes this even further and provides a number of similar patterns for the <a href="http://www.ruby-doc.org/core-1.9.3/Array.html">Array</a> class.</p>

<p>I know this is crazy talk, but I think this is extremely powerful. You can express your intent very clearly in fewer lines. Your readers (yes, readers) are free to focus on <strong>what</strong> you are doing instead of <strong>how</strong>.</p>

<p>If you read about FP, you&#8217;ll also hear a lot about state. The notion is that if you&#8217;ve got methods attached to a class, the state of that class is implicit input to any given method. Coming from a testing perspective, I believe this makes a class harder to unit test. Sometimes you must store state, obviously, but in general a method which has explicit inputs and outputs is easier to test. (I suppose this is also applicable to trying to reason about what a method does mathematically.)</p>

<p>What was sort of revelatory to me is that, actually, a lack of mutable state isn&#8217;t so crazy (h/t <a href="http://www.youtube.com/watch?v=b9FagOVqxmI">Haskell Amuse-Bouche</a>). If you&#8217;ve used *nix for getting work done, you&#8217;ve probably done something like this:</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-o</span> <span style="color: #ff0000;">'foo.*bar'</span> ~<span style="color: #000000; font-weight: bold;">/</span>baz <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $1}'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sort</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">uniq</span> <span style="color: #660033;">-c</span></pre></div></div>


<p>None of those are actually changing any state. You&#8217;re just filtering input. If you take the above — avoid state, give functions explicit input/output — to a reasonable conclusion, what you end up with is a glorified pipeline like what you see above. And this is one of the ideas behind Haskell.</p>

<h3>A simple example and then done</h3>

<p>In Haskell, you can compose a series of functions pretty easily, like this:</p>


<div class="wp_syntax"><div class="code"><pre class="haskell" style="font-family:monospace;"><span style="font-weight: bold;">map</span> <span style="color: green;">&#40;</span><span style="font-weight: bold;">negate</span> <span style="color: #339933; font-weight: bold;">.</span> <span style="font-weight: bold;">abs</span><span style="color: green;">&#41;</span> <span style="color: green;">&#91;</span><span style="color: red;">5</span><span style="color: #339933; font-weight: bold;">,-</span><span style="color: red;">3</span><span style="color: #339933; font-weight: bold;">,-</span><span style="color: red;">6</span><span style="color: #339933; font-weight: bold;">,</span><span style="color: red;">7</span><span style="color: #339933; font-weight: bold;">,-</span><span style="color: red;">3</span><span style="color: #339933; font-weight: bold;">,</span><span style="color: red;">2</span><span style="color: #339933; font-weight: bold;">,-</span><span style="color: red;">19</span><span style="color: #339933; font-weight: bold;">,</span><span style="color: red;">24</span><span style="color: green;">&#93;</span></pre></div></div>


<p>It&#8217;s a slightly goofy <a href="http://learnyouahaskell.com/higher-order-functions#composition">math example</a> ripped off from Learn You a Haskell, but you get the idea. We chain together functions <code>negate</code> and <code>abs</code> as one function, and then map that onto the following list.</p>

<p>The concision here is impressive, although I find &#8220;real&#8221; Haskell considerably more difficult to read so far. Haskell programmers are very fond of one-letter variables and the syntax itself is so expressive in part because it is so concise. If you can decode it, it starts to become beautiful, but it&#8217;s that decoding part I still struggle with.</p>

<p>As I delve more into Haskell, I&#8217;ll probably blog about it. This is enough for now, though.</p>
]]></content:encoded>
			<wfw:commentRss>https://incrediblevehicle.com/2012/04/26/learn-me-a-haskell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Productivity</title>
		<link>https://incrediblevehicle.com/2012/04/25/productivity/</link>
		<comments>https://incrediblevehicle.com/2012/04/25/productivity/#comments</comments>
		<pubDate>Thu, 26 Apr 2012 05:19:57 +0000</pubDate>
		<dc:creator>Matthew</dc:creator>
				<category><![CDATA[Coding]]></category>

		<guid isPermaLink="false">http://incrediblevehicle.com/?p=1082</guid>
		<description><![CDATA[So what languages do I think offer the best prospects for high-productivity coding buttressed by strong typing? Maybe it says something about what my opinion is worth that I&#8217;m not so sure about one of the two languages I was putting forward. Still, this is as good as time as any to talk about the [...]]]></description>
			<content:encoded><![CDATA[<p>So what languages do I think offer the best prospects for high-productivity coding buttressed by strong typing? Maybe it says something about what my opinion is worth that I&#8217;m not so sure about one of the two languages I was putting forward.</p>

<p>Still, this is as good as time as any to talk about the first one. Lately I&#8217;ve spent some time with <a href="http://www.golang.org/">the Go programming language</a>.</p>

<h3>Go</h3>

<p>If I had to sum up Go in my own words, I&#8217;d call it the spiritual successor to C, with modern sensibilities. It has concise and lightweight syntax. It&#8217;s memory safe (read: garbage-collected) and strongly typed. It has powerful concurrency primitives at the language level. It has a unique approach to interfaces where they are actually orthogonal to data types, not unlike Haskell&#8217;s typeclasses. It has first class functions and lexical closures. And it has a rich standard library.</p>

<p>Although Go doesn&#8217;t ship with a REPL or interpreter, there are some <a href="https://bitbucket.org/binet/igo">projects</a> <a href="https://github.com/vito/go-repl">out</a> <a href="https://github.com/mattn/yet-another-go-repl">there</a>. However, there&#8217;s also <a href="">http://play.golang.org/</a>. As far as I&#8217;m concerned, this is close enough to a REPL that I&#8217;ve found it extremely useful for prototyping, testing out a package from the Go standard library, and I&#8217;ve even written code I&#8217;ve ended up keeping later.</p>

<p>Go threads the needle between providing a strongly typed language which is more productive than C++ and orders of magnitude less verbose and clunky than Java. It&#8217;s more performant than your average scripting language, yet the standard library is just as rich and easy to use. I would probably not go back to Python except for ~100 line helpers, or glue code which is just above shell scripts in terms of complexity.</p>

<p>It&#8217;s tough to pick good examples for some rough comparison that aren&#8217;t already covered in the Go docs. But here&#8217;s one of my hobby-horses, something which is easy in some scripting languages.</p>

<h3>Processing command output</h3>

<p>This is trivially easy in shell scripts, and shell scripts were made for processing text. Perl makes it approximately as easy, and as Ruby borrows so much from Perl, it&#8217;s similarly easy.</p>

<p>In Python 2.x, <a href="http://incrediblevehicle.com/2011/08/31/python-python-python/">it&#8217;s terrible</a>. I&#8217;d rather not write this in C++ or Java.</p>

<p>Here&#8217;s how you run a simple command in Go and capture its output:</p>

<pre><code>// exec lives under the os/exec package
out, err := exec.Command("foo", "--bar", "baz").Output()
</code></pre>

<p><code>out</code> is the output, an array of bytes. You&#8217;ll want to split it in lines and iterate over it, treating it as (say) an id and a username along with it.</p>

<pre><code>lines := bytes.Split(out, '\n')
for _, line := range lines {
  // Split by spaces.
  fields := bytes.Fields(line)
  fmt.Println("id is %v. username is %v.", fields[0], fields[1])
}
</code></pre>

<p>Notice the lack of type declarations. Most of the time you use <code>:=</code> to declare and initialize at once, which ends up feeling a lot like Python or Ruby. The difference is that the Go compiler infers types based on return values and the like, granting the benefit of type checking.</p>

<h3>Further reading</h3>

<p>I could come up with more examples. I&#8217;m trying not to! That&#8217;s because you&#8217;re better off playing with something like <a href="http://tour.golang.org/">the Go tour</a>. Trust me: you might think it a bit silly at first, but there are exercises and the app will test your solution. It&#8217;s very good.</p>

<p>The Go site is rather good, as well. There&#8217;s [a Go tutorial] wherein you write a wiki which is worth your time. You should read <a href="http://golang.org/doc/effective_go.html">Effective Go</a> if you&#8217;ve decided you&#8217;re actually serious about it.</p>
]]></content:encoded>
			<wfw:commentRss>https://incrediblevehicle.com/2012/04/25/productivity/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sublime Text 2</title>
		<link>https://incrediblevehicle.com/2012/04/21/sublime-text-2/</link>
		<comments>https://incrediblevehicle.com/2012/04/21/sublime-text-2/#comments</comments>
		<pubDate>Sat, 21 Apr 2012 17:04:52 +0000</pubDate>
		<dc:creator>Matthew</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[st2]]></category>
		<category><![CDATA[sublimetext2]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://incrediblevehicle.com/?p=1112</guid>
		<description><![CDATA[Today I took a relatively big step in terms of my coding workflow. I purchased a license for Sublime Text 2 and immediately began using it as my full-time code editor. Advantages Vim keybindings for 70% &#8211; 90% of the commands I use (e.g. ci(, marks, :w) Find in files Cmd-R to jump to a [...]]]></description>
			<content:encoded><![CDATA[<p>Today I took a relatively big step in terms of my coding workflow. I purchased a license for <a href="http://www.sublimetext.com/">Sublime Text 2</a> and immediately began using it as my full-time code editor.</p>

<p><span id="more-1112"></span></p>

<h3>Advantages</h3>

<ul>
<li>Vim keybindings for 70% &#8211; 90% of the commands I use (e.g. <code>ci(</code>, marks, <code>:w</code>)</li>
<li>Find in files</li>
<li>Cmd-R to jump to a symbol</li>
<li>Command-T-style fuzzy completion of filenames via Cmd-P</li>
<li>Projects (i.e. a list of files spread across disparate dirs accessible via Cmd-P)</li>
<li>Menu commands executable through Cmd-Shift-P, complete with fuzzy matching</li>
<li>A sensible configuration &amp; plugin language</li>
<li>Fast. Buttery smooth.</li>
<li>Linux AND Mac compatibility</li>
<li>One license, all of your machines</li>
</ul>

<p>It&#8217;s not that Vim can&#8217;t do most of this stuff (modulo the sensible configuration language). It&#8217;s that all of the above <em>works out of the box</em>. There&#8217;s a litany of things that I&#8217;ve just never quite gotten to work right. For instance, CommandT worked for a while and then broke. I don&#8217;t mean to pick on anybody. But this was not uncommon.</p>

<p>That was perhaps the single biggest reason that I switched.</p>

<p>At another point, I was trying to fix bugs in a dozen or so Python scripts, themselves scattered across three or more different subdirectories at various depths. In ST2, I added all three dirs to my project, and I bounced between them with Cmd-P quickly and easily. It just worked. And it&#8217;s <em>fast</em>. It breaks my heart to say it but Vim felt positively medieval in comparison.</p>

<p>I also look forward to learning how to write plugins. I&#8217;ve never been able to convince myself to learn Vim&#8217;s scripting language.</p>

<p>There are some disadvantages worth mentioning.</p>

<h3>Disadvantages</h3>

<ol>
<li>Split-pane isn&#8217;t as good as Vim</li>
<li>Inaccessible via the Terminal</li>
<li>Not libre or gratis</li>
<li>I may run into cognitive dissonance wrt Vim bindings</li>
</ol>

<p>With ST2, you have to switch between a canned set of layouts rather than being able to ad-hoc split pane. With Vim, I have anywhere from 3 &#8211; 5 panes open, and with <code>^W</code> and some handy <code>\ew</code> aliases (edit file in same working dir as this file), it&#8217;s mostly muscle memory.</p>

<p>I can&#8217;t use ST2 in the Terminal, which means I&#8217;ll have to fallback to Vim. That&#8217;s not the end of the world, but it is inconvenient.</p>

<p>I hesitated for weeks, having taken it for a test drive for some of the toying around I&#8217;ve done with <a href="http://golang.org">Go</a>. But it wasn&#8217;t about FOSS. It was about the price. Why pay for a text editor when there are N free ones available?</p>

<p>That said, I am willing to pay a little bit of money to get the job done. (Shit, if time is money, it&#8217;s already saved me a ton of time.) And I know that I&#8217;m supporting a small and independent developer. I want to live in a world where people can make money off of developing kick-ass software.</p>

<p>Vintage (the plugin for ST2 which adds Vim keybindings) does have some limitations. <code></code> &#8220;, double grave, doesn&#8217;t work right. <code>g;</code> and <code>g,</code> don&#8217;t work. I&#8217;m sure I&#8217;ll run across more.</p>

<h3>Conclusion</h3>

<p>It&#8217;s been some weeks since I switched, and I haven&#8217;t really looked back. If you&#8217;ve got the dough and you&#8217;re looking for an editor that&#8217;ll help you step your game up, I recommend you check out Sublime Text 2. As I said, it&#8217;s a free trial.</p>
]]></content:encoded>
			<wfw:commentRss>https://incrediblevehicle.com/2012/04/21/sublime-text-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>In search of productivity</title>
		<link>https://incrediblevehicle.com/2012/02/18/in-search-of-productivity/</link>
		<comments>https://incrediblevehicle.com/2012/02/18/in-search-of-productivity/#comments</comments>
		<pubDate>Sat, 18 Feb 2012 23:20:11 +0000</pubDate>
		<dc:creator>Matthew</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[c]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://incrediblevehicle.com/?p=1055</guid>
		<description><![CDATA[Once upon a time, I started to learn programming in C++. It turns out that it&#8217;s hard (for some value of &#8220;hard&#8221;) to do a lot of basic things in C++. As a budding programmer, I spent more time struggling to make myself understood to the compiler than writing code. When I was introduced to [...]]]></description>
			<content:encoded><![CDATA[<p>Once upon a time, I started to learn programming in C++. It turns out that it&#8217;s hard (for some value of &#8220;hard&#8221;) to do a lot of basic things in C++. As a budding programmer, I spent more time struggling to make myself understood to the compiler than writing code.</p>

<p>When I was introduced to Python, suddenly programming was fun again. It was hard to imagine going back to anything like C++ when I could become so productive so quickly with Python.</p>

<p>I held to this view for a very, very long time. I appreciated how languages like C++ or Java would be useful for writing &#8220;serious&#8221; applications, but I didn&#8217;t write that stuff. That was for other people.</p>

<p>In the last year or so, I&#8217;ve gradually come to believe that a strong type-checking system AND a high-productivity language ought not and are not mutually exclusive. The corollary is that I will consider carefully before I use a scripting language for anything more than a thousand or so lines.</p>

<p><span id="more-1055"></span></p>

<h3>The first sign of trouble</h3>

<p>The first time I ran into serious trouble with a scripting language was a few years ago (yikes). I wrote a script in Python which would monitor some servers for updated software and kick off a job when they were updated. It was less than 1000 lines, but despite knowing better, I did a poor job keeping it clean. And because it was such a mess, of course I had no tests.</p>

<p>Without unit tests, I had to test it manually. The cycle was something like: write a bunch of code, and run the whole dang script. This was time-consuming and error-prone. I&#8217;d miss things. Basic things. The script itself wasn&#8217;t mission critical but I found these bugs and the script itself personally embarrassing; I knew better, and I knew I knew better.</p>

<p>Still, I was otherwise quite productive in Python. Around the same time, using the Django framework, I wrote a server which slurped XML-formatted test results and allowed the user to view results grouped by various properties. It was very fast to write, and I could hardly imagine doing it in C++ or Java.</p>

<p>I had three experiences in the last year or two which rearranged my prejudices.</p>

<h3>JavaScript and the Closure Compiler</h3>

<p>The first was working in JavaScript land, with the <a href="http://code.google.com/closure/compiler/">Closure Compiler</a>. JavaScript was far less restrictive and, in my opinion, more expressive than Java. The compiler caught some of my dumb mistakes and I grudgingly came to value it. However, it didn&#8217;t catch all of my mistakes and the ones that it did not catch were sometimes difficult to track down.</p>

<p>The lesson I learned was that even the slightest type-checking can really help save you from yourself. It also makes refactoring (and thus maintenance) easier; adding or removing a parameter, or passing in the wrong type can be difficult to debug in a language like JavaScript.</p>

<h3>Java</h3>

<p>The second was working in Java land. I wrote a framework which would test a remote API. I had to do a lot of fighting with the language, with a lot of boilerplate and book-keeping. I missed closures and first class functions dearly; contrary to what I thought at first, Java does have a very limited form of closures, in the form of anonymous inner classes. The lengths I had to go to get certain pieces working was comical; at one point, I wrote a <a href="http://incrediblevehicle.com/2011/07/25/java-me/">FactoryFactory</a>. I&#8217;m not kidding! And I&#8217;m not proud of it, but the language and API I was using drove me to it.</p>

<p>However, up to this point in my career, I don&#8217;t think I&#8217;d spent as much time with a decent IDE on an extended project. Several aspects were revelatory. I&#8217;ll mention two.</p>

<p>1) The type system gave me substantially more confidence that I was doing the right thing most of the time. I spent more time fixing incorrect assumptions about the API, adding error-recovery, or simply writing code than chasing down basic mistakes. I do that in any language, but the difference here was that the IDE and language eliminated an entire class of mistakes <em>as I introduced them</em>. By the time I ran my program, I had substantially more confidence about its correctness than I ever did in Python.</p>

<p>2) If you haven&#8217;t yet, read Martin Fowler&#8217;s <a href="http://www.amazon.com/gp/product/0201485672/ref=as_li_ss_tl?ie=UTF8&amp;tag=incredvehicl-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0201485672">Refactoring</a>. The short version is that there are a set of highly mechanical techniques you can use to facilitate refactoring. Furthermore, many Java IDEs support many of these operations. Even something as basic as renaming method calls or variables within a specific context is massively more helpful than dumb S&amp;R.</p>

<h3>Lest I seem insane</h3>

<p>Despite all that, I still wouldn&#8217;t program in Java again by choice. I want closures. I want first class functions. I want built-in higher order functions, for that matter. I want syntax and/or a syntactic paradigm (think variables or methods like fooByBarWithBazAsQuux) that&#8217;s substantially less verbose.</p>

<p>It&#8217;s the difference between</p>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">numbers = <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">1</span>, <span style="color:#006666;">2</span>, <span style="color:#006666;">3</span>, <span style="color:#006666;">4</span>, <span style="color:#006666;">5</span>, <span style="color:#006666;">6</span><span style="color:#006600; font-weight:bold;">&#93;</span>
evens = numbers.<span style="color:#CC0066; font-weight:bold;">select</span> <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>x<span style="color:#006600; font-weight:bold;">|</span> x <span style="color:#006600; font-weight:bold;">%</span> <span style="color:#006666;">2</span> == <span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">&#125;</span></pre></div></div>


<p>and</p>


<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// I'm sure this is still invalid for many reasons.</span>
ArrayList<span style="color: #339933;">&lt;</span>Integer<span style="color: #339933;">&gt;</span> intList <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ArrayList<span style="color: #339933;">&lt;</span>Integer<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">2</span>, <span style="color: #cc66cc;">3</span>, <span style="color: #cc66cc;">4</span>, <span style="color: #cc66cc;">5</span>, <span style="color: #cc66cc;">6</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
ArrayList<span style="color: #339933;">&lt;</span>Integer<span style="color: #339933;">&gt;</span> evenIntsList <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ArrayList<span style="color: #339933;">&lt;</span>Integer<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Integer</span> i <span style="color: #339933;">:</span> intList<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">%</span> <span style="color: #cc66cc;">2</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    evenIntsList.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>


<p>That? That up there? It hurts me inside. The compiler makes it harder for you to screw it up, but you still have to do the whole song and dance every. Single. Time. You spend ~6 lines on an operation which, in the grand scheme of your program, ought to be small and trivial.</p>

<h3>Python</h3>

<p>Speaking of Python, I started relatively recently on refactoring a set of Python scripts responsible for kicking off tests. Nobody owned these scripts and consequently they languished as multiple people had patched or hacked on them to fix bugs or add features. The scripts were a mess.</p>

<p>Furthermore, there are few thousand lines of these scripts, plus thousands of lines more in the form of libraries which the scripts use. There were and are tests, but obviously nobody ran them because they were all broken.</p>

<p>After having spent so much time in the Land of Type-checking, reality came rushing back. It scary to make changes without having any confidence that they were correct. I wrote tests to find basic mistakes which would not manifest until runtime.</p>

<p>I would say that this was the biggest shock and what did the most to change my views. A scripting language is very good for getting something running quickly, but in terms of refactoring and maintenance, it took two or three times as long as I thought it ought to.</p>

<h3>A word about tests</h3>

<p>You could make a strong case that the scenario above— writing tests to the point of boredom— is Working As Intended. I am strongly sympathetic to this idea.</p>

<p>You ought to write unit tests with good coverage no matter the language. Tools like <a href="https://github.com/gfxmonk/autonose">autonose</a> allow you to get feedback from those tests rather quickly. This workflow arguably gives you faster, more comprehensive feedback than one with just a compiler and manually run unit tests.</p>

<p>One hitch is that getting a good error message from a unit test requires an amount of diligence multiplied by the number of unit tests. A compiler does only catch a small subset of the problems a unit test would, but any decent one ought to catch them more reliably and precisely.</p>

<p>Anyway, I haven&#8217;t delved too much into larger-scale projects which are based on scripting languages, but my guess is that their approach is similar to this. Write testable code. Use frameworks which make it easy to write tests (with a nice DSL, flexible mocking, or what have you). Use frameworks which make it easy to run tests (such as speed and parallelism). Minimize the inherent friction and you&#8217;ll get something richer than a compiler alone would offer you.</p>

<h3>The answer?</h3>

<p>I&#8217;m still writing tests in Java. I&#8217;m still refactoring Python scripts. For obvious reasons it would be silly to introduce a new technology into an existing stack chiefly or even partially for my own personal satisfaction. Rewriting is a dubious proposition anyway, one that must be considered very carefully. So for practical reasons, the situation won&#8217;t change.</p>

<p>Even so, I still want to have some go-to language. What could I use for a new project, personal or otherwise which would have good odds of making me happy?</p>

<p>C++ is not memory safe. C is simpler than C++ but is also memory unsafe and has more trade-offs. In both C and C++, it can be very difficult to write basic functionality.</p>

<p>Java is memory safe and has a rich set of libraries, but as I&#8217;ve mentioned, I&#8217;m not interested.</p>

<p>So what&#8217;s the answer? What language or technology do I feel is most promising, offering a combination of strong typing and high productivity? I have one prospect, or even two. But I&#8217;ll save those for the next post.</p>
]]></content:encoded>
			<wfw:commentRss>https://incrediblevehicle.com/2012/02/18/in-search-of-productivity/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Late to the party: D&amp;D 5e</title>
		<link>https://incrediblevehicle.com/2012/02/01/1041/</link>
		<comments>https://incrediblevehicle.com/2012/02/01/1041/#comments</comments>
		<pubDate>Wed, 01 Feb 2012 16:00:22 +0000</pubDate>
		<dc:creator>Matthew</dc:creator>
				<category><![CDATA[Roleplaying]]></category>

		<guid isPermaLink="false">http://incrediblevehicle.com/?p=1041</guid>
		<description><![CDATA[Boy, have I been out of the loop. I guess Monte Cook has been back at Wizards for ~4 months? And he&#8217;s been writing a column? This makes sense, given that there&#8217;s now an announcement about this 5e playtest. Looking back on 4e, I still think it was a really solid edition, but I&#8217;ve come [...]]]></description>
			<content:encoded><![CDATA[<p>Boy, have I been out of the loop.</p>

<p>I guess <a href="http://www.montecook.com/cgi-bin/page.cgi?splash">Monte Cook</a> has been back at Wizards for ~4 months? And he&#8217;s been <a href="http://wizards.com/dnd/Archive.aspx?category=all&amp;subcategory=legendslore">writing a column</a>? This makes sense, given that there&#8217;s now an announcement about <a href="http://wizards.com/dnd/Article.aspx?x=dnd/4ll/20120109">this 5e playtest</a>.</p>

<p>Looking back on 4e, I still think it was a really solid edition, but I&#8217;ve come around to agree with some of the criticism with regard to losing some of the old school flavor. It&#8217;s inevitable that a thick layer of mechanics, no matter how crisply designed, are going to focus people&#8217;s attentions on that.</p>

<p>One part of 3e and Pathfinder I strongly want to remain addressed or fixed in some fashion is character power level. 4e rather strongly pushes a philosophy where PCs get a sort of metaphorical +2, and if nothing else, I found that to be a revelation. If there&#8217;s anything I would preserve from 4e, this would be at the top of the list. (Second would probably be: fighters and their ilk should not be inherently less interesting to play than casters as they have been with previous editions.)</p>

<p>This is in contrast to 3e and even Pathfinder, wherein you get some kind of bonus or interesting ability but there&#8217;s a trade-off baked into the ability. The game is balanced for characters without that sort of advantage, so any advantage a PC receives has to be offset with some penalty or substantial drawback.</p>

<p>I recall this being true in particular of the sorcerer&#8217;s at-will attacks. You get an ability to make some kind of attack. Fantastic! So I don&#8217;t need a crossbow? Well, not quite. A crossbow requires a move action to reload but it does 1d8, which is too much. It would also be too powerful for a caster to do more damage than some spells, so it&#8217;s 1d4 or 1d6 + 1 for every N levels of sorcerer. Oh, and at-will is too powerful, so you&#8217;ve got a fixed number of uses per day. There&#8217;s a neat mechanic attached to some of them which makes it worthwhile but in our analogy of 4e handing out +2, this is more like +0.5.</p>

<p>As you go on and on, you see that there&#8217;s a limit to how awesome even Pathfinder can make you. They can bolt on additional abilities all they want, but they must be 3.5-esque in terms of versatility and power level and they must be in lockstep with what&#8217;s gone before.</p>

<p>Note that, at least from a balance perspective, I&#8217;m entirely sympathetic. The system has got to work. And people who like 3.x are presumably fine with this. I mean, I&#8217;m saying all that stuff up there like it&#8217;s a bad thing! There&#8217;s nothing wrong with people enjoying that flavor of mechanics. Hell, it&#8217;s far and away more interesting than many of the 3e classes, especially for fighters and whatnot. Nevertheless, this is something that has bugged me ever since 2e and Pathfinder is more of the same when it comes down to it.</p>

<p>Anyway, I don&#8217;t want to spend all my time knocking Paizo&#8217;s product. More power to them if they can make something of the contracting tabletop RPG industry. It seems like both they and WotC have their work cut out for them, though. I fear I&#8217;ve turned this blog into some kind of platform of doom and gloom but I can&#8217;t lie: I suspect our hobby will only become more and more niche.</p>
]]></content:encoded>
			<wfw:commentRss>https://incrediblevehicle.com/2012/02/01/1041/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Late to the party: White Wolf Layoffs</title>
		<link>https://incrediblevehicle.com/2011/11/06/late-to-the-party-white-wolf-layoffs/</link>
		<comments>https://incrediblevehicle.com/2011/11/06/late-to-the-party-white-wolf-layoffs/#comments</comments>
		<pubDate>Mon, 07 Nov 2011 00:57:03 +0000</pubDate>
		<dc:creator>Matthew</dc:creator>
				<category><![CDATA[Roleplaying]]></category>
		<category><![CDATA[rpg]]></category>
		<category><![CDATA[white wolf]]></category>

		<guid isPermaLink="false">http://incrediblevehicle.com/?p=1035</guid>
		<description><![CDATA[Holy shit. I heard about the layoffs at White Wolf/CCP. However, when I heard the initial announcement, I didn&#8217;t hear much about specifics and I couldn&#8217;t find a list. Today I decided to look for one while looking or information about M20. I found a list here, from the Unofficial White Wolf Wiki: Russell Bailey [...]]]></description>
			<content:encoded><![CDATA[<p>Holy shit. I heard about the layoffs at White Wolf/CCP. However, when I heard the initial announcement, I didn&#8217;t hear much about specifics and I couldn&#8217;t find a list. Today I decided to look for one while looking or information about M20.</p>

<p><a href="http://whitewolf.wikia.com/wiki/Black_Wednesday">I found a list here</a>, from the <a href="http://whitewolf.wikia.com/wiki/Main_Page">Unofficial White Wolf Wiki</a>:</p>

<ul>
<li>Russell Bailey</li>
<li>John Bridges</li>
<li>Chad Brown</li>
<li>John Chambers</li>
<li>Mike Chaney</li>
<li>Ken Cliffe</li>
<li>Shane DeFreest</li>
<li>Brian Glass</li>
<li>Craig S. Grant</li>
<li>Sara Luebke</li>
<li>Aileen E. Miles</li>
<li>Ethan Skemp</li>
<li>Michelle Webb</li>
</ul>

<p>You can hit the list of layoffs to find links to each person&#8217;s White Wolf CV. There are a lot of names here that go way back before you even start talking about such as Ethan Skemp and Aileen Miles.</p>

<p>I reiterate, this time with emphasis: holy fucking shit. It breaks my heart.</p>

<p>Now, I don&#8217;t pretend that I would even recognize any of these people on the street, let alone that I have any sort of personal relationship with them. I only have a relationship with these people insofar as I&#8217;ve spent countless hours curled up with books they&#8217;ve written, typeset, and otherwise lovingly crafted. I couldn&#8217;t have bought and read a decade&#8217;s worth of White Wolf books without recognizing at least some of these names.</p>

<p>It&#8217;s tempting to opine about the whole White Wolf/CCP thing. Of course some part of me feels bitterness. But if the complaint is that CCP is killing White Wolf, I have to wonder whether White Wolf would&#8217;ve survived, alone, for this long.</p>

<p>No, I don&#8217;t really have any big pronouncements. Recessions suck. I&#8217;m sad about RPGs being on the decline. White Wolf was one of my favorites because I like creepy and/or modern shit.</p>

<p>Arguably this is what happens when times change; the old stuff, which has its own merits and trade-offs, falls by the wayside or is otherwise transformed. They are replaced by new things, which also have their own merits and trade-offs, and will themselves, at some subsequent time, be replaced or transformed. It&#8217;s not the end because it&#8217;s never the end; RPGs live in on multiple forms. Many of their concepts and mechanics are now more pervasive than they&#8217;ve ever been. And in a more concrete sense, White Wolf itself still lives, as does WotC and numerous indie developers.</p>

<p>That&#8217;s about all I&#8217;ve got.</p>
]]></content:encoded>
			<wfw:commentRss>https://incrediblevehicle.com/2011/11/06/late-to-the-party-white-wolf-layoffs/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>My latest apostasy: webmail vs. IMAP</title>
		<link>https://incrediblevehicle.com/2011/09/18/my-latest-apostasy-webmail-vs-imap/</link>
		<comments>https://incrediblevehicle.com/2011/09/18/my-latest-apostasy-webmail-vs-imap/#comments</comments>
		<pubDate>Mon, 19 Sep 2011 00:48:17 +0000</pubDate>
		<dc:creator>Matthew</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[gmail]]></category>
		<category><![CDATA[mac]]></category>

		<guid isPermaLink="false">http://incrediblevehicle.com/?p=1004</guid>
		<description><![CDATA[I am extremely biased. I&#8217;ve been involved with Gmail as a product for some time. And I&#8217;ve had a Gmail account since 2004, when Gmail first came out. And yet I&#8217;ve become conflicted lately. When Lion came out, I decided to check out the state of the art in ostensibly user-friendly (read: GUI) email clients. [...]]]></description>
			<content:encoded><![CDATA[<p>I am extremely biased. I&#8217;ve been involved with Gmail as a product for some time. And I&#8217;ve had a Gmail account since 2004, when Gmail first came out. And yet I&#8217;ve become conflicted lately.</p>

<p>When Lion came out, I decided to check out the state of the art in ostensibly user-friendly (read: GUI) email clients. I don&#8217;t pretend to know much about how Apple Mail It was purely curiosity. But a number of issues have cropped up in my mind.</p>

<ul>
<li><p>Gmail can get really bloated, memory-wise. I was surprised when Mail took up less than 200MB; I assumed all mail clients routinely took up at least twice as much. Gmail often takes up something north of 500MB. (I suppose Chrome doesn&#8217;t help, if only because its multiprocess model necessarily involves a RAM tax.) Part of this is that I keep it open all the time, or rather I used to; now I feel obligated to close it now and then to keep my RAM clear. On balance, I don&#8217;t <em>want</em> to care about RAM, but in practice I feel I have to. I share a laptop with my -girlfriend- wife, which means Gmail effectively occupies 1GB or more. Running a Minecraft server on my desktop machine means I&#8217;m consistently down by 1GB, at least until I move it off.</p></li>
<li><p>The idea of having my mail on every machine is less of a concern now. Chiefly this is because I have a smartphone; if I don&#8217;t have a laptop with me, I always have my phone. IMAP means that changes on one client propagate elsewhere automatically, whether it&#8217;s on the phone, the iPad, or a full-fledged computer.</p></li>
<li><p>I can use an email client offline. This doesn&#8217;t happen <em>that</em> often, admittedly, and when I am completely offline I&#8217;m typically on vacation. Still, there were a couple of occasions recently where my connectivity was poor enough to make Gmail sluggish. A mail client simply had to download my messages once and I could read and search all of them without hitting the server via my flaky connection.</p></li>
<li><p>An email client is consistently faster when it comes to common UI operations. This is not to say that Gmail is slow, at last not <strong>most</strong> of the time. Most of the time, it&#8217;s fast enough. But when it&#8217;s not, it&#8217;s quite frustrating when a simple search takes longer than it really should! Contrariwise, once a client downloads my mail, I&#8217;m not subject to network delays. Yes, the client can be slow due to limitations of my machine, but those same constraints apply to the browser as well. Furthermore, the difference between searching my mail via Gmail and on my own machine continues to narrow, at least for me.</p></li>
<li><p>With Gmail + IMAP, I have the best of both worlds. I can check mail via a browser should I need to, but should I have the need, I can use the client. This is the strongest point in favor of retaining Gmail, modulo other logistical issues: it does&#8217;t have to be either/or.</p></li>
</ul>

<p>That said, there are some significant drawbacks, at least to Apple Mail in particular as well as Gmail/IMAP.</p>

<ul>
<li><p>Gmail/IMAP integration isn&#8217;t that great. Or maybe I should say that IMAP itself isn&#8217;t that great. It&#8217;s a folder-based paradigm, which treats emails like files. I think that&#8217;s ridiculous. IMHO, people only think about emails that way because it&#8217;s been thrust on them, and it&#8217;s not like most people understand the filesystem paradigm in the first place. Labeling/tagging a message is a &#8220;copy&#8221; operation, which is dumb. Archiving a message means &#8220;move to All Mail,&#8221; which is silly, too. Overall I&#8217;d say <a href="http://mail.google.com/support/bin/answer.py?answer=77657">the mapping is somewhat leaky</a>. I&#8217;m not sure it&#8217;s anyone&#8217;s fault in particular; I prefer Gmail&#8217;s model, but I wouldn&#8217;t expect Apple to sign on to that model wholesale.</p></li>
<li><p>Your -filters- Rules don&#8217;t sync across multiple machines. It seems that previously you&#8217;d have to pay for MobileMe to get this, which is/was ridiculous. Perhaps iCloud will fix this? It would be surprising if it didn&#8217;t, esp. considering they&#8217;re offering a full-fledged email service as far as I can tell.</p></li>
<li><p>The keyboard shortcuts aren&#8217;t nearly as good. Although there are hitches now and then, for the most part I can drive Gmail entirely through keyboard shortcuts. Mail&#8217;s keyboard shortcuts are merely OK.</p></li>
</ul>

<p>All this really amounts to in terms of my behavior is that nowadays I often have Mail open on my personal machines. I don&#8217;t shy away from using Mail on iOS devices, either. Beyond that, I still use Gmail for chat and I use it for most email operations that aren&#8217;t simply reading or deleting. The thought remains that I could, if I really wanted to, make the switch. I&#8217;m just not sure what it would take for me to do it; certainly I have no reason to now or in the near future.</p>
]]></content:encoded>
			<wfw:commentRss>https://incrediblevehicle.com/2011/09/18/my-latest-apostasy-webmail-vs-imap/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Python, Python, Python</title>
		<link>https://incrediblevehicle.com/2011/08/31/python-python-python/</link>
		<comments>https://incrediblevehicle.com/2011/08/31/python-python-python/#comments</comments>
		<pubDate>Thu, 01 Sep 2011 02:46:34 +0000</pubDate>
		<dc:creator>Matthew</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://incrediblevehicle.com/?p=978</guid>
		<description><![CDATA[Oh, god. I still have a bunch of rant left in me. So here we go, Internet: yet another angry rant to add to the pile. Sometimes, in the course of one&#8217;s life, one is left with a one-off task. In this case, I needed to call a binary a whole lot of times, and [...]]]></description>
			<content:encoded><![CDATA[<p>Oh, god. I still have a bunch of rant left in me. So here we go, Internet: yet another angry rant to add to the pile.</p>

<p>Sometimes, in the course of one&#8217;s life, one is left with a one-off task. In this case, I needed to call a binary a whole lot of times, and do something with the output each time. The details aren&#8217;t important; I just needed to write a wrapper script for this binary, do a modest amount of processing on it, and then output the result to a file. This is a pretty common task, one to which the command line in general and *nix in particular is well-suited.</p>

<p>Now, for various reasons, I prefer not to do this via shell scripts. I don&#8217;t have a hard and fast rule for when or why. Unless you routinely write shell scripts (I don&#8217;t), you&#8217;ll inevitably spend a bunch of time looking stuff up that you looked up, oh, six months ago. Or at least I do. I don&#8217;t enjoy it, so if I can&#8217;t do it with a few commands, maybe one loop or so, then I prefer to use a scripting language. I have the advantage of better/clearer failure modes and simpler syntax and I feel like I&#8217;m learning something more powerful and more widely applicable in the process.</p>

<p><span id="more-978"></span></p>

<p>One of my &#8220;favorite&#8221; things to forget and look up again is the difference between <code>[[ ]]</code> and <code>[ ]</code> in tests. Another one is how you loop over a file or output from a command (<code>while read line; do bar --baz $line; done &lt;foo</code> and <code>foo | while read line; do bar $line; done</code>, respectively).</p>

<p>If you have no trouble remembering this stuff or you write scripts often enough, I suppose this is moot. There was a time when I was scripting enough that I didn&#8217;t have to look all this stuff up every time, but that time is past. YMMV and all that.</p>

<p>Anyway, the point is that I probably could&#8217;ve done this with something like this (which is simplified somewhat):</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">ARGS</span>=<span style="color: #ff0000;">&quot;--bar=baz&quot;</span>
<span style="color: #007800;">CMD</span>=<span style="color: #ff0000;">&quot;~/bin/foo&quot;</span>
<span style="color: #007800;">KEY</span>=<span style="color: #ff0000;">&quot;quux&quot;</span>
<span style="color: #007800;">MIN</span>=<span style="color: #000000;">0</span>
<span style="color: #007800;">MAX</span>=<span style="color: #000000;">10000</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">for</span> $<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">seq</span> <span style="color: #000000;">0</span> <span style="color: #000000;">1000</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> num <span style="color: #000000; font-weight: bold;">do</span>;
  <span style="color: #007800;">$CMD</span> <span style="color: #007800;">$num</span> <span style="color: #007800;">$ARGS</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #c20cb9; font-weight: bold;">read</span> line;
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #c20cb9; font-weight: bold;">egrep</span> <span style="color: #660033;">-q</span> <span style="color: #007800;">$KEY</span> <span style="color: #000000; font-weight: bold;">&lt;&lt;&lt;</span><span style="color: #007800;">$line</span>; <span style="color: #000000; font-weight: bold;">then</span>
      <span style="color: #007800;">value</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">egrep</span> <span style="color: #660033;">-o</span> <span style="color: #ff0000;">'[1-9]+$'</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$num</span>,<span style="color: #007800;">$value</span>&quot;</span>
    <span style="color: #000000; font-weight: bold;">fi</span>
  <span style="color: #000000; font-weight: bold;">done</span>
<span style="color: #000000; font-weight: bold;">done</span></pre></div></div>


<p>I&#8217;m sure I have a bajillion bugs in there. For example, I am not at all confident about the outer <code>for</code> loop syntax. And while it was easy to write, I&#8217;m not doing anything with command line args, doing any error handling, or anything like that. (On the other other hand, I uh underestimated how easy this was. That&#8217;s partially why I&#8217;m convinced there are bugs in there.)</p>

<p>I still don&#8217;t know how to write idiomatic (typo: idiotmatic) Ruby, so this is going to be very rough. Still, it feels natural to me, minus one or two hitches:</p>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">ARGS = <span style="color:#996600;">&quot;--bar=baz&quot;</span>
CMD = <span style="color:#996600;">&quot;~/bin/foo&quot;</span>
KEY = <span style="color:#006600; font-weight:bold;">/</span>quux<span style="color:#006600; font-weight:bold;">/</span>
MIN = <span style="color:#006666;">0</span>
MAX = <span style="color:#006666;">10000</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">def</span> main
  <span style="color:#006600; font-weight:bold;">&#40;</span>MIN..<span style="color:#9900CC;">MAX</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>i<span style="color:#006600; font-weight:bold;">|</span>
    out = <span style="color:#006600; font-weight:bold;">%</span>x<span style="color:#006600; font-weight:bold;">&#91;</span> <span style="color:#008000; font-style:italic;">#{CMD} #{i} #{ARGS} ]</span>
    out.<span style="color:#CC0066; font-weight:bold;">split</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'<span style="color:#000099;">\n</span>'</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>line<span style="color:#006600; font-weight:bold;">|</span>
      KEY.<span style="color:#9900CC;">match</span><span style="color:#006600; font-weight:bold;">&#40;</span>line<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>m<span style="color:#006600; font-weight:bold;">|</span>
        value = line.<span style="color:#CC0066; font-weight:bold;">split</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">' '</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">1</span><span style="color:#006600; font-weight:bold;">&#93;</span>
        <span style="color:#CC0066; font-weight:bold;">print</span> <span style="color:#996600;">&quot;#{i},#{value}<span style="color:#000099;">\n</span>&quot;</span>
      <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>


<p>I&#8217;m not confident about the outer loop once again, and I&#8217;m not sure the call to match() will do what I want, let alone whether it&#8217;s elegant. Still, I feel pretty good about it. I love Ruby&#8217;s pattern of passing in blocks.</p>

<p>Fortunately or unfortunately, I had to use Python. And don&#8217;t get me wrong: I love Python. It is through Python that I learned to love scripting languages. Processing a file line by line was, I think, the real epiphany. And list comprehensions are wonderfully expressive.</p>

<p>But man alive is it <strong>awful</strong> for this sort of thing. I&#8217;m not even going to bother writing it out in Python. I&#8217;ll just excerpt, from the <a href="http://docs.python.org/library/subprocess.html#replacing-bin-sh-shell-backquote">2.7 subprocess docs</a>. Here&#8217;s what they say should replace backticks <code>output = \</code>mycmd myarg&#96;`:</p>


<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">output = Popen<span style="color: black;">&#40;</span><span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;mycmd&quot;</span>, <span style="color: #483d8b;">&quot;myarg&quot;</span><span style="color: black;">&#93;</span>, stdout=PIPE<span style="color: black;">&#41;</span>.<span style="color: black;">communicate</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span></pre></div></div>


<p>Mind you, this is if you did <code>from subprocess import *</code>. Generally I don&#8217;t, which means it ends up looking like this:</p>


<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">output = \
  <span style="color: #dc143c;">subprocess</span>.<span style="color: black;">Popen</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;mycmd&quot;</span>, <span style="color: #483d8b;">&quot;myarg&quot;</span><span style="color: black;">&#93;</span>, <span style="color: #dc143c;">subprocess</span>.<span style="color: black;">stdout</span>=PIPE<span style="color: black;">&#41;</span>.\
  communicate<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span></pre></div></div>


<p>Yes, once you have it written, sequestered in its own function that you never touch again, it&#8217;s not so bad. However, this is firmly in the category of something I will not be able to (and have not been able to) remember months later.</p>

<p>It is also not discoverable in the sense that it&#8217;s highly particular&#8212; <code>stdout=PIPE</code>? Really? Compare and contrast opening a file (<code>for line in open('somefile'): print foo(line)</code> or <code>[foo(line) for line in open('somefile')</code>) with this monster. Even my Ruby example could have used backticks if I hadn&#8217;t remembered the <code>%x</code> syntax. The best I can say about <code>subprocess</code> is that it&#8217;s a) better than <code>Popen</code> in Python 2.4 (or whatever), and b) it&#8217;s easier to search the web for than <code>%x</code>.</p>

<p>The kicker of course is that rest of the Python script was very easy to write! However, since calling the binary was changing some external state, though, I had to make sure it was doing the right thing. In the end building and testing the call to <code>subprocess.Popen()</code> took longer than the rest of the script. In an otherwise elegant, no-bullshit, batteries included language, the <code>subprocess</code> module is a terrible blemish. It doesn&#8217;t look any better in Python 3.0, either, unfortunately.</p>

<p>Even more unfortunately, this is ultimately why it would be my preference to use either Ruby or shell. Ruby seems to work well for a variety of tasks, from writing a full-fledged webapp to some grungy text manipulation. You don&#8217;t have to compromise because it&#8217;s quite easy to use it for Python-y things as well as Perl-y things. It&#8217;s just a shame that Python seems to treat this case with a bizarre kind of fussiness incongruent with the rest of the language and standard library.</p>
]]></content:encoded>
			<wfw:commentRss>https://incrediblevehicle.com/2011/08/31/python-python-python/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>White Wolf Release Schedule 2011-2012</title>
		<link>https://incrediblevehicle.com/2011/08/09/white-wolf-release-schedule-2011-2012/</link>
		<comments>https://incrediblevehicle.com/2011/08/09/white-wolf-release-schedule-2011-2012/#comments</comments>
		<pubDate>Wed, 10 Aug 2011 04:35:15 +0000</pubDate>
		<dc:creator>Matthew</dc:creator>
				<category><![CDATA[Roleplaying]]></category>
		<category><![CDATA[nwod]]></category>
		<category><![CDATA[oWoD]]></category>

		<guid isPermaLink="false">http://incrediblevehicle.com/?p=969</guid>
		<description><![CDATA[A couple of things have put me in mind of White Wolf over the last few days. One of them was unboxing my roleplaying books. They&#8217;d been boxed up as part of some home improvement and I never got around to unboxing them. This weekend, I did. It&#8217;s hard to describe how I felt. It [...]]]></description>
			<content:encoded><![CDATA[<p>A couple of things have put me in mind of White Wolf over the last few days.</p>

<p>One of them was unboxing my roleplaying books. They&#8217;d been boxed up as part of some home improvement and I never got around to unboxing them. This weekend, I did. It&#8217;s hard to describe how I felt. It was bittersweet, in that I felt nostalgic but also some sense that I might be done with roleplaying for good.</p>

<p>And then just now, I saw that White Wolf had put up their <a href="http://white-wolf.com/community/news/white-wolf-release-schedule-2011-2012">publishing schedule for 2011 &#8211; 2012</a>. Huh.</p>

<p><span id="more-969"></span></p>

<p>I&#8217;ll admit I&#8217;m less than thrilled by the whole <a href="http://blog.vampirethemasquerade.com/page/information.aspx">V20 thing</a>. (I guess we&#8217;re all curmudgeons now?) (Uh, &#8220;now&#8221;?) There wasn&#8217;t much thrill in a game I wasn&#8217;t all that interested in, although on some level I have to feel happy for the people for whom this is a big deal. The guy who runs my FLGS certainly seems pleased. My visits aren&#8217;t often these days, and he brings it up each time. I don&#8217;t have the heart to tell him I thought Requiem was a superior game by nearly every measure.</p>

<p>On top of that, I presumed that the nWoD was all but dead. Perhaps that says more about me than anything else: from glancing at <a href="http://drivethrurpg.com">DriveThruRpg.com</a>, it seems there&#8217;s been a trickle of releases. It&#8217;s difficult to see at what rate with DriveThruRPG&#8217;s interface, but it doesn&#8217;t seem like that many. Maybe that&#8217;s consistent with the rate before the move to digital publishing in any case.</p>

<p>I&#8217;m rambling.</p>

<p>So then I see the new publishing schedule, and it&#8217;s an interesting mix. Releases are one per month, as far as I can tell, and the list goes out to 2012. Remarkably, it seems they&#8217;re releasing new material for the old games (including finishing up some of the old Technocracy Convention books, ha!). But the majority is either nWoD or Exalted.</p>

<p>Another notable piece is that there&#8217;ll be another nWoD expansion game, a remake of Mummy.</p>

<p>Finally, it looks like some of the print on demand stuff came through. On top of the oWoD stuff, a bunch of nWoD stuff will be on here. So there&#8217;s that.</p>

<h3>My own hiatus</h3>

<p>My thoughts on roleplaying these days are few and far between, as I&#8217;m sure I&#8217;ve reiterated the few times I&#8217;ve posted lately. That&#8217;s persisted. I&#8217;ve spent more time reading, coding, working, or goofing off. A big chunk of it is that my core gaming group is heavily ensconced in their own game, for which I have little interest. Hearing about their game evokes the opposite of what I&#8217;d imagined; the more I hear about it, the less I&#8217;m interested in roleplaying overall.</p>

<p>I&#8217;d say it&#8217;s a phase, as these things do move in cycles. Two year cycles, though? That&#8217;s the last time I posted any really coherent thoughts on roleplaying. Oh, I&#8217;m sure I&#8217;ve played some one-shot D&amp;D since then. But I never ran Changeling, nor Dark Sun, nor Geist, nor anything else.</p>

<p>What&#8217;s funny is that when I was shelving my books the other day, I was reminded about how I kept acquiring books even after I&#8217;d ostensibly lost interest. I&#8217;ve got a fair number of D&amp;D books I haven&#8217;t read. In my defense, some (but not all) were gifts. Some of the later <strong>Vampire: the Requiem</strong> books are mostly unread. I <em>probably</em> finished <strong>The Mage Chronicler&#8217;s Guide</strong>.</p>

<p>There&#8217;s something alluring about the books, though, as always. The Requiem clanbooks in particular were among the most enjoyable role-playing books I&#8217;ve ever seen or read.</p>

<p>This is all just a long way of saying that I&#8217;m sure I could get interested again if I tried. But do I want to? I&#8217;m not sure! This I will say: as of this evening, and it sure is tempting to crack open a role-playing book or two in the meantime. I might have achieved the point (seven years?!) at which there&#8217;s enough nostalgia to get me reading, if nothing else.</p>
]]></content:encoded>
			<wfw:commentRss>https://incrediblevehicle.com/2011/08/09/white-wolf-release-schedule-2011-2012/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Thoughts on Lion</title>
		<link>https://incrediblevehicle.com/2011/07/27/thoughts-on-lion/</link>
		<comments>https://incrediblevehicle.com/2011/07/27/thoughts-on-lion/#comments</comments>
		<pubDate>Thu, 28 Jul 2011 01:55:56 +0000</pubDate>
		<dc:creator>Matthew</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[lion]]></category>
		<category><![CDATA[mac]]></category>

		<guid isPermaLink="false">http://incrediblevehicle.com/?p=951</guid>
		<description><![CDATA[I don&#8217;t think I&#8217;ve documented my Mac apostasy by this point. I feel like I should, but maybe another time? The point is that for everything but video games, I prefer MacOS, which recently saw an upgrade, 10.7 aka Lion. autocorrect I didn&#8217;t realize this was going to be as big a deal to me [...]]]></description>
			<content:encoded><![CDATA[<p>I don&#8217;t think I&#8217;ve documented my Mac apostasy by this point. I feel like I should, but maybe another time? The point is that for everything but video games, I prefer MacOS, which recently saw an upgrade, 10.7 aka Lion.</p>

<h3>autocorrect</h3>

<p>I didn&#8217;t realize this was going to be as big a deal to me as I thought. Actually, I&#8217;d forgotten about it entirely until I started writing a couple of blog posts. Thus I was pleasantly surprised when I realized the built-in autocorrect is actually pretty handy. The vast majority of the time it does the right thing! Were I using Vim to do most of my writing, it might not matter so much; Vim has so many handy motions that it&#8217;s easy to jump between words, sentences, and lines in order to fix mistakes quickly. For a standard (read: less arcane) input method like this one, though, I&#8217;ve only got the standard ctrl-a, ctrl-e, alt-left, alt-right, and so on. Having the OS correct the litany of stupid typos I make regularly helps.</p>

<p>I had sort of wondered why this wasn&#8217;t an OS feature in the first place. Input fields are common as mud and autocorrect has been a feature in word processors for a long, long time. So why isn&#8217;t it in the OS? Who knows? It is now.</p>

<p>Irrationally, I worry that a feature like this will erode my typing accuracy.</p>

<h3>fullscreen apps</h3>

<p>To some extent, I&#8217;m being conspicuous when I use them. There&#8217;s no <strong>real</strong> reason that I need to use Safari fullscreen while blogging. After all, Chrome is my main browser. But it does have a nice way of focusing my attention. I&#8217;m also trying out Apple Mail, and segregating it to its own space means I&#8217;m less likely to fidget with checking it.</p>

<h3>mission control</h3>

<p>I was a litte worried about Mission Control doing away with Snow Leopard&#8217;s way of laying out windows via Exposé. Leopard laid out windows sort of haphazardly and without obvious consistency. Snow Leopard made it into a grid layout, which made it a little harder to figure out which window was which but looked a lot neater and cleaner overall. Mission Control looks to restore it back to a semi-haphazard layout, grouped by application, which seemed like a loss of functionality.</p>

<p>What rescues it is the presence of a gesture for application-level Exposé. With that, I don&#8217;t have to Cmd-` my way through two or more Chrome windows. I&#8217;m not sure how useful Mission Control&#8217;s facility for selecting one or more of an app&#8217;s windows is, though.</p>

<h3>launchpad</h3>

<p>It&#8217;s pretty! I&#8217;ll give it that. But I am not sure how useful it is.</p>

<p>It looks like it finds <strong>all</strong> of your apps, which is a good thing overall. It&#8217;d be dumb if it didn&#8217;t.</p>

<p>However, putting them into iOS-style folders and whatnot is odd. For example, I&#8217;ve got a bunch of git clients (<a href="http://www.git-tower.com/">Tower</a>, <a href="http://gityapp.com/">GitY</a>, <a href="http://gitx.frim.nl/">GitX</a>, <a href="http://mac.github.com/">GitHub</a>) sitting in my Applications folder. There&#8217;s also a Development folder in Launchpad. Except it actually corresponds to /Developer. When I moved my various Git.* apps around in Launchpad, it created /Applications/Developer which had only the Git.* apps in it.</p>

<p>Call it a leaky abstraction, I guess. Or a corner case, given that the majority of apps go under /Applications in any case.</p>

<h3>scrolling, gestures</h3>

<p>I&#8217;m fine with the new scrolling. I guess I&#8217;ve lived with it for a week, like I said I would, and I don&#8217;t feel like turning it off.</p>

<p>The gestures are kind of messed up out of the box, though. Two finger swipe for fwd/back is fine in theory but it doesn&#8217;t work at all in Chrome (expected; I presume they&#8217;d have to make a code change) or even System Preferences (!). It&#8217;s easy to switch it back to three finger swipe, and I did that.</p>

<p>I like the new scrollbars, although once again they&#8217;re hideous in Chrome. Chrome still has the old scrollbar gutter, and the gray scrollbar is always present. The Chrome team <a href="http://www.macnn.com/articles/11/07/27/mac.software.undergoing.slow.evolution/">is working on it, or so I hear</a>.</p>

<h3>TTFN</h3>

<p>That&#8217;s all I&#8217;ve got for now.</p>

<p>I sort of want to write something about Resume and whatnot, but I&#8217;m out of steam at the moment. Perhaps another time. John Siracusa&#8217;s <a href="http://arstechnica.com/apple/reviews/2011/07/mac-os-x-10-7.ars">excellent review</a> of Lion <a href="http://arstechnica.com/apple/reviews/2011/07/mac-os-x-10-7.ars/8#process-model">covers this</a> in more detail, and he probably says it better than I would anyway.</p>
]]></content:encoded>
			<wfw:commentRss>https://incrediblevehicle.com/2011/07/27/thoughts-on-lion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
