<?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>Nathan WongNathan Wong - Thinking in Code</title>
	<atom:link href="http://nathan.ca/feed/" rel="self" type="application/rss+xml" />
	<link>http://nathan.ca</link>
	<description>Thinking in Code</description>
	<lastBuildDate>Tue, 26 Mar 2013 01:17:38 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Bash History Tip</title>
		<link>http://nathan.ca/2013/03/bash-history-tip/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=bash-history-tip</link>
		<comments>http://nathan.ca/2013/03/bash-history-tip/#comments</comments>
		<pubDate>Tue, 26 Mar 2013 01:16:32 +0000</pubDate>
		<dc:creator>Nathan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://nathan.ca/?p=442</guid>
		<description><![CDATA[In order to redeem myself for neglecting my blog, here&#8217;s a quick productivity tip for Bash. I&#8217;ve been using this for the past few months, and every time I log on to a server that doesn&#8217;t have this, I wonder how I ever functioned on the command line. It&#8217;s 6 simple lines in ~/.inputrc: All [...]]]></description>
				<content:encoded><![CDATA[<p>In order to redeem myself for neglecting my blog, here&#8217;s a quick productivity tip for Bash. I&#8217;ve been using this for the past few months, and every time I log on to a server that doesn&#8217;t have this, I wonder how I ever functioned on the command line.</p>
<p>It&#8217;s 6 simple lines in ~/.inputrc:</p>
<pre><pre class="brush: plain; title: ; notranslate"># change up/down arrows to be search
  &quot;\e[A&quot;: history-search-backward
  &quot;\e[B&quot;: history-search-forward
  &quot;\e[C&quot;: forward-char
  &quot;\e[D&quot;: backward-char
  set show-all-if-ambiguous on
  set completion-ignore-case on
</pre></pre>
<p>All it does is change the arrow keys to become command history search. So now, if I type <code>se</code> and hit up, instead of getting the previous command I had run, I get <code>service httpd restart</code>. Or <code>svn c</code> which gets me <code>svn commit -F ../whatidid.txt</code>.</p>
<p>This is especially helpful for toggling back and forth between commands. Usually when toggling between two or three commands, they inevitably get out of sync &ndash; hitting the up arrow twice brings you to the wrong command, and you have to consciously look for it. Now, the first character of each command guarantees you the right one.</p>
<p>Could I use aliases for all of these? I most certainly could. But with this simple .inputrc change, I don't even think about aliases anymore. Like all .inputrc directives, it also works for the MySQL command line client and other readline-derived prompts.</p>
<p>If you use the command line like I do, this will likely save what feels like hours of your life.</p>
<div style="display:none;"><pre class="brush: cpp; title: ; notranslate"> </pre></div>
]]></content:encoded>
			<wfw:commentRss>http://nathan.ca/2013/03/bash-history-tip/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Formatter</title>
		<link>http://nathan.ca/2013/01/php-formatter/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=php-formatter</link>
		<comments>http://nathan.ca/2013/01/php-formatter/#comments</comments>
		<pubDate>Tue, 01 Jan 2013 22:43:16 +0000</pubDate>
		<dc:creator>Nathan</dc:creator>
				<category><![CDATA[Fun Stuff]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php formatter]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://nathan.ca/?p=420</guid>
		<description><![CDATA[The best part about the holidays is the free time to write fun code. I&#8217;ve wanted to write a PHP formatter since I first used Go&#8217;s gofmt, so this week it was a pretty easy choice. The code is available on GitHub: PHP Formatter, and licensed under the MIT License like most of my code. [...]]]></description>
				<content:encoded><![CDATA[<p>The best part about the holidays is the free time to write fun code. I&#8217;ve wanted to write a PHP formatter since I first used Go&#8217;s <code>gofmt</code>, so this week it was a pretty easy choice.</p>
<p>The code is available on <a href="https://github.com/NathanWong/phpformatter">GitHub: PHP Formatter</a>, and licensed under the <a href="/code/license">MIT License</a> like most of my code.</p>
<p>It uses PHP&#8217;s built-in <code>token_get_all</code> function to tokenize the PHP into operators, keywords, strings, HTML, and whitespace, and then steps through these tokens, focusing mostly on rearranging the whitespace. All whitespace (outside of strings and HTML, of course) is stripped except for multiple sequential newlines which are reduced to a single newline. After that, &#8220;correct&#8221; whitespace is added back into the code.</p>
<p>In order to avoid creating an unruly mess, it then goes through and ensures that no line is longer than 97 characters unless absolutely necessary (i.e. it doesn&#8217;t automatically break strings up yet). For consistency sake, it also re-arranges sequential single-line comments to the same line length.</p>
<p>Additionally, PHP Formatter will format inline HTML for indenting, although the HTML formatting is much more permissive, with whitespace for the most part being left untouched. The indenting rule here is that each line that has an opening tag is indented once (regardless of how many tags are opened on that line), and likewise each line with a closing tag is unindented. For this to work, closing tags are rearranged to remain on the same line as the other corresponding open tags were originally. If a closing tag occurs out of order, unclosed tags will be closed to help promote valid markup.</p>
<p>As an added perk, inline JavaScript (through <code>script</code> tags) will be formatted using the <a href="https://github.com/NathanWong/js-beautify">JS-Beautify PHP port</a> if it&#8217;s available alongside the PHP Formatter. I forked this in order to make it ignore PHP tags inside the JS as though they were just comments, since it&#8217;s not actually valid JavaScript, although that&#8217;s only necessary if you mix PHP and JS.</p>
<p>All in all, this actually took me a fair bit longer than I thought it would &ndash; I was expecting to get a lot more done today and yesterday outside of this &ndash; as it turns out that nearly everything about the way we format code is an edge-case, with the word &#8220;exception&#8221; (or worse &#8220;the one exception&#8221;) appearing all too often in the comments. Nonetheless, save for a few quirks, it effectively formats code the way I&#8217;ve been trying to, and does so with minimal effort on the developer&#8217;s part.</p>
<div style="display:none;"><pre class="brush: cpp; title: ; notranslate"> </pre></div>
]]></content:encoded>
			<wfw:commentRss>http://nathan.ca/2013/01/php-formatter/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Why I&#8217;m a Programmer</title>
		<link>http://nathan.ca/2012/12/why-im-a-programmer/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=why-im-a-programmer</link>
		<comments>http://nathan.ca/2012/12/why-im-a-programmer/#comments</comments>
		<pubDate>Mon, 24 Dec 2012 01:22:29 +0000</pubDate>
		<dc:creator>Nathan</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Thoughts]]></category>
		<category><![CDATA[life]]></category>
		<category><![CDATA[personal]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://nathan.ca/?p=404</guid>
		<description><![CDATA[I&#8217;ve been thinking a lot lately about why and how I chose to be a programmer. In doing so, I discovered an interesting fact: as of next week, I will have been writing software for more than half of my life. That actually makes figuring out the original decision process somewhat difficult, because honestly I [...]]]></description>
				<content:encoded><![CDATA[<p>I&#8217;ve been thinking a lot lately about why and how I chose to be a programmer. In doing so, I discovered an interesting fact: as of next week, I will have been writing software for more than half of my life. That actually makes figuring out the original decision process somewhat difficult, because honestly I don&#8217;t have too many memories that predate being a programmer.</p>
<p>Perhaps this sheer volume of time illustrates rather poignantly how great programming is. When I first started programming, I was 10 (let&#8217;s not count writing HTML and copying and pasting Perl scripts around from a few years prior to that, since that only barely counts as programming). Within several months, I had released my first open source project with some 20,000 lines of code for the world to see.</p>
<p><span id="more-404"></span></p>
<p>Now granted, I&#8217;m sure that was 20,000 ugly lines of code. But it worked, and felt magical. Where else can a child create something with as much intrinsic value as a full-fledged bulletin board in under a year with no prior experience, and no mentors or teachers except the open wild internet, and then have people make use of it to boot?</p>
<p>Fast forward a decade and the mystique persists. A rough count suggests I&#8217;ve personally written and shipped several hundred thousand lines of code in my life, and written a hundred thousand more that&#8217;s never seen the light of day. More interesting than lines of code, though, is that software I&#8217;ve directly written has helped people capture tens of millions of dollars of wealth. It&#8217;s been run on hundreds of millions of computers. Some of it has been invoked hundreds of billions of times.</p>
<p>To put this in perspective, if I had chosen instead to be a lawyer, or doctor, or some other &#8220;accredited&#8221; profession, I very likely would&#8217;ve helped a grand total of zero people in my career thus far, and couldn&#8217;t for another five or so years given that I (likely) wouldn&#8217;t even be in law or med school yet.</p>
<p>What intrigues me most about programming is the ability to work collaboratively, yet achieve things individually. This is fun because individually you can punch out a simple web app in a weekend given a well-defined idea of what you&#8217;re building, and then grow it to the next level as a team. Perhaps more importantly, though, the ability to work individually allows you to practice and iterate at a higher level than professions that revolve around collaboration.</p>
<p>Stripe co-founder Patrick Collison <a href="http://www.forbes.com/sites/quora/2012/12/10/does-stripe-have-product-managers-or-do-engineers-manage-the-products-themselves/">said it well</a>:</p>
<blockquote><p>If the same person is designing and implementing, the feedback cycle takes place within that person&#8217;s head. Even if product managers have equally good ideas, they&#8217;re likely not able to experiment with as many of them.</p></blockquote>
<p>I think this is an oft-understated aspect of programming, and not just in the context of product managers and engineers. People like to debate whether programming will become an intrinsic skill like math or language, or if programmers will continue to be their own profession. Arguably as more and more industries depend on data-driven decision making, from science to marketing to finance, a specialist who also knows how to write code will simply be able to practice more efficiently &ndash; and therefore get better at their specialty &ndash; than one who doesn&#8217;t.</p>
<p>When you think of it that way, you could argue that &#8220;being a programmer&#8221; doesn&#8217;t really exist, outside of maybe research. Writing the code is the easy part. I&#8217;d say code flows from my brain more fluently than English does. Laying out data, organizing code, and writing sequential logic statements is just something I do, like washing dishes or riding a bike. My actual job is building products that help people get ahead. That&#8217;s the hard part: understanding requirements, determining what people need and want, and taking it from vague idea to production.</p>
<p>But the programming half of it sure is fun. And in writing this, I hope that maybe I can inspire someone who has considered learning to code to get out there and do it, especially in a market that&#8217;s begging for it. Start writing code, open source it, and don&#8217;t be afraid to make mistakes along the way. If you need any help, get in touch.</p>
]]></content:encoded>
			<wfw:commentRss>http://nathan.ca/2012/12/why-im-a-programmer/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Google Doodle Basketball &#8211; Automatic 45 Points</title>
		<link>http://nathan.ca/2012/08/google-doodle-basketball/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=google-doodle-basketball</link>
		<comments>http://nathan.ca/2012/08/google-doodle-basketball/#comments</comments>
		<pubDate>Thu, 09 Aug 2012 00:27:55 +0000</pubDate>
		<dc:creator>Nathan</dc:creator>
				<category><![CDATA[Fun Stuff]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[basketball]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[google doodle]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://nathan.ca/?p=391</guid>
		<description><![CDATA[Enamored by Google Doodle Basketball, but unable to get more than 42 points, I was intrigued at the upper limit of the game&#8217;s score. I knew for sure you could get away another shot past 42 once the balls move off the screen, but I was never able to get there. The easiest solution was [...]]]></description>
				<content:encoded><![CDATA[<p>Enamored by Google Doodle Basketball, but unable to get more than 42 points, I was intrigued at the upper limit of the game&#8217;s score. I knew for sure you could get away another shot past 42 once the balls move off the screen, but I was never able to get there.</p>
<p>The easiest solution was to write 40 lines of JavaScript to win for me. I spent some time playing around with the shot times, and was unable to get more than 45. But at least now I have a script that gets 45 points automatically every single time:</p>
<p><span id="more-391"></span></p>
<pre><pre class="brush: jscript; title: basketball.js; notranslate">// first of all, bring in jQuery to handle triggering events
var s = document.createElement('script');
s.src = 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js';
document.body.appendChild(s);

// let's define our parameters... basically, how long each shot takes
var wait = 1000,
	freethrow = 100,
	jumpshot = 250,
	forthree = 430,
	waydowntown = 650,
	moneyball = 1000,
	timeouts = [
		// click the start button first, and then the first throw
		// needs a lag first or it doesn't register
		1000, 500, 300, 200,
		freethrow, wait, freethrow, wait, freethrow, wait, freethrow,
		wait, jumpshot, wait, jumpshot, wait, jumpshot, wait, jumpshot,
		wait, forthree, wait, forthree, wait, forthree, wait, forthree,
		wait, waydowntown, wait, waydowntown, wait, waydowntown, wait, waydowntown,
		wait, wait, moneyball],
	n = 0;

// now walk through the timeouts array, alternating between clicking down and up
function go () {
	var timeout = timeouts.shift(),
		i = n++;

	if (timeout)
	{
		setTimeout(function () {

			var e = $.Event(i % 2 == 0 ? 'mousedown' : 'mouseup');
			$('canvas').trigger(e);

			go();
		}, timeout);
	}
}
go();
</pre></pre>
<p>To run it, just load Google&#8217;s homepage or their <a href="http://www.google.com/logos/2012/basketball-2012-hp.html">direct basketball doodle</a> page and paste the code into Chrome&#8217;s JS console and hit enter. If all goes right, enjoy a perfect score.</p.</p>
<p>Unfortunately, it looks like the timing of the script may be dependent on the performance of the computer it&#8217;s being run on. Tested on three different computers, I got surprisingly different results. On my computer, it hasn&#8217;t missed a shot yet. On another one, every now and again it misses one. On a third computer, it wasn&#8217;t able to get more than a couple in at all. So, if you can&#8217;t experience it first hand, either fiddle with the shot timing variables or just enjoy this video:</p>
<p><iframe width="560" height="315" src="http://www.youtube.com/embed/zRbwm2u9Xco" frameborder="0" allowfullscreen></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://nathan.ca/2012/08/google-doodle-basketball/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Unit Testing in C++</title>
		<link>http://nathan.ca/2012/06/unit-testing-in-cpp/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=unit-testing-in-cpp</link>
		<comments>http://nathan.ca/2012/06/unit-testing-in-cpp/#comments</comments>
		<pubDate>Sun, 24 Jun 2012 17:23:34 +0000</pubDate>
		<dc:creator>Nathan</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[nih]]></category>
		<category><![CDATA[tester]]></category>
		<category><![CDATA[unit-testing]]></category>

		<guid isPermaLink="false">http://nathan.ca/?p=358</guid>
		<description><![CDATA[I was chatting with an old friend this morning who was expressing frustration about the fact that C++ lacks a well-documented and easy to use unit testing framework. All he wanted was a way to write annotated tests to confirm that some parsing routines of his did indeed parse the correct values out of various [...]]]></description>
				<content:encoded><![CDATA[<p>I was chatting with an old friend this morning who was expressing frustration about the fact that C++ lacks a well-documented and easy to use unit testing framework. All he wanted was a way to write annotated tests to confirm that some parsing routines of his did indeed parse the correct values out of various known edge cases as he continued to expand on the parser. He said he had spent an hour or two searching and trying various libraries, but they were all overkill for what he was trying to do.</p>
<p>I suggested that perhaps the reason that there aren&#8217;t any good micro unit testing libraries available for C++ is that you could write your own faster than you could find one, and so everybody just did that; actually, my words were closer to &#8220;you could probably do it in a half an hour&#8221;. He wasn&#8217;t convinced, so I went ahead and did it.</p>
<p><span id="more-358"></span></p>
<p>The task at hand is greatly simplified by two features, one in C and one in C++. The first is that C macros let you &#8220;stringify&#8221; their input, which lets us output what the test actually was. The second is that C++11 can deduce the types of your inputs, and in general print out more or less any type (that has the available conversion, obviously) with streams. This means that not only do you need just two testing functions, test bool and test any comparison (unlike some libraries which try to offer various comparison functions), but you also maintain type safety and are able to take advantage of C++ overloads.</p>
<p>So here&#8217;s <a href="/code/tester"><em>tester</em></a>, a micro unit testing library for those who want to just write the damn tests without too much overhead.</p>
<h4>Core Functions / Macros</h4>
<p>Usage of <em>tester</em> is simple. Include <code>tester.h</code>, and remember these 4 functions (actually macros):</p>
<ul>
<li><code><b>tester_addsuite(id, name);</b></code> &#8211; sets up the class for the test suite under the heading of the given name. Once run, define <code>void tests::id::test() {}</code> with your actual tests.</li>
<li><code><b>tester_bool(cond, msg);</b></code> &#8211; tests whether the given <code>cond</code> evaluates to true.</li>
<li><code><b>tester_cmp(left, operand, right, msg);</b></code> &#8211; tests whether the given comparison of <code>left</code> and <code>right</code> by the given <code>operand</code> evaluates to true.</li>
<li><code><b>tester_with(var);</b></code> &#8211; outputs a variable name for reference.</li>
</ul>
<h4>Example</h4>
<pre><pre class="brush: cpp; title: stdlibtest.h; notranslate">#include &quot;tester.h&quot;

// let's test some standard library functions to make sure that they're correct.
tester_addsuite(StdlibTests, &quot;My Stdlib Test Cases&quot;);
void tests::StdlibTests::test()
{
	// trailing garbage
	const char *trailgarbage = &quot;123testt5&quot;;
	char *endptr;
	tester_with(trailgarbage);
	tester_cmp(strtoul(trailgarbage, &amp;endptr, 10), ==, 123,
		&quot;Trailing garbage in the numeric string should be ignored&quot;);
	tester_cmp(endptr - trailgarbage, ==, 3,
		&quot;Trailing garbage in the numeric string should not be eaten&quot;);

	// leading garbage
	tester_cmp(strtoul(&quot;test123&quot;, NULL, 10), ==, 0,
		&quot;Leading garbage in the numeric string should result in a failed output&quot;);
}</pre></pre>
<pre><pre class="brush: cpp; title: mytests.cpp; notranslate">#include &quot;tester.h&quot;
#include &quot;stdlibtest.h&quot;

int main(int argc, char *argv[])
{
	Tester t;

	t.addCase(new tests::StdlibTests());

	return t.run(argc &gt; 1);
}</pre></pre>
<p>That&#8217;s all there is to it. Compile along-side the rest of your code (save for your project&#8217;s normal main.cpp) and run it:</p>
<pre><pre class="brush: plain; title: Output; notranslate">
testproject&gt; ./mytests
Running My Stdlib Test Cases

	[PASS] Trailing garbage in the numeric string should be ignored
	[PASS] Trailing garbage in the numeric string should not be eaten
	[PASS] Leading garbage in the numeric string should result in a failed output
Finished running My Stdlib Test Cases 3 / 3

TOTAL: 1 / 1

testproject&gt; ./mytests verbose
Running My Stdlib Test Cases

	With trailgarbage = 123testt5
	[PASS] Trailing garbage in the numeric string should be ignored
		strtoul(trailgarbage, &amp;endptr, 10) == 123
		123 == 123

	[PASS] Trailing garbage in the numeric string should not be eaten
		endptr - trailgarbage == 3
		3 == 3

	[PASS] Leading garbage in the numeric string should result in a failed output
		strtoul(&quot;test123&quot;, NULL, 10) == 0
		0 == 0

Finished running My Stdlib Test Cases 3 / 3

TOTAL: 1 / 1

</pre></pre>
]]></content:encoded>
			<wfw:commentRss>http://nathan.ca/2012/06/unit-testing-in-cpp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Facebook&#8217;s Folly and Fedora 17</title>
		<link>http://nathan.ca/2012/06/facebooks-folly-and-fedora-17/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=facebooks-folly-and-fedora-17</link>
		<comments>http://nathan.ca/2012/06/facebooks-folly-and-fedora-17/#comments</comments>
		<pubDate>Mon, 11 Jun 2012 01:27:20 +0000</pubDate>
		<dc:creator>Nathan</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[eigen]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[fedora]]></category>
		<category><![CDATA[folly]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[open source]]></category>

		<guid isPermaLink="false">http://nathan.ca/?p=339</guid>
		<description><![CDATA[When Facebook released Folly last week, I couldn&#8217;t resist taking it for a spin. Even the &#8220;boring&#8221; stuff like strings and vectors are pretty neat, but the dynamic class and subsequent JSON parser are very interesting. What&#8217;s especially refreshing is the unadulterated use of C++11, a liberty that most libraries likely aren&#8217;t able to take. [...]]]></description>
				<content:encoded><![CDATA[<p>When Facebook released <a href="https://github.com/facebook/folly">Folly</a> last week, I couldn&#8217;t resist taking it for a spin. Even the &#8220;boring&#8221; stuff like strings and vectors are pretty neat, but the <code>dynamic</code> class and subsequent JSON parser are very interesting. What&#8217;s especially refreshing is the unadulterated use of C++11, a liberty that most libraries likely aren&#8217;t able to take.</p>
<p><span id="more-339"></span></p>
<p>One thing I&#8217;ve noticed when writing C++ is just how different my mindset is surrounding &#8220;waste&#8221;. In dynamic languages, I don&#8217;t hesitate to build up nested hash maps and concatenate strings liberally where convenient; one could argue even that some languages beg to be treated that way, and that the expressiveness you gain from being able to throw caution to the wind with regards to performance is a virtue.</p>
<p>However, while I&#8217;d readily write some scrappy string concatenations to generate presentable data in say JavaScript, I hesitate about writing the exact same code in C++, thinking twice about the ramifications of copying the string through the various levels of parsing, escaping, and string building, and worrying about the number of times the string is going to have to reallocate and copy; truly micro and premature optimization at its worst. The irony is, of course, that the C++ code would likely be faster than the JavaScript even with dynamic idioms.</p>
<p>So playing around with Folly&#8217;s <code>dynamic</code> class was, in a way, liberating. While I love static typing, indulging in the free-wheeling nature of dynamic C++ was oddly satisfying.</p>
<h3>Fedora</h3>
<p>In order to play around with Folly, I decided to setup a Linux VirtualBox. I launched a 64-bit CentOS 6 ISO, and proceeded to try to get it up to date. I&#8217;m going to spare you excessive details, but let&#8217;s just say I lost an entire afternoon trying to get CentOS to play nicely with VirtualBox (could not get internet or file sharing to work, though I could access Apache from my computer to the VirtualBox and vice versa) and trying to get GCC 4.7 installed. Memories of trying to upgrade CentOS 5 off of PHP 5.1 a half decade after its successor had been released, or trying to get anything past GCC 4.4 installed even on CentOS 6 lingered as I fired up the VM, having worked with CentOS at BSA (where I end up being the de facto sysadmin), but I felt that I&#8217;d still be most productive with an environment I was familiar with.</p>
<p>How wrong I was. After many hours of bashing my head into the wall, wondering how anyone enjoys system administration stuff (I like solving puzzles in my code, not other people&#8217;s), I deleted the virtual hard drive and downloaded Fedora, which I haven&#8217;t used since I ran a server with Fedora Core 1 when it first came out many years ago. What a difference. In the back of my mind, I had always associated Linux with CentOS and thus always unfairly associated Linux with being a pain in the ass. My outlook has changed thanks to Fedora.</p>
<p>Not only does it come with GCC 4.7 out of the box (not to mention PHP 5.4 and probably updated versions of just about everything else), but VirtualBox&#8217;s shared folder integration and bridge networking worked with just two clicks of the mouse. It basically booted up and was in a state that was ready to use. Compiling Folly from there was a breeze, as all of its dependencies were available in <code>yum</code>. While I&#8217;m still getting used to <code>systemd</code> and some other things that are different, Fedora thus far has actually been pretty enjoyable to use.</p>
<h3>Eigen</h3>
<p>While on the topic of awesome open source stuff, I want to give a shout-out to <a href="http://eigen.tuxfamily.org/index.php?title=Main_Page">Eigen</a>. If you&#8217;re ever doing linear algebra (not that I do very often), Eigen is absolutely fantastic. It&#8217;s highly portable, has no dependencies, and is entirely contained in header files, meaning you don&#8217;t need to compile a library first. It&#8217;s also LGPL, which I think is the most sensible for a library like this.</p>
<p>While some may balk at their use of operator overloading, it&#8217;s actually highly enjoyable to work with. Check out the ease of <a href="http://eigen.tuxfamily.org/dox/TutorialLinearAlgebra.html">solving a system of equations</a>.</p>
<p>When I first saw it, I was trying to figure out why they didn&#8217;t have a better getting started guide for the library itself. Then I realized that the code they provided compiled as-is and that there wasn&#8217;t anything else to do, and no platform-dependent intricacies. It&#8217;s also incredibly fast execution wise, at least if you&#8217;re comparing it to Matlab as I was. I&#8217;d go as far as to say that C++ with Eigen is both more enjoyable to code and more practical to use than Matlab.</p>
<h3>Thank You</h3>
<p>So, thank you to everyone working on Eigen, Folly, Fedora, and of course all of the technologies upon which these are built, for making available such incredibly useful building blocks for the rest of us.</p>
<p>There exists an opportunity here for a service that lets people donate to multiple open source projects all at once, like a bundle site for open source stuff. A way to make donations more as a thank you than a financial contribution, to reward open source contributors while also allowing people to find new projects that they may otherwise never discover based on other people&#8217;s donations.</p>
<div style="display:none;"><pre class="brush: cpp; title: ; notranslate"> </pre></div>
]]></content:encoded>
			<wfw:commentRss>http://nathan.ca/2012/06/facebooks-folly-and-fedora-17/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Living in Canada? Check Out Well.ca</title>
		<link>http://nathan.ca/2012/05/welcome-to-the-21st-century-canada/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=welcome-to-the-21st-century-canada</link>
		<comments>http://nathan.ca/2012/05/welcome-to-the-21st-century-canada/#comments</comments>
		<pubDate>Wed, 16 May 2012 00:41:16 +0000</pubDate>
		<dc:creator>Nathan</dc:creator>
				<category><![CDATA[Cool Stuff]]></category>
		<category><![CDATA[canada]]></category>
		<category><![CDATA[well.ca]]></category>

		<guid isPermaLink="false">http://nathan.ca/?p=329</guid>
		<description><![CDATA[I recently discovered Guelph-based Well.ca and want to share the word: Their service rocks. I placed an order for shampoo and some other stuff on Saturday, about $15 with free shipping. They processed it and sent me a tracking number for it Monday evening, and the parcel was delivered in my mailbox at 8:35am Tuesday [...]]]></description>
				<content:encoded><![CDATA[<p>I recently discovered Guelph-based <a href="http://well.ca/">Well.ca</a> and want to share the word: Their service rocks.</p>
<p>I placed an order for shampoo and some other stuff on Saturday, about $15 with free shipping. They processed it and sent me a tracking number for it Monday evening, and the parcel was delivered in my mailbox at 8:35am Tuesday morning, all neatly packed and wrapped up in recyclable paper and boxing.</p>
<p><span id="more-329"></span></p>
<p>American readers, particularly Amazon Prime customers, may be wondering &#8220;so what?&#8221;, but fellow Canadians should share my joy in finally having services like this up here.</p>
<p>Amazon might as well not exist in Canada. Amazon.ca carries so little that it&#8217;s not worth checking. And Amazon.com? If you&#8217;re lucky enough for the product to even ship to Canada, it&#8217;s not unusual to see $75 of shipping costs on a $20 order.</p>
<p>Honestly, the way US companies ship to Canada you would think we were separated by an ocean and were nothing but tundra; I can see New York from my balcony on a clear day, so I can tell you, it&#8217;s not that far.</p>
<p>All this to say, if you&#8217;re Canadian, go check out Well.ca. The two orders I&#8217;ve placed with them have been awesome experiences &#8211; competitive prices with free and fast shipping by Canada Post, everything you could ask for.</p>
<p>An honorary mention goes out to <a href="http://staples.ca/">Staples.ca</a>, who also recently introduced free next-day shipping. <a href="http://www.theglobeandmail.com/report-on-business/what-keeps-online-retail-in-canada-from-clicking/article2430484/">Apparently</a> <a href="http://shop.ca">Shop.ca</a> is going to start competing for Canadian online consumerism now too. Only a few years late, Canada, but we&#8217;re getting there.</p>
]]></content:encoded>
			<wfw:commentRss>http://nathan.ca/2012/05/welcome-to-the-21st-century-canada/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HTML5 Helicopter</title>
		<link>http://nathan.ca/2012/04/html5-helicopter/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=html5-helicopter</link>
		<comments>http://nathan.ca/2012/04/html5-helicopter/#comments</comments>
		<pubDate>Mon, 30 Apr 2012 02:53:34 +0000</pubDate>
		<dc:creator>Nathan</dc:creator>
				<category><![CDATA[Fun Stuff]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[html5 helicopter]]></category>
		<category><![CDATA[michelle]]></category>

		<guid isPermaLink="false">http://nathan.ca/?p=313</guid>
		<description><![CDATA[My girlfriend, Michelle, is spending this summer learning to code with the intention of creating a startup. She finished her last exam of the year on Thursday (analytical chemistry) and has already started pursuing programming. Prior to this weekend, Michelle had dabbled in PHP and HTML/CSS here and there, and had a one-semester class in [...]]]></description>
				<content:encoded><![CDATA[<p>My girlfriend, Michelle, is spending this summer learning to code with the intention of creating a startup. She finished her last exam of the year on Thursday (analytical chemistry) and has already started pursuing programming.</p>
<p>Prior to this weekend, Michelle had dabbled in PHP and HTML/CSS here and there, and had a one-semester class in Matlab for her Chemistry program. So when she said she wanted to learn Javascript this weekend, I thought that writing an old-school helicopter game using Canvas in HTML5 and getting it live by the end of the weekend would be a reasonable goal.</p>
<p>Always looking to impress &#8211; and quite frankly, from my perspective learning Javascript is easier, or at least way more fun, than writing three chemistry exams in four days &#8211; here it is: <a href="http://html5helicopter.com/">HTML5 Helicopter</a>.</p>
<p><span id="more-313"></span></p>
<p>This is definitely my new favorite game. My high score is <strike>87</strike> <strike>131</strike> 202.</p>
<p>For this one, I had to take on the dreaded product manager role; it was incredibly frustrating not being allowed to write or talk about code, and having to instead provide high-level constructive feedback and wait while Google answered questions to which I knew the answer.</p>
<p>That&#8217;s all part of the learning process, though, and I myself learned a valuable lessons: not being able to do real work invokes an overwhelming feeling of helplessness and uselessness all at once, and is not something I would wish upon my greatest enemy. But the old adage that if you want something done right, you have to do it yourself is nowhere near as accurate as I had previously believed.</p>
]]></content:encoded>
			<wfw:commentRss>http://nathan.ca/2012/04/html5-helicopter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Say Hello to Donut Bot, BSA&#8217;s Campfire Companion</title>
		<link>http://nathan.ca/2012/04/say-hello-to-donut-bot/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=say-hello-to-donut-bot</link>
		<comments>http://nathan.ca/2012/04/say-hello-to-donut-bot/#comments</comments>
		<pubDate>Tue, 10 Apr 2012 15:06:33 +0000</pubDate>
		<dc:creator>Nathan</dc:creator>
				<category><![CDATA[BSA]]></category>
		<category><![CDATA[Fun Stuff]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[bsa]]></category>
		<category><![CDATA[donut-bot]]></category>
		<category><![CDATA[nodejs]]></category>

		<guid isPermaLink="false">http://nathan.ca/?p=307</guid>
		<description><![CDATA[At BuySellAds, we&#8217;re spread out geographically all around the world, across 10 cities in 5 countries. Sometimes in the midst of overhauling our product we need some digital fun to help strengthen our team. So one morning while I was in a holding pattern waiting on a couple of UI screens for BSA v3, I [...]]]></description>
				<content:encoded><![CDATA[<p>At <a href="http://buysellads.com/">BuySellAds</a>, we&#8217;re spread out geographically all around the world, across 10 cities in 5 countries. Sometimes in the midst of <a href="http://blog.buysellads.com/2012/03/version-3-released/">overhauling our product</a> we need some digital fun to help strengthen our team.</p>
<p>So one morning while I was in a holding pattern waiting on a couple of UI screens for BSA v3, I whipped up our very own Donut Bot to hang out with us in <a href="http://campfirenow.com/">Campfire</a>.</p>
<p><span id="more-307"></span></p>
<p>How does it work? In its simplest form, the Donut Bot allows for team members to acknowledge favors or good work by sharing donuts. Just type <code>!give 10 Nathan for writing the Donut Bot</code> and the transfer is complete.</p>
<p>But it doesn&#8217;t end there. The Donut Bot also offers a roulette wheel for anyone hoping to increase their donut count. Indicate your bet by typing <code>!roulette 10 red</code>. It accepts red, black, even, odd, hi, lo, and any number straight-up. When all bets are in, one person types <code>!spin</code> to let it fly. As a single-zero table, you&#8217;re better off with us than in Vegas.</p>
<p>The nature of gambling has proven interesting at BSA. For starters, many of us (myself included) are compulsive gamblers who should never set foot in a casino. Almost 1500 wagers have been placed since the bot took flight on March 1, with 250 of those on the first day alone. Donut bankruptcy has been reached at least a dozen times. Lesson learned.</p>
<p>Once the initial novelty wore off, though, we reset the totals, and upped the stakes, establishing a lottery at the end of March, where donuts were tickets. <code>!leaderboard</code> lists the current donut leaders, and <code>!donuts</code> indicates your own donut count. Of course, we used our very own <code>getAds</code> function from our ad code to pick the winner of the lottery.</p>
<p>All in all, the dynamic of sharing donuts has been great. Between bonding over &#8220;we&#8217;re in it together, double or nothing&#8221; bets, helping each other out of donut bankruptcy, and in general just rewarding good deeds, the Donut Bot has been welcomed to our team with open arms.</p>
<p>I&#8217;m releasing the code in hopes that other remote teams can enjoy what we&#8217;ve been enjoying for the past month. It was put together hastily (we&#8217;ve got a ton of great stuff going on at BSA that keeps me busy), and I&#8217;m far from an expert in Node.js, so it may not be a shining example of how to write a Campfire bot, but it gets the job done.</p>
<p>It uses the <a href="https://github.com/tristandunn/node-campfire">node-campfire</a> library to interface with Campfire. I had to patch it to automatically reconnect to rooms when Campfire drops the connection, but this actually got fixed before I had a chance to share my patch upstream, which is good to see. It also uses <a href="https://github.com/felixge/node-dirty">node-dirty</a> to store the donut counts. More info on setting up is available in the README file.</p>
<p><a href="https://github.com/buysellads/donut-bot">Get the code from BSA&#8217;s GitHub.</a></p>
<div style="display:none;"><pre class="brush: cpp; title: ; notranslate"> </pre></div>
]]></content:encoded>
			<wfw:commentRss>http://nathan.ca/2012/04/say-hello-to-donut-bot/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introducing SDFRY, The Modern Programming Language</title>
		<link>http://nathan.ca/2012/04/introducing-sdfry-the-modern-programming-language/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=introducing-sdfry-the-modern-programming-language</link>
		<comments>http://nathan.ca/2012/04/introducing-sdfry-the-modern-programming-language/#comments</comments>
		<pubDate>Sun, 01 Apr 2012 13:36:26 +0000</pubDate>
		<dc:creator>Nathan</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[sdfry]]></category>
		<category><![CDATA[startthemonthright]]></category>

		<guid isPermaLink="false">http://nathan.ca/?p=280</guid>
		<description><![CDATA[Backstory Programming languages have stagnated. 1958 was a great year for language development, as was 1995, depending on who you ask. The only problem is 17 years have passed since then and we&#8217;re still trying to shoe-horn software development principles into languages not built for them. It seems that we&#8217;re primed for a revolution. Not [...]]]></description>
				<content:encoded><![CDATA[<h4>Backstory</h4>
<p>Programming languages have stagnated. 1958 was <a href="http://en.wikipedia.org/wiki/Fortran">a</a> <a href="http://en.wikipedia.org/wiki/Lisp_(programming_language)">great</a> <a href="http://en.wikipedia.org/wiki/ALGOL">year</a> for language development, as was 1995, <a href="http://php.net/">depending</a> <a href="http://www.java.com/en/">on</a> <a href="http://www.ruby-lang.org/en/">who</a> <a href="http://en.wikipedia.org/wiki/Javascript">you</a> ask. The only problem is 17 years have passed since then and we&#8217;re still trying to shoe-horn software development principles into languages not built for them.</p>
<p>It seems that we&#8217;re primed for a revolution. Not one rooted in languages <a href="http://www.python.org/">picking</a> <a href="http://www.haskell.org/haskellwiki/Haskell">up</a> <a href="http://www.erlang.org/">steam</A> despite being older than the average Valley CTO, but new languages that <a href="http://coffeescript.org/">make</a> <a href="http://golang.org/">us</a> <a href="http://code.google.com/p/php-snow/"><em>really</em></a> <a href="http://www.dartlang.org/">think</a>.</p>
<p>Thus, I introduce <strong>SDFRY</strong> (pronounced &#8220;super deep fry&#8221;) that strives to optimize writing software for humans, not for computers, named after its fundamental rule: <strong>S</strong>eriously, <strong>D</strong>on&#8217;t <strong>F</strong>reaking <strong>R</strong>epeat <strong>Y</strong>ourself. Designed without buzz-words like &#8220;dynamically typed&#8221; or &#8220;purely functional&#8221;, SDFRY fills a gaping void by being a pragmatic every-day language built for developers.</p>
<p>Behold the power of a truly expressive language that eliminates the dry aspects of programming.</p>
<h4>Demo</h4>
<p><a href="/demo/sdfry-connect-four">Play Connect Four</a> | <a href="/code/sdfry-connect-four">View Code</a></p>
<p><span id="more-280"></span></p>
<h4>The Important Stuff</h4>
<p>SDFRY starts by eliminating the repetition of boring syntax that makes code harder to write and even harder to read. The following rules shall be enforced by the compiler:</p>
<ul class="disc">
<li>All whitespace is significant. Indentation will be performed by a tab (<code>\t</code>), and at most two tabs may be present on any line of code to avoid repetition. Did you know that almost 40% of all Python code is wasted as whitespace?</li>
<li>There shall be no parentheses for function calls or conditions. They&#8217;re repetitive, unnecessary, and unnatural. The compiler knows that it&#8217;s a function as much as the developer does.</li>
<li>Strings begin and end with a tilde (<code>~</code>), which doubles for string concatenation, and the backtick (<code>`</code>) escapes strings for nesting variables. Strings can also end with a newline. This means that when you finish a line with a string, you don&#8217;t have to close the quote; much like the elimination of semicolons in other modern languages, using both a newline and closing quote to signify the end of a string is wasteful. The decision to use a tilde instead of a quote was to avoid the masses coming from inferior languages crying about supposed &#8220;imbalanced quotes.</li>
<li>Functions are declared as a token followed by a colon (<code>:</code>), and anonymous functions are declared simply by a double colon (<code>::</code>). Every competent developer would know what you meant if you removed the millions of <code>def</code>&#8216;s, <code>function</code>&#8216;s, <code>fn</code>&#8216;s, and <code>func</code>&#8216;s from your code. The money operator (<code>$</code>) returns from a function, though single expression anonymous functions automatically return.</li>
<li>The comma operator (<code>,</code>) behaves identically to the newline, allowing developers to put together as many expressions on a single line as desired.</li>
</ul>
<h4>Operators and Constructs</h4>
<p>Often, developers are forced to write caveman-like statements like <code>if (hungry()) eatFood();</code> due to limitations in the language. In SDFRY, conditions can be written in prefix or infix notation. <code>eatFood if hungry</code> would likely be optimal in this case. And, in the interest of not repeating ourselves over, and over, and over again, synonymous constructs exist to better match the way developers think:</p>
<ul class="disc">
<li><strong>If constructs</strong>: <code>if</code>, <code>assuming</code>, <code>given</code>, <code>when</code>, <code>supposing</code>, <code>whenever</code>, <code>wherever</code></li>
<li><strong>Not-If constructs</strong>: <code>unless</code>, <code>notwithstanding</code>, <code>lest</code></li>
<li><strong>Else clauses</strong>: <code>else</code>, <code>then</code> (for not-if), <code>otherwise</code></li>
<li><strong>Always-true constructs</strong>: <code>always</code>, <code>whatever</code></li>
<li><strong>Loop constructs</strong>: <code>while</code>, <code>until</code>, <code>for</code>, <code>loop</code>, <code>repeat-until</code>, <code>till</code>, <code>do-while</code></li>
<li><strong>Infinite loop constructs</strong>: <code>do</code>, <code>repeat</code>, <code>forever</code>, <code>do-forever</code></li>
</ul>
<p>One of the primary reasons bad languages require explicit syntax for calling functions or accessing objects is likely the desire to keep the syntax context-free. This makes it easier for compilers to read code, but it doesn&#8217;t always fit with developers&#8217; intentions. As already noted, functional calls are first class citizens in SDFRY. To extend on this, object access is syntactically identical to a function call; once again, the compiler knows whether your variable is an object or a function, and so does the developer.</p>
<p>Thus, in order to <code>solve</code> a <code>Quadratic q</code>, you can just say <code>q solve</code>. The standard <code>-&gt;</code> operator also exists to dereference members in SDFRY, but with opposite semantics to its use in C/C++ where it is simply wrong. The <code>-&gt;</code> operator now points to the object and can be run either way, e.g. <code>addClass hovered -&gt; header</code> or <code>header &lt;- addClass hovered</code>, or <code>write ~Hello World~ -&gt; document</code>.</p>
<p>To maintain consistency, the assignment operator also works both ways, with <code>=</code> and <code>:=</code> being traditional assignment and <code>=:</code> being reverse assignment, as does function calling, where a space or <code>&lt;=</code> are the traditional convention, and <code>=&gt;</code> passes the argument into a function in reverse. It&#8217;s assumed that despite being available, <code>&lt;-</code>, <code>:=</code> and <code>&lt;=</code> will not be used in favor of the standard space, <code>=</code>, and space respectively, however they are included to provide symetric calling conventions with their respective reverse notation.</p>
<p>Furthermore, second only to the DRY mantra, SDFRY aims to promote convention over configuration wherever it can. A traditional <code>for(var i = 0; i < 9; i++)</code> loop can be written as just <code>for 9:</code>, making the assumption that you wanted to use <code>i</code> as your incrementor. Nested loops will proceed to use <code>j</code>, <code>k</code>, and so-on.</p>
<h4>Functions and Lambda Semantics</h4>
<p>Due to technological limitations, developers have traditionally been required to decide whether they want to wrap something in a lambda or not. In SDFRY, this decision making pain-point has been removed in favor of ease of development: everything is a lambda. The underscore (<code>_</code>) will represent the standard <code>this</code> context, providing a 2x (or 4x depending on your keyboard configuration) key stroke savings with no foreseeable degradation when searching or reading.</p>
<p>Think of the following example in JavaScript: <code>$('header').css('top', $('#header').css('top') + $('#flydown').height());</code>. The need to select header twice is redundant and repetitive. In SDFRY, the equivalent would be: <code>header css top + #flydown height =&gt; _ css top</code> or more traditionally but less idiomatically <code>header css top _ + height -> #flydown</code>.</p>
<p>In this regard, Lisp showed us the power of lambdas but lacked the balls to enforce it everywhere.</p>
<p>Function arguments by default can be accessed with the <code>@</code> operator (referred to as the "argument" operator), and subsequently <code>@2</code>, <code>@3</code>, etc., without needing to specify redundant parameter names, further promoting convention over configuration. The <code>@</code> operator (referred to as the "apply" operator) can also be used to split an array up into arguments to avoid the need for <a href="http://stackoverflow.com/questions/1986896/what-is-the-difference-between-call-and-apply">both</a> <code>call</code> and <code>apply</code>. To ease delegation, a function called without any parameters will be passed its caller's parameters.</p>
<h4>First-class DOM and Scope</h4>
<p>Due to heavy dependence on DOM manipulation both client and server side, SDFRY has made jQuery/Sizzle's <code>$</code> function part of the language. As such, any CSS selector accepted by Sizzle will be accepted as a first-class variable name.</p>
<p>Although are plenty of examples that demonstrate how broken other languages are in this regard, look no further than typical JavaScript: <code>var sidebar = $('#sidebar');</code>. In SDFRY, developers can access <code>#sidebar</code> directly to mean the same thing. This is especially useful with HTML5's new semantic tags such as <code>&lt;header&gt;</code>, as seen above.</p>
<p>The "lambda everywhere" semantic is exceedingly easy to remember, but it does add some complexity to maintaining the call stack and scope as a developer. As such, scope has been completely eliminated from SDFRY. The reason for this fits in with the core principles of the language: if you are reusing a variable name, you are likely repeating yourself. This should be apparent in every day code in old-fashioned languages that make you write things like this: <code>Box::Box(string name, int width, int height) : name(name), width(width), height(height) {}</code>, only to be called with <code>Box box("box", width, height);</code>.</p>
<p>This will likely become a <a href="http://stackoverflow.com/questions/3912089/why-no-generics-in-go">StackOverflow</a> question, so let me make this perfectly clear: there is no intention to introduce scope to SDFRY, and you will without a question thank us later once you have shed the stigma and baggage associated with maintaining scope as a developer. If you think you rely on scope, you are likely writing incorrect code.</p>
<p>Eliminating scope also ties together nicely with the notion that CSS selectors are first class citizens. DOM elements are by definition global; in jQuery, <code>$('#sidebar')</code> is the same everywhere, and consequently so is <code>#sidebar</code> in SDFRY. Instead of railing against this with different semantics for variables, SDFRY embraces it.</p>
<h4>Function Naming</h4>
<p>In order to align with the built-in constructs and to maintain the overall idioms of the language, all functions must provide at least 2 synonyms; ideally, a function should provide adequate synonyms such on any given source file each function is only be called by name once, although this is not always possible. Synonyms shall be defined with the pipe (<code>|</code>) operator, as in this function signature: <code>addClass | classify | appendClass className:</code>.</p>
<p>This ensures that repetitious function calls will not appear on the same page of code to better engage future developers.</p>
<p>Additionally, SDFRY brings name resolution to the 21st century by providing three different resolution approaches. First, of course, functions can be called by name, as in any language. Secondly, function names will be matched by the least number of characters needed to resolve. This means that an object with functions <code>addClass</code> and <code>append</code> can be differentiated by <code>ad</code> and <code>ap</code>. Thirdly, camelCase functions will be resolved by acronym, so <code>e iips</code> will invoke jQuery's <code>event.isImmediatePropagationStopped()</code>, barring any conflicts.</p>
<p>The motivation for the alternate name resolution was the obvious dependence poorly designed languages have on IDEs. Sure, all the major IDEs will already write "isImmediatePropagationStopped" when you type "iips" and hit tab. But to paraphrase some guy on Hacker News: if your IDE makes writing code easier, your language sucks. The corollary is, thus, that bringing these features into the language ensures it will <em>not suck</em> or be held hostage by advanced IDEs that write and refactor code for you. IDEs? What is this, Java? Total non-starter.</p>
<h4>Usage and Deployment</h4>
<p>As SDFRY is an exceptionally high-level language, it will likely compile to many languages with time. The spec implementation has been written to compile to JavaScript for both client and server code, due to its monopoly on the client-side and similarity in semantics (lambdas, loose types, little care for correctness), although it's not unreasonable to assume that in the future it will support languages like PHP (for widespread server-side availability) or Fortran (for performance), thus providing the ultimate <a href="http://www.cs.nott.ac.uk/~cah/G51ISS/Documents/NoSilverBullet.html">silver bullet</a>: developers can write in SDFRY and have the performance-intensive parts compile to Fortran (and then optimized assembly), server-side work done in PHP, and client-side work done in JavaScript for free.</p>
<p>The module system closely resembles that of NodeJS and other scripting languages, but with some modifications to better suit the language. Most notably, there's no <code>require</code> function. Code that needs to be split up into separate files is likely too long. A better solution than splitting your code into multiple files would be to re-think your code and write it better.</p>
<h4>Future Plans</h4>
<p>There exists debate within the community as to whether the standard UNIX way of invoking scripting languages is ideal for a language of this power and expressiveness. Currently, the spec implementation runs the <code>deepfry [file]</code> command, which produces the appropriate files to be run.</p>
<p>Many feel strongly, however, that a REPL would be better suited, with no option to load a file from disk. The code would be typed into the REPL at first, and further modifications could be made accordingly at the prompt. The environment would be responsible for saving the current state when it was closed, and respawning to that same point. This would again take powerful aspects of Lisp and extend on them in a way that Lisp failed to do. Arguably, if you are loading code from a file, you are being repetitious. This will be re-addressed before version 1 is released.</p>
<p>On a brighter note, I'm pleased to announce that we have found a publishing deal for <em>Learn SDFRY the Easy Way</em>; prior to this point, we were having trouble convincing a publisher to print a hard-cover reference book that was only 12 pages including the copyright mumbo jumbo, preface, and author biography. Having an official text should also encourage the widespread adoption of referring to SDFRY developers as <strong>greasers</strong> as opposed to the derogatory SDFRY'ists or fryers.</p>
<h4>Licensing</h4>
<p>Right now, SDFRY is in a <em>private beta</em> only for developers who are awesome. I primarily wrote this so that I could take over the world by myself, but realized that since it's so awesome I have <a href="http://therain.posterous.com/dustin-curtis-single-mistake-with-svbtle">no choice</a> but to share it. But only with people who are worthy, since it <em>guarantees</em> you're going to be great. It will be released for everyone to use soon, once everyone achieves expert programming abilities. If you attempt to clone this in an afternoon and put it on GitHub for everyone to use, well, kudos to you, but expect serious patent litigation. In the meantime, those in the private beta can start changing the world with their unparalleled level of expressiveness.</p>
<p>SDFRY offers an edge for startups so large that they will succeed over everyone else. So if you're not using SDFRY, stop working, and start talking about tools instead. And stop using <a href="http://blog.mailchimp.com/ewww-you-use-php/">bad languages</a>.</p>
<p><strong>UPDATE:</strong> I've received many emails asking about the syntax of comments. At this time, general consensus in the community is that the language is so self-documenting that comments are unnecessary, and as such have been left out of the spec. It's likely that any proposals for comments would be rejected on the basis that they simply repeat the code, however I personally have not ruled them out.</p>
<div style="display:none;"><pre class="brush: cpp; title: ; notranslate"> </pre></div>
]]></content:encoded>
			<wfw:commentRss>http://nathan.ca/2012/04/introducing-sdfry-the-modern-programming-language/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
