<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<feed xmlns="http://www.w3.org/2005/Atom">

	<title>TecnoFe</title>
	<link rel="self" href="http://blogs.firebirds.com.ar/atom.xml"/>
	<link href="http://blogs.firebirds.com.ar"/>
	<id>http://blogs.firebirds.com.ar/atom.xml</id>
	<updated>2008-08-20T16:45:26+00:00</updated>
	<generator uri="http://www.planetplanet.org/">Planet/2.0 +http://www.planetplanet.org</generator>

	<entry>
		<title type="html">¿Preincrementar o postincrementar?</title>
		<link href="http://cmasomenos.blogspot.com/2008/08/preincrementar-o-postincrementar.html"/>
		<id>tag:blogger.com,1999:blog-4295741868585735005.post-4871056687622874222</id>
		<updated>2008-08-19T09:34:00+00:00</updated>
		<content type="html">Hace mucho que quería escribir un post tan inútil como este. La duda que siempre me pasaba por la cabeza era la siguiente: ¿Será exactamente el mismo código ensamblador el que genera el compilador cuando utilizamos el preincremento o el postincremento (sin utilizar el valor de retorno)? Tenía la seguridad de que así debía ser (una optimización tan básica no podía ser dejada de lado), pero me faltaban las pruebas (en ensamblador) para verificarlo.&lt;br /&gt;
&lt;br /&gt;
Recordando un poco, el preincremento&lt;br /&gt;
&lt;pre class=&quot;source-code&quot;&gt;int a = 0;
int b = ++a;
&lt;/pre&gt;hace &lt;i&gt;a=1&lt;/i&gt; y &lt;i&gt;b=1&lt;/i&gt;, mientras que el postincremento&lt;br /&gt;
&lt;pre class=&quot;source-code&quot;&gt;int a = 0;
int b = a++;
&lt;/pre&gt;hace &lt;i&gt;a=1&lt;/i&gt; y &lt;i&gt;b=0&lt;/i&gt;, esto significa que &lt;i&gt;b&lt;/i&gt; obtuvo el valor de &lt;i&gt;a&lt;/i&gt; anterior al incremento.&lt;br /&gt;
&lt;br /&gt;
Aquí &lt;i&gt;estamos utilizando&lt;/i&gt; el valor de retorno del operador incremento. El código ensamblador &lt;i&gt;es distinto&lt;/i&gt; para cada caso. Vamos a echarle una mirada (antes le recomiendo ver &lt;a rel=&quot;nofollow&quot; target=&quot;_blank&quot; href=&quot;http://www.unixwiz.net/techtips/win32-callconv-asm.html&quot;&gt;este excelente artículo&lt;/a&gt; para comprender más sobre el stack y las convenciones de llamadas). En el preincremento el código ensamblador (generado por GCC 3.4.5 para i386) es:&lt;br /&gt;
&lt;pre class=&quot;source-code&quot;&gt;subl $8, %esp // reservamos 8 bytes en el &lt;a rel=&quot;nofollow&quot; target=&quot;_blank&quot; href=&quot;http://en.wikipedia.org/wiki/Call_stack&quot;&gt;stack&lt;/a&gt; (para variables locales)
movl $0, -4(%ebp) // a = 0
leal -4(%ebp), %eax // eax = &amp;amp;a
incl (%eax) // *eax= (*eax) + 1
movl -4(%ebp), %eax // eax = a
movl %eax, -8(%ebp) // b = eax
&lt;/pre&gt;En el postincremento&lt;br /&gt;
&lt;pre class=&quot;source-code&quot;&gt;subl $8, %esp // reservamos 8 bytes en el stack
movl $0, -4(%ebp) // a = 0
movl -4(%ebp), %edx // edx = a
leal -4(%ebp), %eax // eax = &amp;amp;a
incl (%eax) // *eax= (*eax) + 1
movl %edx, -8(%ebp) // b = edx&lt;/pre&gt;donde se ve que el registro edx se utiliza para guardar el valor que tenía &lt;i&gt;a&lt;/i&gt; antes del incremento para luego asignárselo a &lt;i&gt;b&lt;/i&gt;.&lt;br /&gt;
&lt;br /&gt;
Pero la pregunta original es, ¿qué pasa si &lt;b&gt;no&lt;/b&gt; usamos el valor de retorno? ¿el código de ++i o i++ es igual? Debería serlo, y de hecho, lo es. Pero como veremos más abajo, esto sólo se cumple si utilizamos tipos de datos &lt;i&gt;built-in&lt;/i&gt; (int, double, long, etc.). Miremos el siguiente código:&lt;br /&gt;
&lt;pre class=&quot;source-code&quot;&gt;void func() { }
void pre () { for (int c=0; c&amp;lt;8; ++c) { func(); } }
void post() { for (int c=0; c&amp;lt;8; c++) { func(); } }
int main()
{ pre(); post(); return 0;
}
&lt;/pre&gt;Básico, un &lt;i&gt;for&lt;/i&gt; pero con las dos variantes posible de incremento. El código generado para ambos casos (tanto para la función &lt;i&gt;pre&lt;/i&gt; como &lt;i&gt;post&lt;/i&gt;) es el siguiente:&lt;br /&gt;
&lt;pre class=&quot;source-code&quot;&gt;&lt;span&gt;&lt;/span&gt; pushl %ebp // guardar el viejo puntero a la base del stack movl %esp, %ebp // establecer la nueva base del stack subl $4, %esp // guardar 4 bytes en el stack (para variables locales) movl $0, -4(%ebp) // c = 0
L3: cmpl $7, -4(%ebp) jg L2 // si c &amp;gt; 7 entonces ir a L2 call _func // llamar a la función func() leal -4(%ebp), %eax // eax = &amp;amp;c incl (%eax) // *eax= (*eax) + 1 jmp L3 // repetir yendo a L3
L2: leave // restaurar la base del stack (popl %ebp) ret // retornar al punto de llamada
&lt;/pre&gt;Realmente es indiferente usar cualquiera de los dos tipos de incremento, salvo, en los tipos definidos por el usuario. C++ ofrece un soporte para tipos de usuario igual a los built-in (bueno, no del todo, pero &lt;a rel=&quot;nofollow&quot; target=&quot;_blank&quot; href=&quot;http://www.artima.com/cppsource/cpp0xP.html&quot;&gt;lo están solucionando&lt;/a&gt;). Nos da la posibilidad de sobrecargar los operadores de nuestros propios tipos (clases). Por ejemplo:&lt;br /&gt;
&lt;pre class=&quot;source-code&quot;&gt;class tipo { int x;
public: tipo(int y) : x(y) { } tipo(const tipo&amp;amp; y) : x(y.x) { } // preincremento tipo&amp;amp; operator++() { ++x; return *this; } // postincremento tipo operator++(int) { tipo tmp(*this); ++x; return tmp; } bool operator&amp;lt;(int y) const { return x &amp;lt; y; }
}; void func() { }
void pre() { for (tipo c=0; c&amp;lt;8; ++c) { func(); } }
void post() { for (tipo c=0; c&amp;lt;8; c++) { func(); } } int main()
{ post(); return 0;
}
&lt;/pre&gt;No colocaré el código ensamblador por desbordar belleza, pero el código generado en este caso es distinto: cada incremento llama a la función correspondiente a su operador. Esto es debido a que ambas implementaciones varían considerablemente. Por ejemplo, el postincremento necesita de una instancia extra de &lt;i&gt;tipo&lt;/i&gt; para poder devolver el anterior valor de &lt;i&gt;this&lt;/i&gt;, en cambio, el preincremento devuelve una referencia al mismo &lt;i&gt;this&lt;/i&gt; (sin necesidad de hacer una copia).&lt;br /&gt;
&lt;br /&gt;
Como dato curioso, algo interesante ocurre al utilizar las optimizaciones del GCC. Si compilamos este último programa con el parámetro -O3, vamos a ver que todas las funciones correspondientes a la clase &lt;i&gt;tipo&lt;/i&gt; desaparecen, y todo el código resultantes es &lt;i&gt;inline&lt;/i&gt;, dando como resultado un código tan óptimo como si hubiéramos utilizado un &lt;i&gt;int&lt;/i&gt; en vez de nuestra clase &lt;i&gt;tipo&lt;/i&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;¿Cómo obtengo el código ensamblador desde un archivo C/C++?&lt;/b&gt;&lt;br /&gt;
Con el compilador &lt;i&gt;gcc&lt;/i&gt;, hay que utilizar el parámetro -S: &lt;br /&gt;
&lt;pre class=&quot;source-code&quot;&gt;g++ -S -o archivo.s -c archivo.cpp
&lt;/pre&gt;En &lt;i&gt;archivo.s&lt;/i&gt; queda el código ensamblador (sintaxis &lt;a rel=&quot;nofollow&quot; target=&quot;_blank&quot; href=&quot;http://www.google.com.ar/search?q=AT%26T+Assembly+Syntax&quot;&gt;AT&amp;amp;T&lt;/a&gt;).</content>
		<author>
			<name>David A. Capello</name>
			<uri>http://pipes.yahoo.com/pipes/pipe.info?_id=lP8f3hnf3BGlYcsNj0nRlg</uri>
		</author>
		<source>
			<title type="html">David A. Capello</title>
			<subtitle type="html">Feeds de los blogs de esta persona, desconocida por todos (hasta por el mismo).</subtitle>
			<link rel="self" href="http://www.davidcapello.com.ar/blog/feed/"/>
			<id>http://www.davidcapello.com.ar/blog/feed/</id>
			<updated>2008-08-20T16:45:11+00:00</updated>
		</source>
	</entry>

	<entry xml:lang="en">
		<title type="html">Fotografiando desde el camino</title>
		<link href="http://www.juanjoconti.com.ar/2008/08/18/fotografiando-desde-el-camino/"/>
		<id>http://www.juanjoconti.com.ar/?p=512</id>
		<updated>2008-08-18T16:59:45+00:00</updated>
		<content type="html">&lt;p&gt;&lt;a href=&quot;http://www.juanjoconti.com.ar/wp-content/uploads/2008/08/200808160019221_3426132759.jpg&quot;&gt;&lt;img class=&quot;alignright size-medium wp-image-515&quot; title=&quot;200808160019221_3426132759&quot; src=&quot;http://www.juanjoconti.com.ar/wp-content/uploads/2008/08/200808160019221_3426132759-225x300.jpg&quot; alt=&quot;&quot; width=&quot;135&quot; height=&quot;180&quot; /&gt;&lt;/a&gt;Hace unos días empecé a publicar fotos &lt;strong&gt;instantáneas &lt;/strong&gt;en mi blog. Basándome en el servicio gratuito de Personal puedo tener en mi blog, en menos de un minuto, fotos que tome con mi celular.&lt;/p&gt;
&lt;p&gt;&lt;a title=&quot;Album&quot; href=&quot;http://album.personal.com.ar&quot; target=&quot;_blank&quot;&gt;Album Personal&lt;/a&gt; es un servicio que te permite subir sin cargo fotos desde tu celular a un espacio privado en la web. Una vez que las fotos están ahí puedo jalarlas (&lt;em&gt;pool&lt;/em&gt;) al servidor dónde está alojado mi blog.&lt;/p&gt;
&lt;p&gt;Este procesos de pooling es llevado a cabo mediante un script escrito en Python (sirviéndome de las librerías &lt;a title=&quot;BeautifulSoup&quot; href=&quot;http://www.crummy.com/software/BeautifulSoup/download/BeautifulSoup.py&quot; target=&quot;_blank&quot;&gt;BeautifulSoup&lt;/a&gt;, &lt;a title=&quot;urllib2&quot; href=&quot;http://www.python.org/doc/lib/module-urllib2.html&quot; target=&quot;_blank&quot;&gt;urllib2&lt;/a&gt; y &lt;a title=&quot;cookielib&quot; href=&quot;http://www.python.org/doc/lib/module-cookielib.html&quot; target=&quot;_blank&quot;&gt;cookielib&lt;/a&gt;) que puedo ejecutar directamente desde mi celular utilizando &lt;a title=&quot;SSH&quot; href=&quot;http://www.xk72.com/midpssh/&quot; target=&quot;_blank&quot;&gt;MidpSSH&lt;/a&gt; (un cliente ssh escrito en &lt;a title=&quot;Java ME&quot; href=&quot;http://java.sun.com/javame/index.jsp&quot; target=&quot;_blank&quot;&gt;Java&lt;/a&gt; para celulares).&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://www.juanjoconti.com.ar/wp-content/uploads/2008/08/200808171445262_3426132759.jpg&quot;&gt;&lt;img class=&quot;size-medium wp-image-516 aligncenter&quot; title=&quot;200808171445262_3426132759&quot; src=&quot;http://www.juanjoconti.com.ar/wp-content/uploads/2008/08/200808171445262_3426132759-225x300.jpg&quot; alt=&quot;&quot; width=&quot;135&quot; height=&quot;180&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Por ahora solo se visualiza la última foto que subo en la página principal del blog. Pronto voy a implementar un álbum desde el cual  ver también las fotos anteriores.&lt;a href=&quot;http://www.juanjoconti.com.ar/wp-content/uploads/2008/08/200808171623181_3426132759.jpg&quot;&gt;&lt;img class=&quot;size-medium wp-image-517 aligncenter&quot; title=&quot;200808171623181_3426132759&quot; src=&quot;http://www.juanjoconti.com.ar/wp-content/uploads/2008/08/200808171623181_3426132759-225x300.jpg&quot; alt=&quot;&quot; width=&quot;135&quot; height=&quot;180&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</content>
		<author>
			<name>Juanjo Conti</name>
			<uri>http://www.juanjoconti.com.ar</uri>
		</author>
		<source>
			<title type="html">Vientos de Libertad</title>
			<subtitle type="html">el blog de Juanjo Conti - en borrador permanente</subtitle>
			<link rel="self" href="http://www.juanjoconti.com.ar/feed/"/>
			<id>http://www.juanjoconti.com.ar/feed/</id>
			<updated>2008-08-18T17:15:22+00:00</updated>
		</source>
	</entry>

	<entry xml:lang="en">
		<title type="html">Podés estar seguro que no entendiste el Proceso Unificado cuando…</title>
		<link href="http://nacho.larrateguy.com.ar/2008/08/14/no-entendiste-el-proceso-unificado-cuando/"/>
		<id>http://nacho.larrateguy.com.ar/?p=118</id>
		<updated>2008-08-14T18:04:41+00:00</updated>
		<content type="html">&lt;p&gt;Un extracto del Libro de Larman (&lt;a href=&quot;http://www.amazon.com/Applying-UML-Patterns-Introduction-Object-Oriented/dp/0131489062/ref=sr_1_1/002-2801511-2159202?ie=UTF8&amp;amp;s=books&amp;amp;qid=1194351090&amp;amp;sr=1-1&quot; target=&quot;_blank&quot;&gt;Applying UML and Patterns: An Introduction to Object-Oriented Analysis and Design and Iterative Development, Third Edition&lt;/a&gt;) mientras termino un post donde resumimos largas charlas presenciales y virtuales con Milton acerca de las metodologías para el desarrollo de software.&lt;/p&gt;
&lt;h3&gt;2.13. You Know You Didn&amp;#8217;t Understand Iterative Development or the UP When&amp;#8230;&lt;/h3&gt;
&lt;p&gt;Here are some signs that you have not understood what it means to adopt iterative development and the UP in a healthy agile spirit.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;You try to define most of the requirements before starting design or implementation. Similarly, you try to define most of the design before starting implementation; you try to fully define and commit to an architecture before iterative programming and testing.&lt;/li&gt;
&lt;li&gt;You spend days or weeks in UML modeling before programming, or you think UML diagramming and design activities are a time to fully and accurately define designs and models in great detail. And you regard programming as a simple mechanical translation of these into code.&lt;/li&gt;
&lt;li&gt;You think that inception = requirements, elaboration = design, and construction = implementation (that is, superimposing the waterfall on the UP).&lt;/li&gt;
&lt;li&gt;You think that the purpose of elaboration is to fully and carefully define models, which are translated into code during construction.&lt;/li&gt;
&lt;li&gt;You believe that a suitable iteration length is three months long, rather than three weeks long.&lt;/li&gt;
&lt;li&gt;You think that adopting the UP means to do many of the possible activities and create many documents, and you think of or experience the UP as a formal, fussy process with many steps to be followed.&lt;/li&gt;
&lt;li&gt;You try to plan a project in detail from start to finish; you try to speculatively predict all the iterations, and what should happen in each one.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Destaco por ahora la ante última oración para los detractores y que dicen que es poco ágil.&lt;/p&gt;
&lt;p&gt;Más información acerca del UP, Rational UP, y otras &amp;#8220;instancias&amp;#8221; del UP.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://www.agilemodeling.com/essays/agileModelingRUP.htm&quot;&gt;http://www.agilemodeling.com/essays/agileModelingRUP.htm&lt;/a&gt;&lt;/p&gt;</content>
		<author>
			<name>Luis Ignacio Larrateguy</name>
			<uri>http://nacho.larrateguy.com.ar</uri>
		</author>
		<source>
			<title type="html">Open Minded</title>
			<subtitle type="html">... o no tanto.</subtitle>
			<link rel="self" href="http://nacho.larrateguy.com.ar/feed/"/>
			<id>http://nacho.larrateguy.com.ar/feed/</id>
			<updated>2008-08-14T18:15:28+00:00</updated>
		</source>
	</entry>

	<entry xml:lang="en">
		<title type="html">Nuevo número de celular</title>
		<link href="http://www.juanjoconti.com.ar/2008/08/09/nuevo-numero-de-celular/"/>
		<id>http://www.juanjoconti.com.ar/?p=502</id>
		<updated>2008-08-09T21:39:28+00:00</updated>
		<content type="html">&lt;p&gt;Desde ayer a la tarde tengo un &lt;strong&gt;nuevo número de celular&lt;/strong&gt;. Aproveché el viaje de hoy a Pellegrini para enviar un mensaje masivo a todos mis contactos del viejo celular comunicándoles mi nuevo número.&lt;/p&gt;
&lt;p&gt;¿No te lo mandé? ¿Debería haberlo hecho? Mandame un mail y te lo paso!&lt;/p&gt;</content>
		<author>
			<name>Juanjo Conti</name>
			<uri>http://www.juanjoconti.com.ar</uri>
		</author>
		<source>
			<title type="html">Vientos de Libertad</title>
			<subtitle type="html">el blog de Juanjo Conti - en borrador permanente</subtitle>
			<link rel="self" href="http://www.juanjoconti.com.ar/feed/"/>
			<id>http://www.juanjoconti.com.ar/feed/</id>
			<updated>2008-08-18T17:15:22+00:00</updated>
		</source>
	</entry>

</feed>
