<?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>Databases and Life</title>
	<atom:link href="http://www.databasesandlife.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.databasesandlife.com</link>
	<description>Adrian Smith's blog</description>
	<lastBuildDate>Mon, 14 Jun 2010 09:41:07 +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>Multi-core RISC OS proposal</title>
		<link>http://www.databasesandlife.com/multi-core-risc-os-proposal/</link>
		<comments>http://www.databasesandlife.com/multi-core-risc-os-proposal/#comments</comments>
		<pubDate>Fri, 11 Jun 2010 13:43:37 +0000</pubDate>
		<dc:creator>adrian</dc:creator>
				<category><![CDATA[Software Design]]></category>

		<guid isPermaLink="false">http://www.databasesandlife.com/?p=551</guid>
		<description><![CDATA[I was reading an article about the RISC OS operating system and the fact that it doesn&#8217;t support multiple CPU cores. Then I got to thinking, how would one implement multi-CPU support on such an operating system?
Between 1989 and 1994 I used a British computer running the operating system RISC OS. This operating system is [...]]]></description>
			<content:encoded><![CDATA[<p><strong>I was reading an article about the RISC OS operating system and the fact that it doesn&#8217;t support multiple CPU cores. Then I got to thinking, how would one implement multi-CPU support on such an operating system?</strong></p>
<p>Between 1989 and 1994 I used a British computer running the operating system <a href="http://www.wrocc.org.uk/riscos/what.shtml">RISC OS</a>. This operating system is still alive, and is still in use. It was produced by <a href="http://en.wikipedia.org/wiki/Acorn_Computers">Acorn Computers</a> and runs on the <a href="http://www.arm.com/">ARM processor</a> (&#8220;Acorn Risc Machine&#8221;), now found in many computing platforms such as the iPhone. It has many innovative features which haven&#8217;t made it yet to other operating systems (although is the topic for a post of its own!)</p>
<p>Back then there was obviously no need to support multiple CPUs. So today one has the choice of either finding single-core CPUs (will become increasingly difficult) or using a multi-core CPU with all but one core inactive (which is a waste). Various <a href="http://www.drobe.co.uk/riscos/artifact1690.html">fora</a> speculate on the technical possibility or impossibility of utilizing the extra cores. I don&#8217;t think it would be especially difficult. This article describes how I would go about it.</p>
<p>Constraints and information about RISC OS:</p>
<ul class="tight">
<li>RISC OS can run multiple programs at once but yet has no concept of pre-emptive multi-tasking, threads, processes, etc.</li>
<li>It&#8217;s extremely old, therefore extremely fast on modern processors (even running on only one core)</li>
<li>Many parts of the operating system, such as those to do with the filesystem, are marked as &#8220;non re-entrant&#8221; in the documentation, that means they would need to be re-written or altered to work with pre-emptive multi-tasking or simultaneous execution (multi-core), for example locks would need to be introduced.</li>
</ul>
<p>For me at least, I would say that the way the system currently operates on a single core is already very fast (when running at less than full speed via emulation on an x86 processor &#8211; it runs faster than it did on native hardware in the 1990s, it runs faster than Windows ran in the 1990s, and faster than Windows runs today.) So I think for most tasks, there is no need to use additional cores.</p>
<p>I am used to working in companies with limited human resources, and due to the fact that RISC OS isn&#8217;t a mainstream operating system, I am going to assume that this would also be a constraint with any solution to introduce multi-core capabilities to RISC OS. That means a complete re-write of RISC OS and applications, or even visiting every single part of the operating system and introducing locking and the expectation that any function can be called at any time due to pre-emptive multi-tasking and simultaneous execution by multiple cores, is also out of the question.</p>
<p>So my solution would be to assume that those extra cores should do &#8220;pure CPU&#8221; work, for example video processing, rendering fractals, or other CPU-intensive work. All work like accessing the filesystem, interacting with the user, which is already fast enough, would <em>not </em>be given the opportunity to work even faster by being executed in parallel on multiple cores.</p>
<p>I would write a very simply layer, similar to a hypervisor, which would run under RISC OS, which would simply handle allocation of CPU and memory resources. This supervisor would allow processes to run, which would not share memory (and thus not need to support shared-memory primitives such as locking). Pipes would allow processes managed by the supervisor to communicate.</p>
<p>The first, and often the only process, which this supervisor would manage, would be the entire existing RISC OS and all applications. This process would manage the user-interface, network, filesystem, printers and communication between all running RISC OS applications. So this &#8220;RISC OS + applications&#8221; process would run largely unaltered from the existing software (saving much development time; but also providing no benefit in terms of speed increase).</p>
<p>But there would be an extra API available to applications to spawn new processes managed by the supervisor, which would execute asynchronously, and primitives to pass/receive messages from those spawned processes. The supervisor would run these processes on the different cores, and pre-emptively multi-task the processes in the case of more processes than cores.</p>
<p>I would take the approach to concurrency of &#8220;message-passing with no shared memory&#8221; as opposed to &#8220;shared memory (threads)&#8221; for two reasons:</p>
<ul>
<li>Existing RISC OS lacks the primitives to deal with shared memory and pre-emptive concurrency (such as locking), so it would not be possible to allow the spawned processes to interact with the main memory of the RISC OS applications. (Although it would be theoretically possible to allow the spawned processes to themselves have threads, although that would require introducing extra concepts such as locking to the supervisor.)</li>
<li>It might be argued one would need to support shared-memory computation to allow existing software to be easily ported to the platform, however this isn&#8217;t really a concern as porting software to RISC OS is next to impossible for other reasons: there is no POSIX, and the concepts provided by POSIX such as streams unifying filesystem access, inter-process communication, network access, are not available on RISC OS (and I would not advocate building them in the supervisor.)</li>
</ul>
<p>I would allow &#8220;pipes&#8221; to be created between the processes and the pipes store an ordered set of &#8220;messages&#8221;, each message is simply a bunch of bytes. RISC OS software is generally written in C so just passing the byte-contents of a &#8220;struct&#8221; is easy and convenient. (This is the Erlang philosophy: <a href="http://www.facebook.com/note.php?note_id=379717628919">Facebook say</a> &#8220;Erlang&#8230; approaches concurrency with three iron rules: no shared memory even between processes on the same computer, a standard format for messages passed between processes, and a guarantee that messages are read in the order  in which they were received.&#8221;)</p>
<p>This proposal has the following consequences:</p>
<ul class="tight">
<li>The supervisor would be reasonably easy to write</li>
<li>RISC OS and applications would not need to be re-written. The application developer can, at a time of their choosing, decide to take advantage of the new feature, and surgically alter their code by altering only that part of the code where the speed improvement is desired (i.e. processing logic, not the GUI)</li>
<li>The supervisor as described would not consume many resources (i.e. the system would not suddenly become radically slower due to the introduction of this layer.)</li>
<li>The system would work as well on single-CPU systems as on multi-CPU systems (so software written with the new system can work on older single-core hardware)</li>
<li>One could envisage such software also running across multiple networked computers, so if a colleague&#8217;s computer was not in use (e.g. they were on holiday) ones own computer could become faster.</li>
</ul>
<p>Admittedly there although there is no performance loss, there is also no performance gain until apps are extended. However I think spending the work to add pre-emptive multi-tasking to RISC OS (a huge undertaking) simply isn&#8217;t necessary: RISC OS works well as it is, and arguably is a lot more reliable (in terms of repeatable and therefore testable behaviour) due to its cooperative nature. The original designers of RISC OS could have created a pre-emptive multi-tasking operating system instead of RISC OS &#8212; the hardware supported it (<a href="http://en.wikipedia.org/wiki/RISC_iX">RISC/iX</a> ran on it) &#8212; but they actively decided not to do that.</p>
<p>See also:</p>
<ul class="tight">
<li><a href="http://www.simtec.co.uk/products/AUHYDRA/files/api.txt">Hydra card for RiscPC</a> &#8211; Supports shared memory and access to filesystem etc., so necessarily more complex</li>
<li><a href="http://www.riscosopen.org/forum/forums/5/topics/406">Discussion of adding multi-core capability to &#8220;RISC OS Open&#8221; </a></li>
<li><a href="http://developer.apple.com/Mac/library/documentation/Carbon/Conceptual/Multitasking_MultiproServ/02concepts/concepts.html">Adding multi-processor support to Mac OS classic</a>, in many ways a similar situation.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.databasesandlife.com/multi-core-risc-os-proposal/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sudoku Solver</title>
		<link>http://www.databasesandlife.com/sudoku/</link>
		<comments>http://www.databasesandlife.com/sudoku/#comments</comments>
		<pubDate>Sat, 15 May 2010 13:45:16 +0000</pubDate>
		<dc:creator>adrian</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.databasesandlife.com/?p=515</guid>
		<description><![CDATA[
 div#sudokucontainer {  height:460px; text-align:center; }
 table.sudoku { empty-cells: show; border-collapse: collapse;  margin-left: auto; margin-right: auto; }
 table.sudoku div { font-size: 10pt }
 tr.sudokurow td { text-align:center; border: 1px solid #CCC; }
 tr.sudokurow td.leftcol { border-left: 3px solid black;  }
 tr.sudokurow td.rightcol { border-right: 3px solid black;  }
 tr.sudokurow.start td { [...]]]></description>
			<content:encoded><![CDATA[<style>
 div#sudokucontainer {  height:460px; text-align:center; }
 table.sudoku { empty-cells: show; border-collapse: collapse;  margin-left: auto; margin-right: auto; }
 table.sudoku div { font-size: 10pt }
 tr.sudokurow td { text-align:center; border: 1px solid #CCC; }
 tr.sudokurow td.leftcol { border-left: 3px solid black;  }
 tr.sudokurow td.rightcol { border-right: 3px solid black;  }
 tr.sudokurow.start td { border-top: 3px solid black;  }
 tr.sudokurow.end td { border-bottom: 3px solid black;  }
 tr.sudokurow td { width: 40px; height: 40px; }
 tr.sudokurow span.result { color: #AAA; }
 tr.sudokurow span.result,
 tr.sudokurow span.userentered,
 tr.sudokurow input.number { font-size: 19pt; font-family: helvetica }
 tr.sudokurow input.number { width: 20px; padding-left:2px; border:0; }
 table.sudoku td.statusrow { height:30px; text-align:center; vertical-align:top }
 table.sudoku td.statusrow .message { padding-left: 5px; }
 table.sudoku td.submitinfo { text-align:left  }
 table.sudoku td.submit { height:30px; text-align:right }
 table.sudoku div.spinner { text-right center ; }
 table.sudoku div.spinner img { margin-top:5px; margin-right: 10px; }
 td.statusrow .error,
 td.statusrow .success {
    padding-left: 7px;
    padding-right: 7px;
    display: inline;
    overflow: hidden;
 }
 td.statusrow .error {
    color: #800;
    background-color: #FCC;
    border: solid 1px red ;
 }
 td.statusrow .success {
    color: #080;
    background-color: #EFE;
    border: solid 1px green ;
 }
</style>
<table width="100%"">
<tr>
<td align="center">
<div id="sudokucontainer">
 </div>
</td>
</tr>
</table>
<p>The above is a Sudoku solver I wrote in Java a while back. Here it is running in the browser. The Java has been converted to in-browser Javascript by Google Web Toolkit.</p>
<p>Please feel free to type in the hardest Sudokus you can find anywhere, and let me know if it can solve them, I haven&#8217;t found any it can&#8217;t yet.</p>
<p>I assume the in-page Javascript will not work in RSS readers, email notifications, etc. If that&#8217;s the case, click here to get to the <a  href="http://www.databasesandlife.com/sudoku">original Sudoku solver page</a> on my blog.</p>
<p>The algorithm works by backtracking, i.e. simply going through all squares from top-left to bottom-right, and finding the set of &#8220;candidate numbers&#8221; for that square (i.e. which numbers are not already used on that row, column or 3&#215;3 block). The first candidate number is &#8220;applied&#8221; by placed it into the square, and the algorithm moves to the next square. If there is a square where the set of candidate numbers is empty (i.e. no number would work, given the candidates applied in previous squares) then the system returns to the previous square and tries the next candidate for that square. Once the system has gone &#8220;beyond&#8221; the bottom-right square, then the set of applied candidates consitutes a solution. However, backtracking continues, if the system reaches beyond the bottom-right square again, then the previously found solution<br />
was not unique, and the algorithm terminates. Once the system has backtracked back to the start, if a single solution was found then it is a &#8220;unique solution&#8221; (success case), otherwise if there are no solutions then the Sudoku is unsolvable.</p>
<p>By the way, Internet Explorer really isn&#8217;t that fast; I appreciate that is well-known to anyone who&#8217;s ever read Google Chrome marketing material! But the Sudoku <a href="http://z.about.com/d/puzzles/1/0/l/e/1/sudokux103.gif">here</a> takes 708ms to solve on IE8, 334ms on Firefox 3.6, about 100ms on Safari 4 and Opera 10, and 49ms on Chrome 4, on this 2.3GHz/core Intel Windows Vista computer.</p>
<p><strong>Update: </strong>Alas there were Sudokus which took too long for the original synchronous approach (i.e. user clicks, do calculation, update the screen with the results). So now, in the case the calculation takes too long, a &#8220;worker&#8221; is spawned, which does the calculation, and the spinner is displayed in that case.</p>
<p><a href="/blog-attachments/20100515-com.databasesandlife.sudoku.Sudoku/databasesandlife-sudoku-solver-source.zip">Download the source here</a>.<br />
<script language="javascript" src="/blog-attachments/20100515-com.databasesandlife.sudoku.Sudoku/com.databasesandlife.sudoku.Sudoku.nocache.js"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.databasesandlife.com/sudoku/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Mistake</title>
		<link>http://www.databasesandlife.com/mistake/</link>
		<comments>http://www.databasesandlife.com/mistake/#comments</comments>
		<pubDate>Wed, 05 May 2010 18:45:58 +0000</pubDate>
		<dc:creator>adrian</dc:creator>
				<category><![CDATA[Life]]></category>

		<guid isPermaLink="false">http://www.databasesandlife.com/?p=507</guid>
		<description><![CDATA[I sent an invoice to an agent. The first page of the PDF was the normal  invoice stuff &#8211; my name and address, their name and address, the number  of hours worked, hourly rate, total amount, etc. The second page was, as  they had requested, the hours that I&#8217;d worked; each day [...]]]></description>
			<content:encoded><![CDATA[<p>I sent an invoice to an agent. The first page of the PDF was the normal  invoice stuff &#8211; my name and address, their name and address, the number  of hours worked, hourly rate, total amount, etc. The second page was, as  they had requested, the hours that I&#8217;d worked; each day on a separate  line with the start/end time and number of hours lunch.</p>
<p>Obviously I&#8217;m not an expert on the German language and tone is always  difficult to gauge but they replied:</p>
<blockquote><p>
mit Ihrem  Anhang kann ich nichts anfangen, da es weder eine Tagesstundensumme noch  eine Monatsumme, noch Ihren Name, noch das Projekt aufweist. &#8230;  bitte  ich Sie, mir eine ordnungsgemäße Stundenaufzeichnung zu schicken
</p></blockquote>
<p>My name was on the first page, why do they need it on the second as  well? They want to know how many hours I&#8217;ve worked per day, well there  is an invention known as the spreadsheet, and that comes with a SUM(..) function.</p>
<p>But it was the tone which annoyed me the most, I mean if they need this info, they can just ask me, I&#8217;m more than happy to provide it.</p>
<p>I mean I guess one has to decide, does one just &#8220;take it&#8221; (signalling  that this sort of communication is acceptable) or does one &#8220;attack&#8221; (leading potentially to  disharmony, or, in my case, possible inappropriateness if I&#8217;ve  misinterpreted the tone). But I don&#8217;t want to just always have to &#8220;take  it&#8221; because I&#8217;m not confident enough about my German.</p>
<p>So I amended the PDF and sent it to them, but wrote to them in the mail that I assumed they would already know my name, as it was written on the first page&#8230;. (The bit about spreadsheets having been invented I left out.)</p>
<p>So I sent that off, was looking forward to see what the reply would be,  when I realized that every email I wrote to them I started with &#8220;Sehr  geehrter Herr X&#8221; and every email they wrote to me they signed &#8220;Frau X&#8221;,  nice one&#8230;. I think I have my explanation as to why they were so  displeased with me&#8230; and tomorrow they&#8217;ve got my nice aggressive answer  waiting in their inbox, also addressed to Herr X &#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.databasesandlife.com/mistake/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>My mate came across the following HTML</title>
		<link>http://www.databasesandlife.com/a-few-html-option/</link>
		<comments>http://www.databasesandlife.com/a-few-html-option/#comments</comments>
		<pubDate>Fri, 30 Apr 2010 19:03:32 +0000</pubDate>
		<dc:creator>adrian</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.databasesandlife.com/?p=494</guid>
		<description><![CDATA[
&#60;select class="selectTitle" id="C5" name="C5"&#62;
  &#60;option value=""&#62;--select--&#60;/option&#62;
  &#60;option value="1"&#62;Mr&#60;/option&#62;
  &#60;option value="2"&#62;Ms&#60;/option&#62;
  &#60;option value="3"&#62;Mrs&#60;/option&#62;
  &#60;option value="4"&#62;Miss&#60;/option&#62;
  &#60;option value="5"&#62;Doctor&#60;/option&#62;
  &#60;option value="6"&#62;Judge&#60;/option&#62;
  &#60;option value="7"&#62;Professor&#60;/option&#62;
  &#60;option value="8"&#62;Councillor&#60;/option&#62;
  &#60;option value="9"&#62;Madam&#60;/option&#62;
  &#60;option value="10"&#62;Mr &#38;amp; Mrs&#60;/option&#62;
  &#60;option value="11"&#62;Rev&#60;/option&#62;
  &#60;option value="12"&#62;Sir&#60;/option&#62;
  &#60;option value="13"&#62;Major&#60;/option&#62;
  &#60;option value="14"&#62;See Questions&#60;/option&#62;
  &#60;option value="15"&#62;Lord&#60;/option&#62;
 [...]]]></description>
			<content:encoded><![CDATA[<pre>
&lt;select class="selectTitle" id="C5" name="C5"&gt;
  &lt;option value=""&gt;--select--&lt;/option&gt;
  &lt;option value="1"&gt;Mr&lt;/option&gt;
  &lt;option value="2"&gt;Ms&lt;/option&gt;
  &lt;option value="3"&gt;Mrs&lt;/option&gt;
  &lt;option value="4"&gt;Miss&lt;/option&gt;
  &lt;option value="5"&gt;Doctor&lt;/option&gt;
  &lt;option value="6"&gt;Judge&lt;/option&gt;
  &lt;option value="7"&gt;Professor&lt;/option&gt;
  &lt;option value="8"&gt;Councillor&lt;/option&gt;
  &lt;option value="9"&gt;Madam&lt;/option&gt;
  &lt;option value="10"&gt;Mr &amp;amp; Mrs&lt;/option&gt;
<span id="more-494"></span>  &lt;option value="11"&gt;Rev&lt;/option&gt;
  &lt;option value="12"&gt;Sir&lt;/option&gt;
  &lt;option value="13"&gt;Major&lt;/option&gt;
  &lt;option value="14"&gt;See Questions&lt;/option&gt;
  &lt;option value="15"&gt;Lord&lt;/option&gt;
  &lt;option value="16"&gt;Lady&lt;/option&gt;
  &lt;option value="17"&gt;Prince&lt;/option&gt;
  &lt;option value="18"&gt;Dr&lt;/option&gt;
  &lt;option value="19"&gt;Eng&lt;/option&gt;
  &lt;option value="20"&gt;Lt Col&lt;/option&gt;
  &lt;option value="21"&gt;AirComm&lt;/option&gt;
  &lt;option value="22"&gt;AirMarsh&lt;/option&gt;
  &lt;option value="23"&gt;Archbishop&lt;/option&gt;
  &lt;option value="24"&gt;Archdeacon&lt;/option&gt;
  &lt;option value="25"&gt;Baron&lt;/option&gt;
  &lt;option value="26"&gt;Baroness&lt;/option&gt;
  &lt;option value="27"&gt;Bishop&lt;/option&gt;
  &lt;option value="28"&gt;Bombadier&lt;/option&gt;
  &lt;option value="29"&gt;BrigGen&lt;/option&gt;
  &lt;option value="30"&gt;Brigadier&lt;/option&gt;
  &lt;option value="31"&gt;Brother&lt;/option&gt;
  &lt;option value="32"&gt;Cadet&lt;/option&gt;
  &lt;option value="33"&gt;Canon&lt;/option&gt;
  &lt;option value="34"&gt;Captain&lt;/option&gt;
  &lt;option value="35"&gt;Cardinal&lt;/option&gt;
  &lt;option value="36"&gt;Chancellor&lt;/option&gt;
  &lt;option value="37"&gt;Chief&lt;/option&gt;
  &lt;option value="38"&gt;ChiefJust&lt;/option&gt;
  &lt;option value="39"&gt;Colonel&lt;/option&gt;
  &lt;option value="40"&gt;ColSgt&lt;/option&gt;
  &lt;option value="41"&gt;Commander&lt;/option&gt;
  &lt;option value="42"&gt;Commodore&lt;/option&gt;
  &lt;option value="43"&gt;Constable&lt;/option&gt;
  &lt;option value="44"&gt;Corporal&lt;/option&gt;
  &lt;option value="45"&gt;Count&lt;/option&gt;
  &lt;option value="46"&gt;Countess&lt;/option&gt;
  &lt;option value="47"&gt;Dame&lt;/option&gt;
  &lt;option value="48"&gt;Deacon&lt;/option&gt;
  &lt;option value="49"&gt;Deaconess&lt;/option&gt;
  &lt;option value="50"&gt;Dowager&lt;/option&gt;
  &lt;option value="51"&gt;Duchess&lt;/option&gt;
  &lt;option value="52"&gt;Duke&lt;/option&gt;
  &lt;option value="53"&gt;Earl&lt;/option&gt;
  &lt;option value="54"&gt;Father&lt;/option&gt;
  &lt;option value="55"&gt;FldMarsh&lt;/option&gt;
  &lt;option value="56"&gt;FlightLt&lt;/option&gt;
  &lt;option value="57"&gt;FltSgt&lt;/option&gt;
  &lt;option value="58"&gt;FlOfficer&lt;/option&gt;
  &lt;option value="59"&gt;Frau&lt;/option&gt;
  &lt;option value="60"&gt;Fraulein&lt;/option&gt;
  &lt;option value="61"&gt;Fusilier&lt;/option&gt;
  &lt;option value="62"&gt;General&lt;/option&gt;
  &lt;option value="63"&gt;GrpCapt&lt;/option&gt;
  &lt;option value="64"&gt;Guardsman&lt;/option&gt;
  &lt;option value="65"&gt;Gunner&lt;/option&gt;
  &lt;option value="66"&gt;Herr&lt;/option&gt;
  &lt;option value="67"&gt;Inspector&lt;/option&gt;
  &lt;option value="68"&gt;JusticeCL&lt;/option&gt;
  &lt;option value="69"&gt;JusticeGN&lt;/option&gt;
  &lt;option value="71"&gt;LanceBmdr&lt;/option&gt;
  &lt;option value="72"&gt;LanceCorp&lt;/option&gt;
  &lt;option value="73"&gt;LieutCdr&lt;/option&gt;
  &lt;option value="74"&gt;LieutCol&lt;/option&gt;
  &lt;option value="75"&gt;LieutGen&lt;/option&gt;
  &lt;option value="76"&gt;Lieutenant&lt;/option&gt;
  &lt;option value="78"&gt;Madame&lt;/option&gt;
  &lt;option value="79"&gt;Mdmoiselle&lt;/option&gt;
  &lt;option value="80"&gt;MajorGen&lt;/option&gt;
  &lt;option value="81"&gt;Mrchioness&lt;/option&gt;
  &lt;option value="82"&gt;Marquess&lt;/option&gt;
  &lt;option value="83"&gt;Marquis&lt;/option&gt;
  &lt;option value="84"&gt;Marshal&lt;/option&gt;
  &lt;option value="85"&gt;Master&lt;/option&gt;
  &lt;option value="86"&gt;Matron&lt;/option&gt;
  &lt;option value="87"&gt;Mipshipman&lt;/option&gt;
  &lt;option value="89"&gt;Mistress&lt;/option&gt;
  &lt;option value="90"&gt;Monsieur&lt;/option&gt;
  &lt;option value="91"&gt;Monsignor&lt;/option&gt;
  &lt;option value="92"&gt;Mother&lt;/option&gt;
  &lt;option value="93"&gt;Nurse&lt;/option&gt;
  &lt;option value="94"&gt;Officer&lt;/option&gt;
  &lt;option value="95"&gt;Pastor&lt;/option&gt;
  &lt;option value="96"&gt;PC&lt;/option&gt;
  &lt;option value="97"&gt;PtyOffcr&lt;/option&gt;
  &lt;option value="98"&gt;PltOffcr&lt;/option&gt;
  &lt;option value="100"&gt;Princess&lt;/option&gt;
  &lt;option value="101"&gt;Private&lt;/option&gt;
  &lt;option value="102"&gt;Rabbi&lt;/option&gt;
  &lt;option value="103"&gt;RearAdmr&lt;/option&gt;
  &lt;option value="104"&gt;Rifleman&lt;/option&gt;
  &lt;option value="105"&gt;Sapper&lt;/option&gt;
  &lt;option value="106"&gt;Senor&lt;/option&gt;
  &lt;option value="107"&gt;Senora&lt;/option&gt;
  &lt;option value="108"&gt;Senorina&lt;/option&gt;
  &lt;option value="109"&gt;Sergeant&lt;/option&gt;
  &lt;option value="110"&gt;Signor&lt;/option&gt;
  &lt;option value="111"&gt;Signora&lt;/option&gt;
  &lt;option value="112"&gt;Signorina&lt;/option&gt;
  &lt;option value="113"&gt;Sister&lt;/option&gt;
  &lt;option value="114"&gt;SqnLeader&lt;/option&gt;
  &lt;option value="115"&gt;StaffSgt&lt;/option&gt;
  &lt;option value="117"&gt;SubLieut&lt;/option&gt;
  &lt;option value="118"&gt;Superintd&lt;/option&gt;
  &lt;option value="119"&gt;TheHon&lt;/option&gt;
  &lt;option value="120"&gt;TheRtHon&lt;/option&gt;
  &lt;option value="121"&gt;Trooper&lt;/option&gt;
  &lt;option value="122"&gt;Vicar&lt;/option&gt;
  &lt;option value="123"&gt;ViceAdmr&lt;/option&gt;
  &lt;option value="124"&gt;Viscount&lt;/option&gt;
  &lt;option value="125"&gt;Viscountss&lt;/option&gt;
  &lt;option value="126"&gt;Warrntoff&lt;/option&gt;
  &lt;option value="127"&gt;WingCmdr&lt;/option&gt;
  &lt;option value="128"&gt;WPC&lt;/option&gt;
  &lt;option value="129"&gt;Dom&lt;/option&gt;
  &lt;option value="130"&gt;Deputy&lt;/option&gt;
  &lt;option value="131"&gt;Rt. Honourable&lt;/option&gt;
  &lt;option value="132"&gt;Venerable&lt;/option&gt;
  &lt;option value="133"&gt;Sheikh&lt;/option&gt;
&lt;/select&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.databasesandlife.com/a-few-html-option/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The special variable &#8220;_&#8221;</title>
		<link>http://www.databasesandlife.com/the-underscore-variable/</link>
		<comments>http://www.databasesandlife.com/the-underscore-variable/#comments</comments>
		<pubDate>Fri, 30 Apr 2010 14:05:39 +0000</pubDate>
		<dc:creator>adrian</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Perl]]></category>

		<guid isPermaLink="false">http://www.databasesandlife.com/?p=479</guid>
		<description><![CDATA[Reading this blog post, Destructuring binds in Ruby just now reminded me of a feature I love about Prolog which I wish would make it into other languages.
Firstly, I love assigning a list to a list of lvalues i.e. variables; this is possible in both PHP and Perl which I use regularly; and no doubt [...]]]></description>
			<content:encoded><![CDATA[<p>Reading this blog post, <a href="http://citizen428.net/archives/427-Destructuring-binds-in-Ruby.html">Destructuring binds in Ruby</a> just now reminded me of a feature I love about Prolog which I wish would make it into other languages.</p>
<p>Firstly, I love assigning a list to a list of <a href="http://cplus.about.com/od/glossar1/g/lvalue.htm">lvalues</a> i.e. variables; this is possible in both PHP and Perl which I use regularly; and no doubt many other languages. (But not Java: why not!?)</p>
<pre>
    ($a, $b) =      ($b, $a);  // Perl
list($a, $b) = array($b, $a);  // PHP
</pre>
<p>PHP, as always, wins in inelegance, having the left side syntactically different to the right side. While it&#8217;s obviously the case that a list of values and a list of lvalues are technically different, I don&#8217;t think this difference should be expressed in the syntax.</p>
<p>I mean, in most languages you write e.g. $foo=4 and $bar=$foo; in both those cases you write $foo but yet they do something different (lvalue and rvalue); given that you write them the same there i think the same should apply to lists.</p>
<p>But I digress &#8211; What I want to mention is using &#8220;underscore&#8221; to mean &#8220;any variable&#8221;. I first saw this in Prolog.</p>
<p>For example, imagine you have to implement an interface (e.g. in Java), it requires you to write a function taking two parameters, but one of the parameters you don&#8217;t care about. Wouldn&#8217;t it be nice to write</p>
<pre>
interface ExistingApi {
   public void createObject(String name, Object otherInformation);
}

class MyInstanceOfTheApi {
   public void createObject(String name, _) {
      ...
   }
}
</pre>
<p>i.e. this shows clearly you do not care about the second parameter. </p>
<p>In current Java (and all languages I program including Perl, PHP) you have to give all variables a name even if you don’t use them, either in function definitions or in “assign to a list” scenarios mentioned above. It is then left as an exercise to the reader to determine if these variables are used or not, and indeed an exercise to the writer to name the variable they are never going to use.</p>
<p>I mean yes, technically you can actually just call variables “_” (or “$_” (except in Perl where “$_” already means something)) but that would then be a coding convention as opposed to a language feature, and who knows if the coding convention is actually used correctly by a programmer. (If “_” is a variable there’s nothing stopping someone from using its value.)</p>
<p>And then you have the problem if you have two variables you don&#8217;t care about, you can&#8217;t call them both &#8220;_&#8221;.</p>
<p>By the way, <a href="http://books.google.com/books?id=VjHk2Cjrti8C&#038;printsec=frontcover&#038;dq=Programming+in+Prolog&#038;source=bl&#038;ots=IHQtLmvJqC&#038;sig=RFhnlEzs_Nu_GkwTQD_Z3som5Ds#v=onepage&#038;q&#038;f=false">Programming in Prolog</a> is an excellent book.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.databasesandlife.com/the-underscore-variable/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>/etc/cron.daily scripts may not have dots in their name</title>
		<link>http://www.databasesandlife.com/etc-cron-daily-scripts-may-not-have-dots-in-their-name/</link>
		<comments>http://www.databasesandlife.com/etc-cron-daily-scripts-may-not-have-dots-in-their-name/#comments</comments>
		<pubDate>Sun, 18 Apr 2010 16:20:01 +0000</pubDate>
		<dc:creator>adrian</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.databasesandlife.com/?p=473</guid>
		<description><![CDATA[I just had the problem I&#8217;d placed a script into /etc/cron.daily on my Debian Lenny system but it wasn&#8217;t getting run (or at least it didn&#8217;t seem so).
Two things I learned:
(1) Execute the following to see which scripts would get run:

run-parts --test /etc/cron.daily

(2) In my case, the reason the script was never executed was that [...]]]></description>
			<content:encoded><![CDATA[<p>I just had the problem I&#8217;d placed a script into /etc/cron.daily on my Debian Lenny system but it wasn&#8217;t getting run (or at least it didn&#8217;t seem so).</p>
<p>Two things I learned:</p>
<p>(1) Execute the following to see which scripts would get run:</p>
<pre>
run-parts --test /etc/cron.daily
</pre>
<p>(2) In my case, the reason the script was never executed was that I called it &#8220;xyz.sh&#8221; as it was a shell script; the dot in the filename was the problem. I removed the dot and now it runs.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.databasesandlife.com/etc-cron-daily-scripts-may-not-have-dots-in-their-name/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java is lacking a String &#8220;join&#8221; function</title>
		<link>http://www.databasesandlife.com/java-is-lacking-a-string-join-function/</link>
		<comments>http://www.databasesandlife.com/java-is-lacking-a-string-join-function/#comments</comments>
		<pubDate>Fri, 16 Apr 2010 10:49:49 +0000</pubDate>
		<dc:creator>adrian</dc:creator>
				<category><![CDATA[Broken]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.databasesandlife.com/?p=465</guid>
		<description><![CDATA[Between Java 1.0 and Java 1.3 (1996-2002 according to Wikipedia) there was no way to split strings into an array or a list.
In Java 1.4 the authors of Java saw it fit to introduce a method to split strings,
String csvData = "field1,field2,field3";
String[] fields = csvData.split(",");

However they did not introduce a method to &#8220;join&#8221; strings! Even [...]]]></description>
			<content:encoded><![CDATA[<p>Between Java 1.0 and Java 1.3 (1996-2002 according to Wikipedia) there was no way to split strings into an array or a list.</p>
<p>In Java 1.4 the authors of Java saw it fit to introduce a method to split strings,</p>
<pre>String csvData = "field1,field2,field3";
String[] fields = csvData.split(",");
</pre>
<p>However they did not introduce a method to &#8220;join&#8221; strings! Even in Java 7 there is no way to do this, e.g. via a static String.join method (2002-now).</p>
<p>OK I realize this is not &#8220;rocket science&#8221;, and I appreciate it exists in various versions in various third-party libraries, but still, it&#8217;s something every program needs to do at some point, it&#8217;s annoying to have to re-define it or think about it for each application.</p>
<p>For example, in one project I was working on in the last 6 months, such a function was created, and then had a bug! (OK but to be fair, that was not the only bug in the application!)</p>
<p>Come on, I mean this is a totally trivial function, totally necessary, available in all scripting lanuags why is it still not in Java?!</p>
<p>(P.S. Want to see an &#8220;enterprise java&#8221; solution to this problem? Check out the <a href="http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/base/Joiner.html#method_summary">number of methods on this class</a>)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.databasesandlife.com/java-is-lacking-a-string-join-function/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Java varargs: inconsistent behaviour if you pass an array</title>
		<link>http://www.databasesandlife.com/java-varargs-inconsistent-behaviour-if-you-pass-an-array/</link>
		<comments>http://www.databasesandlife.com/java-varargs-inconsistent-behaviour-if-you-pass-an-array/#comments</comments>
		<pubDate>Thu, 15 Apr 2010 10:39:07 +0000</pubDate>
		<dc:creator>adrian</dc:creator>
				<category><![CDATA[Broken]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.databasesandlife.com/?p=461</guid>
		<description><![CDATA[In Java 1.4 there was the function Arrays.asList. You could pass it an array and it would make a list out of it.
String[] myArray = new String[] { "foo", "bar" };
List myList = Arrays.asList(myArray);

In Java 1.5 this was retrofitted for varargs; you could simply pass elements to the function
List&#60;String&#62; myList = Arrays.asList("foo", "bar");

I never really [...]]]></description>
			<content:encoded><![CDATA[<p>In Java 1.4 there was the function Arrays.asList. You could pass it an array and it would make a list out of it.</p>
<pre>String[] myArray = new String[] { "foo", "bar" };
List myList = Arrays.asList(myArray);
</pre>
<p>In Java 1.5 this was retrofitted for varargs; you could simply pass elements to the function</p>
<pre>List&lt;String&gt; myList = Arrays.asList("foo", "bar");
</pre>
<p>I never really understood how that worked in a backwards-compatible way; I mean either the function takes an array of stuff, or it takes individual elements, surely?</p>
<p>It turns out, that with the varargs syntax, the caller is not forced to pass individual elements, the caller can instead pass an array of elements.</p>
<pre>List&lt;String&gt; myList = Arrays.asList("foo", "bar");
List&lt;String&gt; myList = Arrays.asList(new String[] { "foo", "bar" });
</pre>
<p>The above two calls are identical, both return a List&lt;String&gt;.</p>
<p>But surely this is really dangerous? I mean Arrays.asList does not make any assumptions about what types of arguments it accepts; the list can be composed of any object.</p>
<p>How can it be certain that you want to have an List of Strings, and not a List containing a single element which is a String array? (An array is an object.)</p>
<p>To demonstrate this inconsistency:</p>
<pre>String[] arr = new String[] { "foo", "bar" };
Arrays.asList(arr);            // returns List&lt;String&gt;
Arrays.asList(arr, arr);       // returns List&lt;String[]&gt;
Arrays.asList(arr, arr, arr);  // returns List&lt;String[]&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.databasesandlife.com/java-varargs-inconsistent-behaviour-if-you-pass-an-array/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>foreach syntax</title>
		<link>http://www.databasesandlife.com/foreach-syntax/</link>
		<comments>http://www.databasesandlife.com/foreach-syntax/#comments</comments>
		<pubDate>Wed, 24 Mar 2010 13:04:26 +0000</pubDate>
		<dc:creator>adrian</dc:creator>
				<category><![CDATA[Broken]]></category>
		<category><![CDATA[Coding]]></category>

		<guid isPermaLink="false">http://www.databasesandlife.com/?p=442</guid>
		<description><![CDATA[Most modern languages use very similar syntax inspired by C; but the features added since C are really non-standard! The &#8220;for-each&#8221; syntax annoys me particularly. I mean none of these is significantly better/worse than the others, but I program in all these languages (apart from C#) on a regular basis and I always have to [...]]]></description>
			<content:encoded><![CDATA[<p>Most modern languages use very similar syntax inspired by C; but the features added since C are really non-standard! The &#8220;for-each&#8221; syntax annoys me particularly. I mean none of these is significantly better/worse than the others, but I program in all these languages (apart from C#) on a regular basis and I always have to think when typing in the line in order not to get the wrong syntax.</p>
<table style="width: 100%;">
<tbody>
<tr>
<td style="width: 100px;"><strong>PHP</strong></td>
<td style="font-family: monospace;">foreach (<em>list </em>as <em>element</em>)</td>
</tr>
<tr>
<td><strong>Perl</strong></td>
<td style="font-family: monospace;">foreach my <em>element </em>(<em>list</em>)</td>
</tr>
<tr>
<td><strong>Java</strong></td>
<td style="font-family: monospace;">for (<em>element </em>: <em>list</em>)</td>
</tr>
<tr>
<td><strong>Javascript</strong></td>
<td style="font-family: monospace;">for (var <em>element </em>in <em>list</em>)</td>
</tr>
<tr>
<td><strong>C#</strong></td>
<td style="font-family: monospace;">foreach (<em>element </em>in <em>list</em>)</td>
</tr>
</tbody>
</table>
<p>For what it&#8217;s worth, I think &#8220;foreach&#8221; is nicer than &#8220;for&#8221; as it reads more like a sentence (the word &#8220;for&#8221; really makes no sense at all in that context); and about &#8220;in&#8221; vs. colon I&#8217;ve got no preference really.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.databasesandlife.com/foreach-syntax/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>NoSQL becuase SQL is too slow?</title>
		<link>http://www.databasesandlife.com/436/</link>
		<comments>http://www.databasesandlife.com/436/#comments</comments>
		<pubDate>Mon, 08 Mar 2010 16:36:13 +0000</pubDate>
		<dc:creator>adrian</dc:creator>
				<category><![CDATA[uboot]]></category>

		<guid isPermaLink="false">http://www.databasesandlife.com/?p=436</guid>
		<description><![CDATA[I just read this excellent article relating to the reasoning for using NoSQL databases being performance problems.
http://thoughts.j-davis.com/2010/03/07/scalability-and-the-relational-model/
However, I wonder if it&#8217;s even reasonable to search for solutions to performance problems with the relational model; NoSQL, etc.
I think as computers get faster and faster (CPUs, SSDs, more memory, &#8230;) the set of problems which are &#8220;too [...]]]></description>
			<content:encoded><![CDATA[<p>I just read this excellent article relating to the reasoning for using NoSQL databases being performance problems.</p>
<p><a href="http://thoughts.j-davis.com/2010/03/07/scalability-and-the-relational-model/">http://thoughts.j-davis.com/2010/03/07/scalability-and-the-relational-model/</a></p>
<p>However, I wonder if it&#8217;s even reasonable to search for solutions to performance problems with the relational model; NoSQL, etc.</p>
<p>I think as computers get faster and faster (CPUs, SSDs, more memory, &#8230;) the set of problems which are &#8220;too slow&#8221; for a particular technology (or mindset) get fewer and fewer.</p>
<p>I used to have the pleasure of having to optimize systems (based on SQL, some of our solutions involved leaving the relational model); e.g. community with 4M users (uboot.com), but nowadays I have no customer where even an open-source database installed on reasonably inexpensive hardware is insufficient.</p>
<p>Of course, that&#8217;s just my experience, and there certainly are many problems, companies, etc. today which require solving performance problems in the database, but I assert a lot of the people proposing NoSQL as a solution to performance problems with SQL databases don&#8217;t have the performance problems in the first place; I mean not everyone is implementing Facebook, Google, &#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.databasesandlife.com/436/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
