<?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>Getting Connected</title>
	<atom:link href="http://dinochiesa.net/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://dinochiesa.net</link>
	<description>Can I connect these pieces?</description>
	<lastBuildDate>Sat, 18 May 2013 01:47:12 +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>You are not an idiot if you use NodeJS</title>
		<link>http://dinochiesa.net/?p=920&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=you-are-not-an-idiot-if-you-use-nodejs</link>
		<comments>http://dinochiesa.net/?p=920#comments</comments>
		<pubDate>Fri, 17 May 2013 15:37:44 +0000</pubDate>
		<dc:creator>dpc</dc:creator>
				<category><![CDATA[Developer]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Node.js]]></category>

		<guid isPermaLink="false">http://dinochiesa.net/?p=920</guid>
		<description><![CDATA[Just saw this. A Youtube rant by Brandon Wirtz clarifying for us all how stupid NodeJS is. From January 2012. Most excellent. Well played. Even the title is deliciously Colbert-esque: &#8220;Node.JS Is Stupid And If You Use It So Are You&#8221;. Highly Recommended if you like nerd rants, &#8230; <a class="smt-continue" href="http://dinochiesa.net/?p=920">Continue reading <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Just saw this. A Youtube rant by Brandon Wirtz clarifying for us all how stupid NodeJS is.  From January 2012.  </p>
<p><iframe width="560" height="315" src="http://www.youtube.com/embed/1e1zzna-dNw?hl=en_US" frameborder="0" allowfullscreen></iframe></p>
<p>Most excellent. Well played. Even the title is deliciously <a href='http://colbertnation.com/'>Colbert-esque</a>: <span style='font-weight:bold;'>&#8220;Node.JS Is Stupid And If You Use It So Are You&#8221;.</span>  Highly Recommended if you like nerd rants, and I mean that in the best way.  </p>
<p>Even so, I disagree. Mostly I don&#8217;t disagree with the specific points Mr Wirtz makes, but I do disagree that those points are important, and I also disagree with his conclusion. Be assured: You are  not an idiot if you use NodeJS. </p>
<p>Mr Wirtz&#8217;s main point is that NodeJS is based on JavaScript, which historically has been slow. Very slow, when compared to C/C++, pretty slow when compared to a modern Java or C#.  JavaScript running in v8, which is what you get with NodeJS, is Fast fast FAST compared to JavaScript from 1997 running in an interpreter. But even so it is still has been slow compared to other options like C and Java.  </p>
<p>So, why is this not a disqualifier? </p>
<p>First, lately, v8 micro-benchmarks (<a href='http://www.stefankrause.net/wp/?p=144'>example 1</a>, <a href='http://www.redcode.nl/blog/2012/07/java-speed-of-math/'>example 2</a>) are showing that JavaScript can match the performance of C or Java, or even beat the performance of Java. I don&#8217;t put much stock in micro-benchmarks, because they are too simplistic and the performance they measure is often not indicative of real world scenarios. But even so, these benchmarks seem to show that the performance of JavaScript running on v8 is at least comparable.  JS may not be faster than Java, but at least it is not orders of magnitude slower.  </p>
<p>But more importantly, the performance of JavaScript is not a disqualifier for NodeJS because writing JavaScript is fun. People like it. People like coding in JavaScript, obviously, and many people are attracted to the idea of one-language-everywhere.  Not in the Write-Once-Run-Anywhere (WORA) sense of Java circa 1997, but in the learn-once-write-for-anywhere sense. Just about everyone learns JavaScript. (though many of us learn it poorly. Douglas Crockford has said in his <a href='http://www.youtube.com/watch?v=hQVTIJBZook'>&#8220;Good Parts&#8221; lectures</a>, that the people who know curly-brace languages like Java and C often begin to use JavaScript without actually learning it, because it&#8217;s forgiving, and they can actually limp through.  In general, people don&#8217;t learn JavaScript very rigorously.  As an example of this, not very long ago a respected colleague observed  that JavaScript is &#8220;Not OO&#8221;, and many people have told me JavaScript, the language, is never JIT compiled.) </p>
<p>The obvious comparison is Java, which is a big pain to write. Building something in Java often requires very verbose code, lots of boilerplate, class structure and explicit interface implementation, and so on. The polar opposite of JavaScript.</p>
<p>To my mind, the popularity of NodeJS is similar to the popularity of PHP.  People like both of these flawed environments because they mostly work and they are easy to use. NodeJS may be slow, or it may not be.  But that is sort of irrelevant. Slow compared to what?  It is theoretically slow, but practically speaking, it&#8217;s plenty fast for most applications. It&#8217;s faster than PHP or Ruby. Also, we have an embarrassment of Gigahertz riches and if we choose to frivolously spend CPU cycles on JavaScript engines, so what? </p>
<p>Also, unlike Mr Wirtz, I don&#8217;t care about whether the marketing around NodeJS is accurate or not. They say it&#8217;s really fast, and maybe that&#8217;s not generally true.  But I don&#8217;t worry about that. The bottom line is: people like NodeJS because it&#8217;s nice and easy and friendly and familiar, and fun damnit, and the performance is plenty good enough. </p>
<p>That doesn&#8217;t mean that JavaScript or NodeJS is the answer to all programming questions. It isn&#8217;t. For large projects I&#8217;d be concerned about type integrity (though we can try using <a href='http://www.typescriptlang.org/'>Microsoft&#8217;s TypeScript</a> for that), or the hierarchy of modules. I think npm kindof just punted on that. Also the explosion of modules in npm makes it clear that NodeJS is a technology that is not quite stable. Lots of things are changing, very rapidly. There&#8217;s good and bad there, but surely the relative safety and stability of Java v6 offers a stark comparison. So NodeJS is not the answer to every problem, but it is a good answer to many programming problems.  You&#8217;re not stupid if you use NodeJS. </p>
<p>If I were advising a young aspiring programmer today, I&#8217;d tell them to learn JavaScript and Go. </p>
]]></content:encoded>
			<wfw:commentRss>http://dinochiesa.net/?feed=rss2&#038;p=920</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pet peeve &#8211; NodeJS people, What&#8217;s with &#8220;err&#8221;?</title>
		<link>http://dinochiesa.net/?p=904&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=pet-peeve-nodejs-people-whats-with-err</link>
		<comments>http://dinochiesa.net/?p=904#comments</comments>
		<pubDate>Fri, 17 May 2013 01:19:40 +0000</pubDate>
		<dc:creator>dpc</dc:creator>
				<category><![CDATA[Developer]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Node.js]]></category>

		<guid isPermaLink="false">http://dinochiesa.net/?p=904</guid>
		<description><![CDATA[This is a pet peeve of mine. I think the code is the documentation, and names of variables, functions, and classes used in the code are important. These names communicate the purpose of the things being named. It makes sense that Node&#8217;s package manager is called &#8220;npm&#8221; because &#8230; <a class="smt-continue" href="http://dinochiesa.net/?p=904">Continue reading <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This is a pet peeve of mine. </p>
<p>I think <A href='http://www.martinfowler.com/bliki/CodeAsDocumentation.html'>the code is the documentation</A>, and names of variables, functions, and classes used in the code are important. These names communicate the purpose of the things being named. </p>
<p>It makes sense that Node&#8217;s package manager is called &#8220;npm&#8221; because that denotes &#8220;node package manager.&#8221;  Easy to decipher, and if you know what a package manager is, then you know what npm is. No need to think about it. </p>
<p>The names of variables in any particular language are also important. <span style='font-family: Consolas, Courier;'>i</span> and  <span style='font-family: Consolas, Courier;'>j</span> indicate loop indices. Variables like  <span style='font-family: Consolas, Courier;'>req</span> and  <span style='font-family: Consolas, Courier;'>res</span> might indicate a request and a response object, respectively, though in many cases I would prefer to just see <span style='font-family: Consolas, Courier;'>request</span> and  <span style='font-family: Consolas, Courier;'>response</span>. </p>
<h2>Ok</h2>
<pre style="margin-bottom:16px;font-size:12px;color: #ffffff; background-color: #000000;">
  <span style="color: #00ffff;">var</span> <span style="color: #eedd82;">http</span> = require(<span style="color: #e066ff; background-color: #1c1c1c;">'http'</span>),
      server = http.createServer();

  <span style="color: #00ffff;">function</span> <span style="color: #4876ff;">handleRequest</span>(<span style="color: #eedd82;">req</span>, <span style="color: #eedd82;">res</span>) {
    res.writeHead(200, { <span style="color: #e066ff; background-color: #1c1c1c;">'content-type'</span>: <span style="color: #e066ff; background-color: #1c1c1c;">'text/plain'</span>});
    res.write(<span style="color: #e066ff; background-color: #1c1c1c;">'Hello, World!'</span>);
    res.end();
  }

  server.on(<span style="color: #e066ff; background-color: #1c1c1c;">'request'</span>, handleRequest);

  server.listen(8080);
</pre>
<h2>Better</h2>
<pre style="margin-bottom:16px;font-size:12px;color: #ffffff; background-color: #000000;">
  <span style="color: #00ffff;">var</span> <span style="color: #eedd82;">http</span> = require(<span style="color: #e066ff; background-color: #1c1c1c;">'http'</span>),
      server = http.createServer();

  <span style="color: #00ffff;">function</span> <span style="color: #4876ff;">handleRequest</span>(<span style="color: #eedd82;">request</span>, <span style="color: #eedd82;">response</span>) {
    response.writeHead(200, { <span style="color: #e066ff; background-color: #1c1c1c;">'content-type'</span>: <span style="color: #e066ff; background-color: #1c1c1c;">'text/plain'</span>});
    response.write(<span style="color: #e066ff; background-color: #1c1c1c;">'Hello, World!'</span>);
    response.end();
  }

  server.on(<span style="color: #e066ff; background-color: #1c1c1c;">'request'</span>, handleRequest);

  server.listen(8080);
</pre>
<p>Or, if you look at Java, something like an exception is usually named with an e, or an exc, sometimes followed by a numeric suffix. Like so: </p>
<pre style="margin-bottom:16px;font-size:12px;color: #ffffff; background-color: #000000;">
    <span style="color: #00ffff;">try</span> {
        <span style="color: #98fb98;">arf</span> <span style="color: #eedd82;">me</span> = <span style="color: #00ffff;">new</span> <span style="color: #98fb98;">arf</span>(args);
        <span style="color: #1e90ff;">me</span>.Run();
    }
    <span style="color: #00ffff;">catch</span> (<span style="color: #1e90ff;">java</span>.<span style="color: #1e90ff;">lang</span>.<span style="color: #98fb98;">Exception</span> <span style="color: #eedd82;">exc1</span>) {
        System.out.println(<span style="color: #e066ff; background-color: #1c1c1c;">"Exception:"</span> + exc1.toString());
        exc1.printStackTrace();
    }
</pre>
<p>It makes sense. </p>
<h2>To err is human.</h2>
<p>Which brings me to the point. There are <a href='http://nodetuts.com/02-callback-pattern.html'>numerous</a> examples showing how to code a callback function in Node, that look like this: </p>
<pre style="margin-bottom:16px;font-size:12px;color: #ffffff; background-color: #000000;">
  fs.readFile(<span style="color: #e066ff; background-color: #1c1c1c;">'/etc/passwd'</span>, <span style="color: #00ffff;">function</span> (<span style="color: #eedd82;">err</span>, <span style="color: #eedd82;">results</span>) {
    <span style="color: #00ffff;">if</span> (err) {
      handleError(err);
      <span style="color: #00ffff;">return</span>;
    }
    console.log(<span style="color: #e066ff; background-color: #1c1c1c;">'File contents:'</span>, results);
  });
</pre>
<p>As you can see, the variable that holds the error is called <span style='font-family: Consolas, Courier;'>err</span>.  Now if English is one of the languages you use, which is probably true if you are reading this, then you probably know that &#8220;error&#8221; is a noun and &#8220;err&#8221; is a verb.  </p>
<p>Using the verb form of that word as a &#8220;shorthand&#8221; for the noun is confusing to code reviewers, and therefore wrong.  Yes, everyone is assumed to know that &#8220;err&#8221; really refers to an error, but everyone incurs a small but not negligible mental burden in reconciling that difference, every time they look at that variable. Why?  To save 2 characters?  If really we are economizing on variable name length, and I respect efforts to do so, then why not just use the letter e, which is often used to represent errors or exceptions?  </p>
<p>Either <span style='font-family: Consolas, Courier;'>e</span> or <span style='font-family: Consolas, Courier;'>error</span> is preferred over <span style='font-family: Consolas, Courier;'>err</span>. </p>
<p>An error does not become truth by reason of multiplied propagation, nor does truth become error because nobody sees it. &#8211; Mahatma Gandhi </p>
]]></content:encoded>
			<wfw:commentRss>http://dinochiesa.net/?feed=rss2&#038;p=904</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pretty printing XML from within emacs</title>
		<link>http://dinochiesa.net/?p=891&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=pretty-printing-xml-from-within-emacs</link>
		<comments>http://dinochiesa.net/?p=891#comments</comments>
		<pubDate>Tue, 30 Apr 2013 14:46:09 +0000</pubDate>
		<dc:creator>dpc</dc:creator>
				<category><![CDATA[Developer]]></category>
		<category><![CDATA[emacs]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://dinochiesa.net/?p=891</guid>
		<description><![CDATA[I use emacs. Can&#8217;t help it. Been using it for years, and the cost of switching to something &#8220;more modern&#8221; has never reached the payoff threshold. Today I want to show you how I pretty-print XML from within emacs. The elisp for the pretty-printing logic was originally from &#8230; <a class="smt-continue" href="http://dinochiesa.net/?p=891">Continue reading <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I use emacs. Can&#8217;t help it. Been using it for years, and the cost of switching to something &#8220;more modern&#8221; has never reached the payoff threshold. </p>
<p>Today I want to show you how I pretty-print XML from within emacs. </p>
<p><iframe width="548" height="342" src="http://www.youtube.com/embed/p7YJ40FoV4M?hl=en_US" frameborder="0" allowfullscreen></iframe></p>
<p>The elisp for the pretty-printing logic was originally from<br />
a <a href='http://stackoverflow.com/a/5198243/48082'>stackoverflow answer</a>. I modified it slightly and post it here:  </p>
<link href="http://yandex.st/highlightjs/7.0/styles/default.min.css" rel="stylesheet">
    <script src="http://yandex.st/highlightjs/7.0/highlight.min.js"></script></p>
<p>    <script type='text/javascript'>  $(document).ready(function() {
    $.ajax({type: "GET",
            url: "https://api.github.com/gists/5489021",
            dataType: "jsonp",
            success: function(resp) {
              var contents = resp.data.files['xmlpretty.el'].content;
              //console.log(contents);
              $('#c5489021').html(contents);
              $('#c5489021').each(function(i, e) {
                hljs.highlightBlock(e);
              });
            }});
  }); 
</script></p>
<div id='d1' style='max-height:420px;border:1px dotted black;overflow:auto;padding:0;'>
<pre style='margin:0;padding:0;'>
        <code id='c5489021' style='font-size:10px;margin:0;padding:2px;'>
        </code>
      </pre>
</p></div>
<p>Thanks to <A href='https://github.com/isagalaev'>isagalaev</a> for <a href='https://github.com/isagalaev/highlight.js'>highlight.js</a>. </p>
]]></content:encoded>
			<wfw:commentRss>http://dinochiesa.net/?feed=rss2&#038;p=891</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>emacs dired fixups</title>
		<link>http://dinochiesa.net/?p=868&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=emacs-dired-fixups</link>
		<comments>http://dinochiesa.net/?p=868#comments</comments>
		<pubDate>Thu, 14 Mar 2013 00:17:08 +0000</pubDate>
		<dc:creator>dpc</dc:creator>
				<category><![CDATA[Developer]]></category>
		<category><![CDATA[elisp]]></category>
		<category><![CDATA[emacs]]></category>
		<category><![CDATA[screencast]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://dinochiesa.net/?p=868</guid>
		<description><![CDATA[For the geeks and dinosaurs among us**, A quick post on dired fixups I use for emacs. I like to sort by name, size, date, and extension. Dired sorts by name and time I think, by default. For other options you need to manually enter the ls sorting &#8230; <a class="smt-continue" href="http://dinochiesa.net/?p=868">Continue reading <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>For the geeks and dinosaurs among us**, A quick post on dired fixups I use for emacs. I like to sort by name, size, date, and extension.  Dired sorts by name and time I think, by default.  For other options you need to manually enter the ls sorting options.  This elisp teaches dired to sort by size and extension as well.  </p>
<link href="http://yandex.st/highlightjs/7.0/styles/default.min.css" rel="stylesheet">
    <script src="http://yandex.st/highlightjs/7.0/highlight.min.js"></script><br />
    <script  src='https://raw.github.com/jamesward/github-files/master/src/main/javascript/github-files.js'></script></p>
<p>    <script type='text/javascript'>$(document).ready(function() {
  $.getGithubFile("DinoChiesa",
                  "dpchiesa-elisp",
                  "7f8d34c30be6a044deeda3099a129b4c54c12055",
    function(contents) {
      console.log(contents);
      $('#c7f8d34c30be6a044deeda3099a129b4c54c12055').html(contents);
      $('#c7f8d34c30be6a044deeda3099a129b4c54c12055').each(function(i, e) {
        hljs.highlightBlock(e);
      });
    });
}); </script></p>
<div id='d1' style='max-height:420px;border:1px dotted black;overflow:auto;padding:0;'>
<pre style='margin:0;padding:0;'>
        <code id='c7f8d34c30be6a044deeda3099a129b4c54c12055' style='font-size:10px;margin:0;padding:2px;'>
        </code>
      </pre>
</p></div>
<p>In action:</p>
<p><iframe width="560" height="315" src="http://www.youtube.com/embed/Bdfpbmwm96k?hl=en_US" frameborder="0" allowfullscreen></iframe></p>
<p>Thanks to <A href='https://github.com/isagalaev'>isagalaev</a> and <a href='https://github.com/jamesward/github-files/blob/master/src/main/javascript/github-files.js'>jamesward</a> for <a href='https://github.com/isagalaev/highlight.js'>highlight.js</a> and <a href='https://github.com/jamesward/github-files/blob/master/src/main/javascript/github-files.js'>github-files.js</a> respectively. </p>
<p>**Someone today told me that emacs is a throwback and I am a dinosaur for continuing to use it.  He said he used emacs in the past, but now he uses &#8220;more modern&#8221; tools.  I&#8217;m a little suspicious because his first excuse for not using emacs was, &#8220;I run Windows&#8221;. </p>
]]></content:encoded>
			<wfw:commentRss>http://dinochiesa.net/?feed=rss2&#038;p=868</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>I hate Node.js</title>
		<link>http://dinochiesa.net/?p=831&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=i-hate-node-js</link>
		<comments>http://dinochiesa.net/?p=831#comments</comments>
		<pubDate>Sun, 13 Jan 2013 03:19:09 +0000</pubDate>
		<dc:creator>dpc</dc:creator>
				<category><![CDATA[Developer]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[MacOS]]></category>
		<category><![CDATA[Node.js]]></category>

		<guid isPermaLink="false">http://dinochiesa.net/?p=831</guid>
		<description><![CDATA[Node.js is cool, so they say. Everybody&#8217;s doing it, so I hear. I hate it. Node.js has wasted so much of my time, I don&#8217;t think I will ever forgive it. But take that with a grain of salt. I don&#8217;t use Node.js for its intended purpose, which &#8230; <a class="smt-continue" href="http://dinochiesa.net/?p=831">Continue reading <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Node.js is cool, so they say. Everybody&#8217;s doing it, so I hear. </p>
<p>I hate it. Node.js has wasted so much of my time, I don&#8217;t think I will ever forgive it. But take that with a grain of salt. I don&#8217;t use Node.js for its intended purpose, which is server-side Javascript. </p>
<p>What I want is a scripting environment for automation on the local machine. In this <em>particular</em> case, I want to script an FTP session from my bash prompt, I want to script a directory sync. I know I can do this with bash scripting, but I already know Javascript syntax and semantics, so I&#8217;d like to use what I know. It&#8217;s FTP in this case, but in general I want to be able to script arbitrary things on the local machine. </p>
<p>By the way: I can do this on Windows. I can run Javascript programs from the CMD shell, to script an FTP session, automate filesystem operations, launch applications, and a bunch of other things. It&#8217;s really nice. There&#8217;s a whole catalog of COM objects that can be scripted, including obscure stuff like the fax system in Windows, or more  mainstream things like IE settings (like proxies), or IIS administration. Tons of things.  </p>
<p>Of course I could do similar things with Node.js on MacOS, too. The problem is, the Node.js model is designed for server use. Everything is asynchronous. When I retrieve a set of files from an FTP server, and I want to iterate and retrieve each file, I have to do that asynchronously. But I don&#8217;t want it to be asynchronous. Writing asynchronous code lets me get really good throughput on a server. Writing asynchronous code for <em>my</em> purpose just obscures the goal of the code. I want to do this: </p>
<pre style='background-color:#000;color:#EEE;font-size:9pt;'>
    fileList.forEach(<span style="color: #ffffff;">function</span>(<span style="color: #eedd82;">item</span>) {
        <span style="color: #ffffff;">var</span> <span style="color: #eedd82;">modTime</span> = ftp.getModTime(item);
        <span style="color: #ffffff;">if</span> (modTime &gt; lastUpdate) {
            ftp.retrieveFile(item);
        }
    });
</pre>
<p>But I can&#8217;t do that.  No sir.  No I cannot.  I&#8217;m using Node.js.  And because of that, I need this: </p>
<pre style='background-color:#000;color:#EEE;font-size:9pt;'>

    <span style="color: #00ffff;">var</span> <span style="color: #eedd82;">c</span> = 0, <span style="color: #eedd82;">L</span> = flist.length,
        checkIfDone = <span style="color: #00ffff;">function</span>() {
            c++;
            <span style="color: #00ffff;">if</span> (c == L) { next(); }
        };

    fileList.forEach(<span style="color: #00ffff;">function</span>(<span style="color: #eedd82;">item</span>, <span style="color: #eedd82;">ix</span>) {
        <span style="color: #00ffff;">var</span> <span style="color: #eedd82;">localPath</span> = (dir == <span style="color: #e066ff; background-color: #1c1c1c;">'.'</span>) ? item : Path.join(dir, item),
            stat, localMtime = ...,
            remoteMtime = 0;

        <span style="color: #ff3e96;">// </span><span style="color: #ff3e96;">get modification time of the remote file
</span>        sync.ftp.raw.mdtm(localPath, <span style="color: #00ffff;">function</span> (<span style="color: #eedd82;">e</span>, <span style="color: #eedd82;">res</span>) {
            <span style="color: #00ffff;">var</span> <span style="color: #eedd82;">d</span>, <span style="color: #eedd82;">tm</span>;
            <span style="color: #00ffff;">if</span> (e) { }
            <span style="color: #00ffff;">else</span> {
                remoteMtime = <span style="color: #00ffff;">new</span> <span style="color: #98fb98;">Date</span>(res);
                <span style="color: #00ffff;">if</span> (localMtime == 0 || (remoteMtime &gt; localMtime)) {
                    <span style="color: #ff3e96;">// </span><span style="color: #ff3e96;">Retrieve the file using async streams
</span>                    sync.ftp.getGetSocket(localPath, <span style="color: #00ffff;">function</span>(<span style="color: #eedd82;">e</span>, <span style="color: #eedd82;">sock</span>) {
                        <span style="color: #00ffff;">if</span> (e) <span style="color: #00ffff;">return</span> console.error(e);
                        <span style="color: #00ffff;">var</span> <span style="color: #eedd82;">fd</span> = fs.openSync(localPath, <span style="color: #e066ff; background-color: #1c1c1c;">"w+"</span>);

                        <span style="color: #ff3e96;">// </span><span style="color: #ff3e96;">`sock` is a stream. attach events to it.
</span>                        sock.on(<span style="color: #e066ff; background-color: #1c1c1c;">"data"</span>, <span style="color: #00ffff;">function</span>(<span style="color: #eedd82;">p</span>) {
                            fs.writeSync(fd, p, 0, p.length, <span style="color: #1e90ff;">null</span>);
                        });
                        sock.on(<span style="color: #e066ff; background-color: #1c1c1c;">"close"</span>, <span style="color: #00ffff;">function</span>(<span style="color: #eedd82;">e</span>) {
                            <span style="color: #00ffff;">if</span> (e) <span style="color: #00ffff;">return</span> console.error(<span style="color: #00ffff;">new</span> <span style="color: #98fb98;">Error</span>(<span style="color: #e066ff; background-color: #1c1c1c;">"error"</span>));
                            fs.closeSync(fd);
                            checkIfDone();
                        });

                        <span style="color: #ff3e96;">// </span><span style="color: #ff3e96;">The sock stream is paused. Call
</span>                        <span style="color: #ff3e96;">// </span><span style="color: #ff3e96;">resume() on it to start reading.
</span>                        sock.resume();
                    });
                }
                <span style="color: #00ffff;">else</span> {
                    checkIfDone();
                }
            }
        });
    });
</pre>
<p>Can anyone ELSE see why I&#8217;d rather not use an asynchronous-optimized, server-oriented programming environment to script my desktop? </p>
<p>It&#8217;s not Javascript that&#8217;s the problem here. I can grab the v8 Javascript engine and use it to run JS code. That works. The problem is that there are no JS libraries for v8. There&#8217;s no FTP library. There&#8217;s no &#8220;any&#8221; library. The only FTP libraries I&#8217;ve found are Node-compliant. To use it, I have to do Node.js things. Likewise for all the other purposes. There&#8217;s no package manager for JS libraries, except for Node.js. </p>
<p>I think the solution here is for me to learn to use Bash scripting and use CURL. But that&#8217;s a lame solution. It would be nice if MacOS supported Javascript for client-side use, as nicely as Windows does. Because I hate Node.js.</p>
]]></content:encoded>
			<wfw:commentRss>http://dinochiesa.net/?feed=rss2&#038;p=831</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>The way Azure should have done it &#8211; A better Synonyms Service</title>
		<link>http://dinochiesa.net/?p=821&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=the-way-azure-should-have-done-it-a-better-synonyms-service</link>
		<comments>http://dinochiesa.net/?p=821#comments</comments>
		<pubDate>Wed, 02 Jan 2013 19:58:58 +0000</pubDate>
		<dc:creator>dpc</dc:creator>
				<category><![CDATA[Analysis]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[Azure]]></category>
		<category><![CDATA[REST]]></category>

		<guid isPermaLink="false">http://dinochiesa.net/?p=821</guid>
		<description><![CDATA[This is a followup from my previous post, in which I critiqued the simple Synonyms Service available on the Azure Datamarket. To repeat, the existing URI structure for the service is like this: GET https://api.datamarket.azure.com/Bing/Synonyms/GetSynonyms?Query=%27idiotic%27 How would I do things differently? The hostname is just fine &#8211; there&#8217;s &#8230; <a class="smt-continue" href="http://dinochiesa.net/?p=821">Continue reading <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This is a followup from <a href='http://dinochiesa.net/?p=807'>my previous post</a>, in which I critiqued the simple Synonyms Service available on the Azure Datamarket. </p>
<p>To repeat, the existing URI structure for the service is like this:<br />
<code><br />
 GET https://api.datamarket.azure.com/Bing/Synonyms/GetSynonyms?Query=%27idiotic%27<br />
</code></p>
<p>How would I do things differently? </p>
<p>The hostname is just fine &#8211; there&#8217;s nothing wrong with that. So let&#8217;s focus on the URI path and the other parts.<br />
<code><br />
 GET /Bing/Synonyms/GetSynonyms?Query=%27idiotic%27<br />
</code></p>
<p>Here&#8217;s what I would do differently.</p>
<ol>
<li>Simplify. The URI structure should be simpler. Eliminate Bing and  GetSynonyms from the URI path, as they are completely extraneous. Simplify the query parameter. Eliminate the url-encoded quotes when they are not necessary.  Result: <span style='font-family:Consolas,Courier; font-size:10pt;'> GET /Synonyms?w=improved<br />
</span></li>
<li>Add some allowance for versioning.   <span style='font-family:Consolas,Courier; font-size:10pt;'> GET /v1/Synonyms?w=positive<br />
</span></li>
<li>Allow the caller to specify the API Key in the URI. (Eliminate the distorted use of HTTP Basic Auth to pass this information).  <span style='font-family:Consolas,Courier; font-size:10pt;'> GET /v1/Synonyms?w=easy&#038;key=0011EEBB4477</span></li>
</ol>
<p>What this gets you, as an API provider:  </p>
<ol>
<li>
This approach allows users to try the API from a browser or console without registering. The service could allow 3 requests per minute, or up to 30 requests per day, for keyless access. Allowing low-cost or no-cost exploration is critical for adoption.
</li>
<li>The query is as simple as necessary and no simpler. There is no extraneous Bing or GetSynonyms or anything else. It&#8217;s very clear from the URI structure what is being requested. It&#8217;s &#8220;real&#8221; REST. </li>
</ol>
<p>What about multi-word queries? Easy: just URL-encode the space.<br />
<span style='font-family:Consolas,Courier; font-size:10pt;'> GET /v1/Synonyms?w=Jennifer%20Lopez&#038;key=0011EEBB4477</span></p>
<p>There&#8217;s no need to add in url-encoded quotes for <em>every</em> query, in order to satisfy the 20% case where the query involves more than one word.  In fact I don&#8217;t think multi-word would even be 20%. Maybe more like 5%. </p>
<p>For extra credit, do a basic content negotiation that looks at the incoming <span style='font-family:Consolas,Courier; font-size:10pt;'>Accepts</span> header and modifies the format of the result based on that header.  As an alternative, you could include a suffix in the URI path, to indicate the desired output data format, as Twitter and the other big guys do it: </p>
<p><span style='font-family:Consolas,Courier; font-size:10pt;'> GET /v1/Synonyms.xml?w=adaptive&#038;key=0011EEBB4477</span></p>
<p><span style='font-family:Consolas,Courier; font-size:10pt;'> GET /v1/Synonyms.json?w=adaptive&#038;key=0011EEBB4477</span></p>
<p>As an API provider, conforming to a &#8220;pragmatic REST&#8221; approach means you will deliver an API that is immediately familiar to developers regardless of the platform they use to submit requests. That means you have a better chance to establish a relationship with those developers, and  a better chance to deepen that relationship. </p>
<p>That&#8217;s why it&#8217;s so important to get the basic things right. </p>
]]></content:encoded>
			<wfw:commentRss>http://dinochiesa.net/?feed=rss2&#038;p=821</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Azure Synonyms Service &#8211; How NOT to do REST.</title>
		<link>http://dinochiesa.net/?p=807&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=azure-synonyms-service-a-lesson-in-how-not-to-do-rest</link>
		<comments>http://dinochiesa.net/?p=807#comments</comments>
		<pubDate>Wed, 02 Jan 2013 04:02:06 +0000</pubDate>
		<dc:creator>dpc</dc:creator>
				<category><![CDATA[Analysis]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[Azure]]></category>
		<category><![CDATA[REST]]></category>

		<guid isPermaLink="false">http://dinochiesa.net/?p=807</guid>
		<description><![CDATA[Recently, I looked on the Azure data market place (or whatever it&#8217;s called) to see what sort of data services are available there. I didn&#8217;t find anything super compelling. There were a few premium, for-fee services that sounded potentially interesting but nothing that I felt like spending money &#8230; <a class="smt-continue" href="http://dinochiesa.net/?p=807">Continue reading <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Recently, I looked on the Azure data market place (or whatever it&#8217;s called) to see what sort of data services are available there. I didn&#8217;t find anything super compelling. There were a few premium, for-fee services that sounded potentially interesting but nothing that I felt like spending money on before I could try things out. </p>
<p>As I was perusing, I found <a href='http://www.bing.com/community/site_blogs/b/developer/archive/2012/11/01/bing-synonyms-api-now-available-on-windows-azure-marketplace.aspx'>a synonyms service</a>. Nice, but this is nothing earth-shaking. There are already a number of viable, programmable synonyms services out there. Surely <a href='http://Thesaurus.com'>Thesaurus.com</a> has one. I think Wolfram Alpha has one. <a href='http://developer.wordnik.com/'>Wordnik has one</a>. <a href='http://words.bighugelabs.com/'>BigHugeLabs has one</a> that I <a href='https://github.com/DinoChiesa/dpchiesa-elisp/blob/master/thesaurus.el'>integrated with emacs</a>. But let&#8217;s look a little closer.</p>
<p>Let me show you the URL structure for the &#8220;Synonyms&#8221; service available (as <em>&#8220;Community Technical Preview&#8221;</em>!) on Azure.</p>
<p><code></p>
<p>https://api.datamarket.azure.com/Bing/Synonyms/GetSynonyms?Query=%27idiotic%27</p>
<p></code></p>
<p>Oh, Azure Synonyms API, how do I NOT love thee?  Let me count the ways&#8230;</p>
<ol>
<li>There&#8217;s no version number. What if the API gets revised? Rookie mistake.</li>
<li>GetSynonyms?  Why put a verb in the URI path, when the HTTP verb &#8220;GET&#8221; is already implied by the request? Useless redundancy. If I call GET on a URI path with the word &#8220;Synonyms&#8221; in it, then surely I am trying to get synonyms, no? </li>
<li>Why is the word Bing in there at all?  </li>
<li>Notice that the word to get synonyms of, must be passed with the query param named &#8220;Query&#8221;.  Why use Query?  Why not &#8220;word&#8221; or &#8220;term&#8221; or something that vaguely corresponds to the actual thing we&#8217;re trying to do here?  Why pass it as a query param at all?  Why not simply as part of the URL path?</li>
<li>Also notice that the word <em>must be enclosed in quotes</em>, which themselves must be URL-encoded. That seems like an awkward design.
</li>
<li>What you cannot see in that URL is the authentication required. Azure says the authentication is &#8220;HTTP Basic Auth&#8221; which means you pass a username and password pair, joined by a colon then base64 encoded, as an HTTP Header. But&#8230; there is no username and password. Bing/Azure/Microsoft gives you an API Key, not a user name. And there&#8217;s no password. So you need to double the API key then base64 encode *that*, and <em>pretend</em> that it&#8217;s HTTP Basic Auth.
</ol>
<p>&#8212;</p>
<p>If readers aren&#8217;t persuaded that the above are evidence of poor API design, then you might consider heading over to the <a href='http://groups.google.com/group/api-craft'>API Craft</a> discussion group on Google Groups to talk it over. </p>
<p>Alternatively, or in addition, spend some time reading &#8220;the REST Manifesto,&#8221; Roy Fielding&#8217;s <a href='http://www.ics.uci.edu/~fielding/pubs/dissertation/top.htm'>thesis paper</a>, specifically <a href='http://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arch_style.htm'>chapter 5 in that document</a>. It&#8217;s about 18 printed pages, so not too big a commitment. </p>
<p>The problem with releasing a poorly-designed API, is that it can do long-term damage.<br />
As soon as a real developer takes a look at your service, he will not walk, he&#8217;ll RUN away to an alternative service. If your API is a pain to use, or is poorly designed, you are guaranteed to drive developers somewhere else.  And they won&#8217;t come back! They might come just to poke around, but if they see a bad service, like this Synonyms service, they will flee, never to return. They will quickly conclude that you just don&#8217;t get it, and who could blame them? </p>
<p>So learn from Azure&#8217;s mistakes, and learn from the success of others. Take the time to get it right. </p>
<p>And now a word from my sponsor: Apigee offers a Rapid API Workshop service where we can send in experts to collaborate with your team on API design principles and practice. Contact us at <a href='mailto:sales@Apigee.com'>sales@Apigee.com</a> for more information.</p>
]]></content:encoded>
			<wfw:commentRss>http://dinochiesa.net/?feed=rss2&#038;p=807</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>US balks at ITU Treaty; Government vs Big (Internet) Business</title>
		<link>http://dinochiesa.net/?p=799&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=us-balks-at-itu-treaty-government-vs-big-internet-business</link>
		<comments>http://dinochiesa.net/?p=799#comments</comments>
		<pubDate>Mon, 17 Dec 2012 20:11:46 +0000</pubDate>
		<dc:creator>dpc</dc:creator>
				<category><![CDATA[Quickies]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[ITU]]></category>

		<guid isPermaLink="false">http://dinochiesa.net/?p=799</guid>
		<description><![CDATA[At the WCIT in Dubai, the US has refused to sign the ITU Treaty establishing global regulations for dealing with the Internet. ITU is an UN agency, part of a global government or quasi-government effort. This isn&#8217;t conspiracy theory; this is just fact. The UN attempts to establish &#8230; <a class="smt-continue" href="http://dinochiesa.net/?p=799">Continue reading <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<div style='float:right; margin-left:10px;'><A href='http://www.itu.int/en/Pages/default.aspx'><img src='/wp-content/uploads/2012/12/ITUlogo.png' style='width:240px;'></a></div>
<p>At the WCIT in Dubai, the US has refused to sign the ITU Treaty establishing global regulations for dealing with the Internet. </p>
<p><a href='http://www.itu.int/en/Pages/default.aspx'>ITU is an UN agency</a>, part of a global government or quasi-government effort. This isn&#8217;t conspiracy theory; this is just fact. The UN attempts to establish rules governing global behavior.</p>
<p>A number of governments, including China, Russia, Iran, Saudi Arabia, many African nations, and other &#8220;closed&#8221; societies have voted in favor of the ITU Treaty, which includes provisions for how the Internet can be regulated. In short, these are not lovers of liberty. The concerns about their interests in restricting the public Internet <a href='http://www.ipbrief.net/2012/06/24/the-itu-icann-and-control-over-the-internet/'>are not new</a>.</p>
<p>The US has voted against the treaty. Certainly the commercial interests in the US, including companies like Google who are focused on advertising, and content-providers like Disney, are against the regulation of the global network as it restricts their access to vast new oceans of potential customers. I can understand the reluctance of some countries to open up to the &#8220;assault&#8221; on their people of US-oriented commercial interests via the public network. I can understand it but I don&#8217;t condone it.</p>
<p>I am flatly against the mullahs in Iran approving what&#8217;s ok for me to read on the Internet in Seattle, Washington. I also think that, without democratic elections, these people and their counterparts in Saudi, Russia, China, and many other countries, have no moral authority to make similar decisions for the people that live in their respective countries. </p>
<p>Let the closed societies try to regulate the Internet within their borders if they want to. It won&#8217;t work. As we see in Iran, China, and other places, the information will get in and out, eventually. People want the freedom to educate themselves. The US should not back up one bit from its stance on this.  </p>
<p>The Internet is a much more effective spreader of democracy than 3 battalions of US Marines. </p>
<p>Related: <a href='http://www.pcmag.com/article2/0,2817,2413219,00.asp'>Dvorak on the ITU Treaty</a><br/></p>
]]></content:encoded>
			<wfw:commentRss>http://dinochiesa.net/?feed=rss2&#038;p=799</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hmmm, SOA is a bad word? So let&#8217;s call it APIs !</title>
		<link>http://dinochiesa.net/?p=790&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=hmmm-soa-is-a-bad-word-so-lets-call-it-apis</link>
		<comments>http://dinochiesa.net/?p=790#comments</comments>
		<pubDate>Sat, 15 Dec 2012 00:09:04 +0000</pubDate>
		<dc:creator>dpc</dc:creator>
				<category><![CDATA[Reaction]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[Apigee]]></category>
		<category><![CDATA[InfoWorld]]></category>
		<category><![CDATA[SOA]]></category>

		<guid isPermaLink="false">http://dinochiesa.net/?p=790</guid>
		<description><![CDATA[David Linthicum, in his InfoWorld article, observes that SOA is a &#8220;bad word&#8221;, noting that SOA Companies are now rebranding themselves as API Management companies. Some editor at InfoWorld apparently chose the article title to be &#8220;Service governance morphs into cloud API management&#8221;. But I don&#8217;t think that&#8217;s &#8230; <a class="smt-continue" href="http://dinochiesa.net/?p=790">Continue reading <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>David Linthicum, in <a href='http://www.infoworld.com/d/cloud-computing/service-governance-morphs-cloud-api-management-209183'>his InfoWorld article</a>, observes that SOA is a &#8220;bad word&#8221;, noting that SOA Companies are now rebranding themselves as API Management companies. </p>
<p>Some editor at InfoWorld apparently chose the article title to be<br />
<strong>&#8220;Service governance <em>morphs into</em> cloud API management&#8221;</strong>.  But I don&#8217;t think that&#8217;s an accurate summary of the article. That&#8217;s not the gist of it. </p>
<p>The gist is more accurately captured in Linthicum&#8217;s subtitle, to wit: <em>More evidence that <strong>SOA is a bad word</strong>: Traditional SOA service governance technology rebrands itself for the cloud</em>.</p>
<p>Re-branding is the first baby step in the &#8220;morphing&#8221; process I guess. But <A href='http://og-blogdotcom.blogspot.com/2008/05/saying-it-dont-make-it-so.html'><em>sayin it don&#8217;t make it so</em></a>. </p>
<p>The problem with the rest of Linthicum&#8217;s anaylsis is that it looks at everything through a SOA lens. API Management exposes APIs &#8211; &#8220;that&#8217;s SOA&#8221; he says. API Management platforms enforce security controls. &#8220;That&#8217;s SOA governance.&#8221;</p>
<p>Great, I can see the parallels. But what about the things API Management platforms do that are completely outside the domain of SOA? What about developer enablement and engagement? What about analytics? Versioning, cloud-based scale out. </p>
<p>Linthicum is an SOA guy, and when he looks around, everything is tinted with his SOA-colored glasses. I have a different perspective. SOA solved some big problems. As a metaphor for interconnecting enterprises, it was a huge advance. A huge improvement. </p>
<p>Even so, with SOA there were problems. Poor support for mobile devices. Still a great deal of complexity. Hard for developers to get connected and productive. Poor visibility by business owners into the impact of applicaiton inter-connect traffic. API Management platforms present an opportunity to address all those challenges. </p>
<p>Despite what Linthicum sees, API Management is not simply re-branded SOA. </p>
]]></content:encoded>
			<wfw:commentRss>http://dinochiesa.net/?feed=rss2&#038;p=790</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>APIs within the Enterprise &#8211; a Webinar</title>
		<link>http://dinochiesa.net/?p=781&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=apis-within-the-enterprise</link>
		<comments>http://dinochiesa.net/?p=781#comments</comments>
		<pubDate>Sat, 01 Dec 2012 00:19:36 +0000</pubDate>
		<dc:creator>dpc</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[REST]]></category>
		<category><![CDATA[SOAP]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://dinochiesa.net/?p=781</guid>
		<description><![CDATA[Recently I did a web chat with colleague Greg Brail discussing the use of APIs in the Enterprise. Quick summary: SOA has been used with success within enterprises to interconnect systems. APIs address a different set of problems, and there is real value to be gained by using &#8230; <a class="smt-continue" href="http://dinochiesa.net/?p=781">Continue reading <span class="meta-nav">&#187;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Recently I did a web chat with colleague Greg Brail discussing the use of APIs in the Enterprise. </p>
<p>Quick summary: SOA has been used with success within enterprises to interconnect systems. APIs address a different set of problems, and there is real value to be gained by using APIs to interconnect systems within the enterprise, as well as to provide external or partner access into enterprise systems.  </p>
<p><iframe width="560" height="315" src="http://www.youtube.com/embed/p1RlWhnIBZ4?hl=en_US" frameborder="0" allowfullscreen></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://dinochiesa.net/?feed=rss2&#038;p=781</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Hosting24 Analytics Code -->
<script type="text/javascript" src="http://stats.hosting24.com/count.php"></script>
<!-- End Of Analytics Code -->
