<?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>TooMeta.com &#187; Programming</title>
	<atom:link href="http://toometa.com/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://toometa.com</link>
	<description>Nobody wears digital watches</description>
	<lastBuildDate>Wed, 11 Nov 2009 17:52:15 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Ruby Sucks</title>
		<link>http://toometa.com/2009/03/19/ruby-sucks/</link>
		<comments>http://toometa.com/2009/03/19/ruby-sucks/#comments</comments>
		<pubDate>Thu, 19 Mar 2009 22:34:58 +0000</pubDate>
		<dc:creator>tbelote</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://toometa.com/?p=46</guid>
		<description><![CDATA[Ruby cares nothing about backwards compatibility.
This code on lenny:
irb(main):012:0> tmpFile = Tempfile.new('_archive_')
=> #
irb(main):013:0> tmpFile.close(true)
=> nil
irb(main):014:0> tmpFile.path
=> nil

Used to do this on sarge:
irb(main):012:0> tmpFile = Tempfile.new('_archive_')
=> #
irb(main):013:0> tmpFile.close(true)
=> nil
irb(main):014:0> tmpFile.path
=> "/tmp/_archive_20090319-12089-1dphb46-0"

And sadly there are many other such examples.
]]></description>
			<content:encoded><![CDATA[<p>Ruby cares nothing about backwards compatibility.<br />
This code on lenny:<br />
<code>irb(main):012:0> tmpFile = Tempfile.new('_archive_')<br />
=> #<file :/tmp/_archive_20090319-12089-1dphb46-0><br />
irb(main):013:0> tmpFile.close(true)<br />
=> nil<br />
irb(main):014:0> tmpFile.path<br />
=> nil<br />
</file></code><br />
Used to do this on sarge:<br />
<code>irb(main):012:0> tmpFile = Tempfile.new('_archive_')<br />
=> #<file :/tmp/_archive_20090319-12089-1dphb46-0><br />
irb(main):013:0> tmpFile.close(true)<br />
=> nil<br />
irb(main):014:0> tmpFile.path<br />
=> "/tmp/_archive_20090319-12089-1dphb46-0"</p>
<p></file></code><br />
And sadly there are many other such examples.</p>
]]></content:encoded>
			<wfw:commentRss>http://toometa.com/2009/03/19/ruby-sucks/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Java File Descriptor Leak</title>
		<link>http://toometa.com/2007/05/31/java-file-descriptor-leak/</link>
		<comments>http://toometa.com/2007/05/31/java-file-descriptor-leak/#comments</comments>
		<pubDate>Fri, 01 Jun 2007 05:12:45 +0000</pubDate>
		<dc:creator>tbelote</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://toometa.com/2007/05/31/java-file-descriptor-leak/</guid>
		<description><![CDATA[I&#8217;ve encountered issues similar this bug:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6246565
and have found some other bug entries in the past that seem to cover the same problem.
If I&#8217;m running a lot of Runtime.getRuntime().exec() or Axis SOAP calls java open several pipes associated with each exec or SOAP call, that especially under a heavily loaded system, can take a very long [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve encountered issues similar this bug:<br />
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6246565<br />
and have found some other bug entries in the past that seem to cover the same problem.</p>
<p>If I&#8217;m running a lot of Runtime.getRuntime().exec() or Axis SOAP calls java open several pipes associated with each exec or SOAP call, that especially under a heavily loaded system, can take a very long time to be garbage collected. This has lead to a case where this code hits the default 1024 open file limit in a case where only maybe 20 or 30 files should be open at a time. The solution thus far has been be more careful about opening sockets and pipes in Java, but  I have yet to find a better solution. I&#8217;m still running Java 5 JDK 1.5 and many of the bug entries seem to recommend upgrading to Java 6.</p>
]]></content:encoded>
			<wfw:commentRss>http://toometa.com/2007/05/31/java-file-descriptor-leak/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pessimistic Programming</title>
		<link>http://toometa.com/2006/06/04/pessimistic-programming/</link>
		<comments>http://toometa.com/2006/06/04/pessimistic-programming/#comments</comments>
		<pubDate>Mon, 05 Jun 2006 06:21:41 +0000</pubDate>
		<dc:creator>tbelote</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tom]]></category>

		<guid isPermaLink="false">http://toometa.com/2006/06/04/pessimistic-programming/</guid>
		<description><![CDATA[I am now totally sold that the only way input validation will ever be secure is by explicitly listing safe characters and not be listing unsafe characters. I was on the fence on this issue. I thought that as long as you used well published open source functions to check for unsafe characters you were [...]]]></description>
			<content:encoded><![CDATA[<p>I am now totally sold that the only way input validation will ever be secure is by explicitly listing safe characters and not be listing unsafe characters. I was on the fence on this issue. I thought that as long as you used well published open source functions to check for unsafe characters you were pretty secure, but then I saw <a target="_blank" href="http://bugs.mysql.com/bug.php?id=8378">this bug for mysql_real_escape_string()</a>. This took a year to be fixed as well.</p>
<p>Worst of all is that I&#8217;ve tested applications with MySQL backends with many security tools that look for SQL injection, including security tools that costs thousands of dollars per run, and none of these tools found this bug. I read in many places that unicode has been a big recurring headache for software security. So, I would that would be the second place to look after the obvious SQL injection attacks.<br />
This is why I now think everyone should program explicitly listing the safe characters and input lengths,  even if this hurts the future flexibiity of the program. The solution is obvious for things like names, zip codes, etc. I know the solution is clearly not obvious for multilingual sites. And binary files are still tricky to validate. The best I can think of for this is to use <a target="_blank" href="http://en.wikipedia.org/wiki/Base64">Base64</a> encoding.</p>
]]></content:encoded>
			<wfw:commentRss>http://toometa.com/2006/06/04/pessimistic-programming/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zero day exploits</title>
		<link>http://toometa.com/2006/05/27/zero-day-exploits/</link>
		<comments>http://toometa.com/2006/05/27/zero-day-exploits/#comments</comments>
		<pubDate>Sun, 28 May 2006 06:41:50 +0000</pubDate>
		<dc:creator>tbelote</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tom]]></category>

		<guid isPermaLink="false">http://toometa.com/2006/05/27/zero-day-exploits/</guid>
		<description><![CDATA[Whoever you are, I have always depended on the kindness of strangers.  &#8212; Blanche DuBois, A Streetcar Named Desire
As far as I can see there is no solution to the zero day exploit problem. Someone can always see what software you are running and wait until the moment a vulnerability is discovered and immediately attack [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>Whoever you are, I have always depended on the kindness of strangers.  &#8212; Blanche DuBois, <em>A Streetcar Named Desire</em></p></blockquote>
<p>As far as I can see there is no solution to the zero day exploit problem. Someone can always see what software you are running and wait until the moment a vulnerability is discovered and immediately attack you before you can patch. It is true however that most people will not be targeted in this way since there are many more benevolent people than malicious people (see above quote). In general websites are not targeted until vulnerable sites can be found with a web search engine, making it easy for a few people to find a large number of vulnerable sites.</p>
<p>Don&#8217;t know where I&#8217;m going with this post. Just that we are doomed to not be able to instantly patch.</p>
]]></content:encoded>
			<wfw:commentRss>http://toometa.com/2006/05/27/zero-day-exploits/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Microsoft Announces Meta OS</title>
		<link>http://toometa.com/2005/11/03/microsoft-announces-meta-os/</link>
		<comments>http://toometa.com/2005/11/03/microsoft-announces-meta-os/#comments</comments>
		<pubDate>Thu, 03 Nov 2005 19:01:35 +0000</pubDate>
		<dc:creator>tbelote</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tom]]></category>

		<guid isPermaLink="false">http://toometa.com/?p=19</guid>
		<description><![CDATA[So this post was inspired by a slashdot article. Though I wasn&#8217;t able to view Microsoft&#8217;s site on Singularity because it was already slashdotted.  
Any way so that idea appears to be making an OS where the only code you can run is managed code which is Microsoft speak for interpreted code as opposed [...]]]></description>
			<content:encoded><![CDATA[<p>So this post was inspired by a <a href="http://slashdot.org/articles/05/11/03/1744230.shtml?tid=190&#038;tid=109">slashdot article</a>. Though I wasn&#8217;t able to view <a href="http://research.microsoft.com/os/singularity/">Microsoft&#8217;s site on Singularity</a> because it was already <a href="http://en.wikipedia.org/wiki/Slashdotted">slashdotted</a>.  </p>
<p>Any way so that idea appears to be making an OS where the only code you can run is <a href="http://blogs.msdn.com/brada/archive/2004/01/09/48925.aspx">managed code</a> which is Microsoft speak for interpreted code as opposed to native byte code. The only thing I think this gives you is buffer overflow prevention. The garbage collection is a bit of a an unachievable goal because you can still write in memory leaks in code with garbage collectors just by writing bade code that keeps a pointer to the object longer than you need to. And you can still write a program that asks to allocate all memory like <code>while(true) { $a[$i++] =  "some string"; }</code> </p>
<p>And I&#8217;m sure there are still interpreted viruses&#8230; I think they are called Visual Basic macros, or Office Add-ins. </p>
<p>Overall though I like interpreted languages more than native binary compiled languages, despite the <a href="http://shootout.alioth.debian.org/benchmark.php?test=all&#038;lang=all&#038;sort=fullcpu">occasional speed/memory issue</a>. So I&#8217;m all for it.</p>
]]></content:encoded>
			<wfw:commentRss>http://toometa.com/2005/11/03/microsoft-announces-meta-os/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Falling Behind</title>
		<link>http://toometa.com/2005/11/01/falling-behind/</link>
		<comments>http://toometa.com/2005/11/01/falling-behind/#comments</comments>
		<pubDate>Wed, 02 Nov 2005 04:46:10 +0000</pubDate>
		<dc:creator>tbelote</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tom]]></category>

		<guid isPermaLink="false">http://toometa.com/?p=17</guid>
		<description><![CDATA[Damn, Ravi outnumbers me in posts 2 to 1&#8230; and I&#8217;m only level 36 in WoW.  I&#8217;m not sure exactly what we might be competing for, but I think Ravi is winning.
I&#8217;ve become sold on the whole Pragmatic Programmer  site, philosophy, whatever.  Automated build and testings systems, for which the proper term [...]]]></description>
			<content:encoded><![CDATA[<p>Damn, Ravi outnumbers me in posts 2 to 1&#8230; and I&#8217;m only level 36 in WoW.  I&#8217;m not sure exactly what we might be competing for, but I think Ravi is winning.</p>
<p>I&#8217;ve become sold on the whole <a href="http://pragmaticprogrammer.com/">Pragmatic Programmer</a>  site, philosophy, whatever.  Automated build and testings systems, for which the proper term is Continuous Integration, seem especially cool. Check out the <a href="http://damagecontrol.codehaus.org/Continuous+Integration+Server+Feature+Matrix">DamageControl CI comparison site</a>. I wanted to try out Tinderbox 2.0 which is what Mozilla is using (not Tinderbox 3.0), but I can&#8217;t find anywhere to download it. I only see how to view the interface to it on mozilla&#8217;s site. Right now I&#8217;m liking DamageControl and BuildBot. I don&#8217;t really want to run a Java system&#8230; since I don&#8217;t use Java much except when I have to for school, and I also don&#8217;t have a windows server to run cruise control.net.</p>
<p>In outher programming news in my life, <a href="http://wix.sourceforge.net/">WiX</a>  caused me a bit of pain because I thought it was more mature that it appears to be.  <a href="http://www.jrsoftware.org/isinfo.php">Inno Setup</a> kicks ass though for a Windows Installer.</p>
<p>Hmm&#8230; well more later&#8230; just felt pressured to post <img src='http://toometa.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://toometa.com/2005/11/01/falling-behind/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Some more reasons that Perl sucks</title>
		<link>http://toometa.com/2005/09/26/and-the-high-horse-it-came-in-on/</link>
		<comments>http://toometa.com/2005/09/26/and-the-high-horse-it-came-in-on/#comments</comments>
		<pubDate>Mon, 26 Sep 2005 17:27:14 +0000</pubDate>
		<dc:creator>rkanodia</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ravi]]></category>

		<guid isPermaLink="false">http://toometa.com/?p=7</guid>
		<description><![CDATA[So Tom did quite a bang-up job of explaining why the switch statement is so retarded in Perl.  But there are other reasons that Perl sucks.
The scalar data type is an extremely leaky abstraction
As Joel Spolsky notes in the Law of Leaky Abstractions, you have to understand the theory that an abstraction is, well, [...]]]></description>
			<content:encoded><![CDATA[<p>So Tom did quite a bang-up job of explaining why the switch statement is so retarded in Perl.  But there are other reasons that Perl sucks.</p>
<p><strong>The scalar data type is an extremely leaky abstraction</strong><br />
As Joel Spolsky notes in the Law of Leaky Abstractions, you have to understand the theory that an abstraction is, well, abstracting, in order to use it properly because, for any abstraction, there are situations which cause the abstraction to &#8216;leak&#8217; and reveal the underlying complexity.  The better an abstraction is, the further it has to be pushed before it starts to leak.</p>
<p>Testing for equality should not be the kind of Xtr333m action that causes an abstraction to leak, but in Perl, that&#8217;s exactly what will happen.<br />
<code><br />
my $foo = function_to_get_input();<br />
if ($foo == 123) {<br />
 print "Wooha\n";<br />
}<br />
</code><br />
This seems like a pretty innocent snippet, right?  Too bad it will fuck up your day &#8211; unless you spend far too much work patching the holes in the abstraction.  If function_to_get_input() returned a number, everything&#8217;s fine.  But if  it returned a string, the comparison $foo == 123 will generate a warning, because <code>==</code> expects a number and $foo is a string.  So clearly the abstraction is leaky: Perl only provides the scalar data type, because the user &#8216;doesn&#8217;t need to know&#8217; whether the scalar is a number or a string.  Unfortunately, the user DOES need to know, because the interpreter is making the user responsible for matching the data types.</p>
<p>Warnings aside, strings in perl also evaluate to 0 in a numeric context &#8211; unless they happen to represent a number.  This means that <code>==</code> will tell you that 0, &#8220;0&#8243;, and &#8220;My lord, there is talk of cake&#8221; are all the same thing.  C has NaNs.  Perl is written in C.  Why does Perl think 0 is a more accurate description of &#8220;Mary Poppins is the antichrist, I have proof&#8221; than Not a Number?</p>
<p>The string comparison operator, <code>eq</code>, is a bit more generous in its argument coersion; it will automatically convert a number to its string representation.  Unfortunately you end up with the same &#8217;smushing&#8217; effect where 1 and &#8216;1&#8242; are the same thing.</p>
<p><a href="http://www.ruby-lang.org">Most</a> <a href="http://www.php.net">scripting</a> <a href="http://www.python.org">languages</a> will have functions like is_numeric() and is_string(), which return 1 if the object is of the listed type and 0 otherwise.  But Perl doesn&#8217;t have anything like that; in order to get the true representation of a scalar, you&#8217;ve got to install a module, written in C, which violates the encapsulation of the scalar to read an internal variable.</p>
<p>The long and short of it is that writing a block like</p>
<p><code>my $foo = function_to_get_input();<br />
if ($foo eq "Do it") {<br />
 print "Wooha\n";<br />
} elsif ($foo == 1) {<br />
 print "Blarg\n";<br />
} elsif ($foo eq "1") {<br />
 print "My eyes are bleeding help help I can't see\n";<br />
}</code></p>
<p>ends up being an entirely non-trivial affair.</p>
<p><strong>Input to regular expressions can fuck the interpreter</strong><br />
<code>$foo =~ s/meh/bah/;</code><br />
works just fine.  But suppose we want to replace the right-hand side with the variable <code>$gee</code>.  Let&#8217;s see what happens:<br />
<code>$foo =~ s/meh/$gee/;</code><br />
Harmless, right?  Sure it is &#8211; until $gee gets assigned the value &#8220;/&#8221; and, you guessed it, the interpreter throws an error and exits.  You can solve this with the \Q and \E (start quotation, end quotation) metacharacters, but this will cause a problem &#8211; backreferences won&#8217;t work.  That is to say, if $gee is assigned the value &#8220;\$1&#8243; (a literal backslash followed by the numeral one), then the code</p>
<p><code>$foo = "I know kung fu";<br />
$gee = "\$1";<br />
$foo =~ s/know (.*)/\Q$gee\E/;<br />
print "$foo\n";<br />
</code></p>
<p>will print the line &#8220;I $1&#8243; instead of &#8220;I kung fu.&#8221;</p>
<p>Using evaluation of the right hand as code (adding an <code>e</code> after the regex) can solve this problem, sort of:</p>
<p><code>$foo = "I know kung fu";<br />
$gee = "\$1";<br />
$foo =~ s/know (.*)/$gee/e;<br />
print "$foo\n";<br />
</code></p>
<p>That gets &#8220;I kung fu&#8221;.  But<br />
<code>$foo = "I know kung fu";<br />
$gee = "\$1";<br />
$foo =~ s/know (.*)/think $gee is awesome/e;<br />
print "$foo\n";<br />
</code></p>
<p>will explode, because the interpreter <i>can</i> evaluate &#8220;$1&#8243; as a command, but <i>can&#8217;t</i> evaluate &#8220;think $1 is awesome&#8221; as a command.  In order to do that, we&#8217;re going to need an extra level of indirection:</p>
<p><code>$foo = "I know kung fu";<br />
$gee = "\$1";<br />
$foo =~ s/know (.*)/"\"think $gee is awesome\""/ee;<br />
print "$foo\n";<br />
</code></p>
<p>Notice the two <code>e</code>&#8217;s at the end of that regex; they tell Perl to evaluate  the righthand side as code, then evaluate the output of that as code, then use that as the substitution pattern.</p>
<p>Perl sucks.  And don&#8217;t tell me any crap about Perl 6; the Promised Land has been on the horizon for several years now, and PHP and Python and Ruby and a million other languages are way ahead of where Perl was supposed to be.  I can&#8217;t believe I thought this language was awesome.  What a noob.</p>
<p>Author&#8217;s note: the original version of this document contained some boneheaded errors.  I fixed them.  Perl still sucks.</p>
]]></content:encoded>
			<wfw:commentRss>http://toometa.com/2005/09/26/and-the-high-horse-it-came-in-on/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Perl Switch considered painfully slow</title>
		<link>http://toometa.com/2005/09/25/perl-switch-considered-painfully-slow/</link>
		<comments>http://toometa.com/2005/09/25/perl-switch-considered-painfully-slow/#comments</comments>
		<pubDate>Mon, 26 Sep 2005 01:48:37 +0000</pubDate>
		<dc:creator>tbelote</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tom]]></category>

		<guid isPermaLink="false">http://toometa.com/?p=6</guid>
		<description><![CDATA[Perl Switch is damn slow!]]></description>
			<content:encoded><![CDATA[<p>The Switch perl modules is much slower than and if/elsif/else block. The below benchmark code puts it at about 40 times slower.</p>
<p>I used this program to generate some test data.<br />
<code>#!/usr/bin/perl</p>
<p>@options = ('a','b','c','d','e','f','g','h','i','j');</p>
<p>for($i=0; $i&lt;1000000; $i++) {<br />
    print $options[int(rand($#options))] . "\n";<br />
}<br />
</code></p>
<p>Then I timed these two:<br />
<code>#!/usr/bin/perl</p>
<p>my $a = 0;<br />
while($line = <>) {<br />
    chomp $line;<br />
    if($line eq 'a') { $a = $a+1; }<br />
    elsif($line eq 'b') { $a = $a+2}<br />
    elsif($line eq 'c') { $a = $a+3; }<br />
    elsif($line eq 'd') { $a = $a+4; }<br />
    elsif($line eq 'e') { $a = $a+5; }<br />
    elsif($line eq 'f') { $a = $a+6; }<br />
    elsif($line eq 'g') { $a = $a+7; }<br />
    elsif($line eq 'h') { $a = $a+8; }<br />
    elsif($line eq 'i') { $a = $a+9; }<br />
    elsif($line eq 'j') { $a = $a+10; }<br />
}</p>
<p>print $a . "\n";</p>
<p></code></p>
<p>And:<br />
<code>#!/usr/bin/perl</p>
<p>use Switch;</p>
<p>my $a = 0;<br />
while($line = <>) {<br />
    chomp $line;<br />
    switch($line) {<br />
        case 'a' { $a = $a+1; }<br />
        case 'b' { $a = $a+2}<br />
        case 'c' { $a = $a+3; }<br />
        case 'd' { $a = $a+4; }<br />
        case 'e' { $a = $a+5; }<br />
        case 'f' { $a = $a+6; }<br />
        case 'g' { $a = $a+7; }<br />
        case 'h' { $a = $a+8; }<br />
        case 'i' { $a = $a+9; }<br />
        case 'j' { $a = $a+10; }<br />
    }<br />
}</p>
<p>print $a . "\n";<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://toometa.com/2005/09/25/perl-switch-considered-painfully-slow/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
