<?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>trisweb.com &#187; Programming</title>
	<atom:link href="http://www.trisweb.com/archives/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.trisweb.com</link>
	<description>programming, web, music and life</description>
	<lastBuildDate>Fri, 16 Apr 2010 19:55:57 +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>Static vs. Dynamic Typing</title>
		<link>http://www.trisweb.com/archives/2008/01/25/static-vs-dynamic-typing/</link>
		<comments>http://www.trisweb.com/archives/2008/01/25/static-vs-dynamic-typing/#comments</comments>
		<pubDate>Fri, 25 Jan 2008 21:36:10 +0000</pubDate>
		<dc:creator>Tristan</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://www.trisweb.com/archives/2008/01/25/static-vs-dynamic-typing/</guid>
		<description><![CDATA[Every good programmer probably has to write about their opinion on this subject once in their lifetime, so here&#8217;s my take
As part of my consulting gig I work on &#8220;Enterprise Java&#8221; code. I just had to write this line after receiving two separate exceptions on the matter (types obfuscated to protect the guilty (and they [...]]]></description>
			<content:encoded><![CDATA[<p>Every good programmer probably has to write about their opinion on this subject once in their lifetime, so here&#8217;s my take</p>
<p>As part of my consulting gig I work on &#8220;Enterprise Java&#8221; code. I just had to write this line after receiving two separate exceptions on the matter (types obfuscated to protect the guilty (and they are oh so guilty&#8230; I won&#8217;t get into that)):</p>
<p><code>String somenumber = (String) ((TypeAttribute) TypeCache.getTypeFromCache("Thingie") .getAttribute("someNumber")).getValue((Thingie) object);</code></p>
<p><strong>You&#8217;re a freaking computer! Figure it out for me!</strong></p>
<p>Also, xkcd, as always, <a href="http://xkcd.com/353/" title="import antigravity;">says it the best</a>.</p>
<p>It&#8217;s revealing to be a Java programmer every 2 weeks, and a Ruby and Flex developer the next 2 weeks, with PHP and JavaScript by night. I understand <em>everything</em> about why static typing is good and proper, but today, when computers (and compilers especially) are powerful and intelligent, I think the computer should do what a computer is great for, namely figuring out extremely complex yet orderly relationships between types of things, leaving the programmer to focus on much more important stuff.</p>
<p>When I&#8217;m coding in Java, it takes me 50 lines of rudimentary logic and typecasting muck in a new inline comparator class to do something as simple as sorting custom objects.</p>
<p>In Ruby it&#8217;s a one-liner. I don&#8217;t care how much less efficient that is for the computer (and it&#8217;s not), that is worth its weight in gold in programmer time and code elegance.</p>
<p>I enjoy dynamically typed languages, and any good programmer knows that it&#8217;s <em>programmers having fun</em> that makes good software, not programmers spending 50% of their time dealing with code that gets in their way. What kills me most is that computers are really good at automatically doing the stuff that&#8217;s not fun&#8211;that is in fact what they&#8217;re designed to do&#8211;and there are people who have fun making that stuff fast, so why don&#8217;t we just let them?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.trisweb.com/archives/2008/01/25/static-vs-dynamic-typing/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Javascript selectedIndex NS_ERROR_FAILURE in Firefox</title>
		<link>http://www.trisweb.com/archives/2007/04/24/javascript-selectedindex-ns_error_failure/</link>
		<comments>http://www.trisweb.com/archives/2007/04/24/javascript-selectedindex-ns_error_failure/#comments</comments>
		<pubDate>Tue, 24 Apr 2007 20:59:42 +0000</pubDate>
		<dc:creator>Tristan</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.trisweb.com/archives/2007/04/24/javascript-selectedindex-ns_error_failure/</guid>
		<description><![CDATA[I was amazed that the top hit in Google for this was the Mozilla source code (which was helpful, but not very user-friendly) so I&#8217;m writing up a bit on this confusing error message.
This is a Mozilla (Firefox, Seamonkey, Ephiphany, etc.) exception that gets thrown when you try to set the selectedIndex of a select [...]]]></description>
			<content:encoded><![CDATA[<p>I was amazed that the top hit in Google for this was <a href="http://www.koders.com/cpp/fid2C01DCE4790541430FCCF06615AE6F76111563AE.aspx">the Mozilla source code</a> (which was helpful, but not very user-friendly) so I&#8217;m writing up a bit on this confusing error message.</p>
<p>This is a Mozilla (Firefox, Seamonkey, Ephiphany, etc.) exception that gets thrown when you try to set the selectedIndex of a select element out of bounds of its options. The error message (from <a href="http://www.getfirebug.com/" title="Firebug is amazing for Javascript debugging, just get it.">Firebug</a>) looks like:</p>
<blockquote><p><code style="color: #cc0000;">uncaught exception: [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIDOMHTMLSelectElement.selectedIndex]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: http://www.example.com/test.html :: testSelect :: line 8" data: no]</code></p></blockquote>
<p>This is not your standard JavaScript error. It&#8217;s not informative, useful, user-friendly, and barely gives you a line number to work with.<span id="more-857"></span></p>
<p>What it means, however, is very simple. The <code>nsIDOMHTMLSelectElement</code> component is an HTML Select Box, like so:</p>
<select name="select1" id="testselect1">
  <option value="1">Option 1</option><br />
  <option value="2">Option 2</option><br />
</select>
<p>Now, let&#8217;s say you had a script triggered by a button that did something silly like set the <code>selectedIndex</code> of that select box to be an index that doesn&#8217;t exist, like 3:</p>
<blockquote><p><code>function testSelect() {<br />
  // A bad selectedIndex:<br />
  document.testform.select1.selectedIndex = 3;<br />
}</code></p></blockquote>
<p>You&#8217;d think this would throw a nice Javascript error message, like &#8220;Javascript error: Index out of bounds.&#8221; But it doesn&#8217;t. It barfs out the garbage NS_ERROR_FAILURE exception from the <em>browser widget itself</em> because that index gets passed right on through.</p>
<p>Turn on Firebug and<br />
<input type="button" value="click here to try it" onclick="document.getElementById('testselect1').selectedIndex = 3;" /> (sets the selectedIndex of the above to 3).</p>
<p><strong>The conclusion:</strong> an out-of-bounds selectedIndex results in an NS_ERROR_FAILURE exception.</p>
<p><strong>The solution:</strong> check that your selectedIndex is within the bounds of the option array! Never set it blindly without checking first.</p>
<p>Hopefully this saves someone the time looking through the Mozilla source for instances of the exception in the select widget C++ code&#8230; though that was kinda fun. If you see an NS_ERROR_FAILURE from a different widget or component, I can recommend searching the Mozilla code for the component it tells you about, it&#8217;s not too difficult. But for something as stupid as an index out of bounds, I hope this helps.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.trisweb.com/archives/2007/04/24/javascript-selectedindex-ns_error_failure/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>My Aversion to Java Explained</title>
		<link>http://www.trisweb.com/archives/2007/03/27/i-love-hate-java/</link>
		<comments>http://www.trisweb.com/archives/2007/03/27/i-love-hate-java/#comments</comments>
		<pubDate>Wed, 28 Mar 2007 03:38:29 +0000</pubDate>
		<dc:creator>Tristan</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://www.trisweb.com/archives/2007/03/27/i-love-hate-java/</guid>
		<description><![CDATA[I work on Java software for my day job, and now for my night job as well (don&#8217;t worry, that&#8217;s not Zenphoto). I learned Java in college, I&#8217;ve used it for years, I know it well, but I&#8217;ve never really liked it as a general rule; as in, I&#8217;ve never ever thought &#8220;Wow, Java would [...]]]></description>
			<content:encoded><![CDATA[<p>I work on Java software for my day job, and now for my night job as well (don&#8217;t worry, that&#8217;s not Zenphoto). I learned Java in college, I&#8217;ve used it for years, I know it well, but I&#8217;ve never really liked it as a general rule; as in, I&#8217;ve never <em>ever</em> thought &#8220;Wow, Java would be really <em>great</em> for this project!&#8221; with any enthusiasm. Java has been the choice because of other reasons in every case &#8212; on one project, my team chose it because it was the one common language we all knew, so there was no learning curve. At work, I&#8217;m stuck with it because that&#8217;s what the &#8220;enterprise&#8221; software I customize is written in. Now in a new project I&#8217;m getting into, we&#8217;ve decided on it for scalability and a new web application framework called JSF, and it&#8217;s actually looking pretty good so far. But as I sit here learning JSF and the component framework I&#8217;m going to be working in, I came to a clear realization:</p>
<p><strong><em>Nothing</em> in Java is simple.</strong></p>
<p>That&#8217;s the bad taste in my mouth. That&#8217;s the main thing that makes me dread opening NetBeans or Eclipse. The reason is stupid: I am a designer at heart, not a programmer. Programming is more visual for me; I try to see organization and elegance in the end user interface as well as in the code behind it, and Java pretty much obscures that notion of beautiful code entirely. It&#8217;s just not simple enough to be called that.</p>
<p>So what programming languages do I like? Well I&#8217;m a PHP programmer by preference, because very little gets in the way between me and the HTML. It&#8217;s inherently simple, because it gives you pretty much nothing to start with. Next on the list is JavaScript, which I like a lot, for many reasons. And after that, ironically, I guess it&#8217;s Java.</p>
<p>So I have a love-hate relationship with Java. On the one hand, it helps you do stuff you couldn&#8217;t ever do in a simpler language, it&#8217;s automatically cross-platform, it&#8217;s generally fast these days, and it&#8217;s easy to work with in the right IDE. On the other hand, it&#8217;s complex. So what? I can live with complex. It just annoys the heck out of me sometimes that I have to jump through so many hoops just to build an interface component. Sigh&#8230; in the long run, though, it&#8217;ll work better for it.</p>
<p>But one thing you can be darned sure of: Zenphoto will never be a Java application.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.trisweb.com/archives/2007/03/27/i-love-hate-java/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Zenphoto dynamic theme concept</title>
		<link>http://www.trisweb.com/archives/2007/03/16/zenphoto-dynamic-theme-concept/</link>
		<comments>http://www.trisweb.com/archives/2007/03/16/zenphoto-dynamic-theme-concept/#comments</comments>
		<pubDate>Fri, 16 Mar 2007 23:12:19 +0000</pubDate>
		<dc:creator>Tristan</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[zenphoto]]></category>

		<guid isPermaLink="false">http://www.trisweb.com/archives/2007/03/16/zenphoto-dynamic-theme-concept/</guid>
		<description><![CDATA[I started working on a Zenphoto theme to sort of mimic the performance of Google&#8217;s Picasa Web Albums service (which is very nice, and was recently upgraded to 1 GB of free storage, see my public albums there for a good example). 
Picasa-Web made huge strides in the usability of online photo viewing, in my [...]]]></description>
			<content:encoded><![CDATA[<p>I started working on a Zenphoto theme to sort of mimic the performance of <a href="http://picasaweb.google.com">Google&#8217;s Picasa Web Albums</a> service (which is very nice, and was recently upgraded to 1 GB of free storage, <a href="http://picasaweb.google.com/trisweb">see my public albums there</a> for a good example). </p>
<p>Picasa-Web made huge strides in the usability of online photo viewing, in my opinion. The main advantage was the quick loading of previous and next images when browsing an album in the one-image view (where most browsing takes place, or at least, where the user cares most about speed). It was all done in JavaScript and AJAX, of course, and images were even loaded in low-res (pixelated) first so you at least saw <em>something</em> if you were too fast for your connection. </p>
<p>The other real speed improvement came unexpected&#8211;simply using the &#8216;onMouseDown&#8217; event instead of &#8216;onClick&#8217; to trigger the image switch. It&#8217;s <em>incredible</em> how much faster the first feels. It&#8217;s like the transition happens before you even thought about it, as if it&#8217;s somehow reading your mind. I guess that just shows how ingrained it is that actions happen when we lift the mouse button. That probably makes sense for most actions, but for browsing a photo gallery I can see why instant action is preferred&#8211; it feels fast, very fast.</p>
<p><strong>So without further ado, I give you <a href="/tests/zenphoto-svn/Random/Desktops/ActionCat-1051338286.jpg.html" title="It's even in a sub-album...">an image page with dynamic image loading and navigation</a></strong>. Please, browse, take a look, and tell me what you think.</p>
<p>Things that still aren&#8217;t complete include:</p>
<ul>
<li>Comments, loading and submitting for each image.</li>
<li>Navigating to a specific image (currently always goes to the first)</li>
<li>Browser history/back/forward preservation</li>
<li>Full-sized or larger-sized image view, with Light/thick/slimbox etc. perhaps</li>
<li>Better theme design &#8212; should be a good one.</li>
</ul>
<p>so don&#8217;t complain about them just yet. </p>
<p>It&#8217;s a proof-of-concept, to prove that it&#8217;s possible (and quite easy) to make dynamic and fun themes with Zenphoto. All the framework for processing images, iterating over objects, and page handling is done by Zenphoto, leaving the theme developer to focus on the javascript design, which is the fun part of course <img src='http://www.trisweb.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  Zenphoto also makes it easy to &#8220;fall back&#8221; to non-javascript behavior very easily (though this theme doesn&#8217;t show that).</p>
<p>I&#8217;ll work to complete this theme in the coming months, hopefully releasing it sometime soon in a more complete version. The code for the dynamic image navigation may also become a part of the Zenphoto core, at option to be turned on or off by the user. Themes wouldn&#8217;t even need to be changed to take advantage of it. Please, leave a comment, tell me what you think! Thanks.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.trisweb.com/archives/2007/03/16/zenphoto-dynamic-theme-concept/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>JavaScript2</title>
		<link>http://www.trisweb.com/archives/2007/03/01/javascript2/</link>
		<comments>http://www.trisweb.com/archives/2007/03/01/javascript2/#comments</comments>
		<pubDate>Thu, 01 Mar 2007 08:26:40 +0000</pubDate>
		<dc:creator>Tristan</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[zenphoto]]></category>

		<guid isPermaLink="false">http://www.trisweb.com/archives/2007/03/01/javascript2/</guid>
		<description><![CDATA[I ran across this gigantic post on what Steve Yegge calls the &#8220;Next Big Language&#8221; and I&#8217;m saving it here partly for my own reference, partly to comment on what it is exactly.
He tries to keep it a secret, but it&#8217;s obviously JavaScript 2, or ECMAScript 4, whatever you want to call it. &#8220;JS2&#8243; will [...]]]></description>
			<content:encoded><![CDATA[<p>I ran across this gigantic post on <a href="http://steve-yegge.blogspot.com/2007/02/next-big-language.html">what Steve Yegge calls the &#8220;Next Big Language&#8221;</a> and I&#8217;m saving it here partly for my own reference, partly to comment on what it is exactly.</p>
<p>He tries to keep it a secret, but it&#8217;s obviously JavaScript 2, or ECMAScript 4, whatever you want to call it. &#8220;JS2&#8243; will stick better. I&#8217;ve <em>always</em> thought JavaScript was quite an elegant language, if only because functions are first-class. Add optional static typing, and all the other features he lists, and it looks like it won&#8217;t suck. I can only hope it keeps some of the simplicity and flexibility of JavaScript in its current state&#8230;</p>
<p>If you&#8217;re interested, click through this <a href="http://developer.mozilla.org/presentations/xtech2006/javascript/">slideshow on JavaScript 2 and the Future of the Web</a>, or look at <a href="http://www.mozilla.org/projects/tamarin/">Mozilla&#8217;s Tamarin Project</a>. It really looks like a complete and useful language, and it makes sense that if the <em>web</em> is the &#8220;next big thing&#8221; then the next big language will be the <em>one and only language that runs on it</em>. </p>
<p>Until it gets there, I&#8217;ll keep up with my JS1 skillz and get some Ajax going in the zenphoto backend&#8230;</p>
<p><strong>1.0.8</strong> in a few minutes. <img src='http://www.trisweb.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.trisweb.com/archives/2007/03/01/javascript2/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
