<?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>Bin-Blog &#187; reference</title>
	<atom:link href="http://www.bin-co.com/blog/tag/reference/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bin-co.com/blog</link>
	<description>Learn about the latest in Web Development - as soon as I do.</description>
	<lastBuildDate>Tue, 13 Oct 2009 18:55:47 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Python Reference Manual has a lot to Learn From PHP</title>
		<link>http://www.bin-co.com/blog/2008/06/python-reference-manual-has-a-lot-to-learn-from-php/</link>
		<comments>http://www.bin-co.com/blog/2008/06/python-reference-manual-has-a-lot-to-learn-from-php/#comments</comments>
		<pubDate>Tue, 03 Jun 2008 18:34:49 +0000</pubDate>
		<dc:creator>Binny V A</dc:creator>
				<category><![CDATA[Opinion]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[documentation]]></category>
		<category><![CDATA[manual]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[reference]]></category>

		<guid isPermaLink="false">http://www.bin-co.com/blog/?p=110</guid>
		<description><![CDATA[
Unlike the other scripting languages I work with(like PHP, Ruby, JavaScript, etc.), I am not comfortable using Python. I have made some stuff in Python(for example, frees) &#8211; but I could get into the flow as easily as with other languages. For the longest time, I thought it was because of the whitespace issue. But [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.bin-co.com/blog/wp-content/uploads/2008/03/python-logo.gif" alt="" title="Python Logo" width="211" height="71" class="alignnone wp-image-97 intro" align="right"  /></p>
<p class="intro">Unlike the other scripting languages I work with(like PHP, Ruby, JavaScript, etc.), I am not comfortable using Python. I have made some stuff in Python(for example, <a href="http://lindesk.com/2008/04/frees-hard-disk-drives-free-space-viewer/">frees</a>) &#8211; but I could get into the flow as easily as with other languages. For the longest time, I thought it was because of the whitespace issue. But recently, I created a small Python script &#8211; that&#8217;s when I understood that whitespace does not concern me. <strong class="highlight">What make me angry at python is its documentation/manual</strong>.</p>
<p>By Python Manual, I mean the official Python Manual available at <a href="http://docs.python.org/">http://docs.python.org/</a>. I have <strong class="highlight">downloaded the entire <a href="http://www.python.org/doc/2.5.2/download/">manual to my system as HTML files</a> and use that as a reference</strong> when working with Python. This is what I have done for all the other languages I work with&#8230;</p>
<ul>
<li><a href="http://perldoc.perl.org/">Perl</a></li>
<li><a href="http://www.php.net/manual/en/">PHP</a></li>
<li><a href="http://www.ruby-doc.org/docs/ProgrammingRuby/">Ruby</a></li>
<li><a href="http://docs.sun.com/source/816-6408-10/">JavaScript</a> </li>
<li><a href="http://www.w3.org/TR/REC-CSS2/">CSS</a></li>
<li>etc.</li>
</ul>
<h2>Finding a Function</h2>
<p>There is one big problem with using HTML files as your reference &#8211; you cannot search through it. So I try to find a page in the documentation that <strong class="highlight">lists all the functions in a single page</strong>. When I need to find a function, all I have to do is <strong class="highlight">search through this page</strong>. These pages in the documentation serves this purpose&#8230;</p>
<ul>
<li><a href="http://www.php.net/manual/en/indexes.php">PHP</a></li>
<li><a href="http://perldoc.perl.org/index-functions.html">Perl</a></li>
<li><a href="http://docs.sun.com/source/816-6408-10/bklast.htm">JavaScript</a></li>
<li><a href="http://www.ruby-doc.org/docs/ProgrammingRuby/html/builtins.html">Ruby</a></li>
</ul>
<p>What about Python? Well, <strong class="highlight">Python don&#8217;t have such a page</strong> in their manual. The nearest one I could find a combination of four pages &#8211; <a href="http://docs.python.org/modindex.html">Module Index</a> + <a href="http://docs.python.org/lib/genindex.html">Library Index</a> + <a href="http://docs.python.org/tut/node19.html">Tutorial Index</a> + <a href="http://docs.python.org/ref/genindex.html">Language Index</a>. Its no where near as useful.</p>
<p>Even if you are online(remember, many people are not connected all the time), its still <strong class="highlight">not easy to find a function in Python documentation &#8211; even with searching</strong> capabilities. Don&#8217;t believe me? OK &#8211; go to <a href="http://docs.python.org/">Python Docs</a> and try to find the documentation for the function that, say, reverses an array. Now go to the <a href="http://php.net/manual/en/">PHP site</a> and do the same.</p>
<h2>Reference Formats</h2>
<p>Anyway, I cannot really complain about the the availability of the &#8216;function page&#8217;. Its just the way I prefer &#8211; other people may not want such a page. But I can complain about the fact that <strong class="highlight">they don&#8217;t provide a CHM file</strong> in their <a href="http://www.python.org/doc/2.5.2/download/">downloads section</a>. CHM solves the problem as you can search through them easily.</p>
<p>PHP, on other hand, <a href="http://www.php.net/download-docs.php">provides the CHM file</a>. This makes the PHP manual much more easier to use.</p>
<p>Even though Python don&#8217;t officially provide a CHM file, others have made it available on the net. Its just a <a href="http://www.google.com/q=python+reference+chm">google search away</a>. But I prefer to get these stuff from an official source.</p>
<h2>Level of Detail in the Documentation</h2>
<p>The worst sin of the Python manual is that the <strong class="highlight">documentation is not detailed enough</strong>. To better understand this, let&#8217;s take an example &#8211; say the array reversal function. First we take a look at the Python <a href="http://docs.python.org/lib/module-array.html#l2h-779">documentation for this function</a>&#8230;</p>
<dl>
<dt>reverse()</dt>
<dd>Reverse the order of the items in the array.</dd>
</dl>
<p>One line. That&#8217;s it! If you are not well versed in Python, you will have no idea of how to use this function &#8211; because there is no example. Most people will expect that the array must be given as the argument. But the argument list is empty in the documentation. That&#8217;s because the array is not passed as an argument &#8211; rather, in Python, this function is a member function of the array object &#8211; so the proper usage will be something like this&#8230;</p>
<pre><code class="python">x = [1,2,4]
x.reverse()
#Now x has the value [4,2,1]</code></pre>
<p>I know that because I know Python &#8211; but if a new user manages to find the documentation for this function, he will be confused. Another thing &#8211; I am not saying that there are no examples in the documentation &#8211; examples are given for a lot of functions. But its no where near the level that PHP has achieved.</p>
<p>OK &#8211; now lets see the PHP manual for the same function &#8211; <a href="http://php.net/manual/en/function.array-reverse.php">array_reverse()</a>. There is an entire page for that function. Not just for this function &#8211; there is <strong class="highlight">one page of documentation for every function</strong> in PHP. And <strong class="highlight">there are examples</strong>. And at the end, <strong class="highlight">there is a collection of &#8216;user notes&#8217;</strong> &#8211; making each function much clearer. Beautiful!</p>
<p>I feel a bit guilty about comparing Python with PHP documentation &#8211; <strong class="highlight">PHP has the best documentation in its class</strong> of languages. But still, Python has a lot to learn from PHP(I wanted to say that for a long time <img src='http://www.bin-co.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  ).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bin-co.com/blog/2008/06/python-reference-manual-has-a-lot-to-learn-from-php/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Perl Hello Script</title>
		<link>http://www.bin-co.com/blog/2008/04/perl-hello-script/</link>
		<comments>http://www.bin-co.com/blog/2008/04/perl-hello-script/#comments</comments>
		<pubDate>Thu, 10 Apr 2008 18:01:45 +0000</pubDate>
		<dc:creator>Binny V A</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[cheatsheet]]></category>
		<category><![CDATA[hello]]></category>
		<category><![CDATA[reference]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://www.bin-co.com/blog/2008/04/perl-hello-script/</guid>
		<description><![CDATA[
This is the next installment of the Hello Script series &#8211; Hello Script for Perl. &#8216;Hello Script&#8217; is a file that contains the most commonly used elements of a programming language so that it can be used as a cheat sheet when working with that language.
Introduction to Perl
For those of who are unfamiliar with perl, [...]]]></description>
			<content:encoded><![CDATA[<p><img src='http://www.bin-co.com/blog/wp-content/uploads/2008/04/perl.gif' alt='Perl Logo' class="intro" align="right" /></p>
<p class="intro">This is the next installment of the <a href="http://www.bin-co.com/blog/2008/03/learning-a-new-programming-language-the-hello-world-method/">Hello Script series</a> &#8211; Hello Script for Perl. <strong class="highlight">&#8216;Hello Script&#8217; is a file that contains the most commonly used elements of a programming language so that it can be used as a cheat sheet</strong> when working with that language.</p>
<h2>Introduction to Perl</h2>
<p>For those of who are unfamiliar with perl, here is the Wikipedia definition&#8230;</p>
<blockquote><p>Perl is a dynamic programming language created by Larry Wall and first released in 1987. Perl borrows features from a variety of other languages including C, shell scripting (sh), AWK, sed and Lisp. Perl was widely adopted for its strengths in text processing and lack of the arbitrary limitations of many scripting languages at the time.</p></blockquote>
<p>If you are interested in learning perl, I have written a <a href="http://www.bin-co.com/perl/tutorial/">Perl Tutorial</a>. And here are some more links if you are interested</p>
<ul>
<li><a href="http://www.perl.com/">Perl.com</a></li>
<li><a href="http://www.perl.org/">The Perl Directory</a></li>
<li><a href="http://www.perlmonks.org/">Perl Monks</a></li>
</ul>
<h2>Hello Script for Perl</h2>
<pre><code class="perl">
#!/usr/bin/perl
use strict;
use warnings;

# Printing(IO)
print "Hello World!\n";

# Variables, concatenation
my $name = 'Binny';
my $year = 2008;
print "Hello, " . $name . " - welcome to " . $year . "\n";

#If,else conditions
if ($year &gt; 2008) {
	print "Welcome to the future - yes, we have flying cars!";
}
elsif($year &lt; 2008) {
	print "The past - please don't change anything. Don't step on any butterflies. And for the sake of all that's good and holy, stay away from your parents!";
}
else {
	print "Anything wrong with your time machine? You have not gone anywhere, kiddo.";
}
print "\n";

# For loop
for(my $i=0; $i&lt;3; $i++) {
	print "$i) Hi there!\n";
}

#Numerical Array, foreach
my @rules = (
	'Do no harm',
	'Obey',
	'Continue Living'
);
my $i = 1;
foreach my $rule (@rules) {
	print "Rule " . $i . " : " . $rule . "\n";
	$i++;
}

# Associated array, while
my %associated = (
	'hello'	=&gt;	'world',
	'foo'	=&gt;	'bar',
	'lorem'	=&gt;	'ipsum'
);
while(my ($key, $value) = each(%associated)) {
	print "$key: $value\n";
}

# Using Join and Split
my @csv_values = split(',', "hello,world,how,are,you\n");
print join(":", @csv_values);

# Function, argument, return, call
sub hello {
	$name = shift; #First argument.
	return "Hello " . $name;
}
print hello("Binny");

# File IO
# File reading, easy method...
open(IN,'Hello.pl') or die("Cannot open file : $!");
my @lines = &lt;IN&gt;;
close(IN);
my $contents = join('',@lines);
print "Hello has " . length($contents) . " chars\n";
# Writing to a file
open(OUT, '&gt;/tmp/hello.txt');
print OUT "Hello World";
close(OUT);

# Command Executing
print `ls`; #Execute the command 'ls' and print its output
print "\n";

# Regular Expressions
my $string = "Hello World";
print "Yup - its evil\n" if($string =~ /^Hell/);
$string =~ s/l([^l])/$1/g; #Remove an 'l' from both words. Should print 'Helo Word'
print $string;

print "\n\n";
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.bin-co.com/blog/2008/04/perl-hello-script/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
