<?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>Dave Smith&#039;s Blog</title>
	<atom:link href="http://thesmithfam.org/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://thesmithfam.org/blog</link>
	<description>Your blog is probably better than mine.</description>
	<lastBuildDate>Sat, 20 Mar 2010 17:51:58 +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>Parkzone Habu Walk Through</title>
		<link>http://thesmithfam.org/blog/2010/03/20/parkzone-habu-walk-through/</link>
		<comments>http://thesmithfam.org/blog/2010/03/20/parkzone-habu-walk-through/#comments</comments>
		<pubDate>Sat, 20 Mar 2010 17:51:58 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[RC Planes]]></category>

		<guid isPermaLink="false">http://thesmithfam.org/blog/?p=666</guid>
		<description><![CDATA[My new Parkzone Habu ducted fan jet arrived in the mail this week. I put it together and provide this walkthrough for the benefit of those who have not yet purchased their Habu (hint: just do it).
Stay tuned for the flight report in a couple weeks.

Parkzone Habu Walk Through from djsmith on Vimeo.
]]></description>
			<content:encoded><![CDATA[<p>My new Parkzone Habu ducted fan jet arrived in the mail this week. I put it together and provide this walkthrough for the benefit of those who have not yet purchased their Habu (hint: just do it).</p>
<p>Stay tuned for the flight report in a couple weeks.</p>
<p><object width="400" height="300"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=10307236&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=10307236&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="300"></embed></object>
<p><a href="http://vimeo.com/10307236">Parkzone Habu Walk Through</a> from <a href="http://vimeo.com/user3328127">djsmith</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://thesmithfam.org/blog/2010/03/20/parkzone-habu-walk-through/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to auto-reboot your Comcast cable modem</title>
		<link>http://thesmithfam.org/blog/2010/03/16/how-to-auto-reboot-your-comcast-cable-modem/</link>
		<comments>http://thesmithfam.org/blog/2010/03/16/how-to-auto-reboot-your-comcast-cable-modem/#comments</comments>
		<pubDate>Tue, 16 Mar 2010 06:04:28 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Code and Cruft]]></category>

		<guid isPermaLink="false">http://thesmithfam.org/blog/?p=660</guid>
		<description><![CDATA[My office has a piece-of-junk Comcast cable modem that often needs to be rebooted. I got tired of walking back to the network closet, so I bought a USB relay for $30.
Yeah, I could have simply bought a better modem, but where&#8217;s the fun in that?
Here&#8217;s a photo of the relay board:

After connecting it to [...]]]></description>
			<content:encoded><![CDATA[<p>My office has a piece-of-junk Comcast cable modem that often needs to be rebooted. I got tired of walking back to the network closet, so I bought a <a href="http://www.ecrater.com/product.php?pid=4757843">USB relay</a> for $30.</p>
<p>Yeah, I could have simply bought a better modem, but where&#8217;s the fun in that?</p>
<p>Here&#8217;s a photo of the relay board:</p>
<p><img src="/images/usb-relay-1.jpg" /></p>
<p>After connecting it to the modem&#8217;s power, I wrapped it in heat shrink:</p>
<p><img src="/images/usb-relay-2.jpg" /></p>
<p>And its final resting place where it will happily power cycle my cable modem for its entire useful life:</p>
<p><img src="/images/usb-relay-3.jpg" /></p>
<p>I put the relay between the modem&#8217;s power adapter and the modem itself, and connected the relay to my Linux server&#8217;s USB port for control. Once connected, the Linux kernel happily registered it as <b>/dev/ttyUSB0</b> (it uses an FTDI chip for its USB-to-Serial translation, which is supported by all modern Linux kernels). </p>
<p>When connecting the power, I used the &#8220;C&#8221; and &#8220;NC&#8221; ports (&#8220;C&#8221; = &#8220;Common&#8221; and &#8220;NC&#8221; = &#8220;Normally Closed&#8221;). I didn&#8217;t use the &#8220;NO&#8221; port (&#8220;NO = &#8220;Normally Open&#8221;) because I don&#8217;t want my modem powering off just because the relay loses power (e.g., when the Linux box reboots).</p>
<p>This simple shell script power cycles the modem, which I run nightly using cron:</p>
<p><code><br />
#!/bin/bash<br />
device=/dev/ttyUSB0<br />
printf '\xFF\x01\x01' >$device # Power off<br />
sleep 60<br />
printf '\xFF\x01\x00' >$device # Power on<br />
</code></p>
<p>I noticed that I needed to let the modem sleep for longer than 10 seconds, or there are problems on the network. In particular, our Outlook clients seem to lose their brains to our (off-site) Exchange server unless I sleep for longer. I used 60 seconds just to be safe.</p>
<p>The next step is to setup another cron job on my Linux box that will power cycle the modem if it ever discovers that it can&#8217;t reach the internet, or that its internet bandwidth is degraded.</p>
<p>I also wrote a small C++ program for Windows (about 20 lines) just to test the relay. It worked fine, but Linux was a <b>lot</b> easier to setup (no compiler necessary). In the time it took me to write that stupid C++ program, I was able to create <b>both</b> a working Python script and working shell script to do the same job (and Linux didn&#8217;t even require me to know the baud rate).</p>
<p>By the way, I would have avoided this whole exercise if my modem, like many others, had a software controllable reboot (some can be rebooted with <b>wget</b>, but not mine).</p>
<p>Happy (hardware) hacking!</p>
]]></content:encoded>
			<wfw:commentRss>http://thesmithfam.org/blog/2010/03/16/how-to-auto-reboot-your-comcast-cable-modem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fancy QSlider Stylesheet</title>
		<link>http://thesmithfam.org/blog/2010/03/10/fancy-qslider-stylesheet/</link>
		<comments>http://thesmithfam.org/blog/2010/03/10/fancy-qslider-stylesheet/#comments</comments>
		<pubDate>Wed, 10 Mar 2010 21:48:21 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Code and Cruft]]></category>

		<guid isPermaLink="false">http://thesmithfam.org/blog/?p=650</guid>
		<description><![CDATA[Seriously. I don&#8217;t know how I ever created a Qt user interface without using stylesheets. This was, by far, the best idea Trolltech ever had.
For today&#8217;s show-and-tell, I give you a nifty-looking QSlider with some nice gradient style applied to it:

The handle has a nice hover effect, the bar has a moving gradient as you [...]]]></description>
			<content:encoded><![CDATA[<p>Seriously. I don&#8217;t know how I ever created a Qt user interface without using stylesheets. This was, by far, the best idea Trolltech ever had.</p>
<p>For today&#8217;s show-and-tell, I give you a nifty-looking QSlider with some nice gradient style applied to it:</p>
<p><img src="/images/slider-stylized.png" /></p>
<p>The handle has a nice hover effect, the bar has a moving gradient as you slide the slider, and it looks good when disabled. Notice also the rounded corners. No image files were harmed in the making of this widget.</p>
<p>Here&#8217;s the stylesheet code (I used <a href="http://qt.nokia.com/doc/4.6/stylesheet-examples.html#customizing-qslider">Qt&#8217;s example</a> as a starting point).</p>
<pre style="font-size: 9pt; border: 2px solid #016; padding: 5px; color: white; background: #333;">
QSlider::groove:horizontal {
border: 1px solid #bbb;
background: white;
height: 10px;
border-radius: 4px;
}

QSlider::sub-page:horizontal {
background: qlineargradient(x1: 0, y1: 0,    x2: 0, y2: 1,
    stop: 0 #66e, stop: 1 #bbf);
background: qlineargradient(x1: 0, y1: 0.2, x2: 1, y2: 1,
    stop: 0 #bbf, stop: 1 #55f);
border: 1px solid #777;
height: 10px;
border-radius: 4px;
}

QSlider::add-page:horizontal {
background: #fff;
border: 1px solid #777;
height: 10px;
border-radius: 4px;
}

QSlider::handle:horizontal {
background: qlineargradient(x1:0, y1:0, x2:1, y2:1,
    stop:0 #eee, stop:1 #ccc);
border: 1px solid #777;
width: 13px;
margin-top: -2px;
margin-bottom: -2px;
border-radius: 4px;
}

QSlider::handle:horizontal:hover {
background: qlineargradient(x1:0, y1:0, x2:1, y2:1,
    stop:0 #fff, stop:1 #ddd);
border: 1px solid #444;
border-radius: 4px;
}

QSlider::sub-page:horizontal:disabled {
background: #bbb;
border-color: #999;
}

QSlider::add-page:horizontal:disabled {
background: #eee;
border-color: #999;
}

QSlider::handle:horizontal:disabled {
background: #eee;
border: 1px solid #aaa;
border-radius: 4px;
}
</pre>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://thesmithfam.org/blog/2010/03/10/fancy-qslider-stylesheet/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Qt Layout Squashing</title>
		<link>http://thesmithfam.org/blog/2010/03/09/qt-layout-squashing/</link>
		<comments>http://thesmithfam.org/blog/2010/03/09/qt-layout-squashing/#comments</comments>
		<pubDate>Tue, 09 Mar 2010 16:31:07 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Code and Cruft]]></category>

		<guid isPermaLink="false">http://thesmithfam.org/blog/?p=636</guid>
		<description><![CDATA[I&#8217;ve encountered this problem a handful of times over the past few years using Qt&#8217;s layouts. Qt generally does a great job making sure that your Windows cannot be resized too small such that your content would be truncated. However, it seems that introducing a QStackedWidget causes a problem.
These two screenshots illustrate the issue:
Screenshot 1 [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve encountered this problem a handful of times over the past few years using Qt&#8217;s layouts. Qt generally does a great job making sure that your Windows cannot be resized too small such that your content would be truncated. However, it seems that introducing a <strong>QStackedWidget</strong> causes a problem.</p>
<p>These two screenshots illustrate the issue:</p>
<p><strong>Screenshot 1</strong> The widget prior to resizing (all text appears correctly)</p>
<p><img src="/images/qt-layout-problem-1.png" /></p>
<p><strong>Screenshot 2</strong> The user resizes the widget (the text is truncated)</p>
<p><img src="/images/qt-layout-problem-2.png" /></p>
<p>Like I said above, I think the problem is caused by the <strong>QStackedWidget</strong>. Without it, Qt properly limits the widget&#8217;s minimum size such that the text cannot be truncated. I would <strong>love</strong> it if the <a href="http://qt.nokia.com/">Trolls</a> could have a look at this issue. I&#8217;ve seen the problem since Qt 4.0, but I never reduced the problem to its base (it took a while to deduce that the <strong>QStackedWidget</strong> was the culprit). </p>
<p>If you&#8217;re interested, I&#8217;ve included the <a href="/files/LayoutProblem.ui">minimal Designer UI file</a> that shows the problem (right click that link to save it). I used Designer 4.6.2 to create this file.</p>
]]></content:encoded>
			<wfw:commentRss>http://thesmithfam.org/blog/2010/03/09/qt-layout-squashing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Talking to Qt Threads</title>
		<link>http://thesmithfam.org/blog/2010/02/07/talking-to-qt-threads/</link>
		<comments>http://thesmithfam.org/blog/2010/02/07/talking-to-qt-threads/#comments</comments>
		<pubDate>Mon, 08 Feb 2010 05:59:31 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Code and Cruft]]></category>

		<guid isPermaLink="false">http://thesmithfam.org/blog/?p=609</guid>
		<description><![CDATA[I wrote about multi-threading in Qt a while back, and how to use QThread to wrap a blocking function call &#8220;lock free&#8221;. Today we&#8217;ll talk about how to pass data into your thread. This approach can be used, for example, to tell your QThread to stop.

pre { font-size: 10pt; border: 2px solid #016; padding: 5px; [...]]]></description>
			<content:encoded><![CDATA[<p>I wrote about <a href="http://thesmithfam.org/blog/2009/09/30/lock-free-multi-threading-in-qt/">multi-threading in Qt</a> a while back, and how to use <b>QThread</b> to wrap a blocking function call &#8220;lock free&#8221;. Today we&#8217;ll talk about how to pass data into your thread. This approach can be used, for example, to tell your <b>QThread</b> to stop.</p>
<style>
pre { font-size: 10pt; border: 2px solid #016; padding: 5px; color: white; background: #333; }
</style>
<p>There are two ways to use <b>QThread</b>, with and without an event loop, and the preferred method for talking to a <b>QThread</b> depends on which of them you use.</p>
<p><b>Way 1: Without an event loop</b></p>
<p>When you&#8217;re not using an event loop, the thread&#8217;s <b>run()</b> method often looks like this:</p>
<pre>
void MyThread::run()
{
    forever
    {
        // Do some stuff
    }
}
</pre>
<p>Since this method does not use an event loop, there is no way to deliver a signal to your thread. So if you want to pass data into the thread, you have to use a good old fashioned mutex. Let&#8217;s look at an example showing you how to <b>stop</b> your thread:</p>
<pre>
void MyThread::run()
{
    forever
    {
        {
            // "mutex" and "stopRequested" are member
            // variables of MyThread:
            QMutexLocker locker(&#038;mutex);
            if(stopRequested)
                return;
        }

        // Do some stuff
    }
}

void MyThread::stop()
{
    QMutexLocker locker(&#038;mutex);
    stopRequested = true;
}
</pre>
<p>In this case, we have to check the <b>stopRequested</b> variable in a timely manner in our thread&#8217;s <b>run()</b> method. The longer you run between checks, the longer it will take your thread to actually stop.</p>
<p>Outside observers can use the <b>finished()</b> signal to know when your thread is actually done. So if you are in a QMainWindow, for example, and a <b>closeEvent()</b> happens, you can ignore the event, call <b>MyThread::stop()</b>, and then when the <b>QThread::finished()</b> signal arrives, you can actually close the window.</p>
<p>The downside is that the <b>stop()</b> call will actually block while it tries to acquire the <b>mutex</b>. Given the way this code is written, the blocking will probably be very short, but hey, I hate blocking. Let&#8217;s see if we can dig up a better way to do this.</p>
<p><b>Way 2: With an event loop</b></p>
<p>If you have an event loop, you can use Qt&#8217;s meta-objects to talk to your thread. Let&#8217;s look at the same example as before, only this time with no locking or blocking.</p>
<pre>
void MyThread::MyThread()
{
    moveToThread(this);
}

void MyThread::run()
{
    QTimer *timer = new QTimer();
    connect(timer, SIGNAL(timeout()),
        this, SLOT(doSomething()));
    timer->start(0);

    exec(); // starts the event loop, and doesn't
            // return until it is told to quit()
}

void MyThread::stop()
{
    if(currentThread() != this)
    {
        // The caller is running in a
        // different thread, so use Qt to
        // call stop() later, on our own thread:
        QMetaObject::invokeMethod(this, "stop",
                        Qt::QueuedConnection);
    }
    else
    {
        // Now the call has arrived from our
        // own thread, yay! We can safely
        // shut down our event loop.
        quit();
    }
}
</pre>
<p>Look mom! No locks! Now we have killed our thread, safely and gracefully. There is no chance of blocking, and we learned something about QMetaObject.</p>
<p>A couple items to note:</p>
<ul>
<li>The <b>doSomething()</b> method is left as an exercise for the reader, but be careful about the <b>QTimer</b> interval. I used <b>0</b>, which means it will be firing almost constantly.</li>
<li>The <b>stop()</b> method must be a <b>slot</b> in MyThread (and not just a regular method) or else <b>invokeMethod()</b> will return false and not actually re-invoke <b>stop()</b> for you.</li>
<li>You <b>can</b> pass arguments to your thread this way, but it requires a bit more fun with <a href="http://doc.trolltech.com/4.6/qmetaobject.html">QMetaObject::invokeMethod()</a>.</li>
<li>You can reduce this whole thing to a magical macro that you could put at the top of your stop() method, saving you from having to write <b>if(currentThread() == this)</b> at the top of every method. Hint: use the __FUNCTION__ macro.</li>
<li>To run this example code, you&#8217;ll need to <b>#include</b> these files: QThread, QTimer, QMetaObject, QMutexLocker, and QMutex</li>
<li>To call <b>quit()</b>, it may not actually be necessary to be running on the same <b>QThread</b> (it works for me without the QMetaObject), but this will be required when you start passing in data to your thread. Without it, your program could do unpredictable naughty things. I can&#8217;t find anything in the docs about whether <b>quit()</b> is thread safe.
</li>
</ul>
<p>I&#8217;ve found this <b>QMetaObject</b> approach the most effective and easiest way to pass data to <b>QThreads</b> safely, without blocking and without locks.</p>
<p>Happy threading!</p>
]]></content:encoded>
			<wfw:commentRss>http://thesmithfam.org/blog/2010/02/07/talking-to-qt-threads/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>First Person Video on a Shoestring</title>
		<link>http://thesmithfam.org/blog/2010/02/03/first-person-video-on-a-shoestring/</link>
		<comments>http://thesmithfam.org/blog/2010/02/03/first-person-video-on-a-shoestring/#comments</comments>
		<pubDate>Thu, 04 Feb 2010 03:14:53 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[RC Planes]]></category>

		<guid isPermaLink="false">http://thesmithfam.org/blog/?p=597</guid>
		<description><![CDATA[Today my friend Cliff showed me his first-person video R/C airplane:

This thing has every feature imaginable, which means it packs a lot of wires:

Here&#8217;s a video tour of all its features, which include the following:

Auto fly-home if control is lost (uses GPS)
Heads up video display of altitude, heading, and pitch
RF beacon if the plane is [...]]]></description>
			<content:encoded><![CDATA[<p>Today my friend Cliff showed me his first-person video R/C airplane:</p>
<p><img src="/images/cliffs-fpv-wild-hawk.jpg" /></p>
<p>This thing has every feature imaginable, which means it packs a lot of wires:</p>
<p><img src="/images/cliffs-fpv-wild-hawk-closeup.jpg" /></p>
<p>Here&#8217;s a video tour of all its features, which include the following:</p>
<ul>
<li>Auto fly-home if control is lost (uses GPS)</li>
<li>Heads up video display of altitude, heading, and pitch</li>
<li>RF beacon if the plane is lost</li>
<li>Auto stabilization using FMA co-pilot</li>
<li>Data logger providing an audible report of battery life and other stats</li>
<li>VR goggles for watching the action</li>
<li>Pan and tilt camera, controllable from the radio</li>
<li>High-power transmitter (he&#8217;s flown a mile away on FPV)</li>
</ul>
<p><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/ZuYbWzJIUCc&#038;hl=en&#038;fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/ZuYbWzJIUCc&#038;hl=en&#038;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://thesmithfam.org/blog/2010/02/03/first-person-video-on-a-shoestring/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to (really) change the calendar colors on your iPhone</title>
		<link>http://thesmithfam.org/blog/2010/01/23/how-to-really-change-the-calendar-colors-on-your-iphone/</link>
		<comments>http://thesmithfam.org/blog/2010/01/23/how-to-really-change-the-calendar-colors-on-your-iphone/#comments</comments>
		<pubDate>Sun, 24 Jan 2010 05:10:35 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Code and Cruft]]></category>

		<guid isPermaLink="false">http://thesmithfam.org/blog/?p=578</guid>
		<description><![CDATA[The iPhone doesn&#8217;t (easily) let you change the colors of your calendar items. Couple this with the fact that there are lots of ways to setup calendar sync&#8217;ing, and it&#8217;s easy to get discouraged.
For me, my work calendar and my personal calendar both showed up as nearly the same shade of red. Fail.
Here&#8217;s how I [...]]]></description>
			<content:encoded><![CDATA[<p>The iPhone doesn&#8217;t (easily) let you change the colors of your calendar items. Couple this with the fact that there are lots of ways to setup calendar sync&#8217;ing, and it&#8217;s easy to get discouraged.</p>
<p>For me, my work calendar and my personal calendar both showed up as nearly the same shade of red. Fail.</p>
<p>Here&#8217;s how I fixed it. This only works if you have the following situation:</p>
<ul>
<li>iPhone OS 3.0 or newer</li>
<li>Using Google Calendar with CalDAV (<b>not</b> Exchange)</li>
<li>Note: I use Exchange for my work calendar and Google for my personal calendar, and I want them <b>both</b> on my iPhone with different colors</li>
</ul>
<p>Steps to change the color (this takes about 5 minutes if nothing goes wrong).</p>
<ol>
<li>Open iCal on your Mac (don&#8217;t have a Mac? Maybe Mozilla Sunbird can do this too)</li>
<li>Subscribe to your Google Calendar (<a href="http://www.google.com/support/calendar/bin/answer.py?hl=en&#038;answer=99358#ical">instructions to do this</a></li>
<li>In the sidebar, notice your new calendar appears<br />
<img src="/images/ical-with-google.png" /></li>
<li>Right-click on the new calendar and select <b>Get Info</b></li>
<li>Now change the color to what you want<br />
<img style="margin-left: -55px" src="/images/ical-with-google-color.png" /></li>
<li>Do nothing, and in a couple minutes your iPhone calendar items will have the new color</li>
</ol>
<p>If you can&#8217;t get iCal setup, don&#8217;t fret. It does work. Double check your URL you typed to subscribe to your Google Calendar. Don&#8217;t forget the &#8220;/user&#8221; at the end. Follow Google&#8217;s instructions (see link above) very closely.</p>
<p>Good luck!</p>
]]></content:encoded>
			<wfw:commentRss>http://thesmithfam.org/blog/2010/01/23/how-to-really-change-the-calendar-colors-on-your-iphone/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Functional is not Procedural</title>
		<link>http://thesmithfam.org/blog/2010/01/05/functional-is-not-procedural/</link>
		<comments>http://thesmithfam.org/blog/2010/01/05/functional-is-not-procedural/#comments</comments>
		<pubDate>Tue, 05 Jan 2010 22:17:46 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Code and Cruft]]></category>

		<guid isPermaLink="false">http://thesmithfam.org/blog/?p=562</guid>
		<description><![CDATA[I&#8217;ve recently seen some confusion about the terms functional and procedural in the software development community. Let me spend a moment trying to clear things up for (both of) my readers.
First of all, just because a programming language has functions, that does not mean it is functional. In fact, its confusing name has nothing to [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve recently seen some confusion about the terms <b>functional</b> and <b>procedural</b> in the software development community. Let me spend a moment trying to clear things up for (both of) my readers.</p>
<p>First of all, just because a programming language has <b>functions</b>, that does not mean it is <b>functional</b>. In fact, its confusing name has nothing to do with functions. The history of the term <b>function</b>, as used in the computation world, hails back to the 1930&#8217;s when Alonzo Church created Lambda Calculus to be able to use and define mathematical algorithms on paper. Later, when computers arrived on the scene, programmers adopted the term <b>function</b> to describe a chunk of code that could be re-used by other chunks of code. Functions, in this context, have been adopted by every programming language I know of, including assembly language. Functions are commonly referred to as &#8220;routines&#8221;, &#8220;subroutines&#8221;, or &#8220;procedures&#8221;. Some might even argue that a &#8220;method&#8221; is pragmatically identical to a function.</p>
<p>Here&#8217;s where the confusion begins.</p>
<p>This is hard to explain rigorously, but here goes anyway.</p>
<p>Some languages, like C, tend to encourage computer programmers to make use of functions. Programs written in these languages tend to consist of a set of functions, and a &#8220;main&#8221; function that kicks everything off. Such a language is often referred to as &#8220;procedural&#8221;, but really the term &#8220;procedural&#8221; refers to a style of programming, and does not really describe a language, per se. It is most often used as an antonym to the concept of &#8220;object oriented&#8221;. But, oddly, it has nothing to do with &#8220;functional&#8221; programming.</p>
<p>Other languages, like Scheme and Haskell, tend to encourage computer programmers to write code with functions that avoid internal state changes and produce no side effects when called. For example, these language discourage global variables, and particularly the calling of functions that would mutate global variables (that would be a side effect).</p>
<p>To sum up.</p>
<p>Procedural programming languages can be functional or not. Functional programming languages can be procedural or not.</p>
<p>Here&#8217;s a table:</p>
<style><!--
table { border: 1px solid black; border-collapse: collapse; }
table td, table th { padding: 3px; border: 1px solid black; }
--></style>
<table>
<tr>
<th>Language</th>
<th>Functional</th>
<th>Procedural</th>
</tr>
<tr>
<td>C</td>
<td>No</td>
<td>Yes</td>
</tr>
<tr>
<td>Haskell</td>
<td>Yes</td>
<td>Yes</td>
</tr>
<tr>
<td>Python</td>
<td>Can be</td>
<td>Can be</td>
</tr>
<tr>
<td>C++</td>
<td>No</td>
<td>Can be (if you write it like C)</td>
</tr>
<tr>
<td>Java</td>
<td>No</td>
<td>Usually not</td>
</tr>
<tr>
<td>OCaml</td>
<td>Yes</td>
<td>Yes</td>
</tr>
</table>
<p>If you take nothing else away from this article, take this: The C programming language is <b>not</b> a functional language. It&#8217;s not bad, it&#8217;s just not functional.</p>
]]></content:encoded>
			<wfw:commentRss>http://thesmithfam.org/blog/2010/01/05/functional-is-not-procedural/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Technology Predictions for 2010</title>
		<link>http://thesmithfam.org/blog/2010/01/01/technology-predictions-for-2010/</link>
		<comments>http://thesmithfam.org/blog/2010/01/01/technology-predictions-for-2010/#comments</comments>
		<pubDate>Fri, 01 Jan 2010 16:30:54 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Code and Cruft]]></category>
		<category><![CDATA[Miscellany]]></category>
		<category><![CDATA[RC Planes]]></category>
		<category><![CDATA[2010]]></category>

		<guid isPermaLink="false">http://thesmithfam.org/blog/?p=539</guid>
		<description><![CDATA[My brain&#8217;s been a stewing about 2010, and I just gotta let it all out. If I&#8217;m even half right, 2010 will be awesome.
1. Hulu in the Living Room

In 2010, Hulu will partner with a company like Western Digital or Popcorn Hour to release a tiny box that connects to your HDTV to watch TV [...]]]></description>
			<content:encoded><![CDATA[<p>My brain&#8217;s been a stewing about 2010, and I just gotta let it all out. If I&#8217;m even half right, 2010 will be awesome.</p>
<h2>1. Hulu in the Living Room</h2>
<p><img src="/images/hulu.png" style="float: right; margin-left: 20px; margin-bottom: 0px;" /></p>
<p>In 2010, <a href="http://hulu.com">Hulu</a> will partner with a company like <a href="http://www.wdc.com/en/products/WDTV/">Western Digital</a> or <a href="http://www.popcornhour.com/">Popcorn Hour</a> to release a tiny box that connects to your HDTV to watch TV shows and movies, streamed from Hulu&#8217;s servers. The box will cost less than $100, and have no monthly subscription, because its development will be subsidized by Hulu&#8217;s ad revenues. If it&#8217;s not released in 2010, it will at least be announced.</p>
<h2>2. Cable Networks Become Record Labels</h2>
<p><img src="/images/itunes.png" style="float: right; margin-left: 20px; margin-bottom: 0px;" /></p>
<p>Just like iTunes changed the music industry, online media and broadband Internet access will start to change the TV industry. It remains to be seen who will be the big player (my money&#8217;s on <a href="http://hulu.com">Hulu</a>), but one thing is for sure: Americans will have a choice when it comes to buying subscription TV services. The trend will begin in 2010, allowing consumers to get on-demand TV content for free, and will finish some time in the future with cable companies either totally transforming into something like modern record labels, or going out of business.</p>
<h2>3. HDTV Sales Will Boom</h2>
<p><img src="/images/hdtv.png" style="float: right; margin-left: 20px; margin-bottom: 0px;" /></p>
<p>HDTV&#8217;s have gotten so inexpensive that nearly every American household will have one by the end of 2010. This will be driven by the fact that online media will be so easily accessible that most people won&#8217;t need to buy cable, so they can easily justify the cost of a new $500 TV.</p>
<h2>4. Qt&#8217;s Best Year</h2>
<p><img src="/images/qt-logo.png" style="float: right; margin-left: 20px; margin-bottom: 0px;" /></p>
<p>Companies who develop desktop application software that needs to run on Mac and Windows will simply have no other choice for their developers than Qt. That trend will strengthen in 2010 to the point that it&#8217;s a no-brainer decision over platform-specific choices like .NET, Cocoa, and others. Qt has matured so much over the last 5 years that its toe-hold in this market will grow to a full Nelson in 2010.</p>
<h2>5. Model Aviation Takes Off</h2>
<p><img src="/images/super-cub.png" style="float: right; margin-left: 20px; margin-bottom: 0px;" /></p>
<p>Model airplanes have gotten very popular and accessible. Manufacturers have pushed prices down so low that anyone can afford to get into the hobby. Batteries, R/C electronics, and planes have gotten cheaper, and planes have gotten easier to fly for the novice pilot. The entry-level model airplane market will take off in 2010.</p>
<h2 style="color: #061">Your Turn</h2>
<p>Do you agree with my predictions, or am I totally off?</p>
<p>Have any predictions of your own?</p>
]]></content:encoded>
			<wfw:commentRss>http://thesmithfam.org/blog/2010/01/01/technology-predictions-for-2010/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Apple Time Machine User Interface Win</title>
		<link>http://thesmithfam.org/blog/2009/10/25/apple-time-machine-user-interface-win/</link>
		<comments>http://thesmithfam.org/blog/2009/10/25/apple-time-machine-user-interface-win/#comments</comments>
		<pubDate>Mon, 26 Oct 2009 04:26:53 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Code and Cruft]]></category>

		<guid isPermaLink="false">http://thesmithfam.org/blog/?p=523</guid>
		<description><![CDATA[Earlier this year, a shiny new iMac graced my home (increasing my resale value by about 10%, according to Zillow). Since then, I&#8217;ve had to replace my keyboard three times due to drool damage.
It happened again tonight, this time compliments of the Time Machine menu bar icon (I know, it&#8217;s a curse).

I noticed months ago [...]]]></description>
			<content:encoded><![CDATA[<p>Earlier this year, a shiny new iMac graced my home (increasing my resale value by about 10%, according to <a href="http://www.zillow.com/">Zillow</a>). Since then, I&#8217;ve had to replace my keyboard three times due to drool damage.</p>
<p>It happened again tonight, this time compliments of the <a href="http://www.apple.com/macosx/what-is-macosx/time-machine.html">Time Machine</a> menu bar icon (I know, it&#8217;s a curse).</p>
<p><img src="/images/time-machine-menubar-icon.png" /></p>
<p>I noticed months ago that the icon spins while Time Machine is backing up my iMac. But that&#8217;s not the drool feature. The little hands on the clock spin, but they go <b>backwards</b>! It&#8217;s a gentle reminder that Time Machine lets you go <b>back in time</b> to restore your files.</p>
<p>Awesome, but now it&#8217;s time for another new <a href="http://www.apple.com/keyboard/">keyboard</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://thesmithfam.org/blog/2009/10/25/apple-time-machine-user-interface-win/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
