<?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>Full of BS &#187; ECMAScript</title>
	<atom:link href="http://fullof.bs/category/programming/ecmascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://fullof.bs</link>
	<description>He just never stops talking</description>
	<lastBuildDate>Wed, 21 Mar 2012 05:14:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Prototype: EEP18 Considered Harmful: The problems with Erlang to JSON term translation</title>
		<link>http://fullof.bs/prototype-eep-18-considered-harmful-the-problems-with-erlang-to-json-term-translation/</link>
		<comments>http://fullof.bs/prototype-eep-18-considered-harmful-the-problems-with-erlang-to-json-term-translation/#comments</comments>
		<pubDate>Sat, 06 Dec 2008 20:40:26 +0000</pubDate>
		<dc:creator>John Haugeland</dc:creator>
				<category><![CDATA[ECMA / Javascript]]></category>
		<category><![CDATA[ECMAScript]]></category>
		<category><![CDATA[Erlang]]></category>
		<category><![CDATA[General Interest]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Rants]]></category>
		<category><![CDATA[Tools and Libraries]]></category>
		<category><![CDATA[Web and Web Standards]]></category>
		<category><![CDATA[bif]]></category>
		<category><![CDATA[conversion]]></category>
		<category><![CDATA[convert]]></category>
		<category><![CDATA[eep]]></category>
		<category><![CDATA[eep 18]]></category>
		<category><![CDATA[eep18]]></category>
		<category><![CDATA[eeps]]></category>
		<category><![CDATA[erlang enhancement proposal 18]]></category>
		<category><![CDATA[javascript object notation]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[json bif]]></category>

		<guid isPermaLink="false">http://fullof.bs/?p=402</guid>
		<description><![CDATA[THIS IS ONLY HALF WRITTEN.  I have been sitting on this post, waiting for the mood to finish it, for months; because EEP18 is now being treated as a likely implement, I am immediately publishing the half-written version, because it exposes many (though not all) of the serious, irreconcilable problems with EEP18. On the mailing [...]]]></description>
			<content:encoded><![CDATA[<p><span style="color: #ff0000"><em><strong>THIS IS ONLY HALF WRITTEN.  I have been sitting on this post, waiting for the mood to finish it, for months; because EEP18 is now being treated as a likely implement, I am immediately publishing the half-written version, because it exposes many (though not all) of the serious, irreconcilable problems with EEP18.</strong></em></span></p>
<p>On the mailing list, people are actively trying to bring Erlang up to snuff with regards to web standards.  One of the more unfortunate choices being discussed is JSON as a data notation.  JSON, unfortunately, does not actually map to Erlang in a useful way.  Joe Armstrong has gone as far as to suggest BIFs, which are decidedly unrealistic as well as unnecessary.  My goal is to create a JSON handling library.  However, the mailing list is beginning to put momentum behind an alternative proposal which is currently presented in BIF form.</p>
<p>This post explains why my approach is different.  Many of the issues herein are discussed by <a title="Richard O'Keefe's EEP18, JSON BIFs" href="http://www.erlang.org/eeps/eep-0018.html" target="_blank">the tabled EEP</a> (EEP 18, &#8220;JSON BIFs&#8221; by Rickard O&#8217;Keefe), but some are not, and some of these issues are accepted when I believe they should not be.  <span style="text-decoration: underline"><strong>It is my position that EEP 18 is unacceptably dangerous</strong></span>.  I will explain why.</p>
<p><span id="more-402"></span></p>
<p>This paper assumes you are familiar with Erlang and with fundamental containers (the list, the array and the key/value map).  It is very helpful, but not required, to be familiar with JSON, or JavaScript or any ECMA derived language such as ActionScript.</p>
<h1>Premise</h1>
<p>There&#8217;s a movement starting to use Erlang for web work.  There are several stumbling blocks to that end.  Among them are a simple primary webserver, a simple primary unicode system and a simple primary JSON manager.</p>
<p>The webserver problem is mostly solved: there&#8217;s the httpd module, there&#8217;s yaws, there&#8217;s mochiweb, there&#8217;s the currently unavailable work at Tobbe&#8217;s Red Hot Erlang Blog, there&#8217;s even Joe&#8217;s HTTPD tutorial.  YAWS and MochiWeb in particular get a lot of action these days.  The situation isn&#8217;t amazingly straightforward, but it&#8217;s fairly straightforward; we&#8217;re in &#8220;Good Enough&#8221; territory.  (I&#8217;m building another webserver that behaves like factor&#8217;s drop-and-go server, based on Joe&#8217;s tutorial, but that&#8217;s not for here.)</p>
<p>The unicode problem, however, as well as the JSON problem, are not solved.  Unfortunately, whereas the Erlang community has had the foresight to deal with complex problems in modules first then to move them to syntax later, this process seems to be failing with both JSON and Unicode.  It can be argued that some of the choices made in each process are dangerous.  This community will, by and on the whole, remember the re: module, which is being replaced now with a partially incompatible successor that takes account of limitations and problems in the prior attempt, as well as moves to a stronger RE dialect.  It is important that this ability be retained for JSON and Unicode, both of which are subtly strikingly difficult problems, and both of which are unlikely to be Gotten Right™ on their respective first attempts.</p>
<h1>The Principle of Least Surprise</h1>
<p>One of the most important parts of writing libraries is to not write nasty shocks into place for users.  In transcoding libraries, there is one rule that defines least surprise more powerfully than any other: <em><strong>round-trip translations must not lose data</strong></em>.  No configuration of EEP 18 can achieve this.  Indeed, it is my position that a one to one translation of JSON to Erlang terms cannot exist, and that any attempt to present a not-1:1 translation as a translation is unacceptable, in that people will expect <span style="color: #0000ff"><code>j2e(e2j(X)) == X</code></span>, and that cannot be true.  This is especially important given that the suggestion that these translations become BIFs seems to be being taken seriously; <span style="color: #0000ff"><code>foo_to_bar(X)</code></span> bifs are currently never lossy, and this would create a worrying change in the meaning of several basic naming practices.</p>
<p>It is of critical importance, in my opinion, that we do not provide libraries which fail round-trip conversion in either direction.  At this time, EEP 18 attempts to satisfy this clause with creation-time configurability; I will explain my stance that this is inadequate below.</p>
<h1>Why Translation is Unclear</h1>
<p>There are, in fact, quite a few problems that prevent 1:1 translation.  We&#8217;ll go over them one by one.</p>
<ol>
<li>The notations offer different fundamental containers
<ol>
<li>Erlang offers dense sequence (&#8220;tuple&#8221;, <span style="color: #0000ff"><code>{}</code></span>) and singly linked list (&#8220;list&#8221;, <span style="color: #0000ff"><code>[]</code></span>) containers.  The erlang standard library offers other containers; I discuss later in this document why I&#8217;m not using them.</li>
<li>JSON offers dense sequence (&#8220;array&#8221;, <span style="color: #0000ff"><code>[]</code></span>) and key-value map (&#8220;object&#8221;, <span style="color: #0000ff"><code>{}</code></span>) containers.  That&#8217;s it.</li>
</ol>
</li>
<li>The notations offer different fundamental datatypes
<ol>
<li>JSON has a fundamental string type; erlang doesn&#8217;t.</li>
<li>Erlang has atoms; JSON doesn&#8217;t.</li>
<li>JSON has booleans and &#8220;null&#8221;; Erlang doesn&#8217;t.  For transcoding, pretending they&#8217;re atoms creates ambiguity, and is therefore unacceptable.</li>
<li>JSON has explicit support for unicode characters in strings.  Erlang doesn&#8217;t have strings at all, but rather lists of characters (in the way that C has arrays of characters).  Those lists are context and usage defined; C++ programmers may think of this as parallel to array strings vs std::string.  Erlang currently has no concept of Unicode (<span style="color: #999999"><em>though that&#8217;s another issue I&#8217;m working on as divergent from the current mailing list / EEP approach</em>.</span>)</li>
<li>JSON and Erlang have very different lists of quoted terms for strings.
<ol>
<li>Erlang supports embedded octal with shortening, and a bunch of semi-defunct control characters like form feed (<span style="color: #0000ff"><code>"\f"</code></span>) and escape (<span style="color: #0000ff"><code>"\e"</code></span>).</li>
<li>JSON supports 16-bit Unicode character embedding.</li>
<li>Problematically, JSON does not define whether that embedding is UTF16, UCS2 or something else.  Most software implementations assume UTF16.  This document will carefully avoid the issue, which is a serious defect in this document, and a serious defect in JSON.</li>
</ol>
</li>
<li>Erlang terms are byte-available, meaning Erlang programmers may be aware of endianness; JSON objects are not.  This suggests that the handling library needs to either make a choice about internal endianness, or needs to provide control to the user.</li>
</ol>
</li>
<li>The notation for similar containers is dissimilar</li>
<li>Similar notations are similar, not identical</li>
<li>Dangerous string ambiguities</li>
</ol>
<p>Working from http://sc.tri-bit.com/outgoing/scjson%20parser%20halp.html</p>
]]></content:encoded>
			<wfw:commentRss>http://fullof.bs/prototype-eep-18-considered-harmful-the-problems-with-erlang-to-json-term-translation/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Yay for Varun!  Open Source Inbound</title>
		<link>http://fullof.bs/yay-for-varun-open-source-inbound/</link>
		<comments>http://fullof.bs/yay-for-varun-open-source-inbound/#comments</comments>
		<pubDate>Wed, 26 Nov 2008 02:26:58 +0000</pubDate>
		<dc:creator>John Haugeland</dc:creator>
				<category><![CDATA[ECMA / Javascript]]></category>
		<category><![CDATA[ECMAScript]]></category>
		<category><![CDATA[General Interest]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tools and Libraries]]></category>
		<category><![CDATA[8601]]></category>
		<category><![CDATA[free]]></category>
		<category><![CDATA[gpl-free]]></category>
		<category><![CDATA[iso8601]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[Kayako]]></category>
		<category><![CDATA[libraries]]></category>
		<category><![CDATA[mit license]]></category>
		<category><![CDATA[Open source]]></category>

		<guid isPermaLink="false">http://fullof.bs/?p=427</guid>
		<description><![CDATA[My boss&#8217; boss, Varun, is letting me open source some of the work I&#8217;m doing at Kayako.  I&#8217;m not supposed to talk about the interesting three until they&#8217;re ready for release, but I can tell you that a JavaScript ISO8601 implementation is among them, and that they&#8217;re all going to be MIT licensed, no GPL [...]]]></description>
			<content:encoded><![CDATA[<p>My boss&#8217; boss, Varun, is letting me open source some of the work I&#8217;m doing at <a title="Kayako" href="http://kayako.com/" target="_blank">Kayako</a>.  I&#8217;m not supposed to talk about the interesting three until they&#8217;re ready for release, but I can tell you that a JavaScript ISO8601 implementation is among them, and that they&#8217;re all going to be MIT licensed, no GPL contamination.</p>
<p>More news as I get my butt in gear and finish the libraries in question.  But, yay Varun!</p>
]]></content:encoded>
			<wfw:commentRss>http://fullof.bs/yay-for-varun-open-source-inbound/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Gearing Up for Public SVN</title>
		<link>http://fullof.bs/gearing-up-for-public-svn/</link>
		<comments>http://fullof.bs/gearing-up-for-public-svn/#comments</comments>
		<pubDate>Thu, 24 Jul 2008 16:01:46 +0000</pubDate>
		<dc:creator>John Haugeland</dc:creator>
				<category><![CDATA[C/C++]]></category>
		<category><![CDATA[ECMA / Javascript]]></category>
		<category><![CDATA[ECMAScript]]></category>
		<category><![CDATA[Erlang]]></category>
		<category><![CDATA[Game Algorithms]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tools and Libraries]]></category>
		<category><![CDATA[Web and Web Standards]]></category>
		<category><![CDATA[a*]]></category>
		<category><![CDATA[astar]]></category>
		<category><![CDATA[embed]]></category>
		<category><![CDATA[embeddable]]></category>
		<category><![CDATA[htstub]]></category>
		<category><![CDATA[Public svn]]></category>
		<category><![CDATA[regression test]]></category>
		<category><![CDATA[scastar a star]]></category>
		<category><![CDATA[scutil]]></category>
		<category><![CDATA[stochastic test]]></category>
		<category><![CDATA[subversion]]></category>
		<category><![CDATA[svn]]></category>
		<category><![CDATA[unit test]]></category>
		<category><![CDATA[webserver]]></category>

		<guid isPermaLink="false">http://fullof.bs/?p=271</guid>
		<description><![CDATA[I&#8217;m going to be releasing a few new libraries in the next several days, both by archive and public subversion.  I&#8217;ve already bought the domains and built a forum for them.  I even wasted a couple hours subversion automating everything down to the line of having little library websites made automatically, with custom per-library color [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m going to be releasing a few new libraries in the next several days, both by archive and public subversion.  I&#8217;ve already bought the domains and built a forum for them.  I even wasted a couple hours subversion automating everything down to the line of having little library websites made automatically, with custom per-library color palettes.</p>
<p>I was a little bored.</p>
<p>So we&#8217;re going to have three libraries progressing in the immediate future, with quite a few more over time:</p>
<ol>
<li><a title="HtStub - an embeddable Erlang webserver" href="http://htstub.com/" target="_blank">HtStub</a> &#8211; An embeddable, zero-config, zero-behavior secure Erlang webserver</li>
<li><a title="StoneCypher's A* library, with tutorial" href="http://scastar.com/" target="_blank">SC A-Star</a> &#8211; An efficient, modular ECMAscript (flash/actionscript, javascript, jscript etc) A* implementation with support for custom grid geometries (<em>includes algorithm tutorial</em>)</li>
<li><a title="TestErl - an erlang library for unit, regression and stochastic testing" href="http://testerl.com/" target="_blank">TestErl</a> &#8211; unit, regression and stochastic testing for Erlang</li>
<li><a title="ScUtil - StoneCypher's erlang utility library" href="http://scutil.com/" target="_blank">ScUtil</a> &#8211; a fairly large list of gap filling functionality for Erlang</li>
</ol>
<p>In the near future, I will add C++ and PHP libraries, as well as many some libraries for more obscure languages like FormulaONE, Mozart-Oz, Factor and maybe (sadly) Delphi.  I have more than 30 libraries ready for release.</p>
<p>All those repos are pretty empty at the moment.  That will change in coming days, and I&#8217;m sure I&#8217;ll post lots of boring little snippets here about whatever minor new thing my crap does.</p>
<p>Yay!</p>
]]></content:encoded>
			<wfw:commentRss>http://fullof.bs/gearing-up-for-public-svn/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

