Back to an Old Friend

January 14, 2008

Last year I set up my old Athlon 850 as a MythTV (both front and back-end) box. With a PVR-150 and a PVR-250 installed, it was a passable DVR running Mythdora. During our transition to Michigan, it fell out of use. One day I tried to upgrade to MythTV .20 but the Mythdora installation that supported it did not allow me to use the older NVidia drivers and so it would freeze up when XOrg launched. When DataDirect started charging for channel listings. I gave up on the project completely. I put my PC into permanent retirement.

But then, like the Army coming back to ask John Rambo for help, I coaxed my old PC to help me one more time. Its mission: to run IEs4Linux to aid in some part-time freelancing. I tried to install MythTV .19 and have my MythTV along with IEs4Linux, but the LVM volume kept corrupting for some reason. I then installed Fedora Core 4 and now everything is running beautifully.

While I had signed up for some shared hosting for my dkast.net domain, the service has proved to be unreliable, so I’ve just decided to host my own sites. It’ll be a better learning experience, too, as I’ll get to work with git, capistrano, and perhaps mongrel/nginx.

Once you get Linux working, it really is a pleasure to work with.

Next step: find a way to get my Airport Express to act as an ethernet-to-wireless bridge and WDS repeater simultaneously.


Industrialization and Web Development

December 22, 2007

On my way down to Illinois today, I listened to a podcast giving an overview of American history before 1870.  In it, Dr. Reilly talks about the industrial revolution.  I was enthralled as I contemplated the changes that the revolution brought about and the similarities to the changes taking place in web development.

In the 1800’s manufacturing moved from a guild system toward the use of unskilled labor and interchangeable parts.  Under the guild system, an apprentice would live and work for a master tradesman who provided food, shelter, and training.  Goods
were produced from start to finish by a single tradesman. Volume of production was limited and a great deal of skill was required of the tradesmen, who needed to have a holistic understanding of the products they produced.

The guild system remained primarily because it was most economical to have a local tradesman produce goods.  It was too costly to import goods from across a continent.  Once canals and railroads provided cheap freight services, it became economical to produce a high volume of goods and ship them to distant customers.  Thus, the need for mass production arose.  Instead of hiring ten times more tradesman to produce ten times more products, it made more sense to hire unskilled workers to perform specialized tasks, thus “pipelining” the production process.  Tradesman began to take more managerial roles, training the unskilled laborers in their specific jobs.

At the same time, the idea of using interchangeable parts arose.  With interchangeable parts, it was much easier to repair and maintain products.  Before the revolution, a product was custom made and its design was known intimately by the tradesman who made it.  If it needed to be fixed, the best person to fix it was the one who made it.  With interchangeable parts, a product’s parts could be easily replaced if broken and could be repaired or maintained by anyone familiar with the industry.  Furthermore, a factory producing widgets can make the widget almost completely out of interchangeable parts produced by other companies.  No specialized knowledge of how each part is made is required.  The factory can simply make new widgets out of preexisting components.

The industrial revolution was a drastic change for the tradesman who were accustomed to the old guild system.  The tradesman who prided themselves on quality (and high wages for specialized work) strongly opposed the revolution.  They considered the mass-produced goods to be inferior to their custom, hand-made products.  They formed unions to try and preserve their wages and job security. But ultimately, mass production won out and in many industries completely replaced the guild system.

So how does this relate to web development?  In many ways there has been an “industrialization” of how web applications are developed.  In many cases today, web applications are (or have been) written by one or a few programmers who are intimately familiar with their custom implementation.  If a programmer leaves, the web development company is in a bit of bind because knowledge of all of the intimate details of the system is lost and a great deal of time is required for new programmers to wrap their heads around the system in order to maintain or improve it.  Over the past seven or so years, there has been a trend toward specialization of work and an increase in the use of libraries, code generators, and frameworks, similar to the idea of interchangeable parts. 

Prior to our current days of web 2.0, the only division of labor that normally existed was between graphic design and programming.  As web applications have become more complex, many companies have moved from hiring jack-of-all-trades web developers to hiring specialized Flash developers, UI developers, database developers, and server-side develoeprs.  Companies seem to care more about whether a programmer is intimately familiar with J2EE or DOM scripting rather than a holistic understanding of web applications and computer science.  To run with the industrial revolution analogy, it’s like an employer who is more interested in how well a worker can operate a welder, rather than being able to build an entire car by hand.

Libraries, frameworks, code generators, web services, and mashups can be considered the “interchangeable parts” of the web.  As long as an unskilled programmer knows a specific framework, say CakePHP, he can jump into any CakePHP project and easily maintain it. Not as much specialized knowledge about the application is needed compared to a custom-written, classic PHP site.

While there are similarities between the effects that the industrial revolution had on industries like blacksmithing, shoe making, and automobile making, and the effects of industrialization on web development, there are some differences.  While the industrial revolution nearly completely replaced tradesmen with unskilled workers (and even robotics) in industries where simple products are produced, it has not replaced tradesman in every industry.  For example, in most cases skilled contractors are still needed to build houses and large buildings.

As I see it, there are currently three types of web applications being produced today.  The first type is the static, informational web site.  There’s not much for a programmer to do here.  Most of the work is for the designer.  At one time, someone who knew HTML was needed, but apps like Dreamweaver have replaced that need.  The second type is the CMS-style site that might have news, events, subscriptions, or blogs.  These sites used to require dedicated developers, but now packages like Drupal, PHPNuke, and wikis have replaced this need.  Some companies still develop these type of sites from scratch, but as customers become more educated and competitors outsell the custom shops with prepackaged CMS systems, the custom-designed CMS site is a dying breed.  The third type of web app either has complex business rules or it stands on the bleeding edge of technology.  These type of apps will need developers, but not necessarily the “jack of all trades” developer.

On the one hand, it is comforting to know that, at least for the time being, there is a need for skilled developers.  The web development guild system hasn’t yet been eliminated by unskilled labor.  However, it is a bit disturbing to see companies move toward hiring specialized developers who are “intimately familiar” with specific languages or platforms, rather than
developers who have a holistic understanding of web applications.  In addition, many companies are hiring programmers with little skills to churn out sloppily-coded applications.  What is a “craftsman developer” to do? 


Continuations in Ruby

December 12, 2007

A week ago, Dr. Frens spoke about continuations in Ruby at the Michigan Ruby Users Group. It was very interesting as it brought back my college days when I learned Scheme and functional programming concepts. I always enjoyed functional programming because it presents such a different way of thinking through problems.

I was going to blog about his presentation, but it turns out he blogged all his own notes already. But what I found interesting is the sort of hybrid nature that Ruby has. It is both an object-oriented language and it also supports some functional programming concepts. The drawback Dr. Frens found was that Ruby doesn’t do tail recursion optimization, so it’s not really worth using continuation passing style functions. Interesting, nonetheless!


Video on the Web

December 2, 2007

It’s really great that video is becoming more prevalent on the web. We can now ditch our TVs and watch video online. We can watch presentations given at conferences that we missed or couldn’t attend.

However, it’s really annoying when all I want is some quick information, but I have to sit or scrub through 5 minutes of irrelevant babble to get to the gold. For instance, when Android came out, Google posted some nice, long videos about their technology. If you wanted to know any detailed information about it, you had to sit through the boring video.

Technocracy Radio discussed fora.tv in their last podcast. Basically, it’s sort of the C-SPAN of the internet, but not just restricted to politics. While having all of this video is great, I think having a textual transcription of the speech is much more valuable. You can easily search text and do all kinds of data mining with it. I think the next breakthrough in media is going to be when speech to text recognition is perfected, fast, and cheap. This way, we can search for any time the President says, “nukular.” We can also have TVs that recognize a viewer’s laughter and flag the funniest quotes in a Simpsons episode. Awesome!


Eager Loading

December 1, 2007

One thing that made me uneasy about Rails’ ActiveRecord was how it handles associations. For instance, say I have a table of products in the database and another table listing comments about the products. So, for each product we have many comments.

Back in the good ol’ ColdFusion days, I would write a query that joins the two tables. Then I would loop through each field and have some funky conditional statements, like the following:

<cfset prevProductId = 0 />
<cfloop query=”qryProductsWithComments”>
 <cfif product_id neq prevProductId>
  …if this is not the first product, finish printing the previous product’s template…
  …we’ve hit either the first product or a new product, so print out the beginning of the product template and the first comment…
 <cfelse>
  …this is another comment, so print out just another comment…
 </cfif>
 <cfset prevProductId = product_id />
</cfloop>

That’s pretty darn confusing, but it was better, performance-wise, than executing a new query every time you iterate over the products loop, like so:

<cfloop query=”qryProducts”>
 …spit out the product template…
 <cfquery name=”qryComments” …>
  SELECT * FROM comments WHERE product_id = #qryProducts.product_id#
 </cfquery>
 <cfloop query=”qryComments”>
  …spit out a comment…
 </cfloop>
</cfloop>

By default, ActiveRecord will perform similarly to the latter example. However, with eager loading, you can get the same performance as the former example without all of the confusing if statements:


# in our model:
class Product < ActiveRecord::Base
 has_many :comments
end


# in our controller:
class ProductsController < ApplicationController
 def index
  @products = Product.find(:all, :include => :comments)
 end
end


# in our view:
<% for product in @products -%>
 <%= render :partial => “products/product” %>
 <% for comment in @products.comments -%>
  <%= render :partial => “comments/comment” %>
 <% end -%>
<% end -%>

So much cleaner! And easier!

With ASP.NET 2.0, you’re pretty much stuck doing the equivalent of the second CF example using the server controls or you have to build your own object data source that will work similarly to ActiveRecord, but you’ve just spent an hour or so reinventing the wheel.


Some Very Strange Markup

November 7, 2007

I was viewing the source of the Facebook iPhone webapp to see how they did their fancy transitions between pages, when I found some very strange HTML:

<body home=”home.php”>
<div class=”toolbar1 tops chrome”>
<u href=”home.php”><img src=”images/facebook.png”/></u>
<u class=”button plain leftButton” href=”#status”>Status</u>
<u class=”button plain” href=”#search” radio=”true”>Search</u>
</div>

How can a <body> tag have a “home” attribute or a <u> tag have an “href” attribute? I scoured the W3C spec and looked for a possible mobile HTML standard supporting it, but couldn’t find anything.Well, it turns out they’re doing some non-standard trickery by adding custom attributes to their elements. They’re then using JavaScript to get the values of those attributes and use them in their “onclick” handlers for each element. Sneaky!


Fun With Microformats

October 24, 2007

I just updated my food blog by encoding all of the restaurants’ contact information in microformats. It’s basically a way to encode vCard/vCal data using HTML. It’s part of the latest movement to bring semantics (meaningful data that can be interpreted by computer programs) to web content. For instance, with this technology you could easily write a program to find all the phone numbers and addresses listed on the internet and generate a worldwide phone book. Or you could track who has lived in a given house over the past X years. Or you could generate statistics on how many CEOs live next to golf courses. Or you could figure out, according to published calendars, when most people will be away from home and thus not watching the latest sitcom. And that’s just the beginning.

One thing that’s cool about the hCard specification is its flexibility. According to the spec, they recommend the following format:

<div class="vcard">
  <span class="fn n">
     <a class="url" href="http://t37.net">
       <span class="given-name">Fréderic</span>
       <span class="family-name">de Villamil</span>
     </a>
  </span>
  <span class="nickname">neuro</span>
  <a class="email" href="mailto:neuroNOSPAM@t37.net">
     <span class="type">pref</span><span>erred email</span>
  </a>
  <span class="org">Omatis</span>
  <span class="adr">
     <abbr class="type" title="dom">France</abbr>
     <span class="type">home</span> address
     <abbr class="type" title="postal">mail</abbr> and
     <abbr class="type" title="parcel">shipments</abbr>:
     <span class="street-address">12 rue Danton</span>
     <span class="locality">Le Kremlin-Bicetre</span>
     <span class="postal-code">94270</span>
     <span class="country-name">France</span>
  </span>
</div>

But I was able to easily use different elements in place of <div> and <span>:

<p class="vcard">
  <span class="fn n">
     <a class="url" href="http://t37.net">
       <span class="given-name">Fréderic</span>
       <span class="family-name">de Villamil</span>
     </a>
  </span>
  <span class="nickname">neuro</span>
  <a class="email" href="mailto:neuroNOSPAM@t37.net">
     <span class="type">pref</span><span>erred email</span>
  </a>
  <span class="org">Omatis</span>
  <a class="adr" href="http://somegooglemapslink">
     <abbr class="type" title="dom">France</abbr>
     <span class="type">home</span> address
     <abbr class="type" title="postal">mail</abbr> and
     <abbr class="type" title="parcel">shipments</abbr>:
     <span class="street-address">12 rue Danton</span>
     <span class="locality">Le Kremlin-Bicetre</span>
     <span class="postal-code">94270</span>
     <span class="country-name">France</span>
  </a>
</p>

This was useful because wordpress does not allow <div> in your blog posts. It automatically converts them to <p> :p