<?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>Embracing Chaos &#187; Computer Science</title>
	<atom:link href="http://www.embracingchaos.com/computer-science/feed" rel="self" type="application/rss+xml" />
	<link>http://www.embracingchaos.com</link>
	<description>Leo Parker Dirac on Business and Technology Trends</description>
	<lastBuildDate>Wed, 14 Jul 2010 01:21:03 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Gmail Slowing Down: Why and how to fix it</title>
		<link>http://www.embracingchaos.com/2007/09/gmail-slowing-d.html</link>
		<comments>http://www.embracingchaos.com/2007/09/gmail-slowing-d.html#comments</comments>
		<pubDate>Thu, 20 Sep 2007 16:47:00 +0000</pubDate>
		<dc:creator>leodirac</dc:creator>
				<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Geek]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[User Experience]]></category>

		<guid isPermaLink="false">http://wp.embracingchaos.com/2007/09/gmail-slowing-d.html</guid>
		<description><![CDATA[Gmail feels like it is slowing down to me. Maybe my standards are going up. Or maybe gmail's user base has grown to the point where the servers to run it cost real money to Google, and they've throttled the computing resources to an "acceptable level of performance." But it bothers me when I hit the "archive" button and I have to wait half a second for the UI to respond. Sometimes even a couple of seconds. Why does it take so long? Just to get that line off my inbox screen? The answer lies in computer science. Gmail is...
]]></description>
			<content:encoded><![CDATA[<p>Gmail feels like it is slowing down to me.&nbsp; Maybe my standards are going up.&nbsp; Or maybe gmail&#8217;s user base has grown to the point where the servers to run it cost real money to Google, and they&#8217;ve throttled the computing resources to an &quot;acceptable level of performance.&quot;&nbsp; But it bothers me when I hit the &quot;archive&quot; button and I have to wait half a second for the UI to respond.&nbsp; Sometimes even a couple of seconds.&nbsp; Why does it take so long?&nbsp; Just to get that line off my inbox screen?&nbsp; The answer lies in computer science.</p>
<p><strong>Gmail is written using a classic MVC pattern</strong> &#8212; Model, View, Controller.&nbsp; The View reflects changes in the Model, and the Controller tells them what to do.&nbsp; Clearly the View is our web page, and in this implementation, the Model is stored on Google&#8217;s servers.&nbsp; What this means is that when you do something like archive a message, you&#8217;re not going to see the results until a message is sent to Google&#8217;s servers and the response comes back.&nbsp; Now Google has really fast servers, but networks are slow.&nbsp; <strong>By following this design pattern, Gmail is easy to code new features for and maintain relatively bug-free, but it&#8217;s never going to be all that fast.<br /></strong></p>
<p>Gmail engineers could code up optimizations for special cases.&nbsp; For example, when I&#8217;m looking at my inbox and I hit archive on a message, they could detect this case, and just remove it from the page and then tell the server afterwards.&nbsp; This kind of coding will quickly make the Gmail hard to maintain and result in lots of bugs.&nbsp; Especially when you consider that multiple clients can connect to a single gmail account at once.&nbsp; Strictly following MVC makes it easy to resolve conflicts in one place &#8212; the server.</p>
<h3>A Proposed Solution</h3>
<p>There is a solution though.&nbsp; <a href="http://gears.google.com/">Google Gears</a> can help.&nbsp; The Gmail UI could be (and for all I know currently is being) re-architected to <strong>use Google Gears as the Model</strong> in the MVC pattern.&nbsp; This means any operation in the UI would be committed very quickly to the SQLite database on your hard drive.&nbsp; Then another thread would synchronize these changes in the background with the master model on Google&#8217;s servers.&nbsp; Everything works &#8212; UI operations are reflected to the user extremely quickly.&nbsp; We don&#8217;t lose all the benefits of storing all our data on the server.&nbsp; And as an added bonus, we can still work on our e-mail when our computers are offline.&nbsp; Yet another reason <a href="http://www.embracingchaos.com/2007/09/why-google-gear.html">why Google Gears is important</a>.</p>
<p>So when is this coming?&nbsp; Synchronization and it&#8217;s evil twin, conflict resolution, are complex software tasks, so it could take a while.&nbsp; But if I were placing bets, I&#8217;d guess we&#8217;ll see this in the first half of 2008.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.embracingchaos.com/2007/09/gmail-slowing-d.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rhapsody Greasemonkey Script: Optimizing Text Manipulation in Javascript with Regular Expressions</title>
		<link>http://www.embracingchaos.com/2007/04/rhapsody_grease-2.html</link>
		<comments>http://www.embracingchaos.com/2007/04/rhapsody_grease-2.html#comments</comments>
		<pubDate>Wed, 25 Apr 2007 03:47:00 +0000</pubDate>
		<dc:creator>leodirac</dc:creator>
				<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Music]]></category>
		<category><![CDATA[Software Engineering]]></category>

		<guid isPermaLink="false">http://wp.embracingchaos.com/2007/04/rhapsody_grease-2.html</guid>
		<description><![CDATA[After many months of talking and thinking about it, I finally wrote a greasemonkey script to annotate web pages with Rhaplinks. The script scans web pages looking for the names of musicians and when it finds them, links them to Rhapsody.com so you can listen to music by the named artist. This simple idea is actually tricky to implement properly. Rhapsody has a lot of music and a lot of artists. So many that keeping the entire list in a javascript program is impractical, as is downloading the entire list from the server. So I took the most popular 50-100...
]]></description>
			<content:encoded><![CDATA[<p>After many months of talking and thinking about it, I finally wrote a <a href="http://www.greasespot.net/">greasemonkey</a> script to annotate web pages with <a href="http://webservices.rhapsody.com/index.php?name=News&amp;file=article&amp;sid=18">Rhaplinks</a>.&nbsp; The script <strong>scans web pages looking for the names of musicians</strong> and when it finds them, <strong>links them to <a href="http://www.rhapsody.com/">Rhapsody.com</a> so you can listen to music</strong> by the named artist.</p>
<p>This simple idea is actually tricky to implement properly.&nbsp; Rhapsody has a <em>lot</em> of music and a <em>lot </em>of artists.&nbsp; So many that keeping the entire list in a javascript program is impractical, as is downloading the entire list from the server.&nbsp; So I took the most popular 50-100 artists in each primary genre and combined them into a single manageable list of about 1,000 names.</p>
<p>This idea is made practical by one of my favorite features of Rhapsody.com &#8212; human-writable URLs.&nbsp; Assuming your browser is set up properly (install plugin, enable pop-ups), opening <a href="http://play.rhapsody.com/Morcheeba">http://play.rhapsody.com/Morcheeba</a> causes Morcheeba to start playing.&nbsp; &nbsp;This API (can URL&#8217;s be API&#8217;s?&nbsp; I think so!) accepts punctuation too &#8212; <a href="http://play.rhapsody.com/R.E.M.">http://play.rhapsody.com/R.E.M.</a> will play R.E.M.&nbsp; And thanks to a generous interpretation of the HTTP spec by just about everybody, <a href="http://play.rhapsody.com/The Postal Service">http://play.rhapsody.com/The Postal Service</a> actually works too.&nbsp; (Note the technically illegal spaces in the URL.)&nbsp; What this means is that my script just needs a list of the names of the artists, and doesn&#8217;t need corresponding ID values to generate the playback URL.&nbsp; In fact, you can browse <a href="http://www.Rhapsody.com">www.rhapsody.com</a> for quite a while before ever seeing a database ID in your address bar.&nbsp; Which brings me to the interesting part of this post.</p>
<p><u><strong>Computer Science Interlude</strong></u></p>
<p><strong>Javascript is</strong> a <strong>slow</strong>, interpreted language.&nbsp; The straightforward way to write this script would be to loop through a list of artist names, replacing each one in the document.&nbsp; Something like this:</p>
<p><code>var artists = ['The Postal Service', 'Morcheeba', 'Massive Attack', 'Madonna', 'Tosca', 'Underworld' ];&nbsp; // The actual list is much<br />
longer...</p>
<p>for(var i=0; i&lt;artists.length; i++) {<br />&nbsp; &nbsp;document.body.innerHTML = document.body.innerHTML.replace( //... some regular expression<br />&nbsp; &nbsp;);<br />}</code></p>
<p>This script would run very slowly.&nbsp; To <strong>scan an HTML document with N characters for M artist names</strong> this way would take O(N*M) time.&nbsp; &nbsp;Instead I wrote the script in just 2 lines as follows:</p>
<p><code>var regex = /\b(The Postal Service|Morcheeba|Massive Attack|Madonna|Tosca|Underworld)\b/gi;&nbsp; // The actual list is much longer...</p>
<p>document.body.innerHTML= document.body.innerHTML.replace(regex,&quot;&lt;a href=\&quot;http://play.rhapsody.com/$1\&quot; title=\&quot;Play $1 on Rhapsody\&quot; &gt;$1&lt;img src='http://www.rhapsody.com/favicon.ico' alt=\&quot;Play $1 on Rhapsody\&quot;/&gt;&lt;/a&gt;&quot;);</code></p>
<p><code></code></p>
<p><a href="http://regex.info/"><img border="0" src="http://regex.info/i/mre3_sm.gif" style="padding: 5px; float: left;" /></a>This might look like a cop-out &#8212; a cheezy easy way to do this.&nbsp; But it&#8217;s actually much faster.&nbsp; This will run <strong>in about O(N) time</strong> (assuming N&gt;&gt;M).&nbsp; The single giant regular expression looks for any of the artist-name-keywords and applies it to the whole HTML document at once.&nbsp; <strong>Firefox&#8217;s highly-optimized C++ regular expression engine compiles the big artist list into a single state-machine which</strong> is applied to the HTML much faster than anything I could possibly write in javascript.&nbsp; Regular expression interpreters are brilliantly efficient.&nbsp; Check out <a href="http://regex.info/">Jeffrey Friedl&#8217;s excellent Regular Expressions book</a> if you want to know more about this highly practical topic.&nbsp; The result is that the script can parse a document for a large number of artist names in a totally tolerable amount of time.&nbsp; There&#8217;s a short delay when the page loads, but it&#8217;s still faster than browsing in IE.</p>
<p><u><strong>Enough Theory.&nbsp; Let&#8217;s get down to practice!</strong></u></p>
<p>The script isn&#8217;t perfect, but it&#8217;s pretty neat to <strong>use it to browse Myspace or Facebook and have a lot of the music people mention be instantly playable</strong>.&nbsp; </p>
<p>If you&#8217;d like to play with it, <a href="https://addons.mozilla.org/firefox/748/">install Greasemonkey</a>, and then install the Rhapsody Artist Linker script <a href="/downloads/rhapartist.user.js">here</a>.</p>
<p><em>[Update 5/4/07: a new and improved script is available <a href="/downloads/rhapsody-artist-linker.user.js">here</a>.&nbsp; Read about <a href="http://www.embracingchaos.com/2007/05/rhapsody_grease.html">the changes</a>.]</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.embracingchaos.com/2007/04/rhapsody_grease-2.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Free Will and Turing-completeness of the Brain</title>
		<link>http://www.embracingchaos.com/2007/02/turing_complete.html</link>
		<comments>http://www.embracingchaos.com/2007/02/turing_complete.html#comments</comments>
		<pubDate>Thu, 22 Feb 2007 23:20:00 +0000</pubDate>
		<dc:creator>leodirac</dc:creator>
				<category><![CDATA[Chemistry]]></category>
		<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Philosophy]]></category>
		<category><![CDATA[Physics]]></category>
		<category><![CDATA[Science]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Transhumanism]]></category>
		<category><![CDATA[Uploading]]></category>

		<guid isPermaLink="false">http://wp.embracingchaos.com/2007/02/turing_complete.html</guid>
		<description><![CDATA[In this essay, I'm going to explore the question "If the human brain is Turing complete, what does that imply about the existence of free will?" And moreover, what does that mean about the ability to upload our consciousness into computers? First, a little computer science background. Turing completeness is the idea that a computing system has the same capabilities as a universal Turing machine. This theoretical machine moves along a long tape which has various symbols on it that the machine can read and write. The machine itself is always in one internal state, but will change to different...
]]></description>
			<content:encoded><![CDATA[<p>In this essay, I&#8217;m going to explore the question &quot;<strong>If the human brain is Turing complete, what does that imply about the existence of free will?</strong>&quot;&nbsp; And moreover, what does that mean about the ability to upload our consciousness into computers?</p>
<p>First, a little computer science background.&nbsp; Turing completeness is the idea that a computing system has the same capabilities as a universal Turing machine.&nbsp; This theoretical machine moves along a long tape which has various symbols on it that the machine can read and write.&nbsp; The machine itself is always in one internal state, but will change to different states based on its programming and input.&nbsp; It is programmed by a huge state transition table which says &quot;if you&#8217;re in state <em>X</em>, and you&#8217;re reading symbol <em>Y</em>, then write symbol <em>Z</em>, move <em>left n</em> spaces, and switch to state <em>W</em>&quot; for all possible states and symbols.&nbsp; It turns out that with a long enough tape and enough states this device can do just about anything you think of a computer being able to do.&nbsp; In fact, computer scientists have shown that every modern computer system is functionally equivalent to a Turing machine.&nbsp; That is to say <strong>all modern computers are Turing complete</strong>.&nbsp; It&#8217;s useful because it&#8217;s simple enough to prove theorems about.&nbsp; Some important things we know about Turing machines and anything which is functionally equivalent to one: </p>
<ul>
<li><strong>Turing machines are deterministic</strong> &#8212; given a set of inputs they&#8217;ll always reach the same output.</li>
<li>It&#8217;s impossible to reliably predict whether or not a program on a Turing machine will ever finish.</li>
</ul>
<p>I see two ways to interpret the question of whether or not a human brain is Turing complete.&nbsp; The first one is &quot;<strong>Can a human brain perform the same functions as a Turing machine?</strong>&quot;&nbsp; I think that given a pen, paper, and enough patience the answer is <strong>clearly yes</strong>.&nbsp; But that&#8217;s not the question that interests me.</p>
<p>As a transhumanist, the interesting question for me is &quot;<strong>Can a Turing-complete computer perform the same functions as a human brain?</strong>&quot;&nbsp; This question is important to me because if the answer is yes, then it is possible for a computer to simulate a human personality.&nbsp; That is to say uploading of a human consciousness into a computer is possible.&nbsp; I&#8217;m going to dodge the detailed analysis of this question today, and get back to it in a later article.&nbsp; For now, let&#8217;s <strong>assume</strong> the answer is <strong>&quot;Yes&quot;</strong> and see what that implies about free will.</p>
<p>Remember that theorem that says Turing machines are deterministic?&nbsp; That is, once you start it going with a given set of inputs, that it&#8217;s always going to reach the same answer?&nbsp; If this were true for us as humans, then we would have no free will &#8212; our actions would be entirely determined by our current state and our surroundings.&nbsp; We might think we are making choices, but in fact a fast computer could run the same calculation and tell us what our answer would be before we thought we had decided.&nbsp; So by this logic <strong>if uploading is possible, then humans have no free will</strong>.&nbsp; Troubling, eh?</p>
<p>Fortunately, I think the above analysis has a flaw.&nbsp; Let&#8217;s dive down a little deeper into neurochemistry.&nbsp; Neurons fire as a result of electro-chemical processes.&nbsp; Basic chemistry tells us that the rates of chemical reactions are deterministic based on concentrations of the relevant input chemicals.&nbsp; But if you took stat-mech then you learned that these predicted rates are actually just statistical averages and that they&#8217;re only accurate if the brazillions of molecules involved happen to collide with each other at a constant frequency as they randomly bounce around in solution.&nbsp; And quantum mechanics tells us that this apparently random bouncing around is in fact, to Einstein&#8217;s chagrin, truly random &#8212; god does play dice with the universe.&nbsp; (I&#8217;m not sure I completely buy this, but I&#8217;ll have to save that for another article too.&nbsp; Yes, I know that the Bell inequalities were experimentally observed in the 1980&#8217;s but it still sits funny with me.&nbsp; Sorry <a href="http://en.wikipedia.org/wiki/Paul_Dirac">grandpa</a>.&nbsp; More on this later.)&nbsp; Because of this randomness, <strong>the instantaneous rate of any chemical reaction will vary randomly</strong>, while still averaging around the classically predicted rate.&nbsp; So the upshot is that neurons don&#8217;t behave completely deterministically, but that <strong>the exact timing of neurons firing has a truly (quantum) random component to it</strong>.</p>
<p>Now this implies quite firmly that our brains cannot be simulated by a Turing machine since Turing machines can&#8217;t act randomly, and thus wouldn&#8217;t be able to properly simulate the randomness of neurons firing.&nbsp; But if we modify a Turing machine slightly so that a spot on its tape read a different random symbol each time you check, I think we&#8217;re good.&nbsp; Given this, it seems reasonable that <strong>a modern computer that has a source of truly random data could simulate a brain</strong>.&nbsp; Some have argued that we need quantum computers to simulate consciousness, but I don&#8217;t think so.&nbsp; (Again, more on this later.)</p>
<p>Computers are pretty good at generating psuedo-random data internally, and by listening to the outside world (hard drive vibration, microphones, etc) can generate what is probably actually random data.&nbsp; If true randomness is really important, we can build small accessory cards that sample thermal noise on<br />
a resistor and produce large volumes of truly (quantum) random data.&nbsp; Some advanced cryptographic systems do this today.&nbsp; So it&#8217;s totally possible today to build this modified Turing machine that also incorporates random input.</p>
<p>Now our transhuman dilemma is solved.&nbsp; The <strong>essence of free will lies in the quantum randomness of electro-chemical processes in our brain</strong>.&nbsp; Moreover, it will be possible to upload our personalities into computers, complete with our free wills in tact, by incorporating random processes into the hardware that simulates our brains.&nbsp; If the computers we upload into are only psuedo-random (as almost all software is today), we will appear to have free will, in fact we will believe that we have it, but we will in fact be total robots.&nbsp; Now, who can come up with <strong>a Turing test for free will?</strong></p>
<p><em>[[Thanks to Barry Brummit.&nbsp; This article is a rehash of a couple good conversations we had over New Year's and this morning after yoga practice.]]</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.embracingchaos.com/2007/02/turing_complete.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
