tag:dreamwidth.org,2010-08-20:547548gareth_reesgareth_reesgareth_rees2015-12-14T18:43:16Ztag:dreamwidth.org,2010-08-20:547548:10738Plan to throw one away2015-12-14T18:43:16Z2015-12-14T18:43:16Zpublic0<p>When I had interviewed for the job, the interviewer had explained that I was needed to work on their JavaScript engine. The company was a web development tools startup, and they had spotted that it would be a good idea to have JavaScript code running on the server as well as on the client, so that you could share your business logic and validation code between the client-side and server-side parts of your application. There are now lots of products in this space but twenty years ago was probably too soon for this to be a success.
<p>Anyway, the interviewer told me that the JavaScript engine was nearly done, but there were one or two features that were missing, and it was running a bit slowly, so I might have to do a bit of optimization. <b>( <a href="http://garethrees.org/2015/12/14/javascript/">Sure, I said, that sounded like it would be fun …</a> )</b></p></p><br /><br /><img src="https://www.dreamwidth.org/tools/commentcount?user=gareth_rees&ditemid=10738" width="30" height="12" alt="comment count unavailable" style="vertical-align: middle;"/> commentstag:dreamwidth.org,2010-08-20:547548:10272Exact cover II2015-12-14T18:41:59Z2015-12-14T18:41:59Zpublic0<p>The story so far: <a href="http://garethrees.org/2015/11/09/exact-cover/">I wrote a solver for a generic exact cover problem in Python</a>, and used it to find polyomino tilings. The reason for using Python was because Python’s simplicity, terseness, and flexibility makes it easy to write solvers for other combinatorial problems. <b>( <a href="http://garethrees.org/2015/11/17/exact-cover/">So let’s have a look at a second problem …</a> )</b></p><br /><br /><img src="https://www.dreamwidth.org/tools/commentcount?user=gareth_rees&ditemid=10272" width="30" height="12" alt="comment count unavailable" style="vertical-align: middle;"/> commentstag:dreamwidth.org,2010-08-20:547548:10143Exact cover2015-12-14T18:40:04Z2015-12-14T18:40:04Zpublic0<p>Karp (1972) introduces the name ‘<a href="https://en.wikipedia.org/wiki/Exact_cover">exact cover</a>’ for the following <a href="https://en.wikipedia.org/wiki/Decision_problem">decision problem</a>:<blockquote><p>INPUT: Family <i>S</i><sub><i>j</i></sub> of subsets of a set <i>u</i><sub><i>i</i></sub>, <i>i</i>=1,2,…,<i>t</i> <br> <br> PROPERTY: There is a subfamily <i>T</i><sub><i>h</i></sub> ⊆ <i>S</i><sub><i>j</i></sub> such that the sets <i>T</i><sub><i>h</i></sub> are disjoint and ∪<i>T</i><sub><i>h</i></sub> = ∪<i>S</i><sub><i>j</i></sub> = <i>u</i><sub><i>i</i></sub>, <i>i</i>=1,2,…,<i>t</i></p></blockquote><p>(The problem being to determine, for an arbitrary input, whether it possesses the property.) Karp goes on to prove that this problem is NP-complete, using a reduction from <a href="https://en.wikipedia.org/wiki/Graph_coloring">chromatic number</a>, which has a reduction from <a href="https://en.wikipedia.org/wiki/Boolean_satisfiability_problem#3-satisfiability">satisfiability with at most three literals per clause</a>, which in turn has a reduction from <a href="https://en.wikipedia.org/wiki/Boolean_satisfiability_problem">satisfiability</a>, which he proves is NP-complete directly.
<p><b>( <a href="http://garethrees.org/2015/11/09/exact-cover/">Instances of this problem often arise in the solution of combinatorial problems …</a> )</b></p></p></p><br /><br /><img src="https://www.dreamwidth.org/tools/commentcount?user=gareth_rees&ditemid=10143" width="30" height="12" alt="comment count unavailable" style="vertical-align: middle;"/> commentstag:dreamwidth.org,2010-08-20:547548:9839A performance regression2015-08-09T17:42:36Z2015-08-09T17:42:36Zpublic0<p>So, another day at the customer site, another issue to fix:
<blockquote><p><b>Issue 234.</b> Over the past three months, the performance of [PRODUCT] has regressed. In December, at commit 919074d, [TESTCASE] ran in 21 seconds, but now it takes 44 seconds.</p></blockquote>
<p>The first step is to check that the problem is reproducible (it is), <b>( <a href="http://garethrees.org/2015/08/09/perf/">and the next is to run a <code>git bisect</code> to see if there was a bad commit …</a> )</b></p></p><br /><br /><img src="https://www.dreamwidth.org/tools/commentcount?user=gareth_rees&ditemid=9839" width="30" height="12" alt="comment count unavailable" style="vertical-align: middle;"/> commentstag:dreamwidth.org,2010-08-20:547548:9636Emacs/Perforce integration: a retrospective2015-08-07T20:19:43Z2015-08-07T20:19:43Zpublic0<p>I’ve been maintaining the <strong><a href="https://github.com/gareth-rees/p4.el/">Perforce/Emacs integration</a></strong> for a couple of years now, so it’s time for a retrospective. … Perforce and Emacs are tools that I use all day every day, which means that small inconveniences in the integration stand out to me and I can see clearly cases where I have a frequently performed task that deserves some extra automation or assistance. I’m also in a position to check quickly that my change really fixes the problem. <b>( <a href="http://garethrees.org/2015/08/07/p4.el/">Here are examples of improvements I’ve made based on this approach…</a> )</b></p><br /><br /><img src="https://www.dreamwidth.org/tools/commentcount?user=gareth_rees&ditemid=9636" width="30" height="12" alt="comment count unavailable" style="vertical-align: middle;"/> commentstag:dreamwidth.org,2010-08-20:547548:9365The ping that wouldn’t die2015-08-07T18:10:43Z2015-08-07T18:10:43Zpublic0<p>It was Friday afternoon at the customer site and I had completed my tasks for the week. I had implemented the new feature and its test cases, written a design justifying the implementation, and drafted a section of the user manual explaining how to use it, so now I was looking for something else to do. In any large program, there are always things that need fixing, so I poked about in the depths of the issue tracker to see if there were any interesting problems that could be appropriated from the other developers. <b>( <a href="http://garethrees.org/2015/08/07/ping/">The unluckily numbered and long unsolved issue 13 caught my eye…</a> )</b></p><br /><br /><img src="https://www.dreamwidth.org/tools/commentcount?user=gareth_rees&ditemid=9365" width="30" height="12" alt="comment count unavailable" style="vertical-align: middle;"/> commentstag:dreamwidth.org,2010-08-20:547548:9186Osama2015-05-01T22:24:09Z2015-05-01T22:24:09Zpublic0<p>Joe sits in the office of his detective agency in Vientiane, drinking and smoking, watching the rain come down, and reading trashy fiction:
<blockquote><p>The book was a worn paperback with a garish, colourful cover. It showed a multi-story building in the final stages of collapse, a dusty African street, and people running away from the blast. The book was called <cite>Assignment: Africa</cite> and, in an only slightly smaller subtitle, announced it as the third title in the series <cite>Osama Bin-Laden: Vigilante</cite>. The unlikely named of the author was Mike Longshott.</p></blockquote>
<p>A woman comes into in Joe’s office with a job for him:
<blockquote><p>At last, she said, ‘I want you find him,’ and her fingers caressed the book; he couldn’t put a name to the look she had in her eyes then; he thought she looked lost, and sad, and a little vulnerable.
<p>‘Find who?’
<p>‘Mike Longshott,’ she said.</p></p></p></blockquote>
<p><b>( <a href="http://garethrees.org/2015/05/01/tidhar/">What follows is a pastiche of the hard-boiled detective genre...</a> )</b></p></p></p><br /><br /><img src="https://www.dreamwidth.org/tools/commentcount?user=gareth_rees&ditemid=9186" width="30" height="12" alt="comment count unavailable" style="vertical-align: middle;"/> commentstag:dreamwidth.org,2010-08-20:547548:8896The Quantum Thief2015-05-01T22:22:46Z2015-05-01T22:22:46Zpublic0<p>Jean le Flambeur, gentleman thief, is sprung from prison by the beautiful Mieli, who persuades him to undertake one last job. Author Hannu Rajaniemi works hard to obscure the familiar outline of this hoariest of heist plots, by layering on the worldbling with a trowel:
<blockquote>The hidden Sobornost tech beneath the Oortian sapphire coral wakes up. The spidership reconfigures itself. The scattered modules pull themselves together along their tethers and fuse together into a tight, hard cone. The q-dot winglets transform from a perfectly reflective material into a diamond-hard firewall. Just in time, before the Archon’s nanomissiles hit.</blockquote>
<p>I do like the experience of being confronted by a complex fictional world and having to make sense of it. <b>( <a href="http://garethrees.org/2015/04/29/rajaniemi/">But I also like to feel that there is in fact some sense to be made, and in this novel I frequently failed to make it.</a> )</b></p></p><br /><br /><img src="https://www.dreamwidth.org/tools/commentcount?user=gareth_rees&ditemid=8896" width="30" height="12" alt="comment count unavailable" style="vertical-align: middle;"/> commentstag:dreamwidth.org,2010-08-20:547548:8571Completion colours2015-02-11T12:32:41Z2015-02-11T12:32:41Zpublic0<p>In ‘<a href="http://garethrees.org/2015/02/09/emacs/">Completion annotations</a>’, I illustrated the interactive completion feature in Emacs with a screenshot showing what happens if you type <kbd>M-x set-cursor-color RET Dark TAB</kbd>: you get a <code>*Completions*</code> buffer containing the colour names starting with ‘Dark’. Nick Barnes posted a <a href="http://garethrees.org/2015/02/09/emacs/#IDComment949243825">comment</a> pointing out a potential usability improvement:
<blockquote>It would be nice to have a bit more control still, so that (for instance) when completing on colour names one could see the colours.</blockquote>
<p>To do this, just evaluate the following expression:
<pre>
(dolist (c (defined-colors))
(put-text-property 0 (length c) 'face `(:foreground ,c) c))
</pre>
<p>and then run any command that prompts you to pick a colour, for example <code>read-color</code>. <b>( <a href="http://garethrees.org/2015/02/11/emacs/">At this point, if you are used to the way strings work in most programming languages, you ought to be asking yourself, <em>how does this work?</em></a> )</b></p></p></p><br /><br /><img src="https://www.dreamwidth.org/tools/commentcount?user=gareth_rees&ditemid=8571" width="30" height="12" alt="comment count unavailable" style="vertical-align: middle;"/> commentstag:dreamwidth.org,2010-08-20:547548:8400Completion annotations2015-02-09T17:29:11Z2015-02-09T17:29:52Zpublic0<p>One of the most useful features of Emacs is its <a href="https://www.gnu.org/software/emacs/manual/html_node/emacs/Completion.html#Completion">interactive completion</a>. Whenever you need to input the name of some item, Emacs allows you to type some parts of the name and then type <kbd>TAB</kbd> to see a list of items that match what you have typed so far. But completion is more sophisticated than just prefix-matching. You can use wildcards (for example <kbd>*green TAB</kbd> will show colour names containing the substring ‘green’) and when the completion items have multiple words (separated by hyphens or spaces), completion works on each word individually, so that you can type <kbd>M-x t-d-o-e RET</kbd> to run the command <a href="https://www.gnu.org/software/emacs/manual/html_node/elisp/Error-Debugging.html"><code>toggle-debug-on-error</code></a>. Naturally you can customize the set of completion mechanisms using the <a href="https://www.gnu.org/software/emacs/manual/html_node/emacs/Completion-Styles.html#Completion-Styles"><code>completion-styles</code></a> setting.
<p>The Emacs/Perforce integration that I maintain, <a href="http://github.com/gareth-rees/p4.el"><code>p4.el</code></a>, implements completion for each kind of Perforce item that you might need to name: branches, numbered pending changelists, clients, filespecs, groups, help topics, jobs, labels, and users. However, <a href="https://github.com/gareth-rees/p4.el/issues/188">this works poorly in the case of changelists and jobs</a>, because <b>( <a href="http://garethrees.org/2015/02/09/emacs/">all you get when you type <kbd>TAB</kbd> is a list of opaque identifiers that give you no help in choosing the item you want.</a> )</b></p></p><br /><br /><img src="https://www.dreamwidth.org/tools/commentcount?user=gareth_rees&ditemid=8400" width="30" height="12" alt="comment count unavailable" style="vertical-align: middle;"/> commentstag:dreamwidth.org,2010-08-20:547548:8137Five Whys2015-02-07T20:31:46Z2015-02-07T20:31:46Zpublic0<p>Toyota’s ‘<a href="http://en.wikipedia.org/wiki/5_Whys">Five Whys</a>’ process is well known to engineers: it’s one of the basic problem-solving tools in modern engineering management systems like <a href="http://en.wikipedia.org/wiki/Six_Sigma">Six Sigma</a> and <a href="http://en.wikipedia.org/wiki/Total_quality_management">Total Quality Management</a>. Here’s how <a href="http://en.wikipedia.org/wiki/Taiichi_Ohno">Taiichi Ohno</a> introduces the process in <cite>Toyota Production System: Beyond Large-Scale Production</cite> (1978):
<blockquote><p>When confronted with a problem, have you ever stopped and asked <em>why</em> five times? <b>( <a href="http://garethrees.org/2015/02/07/whys/">It is difficult to do even though it sounds easy.</a> )</b></p></blockquote></p><br /><br /><img src="https://www.dreamwidth.org/tools/commentcount?user=gareth_rees&ditemid=8137" width="30" height="12" alt="comment count unavailable" style="vertical-align: middle;"/> commentstag:dreamwidth.org,2010-08-20:547548:7848The Bug2015-01-21T19:52:47Z2015-01-21T19:52:47Zpublic0<p>I have been working on a project recently where there has been a lot of tricky debugging to do. The code I’m working on has to live in the same process as third-party code that is not under my control, and which calls into my code unpredictably, often from multiple threads or signal handlers. This is an application environment that’s particularly prone to rare crashes and deadlocks that somehow elude my own thorough test procedures but crop up nonetheless on the machines of potential customers during product evaluations. I used to find these kind of bugs intimidating and nerve-wracking, but (at least on this project and for the moment) I seem to be a match for them.
<p>The process of debugging is (or ought to be) one of calmly, methodically and steadily gathering data that narrows the location of the problem until it can no longer hide and is forced to reveal itself. In my current project the first step is to acquire the log and (in the case of a crash) the backtrace from the customer and analyze it for the sequence of events leading up to the crash or deadlock. This identifies important features of the environment (which programs were running? are they multi-threaded? do they handle signals?) and usually pinpoints a suspect area of code which can be inspected for race conditions and deadlocks. Inspecting the code usually leads to a hypothesis or two about the cause; but even if it doesn’t I develop a test case that thoroughly exercises the problem area. With some experimentation and a lot of thought I’ve so far always found it possible to reproduce the problem under controlled conditions, whereupon it can be analyzed in the debugger.
<p>Writing this is of course a form of hubris: no doubt I will return to work on Monday to find in my inbox a customer report describing a bug that I lack the skill to track down and fix. This hasn’t yet happened in my career, though there have been a few occasions where I have been in doubt as to the outcome, one of which I described in my post ‘<a href="http://garethrees.org/2013/01/06/bug/">The last lousy bug</a>’. Programmers like to call these accounts “war stories”—joking, of course, but joking seriously. It is stressful to know that something is wrong in your code, but not to know what it is or how to find it, and to have it hanging over your head day after day as you fail to make progress towards solving it.
<p><b>( <a href="http://garethrees.org/2015/01/18/ullman/">This nightmare scenario is the driver behind Ellen Ullman’s 2003 novel <cite>The Bug</cite>. )</a></b></p></p></p></p><br /><br /><img src="https://www.dreamwidth.org/tools/commentcount?user=gareth_rees&ditemid=7848" width="30" height="12" alt="comment count unavailable" style="vertical-align: middle;"/> commentstag:dreamwidth.org,2010-08-20:547548:7577Software inspection and the Heartbleed bug2014-05-08T21:38:32Z2014-05-08T21:38:32Zpublic0<p>Since 2005, when a train crashes in the UK, a professional body of investigators—the <a href="http://www.raib.gov.uk/">Rail Accident Investigation Branch</a>—is tasked with determining the cause of the incident and making recommendations to reduce the likelihood, or mitigate the severity, of similar events occurring in the future. There are similar branches tasked with investigating Air and Marine accidents.
<p><b>( <a href="http://garethrees.org/2014/05/08/heartbleed/">There is nothing like this for computer security incidents.</a> )</b></p></p><br /><br /><img src="https://www.dreamwidth.org/tools/commentcount?user=gareth_rees&ditemid=7577" width="30" height="12" alt="comment count unavailable" style="vertical-align: middle;"/> commentstag:dreamwidth.org,2010-08-20:547548:7291“Double Dutch” audax2014-05-08T21:37:45Z2014-05-08T21:37:45Zpublic0<p>Martin Malins has been organizing the “<b>Double Dutch</b>” 200 km audax for four years now. I rode the first edition <a href="http://garethrees.org/2011/04/09/audax/">back in 2011</a>, when we had the most amazing luck with the weather, and I was looking forward to riding it again. The route is a tour of the Fens: starting at Huntingdon, you head north-east via Ramsey, March, and Nordelph, then north up the River Great Ouse to Kings Lynn for the fourth control and lunch. Then you cross the Ouse and head northwest to an info at Holbeach St Matthew close to The Wash, southwest to the sixth control at the Springfields shopping centre in Spalding, Lincolnshire, and back to Huntingdon for the finish.
<p><b>( <a href="http://garethrees.org/2014/04/19/audax/">I set my alarm for 06:00</a> )</b></p></p><br /><br /><img src="https://www.dreamwidth.org/tools/commentcount?user=gareth_rees&ditemid=7291" width="30" height="12" alt="comment count unavailable" style="vertical-align: middle;"/> commentstag:dreamwidth.org,2010-08-20:547548:6974Password purgatory2014-05-08T21:36:34Z2014-05-08T21:36:34Zpublic0<p>Since the <a href="http://heartbleed.com">Heartbleed bug</a> rendered all our passwords insecure, we’ve all been going through the purgatory of upgrading servers and changing passwords. This isn’t the first time I’ve done a mass-reset of my passwords, but I thought I’d try something new. <b>( <a href="http://garethrees.org/2014/04/15/password/">This time I’m seeing what it’s like to try to follow “best practices.”</a> )</b></p><br /><br /><img src="https://www.dreamwidth.org/tools/commentcount?user=gareth_rees&ditemid=6974" width="30" height="12" alt="comment count unavailable" style="vertical-align: middle;"/> commentstag:dreamwidth.org,2010-08-20:547548:6766DIY 200 audax to Wendover2014-05-08T21:35:19Z2014-05-08T21:35:19Zpublic0<p>It’s not easy designing a “<a href="http://www.aukweb.net/diy/traditional/">DIY</a>” audax route. The way these rides work is that you nominate a series of controls, then you ride around and visit each one in turn, collecting “proof of presence” in the form of receipts or cashpoint slips. The tricky bit is that you only get credit for the shortest distance between each pair of controls. So you pick two nice cafés about 50 km apart, but then it turns out that they are only 40 km apart via the A1, so that’s all you get credit for. Add up all those little diversions, and soon your DIY 200 is actually 240 km.
<p>On a calendar ride, the organizer can put in “information” controls anywhere on the route (or at least, anywhere that it’s possible to ask a question), and so bring the distance ridden closer to the nominal distance. When I ran a calendar event a couple of years ago, with judicious placement of controls I managed to get the distance ridden down to 200 km exactly, and so reasonably friendly for beginners. But that’s not possible on a DIY.
<p><b>( <a href="http://garethrees.org/2014/04/05/audax/">So it was only after many experiments with Google Maps that I settled on a route with five controls</a> )</b></p></p></p><br /><br /><img src="https://www.dreamwidth.org/tools/commentcount?user=gareth_rees&ditemid=6766" width="30" height="12" alt="comment count unavailable" style="vertical-align: middle;"/> commentstag:dreamwidth.org,2010-08-20:547548:6490“End of Hibernation” audax 20142014-05-08T21:34:04Z2014-05-08T21:34:04Zpublic0<p>Today was the "<a href="http://www.aukweb.net/events/detail/14-235/">End of Hibernation</a>", a 200 km audax organized by Terry Dickinson of Cambridge Cycling Club. Starting at the village hall in Hauxton, it visited controls at <a href="https://maps.google.co.uk/maps/ms?msa=0&msid=204201713257751721124.000490d9b836387038d87&ie=UTF8&t=m&vpsrc=6&ll=52.1773,0.4319&spn=0.360432,0.547943&z=11&iwloc=000490d9f1cd98554656c&dg=feature">Adam’s Café</a> near Stradishall, the Riverside Lakes Café at Onehouse near Stowmarket, and <a href="https://maps.google.co.uk/maps/ms?msa=0&msid=204201713257751721124.000490d9b836387038d87&ie=UTF8&ll=52.040631,0.356841&spn=0.255949,0.610428&t=v&z=11&vpsrc=6&iwloc=0004c5ae095d8c4e60277">Bosworth’s Café</a> at Finchingfield (plus two information controls).</p>
<p><b>( <a href="http://garethrees.org/2014/03/23/audax/">Today was the third time I’ve ridden this event.</a> )</b></p><br /><br /><img src="https://www.dreamwidth.org/tools/commentcount?user=gareth_rees&ditemid=6490" width="30" height="12" alt="comment count unavailable" style="vertical-align: middle;"/> commentstag:dreamwidth.org,2010-08-20:547548:6157Emitremmus 20132014-05-08T21:31:37Z2014-05-08T21:31:53Zpublic0<p>The “<a href="http://www.stevenagectc.org.uk/emitremmus.php">Emitremmus</a>” is a 100 km audax, run by Stevenage CTC each autumn for the last 19 years, on the Sunday that the clocks go back. The route starts at <a href="http://www.stevenage-leisure.co.uk/CentrenbspLocator/FairlandsValleyPark/tabid/314/Default.aspx">Fairlands Valley Park</a> in Stevenage and heads east via Great Munden and Hare Street to Saffron Walden, returning via Great Chishill and Therfield. <b>( <a href="http://garethrees.org/2013/10/27/audax/">The start of the ride is almost exactly 50 km from my house</a></b> )</p><br /><br /><img src="https://www.dreamwidth.org/tools/commentcount?user=gareth_rees&ditemid=6157" width="30" height="12" alt="comment count unavailable" style="vertical-align: middle;"/> commentstag:dreamwidth.org,2010-08-20:547548:5989Drawing square triangulations2014-05-08T21:25:23Z2014-05-08T21:29:23Zpublic0<p>The story so far:</p>
<ol>
<li><p>I introduced <a href="http://garethrees.org/2013/06/11/tabular/">the tabular method</a> by showing how to count the triangulations of a convex polygon;
<li><p>I used the tabular method to <a href="http://garethrees.org/2013/06/14/euler/">count the number of ways to triangulate</a> an oriented <i>n</i>×<i>n</i> square using only lines joining the 4<i>n</i> integer points around the edge of the square and so solve <a href="http://projecteuler.net/index.php?section=problems&id=270">Project Euler problem 270</a>;
<li><p>I used the <a href="https://pypi.python.org/pypi/svgwrite"><code>svgwrite</code></a> Python package to <a href="http://garethrees.org/2013/06/15/triangulation/">draw the triangulations of a convex polygon</a> using <a href="http://www.w3.org/Graphics/SVG/">Scalable Vector Graphics</a>; and
<li><p>I read <a href="http://www.w3.org/TR/SVG/minimize.html">Appendix J of the SVG specification</a> and used the advice therein to <a href="http://garethrees.org/2013/08/02/svg/">shrink the size of the generated SVG</a>.
</p></li></p></li></p></li></p></li></ol>
<p><b>( <a href="http://garethrees.org/2013/08/09/triangulation/">So now I’ve got all the pieces in place for the last step.</a> )</b></p><br /><br /><img src="https://www.dreamwidth.org/tools/commentcount?user=gareth_rees&ditemid=5989" width="30" height="12" alt="comment count unavailable" style="vertical-align: middle;"/> commentstag:dreamwidth.org,2010-08-20:547548:5855Shrinking SVG2014-05-08T21:23:45Z2014-05-08T21:29:45Zpublic0<p>In “<a href="http://garethrees.org/2013/06/15/triangulation/">Scalable vector triangulations</a>” I used the <a href="https://pypi.python.org/pypi/svgwrite"><code>svgwrite</code></a> package to draw the 429 triangulations of an oriented convex nonagon. But there was something unsatisfactory about the size of the resulting image: 1.2 MiB seems rather large for an image which has 3003 triangles and 6435 lines. <b>( <a href="http://garethrees.org/2013/08/02/svg/">A look at the source reveals three sources of wasted space</a> )</b></p><br /><br /><img src="https://www.dreamwidth.org/tools/commentcount?user=gareth_rees&ditemid=5855" width="30" height="12" alt="comment count unavailable" style="vertical-align: middle;"/> commentstag:dreamwidth.org,2010-08-20:547548:5535One in three?2014-05-08T21:19:49Z2014-05-08T21:19:49Zpublic0<p><a href="http://www.bbc.co.uk/news/uk-politics-23274432">This BBC headline</a> reads “Cambridge cycling: one in three journeys is on a bike.” But is that true? If you actually live and work in Cambridge, and compare the numbers of motor vehicles and cyclists on the roads, or the numbers of car and bicycle parking spaces, that figure does not seem right. Certainly there’s a lot of cycling—more than in any other city on the UK—but one in three journeys does not seem credible.</p>
<p><b>( <a href="http://garethrees.org/2013/07/29/one-in-three/">So what’s going on with that headline?</a> )</b></p><br /><br /><img src="https://www.dreamwidth.org/tools/commentcount?user=gareth_rees&ditemid=5535" width="30" height="12" alt="comment count unavailable" style="vertical-align: middle;"/> commentstag:dreamwidth.org,2010-08-20:547548:5288Scalable vector triangulations2013-06-15T11:40:30Z2013-06-15T11:52:43Zpublic0<p>When I wrote “<a href="http://garethrees.org/2013/06/11/tabular/">The tabular method</a>” I drew a figure showing all the ways to triangulate an oriented convex polygon, from the unique way to triangulate a triangle up to the 14 ways to triangulate a hexagon. I drew it by hand using <a href="http://inkscape.org/">Inkscape</a>, but I felt there was something unsatisfactory about that: if I can write a program to <em>count</em> the triangulations, <b>( <a href="http://garethrees.org/2013/06/15/triangulation/">I ought to be able to write a program to <em>draw</em> them!</a> )</b></p><br /><br /><img src="https://www.dreamwidth.org/tools/commentcount?user=gareth_rees&ditemid=5288" width="30" height="12" alt="comment count unavailable" style="vertical-align: middle;"/> commentstag:dreamwidth.org,2010-08-20:547548:5116User options considered harmful2013-06-13T10:19:45Z2013-06-13T10:19:45Zpublic0<p>A lesson I had to learn several times when I worked in video games is that the addition of user options has to be consciously resisted. The desire to add a user option often indicates that you have skimped on a important piece of usability work and are trying to put off doing it. <b>( <a href="http://garethrees.org/2013/06/13/options/">Now, you’re probably already saying, “but what about—” at this point</a> )</b></p><br /><br /><img src="https://www.dreamwidth.org/tools/commentcount?user=gareth_rees&ditemid=5116" width="30" height="12" alt="comment count unavailable" style="vertical-align: middle;"/> commentstag:dreamwidth.org,2010-08-20:547548:4813Software archaeology and technical debt2013-06-12T19:01:30Z2013-06-12T19:01:30Zpublic0<p>In Vernor Vinge’s 1999 novel <a href="http://www.amazon.co.uk/gp/product/B00AVUMJ26/ref=as_li_ss_tl?ie=UTF8&camp=1634&creative=19450&creativeASIN=B00AVUMJ26&linkCode=as2&tag=garethreesorg-21"><cite>A Deepness in the Sky</cite></a> the protagonist learns what it means to become a <em>programmer–archaeologist</em>:</p>
<blockquote><p>Programming went back to the beginning of time… Behind all the top-level interfaces was layer under layer of support. Some of that software had been designed for wildly different situations. Every so often, the inconsistencies caused fatal accidents. Despite the romance of spaceflight, the most common accidents were simply caused by ancient, misused programs finally getting their revenge.</p>
<p>“We should rewrite it all,” said Pham.</p>
<p>“It’s been tried. But even the top levels of fleet system code are enormous. You and a thousand of your friends would have to work for a century or so to reproduce it. And guess what—even if you did, by the time you finished, you’d have your own set of inconsistencies. And you still wouldn’t be consistent with all the applications that might be needed now and then. The word for all this is ‘mature programming environment’.”</p></blockquote>
<p><b>( <a href="http://garethrees.org/2013/06/12/archaeology/">I often think of this passage when taking on a new project…</a> )</b></p><br /><br /><img src="https://www.dreamwidth.org/tools/commentcount?user=gareth_rees&ditemid=4813" width="30" height="12" alt="comment count unavailable" style="vertical-align: middle;"/> commentstag:dreamwidth.org,2010-08-20:547548:4577The tabular method2013-06-11T13:30:03Z2013-06-11T13:30:03Zpublic0<p><strong>Dynamic programming</strong> is an important technique for writing combinatorial algorithms, in which you divide a problem into sub-problems, like in good ol’ <em>divide-and-conquer</em>, except that the sub-problems may overlap, so you build up a table of these problems and their solutions in order to avoid repeated work. But the name sucks: the technique is no more or less ‘dynamic’ than many other techniques, and ‘programming’ is a fossil: as we’ll see below, the ‘program’ referred to is the <em>output</em> of the technique, not the implementation of the technique itself. I can recall being confused by the name when studying algorithms as an undergraduate: I knew that ‘linear programming’ referred to the optimization of linear functions under linear constraints, but what did the ‘dynamic’ in ‘dynamic programming’ refer to? The name was a small but genuine barrier to understanding the technique.</p>
<p><b>( <a href="http://garethrees.org/2013/06/11/tabular/">So where did the name come from?</a> )</b></p><br /><br /><img src="https://www.dreamwidth.org/tools/commentcount?user=gareth_rees&ditemid=4577" width="30" height="12" alt="comment count unavailable" style="vertical-align: middle;"/> comments