<?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>Atomized &#187; Code</title>
	<atom:link href="http://atomized.org/tag/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://atomized.org</link>
	<description>Fragmenting reality.</description>
	<lastBuildDate>Tue, 31 Aug 2010 18:00:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Frame tiling and centering in Emacs</title>
		<link>http://atomized.org/2010/08/frame-tiling-and-centering-in-emacs/</link>
		<comments>http://atomized.org/2010/08/frame-tiling-and-centering-in-emacs/#comments</comments>
		<pubDate>Wed, 18 Aug 2010 02:05:46 +0000</pubDate>
		<dc:creator>Ian</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[emacs]]></category>

		<guid isPermaLink="false">http://atomized.org/?p=751</guid>
		<description><![CDATA[Since Emacs predates the widespread adoption of the modern GUI andmouse, its vernacular can be somewhat hard to follow. What you would call a window in a modern GUI is called a frame in Emacs. A window is a panel of a frame in Emacs. Most window managers have some facility to arrange the visible [...]]]></description>
			<content:encoded><![CDATA[<p>Since Emacs predates the widespread adoption of the modern GUI andmouse, its vernacular can be somewhat hard to follow. What you would call a <i>window</i> in a modern GUI is called a <i>frame</i> in Emacs. A <i>window</i> is a panel of a frame in Emacs.</p>
<p>Most window managers have some facility to arrange the visible windows. With Emacs, you cna programmatically manipulate a frame’s size and position from Lisp.</p>
<p>There are a few ways I like to arrange my Emacs frames. I generally use one or two – more are harder to manage – and dedicate them to specific purposes. One always has code buffers in it, and the other can have compilation buffers, IRC, w3m, unit test output, or any other variety of programming-related tools.</p>
<p>When I work with a single frame, I like it to be centered on my screen. When I have two, I like them to be next to each other, in the center. Since it’s hard to align by hand, I wrote some code do to it for me.</p>
<pre>
(defun screen-usable-height (&#038;optional display)
  "Return the usable height of the display.

Some window-systems have portions of the screen which Emacs
cannot address. This function should return the height of the
screen, minus anything which is not usable."
  (- (display-pixel-height display)
     (cond ((eq window-system 'ns) 22)
           (t 0))))

(defun screen-usable-width (&#038;optional display)
  "Return the usable width of the display.

This works like `screen-usable-height', but for the width of the display."
  (display-pixel-width display))

(defun frame-sort-ltr (frames)
  "Sort frames by their visual order, left to right.

This method takes a list of frames, and returns that list, sorted
by the visual display order. This is determined by comparing the
left position of the frames; the leftmost frames are returned
first."
  (sort frames (lambda (framea frameb)
                 (< (frame-parameter framea 'left)
                    (frame-parameter frameb 'left)))))

(defun frame-box-get-center (w h cw ch)
  "Center a box inside another box.

Returns a list of `(TOP LEFT)' representing the centered position
of the box `(w h)' inside the box `(cw ch)'."
  (list (/ (- cw w) 2) (/ (- ch h) 2)))

(defun frame-get-center (frame)
  "Return the center position of FRAME on its display."
  (frame-box-get-center (frame-pixel-width frame) (frame-pixel-height frame)
                        (screen-usable-width) (screen-usable-height)))

(defun frame-center (&#038;optional frame)
  "Center a frame on the screen."
  (interactive)
  (apply 'set-frame-position
         `(,(or frame (selected-frame)) ,@(frame-get-center frame))))

(defun frame-tile-horizonal ()
  "Tile visible frames horizontally.

This function tiles visible frames, distributing them evenly
across the display, and centering them vertically.

It doesn't know about multi-head displays, and will probably fail
dramatically if used in such an environment."
  (interactive)
  (let ((pos)
        (offset 0)
        (vwidth (/ (screen-usable-width) (length (visible-frame-list)))))
    (dolist (frame (frame-sort-ltr (visible-frame-list)))
      (setq pos (frame-box-get-center (frame-pixel-width frame)
                                      (frame-pixel-height frame)
                                      vwidth (screen-usable-height)))
      (set-frame-position frame (+ offset (car pos)) (cadr pos))
      (incf offset vwidth))))

(defun frame-tile-center-horizonal ()
  "Tile visible frames horizontally, center-weighted.

Rather than tiling frames evenly across the available width of
the display, this function tiles them into the center of the
display, adding a 2% margin in between frames.

It doesn't know about multi-head displays, and will probably fail
dramatically if used in such an environment."
  (interactive)
  (let* ((framewidth (apply '+ (mapcar 'frame-pixel-width (visible-frame-list))))
         (margin (/ (screen-usable-width) 50)) ;; = (/ s-u-w *.02) = 2%
         (totalwidth (+ framewidth (* margin
                                      (- (length (visible-frame-list)) 1))))
         (offset (car (frame-box-get-center totalwidth 0 (screen-usable-width)
                                            (screen-usable-height)))))

    (dolist (frame (frame-sort-ltr (visible-frame-list)))
      (set-frame-position frame offset (cadr (frame-get-center frame)))
      (incf offset (+ margin (frame-pixel-width frame))))))

(defun frame-restore-defaults (frame)
  (modify-frame-parameters frame default-frame-alist))

(defun frame-default ()
  (interactive)
  (mapcar 'frame-restore-defaults (frame-list))
  (if (> (length (frame-list)) 1)
      (frame-tile-center-horizonal)
    (frame-center)))

(provide 'ime-frame)
</pre>
<p>You can also call <code>M-x frame-tile-center-horizonal</code> or <code>M-x frame-center</code> by hand, if you like.</p>
]]></content:encoded>
			<wfw:commentRss>http://atomized.org/2010/08/frame-tiling-and-centering-in-emacs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Scratch buffers for Emacs</title>
		<link>http://atomized.org/2010/08/scratch-buffers-for-emacs/</link>
		<comments>http://atomized.org/2010/08/scratch-buffers-for-emacs/#comments</comments>
		<pubDate>Tue, 17 Aug 2010 03:44:55 +0000</pubDate>
		<dc:creator>Ian</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[emacs]]></category>

		<guid isPermaLink="false">http://atomized.org/?p=748</guid>
		<description><![CDATA[I often find myself needing to quickly work on some code that’s mostly unrelated to my task at hand. This comes up often when pair programming and code reviews, where you might want to illustrate a tactic without adding useless code to your current buffer. Ordinarily, you’d use *scratch*, but it’s useful to have your [...]]]></description>
			<content:encoded><![CDATA[<p>I often find myself needing to quickly work on some code that’s mostly unrelated to my task at hand. This comes up often when pair programming and code reviews, where you might want to illustrate a tactic without adding useless code to your current buffer.</p>
<p>Ordinarily, you’d use <code>*scratch*</code>, but it’s useful to have your scratch buffer use mode for the language you want to write code in, and <code>*scratch*</code> doesn’t fulfill this unless you’re hacking on emacs-lisp.</p>
<p>To this end, I created <a href="http://github.com/ieure/scratch-el">scratch-el</a>, a bit of code for doing just this.</p>
<p>When you invoke it with <code>M-x scratch</code>, it gives you a scratch buffer with the same mode as your current buffer. So if you’re editing Python code, you get a <code>*python*</code> buffer which uses python-mode. If you’re in a shell, you get a shell-script-mode buffer, and so on.</p>
<p>If you invoke it with a prefix argument, as <code>C-u M-x scratch</code>, it will prompt you for the mode to use, which can be helpful if you want to noodle on a SQL query while editing your app code. There is tab completion support for all known major modes.</p>
<p>If you want to save the resulting work, it’s just a <code>C-x C-w</code> away.</p>
]]></content:encoded>
			<wfw:commentRss>http://atomized.org/2010/08/scratch-buffers-for-emacs/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Stupid PHP Tricks: Accumulate nested arrays</title>
		<link>http://atomized.org/2009/04/stupid-php-tricks-accumulate-nested-arrays/</link>
		<comments>http://atomized.org/2009/04/stupid-php-tricks-accumulate-nested-arrays/#comments</comments>
		<pubDate>Wed, 08 Apr 2009 21:54:11 +0000</pubDate>
		<dc:creator>Ian</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[stupid tricks]]></category>

		<guid isPermaLink="false">http://atomized.org/?p=530</guid>
		<description><![CDATA[I ran into this today while I was dealing with this type of data structure: $data = array(array('foo', 123), array('bar', 456), array('qux', 789)); This nested structure has each (key,val) pair as an array inside another array. It’s quite common in Lisp and Python, but not seen very often in PHP, since it’s more concisely expressed [...]]]></description>
			<content:encoded><![CDATA[<p>I ran into this today while I was dealing with this type of data structure:</p>
<pre>
$data = array(array('foo', 123),
              array('bar', 456),
              array('qux', 789));
</pre>
<p>This nested structure has each <code>(key,val)</code> pair as an array inside another array. It’s quite common in Lisp and Python, but not seen very often in PHP, since it’s more concisely expressed as an associative array.</p>
<p>I needed to map a function across all the keys and values in this structure, then produce an associative array. I discovered this somewhat unusual solution:</p>
<pre>
$keys = $vals = array();
foreach ($data as $pair) {
    list($keys[], $vals[]) = $pair;
}
</pre>
<p>So what happens is that <code>list</code> appends each new key or value to the appropriate array, leaving me with two flat arrays which I can then <code>array_map()</code> over, finally using <code>array_combine()</code> to produce my final output.</p>
]]></content:encoded>
			<wfw:commentRss>http://atomized.org/2009/04/stupid-php-tricks-accumulate-nested-arrays/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>More tough love from PHP</title>
		<link>http://atomized.org/2008/11/more-tough-love-from-php/</link>
		<comments>http://atomized.org/2008/11/more-tough-love-from-php/#comments</comments>
		<pubDate>Mon, 03 Nov 2008 22:28:47 +0000</pubDate>
		<dc:creator>Ian</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[wtf]]></category>

		<guid isPermaLink="false">http://atomized.org/?p=392</guid>
		<description><![CDATA[Consider the following: class Foo { private $var = 'avalue'; private function doStuff() { } } As you might expect, you can’t access $var or doStuff() from outside Foo, which is well and good. However, things get strange when you throw overloading into the mix. class Foo { private $var = 'avalue'; private function doStuff() [...]]]></description>
			<content:encoded><![CDATA[<p>Consider the following:</p>
<pre>
class Foo
{
    private $var = 'avalue';
    private function doStuff()
    {
    }
}
</pre>
<p>As you might expect, you can’t access <code>$var</code> or <code>doStuff()</code> from outside <code>Foo</code>, which is well and good. However, things get strange when you throw overloading into the mix.</p>
<pre>
class Foo
{
    private $var = 'avalue';
    private function doStuff()
    {
    }
    public function __get($var)
    {
        return $this-&gt;$var;
    }
}

$foo = new Foo;
var_dump($foo-&gt;var);
</pre>
<p>This works; if a variable isn’t accessible from the calling scope, it will invoke <code>__get()</code> instead. Too bad it’s not consistent:</p>
<pre>
class Foo
{
    private $var = 'avalue';
    private function doStuff()
    {
    }
    public function __get($var)
    {
        return $this-&gt;$var;
    }
    public function __call($func, array $args = array())
    {
        return call_user_func_array(array($this, $func), $args);
    }
}

$foo = new Foo;
var_dump($foo-&gt;doStuff());
</pre>
<p>This breaks with: “Fatal error: Call to private method Foo::doStuff() from context &#8221;.”</p>
<p>It would be <i>really</i> nice if PHP followed the same rules for overloaded methods as for overloaded variables.</p>
]]></content:encoded>
			<wfw:commentRss>http://atomized.org/2008/11/more-tough-love-from-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Enhancing Emacs’ SQL Mode</title>
		<link>http://atomized.org/2008/10/enhancing-emacs%e2%80%99-sql-mode/</link>
		<comments>http://atomized.org/2008/10/enhancing-emacs%e2%80%99-sql-mode/#comments</comments>
		<pubDate>Sun, 19 Oct 2008 20:04:22 +0000</pubDate>
		<dc:creator>Ian</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[emacs]]></category>
		<category><![CDATA[lisp]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[sql-mode]]></category>

		<guid isPermaLink="false">http://atomized.org/?p=370</guid>
		<description><![CDATA[I use sql-mode a lot. It’s incredibly handy to have my abbrevs and Emacs bindings available when I’m interacting with SQL servers. But there’s always room for improvement, so I’ve identified a few areas where sql-mode could work a bit better, and fixed them. Better Buffer Naming I found this code somwhere a while back, [...]]]></description>
			<content:encoded><![CDATA[<p>I use <code>sql-mode</code> a lot. It’s incredibly handy to have my abbrevs and Emacs bindings available when I’m interacting with SQL servers. But there’s always room for improvement, so I’ve identified a few areas where <code>sql-mode</code> could work a bit better, and fixed them.</p>
<h2>Better Buffer Naming</h2>
<p>I found this code somwhere a while back, and threw in some enhancements:</p>
<ol>
<li>If <code>sql-name</code> is set, that is used in the buffer name, e.g. “*SQL sql-name*”</li>
<li>Otherwise, the name will include the hostname of <code>sql-server</code> and <code>sql-database</code>. If <code>sql-server</code> is an IP address, it’s used; if it’s a DNS name, the hostname part is used. e.g. “*SQL: dbhost/dbname*” or “*SQL 192.168.0.1/dbname”</li>
</ol>
<pre>
(defun sql-make-smart-buffer-name ()
  "Return a string that can be used to rename a SQLi buffer.

This is used to set `sql-alternate-buffer-name' within
`sql-interactive-mode'."
  (or (and (boundp 'sql-name) sql-name)
      (concat (if (not(string= "" sql-server))
                  (concat
                   (or (and (string-match "[0-9.]+" sql-server) sql-server)
                       (car (split-string sql-server "\\.")))
                   "/"))
              sql-database)))

(add-hook 'sql-interactive-mode-hook
          (lambda ()
            (setq sql-alternate-buffer-name (sql-make-smart-buffer-name))
            (sql-rename-buffer)))
</pre>
<h2>Support for TCP Ports</h2>
<p>At Digg, we have a lot of databases. As <a href="http://blog.digg.com/?p=213">you may have read</a>, we have four main pools of databases. Each of these has one write master and several slaves. We have this setup duplicated in many places for production, development, QA, and so on. While the less-stable environments don’t require the full setup, we try to balance consistency with resource usage. What we’ve settled on is one physical host running four different MySQL instance, one for each pool, each listening on a different port. Unfortunately, <code>sql-mode</code> has no support for this. You can set the <code>sql-*-options</code> variables, but this is cumbersome when you need to quickly connect to servers on different ports.</p>
<p>This simple advice will add <code>sql-port</code> into <code>sql-mysql-options</code>, if it’s set.</p>
<pre>
(defadvice sql-connect-mysql (around sql-mysql-port activate)
  "Add support for connecting to MySQL on other ports"
  (let ((sql-mysql-options (or (and (boundp 'sql-port) sql-port (cons (concat "-P " (or (and (numberp sql-port) (number-to-string sql-port)) sql-port)) sql-mysql-options)) sql-mysql-options)))
    ad-do-it))
</pre>
<p>Currently, this ony works for MySQL. It should be trivial to extend the support for other databases.</p>
<p>This doesn’t get read interactively like the other options, so you’ll have to create a new function with a let binding to connect. This isn’t such a bad thing when you throw in the next enhancement.</p>
<h2>Support for Preset Connections</h2>
<p>It’s not much fun to enter your connection information every time you want to connect. I had some functions which used let expressions to set the correct defaults for connections, but this was suboptimal, since you had to hit RET a bunch of times before the connection would start. This is fixed with preset connections. You define <code>sql-connection-alist</code> with a connection name and a list of sql variables to bind. Then you may call <code>sql-connect-preset</code> with the connection name, and you get your connection immediately.</p>
<p>Note that you can specify <code>sql-port</code> in the connection definition. Also, <code>sql-name</code> is defined to the name of the connection, so you can set the buffer name there, as well.</p>
<p>At some point in the future, it would be a good idea to make an interactive version of <code>sql-connect-preset</code>, which prompts you for one of the defined connections. For now, though, you need to define a function.</p>
<p>Example code:</p>
<pre>
(setq sql-connection-alist
      '((pool-a
         (sql-product 'mysql)
         (sql-server "1.2.3.4")
         (sql-user "me")
         (sql-password "mypassword")
         (sql-database "thedb")
         (sql-port 3306))
        (pool-b
         (sql-product 'mysql)
         (sql-server "1.2.3.4")
         (sql-user "me")
         (sql-password "mypassword")
         (sql-database "thedb")
         (sql-port 3307))))

(defun sql-connect-preset (name)
  "Connect to a predefined SQL connection listed in `sql-connection-alist'"
  (eval `(let ,(cdr (assoc name sql-connection-alist))
    (flet ((sql-get-login (&#038;rest what)))
      (sql-product-interactive sql-product)))))

(defun sql-pool-a ()
  (interactive)
  (sql-connect-preset 'pool-a))
</pre>
<p>Now, you can just run <code>sql-pool-a</code> and get connected right away. Because the buffers have good names, you can easily fire up many connections.</p>
]]></content:encoded>
			<wfw:commentRss>http://atomized.org/2008/10/enhancing-emacs%e2%80%99-sql-mode/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Reassigning Trac tickets from commit messages</title>
		<link>http://atomized.org/2008/06/reassigning-trac-tickets-from-commit-messages/</link>
		<comments>http://atomized.org/2008/06/reassigning-trac-tickets-from-commit-messages/#comments</comments>
		<pubDate>Tue, 03 Jun 2008 22:37:16 +0000</pubDate>
		<dc:creator>Ian</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[trac]]></category>

		<guid isPermaLink="false">http://atomized.org/?p=265</guid>
		<description><![CDATA[Here at Digg, we’ve been discussing ways to streamline our development process. One of the suggestions I came up with was the ability to reassign tickets (via trac-post-commit-hook) in commit messages. I hacked it together today and submitted it back to Trac. The changes are against r5308 of the hook, which is all well and [...]]]></description>
			<content:encoded><![CDATA[<p>Here at <a href="http://digg.com/">Digg</a>, we’ve been discussing ways to streamline our development process. One of the suggestions I came up with was the ability to reassign tickets (via <a href="http://trac.edgewall.org/browser/trunk/contrib/trac-post-commit-hook">trac-post-commit-hook</a>) in commit messages.</p>
<p>I hacked it together today and <a href="http://trac.edgewall.org/ticket/7300">submitted it back</a> to Trac.</p>
<p>The changes are against <a href="http://trac.edgewall.org/browser/trunk/contrib/trac-post-commit-hook?rev=5308">r5308</a> of the hook, which is all well and good if you run Trac 0.11.x. Unfortunately, it’s incompatible with Trac 0.11.x. I backed out some of the changes (<a href="http://trac.edgewall.org/changeset/4159/trunk/contrib/trac-post-commit-hook">from r4159</a>) which broke things, and it’s working for me.</p>
<p>My changes are attached to <a href="http://trac.edgewall.org/ticket/7300">the ticket</a> I opened.</p>
]]></content:encoded>
			<wfw:commentRss>http://atomized.org/2008/06/reassigning-trac-tickets-from-commit-messages/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Parsing URL query parameters in Python</title>
		<link>http://atomized.org/2008/06/parsing-url-query-parameters-in-python/</link>
		<comments>http://atomized.org/2008/06/parsing-url-query-parameters-in-python/#comments</comments>
		<pubDate>Mon, 02 Jun 2008 23:22:33 +0000</pubDate>
		<dc:creator>Ian</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://atomized.org/?p=264</guid>
		<description><![CDATA[I’ve been dabbling with Python for several months now, but I’m not quite as proficient with it as I’d like. I was hacking on some stuff recently, and needed to parse the query parameters in a URL. Python has URL parsing, but it doesn’t include querystring parsing. This was the pleasantly easy solution: from urlparse [...]]]></description>
			<content:encoded><![CDATA[<p>I’ve been dabbling with <a href="http://python.org">Python</a> for several months now, but I’m not quite as proficient with it as I’d like.</p>
<p>I was hacking on some stuff recently, and needed to parse the query parameters in a URL. Python has <a href="http://docs.python.org/lib/module-urlparse.html">URL parsing</a>, but it doesn’t include querystring parsing.</p>
<p>This was the pleasantly easy solution:</p>
<pre>
from urlparse import urlparse
url = urlparse('http://www.google.com/search?hl=en&#038;safe=off&#038;q=atomized&#038;btnG=Search')
params = dict([part.split('=') for part in url[4].split('&#038;')])
</pre>
<h2>What’s going on here</h2>
<p>Let’s break the example down a bit.</p>
<ol>
<li>
<pre>from urlparse import urlparse</pre>
<p>This pulls in Python’s URL parser.</p>
</li>
<li>
<pre>url = urlparse('http://www.google.com/search?hl=en&#038;safe=off&#038;q=atomized&#038;btnG=Search')</pre>
<p>This passes the URL through urlparse, leaving us with a <a href="http://en.wikipedia.org/wiki/Tuple">tuple</a> of URL components.</p>
</li>
<li>
<pre>url[4].split('&#038;')</pre>
<p>This splits the querystring on “&#038;” characters, leaving us with a list of “key=val” scalars. The output of this would be:</p>
<pre>['hl=en', 'safe=off', 'q=atomized', 'btnG=Search']</pre>
<p></li>
<li>
<pre>[part.split('=') for part in url[4].split('&#038;')]</pre>
<p>This is Python’s <a href="http://diveintopython.org/native_data_types/mapping_lists.html">list mapping</a>, also known as <a href="http://en.wikipedia.org/wiki/List_comprehension">list comprehension</a>. It allows us to map a function over a list &#8211; in this case, <code>part.split('=')</code> on the list of “key=value” pairs from the previous step. This leaves us with:</p>
<pre>[['hl', 'en'], ['safe', 'off'], ['q', 'atomized'], ['btnG', 'Search']]</pre>
<p>That is, an array of arrays, where the first member of the child array is the key and the second is the value.</p>
</li>
<li>
<pre>params = dict([part.split('=') for part in url[4].split('&#038;')])</pre>
<p>The last part of this is <code>dict()</code>, which turns the array structure above into a dictionary:</p>
<pre>
{'q': 'atomized', 'safe': 'off', 'btnG': 'Search', 'hl': 'en'}
</pre>
<p>Thix is roughly equivalent to a hash map or associative array. It allows us to access specific keys, such as <code>params['q']</code>.</p>
</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://atomized.org/2008/06/parsing-url-query-parameters-in-python/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>The problem with PHP</title>
		<link>http://atomized.org/2008/04/the-problem-with-php/</link>
		<comments>http://atomized.org/2008/04/the-problem-with-php/#comments</comments>
		<pubDate>Thu, 03 Apr 2008 20:09:07 +0000</pubDate>
		<dc:creator>Ian</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://atomized.org/?p=244</guid>
		<description><![CDATA[array_reverse() doesn’t maintain array keys. The problem here isn’t this specific behavior, but it neatly encapsulates one of my core complaints with PHP. Which is: there’s an attitude of “do something dumb, unless the developer asks not to.” You see this over and over in the PHP world. Mangling keys unless you ask not to. [...]]]></description>
			<content:encoded><![CDATA[<p><code>array_reverse()</code> doesn’t maintain array keys.</p>
<p>The problem here isn’t this specific behavior, but it neatly encapsulates one of my core complaints with PHP. Which is: there’s an attitude of “do something dumb, unless the developer asks not to.” You see this over and over in the PHP world. Mangling keys unless you ask not to. Magic quotes being enabled by default. It’s lame, and stupid, and requires the developer to outsmart the language to get basic things done.</p>
<p>This is a problem, because developer time is expensive, and brainpower limited. When things don’t work optimally, that’s wasted developer effort and time. You have to know that there is a problem, and work around it. Or forget that there’s a problem, spend time debugging it, and get a “duh” moment when you remember. Problems like these should not rise to the level of needing attention, because developer attention is better focused on the larger problems.</p>
<p>It’s hard to <a href="http://blog.libssh2.org/index.php?/archives/51-Youre-being-lied-to..html">trust the language to do the right thing</a> for the big stuff when you have to outsmart it to get the small stuff to work.</p>
]]></content:encoded>
			<wfw:commentRss>http://atomized.org/2008/04/the-problem-with-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
