<?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>Vinothbabu&#039;s Desk! &#187; Programming</title>
	<atom:link href="http://vinothbabu.com/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://vinothbabu.com</link>
	<description>When Smart becomes Dumb!</description>
	<lastBuildDate>Thu, 01 Mar 2012 10:38:23 +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>Node.js the future</title>
		<link>http://vinothbabu.com/2012/03/01/a-web-that-is-not-a-global-digital-library-but-a-global-digital-nervous-system-node-js-the-future/</link>
		<comments>http://vinothbabu.com/2012/03/01/a-web-that-is-not-a-global-digital-library-but-a-global-digital-nervous-system-node-js-the-future/#comments</comments>
		<pubDate>Thu, 01 Mar 2012 10:35:51 +0000</pubDate>
		<dc:creator>Sachin</dc:creator>
				<category><![CDATA[My World]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[featured]]></category>

		<guid isPermaLink="false">http://vinothbabu.com/?p=421</guid>
		<description><![CDATA[A web that is not a global digital library, but a global digital nervous system After nearly a two years gap i am filling up my blog with something for my readers who have been disappointed with no updates at all. Recently i was sitting with my friend Nandan and discussing some core concepts of [...]]]></description>
			<content:encoded><![CDATA[<blockquote>
<p style="text-align: center;"><strong>A web that is not a global digital library, but a global digital nervous system</strong></p>
</blockquote>
<p>After nearly a two years gap i am filling up my blog with something for my readers who have been disappointed with no updates at all. Recently i was sitting with my friend Nandan and discussing some core concepts of programming and where would the web end up totally. I had discussion with ma amigos and my big brother over this, but eventually he is a management guy who just worries about the sales. But it’s a lot of work to rewrite everything in sight and I suppose managers are reluctant to invest in that just because something or other is cool.</p>
<p><a href="http://vinothbabu.com/wp-content/uploads/2012/03/node2.jpg"><img class="aligncenter size-medium wp-image-427" title="node" src="http://vinothbabu.com/wp-content/uploads/2012/03/node2-300x119.jpg" alt="" width="300" height="119" /></a></p>
<p><strong>LAMP, DOT NET and Java is DEAD or would eventually die someday</strong></p>
<p>LAMP architectures are dead because few web applications want to ship full payloads of markup to the client in response to a small event; they want to update just a fragment of the DOM, using Javascript. AJAX achieved this, but when your server-side LAMP templates are 10% HTML and 90% Javascript, it’s clear that you’re doing it wrong. Since the birth which happened two decades ago, there has been fundamental shifts in the web with content, protocols, servers and clients. Together we can mark as three ages of the web.</p>
<p>It seems that every few years a new technology comes along which gets a bunch of people excited and they want to rewrite the world in this new thing because it’s so cool. But it’s a lot of work to rewrite everything in sight and I suppose managers are reluctant to invest in that just because something or other is cool. On the other hand the LAMP stack has serious architectural problems and PHP is a horrible language. There are a few things which event driven servers do a zillion times better than LAMP – research the beginnings of COMET and you see people describing a need for which Node.js is the perfect solution.</p>
<p><strong>What is Node.js?</strong></p>
<p>Basically, it is a lightweight framework wrapped around Google’s V8 JavaScript Engine. V8 is the JavaScript engine that powers Google Chrome, their open source Web Browser. Another part of Node.JS is that it is event based, which can make is very quick and efficient.<br />
I’ve been tinkering with Node.JS for a couple of weeks, and it is very interesting and has a lot of potential. It’s unique scoping with JavaScript and event-based methodology makes certain things easy to accomplish that are more difficult in other traditional tools. There are some pretty cool libraries for Node.JS like Socket.IO, a library to support multiple transports using feature detection. So if your browser supports WebSocket or Adobe Flash Socket, it will use that, or AJAX long polling and multipart streaming, or even the Forever Iframe technique. So your application will use which ever type of communication is most efficient.</p>
<p><strong>Node.js &#8211; the Future</strong></p>
<p>The JavaScript age is about event streams. Modern web pages are not pages, they are event-driven applications through which information moves. The core content vessel of the web &#8212; the document object model &#8212; still exists, but not as HTML markup. The DOM is an in-memory, efficiently-encoded data structure generated by JavaScript.</p>
<p>The one thing that worries me about Node.JS is that even though you&#8217;re locked in this jail with no easily available blocking operations, you still need to know (arguably advanced) knowledge regarding how to debug race conditions and how an event loop works (and even how a call stack works due to recursive callbacks smashing the stack). Because of that, the control flow is very strange and mind-bending to people that have been writing C for 20 years, and even junior engineers that are just getting into programming (unless they are web-focused engineers that are used to jQuery-esque continuation passing style). This is pretty much proven by all of the arguments and libraries popping out of the woodworks to deal with control flow in some elegant way (fibers, chaining, etc).</p>
]]></content:encoded>
			<wfw:commentRss>http://vinothbabu.com/2012/03/01/a-web-that-is-not-a-global-digital-library-but-a-global-digital-nervous-system-node-js-the-future/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>UPDATE and INSERT differences in syntax is an inconvenience</title>
		<link>http://vinothbabu.com/2010/05/08/update-and-insert-differences-in-syntax-is-an-inconvenience/</link>
		<comments>http://vinothbabu.com/2010/05/08/update-and-insert-differences-in-syntax-is-an-inconvenience/#comments</comments>
		<pubDate>Sat, 08 May 2010 17:23:34 +0000</pubDate>
		<dc:creator>Sachin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[mys]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[queries]]></category>

		<guid isPermaLink="false">http://vinothbabu.com/?p=288</guid>
		<description><![CDATA[An associative array is the conventional workaround of the coding world.. In an associative array, we can associate any key or index we want with each value. [codesyntax lang="php"] &#60;?php include('escape_arr.php'); //create an array $sets=array( 'userid'=&#62;$userid, 'mimetype'=&#62;$mimetype, 'bytesize'=&#62;$bytesize, 'filename'=&#62;$filename, 'extension'=&#62;$ext, 'lastmodified'=&#62;time(), 'height'=&#62;$height, 'width'=&#62;$width, 'binarydata'=&#62;$data ); list($sets,$cols,$values)=escape_arr($sets); $insert_sql="INSERT INTO `avatars` ".implode(',',$cols)." VALUES(".implode(',',$values).")"; $update_sql="UPDATE `avatars` SET ".implode(',',$sets)." [...]]]></description>
			<content:encoded><![CDATA[<p>An associative array is the conventional workaround of the coding world.. In an associative array, we can associate any key or index we want with each value.<span id="more-288"></span></p>
<p>[codesyntax lang="php"]</p>
<pre>&lt;?php

include('escape_arr.php');
//create an array
$sets=array(
'userid'=&gt;$userid,
'mimetype'=&gt;$mimetype,
'bytesize'=&gt;$bytesize,
'filename'=&gt;$filename,
'extension'=&gt;$ext,
'lastmodified'=&gt;time(),
'height'=&gt;$height,
'width'=&gt;$width,
'binarydata'=&gt;$data
);
list($sets,$cols,$values)=escape_arr($sets);
$insert_sql="INSERT INTO `avatars` ".implode(',',$cols)." VALUES(".implode(',',$values).")";
$update_sql="UPDATE `avatars` SET ".implode(',',$sets)." WHERE userid=$userid LIMIT 1";

if(!$avatar_exists)
{
$result=mysql_query($insert_sql) or die("Insert query failed!");
}else{
$result=mysql_query($update_sql) or die("Update query failed!");
}
echo 'Avatar updated!';
?&gt;
escape_arr.php
&lt;?php
function escape_arr($arr)
{
$out=array();
$sets=array();
foreach ($arr as $key =&gt; $value)
{
$k="`$key`";
$v="'".mysql_real_escape_string($value)."'";
$out[$k] = $v;
$sets[]="$k = $v";
}
return array($sets, array_keys($out), array_values($out));
}
?&gt;</pre>
<p>[/codesyntax]</p>
<p><strong>escape_arr.php</strong></p>
<p>[codesyntax lang="php"]</p>
<pre>&lt;?php
function escape_arr($arr)
{
$out=array();
$sets=array();
foreach ($arr as $key =&gt; $value)
{
$k="`$key`";
$v="'".mysql_real_escape_string($value)."'";
$out[$k] = $v;
$sets[]="$k = $v";
}
return array($sets, array_keys($out), array_values($out));
}
?&gt;</pre>
<p>[/codesyntax]</p>
<p>Although the above code is elegant, an associative array forces me to think of my queries as objects. After putting my head to work, I found that a blank INSERT could put my mind at ease.</p>
<blockquote><p>[codesyntax lang="php"]</p>
<pre>&lt;?php
$sql="INSERT INTO `tbl` (`id`) VALUES(NULL);";
$sql.="UPDATE `tbl` SET `f1`='v1',`f2`='v2' WHERE id = LAST_INSERT_ID();";
mysql_query($sql) or die(mysql_error());
?&gt;</pre>
<p>[/codesyntax]</p></blockquote>
<p>Conclusion: both solutions are equally valid. You may also hard-code your queries but such coding is bad practice. There are many drawbacks for using this approach.</p>
<ol>
<li>First of all, such strings can span several lines of code and make your PHP file hard to read and understand.</li>
<li>Secondly each one of your strings becomes a debugging red-flag.</li>
<li>And thirdly if you ever decided to add a new field to your table &#8211; say “birthdate” &#8211; then you will have to run through each of your hard-coded strings and add-in a field name and value for each of the strings respectively. Each string will then have an added chance for a syntax errors and make debugging harder. And since such coding practice lacks versatility, a simple task such as adding a “birthdate” field later in the future can become a nightmare.</li>
</ol>
<p>One could also use REPLACE. However I strongly advise against using this approach since it reserves the potential to wipe your database clean due to its DELETE + INSERT logic. A better solution would be INSERT … ON DUPLICATE KEY UPDATE. However this query doesn’t address my syntax difference emphasis.</p>
]]></content:encoded>
			<wfw:commentRss>http://vinothbabu.com/2010/05/08/update-and-insert-differences-in-syntax-is-an-inconvenience/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Linklist and ArrayList</title>
		<link>http://vinothbabu.com/2010/03/23/linklist-and-arraylist/</link>
		<comments>http://vinothbabu.com/2010/03/23/linklist-and-arraylist/#comments</comments>
		<pubDate>Tue, 23 Mar 2010 13:07:17 +0000</pubDate>
		<dc:creator>Sachin</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://vinothbabu.com/?p=227</guid>
		<description><![CDATA[Today i was turning back towards Linklist and a question dropped in my mind is when to use Linklist and When to use ArrayList. They both are different in implementations. LinkedList implements it with a doubly-linked list. ArrayList implements it with a dynamically resizing array. If you take up Linklist you can walk the lists [...]]]></description>
			<content:encoded><![CDATA[<p>Today i was turning back towards Linklist and a question dropped in my mind is when to use Linklist and When to use ArrayList.<span id="more-227"></span></p>
<p>They both are different in implementations. LinkedList implements it with a doubly-linked list. ArrayList implements it with a dynamically resizing array. If you take up Linklist you can walk the lists forward or backwards, but grabbing an element in the middle takes time which depeneds upon your size of the list.</p>
<p>ArrayLists allows you random access, but adding and removing from anywhere smells your time which requires shifting all the latter elements. When you add more elements more than the capacity, a new array twice of the default size is allocated and the older array is copied to newer one.</p>
<p><strong>When should i use LinkedList?</strong></p>
<ol>
<li> When you need efficient removal in between elements or at the start.</li>
<li> When you don&#8217;t need random access to elements, but can live with iterating over them one by one</li>
</ol>
<p><strong><br />
When should i use ArrayList?</strong></p>
<ol>
<li> When you need random access to elements (&#8220;get the nth. element&#8221;)</li>
<li> When you don&#8217;t need to remove elements from between others. It&#8217;s possible but it&#8217;s slower since the internal backing-up array needs to be reallocated.</li>
<li> Adding elements is amortized constant time (meaning every once in a while, you pay some performance, but overall adding is instantly done)</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://vinothbabu.com/2010/03/23/linklist-and-arraylist/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

