<?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>coder . cl &#187; tips</title>
	<atom:link href="http://coder.cl/category/tips/feed/" rel="self" type="application/rss+xml" />
	<link>http://coder.cl</link>
	<description>web developer &#38; system programmer</description>
	<lastBuildDate>Sat, 04 Feb 2012 12:07:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>understanding mapreduce</title>
		<link>http://coder.cl/2012/02/understanding-mapreduce/</link>
		<comments>http://coder.cl/2012/02/understanding-mapreduce/#comments</comments>
		<pubDate>Sat, 04 Feb 2012 12:07:01 +0000</pubDate>
		<dc:creator>Daniel Molina Wegener</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[haskell]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://coder.cl/?p=2210</guid>
		<description><![CDATA[MapReduce is a distributed computing model introduced by Google with its framework for distributed computing called MapReduce. Its conceptual basis comes from a functional programming approach based mainly on the basic mathematical concept of Monoid treatment in functional programming. Basically a Monoid lifts data using map and process that data using fold &#8212; which is [...]]]></description>
			<content:encoded><![CDATA[<p><a href='http://en.wikipedia.org/wiki/MapReduce' title='MapReduce' rel="nofollow">MapReduce</a> is a distributed computing model introduced by Google with its framework for distributed computing called MapReduce. Its conceptual basis comes from a functional programming approach based mainly on the basic mathematical concept of Monoid treatment in functional programming. Basically a Monoid <i>lifts</i> data using <a href='http://en.wikipedia.org/wiki/Map_(higher-order_function)' title='Map (higher-order function)' rel="nofollow">map</a> and process that data using <a href='' title='http://en.wikipedia.org/wiki/Fold_(higher-order_function)' title='Fold (higher-order function)' rel="nofollow">fold</a> &mdash; which is called <i>reduce</i> in Python, returning the same bound type as its input &mdash; and can be expressed as the triple <img src='http://s.wordpress.com/latex.php?latex=%5Clangle%20A%2C%20%5Cvarepsilon%2C%20%5Ccdot%20%5Crangle&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\langle A, \varepsilon, \cdot \rangle' title='\langle A, \varepsilon, \cdot \rangle' class='latex' /> as the set <img src='http://s.wordpress.com/latex.php?latex=A&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='A' title='A' class='latex' />, the neutral element <img src='http://s.wordpress.com/latex.php?latex=%5Cvarepsilon&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\varepsilon' title='\varepsilon' class='latex' /> and the operation <img src='http://s.wordpress.com/latex.php?latex=%5Ccdot&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\cdot' title='\cdot' class='latex' />. The problem with the Monoid definition is the fact that it is bound to a type, where MapReduce is not bound to any type, and even it is not bound to a Category.</p>
<p><span id="more-2210"></span></p>
<p>The data is <i>lifted</i> from its original type when it is stored as set. We can have a basic and plain example on how operates the <tt>map</tt> over the data lifting its original type. For example we have a plain text file with lines containing numbers separated by spaces and we want to extract the product for each line of those numbers. Since the data is plain text and it is not a numeric type, we need to <i>lift</i> those numbers and convert them to type that we can operate &mdash; like Integer types. So, <tt>map</tt> implies data extraction and data conversion, to operate that data with <tt>reduce</tt>. Following our plain text file example, we have a plain text file as follows.</p>
<pre name="code" class="brush:bash;">

4 3 1 4 5
2 1 3 2 4
3 4 4 2 1
2 1 3 4 1
</pre>
<p>Now, we can use <tt>map</tt> to make the proper data conversion to <i>lift</i> the input data from the plain text file and process each line obtaining lists of integers instead of string characters as follows.</p>
<pre name="code" class="brush:haskell;">

module Main where

import System.Environment
import Data.String.Utils

liftLine :: String -&gt; [Int]
liftLine l = fmap ( read . strip ) $ split " " l

main :: IO()
main = do [i] &lt;- getArgs
          f &lt;- readFile i
          let rows = fmap liftLine $ lines f
              in putStrLn $ show rows
</pre>
<p>In Haskell there are various <tt>map</tt> functions, here we using the most basic map function called <a href='http://www.haskell.org/ghc/docs/6.12.2/html/libraries/base-4.2.0.1/Control-Monad.html#v%3Afmap' title='Control.Monad -&#038;gt fmap' rel="nofollow">fmap</a>, which is implemented using Functor type class with instance types or anonymous types. So, the <tt>liftLine</tt> function extract a list of Integers from each line splitting the line using the space character, then applies strip to each tokenized string and reads its input converting it to Integer, and since it is using <tt>fmap</tt>, it will return a List of Integers. Where map is used again to lift each line, so, we are using fmap Functor as our lifting map function to extract the data as Integer from its plain text representation.</p>
<p>Now we need to process that <i>lifted</i> data using map, to obtain our required product for each integer list. So, we need to use the <tt>reduce</tt> function, which has two variants in Haskell, foldl and foldr, and for our convenience, we will use foldr, where reduce has a Monoidal behaviour due to its typed nature and can be expressed as <img src='http://s.wordpress.com/latex.php?latex=%5Clangle%20A%2C%201%2C%20%5Ctimes%20%5Crangle&#038;bg=ffffff&#038;fg=000000&#038;s=0' alt='\langle A, 1, \times \rangle' title='\langle A, 1, \times \rangle' class='latex' />.</p>
<pre name="code" class="brush:haskell;">

module Main where

import System.Environment
import Data.String.Utils

liftLine :: String -&gt; [Int]
liftLine l = fmap ( read . strip ) $ split " " l

reduceProduct :: [Int] -&gt; Int
reduceProduct l = foldr (\ x y -&gt; x * y ) 1 l

main :: IO()
main = do [i] &lt;- getArgs
          f &lt;- readFile i
          let rows = fmap liftLine $ lines f
              prds = fmap reduceProduct rows
              in putStrLn $ show prds
</pre>
<p>So, those are the very basic principles of MapReduce, which is used to calculate the <a href='http://en.wikipedia.org/wiki/PageRank' title='PageRank' rel="nofollow">PageRank</a> on Google and get the site ranking on search results. So, this example is not distributed and it is a plain example of how it operates, just think on a distributed <tt>map</tt> and a distributed <tt>reduce</tt> operating with a very large amount of data to be processed. And there are various frameworks to work with MapReduce as model, because the original Google framework is not open source and you cannot work with it. As example of available frameworks supporting MapReduce as model you have <a href='http://hadoop.apache.org/' title='Apache Hadoop' rel="nofollow">Hadoop</a>, <a href='http://aws.amazon.com/elasticmapreduce/' title='Amazon Elastic MapReduce' rel="nofollow">Elastic MapReduce</a> and <a href='http://hackage.haskell.org/package/Holumbus-MapReduce' title='The Holumbus-MapReduce package'>Holumbus</a>, so you can use this model with those frameworks reducing computation costs if you do not want to process your data with linear computations.</p>
<br/><hr height="1px" width="50%" />
<div style='text-align: center !important;'><b>Copyright © 2012 Daniel Molina Wegener</b><br/><b>Atribución-No Comercial-Sin Derivadas 2.0 Chile</b><br/><a target='_new' rel="license" href="http://creativecommons.org/licenses/by-nc-nd/2.0/cl/"><img alt="Creative Commons License" style="border-width:0" src="http://coder.cl.qfl.wpcdn.arcostream.com/cc88x31.png" /></a></div>
<br/><hr height="1px" width="100%" />
<p><small>© Daniel Molina Wegener for <a href="http://coder.cl">coder . cl</a>, 2012. | <a href="http://coder.cl/2012/02/understanding-mapreduce/">Permalink</a> | <a href="http://coder.cl/2012/02/understanding-mapreduce/#comments">No comment</a><br/>Post tags: <br/></small></p>
<script type="text/javascript"><!--
google_ad_client = "ca-pub-6234432850133541";
/* main-feed */
google_ad_slot = "0763600725";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
]]></content:encoded>
			<wfw:commentRss>http://coder.cl/2012/02/understanding-mapreduce/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>what do I dislike from IE?</title>
		<link>http://coder.cl/2012/02/what-do-i-dislike-from-ie/</link>
		<comments>http://coder.cl/2012/02/what-do-i-dislike-from-ie/#comments</comments>
		<pubDate>Fri, 03 Feb 2012 11:46:42 +0000</pubDate>
		<dc:creator>Daniel Molina Wegener</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[rants]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://coder.cl/?p=2206</guid>
		<description><![CDATA[I think that my major school on computing comes from Unix &#38; Linux. Unix and derived operating systems are really cool, they have a lot of data processing tools for the command line and software development. They come at least with one language interpreter called Awk or better suited comes with Perl, so you can [...]]]></description>
			<content:encoded><![CDATA[<p>I think that my major school on computing comes from Unix &amp; Linux. Unix and derived operating systems are really cool, they have a lot of data processing tools for the command line and software development. They come at least with one language interpreter called <i>Awk</i> or better suited comes with <i>Perl</i>, so you can easily automate system tasks. So, Unix systems are really more developer friendly, rather than user friendly operating systems. With many tools that are freely available to extend the operating system and make it fit your data processing needs, without too much licensing problems.</p>
<p><span id="more-2206"></span></p>
<p>An example of a good placed Unix system is Mac OS X, it has several command line tools to automate the operating system and make it friendly and its native development environment called X Code is very easy to acquire, without too much problems. It is a real programmer environment</a>. Flexible enough to be customized, with various tools that allows you to <i>program</i> the environment, automate tasks and make life really more easier. For example while I&#8217;m programming and I want to seek source code with log lines, I use a single command line pipe to filter log messages, as follows.</p>
<pre name="code" class="brush:bash;">

$ find . -type f -name '*.py' -exec grep -nHi 'l.debug' {} \; | sed '/exc/d;'
</pre>
<p>On Windows and similar operating systems, which are specially made for <i>users</i>, rather than <i>developers</i>, I feel really truncated because I cannot do stuff like that. So, I become less productive under Windows and I hate it. Things that should be solved quickly with few command line and editor hooks &mdash; like Emacs provides me for editing automation &mdash; are delayed under Windows because it does not support that kind of stuff. What&#8217;s better than having an editor with an embedded Lisp interpreter? What&#8217;s better than having <i>Perl</i> and <i>Awk</i> among a lot of command line tools that allows me to automate any task that I want?</p>
<p>The same happens on its browser. Internet Explorer does not have enough tools for Web Development like others have. On Firefox and Google Chrome we have very nice development tools, allowing us to create amazing DHTML / AJAX based applications, among other stuff like building amazing HTML 5 and WebGL applications. I find really frustrating any work made under Internet Explorer. If you want to debug a simple JavaScript implementation &mdash; which is not really JavaScript under windows and it is dialect called JScript &mdash; you need to launch a whale called Visual Studio. So, to become productive developing Internet Explorer applications, you must pay for something that will be used with a <i>10%</i> of its capacity, including the licensing cost of Visual Studio.</p>
<p>So, for me Windows, Internet Explorer, and related technologies are a mere gaming console, rather than a developer friendly environment. That is why I dislike using Windows and developing systems for that operating system, because it is poor, overfilled with useless ornaments rather than useful tools.</p>
<br/><hr height="1px" width="50%" />
<div style='text-align: center !important;'><b>Copyright © 2012 Daniel Molina Wegener</b><br/><b>Atribución-No Comercial-Sin Derivadas 2.0 Chile</b><br/><a target='_new' rel="license" href="http://creativecommons.org/licenses/by-nc-nd/2.0/cl/"><img alt="Creative Commons License" style="border-width:0" src="http://coder.cl.qfl.wpcdn.arcostream.com/cc88x31.png" /></a></div>
<br/><hr height="1px" width="100%" />
<p><small>© Daniel Molina Wegener for <a href="http://coder.cl">coder . cl</a>, 2012. | <a href="http://coder.cl/2012/02/what-do-i-dislike-from-ie/">Permalink</a> | <a href="http://coder.cl/2012/02/what-do-i-dislike-from-ie/#comments">One comment</a><br/>Post tags: <br/></small></p>
<script type="text/javascript"><!--
google_ad_client = "ca-pub-6234432850133541";
/* main-feed */
google_ad_slot = "0763600725";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
]]></content:encoded>
			<wfw:commentRss>http://coder.cl/2012/02/what-do-i-dislike-from-ie/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>change management process</title>
		<link>http://coder.cl/2012/01/change-management-process/</link>
		<comments>http://coder.cl/2012/01/change-management-process/#comments</comments>
		<pubDate>Sun, 29 Jan 2012 15:48:08 +0000</pubDate>
		<dc:creator>Daniel Molina Wegener</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://coder.cl/?p=2201</guid>
		<description><![CDATA[Managing changes is really important in software development projects. Each change should be handled carefully and must not be seen as part of the original development process. Instead, you should measure and control each change in the original requirements, even if you are using agile or cascade methodologies. You cannot accept all changes that the [...]]]></description>
			<content:encoded><![CDATA[<p>Managing changes is really important in software development projects. Each change should be handled carefully and must not be seen as part of the original development process. Instead, you should measure and control each change in the original requirements, even if you are using agile or cascade methodologies. You cannot accept all changes that the customer proposes without the proper management process. Is not that easy to handle changes in requirements like changing a comment in the code. Instead of accepting changes and delivering software without the proper management process, you should be able to handle those requirements using a standard method to manage those requirement changes.</p>
<p><span id="more-2201"></span></p>
<p>An example of requirement change management process is as follows:</p>
<ol>
<li>Log the changes.</li>
<li>Perform an impact analysis on the work products.</li>
<li>Estimate the effort needed for the change requests.</li>
<li>Reestimate the delivery schedule.</li>
<li>Perform a cumulative cost impact analysis.</li>
<li>Review the impact with senior management if thresholds are exceeded.</li>
<li>Obtain customer sign-off.</li>
<li>Rework work products.</li>
</ol>
<p>So, you should record each change in the project documentation, on the product backlog on agile projects and the project specification in structured projects. If you do not record all changes that are made to any software piece, there is not log or evidence that were made changes to the project, and you are loosing the core project specification. Any change requires analysis of all changes that are applied to the software piece. If you do not perform analysis, you are delivering software pieces without the proper structure and logical basis, even if you are working with prototypes. And finally, all changes should be measured and estimate the effort required to complete them, without an estimation of those efforts, you will not be able to handle the change set cost, deriving in a project with a higher cost than it was measured originally. Even if you are using agile or structured methodologies, you should measure changes and <i>manage</i> them.</p>
<p>So, if you are working with project managers that are not reestimating the delivery schedule with requirement changes, you are really wasting your time on that company. You can find about this topic on any modern project management book, and you will agree with the idea that a requirement change implies a change in the delivery schedule.</p>
<p>If you think in software pieces like products or physical products, for example like building houses, if you have some UML diagrams, like class diagrams and sequence diagrams, which are specifying how the application should work, if you receive changes over those diagrams and specifications, is the same thing as changing a house plane, you need to rebuild and refactor everything, and it has a very high cost. The same applies to those applications implementing work flows, if they are implemented using precarious <tt>if</tt> statements, instead of using <i>state machines</i>, any change to the work flow will lead you very hard changes on the code. So you should measure and control each change, so you must do <i>management</i>.</p>
<br/><hr height="1px" width="50%" />
<div style='text-align: center !important;'><b>Copyright © 2012 Daniel Molina Wegener</b><br/><b>Atribución-No Comercial-Sin Derivadas 2.0 Chile</b><br/><a target='_new' rel="license" href="http://creativecommons.org/licenses/by-nc-nd/2.0/cl/"><img alt="Creative Commons License" style="border-width:0" src="http://coder.cl.qfl.wpcdn.arcostream.com/cc88x31.png" /></a></div>
<br/><hr height="1px" width="100%" />
<p><small>© Daniel Molina Wegener for <a href="http://coder.cl">coder . cl</a>, 2012. | <a href="http://coder.cl/2012/01/change-management-process/">Permalink</a> | <a href="http://coder.cl/2012/01/change-management-process/#comments">No comment</a><br/>Post tags: <br/></small></p>
<script type="text/javascript"><!--
google_ad_client = "ca-pub-6234432850133541";
/* main-feed */
google_ad_slot = "0763600725";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
]]></content:encoded>
			<wfw:commentRss>http://coder.cl/2012/01/change-management-process/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>django and amazon s3</title>
		<link>http://coder.cl/2012/01/django-and-amazon-s3/</link>
		<comments>http://coder.cl/2012/01/django-and-amazon-s3/#comments</comments>
		<pubDate>Thu, 19 Jan 2012 13:18:45 +0000</pubDate>
		<dc:creator>Daniel Molina Wegener</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://coder.cl/?p=2183</guid>
		<description><![CDATA[Amazon S3 is a well known web based storage system provided as SaaS service provided by Amazon Web Services. On Django you can integrate that service using the storage interface called Django Storages, but you must have some considerations using that SaaS storage interface. Mainly regarding the Date header sent to the service on each [...]]]></description>
			<content:encoded><![CDATA[<p><a href='http://aws.amazon.com/s3/' title='Amazon Simple Storage Service (Amazon S3)'>Amazon S3</a> is a well known web based storage system provided as SaaS service provided by <a href='http://aws.amazon.com/' title='Amazon Web Services (AWS)'>Amazon Web Services</a>. On Django you can integrate that service using the storage interface called <a href='http://code.welldev.org/django-storages/' title='Django Storages (django-storages)'>Django Storages</a>, but you must have some considerations using that SaaS storage interface. Mainly regarding the <tt>Date</tt> header sent to the service on each read, write and similar operations, where you must send an updated header with the proper Time Zone and format.</p>
<p><span id="more-2183"></span></p>
<p>Once you have configured and working the django-storages package, you should fill the <tt>Date</tt> header or the <tt>x-amz-date</tt> header each time that you do a request to S3. So, the only way to do that is not to leave the module sending the date automatically, instead you should write the settings variable <tt>AWS_HEADERS</tt>.</p>
<pre name="code" class="brush:python;">

import pytz
from datetime import datetime
from django.conf import settings

def get_aws_date(self):
    """
    Returns the server date formatted and using the server
    time zone localized to be used as Date header with
    Amazon S3.
    """
    stz = pytz.timezone(settings.TIME_ZONE)
    dtm = stz.localize(datetime.now()).strftime("%a, %d %b %Y %H:%M:%S %z")
    settings.AWS_HEADERS['Date'] = dtm
    settings.AWS_HEADERS['x-amz-date'] = dtm
    return dtm
</pre>
<p>Also, you must consider this requirement to work with S3 on all your requests. Since django-storages checks if the <tt>AWS_HEADERS</tt> has the Date or x-amz-date headers set, you must set that header each time that you make a request to S3, so you cannot use a batch <tt>read()</tt> from the storage or a batch <tt>write()</tt> to the storage, because it will use the previously sent Date header and it will fail, because it is considered inconsistent by the S3 authentication mechanism. If we use S3 as default storage, the example below will fail, because it will send file chunks with the same Date header, because the header was set previously.</p>
<pre name="code" class="brush:python;">

from django.core.files.storage import default_storage

if default_storage.exist('test-large-file.mp3'):
    mp3file = open('test-large-file.mp3')
    s3file = default_storage.open('test-large-file.mp3')
    mp3file.write(s3file.read())
    mp3file.close()
    s3file.close()
</pre>
<p>So, you need to use small chunks to read from the storage, as the example below.</p>
<pre name="code" class="brush:python;">

from django.core.files.storage import default_storage

if default_storage.exist('test-large-file.mp3'):
    get_aws_date()
    mp3file = open('test-large-file.mp3')
    s3file = default_storage.open('test-large-file.mp3')
    buff = s3file.read(settings.AWS_CHUNK_SIZE)
    while buff:
        mp3file.write(buff)
        try:
            buff = s3file.read(settings.AWS_CHUNK_SIZE)
        except Exception, exc:
            buff = None
    mp3file.close()
    s3file.close()
</pre>
<p>But also you must consider few issues about this. Since AWS_HEADERS is a global variable, writing to that variable will slow down your code because it lacks time on GIL usage, also it will lack your threaded application if it written twice, even if you are using locks and Django can handle parallel writes to that variable. So, be careful reading and writing large files from S3, and take a look on how the Date header is sent on each request.</p>
<pre name="code" class="brush:python;">

def _add_aws_auth_header(self, headers, method,
                         bucket, key, query_args):
    if not headers.has_key('Date'):
        headers['Date'] = time.strftime("%a, %d %b %Y %X GMT",
                                        time.gmtime())

    c_string = canonical_string(method, bucket, key,
                                query_args, headers)
    headers['Authorization'] = \
        "AWS %s:%s" % (self.aws_access_key_id,
                       encode(self.aws_secret_access_key, c_string))
</pre>
<p>Where the <tt>%X</tt> <a href='http://docs.python.org/library/datetime.html#strftime-strptime-behavior' title='Python Manual, strftime() and strptime() Behavior'>specifier for localized machines</a> with an environment variable <tt>LC_ALL</tt> different from <i>C</i> will throw the wrong date format disallowing your application to work with S3. This is a well known bug reported <a href='https://bitbucket.org/david/django-storages/issue/56/aws-authentication-requires-a-valid-date' title='#56 "AWS authentication requires a valid Date or x-amz-date header"' rel="nofollow">on this link</a>. So, the right implementation, should be as follows.</p>
<pre name="code" class="brush:python;">

def _add_aws_auth_header(self, headers, method,
                         bucket, key, query_args):
    if not 'Date' in headers:
        stz = pytz.timezone(settings.TIME_ZONE)
        dtm = stz.localize(datetime.now()).strftime("%a, %d %b %Y %H:%M:%S %z")
        headers['Date'] = dtm

    c_string = canonical_string(method, bucket, key,
                                query_args, headers)
    headers['Authorization'] = \
        "AWS %s:%s" % (self.aws_access_key_id,
                       encode(self.aws_secret_access_key, c_string))
</pre>
<p>Good luck using S3.</p>
<br/><hr height="1px" width="50%" />
<div style='text-align: center !important;'><b>Copyright © 2012 Daniel Molina Wegener</b><br/><b>Atribución-No Comercial-Sin Derivadas 2.0 Chile</b><br/><a target='_new' rel="license" href="http://creativecommons.org/licenses/by-nc-nd/2.0/cl/"><img alt="Creative Commons License" style="border-width:0" src="http://coder.cl.qfl.wpcdn.arcostream.com/cc88x31.png" /></a></div>
<br/><hr height="1px" width="100%" />
<p><small>© Daniel Molina Wegener for <a href="http://coder.cl">coder . cl</a>, 2012. | <a href="http://coder.cl/2012/01/django-and-amazon-s3/">Permalink</a> | <a href="http://coder.cl/2012/01/django-and-amazon-s3/#comments">No comment</a><br/>Post tags: <br/></small></p>
<script type="text/javascript"><!--
google_ad_client = "ca-pub-6234432850133541";
/* main-feed */
google_ad_slot = "0763600725";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
]]></content:encoded>
			<wfw:commentRss>http://coder.cl/2012/01/django-and-amazon-s3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>so you feel as programmer</title>
		<link>http://coder.cl/2012/01/so-you-feel-as-programmer/</link>
		<comments>http://coder.cl/2012/01/so-you-feel-as-programmer/#comments</comments>
		<pubDate>Thu, 12 Jan 2012 11:50:32 +0000</pubDate>
		<dc:creator>Daniel Molina Wegener</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://coder.cl/?p=2169</guid>
		<description><![CDATA[So you feel as programmer because you can handle one programming language. Well, the bad news are the fact that you are not a programmer and even you don&#8217;t know too much about programming. At least you should know the three main programming paradigms, which comes from the two main branches called functional and imperative, [...]]]></description>
			<content:encoded><![CDATA[<p>So you feel as programmer because you can handle one programming language. Well, the bad news are the fact that you are not a programmer and even you don&#8217;t know too much about programming. At least you should know the three main programming paradigms, which comes from the two main branches called functional and imperative, so you should know at least functional, procedural and object oriented programming. The reason is quite simple, all languages are becoming hybrid languages supporting those three programming paradigms, if you do not understand their basic concepts, you are lost and messing the code.</p>
<p><span id="more-2169"></span></p>
<p>As example, on Python I have a list of integers and I want the power of two of each element. Someone with the basic approach of imperative programming and procedural programming will implement something like the code that follows.</p>
<pre name="code" class="brush:python;">

nums = xrange(1, 11)
resl = list()
for n in nums:
    resl.append(n ** 2)
print(resl)
</pre>
<p>If you know a little of functional programming and you know that Python is a multi-paradigm programming language that allows you to use some functional features on it, you know that the code above have bad implementation and should be simplified just to three lines of code, because Python supports lambda expressions and higher order functions, as code the code that follows.</p>
<pre name="code" class="brush:python;">

nums = xrange(1, 11)
resl = map(lambda x: x ** 2, nums)
print(resl)
</pre>
<p>Among other stuff, like reducing cyclomatic complexity and making more elegant code, you are not conscious about those changes that are present in other programming languages you will fall in very ugly mistakes about programming. Most programming languages are currently including support for various functional features like lambda expressions, higher order functions, closures, continuations and many other features considered <i>functional</i>. I do not need to name each language that has added support for them, but as examples we have Java, C Sharp, C++, JavaScript, and many others.</p>
<p>We have reached a point where the functional paradigm cannot be ignored any more. You must understand many concepts that comes from functional programming to understand concepts related to technologies that are currently widely used, like <a href='http://en.wikipedia.org/wiki/MapReduce' title='MapReduce'>MapReduce</a>, which has its conceptual basis on functional operations too, by mixing two higher order functions called <a href='http://en.wikipedia.org/wiki/Map_(higher-order_function)' title='Map (higher-order function)'>map</a> and <a href='http://en.wikipedia.org/wiki/Fold_(higher-order_function)' title='Fold (higher-order function)'>fold</a> &mdash; which is called <tt>reduce()</tt> in Python and <tt>(apply)</tt> in Lisp.</p>
<p>So, you should start learning about functional programming, and learning well, from its basis, concepts and implementations. Also, you should know that most languages used in algorithm research are functional languages. So, the next time that I see a <tt>for</tt> statement placed where should be a statement where you can use a higher-order function, I will consider your code not good as you think.</p>
<br/><hr height="1px" width="50%" />
<div style='text-align: center !important;'><b>Copyright © 2012 Daniel Molina Wegener</b><br/><b>Atribución-No Comercial-Sin Derivadas 2.0 Chile</b><br/><a target='_new' rel="license" href="http://creativecommons.org/licenses/by-nc-nd/2.0/cl/"><img alt="Creative Commons License" style="border-width:0" src="http://coder.cl.qfl.wpcdn.arcostream.com/cc88x31.png" /></a></div>
<br/><hr height="1px" width="100%" />
<p><small>© Daniel Molina Wegener for <a href="http://coder.cl">coder . cl</a>, 2012. | <a href="http://coder.cl/2012/01/so-you-feel-as-programmer/">Permalink</a> | <a href="http://coder.cl/2012/01/so-you-feel-as-programmer/#comments">4 comments</a><br/>Post tags: <br/></small></p>
<script type="text/javascript"><!--
google_ad_client = "ca-pub-6234432850133541";
/* main-feed */
google_ad_slot = "0763600725";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
]]></content:encoded>
			<wfw:commentRss>http://coder.cl/2012/01/so-you-feel-as-programmer/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
<!-- This Quick Cache file was built for (  coder.cl/category/tips/feed/ ) in 0.36678 seconds, on Feb 7th, 2012 at 2:22 am UTC. -->
<!-- This Quick Cache file will automatically expire ( and be re-built automatically ) on Feb 7th, 2012 at 3:22 am UTC -->
