<?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; ECMA / Javascript</title>
	<atom:link href="http://fullof.bs/category/ecma-javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://fullof.bs</link>
	<description>He just never stops talking</description>
	<lastBuildDate>Thu, 15 Dec 2011 20:00:48 +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>
		<item>
		<title>Is your new WordPress 2.6 install giving you a blank white screen?  Here&#8217;s how to fix it.</title>
		<link>http://fullof.bs/is-your-new-wordpress-26-install-giving-you-a-blank-white-screen-heres-how-to-fix-it/</link>
		<comments>http://fullof.bs/is-your-new-wordpress-26-install-giving-you-a-blank-white-screen-heres-how-to-fix-it/#comments</comments>
		<pubDate>Tue, 15 Jul 2008 23:03:09 +0000</pubDate>
		<dc:creator>John Haugeland</dc:creator>
				<category><![CDATA[Blog Meta]]></category>
		<category><![CDATA[ECMA / Javascript]]></category>
		<category><![CDATA[Miscellaneous]]></category>
		<category><![CDATA[Word Press]]></category>
		<category><![CDATA[2.6]]></category>
		<category><![CDATA[broken]]></category>
		<category><![CDATA[crash]]></category>
		<category><![CDATA[fail]]></category>
		<category><![CDATA[fix]]></category>
		<category><![CDATA[white screen]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[wp]]></category>
		<category><![CDATA[wp 2.6]]></category>
		<category><![CDATA[wp26]]></category>

		<guid isPermaLink="false">http://fullof.bs/?p=215</guid>
		<description><![CDATA[The most common cause of a blank screen at any stage in the process, if your source view shows empty, is that PHP aborted during its run without dumping buffers.  During software upgrades, this is usually due to one of three reasons: An incomplete transfer of the requisite files.  Don&#8217;t insist that you&#8217;re certain that [...]]]></description>
			<content:encoded><![CDATA[<p>The most common cause of a blank screen at any stage in the process, if your source view shows empty, is that PHP aborted during its run without dumping buffers.  During software upgrades, this is usually due to one of three reasons:</p>
<ol>
<li>An incomplete transfer of the requisite files.  Don&#8217;t insist that you&#8217;re certain that didn&#8217;t happen, even if it&#8217;s from a command like svn or cp that shouldn&#8217;t fail; you&#8217;re not certain until you&#8217;ve checked.</li>
<li>PHP has run out of some resource, typically RAM.</li>
<li>mod_security is set up brokenly</li>
</ol>
<p>[digg-reddit-me]In both cases, you can figure out which by checking your apache logs.  On windows, go to the Windows Event Viewer.  On unix, this may live in a variety of places; most common is shared hosting by cpanel/plesk, where you can get it in your control panel, or to just look in /var/logs/ .</p>
<p>If it&#8217;s #1, you&#8217;re likely to see something like this in logs (this is from my site, which just suffered this problem and was quickly fixed) :</p>
<pre>[Tue Jul 15 18:45:28 2008] [error] [client 24.117...]
PHP Fatal error:  Call to undefined function
force_ssl_admin() in /var/www/html/wp-settings.php on
line 390, referer: http://.../wp-admin/post.php?action=edit&amp;post=55</pre>
<p>Don&#8217;t worry if that undefined function has a different name or a different referrer, or whatever; that&#8217;s how you track down missing code, and missing code means some file didn&#8217;t get updated.</p>
]]></content:encoded>
			<wfw:commentRss>http://fullof.bs/is-your-new-wordpress-26-install-giving-you-a-blank-white-screen-heres-how-to-fix-it/feed/</wfw:commentRss>
		<slash:comments>46</slash:comments>
		</item>
		<item>
		<title>What would make a good image plugin?</title>
		<link>http://fullof.bs/what-would-make-a-good-image-plugin/</link>
		<comments>http://fullof.bs/what-would-make-a-good-image-plugin/#comments</comments>
		<pubDate>Tue, 15 Jul 2008 15:56:40 +0000</pubDate>
		<dc:creator>John Haugeland</dc:creator>
				<category><![CDATA[Blog Meta]]></category>
		<category><![CDATA[Daily Image]]></category>
		<category><![CDATA[ECMA / Javascript]]></category>
		<category><![CDATA[General Interest]]></category>
		<category><![CDATA[Miscellaneous]]></category>
		<category><![CDATA[Picture Links]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tools and Libraries]]></category>
		<category><![CDATA[Web and Web Standards]]></category>
		<category><![CDATA[Word Press]]></category>

		<guid isPermaLink="false">http://fullof.bs/?p=214</guid>
		<description><![CDATA[I&#8217;ve been thinking about making an image plugin for WordPress.  I want to restart my image of the day process, but the import process has been dreadful, and there&#8217;s no programmatic access to the image list, meaning things like random images and images from subgroups aren&#8217;t particularly reasonable.  To that end I need to write [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been thinking about making an image plugin for WordPress.  I want to restart my image of the day process, but the import process has been dreadful, and there&#8217;s no programmatic access to the image list, meaning things like random images and images from subgroups aren&#8217;t particularly reasonable.  To that end I need to write my own, and since I&#8217;d love the rank that comes from having a high-usage plugin, I need a clear idea of what things go into an image plugin, what features are missing from existing plugins, et cetera.</p>
<p>I&#8217;m already doing complex efficient randomization, API access, bulk posting, timed bulk posting, base autotagging, auto-categorization, a catalog widget, and I&#8217;m going to make sure that my stuff is compatible with the <a title="All In One SEO pack" href="http://semperfiwebdesign.com/" target="_blank">All In One SEO pack</a>.  I&#8217;m going to provide integration points, and I&#8217;m going to provide an example integration with LightBox, or one of its relatives.  I&#8217;m going to provide voting, moderated tag suggestion and home-post permalinking.</p>
<p>I&#8217;ll also be writing strict, browser/version portable code without hacks.  Yay!</p>
<p>Please let me know what you&#8217;d want to see if there were a new image plugin coming out.</p>
]]></content:encoded>
			<wfw:commentRss>http://fullof.bs/what-would-make-a-good-image-plugin/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Holy ECMA Hacks, Batman: the Weirdest Path To Default Arguments Ever</title>
		<link>http://fullof.bs/holy-ecma-hacks-batman-the-weirdest-path-to-default-arguments-ever/</link>
		<comments>http://fullof.bs/holy-ecma-hacks-batman-the-weirdest-path-to-default-arguments-ever/#comments</comments>
		<pubDate>Wed, 13 Sep 2006 19:46:12 +0000</pubDate>
		<dc:creator>John Haugeland</dc:creator>
				<category><![CDATA[ECMA / Javascript]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web and Web Standards]]></category>

		<guid isPermaLink="false">http://blog.sc.tri-bit.com/archives/174</guid>
		<description><![CDATA[Yeah, so, I&#8217;m having a hard time adressing the weirdness that is ParentNode&#8217;s approach to default functions. Basically he sets a hook on the prototype for calling the function, and in that he makes a new function which checks for the presence of a particular member (we remember that functions are objects in ECMA, I [...]]]></description>
			<content:encoded><![CDATA[<p>Yeah, so, I&#8217;m having a hard time adressing the weirdness that is <a href="http://parentnode.org/javascript/default-arguments-in-javascript-functions/">ParentNode&#8217;s approach to default functions</a>.  Basically he sets a hook on the prototype for calling the function, and in that he makes a new function which checks for the presence of a particular member (we remember that functions are objects in ECMA, I trust.)  If that member exists, he chops it up, and for each argument in the original function call, he tests for undefinedness, and if that&#8217;s present, he fills in the value.  (This one is order-based default, but there&#8217;s also a by-name default.)</p>
<p>Now, I think it&#8217;s a little impractical, and it leads to a mind-bleedingly weird syntax, but it&#8217;s actually struck me that this is a very clean, very terse format for providing something akin to uniform construction behavior when you&#8217;re dealing with multiple manufacture paths to a given object.  Granted, it&#8217;d be an even bigger, even uglier hack, but still, it&#8217;d work.</p>
<p>Witness syntax:</p>
<blockquote><p>function exampleF(foo, bar, baz) { &#8230; }.defaults(1, 3, 7);</p></blockquote>
<p>Hear that crashing sound?  It&#8217;s your mind, breaking.  But, as much as I hate to admit it, this is one genuinely lovable hack.  Bravo.</p>
]]></content:encoded>
			<wfw:commentRss>http://fullof.bs/holy-ecma-hacks-batman-the-weirdest-path-to-default-arguments-ever/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Checklist for Embedded IE</title>
		<link>http://fullof.bs/checklist-for-embedded-ie/</link>
		<comments>http://fullof.bs/checklist-for-embedded-ie/#comments</comments>
		<pubDate>Thu, 24 Aug 2006 02:13:56 +0000</pubDate>
		<dc:creator>John Haugeland</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[C/C++]]></category>
		<category><![CDATA[DOM]]></category>
		<category><![CDATA[ECMA / Javascript]]></category>
		<category><![CDATA[Internet Explorer]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tools and Libraries]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Web and Web Standards]]></category>

		<guid isPermaLink="false">http://blog.sc.tri-bit.com/archives/163</guid>
		<description><![CDATA[MSHTML is an awesome user interface tool, but it has a whole lot of standard behaviors, many of which aren&#8217;t what one wants for an application (since it&#8217;s designed for the web.) This is a list of stuff you need to do to embed IE COM and have it behave like a normal application. There&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>MSHTML is an awesome user interface tool, but it has a whole lot of standard behaviors, many of which aren&#8217;t what one wants for an application (since it&#8217;s designed for the web.)  This is a list of stuff you need to do to embed IE COM and have it behave like a normal application.  There&#8217;s more than a person might expect.</p>
<p><span id="more-153"></span></p>
<ul>
<li>Suppress the user interface.  IE starts with most of its interface turned off, but a few things aren&#8217;t.  Notable things to include are to suppress the context menu and keyboard navigation.</li>
<ul>
<li>There are several ways to suppress the context menu.  The easiest way is to do it in the html.  Add <u>oncontextmenu=&#8221;return false;&#8221;</u> to your &lt;body&gt; and the problem just goes away, and it&#8217;s easily manually overridden for specific elements later.</li>
<li>Alternately, you can override the interface programmatically through <a title="IDocHostUIHandler Interface" href="http://msdn.microsoft.com/workshop/browser/hosting/reference/ifaces/idochostuihandler/idochostuihandler.asp">IDocHostUIHandler</a>.</li>
</ul>
<li>Get rid of the OnNavigate noise (the clicking sound when you hit a link.)  <a title="Suppressing OnNavigate" href="http://blog.sc.tri-bit.com/archives/162">This is harder than it should be</a>.</li>
<li>Prevent keyboard navigation.  If you only ever navigate once, and then do everything else in DHTML, this isn&#8217;t an issue, because there&#8217;s nothing to go forward or back to.  However, if you need to, the way to do this is to capture <a title="BeforeNavigate2" href="http://windowssdk.msdn.microsoft.com/en-us/library/ms628868.aspx">DWebBrowserEvents2::BeforeNavigate2()</a> and fill its last parameter, VARIANT_BOOL*&amp; Cancel, to true.  For security reasons this can&#8217;t be done in HTML without a garish ugly dialog box confirmation.</li>
<li>Prevent dragging and dropping links.  Do this with BeforeNavigate2() just like keyboard navigation.</li>
<li>Prevent selection.  The easiest way to do that is in the HTML by adding <u>onselectstart=&#8221;return false;&#8221;</u> to the &lt;body&gt;, which is also easily overridden for child elements where appropriate.  If you need it programmatically, such as a block which can be turned from and to editability, that&#8217;s in IDocHostUIHandler.</li>
<li>Handle some keys directly.  Particularly often, control keys, tab and f-keys need very different interpretations in applications than are the defaults in IE.  Some keys can be reliably intercepted in JScript, but not all of them.  For lightweight stuff, use JScript; it&#8217;ll be less painful.  However, if you need real control, you need to provide an <a title="Handle keypresses" href="http://msdn.microsoft.com/workshop/browser/hosting/reference/ifaces/idochostuihandler/translateaccelerator.asp">IDocHostUIHandler::TranslateAccelerator()</a> implementation.</li>
<li>Suppress the interior border.  People are often surprised that they turn off the window border in IE, and yet it seems to still appear.  That&#8217;s because IE&#8217;s default stylesheet puts an inset bevel on every web page.  Turn that off in CSS by writing <u>body { border: 0; }</u>.</li>
<li>Begin to embed your images and other support media as resources, and access them with <a title="The res protocol" href="http://msdn.microsoft.com/workshop/networking/predefined/res.asp">the res:// protocol</a>.</li>
<ul>
<li>One ugly caveat: I have never found any variation of the DirectX PNG alpha filter hack which works with res://, and I&#8217;ve looked often and at some very weird variations.  It is my current belief that a PNG cannot be embedded through res:// and still be fixed for alpha.  This leads to the unfortunate case of requiring at least part of your resources on disk.  If anyone knows a way around this, a heads-up would be <em>greatly</em> appreciated.</li>
</ul>
<li>Set up a system to exchange messages between IE DOM/DHTML/JScript and your application.  There are a bujillion ways to do this, but I tend to use a combination of intercepted element events (mostly OnClick in <a title="NO U INVOKE" href="http://msdn.microsoft.com/workshop/browser/webbrowser/reference/ifaces/dwebbrowserevents/dwebbrowserevents.asp">WebBrowserEvents Invoke</a>,) DOM extension behaviors that allow me to call C++ directly from JScript through <a title="The missing link" href="http://msdn.microsoft.com/workshop/browser/hosting/reference/ifaces/idochostuihandler/getexternal.asp">IDocHostUIHandler::GetExternal()</a>, and executing scripts directly on the DOM object through <a title="Do what I say, DOM" href="http://msdn.microsoft.com/workshop/browser/mshtml/reference/ifaces/window2/execscript.asp">IHTMLWindow2::execScript()</a>.</li>
<li>Build everything in the to be inside a container; make the body itself <u>overflow: none</u>.  This prevents several ugly re-layout quirks which we&#8217;re used to on the web but not in applications, when content gets long.</li>
<ul>
<li>Start the container invisible, and make the black.  That way, during the lag while resources are being loaded, you have a reasonable appearance.  Black flashes look correct.  White flashes look broken.</li>
<li>Set an <u>onload=&#8221;HandleLoad();&#8221;</u> function for the &lt;body&gt;.  That way, you know when all resources are loaded, and thus when it&#8217;s safe to take the invisible clause off of the main container.</li>
<li>Set the main container <u>position:relative</u>, to make absolute positioning of contained elements easier.</li>
</ul>
<li>Build your web page in as a resource, and load it through <a title="How to load a document without about:blank and its white flash." href="http://msdn.microsoft.com/workshop/browser/mshtml/reference/ifaces/document2/write.asp">IHtmlDocument2::write()</a>.  This allows you to load a document at runtime without using about:blank (which most people use, but which causes a brief white flash before your application loads; very unprofessional looking.)  You&#8217;ll need <a title="SafeArrayAccessData" href="http://windowssdk.msdn.microsoft.com/en-us/library/ms221620.aspx">SafeArrayAccessData()</a> and <a title="SafeArrayUnaccessData" href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/automat/html/61b482cb-f0a3-4efb-9a68-f373f241e89a.asp">SafeArrayUnaccessData()</a> to use write() safely.  When it comes time to skin or internationalize, and when you&#8217;re dealing with a compile cycle which is just linking, you&#8217;ll thank me for this.</li>
<li>Suppress dragging on links and buttons.  If you don&#8217;t, people will be able to drag them outside the app and onto the desktop as shortcuts, and when followed those shortcuts will lead into your HTML page from the outside (which is, surprisingly, legal.)</li>
<li>Consider compressing your executable, such as with <a title="Universal Packer for Executables" href="http://upx.sourceforge.net/">UPX</a>, which makes resources unreadable externally.</li>
<li>Set an id on your &lt;body&gt;.  The is considered the origin of most events which don&#8217;t have a clear origin, and that means that catching these events is a lot easier (catching by id is the most straightforward way to sort out sources.)</li>
<li>Resist the urge to use runtime styles.  They&#8217;re not worth the problems they cause.</li>
</ul>
<p>That should get the new IE user through some common foibles.  I&#8217;ve probably missed stuff; if you can think of something, lemme know.  I do not currently know of a way to embed flash, unfortunately, without leaving available an extra file.</p>
]]></content:encoded>
			<wfw:commentRss>http://fullof.bs/checklist-for-embedded-ie/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>XMLHttpRequest &#8211; So Close and yet So Far</title>
		<link>http://fullof.bs/the-xmlhttprequest-object-so-close-and-yet-so-far/</link>
		<comments>http://fullof.bs/the-xmlhttprequest-object-so-close-and-yet-so-far/#comments</comments>
		<pubDate>Wed, 26 Apr 2006 00:37:12 +0000</pubDate>
		<dc:creator>John Haugeland</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[DOM]]></category>
		<category><![CDATA[ECMA / Javascript]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Rants]]></category>
		<category><![CDATA[Web and Web Standards]]></category>

		<guid isPermaLink="false">http://blog.sc.tri-bit.com/archives/125</guid>
		<description><![CDATA[To be plain, I think the XMLHttpRequest object is quite wonderful. It&#8217;s a deeper realization than I&#8217;d had when I was talking about RFC2557+ some years ago; rather than binding people to URLs, it frees them to use sockets. Or does it? There is one simple truism that has shown itself over and over again [...]]]></description>
			<content:encoded><![CDATA[<p>To be plain, I think the <a title="The offender" href="http://www.w3.org/TR/XMLHttpRequest/">XMLHttpRequest object</a> is quite wonderful.  It&#8217;s a deeper realization than I&#8217;d had when I was talking about RFC2557+ some years ago; rather than binding people to URLs, it frees them to use sockets.</p>
<p>Or does it?</p>
<p><span id="more-126"></span></p>
<p>There is one simple truism that has shown itself over and over again in programming.  With the new toolset available, I don&#8217;t think there&#8217;s anyone who&#8217;s going to argue that web programming isn&#8217;t programming anymore.  It&#8217;s becoming the case that what we learned in software engineering is starting to show true in web development.  In this respect, XMLHttpRequest shows several promises which aren&#8217;t immediately obvious, and several pitfalls which apparently haven&#8217;t been noticed at all.</p>
<p>The truism to which I refer is that nothing is ever enough for a programmer.  That&#8217;s not as broad as it sounds; it leads to a few very specific and very important realizations which need to be accounted for.</p>
<ol>
<li>Things need to be modular, because we&#8217;ve scaled too far to even consider looking at systems as a whole for small changes.  This is one of the web&#8217;s strongest points, in large part owing to the fundamental nature of SGML as a meta-markup and the brilliant guiding hand who was <a title="Those of us who remember still mourn" href="http://www.postel.org/remembrances/">John Postel</a>.  In this respect, XMLHttpRequest is well on its way to success; the standard is beginning to take into account languages other than ECMA derived scripts, and sockets are already extremely modular.</li>
<li>Things need to be resilient.  There are adequate mechanisms to determine state and error state, though a callback for connection failure would have been nice (though, admittedly, it&#8217;s easy enough to implement, which I&#8217;ll show in a later blog post.)</li>
<li>Things need to attach to their host environment in a natural fashion.  This has traditionally been a problem for languages like <a title="My favorite constraint language" href="http://f1compiler.com/">FormulaONE</a> and <a title="The only constraint language anyone's actually heard of" href="http://www.swi-prolog.org/">Prolog</a>, though it seems <a title="SCARY" href="http://www.mozart-oz.org/">Mozart-Oz</a> is working them out.  This is arguably XMLHttpRequest&#8217;s greatest strength, the foresight of the responseXML property.  Unfortunately, it also helps mask one of the biggest failings (the only serious one that I see, actually.)</li>
<li>There will come a point at which the programmer needs to do something that isn&#8217;t covered.  Languages, libraries, interfaces and settings which allow the programmer to get to the meat and start replacing things are extremely desirable.  Various examples of this abound; few have had as much success as the Standard Template Library or URLs.  In this fashion, XMLHttpRequest appears to have its bases covered, with the responseText mechanism.  You can recieve things that aren&#8217;t XML and work with them how you see fit, which should open up entirely new vistas of usability and blah blah blah if you&#8217;re just willing to do some string parsing.  The idea is that since you can do raw parsing, and since these are sockets, that that allows you to use the network openly.  Herein lies XMLHttpRequest&#8217;s secret flaw &#8211; requestText is crippled by the connection mechanism.  This isn&#8217;t actually good for much more than porting pre-XML legacy web services.</li>
</ol>
<p>See, I started writing this AJAX tutorial, and I was getting all into it.  I started by writing a lightweight DOM calculator to get people used to working on the document model from a scripting language.  It went well, and Uncle Fatty was happy.  The idea was to move from that to writing a chess game.  Since I used to work for one of the big chess service providers, I decided that what I actually ought to write was a client which touched their servers.</p>
<p>Ha ha.  Joke&#8217;s on me.  See, I fell for it too: if it does responseText, then I can just parse whatever I get manually, and everything&#8217;ll be flowers and syrup, right?  So, I start by porting my old <a title="Style 13, Level 2 Datagrams" href="ftp://ftp.chessclub.com/pub/icc/formats/formats.txt">style13-2</a> and <a title="What you expected, huhu" href="http://www.chessclub.com/help/style12">style12</a> parsers, so that I can touch <a title="FICS, the Free Internet Chess Server" href="http://www.freechess.org/">FreeChess</a>, <a title="The Internet Chess Club" href="http://www.chessclub.com/">ChessClub</a> and <a title="US Chess Live, neé GamesParlor" href="http://www.chess-live.com/">ChessLive</a>.  Porting them into <a title="ECMAscript, the basis of JavaScript, JScript, ActionScript and so on" href="http://www.ecma-international.org/publications/standards/Ecma-262.htm">ECMA</a> was moderately tehsuck, but to be honest it coulda been worse, so I&#8217;m not complaining <em>much</em>.  Built those on edit boxes, fed it a command, it reacted, and eventually I found the right neurons to make the frog jump, and everything was hoppy.  Spent some time nailing stupid effects from <a title="Rico ... suavé" href="http://openrico.org/">Rico</a> and <a title="No, I'm not putting the periods in.  They look stupid." href="http://script.aculo.us/">Scriptaculous</a> onto it, and generally had myself a fun waste of a couple of hours.  Even hammered out a froody little chat system.</p>
<p>Then, it&#8217;s time to get down to the horror that is nailing XMLHttpRequest onto the service, right?  Because I can parse whatever I receive, so it&#8217;ll be candy and bee-farts, right?  <em>Ha, ha: you sir got screwed</em>.</p>
<p>Y&#8217;see, folks, it&#8217;s called XMLHttpRequest for a reason.  It&#8217;s not really sockets, no matter how much .responseText wants to trick you into thinking it is.  It doesn&#8217;t matter if you can parse whatever random damn thing you receive, because of one ugly detail: <strong>there is no way to make a connection without sending HTTP headers first</strong>.  Now, I&#8217;m sure several people laughing at me for being stupid right now.  On the one hand, I did earn it, and so I deserve it; on the other hand, shut up.  At first I thought I was going to fake it by turning off all the headers, but it turns out that the <a title="setRequestHeader" href="http://www.w3.org/TR/XMLHttpRequest/#dfn-setrequestheader">definition of setRequestHeader</a> essentially prohibits it from being possible at all.  Thing is, it&#8217;s actually very easily reparable.  Now, let&#8217;s pretend for a moment that security is the province of the browser author and not the specification, and that raw sockets haven&#8217;t existed safely in Flash for quite a while already.  Raw sockets themselves aren&#8217;t fundamentally dangerous, and because of the way buffering is bound up in the object, it&#8217;s actually a pretty safe playground.</p>
<p>The more important bit, though, is how <strong><em>ridiculously</em></strong> powerful such a tool would be.  That would, in many ways, be what X always wanted to be: a strong, powerful, scripted, media-rich and gracefully degrading platform for semi-thin network applications.  This has the advantage of having all the &#8220;server&#8221; behavior bound up in the web browsers, already far better standardized and far more powerful than X ever was (I&#8217;m sure I&#8217;ll take flak for saying that.)  My chess client is a good example of what could be powerful here: if I could just say &#8220;no, don&#8217;t send the HTTP headers,&#8221; suddenly I would have a portable rich chess client in trivially little code.</p>
<p>As of now, I have to write a stupid little server whose entire purpose is to intercept AJAX, strip the http headers away, then act as a passthrough to the real server.  It&#8217;s a waste of machine time, a waste of bandwidth and of coding effort.  And, the thing is, I think if we don&#8217;t change the XMLHttpRequest object to accomodate, we&#8217;re going to see a lot of just that kind of behavior.  Sure, the original intent of the object was to allow web browsers to embed browsing behavior in their scripting, essentially allowing scripts to act like clients.  That said, sometimes a mechanism is far more powerful than its original intent (Tim Berners-Lee&#8217;s invention of a way to keep data around the particle collider up to date is a beautiful example, because I&#8217;m using its grandchild to put this argument together right now.)</p>
<p>Sometimes small modifications to allow the programmer better control are worth their weight in gold.  Yes, I realize it was an HTTP request mechanism.  I think it shouldn&#8217;t be.  The allowance is made for raw receiving in responseText, because the utility is obvious.  The allowance should be made for raw sending, too.  I believe it&#8217;s significantly important.  This would be a major step towards portable rich applications with network capabilities.  The actual implementation shift is tiny, well-understood and safe.  This really, <em>really</em> needs to be done.</p>
<p>Of course, once you do that, another fairly serious issue rears its head: that this is a one-directional avenue for communication.  We want to build deeply connected apps, here!  We always have, back through SOAP and DCORBA and X11 and UUX and so on.  There are several docs out there dedicated to the issue of emulating server push, many of which use <a title="Server Push" href="http://www.xulplanet.com/tutorials/mozsdk/serverpush.php">browser extensions</a> or to get the job done.  A much more common answer, since it&#8217;s portable, is polling, which is immensely work- and bandwidth-wasteful, and puts a direct server tax on reducing lag (the faster they poll, the harder you have to work to cover something that really should just be data being sent out.)  There are already tons of applications which work this way, and it&#8217;s just going to get worse.  However, there is an unexplained parameter in the connection list called &#8220;<tt>async</tt>&#8221; which may handle exactly this; if so, the second set of needs is obviated.</p>
<p>On those grounds, I recommend the following alterations to the XMLHttpRequest standard:</p>
<p><u>Overview</u>:</p>
<p>To support the direction that AJAX is already taking itself and to reduce the implementation cost of certain commonly desired features, we will define mechanisms to implement raw connections aside from the default HTTP connections, and to recieve server pushed data without extraneous polling mechanisms.  This requires minor but significant alterations to several parts of the proposed standard, and though the implementation cost of these changes is small, it requires a significant re-evaluation of the potential of the mechanism.</p>
<p>In the definition of <tt>open()</tt>, the modes <tt>GET</tt>, <tt>POST</tt> and <tt>PUT</tt> are required.  Two other methods are questionned, suggesting that there is still flexibility in the mode list.  That&#8217;s good: this is the natural place to add raw connection.  I propose a fourth mode: <tt>RAW</tt>.</p>
<ol>
<li>It seems appropriate that <tt>RAW</tt> be placed in the <tt>MUST</tt> support group; things can be supported and turned off for security reasons, and it&#8217;s important that we be able to write software which can check for these things and then move on.</li>
<li><tt>RAW</tt> suppresses all HTTP negotiation and all HTTP headers.  Headers may not be set with <tt>setRequestHeader()</tt> on a <tt>RAW</tt> method connection.</li>
<li>The current send-recieve <tt>readyState</tt> reporting mechanism would not be sufficient for RAW.  Likely the most appropriate thing to do would be to add another enumerant to the state to represent bidirectional transfer, and to change the state transition rules for <tt>RAW</tt> sockets.  This seems likely to result in the most amenable environment to older code.  The state changes would need to be altered to allow <tt>send()</tt> on a <tt>RAW</tt> socket during any state other than 0.  Because of the editorial note suggesting that <tt>readyState</tt> transition be amended for <tt>HEAD</tt> method requests, it seems the editorial body is already amenable to different <tt>send()</tt> semantics for different <tt>readyState</tt>s.</li>
<ol>
<li>There is the question of how to handle sequential input and sequential output.  Receipt on a RAW socket should probably just append onto the existing buffer, as well as attempting to send while send is already underway (or, the current exception behavior could be maintained for the latter case; that&#8217;s a matter of opinion, but I believe queueing is appropriate.)</li>
<li>There is also the argument that each distinct read be cached in a seperate entry in an array, but without the HTTP transport, there would need to be a way to distinguish packet breakup from seperate transfer; it seems inappropriate, especially that this is meant to be a raw socket, and as such I believe the former answer is superior.</li>
</ol>
</ol>
<p>Actually, the second point as a casualty covers server push, too: with the bidi mode in place, you can safely handle any state transition, so we can just happily fire lots of state changes to cover each server push.  This makes <tt>async</tt> (probably) unnessecary.  Because many deployed AJAX codebases don&#8217;t account for such situations, it may be appropriate to keep the current behavior stable, and to add another HTTP request type that has RAW-style state transitions (this would also neatly handle the <tt>HEAD</tt> problem) called, say, <tt>PUSH</tt>, which would allow the immediate deployment of network applications which aren&#8217;t tied to the client-server pipe mindset.</p>
<p>This approach has several advantages:</p>
<ol>
<li>This approach is similar to concepts already under discussion and uses similar mechanisms, but covers several under consideration issues in less work, and in a way which opens up an extremely powerful new tool.</li>
<li>This approach would have essentially zero impact on deployed code, and would cause no disruptions to existing deployments.</li>
<li>This approach can be handled quite easily in a way to degrade gracefully in situations where a polling style mechanism or something similar provides an adequate substitute.</li>
<li>This approach drastically reduces idle bandwidth for certain network connection behaviors.</li>
<li>This approach is extremely easy to implement at a browser level, consisting essentially of work that&#8217;s already done with bits ripped out.  It is likely to be extremely quickly deployed if adopted by a standards body.  Hacks to approach both of the behaviors this allows are already becoming widespread.  We need to open this floodgate early so that it can be handled in a standard fashion; browsers are already starting to expose their guts, and there&#8217;s a possible browser incongruity in the near future if we don&#8217;t get this handled right now.</li>
<li>This provides an extremely pleasant new avenue for thin client development, and will catch like wildfire in the existing AJAX crowd.</li>
</ol>
<p>Please give these changes serious consideration.  If you support them, get some trackbacks going and get the word out.  This is the sort of thing that not too many people will see the importance of, so it&#8217;s important that the word get around so that the right people can pick up the sound.  If you don&#8217;t agree, tell me why.</p>
<p>XMLHttpRequest is in the hands of two people, and small groups of people are often more likely to listen than large groups.  Their minds can be changed.  Want real HTML network clients?  Help me change them.</p>
]]></content:encoded>
			<wfw:commentRss>http://fullof.bs/the-xmlhttprequest-object-so-close-and-yet-so-far/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
	</channel>
</rss>

