<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>My Ruminations on Software</title>
	<atom:link href="http://lispmachine.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://lispmachine.wordpress.com</link>
	<description></description>
	<lastBuildDate>Wed, 03 Apr 2013 06:06:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='lispmachine.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://1.gravatar.com/blavatar/18571c40883a523173a8d10ae8708cb0?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>My Ruminations on Software</title>
		<link>http://lispmachine.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://lispmachine.wordpress.com/osd.xml" title="My Ruminations on Software" />
	<atom:link rel='hub' href='http://lispmachine.wordpress.com/?pushpress=hub'/>
		<item>
		<title>The Programmer Hierarchy</title>
		<link>http://lispmachine.wordpress.com/2013/03/17/the-programmer-hierarchy/</link>
		<comments>http://lispmachine.wordpress.com/2013/03/17/the-programmer-hierarchy/#comments</comments>
		<pubDate>Sun, 17 Mar 2013 05:39:26 +0000</pubDate>
		<dc:creator>arnuld</dc:creator>
				<category><![CDATA[community]]></category>
		<category><![CDATA[Hacking]]></category>
		<category><![CDATA[Dmitry Ignatiev]]></category>
		<category><![CDATA[language comparison]]></category>
		<category><![CDATA[luke welling]]></category>
		<category><![CDATA[programmer comparison]]></category>
		<category><![CDATA[programmer hierarchy]]></category>

		<guid isPermaLink="false">http://lispmachine.wordpress.com/?p=745</guid>
		<description><![CDATA[Recently I came across a chart created by Luke Welling showing programmer hierarchy. Seems like Luke Welling has pencilled facts: I googled for &#8216;Programmer Hierarchy&#8217; and came across another chart by Dmitry Ignatiev. Thougdt I needed to share this too Copyright © 2013 Arnuld Uttre, Village &#8211; Patti, P.O &#8211; Manakpur, Tehsil &#8211; Nangal, Distt. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lispmachine.wordpress.com&#038;blog=1624923&#038;post=745&#038;subd=lispmachine&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p align="justify">Recently I came across a chart created by <a href="http://lukewelling.com/2006/08/03/java-programmers-are-the-erotic-furries-of-programming/">Luke Welling</a> showing programmer hierarchy. Seems like Luke Welling has pencilled facts:</p>
<p style="text-align:center;"><a href="http://lispmachine.files.wordpress.com/2013/03/chart-luke-welling.jpg"><img class="aligncenter size-large wp-image-747" alt="chart-Luke-Welling" src="http://lispmachine.files.wordpress.com/2013/03/chart-luke-welling.jpg?w=550&#038;h=796" width="550" height="796" /></a></p>
<p align="justify">I googled for &#8216;Programmer Hierarchy&#8217; and came across another chart by <a href="http://love5an.livejournal.com/352437.html">Dmitry Ignatiev</a>. Thougdt I needed to share this too</p>
<p><a href="http://lispmachine.files.wordpress.com/2013/03/chart-dmitry-ignatiev.jpg"><img class="aligncenter size-large wp-image-751" alt="chart-Dmitry-Ignatiev" src="http://lispmachine.files.wordpress.com/2013/03/chart-dmitry-ignatiev.jpg?w=550&#038;h=693" width="550" height="693" /></a></p>
<p align="justify"><em><br />
Copyright © 2013 Arnuld Uttre, Village &#8211; Patti, P.O &#8211; Manakpur, Tehsil &#8211; Nangal, Distt. &#8211; Ropar, Punjab (INDIA). Copyright does not apply to charts shown here. Please contact authors for copyright terms of respective charts.<br />
<br />
Verbatim copying and distribution of this entire article are permitted worldwide, without royalty, in any medium, provided this notice, and the copyright notice, are preserved.<br />
</em></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/lispmachine.wordpress.com/745/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/lispmachine.wordpress.com/745/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lispmachine.wordpress.com&#038;blog=1624923&#038;post=745&#038;subd=lispmachine&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://lispmachine.wordpress.com/2013/03/17/the-programmer-hierarchy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/f45bcf34b0e8389c9c6aaac3249f9e4d?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">arnuld</media:title>
		</media:content>

		<media:content url="http://lispmachine.files.wordpress.com/2013/03/chart-luke-welling.jpg?w=550" medium="image">
			<media:title type="html">chart-Luke-Welling</media:title>
		</media:content>

		<media:content url="http://lispmachine.files.wordpress.com/2013/03/chart-dmitry-ignatiev.jpg?w=550" medium="image">
			<media:title type="html">chart-Dmitry-Ignatiev</media:title>
		</media:content>
	</item>
		<item>
		<title>Why every C or C++ programmer must know pointers</title>
		<link>http://lispmachine.wordpress.com/2013/03/04/why-every-c-programmer-must-know-pointers/</link>
		<comments>http://lispmachine.wordpress.com/2013/03/04/why-every-c-programmer-must-know-pointers/#comments</comments>
		<pubDate>Mon, 04 Mar 2013 03:30:46 +0000</pubDate>
		<dc:creator>arnuld</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Hyderabad]]></category>
		<category><![CDATA[Hyderabad local train]]></category>
		<category><![CDATA[MMTS]]></category>

		<guid isPermaLink="false">http://lispmachine.wordpress.com/?p=728</guid>
		<description><![CDATA[Some computer science engineering students once asked me why it is so important to know about pointers in C and C++. They complained (and almost every computer programmer in industry complains) that pointers are so hard to learn and they can&#8217;t see why they should work so hard. I was travelling in MMTS (Local Train [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lispmachine.wordpress.com&#038;blog=1624923&#038;post=728&#038;subd=lispmachine&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p align="justify">
Some computer science engineering students once asked me why it is so important to know about pointers in C and C++. They complained (and almost every computer programmer in industry complains) that pointers are so hard to learn and they can&#8217;t see why they should work so hard. I was travelling in <a href="http://en.wikipedia.org/wiki/Multi-Modal_Transport_System_%28Hyderabad%29"> MMTS </a> (Local Train Service in Hyderabad). MMTS service uses several trains and compartments in few trains have a LED-Box where the name of railway station is displayed before train is about to reach the same. And here is how it shows railway station name sometimes :
</p>
<p><img src="http://lispmachine.files.wordpress.com/2013/03/mmts_photo0038.jpg?w=550" alt="" /><br />
<br />
<img src="http://lispmachine.files.wordpress.com/2013/03/mmts_photo0036.jpg?w=550" alt="" /><br />
<br />
<img src="http://lispmachine.files.wordpress.com/2013/03/mmts_photo0035.jpg?w=550" alt="" /></p>
<p align="justify">
Do you see the name there ? Those letters which look like boxes and Ys with tildes above on them are actually memory corruption rather than English language. Now I can guess the program must have been written in a language where programmer had to do memory management himself. Since it is a LED-Box, it must be a C or C++ prgram in embedded environment. This is a real-life result of not knowing how to respect memory constraints. My best guess is either prgroammer has some dangling-pointer in his code or he must have an array-overrun (a.k.a Buffer-Overflow). Imagine these situations:</p>
<ul>
<li> Your C++ program does financial transactions for some company e.g. distributing salaries to its employees and your program uses a dangling-pointer to set salary amounts. With this dangling-pointer the CEO might get salary of a blue-collar worker or vice-versa.  </li>
<li> Your C program is used in controlling a weapon like firing, pausing, continuous 20 seconds firing etc. With buffer-overflow gun may fire for 20 seconds continuously when you press pause.    </li>
<li> Imagine your C program controlls a satellite orbiting around Earth being controlled from base station somewhere on Earth. Memory corruption can cause satellite to move left instead of right or even stop its motion or may burn all of its fuel while it orbits non-stop at full speed around earth.  </li>
</ul>
<p align="justify">
These are some of the not so serious consequences of not knowing pointers. So, if you want to write correct C and C++ code, learn howe to use pointers. Yes, they are hard to learn and more than hardness, pointers requires experience. It is a very useful skill that will reduce debugging sessions from days to hours. Kernighen and Ritchie said in the preface of their book &#8220;<a href="http://en.wikipedia.org/wiki/The_C_Programming_Language">The C Programming Language</a>&#8221; printed in 1978 that C wears well as one&#8217;s experiecne with it grows. When 2nd edition was printed in 1988 (affectionately known as K&amp;R2) they said they still feel same about C with decade more experience. They had a point (they had pointers in those 10 years <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  ). Experience makes a good C programmer and you achieve that by following the footsteps of masters. In order te be a brilliant C programmer, You need to follow brilliant masters. Start with <a href="http://c-faq.com/"> c-faq.com </a>
</p>
<p align="justify">
<em><br />
Copyright © 2013 Arnuld Uttre, Village &#8211; Patti, P.O &#8211; Manakpur, Tehsil &#8211; Nangal, Distt. &#8211; Ropar, Punjab (INDIA).<br />
Verbatim copying and distribution of this entire article are permitted worldwide, without royalty, in any medium, provided this notice, and the copyright notice, are preserved.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/lispmachine.wordpress.com/728/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/lispmachine.wordpress.com/728/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lispmachine.wordpress.com&#038;blog=1624923&#038;post=728&#038;subd=lispmachine&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://lispmachine.wordpress.com/2013/03/04/why-every-c-programmer-must-know-pointers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/f45bcf34b0e8389c9c6aaac3249f9e4d?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">arnuld</media:title>
		</media:content>

		<media:content url="http://lispmachine.files.wordpress.com/2013/03/mmts_photo0038.jpg" medium="image" />

		<media:content url="http://lispmachine.files.wordpress.com/2013/03/mmts_photo0036.jpg" medium="image" />

		<media:content url="http://lispmachine.files.wordpress.com/2013/03/mmts_photo0035.jpg" medium="image" />
	</item>
		<item>
		<title>GNOME 3 &#8211; Reincarnation of User Interface</title>
		<link>http://lispmachine.wordpress.com/2013/01/17/gnome-3-reincarnation-of-user-interface/</link>
		<comments>http://lispmachine.wordpress.com/2013/01/17/gnome-3-reincarnation-of-user-interface/#comments</comments>
		<pubDate>Thu, 17 Jan 2013 03:38:03 +0000</pubDate>
		<dc:creator>arnuld</dc:creator>
				<category><![CDATA[community]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[free software]]></category>
		<category><![CDATA[gnome]]></category>
		<category><![CDATA[window manager]]></category>

		<guid isPermaLink="false">http://lispmachine.wordpress.com/?p=710</guid>
		<description><![CDATA[I am using Stumpwm from last 2 years and a month back I came to know about GNOME 3. Little bit googling will tell you the kind of harsh and brutal criticism GNOME 3 developers have received for their new ideas. MATE and Cinnamon have come out of that criticism to preserve traditional desktop look [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lispmachine.wordpress.com&#038;blog=1624923&#038;post=710&#038;subd=lispmachine&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p align="justify">I am using Stumpwm from last 2 years and a month back I came to know about GNOME 3. Little bit googling will tell you the kind of harsh and brutal criticism GNOME 3 developers have received for their new ideas. MATE and Cinnamon have come out of that criticism to preserve traditional desktop look and feel. So what is this new interface in GNOME 3 ? Well you can read HIG (Human Interface Guidelines) of GNOME project, I am here to talk about practical aspects not mentioned anywhere but have come out of my own experience of using GNOME 3 for few minutes. I order to explain that you need to know something about dektop and window managers.</p>
<p align="justify">I am not a fan of desktop. I focus on work I need to do and then find methods to accomplish the task in an effcient and faster way without wasting time and energy. This way of thinking had pushed me from Desktop to virtual WMs (window manager), virtual and floating WMs and then to pure tiling WMs. Hence I travelled from KDE, GNOME and Xfce few years back to Fvwm, windowmaker and then to wmii, xmonad and now to Stumpwm and Ratpoison. Still I keep an eye on how different technologies develop in software world and that is how I came to know about new developments in GNOME 3. As per the viewpoint of an average user there are two kinds of interfaces you get on computer: an ugly, hard to use, anti-user <em>black command line</em> and a beautiful, cozy, pleasing and user-friendly <em> graphical-interface a.k.a desktop </em>. Almost all average &#8220;Joes&#8221; love desktop as it works faster for them (in fact, it is actually opposite). Come to Linux world, we have desktops too, unlike all those average Joes believing otherwise. A desktop usually has menus, folders, windows, icons, supports atractive features like drag and drop, openeing a document/file/folder by double-clicking etc. On Command-Line you have to type commands to do anything and you don&#8217;t get icons, windows, menus and or any fancy stuff requiring graphical interface. These are two opposing ways average Joe thinks computers are. Come to Linux world again, here we have <a href="http://en.wikipedia.org/wiki/X_Window_System">X Window System</a> on the top of which a desktop runs. X Window System is <em>the first graphical interface</em>. What I mean by that ? X is the base on the top of which any graphical interface (or GUI) runs as far as Linux is concerned. While Windows XP users only have one kind of desktop, Linux has several as per the likes and needs of the users, GNOME, KDE and Xfce etc. This kind of design gives a lot of flexibility, power and control to Linux users. Like I mentioned earlier a desktop environment consists of several components. Along with menus, icons, panel etc., it has a window manager and a file manager (check <a href="http://en.wikipedia.org/wiki/Desktop_environment"> Wikipedia </a> for full list). What most users want is to do the necessary work and then get on with life e.g one person wants to write an email and hence uses a browser, one wants to watch a movie, one wants to his office work and others just want to browse the internet and many want to do all of these (and that includes me too). So, they need something which is simple, helps them do tasks in an effective way and finishes tasks fast. That was my motto and that pushed me towards Linux after I was mentally tortured, made insane and almost killed psychologically by Windows&#8217;s virus problems, frequent slow downs, weekly-installations and loads of other crap that every Windows user has experienced. Coming back to Linux, now if there is a way to finish the tasks faster then that means current way of doing work must be inferior because if you already doing what is best then there is no way you need anything else. There is another way of saying this: <strong>you are doing tasks in an effective way and there is always room for improvement and there is lot of room if what you are doing is being done same way from a decade. </strong>. I think that is exactly what GNOME team was thinking when they were lying the foundation for GNOME 3. What is this new foundation ? For that I need to explain tiling WMs. In a tiling WM (I use StumpWM) there is no minimize/maximize/resize when it comes to your windows (when you open an application e.g a video player then it opens in a window. If you open 2 applications e.g. video player (lets say VLC) and a browser (lets say Firefox) then you got 2 windows, Firefox window and VLC window). In a usual desktop you can minimize/maximize/resize any window and each window will have buttons to do that including a button, which looks like leter &#8216;x&#8217;, to close the window, usually these 3 buttons are in upper right corner of a window). A tiling WM does not provide any of these facilities, windows will always be maximized and no buttons. Tiling WMs are based on concept that a user wastes too much time in minimizing/maximizing/resizing windows, changing their locations and sizes across the screen and they are right. Screen is divided into panes, like a <a href="http://en.wikipedia.org/wiki/Paned_window">Paned-Window</a>, and you will have one window in one pane. There are no menus, no icons, almost nil mouse support (yes, no left-right clicks and tricks), tiling WMs are keyboard driven. You want any application then know its name and run it as a command and you will not waste your time in trying to find it inside menus or searching pseudonym driven icons/shortcuts and finding where that shortcut points to when you accidentlly loose one. When you sit in front of your computer then most of your attention should be on your work, not on distractions and pure tiling WMs make you do exactly that.</p>
<p align="justify">Sadly almost all people use desktops and waste their time and energy on icons, menus and mouse-clicks. Whole software industry is based and competing on who gives more desktop-eye-candy. Like high-school kids, users keep on eating those candies and spoil their teeth (brain in our case). Tiling WMs have a short learning curve and that takes some time (toook me a month to replace my desktop with StumpWM) and not everyone likes empty screens and black backgrounds. So, something was needed which could bring the usability of tiling WMs and pleasing-candy feelings of desktop under one roof and that is what GNOME 3 did. you can&#8217;t minimize a window in GNOME 3 ()it does not have those buttons) and it has no panel. Each Window is maximized, It does not have right-click menu on desktop. GNOME 3 does not have a menu and you can still find list of all of your applications and settings there, it does not have Home icon but it possesses a file manager for your tasks. GNOME 3 has been criticized by lot of people, even <a href="http://bit.ly/Z4B7Wd">Linus Torvalds finds it a mess </a>. I say GNOME 3 will change the way desktop will be looked at and used, GNOME 3 has redefined the word <em>usability</em> and it has put that word back into desktop. It has combines the effectivemess, speed and usability of tiling WMs and user-frindliness of desktops. There are many desktop UIs already developed for your desktop computers and many will be developed in future. The only difference is inbetween past and future desktop UIs lies GNOME 3. GNOME 3 will pave the way for future desktop UIs. I am using computers from last 10 years and WMs from last 5 years and in last 3 years I tried to use different desktops but could never use any for more than 2 minutes. Now I am using GNOME 3 from 2 weeks because GNOME 3 is not just a desktop, it is the reincarnation of desktop. I see that desktop is moving from traditional way (eye-candy) towards more usable way (tiling WMs) and GNOME 3 team has shown us the way. GNOME 3 team is decade ahead in innovation, is solving practical problems and I think it needs a well-done pat-on-the-back from me at least for their great work <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p align="justify"> <a href="http://lispmachine.files.wordpress.com/2013/01/well-done-gnome-31.png"><img class="aligncenter size-medium wp-image-722" alt="well-done-gnome-3" src="http://lispmachine.files.wordpress.com/2013/01/well-done-gnome-31.png?w=300&#038;h=266" width="300" height="266" /></a></p>
<p align="justify"><em><br />
Copyright © 2013 Arnuld Uttre, Village &#8211; Patti, P.O &#8211; Manakpur, Tehsil &#8211; Nangal, Distt. &#8211; Ropar, Punjab (INDIA). Image produced above is a modified work of art (originally taken from Wikipedia) and hence released under the license mentioned at <a href="http://en.wikipedia.org/wiki/Thumbs_signal"> http://en.wikipedia.org/wiki/Thumbs_signal </a> </em></p>
<p>Verbatim copying and distribution of this entire article are permitted worldwide, without royalty, in any medium, provided this notice, and the copyright notice, are preserved.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/lispmachine.wordpress.com/710/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/lispmachine.wordpress.com/710/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lispmachine.wordpress.com&#038;blog=1624923&#038;post=710&#038;subd=lispmachine&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://lispmachine.wordpress.com/2013/01/17/gnome-3-reincarnation-of-user-interface/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/f45bcf34b0e8389c9c6aaac3249f9e4d?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">arnuld</media:title>
		</media:content>

		<media:content url="http://lispmachine.files.wordpress.com/2013/01/well-done-gnome-31.png?w=300" medium="image">
			<media:title type="html">well-done-gnome-3</media:title>
		</media:content>
	</item>
		<item>
		<title>C++ new() operator</title>
		<link>http://lispmachine.wordpress.com/2012/06/28/c-new-operator/</link>
		<comments>http://lispmachine.wordpress.com/2012/06/28/c-new-operator/#comments</comments>
		<pubDate>Thu, 28 Jun 2012 13:47:44 +0000</pubDate>
		<dc:creator>arnuld</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[C language]]></category>
		<category><![CDATA[programmer]]></category>

		<guid isPermaLink="false">http://lispmachine.wordpress.com/?p=695</guid>
		<description><![CDATA[I was working on adding some features to a software written as a mixture of C and C++ and I came to realize many C++ programmers write C in C++. Take a look at this: Everything looks fine and g++ (on RHEL 5) even compiles/runs with flags (-ansi -pedantic -Wall -Wextra) and without any warning/error. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lispmachine.wordpress.com&#038;blog=1624923&#038;post=695&#038;subd=lispmachine&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p align="justify">
I was working on adding some features to a software written as a mixture of C and C++ and I came to realize many C++ programmers write C in C++. Take a look at this:</p>
<pre class="brush: cpp; title: ; notranslate">
#include &lt;iostream&gt;
#include &lt;new&gt;

int main()
{
  char * t = new char[1];

  if(!t) 
    {
      printf(&quot;Memory Exhausted\n&quot;);
      exit(EXIT_FAILURE);
    }

  t[0] = 'A';

  printf(&quot;t[0] = %c\n&quot;, t[0]);
  return 0;
}
</pre>
</p>
<p align="justify">
Everything looks fine and g++ (on RHEL 5) even compiles/runs with flags (-ansi -pedantic -Wall -Wextra) and without any warning/error. Program just seems to be technically correct (which it is seems like but isn&#8217;t) and prints the value inside array as expected. Now let us take a more basic look at this. Why we are using printf() in a C++ program when C++ has its own standard library ? The program we have writen is actually C in C++. It is like using a powerful mechanism and throwing all the powerful tools/methods away because you don&#8217;t want to know about them. Many industrial programmers don&#8217;t want to know about it because life goes on fine without knowing about it and they are still earning much higer salaries without knowing it (and they will keep on increasing their monthly income by impressing HR guys with a bag of languages and big projects on their Resumes). Hence Why bother ?  Wrong reasons. If you are really looking for laziness then find it elsewhere because laziness equals to the amount of bugs in programming. Rewrite it the C++ way:</p>
<pre class="brush: cpp; title: ; notranslate">
#include &lt;iostream&gt;
#include &lt;new&gt;

int main()
{
  char * t = new char[1];

  if(!t) 
    {
      std::cerr &lt;&lt; &quot;Memory Exhausted&quot; &lt;&lt; std::endl;
      exit(EXIT_FAILURE);
    }

  t[0] = 'A';
  std::cerr &lt;&lt; &quot;t[0] = &quot; &lt;&lt; t[0] &lt;&lt; std::endl;

  return 0;
}
</pre>
</p>
<p align="justify">
It is still not C++. What we call it now is a mixture of C and C++ provided the programmer does not know about C++ much. He was basically a C programmer and was either forced to use C++ compiler or was too lazy to know C++.  Again it compiles/runs fine as it looks technically correct. check out <em>new</em> operator in section 18.6.1 of current C++ standard (you can check out draft of the standard, just google for N3337.pdf). <em>new</em> does not return NULL, hence the check is wrong. <em>new</em> throws bad_alloc() if it can&#8217;t allocate memory. Hence the technically correct version looks like this:</p>
<pre class="brush: cpp; title: ; notranslate">
#include &lt;iostream&gt;
#include &lt;new&gt;

int main()
{
  char * t;

  try { t = new char[1]; }
  catch(bad_alloc)
    {
      std::cerr &lt;&lt; &quot;Memory Exhausted&quot; &lt;&lt; std::endl;
      exit(EXIT_FAILURE);
    }
  
  return 0;
}
</pre>
</p>
<p align="justify">
This will never compile. Why ? Because you did not mention where <em>bad_alloc</em> is coming from. It is in standard library, hence you need to use <em>std::bad_alloc</em>. If you think you simply dump the whole standard namespac by using <em>using namespace std</em> in there, then you really need to read <a href="http://www.parashift.com/c++-faq-lite/">C++ FAQs</a> before writing C++ programs any further. You need to think why I am writing <em>std::cout</em> instead of usual <em>cout</em> used by typical Indian programmers. Let us try one more time:</p>
<pre class="brush: cpp; title: ; notranslate">
#include &lt;iostream&gt;
#include &lt;new&gt;

int main()
{
  char * t;

  try { t = new char[1]; }
  catch(std::bad_alloc)
    {
      std::cerr &lt;&lt; &quot;Memory Exhausted&quot; &lt;&lt; std::endl;
      exit(EXIT_FAILURE);
    }

  t[0] = 'A';
  std::cout &lt;&lt; &quot;t[0] = &quot; &lt;&lt; t[0] &lt;&lt; std::endl;

  return 0;
}
</pre>
</p>
<p align="justify">
This seems like pure C++. Yes, it is. Sure ? We still have one general programmig problem remaining to be solved. If you call exit() then you are not being practical, e.g. you wrote a client which connects to a server.  One of the users of your software is connected and suddenly he is out of memory, then you program  will just disconnect without saying <em>a bye</em>. Server will not like it and may log it as an error or will wait for an automatic timeout.
</p>
<p align="justify">
That was a general exmaple, let us look at more technical example. When a game adjusts your resolution to 640&#215;480 and resets it back to normal (say 1280&#215;1024), it will call destructor on 640&#215;480 in resetting but it will not do so because exit() will not call the destructor, you will get stuck in a low resolution screen. It happens when some games crash without throwing an exception and rolling back the stack. So what do you do ? Let us try one last time to write pure C++ code <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<pre class="brush: cpp; title: ; notranslate">
#include &lt;iostream&gt;
#include &lt;new&gt;

int main()
{
  char * t;

  try { t = new char[1]; }
  catch(std::bad_alloc)
    {
      std::cerr &lt;&lt; &quot;Memory Exhausted&quot; &lt;&lt; std::endl;
      return EXIT_FAILURE;
    }

  t[0] = 'A';
  std::cout &lt;&lt; &quot;t[0] = &quot; &lt;&lt; t[0] &lt;&lt; std::endl;

  return 0;
}

</pre>
</p>
<p align="justify">
<strong>NOTE</strong>:  There is still a way if you want to check for NULL (instead of catch()ing an exception). You can use the <em>nothrow</em> version of <em>new</em> operator which returns a NULL pointer instead of throwing an exception but you have to mention it explicitly.
</p>
<p align="justify"> &nbsp;</p>
<p><em><br />
Copyright © 2012 Arnuld Uttre, Village &#8211; Patti, P.O &#8211; Manakpur, Tehsil &#8211; Nangal,  Distt. &#8211; Ropar, Punjab (INDIA)</p>
<p>Verbatim copying and distribution of this entire article are permitted worldwide, without royalty, in any medium, provided this notice, and the copyright notice, are preserved.<br />
</em></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/lispmachine.wordpress.com/695/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/lispmachine.wordpress.com/695/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lispmachine.wordpress.com&#038;blog=1624923&#038;post=695&#038;subd=lispmachine&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://lispmachine.wordpress.com/2012/06/28/c-new-operator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/f45bcf34b0e8389c9c6aaac3249f9e4d?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">arnuld</media:title>
		</media:content>
	</item>
		<item>
		<title>Queue (singly linked list)</title>
		<link>http://lispmachine.wordpress.com/2012/06/21/queue-singly-linked-list/</link>
		<comments>http://lispmachine.wordpress.com/2012/06/21/queue-singly-linked-list/#comments</comments>
		<pubDate>Thu, 21 Jun 2012 11:32:55 +0000</pubDate>
		<dc:creator>arnuld</dc:creator>
				<category><![CDATA[enqueue/dequeue]]></category>
		<category><![CDATA[Linked List]]></category>
		<category><![CDATA[push/pop]]></category>
		<category><![CDATA[Queue]]></category>
		<category><![CDATA[queue in c]]></category>
		<category><![CDATA[stack]]></category>

		<guid isPermaLink="false">http://lispmachine.wordpress.com/?p=687</guid>
		<description><![CDATA[After a long time I created a Queue(). Can you see what is wrong with it ? Just compile the program, can you spot at least 3 problems without running it ? There are 3 problems: Dequeue operation is O(N). In Queue, addition and deletion are O(1). Can you see why deletion is O(N) here [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lispmachine.wordpress.com&#038;blog=1624923&#038;post=687&#038;subd=lispmachine&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p align="justify">
After a long time I created a Queue(). Can you see what is wrong with it ? Just compile the program, can you spot at least 3 problems without running it ?
</p>
<p align="justify">
<pre class="brush: cpp; title: ; notranslate">
/* A queue implementation with the operations that I need:
 *  (1) Add an element to the front (head) of the queue
 *  (2) Remove an element from rear (tail) of the queue
 *  (2) remove an element with a unique ID (string constant)
 *  (3) compare 2 elements (string comparison) 
 *  (4) print queue
 *
 * VERSION 0.0
 */

#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;string.h&gt;

enum { SIZE_ID = 100, SIZE_ARR = 20, REPS = 3 };

struct myQ
{
  char id[SIZE_ID+1];
  struct myQ* next;
};

struct myList
{
  struct myQ* head;
  struct myQ* tail;
};



struct myList* allocmyList(void);
int enqueue(struct myList* s, const char* id);
struct myQ* dequeue(struct myList** s); 
void removeElement(struct myList* s, const char* id);
struct myQ* searchElement(struct myList* s, const char* is, struct myQ** pr);
void deleteElement(struct myList* s, struct myQ* q, struct myQ* prev);
void printQ(struct myList* s);


int main(void)
{
  struct myList* s = allocmyList();
  int i;
  for(i = 0; i &lt; REPS; ++i)
    {
      int r;
      char arrc[SIZE_ARR+1];
      r = sprintf(arrc, &quot;%d&quot;, i);
      if(0 &gt; r) 
	{
	  printf(&quot;ERROR-SPRINF() = %d\n&quot;, r);
	}
      else
	{
	  enqueue(s, arrc);
	}
      printf(&quot;s-&gt;head = %p, s-&gt;tail = %p\n&quot;, (void*)s-&gt;head, (void*)s-&gt;tail);
    }
 
  printQ(s);
  dequeue(&amp;s);
  printQ(s);
  free(s);

  return 0;
}


int enqueue(struct myList* s, const char* id)
{
  struct myQ *p;
  if(NULL == s || NULL == id) return -1;
  p = malloc(1 * (sizeof *p));
  if(NULL == p) return -1;
  strcpy(p-&gt;id, id);

  if(s-&gt;head)
    {
      p-&gt;next = s-&gt;head;
      s-&gt;head = p;
    }
  else
    {
      s-&gt;head = s-&gt;tail = p;
    }

  return 1;
}


struct myQ* dequeue(struct myList** s)
{
  struct myQ *temp, *prev;
  if(NULL == s || NULL == *s) return 0;
  if(NULL == (*s)-&gt;head) return 0;
  prev = (*s)-&gt;head;
  temp = (*s)-&gt;head;
  if(NULL == (*s)-&gt;head-&gt;next)
    {
      struct myQ* retp = (*s)-&gt;head;
      (*s)-&gt;head = (*s)-&gt;tail = NULL;
      return retp;
    }
  
  while(temp-&gt;next)
    {
      prev = temp;
      temp = temp-&gt;next;
    }

  (*s)-&gt;tail = prev;

  return temp;
}
       

void removeElement(struct myList* s, const char* id)
{
  struct myQ *p, *prev;
  if(NULL == s || NULL == id) return;
  p = searchElement(s, id, &amp;prev);
  if(p)
    {
      deleteElement(s, p, prev);
    }
}


struct myQ* searchElement(struct myList* s, const char* id, struct myQ** pr)
{
  struct myQ *prev, *cur;
  prev = s-&gt;head;
  for(cur = s-&gt;head; cur; cur = cur-&gt;next)
    {
      if(0 == strcmp(cur-&gt;id, id)) { *pr = prev; return cur;}
      else prev = cur;
    }

  return NULL;
}


void deleteElement(struct myList* s, struct myQ* q, struct myQ* prev)
{
  if(0 == strcmp(s-&gt;head-&gt;id, q-&gt;id)) /* removing head */
    {
      s-&gt;head = q-&gt;next;
      free(q);
    }
  else 
    {
      prev-&gt;next = q-&gt;next;
      free(q);
    }
}

void printQ(struct myList* s)
{
  if(s)
    {
      struct myQ* t;
      for(t = s-&gt;head; t; t = t-&gt;next) printf(&quot;ID = %s\n&quot;, t-&gt;id);
    }
  else
    {
      printf(&quot;Nothing to print\n&quot;);
    }

  printf(&quot;--------------------------------\n&quot;);
}
	

struct myList* allocmyList(void)
{
  struct myList* p = malloc(1 * (sizeof *p));
  if(NULL == p) exit(EXIT_FAILURE);
  p-&gt;head = NULL;
  p-&gt;tail = NULL;
  return p;
}
</pre>
</p>
<p align="justify">
There are 3 problems:</p>
<ol>
<li>Dequeue operation is <em>O(N)</em>. In Queue, addition and deletion are O(1). Can you see why deletion is O(N) here ? </li>
<li>Dequeue does not need to take the address of original pointer. It is not needed. </li>
<li>Memory Leak. None of the elements are free()ed. </li>
<li>Enqueue() allocated new element but does not set its &#8220;next pointer&#8221; to NULL. This error was completely ignored by gcc on CentOS 5 machine I am using. </li>
</ol>
<p>Here is the correct code:</p>
<pre class="brush: cpp; title: ; notranslate">
/* A queue implementation with the operations that I need:
 *  (1) Add an element to the front (head) of the queue
 *  (2) Remove an element from rear (tail) of the queue
 *  (2) remove an element with a unique ID (string constant)
 *  (3) compare 2 elements (string comparison) 
 *  (4) print queue
 *
 * VERSION 0.1
 */

#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;string.h&gt;

enum { SIZE_ID = 100, SIZE_ARR = 20, REPS = 3 };

struct myQ
{
  char id[SIZE_ID+1];
  struct myQ* next;
};

struct myList
{
  struct myQ* head;
  struct myQ* tail;
};



struct myList* allocmyList(void);
int enqueue(struct myList* s, const char* id);
struct myQ* dequeue(struct myList* s); 
void removeElement(struct myList* s, const char* id);
struct myQ* searchElement(struct myList* s, const char* is, struct myQ** pr);
void deleteElement(struct myList* s, struct myQ* q, struct myQ* prev);
void printQ(struct myList* s);


int main(void)
{
  struct myQ* temp = NULL;
  struct myList* s = allocmyList();
  int i;
  for(i = 0; i &lt; REPS; ++i)
    {
      int r;
      char arrc[SIZE_ARR+1];
      r = sprintf(arrc, &quot;%d&quot;, i);
      if(0 &gt; r) 
	{
	  printf(&quot;ERROR-SPRINF() = %d\n&quot;, r);
	}
      else
	{
	  enqueue(s, arrc);
	}
      printf(&quot;s-&gt;head = %p, s-&gt;tail = %p\n&quot;, (void*)s-&gt;head, (void*)s-&gt;tail);
    }
 
  printQ(s);
  temp = dequeue(s);
  free(temp);
  printQ(s);
  temp = dequeue(s);
  free(temp);
  printQ(s);
  temp = dequeue(s);
  free(temp);
  printQ(s);
  temp = dequeue(s);
  free(temp);
  printQ(s);
  free(s);

  return 0;
}


int enqueue(struct myList* s, const char* id)
{
  struct myQ *p;
  if(NULL == s || NULL == id) return -1;
  p = malloc(1 * (sizeof *p));
  if(NULL == p) return -1;
  strcpy(p-&gt;id, id);
  p-&gt;next = NULL;

  if(NULL == s-&gt;head) s-&gt;head = p;
  else s-&gt;tail-&gt;next = p;
  s-&gt;tail = p;

  return 1;
}


struct myQ* dequeue(struct myList* s)
{
  struct myQ *retp;
  if(NULL == s || NULL == s-&gt;head) return NULL;
  
  retp = s-&gt;head;
  s-&gt;head = s-&gt;head-&gt;next;
  if(NULL == s-&gt;head) s-&gt;tail = s-&gt;head;
  return retp;
}
       

void removeElement(struct myList* s, const char* id)
{
  struct myQ *p, *prev;
  if(NULL == s || NULL == id) return;
  p = searchElement(s, id, &amp;prev);
  if(p)
    {
      deleteElement(s, p, prev);
    }
}


struct myQ* searchElement(struct myList* s, const char* id, struct myQ** pr)
{
  struct myQ *prev, *cur;
  prev = s-&gt;head;
  for(cur = s-&gt;head; cur; cur = cur-&gt;next)
    {
      if(0 == strcmp(cur-&gt;id, id)) { *pr = prev; return cur;}
      else prev = cur;
    }

  return NULL;
}


void deleteElement(struct myList* s, struct myQ* q, struct myQ* prev)
{
  if(0 == strcmp(s-&gt;head-&gt;id, q-&gt;id)) /* removing head */
    {
      s-&gt;head = q-&gt;next;
      free(q);
    }
  else 
    {
      prev-&gt;next = q-&gt;next;
      free(q);
    }
}

void printQ(struct myList* s)
{
  if(s)
    {
      struct myQ* t = NULL;
      for(t = s-&gt;head; t; t = t-&gt;next) printf(&quot;ID = %s\n&quot;, t-&gt;id);
    }
  else
    {
      printf(&quot;Nothing to print\n&quot;);
    }

  printf(&quot;--------------------------------\n&quot;);
}
	

struct myList* allocmyList(void)
{
  struct myList* p = malloc(1 * (sizeof *p));
  if(NULL == p) exit(EXIT_FAILURE);
  p-&gt;head = NULL;
  p-&gt;tail = NULL;
  return p;
}
</pre>
</p>
<p align="justify">
Deletion was O(N) because you get O(1) only  if you add to tail and remove from head (in case of singly linked list) whereas I was adding to head and removing from tail and because of that I had to find previous pointer and set the tail of Queue to point to it and this operation was O(N).
</p>
<p align="justify"> &nbsp;</p>
<p><em><br />
Copyright © 2012 Arnuld Uttre, Village &#8211; Patti, P.O &#8211; Manakpur, Tehsil &#8211; Nangal,  Distt. &#8211; Ropar, Punjab (INDIA)</p>
<p>Verbatim copying and distribution of this entire article are permitted worldwide, without royalty, in any medium, provided this notice, and the copyright notice, are preserved.<br />
</em></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/lispmachine.wordpress.com/687/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/lispmachine.wordpress.com/687/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lispmachine.wordpress.com&#038;blog=1624923&#038;post=687&#038;subd=lispmachine&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://lispmachine.wordpress.com/2012/06/21/queue-singly-linked-list/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/f45bcf34b0e8389c9c6aaac3249f9e4d?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">arnuld</media:title>
		</media:content>
	</item>
		<item>
		<title>Project Euler &#8211; Problem 2</title>
		<link>http://lispmachine.wordpress.com/2012/06/11/project-euler-problem-2/</link>
		<comments>http://lispmachine.wordpress.com/2012/06/11/project-euler-problem-2/#comments</comments>
		<pubDate>Mon, 11 Jun 2012 04:44:24 +0000</pubDate>
		<dc:creator>arnuld</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Project Euler]]></category>
		<category><![CDATA[project euler solutions]]></category>

		<guid isPermaLink="false">http://lispmachine.wordpress.com/?p=650</guid>
		<description><![CDATA[I mentioned Project Euler in my previous post. Next problem was little bit hard to do and I rewrote my code 3 times before I got it right: What can you see from above code. I got the meaning of problem statement totally wrong. Problem says &#8220;I need to add all Fibonacci numbers with values [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lispmachine.wordpress.com&#038;blog=1624923&#038;post=650&#038;subd=lispmachine&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p align="justify">
I mentioned Project Euler in my <a href="http://lispmachine.wordpress.com/2012/05/28/project-euler-problem-1/">previous post</a>. Next problem was little bit hard to do and I rewrote my code 3 times before I got it right:
</p>
<p align="justify">
<pre class="brush: cpp; title: ; notranslate">
/* By considering the terms in the Fibonacci sequence whose values do not exceed four million, 
 * find the sum of the even-valued terms.
 */
#include &lt;stdio.h&gt;
 
unsigned long fib(unsigned long num);
 
 
int main(void)
{
  const unsigned long limit = 8;
  unsigned long sum = 0;
  unsigned long i = 0;
 
  for(i = 0; i &lt;= limit; ++i)
    {
      unsigned long j = fib(i);
 
      if(0 == (j % 2))
        {
          sum += j;
        }
    }
 
  printf(&quot;Sum of all Fibonaci even numbers upto %lu = (%lu)\n&quot;, limit, sum);
 
  return 0;
}
 
 
unsigned long fib(unsigned long num)
{
  unsigned long temp = 0;
  
  if((0 == num) || (1 == num))
    {
      temp = 1;
    }
  else
    {
      temp = fib(num - 1) + fib(num - 2);
    }
 
  return temp;
}
 
 
</pre>
</p>
<p align="justify">
What can you see from above code. I got the meaning of problem statement totally wrong. Problem says &#8220;I need to add all Fibonacci numbers with values upto 4 million&#8221; whereas I took it as &#8220;add all numbers upto 4 million as input to Fibonacci&#8221;. 2nd, What else is wrong ? Can you spot it ? Stop reading right now and run this in your compiler. If you have gcc then please use <em>-ansi -pedantic -Wall -Wextra</em> flags. Go ahead and try and come back again. This program keeps on running for 11 minutes when limit is 400. The recirsive call eats all CPU. Even after 11 minutes I <a href="http://linux.die.net/man/1/kill">killed</a> it.   My machine is quite average in terms of hardware. Imagine at 4 million as input, how many years it will take to complete ? So what do we do ? First we get our brains right that it requires us to add all Fibonacci values less than 4 millions. 2nd,  we will not use recursion and instead we will make use of the fact that F(N) = F(N-1) + F(N-2) provided F(0) = F(1) = 1,  where F is fibonacci for N. We can rememeber last two fibonacci numbers in some variables instead of using recursion to find out every time. Recursion uses a lot of stack and I don&#8217;t think you should assume that you will have stack for 4 millions. Here is the correct and new iterative version.
</p>
<p align="justify">
<pre class="brush: cpp; title: ; notranslate">
/* By considering the terms in the Fibonacci sequence whose values do not exceed four million, 
 * find the sum of the even-valued terms.
 */
#include &lt;stdio.h&gt;
 
int main(void)
{
  const unsigned long limit = 4000000;
  unsigned long sum = 0;
  unsigned long i = 0;
 
  unsigned long f = 1; /* Fibonacci(0); */
  unsigned long f2 = 1; /* Fibonacci(0); */ 
  unsigned long f1 = 1; /* Fibonacci(1); */
 
  for(i = 2; f &lt;= limit ; ++i)
    {
      /* In first iteration, Fibonacci(2) = F(1) + F(0) */
      f = f1 + f2;
      if(0 == (f % 2))
        {
          sum += f;
        }
 
      f2 = f1;
      f1 = f;
    }
 
  printf(&quot;Sum of all Fibonaci even numbers upto %lu = (%lu)\n&quot;, limit, sum);
 
  return 0;
}
 
</pre>
</p>
<p align="justify">
I still see something wrong with above code. Did you notice several issues ? Don&#8217;t just read ahead, read the code and see how it fits problem statement. Its using <em>&lt;= instead of &lt; </em>. Problem statement says &#8220;upto 4 millions&#8221; and that does not include 4 millionth term (##c on freenode correct me on this as I am not a native English speaker. I thought &#8220;upto&#8221; included 4 millions). Other problem is using iteger <em>i</em>. We are not iterating for a specific number of times but till a certain condition is reached without caring how many times we iterated. So we need to remove that counter.
</p>
<p align="justify">
<pre class="brush: cpp; title: ; notranslate">
/* By considering the terms in the Fibonacci sequence whose values do not exceed four million, 
 * find the sum of the even-valued terms.
 *
 * My Method: F(n) = F(n-1) + F(n - 2) (where F(0) = F(1) = 1)
 * find the sum of all values where F(n) is even, till 4 million
 *
 */
#include &lt;stdio.h&gt;

int main(void)
{
  const unsigned long limit = 4000000;
  unsigned long sum = 0;

  unsigned long f = 0; /* Fibonacci(0); */
  unsigned long f2 = 0; /* Fibonacci(0); */ 
  unsigned long f1 = 1; /* Fibonacci(1); */

  while((f1 &lt; limit) &amp;&amp; (f2 &lt; limit))
    {
      /* In first iteration, F(2) = F(1) + F(0) */
      f = f1 + f2;
      if(f &gt;= limit) break;

      if(0 == (f % 2))
	{
	  sum += f;
	}

      f2 = f1;
      f1 = f;
    }

  printf(&quot;Sum of all Fibonaci even numbers upto %lu = (%lu)\n&quot;, limit, sum);

  return 0;
}
</pre>
</p>
<p align="justify">
How long it takes to execute. As per <a href="http://ideone.com/">ideone.com</a> , it take 0.02 seconds. And I was waiting for 11 minutes for the first piece of code. How much good programming practice is worth of ? a few thousands extra in salary of the programmer, a millions for the bugs caused or the entire bank account multi-billioon dollor corporation if it hires all bad programmers ? What do you think ?
</p>
<p align="justify"> &nbsp;</p>
<p><em><br />
Copyright © 2012 Arnuld Uttre, Village &#8211; Patti, P.O &#8211; Manakpur, Tehsil &#8211; Nangal,  Distt. &#8211; Ropar, Punjab (INDIA)</p>
<p>Verbatim copying and distribution of this entire article are permitted worldwide, without royalty, in any medium, provided this notice, and the copyright notice, are preserved.<br />
</em></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/lispmachine.wordpress.com/650/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/lispmachine.wordpress.com/650/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lispmachine.wordpress.com&#038;blog=1624923&#038;post=650&#038;subd=lispmachine&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://lispmachine.wordpress.com/2012/06/11/project-euler-problem-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/f45bcf34b0e8389c9c6aaac3249f9e4d?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">arnuld</media:title>
		</media:content>
	</item>
		<item>
		<title>Code from IBM</title>
		<link>http://lispmachine.wordpress.com/2012/06/04/code-from-ibm/</link>
		<comments>http://lispmachine.wordpress.com/2012/06/04/code-from-ibm/#comments</comments>
		<pubDate>Mon, 04 Jun 2012 09:58:04 +0000</pubDate>
		<dc:creator>arnuld</dc:creator>
		
		<guid isPermaLink="false">http://lispmachine.wordpress.com/?p=662</guid>
		<description><![CDATA[I got the job to fix Segmentation Fault somewhere. While I was searching for strftime(), localtime(), ctime() , localtime_r() etc and their behavior with with multi-threaded programs (POSIX threads), I came across this piece of code from IBM. you can find it here if its still available. I have a screenshot too This C program [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lispmachine.wordpress.com&#038;blog=1624923&#038;post=662&#038;subd=lispmachine&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p align="justify">
I got the job to fix Segmentation Fault somewhere. While I was searching for strftime(), localtime(), ctime() , localtime_r() etc and their behavior with with multi-threaded programs (POSIX threads), I came across this piece of code from IBM. you can find it <a href="http://publib.boulder.ibm.com/infocenter/iadthelp/v6r0/index.jsp?topic=/com.ibm.etools.iseries.langref.doc/rzan5mst263.htm">here</a> if its still available. I have a <a href="http://i1160.photobucket.com/albums/q490/arnuld_uttre/Programming/ibm.jpg">screenshot</a> too <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />
 </p>
<pre class="brush: cpp; title: ; notranslate">
#include &lt;stdio.h&gt;
#include &lt;time.h&gt;
 
int main(void)
{
     char s[100];
     int rc;
     time_t temp;
     struct tm *timeptr;
 
     temp = time(NULL);
     timeptr = localtime(&amp;temp);
 
     rc = strftime(s,sizeof(s),&quot;Today is %A, %b %d.\nTime:  %r&quot;, timeptr);
     printf(&quot;%d characters written.\n%s\n&quot;,rc,s);
 
     return 0;
}
 
/*************************************************
     The output should be similar to:
     46 characters written
     Today is Wednesday, Oct 24.
     Time:  01:01:15 PM
************************************************************/

</pre>
<p align="justify">
This C program is not correct. Do you see anything wrong with code ? What is it ? Do you see anything wrong with calls of localtime() and strftime() ?  Return values from them are not checked:</p>
<ul>
<li><strong>localtime()</strong>:</li>
<p> Returns NULL when some error occures. You pass this NULL to strftime() and whoaaa.. you got undefined behavior.</p>
<li><strong>strftime()</strong>: </li>
<p> Even if localtime() behaved correctly strftime() can return with an error condition. IBM&#8217;s code does save return value but again does no check of it. Program is simply printing array passed to strftime() without checking if return value was zero or not. Man page of <a href="http://pubs.opengroup.org/onlinepubs/007908799/xsh/strftime.html">strftime()</a> says:
</ul>
<blockquote><p>
The strftime() function returns the number of characters placed in the array, not including the  terminating null byte, provided the string, including the terminating null byte, fits.  Otherwise, it returns 0, and the contents of the array is undefined. (Thus at least since libc 4.4.4;  very  old  versions of libc, such as libc 4.4.1, would return max if the array was too small.)
</p></blockquote>
<p>Now if the contents of array are undefined then behavior of program is undefined too because you are trying to print an array with undefined contents. It can cause crash (if you are lucky), it can print garbage (you are still lucky) or it can just work fine printing the time because most of the time there will no error and that is utter badluck because definitely it will crash on first run when client is using it (trust me, its very ususal). So what we do ? Just two simple checks and client will be happy and that includes your happiness too. Here is the fixed code:</p>
<pre class="brush: cpp; title: ; notranslate">
#include &lt;stdio.h&gt;
#include &lt;time.h&gt;
 
int main(void)
{
     time_t temp;
     struct tm *timeptr;
 
     temp = time(NULL);
     timeptr = localtime(&amp;temp);

     if(NULL == timeptr)
       {
	 printf(&quot;Error localtime()\n&quot;);
       }
     else
       {
	 int rc;
	 char s[100] = {0}; 
	 rc = strftime(s,sizeof(s),&quot;Today is %A, %b %d.\nTime:  %r&quot;, timeptr);
	 if(0 == rc)
	   {
	     printf(&quot;Error strftime()\n&quot;);
	   }
	 else
	   {
	     printf(&quot;%d characters written.\n%s\n&quot;,rc,s);
	   }
       }

     return 0;
}
 
/*************************************************
Compiled on Linux:

/home/arnuld/programs/C $ gcc -std=c99 -pedantic -Wall -Wextra ibm.c 
/home/arnuld/programs/C $ ./a.out 
43 characters written.
Today is Monday, Jun 04.
Time:  03:50:57 PM
/home/arnuld/programs/C $ 
************************************************************/
</pre>
</p>
<p align="justify">
There is one more change. I have put varibales in closest possible block (check out <em>int rc</em> and <em>char s</em>, it is because I don&#8217;t see the point of decalring them earlier and using them later. Local variables must be decalred/defined in the closest block possible. Another difference is I am initializing the array with null characters (or filling it with zeroes) so that it does not contain any garbage. This is actually more of a matter of style, a personal thing rather than a rule to write correct programs in C. It does write correct program and its not required that you do same while the first change regarding keeping variables in tightest scope possible definitely comes under one of the methods of writing good C programs.
</p>
<p align="justify"> &nbsp;</p>
<p><em><br />
Copyright © 2012 Arnuld Uttre, Village &#8211; Patti, P.O &#8211; Manakpur, Tehsil &#8211; Nangal,  Distt. &#8211; Ropar, Punjab (INDIA)</p>
<p>Verbatim copying and distribution of this entire article are permitted worldwide, without royalty, in any medium, provided this notice, and the copyright notice, are preserved.<br />
</em></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/lispmachine.wordpress.com/662/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/lispmachine.wordpress.com/662/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lispmachine.wordpress.com&#038;blog=1624923&#038;post=662&#038;subd=lispmachine&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://lispmachine.wordpress.com/2012/06/04/code-from-ibm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/f45bcf34b0e8389c9c6aaac3249f9e4d?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">arnuld</media:title>
		</media:content>
	</item>
		<item>
		<title>Coding Horror</title>
		<link>http://lispmachine.wordpress.com/2012/06/03/coding-horror/</link>
		<comments>http://lispmachine.wordpress.com/2012/06/03/coding-horror/#comments</comments>
		<pubDate>Sun, 03 Jun 2012 08:47:53 +0000</pubDate>
		<dc:creator>arnuld</dc:creator>
				<category><![CDATA[art]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[coding horror]]></category>
		<category><![CDATA[f5 essential phone interview questions]]></category>
		<category><![CDATA[Five Essential Phone-Screen Questions]]></category>
		<category><![CDATA[steve yegge]]></category>

		<guid isPermaLink="false">http://lispmachine.wordpress.com/?p=656</guid>
		<description><![CDATA[Recently I was reading an article on coding horror which mentioned that most of the software developers who come for interview can&#8217;t even program and later I came across another article regarding phone screening interview and he mentioned Steve Yegge&#8217;s 5 essential phone screen questions. I looked at them and I thought .. whoaaa.. so [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lispmachine.wordpress.com&#038;blog=1624923&#038;post=656&#038;subd=lispmachine&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p align="justify">Recently I was reading an article on <a href="http://www.codinghorror.com">coding horror</a> which mentioned that most of the software developers who come for interview <a href="http://www.codinghorror.com/blog/2007/02/why-cant-programmers-program.html">can&#8217;t even program</a> and later I came across another article regarding phone screening interview and he mentioned Steve Yegge&#8217;s <a href="http://sites.google.com/site/steveyegge2/five-essential-phone-screen-questions">5 essential phone screen questions</a>. I looked at them and I thought .. whoaaa.. so easy. I was with my friend on his Windows machine and did not have access to some Linux machine. So I downloaded Bloodshed&#8217;s Dev-C++ compiler and typed this code and ran several tests, all in 20 minutes. (Bloodshed Dev-C++ version 5.2.0.2). I solved only several questions, will solve others when I get time to sit on machine next time. For now, just enjoy my C code <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />
 </p>
<p align="justify">
<pre class="brush: cpp; title: ; notranslate">
/* (1) Write a program that prints the numbers from 1 to 100. But for multiples of three print &quot;Fizz&quot; instead of the 
number and for the multiples of five print &quot;Buzz&quot;. For numbers which are multiples of both three and five print &quot;FizzBuzz&quot;.

 (2) Write function to compute Nth fibonacci number

 (3) print all odd numbers between 1 and 99
 */

#include &lt;stdio.h&gt;

enum { LIMIT = 100 };

void fib(const int n);
void print_odds(const int limit);
void print_fizzbuzz(const int limit);

int main(void)
{
	print_fizzbuzz(LIMIT); 
	printf(&quot;\n\n&quot;);
	print_odds(LIMIT-1); 
	printf(&quot;\n\n&quot;);
	fib(20);
	return 0;
}

/* No int/unsigned-long overflow check */
void fib(const int n)
{
	unsigned long f0 = 0;
	unsigned long f1 = 1;
	unsigned long fnum = f1;
	int i;
	if((0 == n) || (1 == n))
	{
		printf(&quot;fib(%d) = %d\n&quot;, n, n);
		return;
	}
	for(i = 2; i &lt;= n; ++i)
	{
		fnum = f1 + f0;
		f0 = f1;
		f1 = fnum;
	}
	
	printf(&quot;fib(%d) = %lu&quot;, n, fnum);
}

void print_odds(const int limit)
{
	int i;
	for(i = 1; i &lt;= limit; i = i + 2)
	{
		printf(&quot;%d\t&quot;, i);
	}
	printf(&quot;\n&quot;);
}

void print_fizzbuzz(const int limit)
{
	int i;
	for(i = 0; i &lt;= limit; ++i)
	{
		if((0 == i%3) &amp;&amp; (0 == i%5))
		{
			printf(&quot;fizzbuzz\t&quot;);
		}
		else if(0 == i%3)
		{
			printf(&quot;fizz\t&quot;);
		}
		else if(0 == i%5)
		{
			printf(&quot;buzz\t&quot;);
		}
		else
		{
			printf(&quot;%d\t&quot;, i);
		}
	}
	printf(&quot;\n&quot;);
}
</pre>
<p align="justify"> &nbsp;</p>
<p><em><br />
Copyright © 2012 Arnuld Uttre, Village &#8211; Patti, P.O &#8211; Manakpur, Tehsil &#8211; Nangal,  Distt. &#8211; Ropar, Punjab (INDIA)</p>
<p>Verbatim copying and distribution of this entire article are permitted worldwide, without royalty, in any medium, provided this notice, and the copyright notice, are preserved.<br />
</em></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/lispmachine.wordpress.com/656/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/lispmachine.wordpress.com/656/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lispmachine.wordpress.com&#038;blog=1624923&#038;post=656&#038;subd=lispmachine&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://lispmachine.wordpress.com/2012/06/03/coding-horror/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/f45bcf34b0e8389c9c6aaac3249f9e4d?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">arnuld</media:title>
		</media:content>
	</item>
		<item>
		<title>Project Euler &#8211; Problem 1</title>
		<link>http://lispmachine.wordpress.com/2012/05/28/project-euler-problem-1/</link>
		<comments>http://lispmachine.wordpress.com/2012/05/28/project-euler-problem-1/#comments</comments>
		<pubDate>Mon, 28 May 2012 09:53:10 +0000</pubDate>
		<dc:creator>arnuld</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Project Euler]]></category>

		<guid isPermaLink="false">http://lispmachine.wordpress.com/?p=646</guid>
		<description><![CDATA[Recently I came across Project Euler. I always had trouble with applying problem-solving thinking to problems. Somone on IRC somwhere told me that these are the toughest problem he had ever faced in programming. I think its a good idea to test my abilities by solving these problems. Here is the first and easy one [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lispmachine.wordpress.com&#038;blog=1624923&#038;post=646&#038;subd=lispmachine&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p align="justify">
Recently I came across <a href="http://projecteuler.net">Project Euler</a>. I always had trouble with applying problem-solving thinking to problems. Somone on IRC somwhere told me that these are the toughest problem he had ever faced in programming. I think its a good idea to test my abilities by solving these problems. Here is the first and easy one (easiest one ?):
</p>
<pre class="brush: cpp; title: ; notranslate">
/* Add all the natural numbers below one thousand that are multiples of 3 or 5. 
 * version 0.1
 */

#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;

int main(void)
{
  int i;
  unsigned long s = 0;
  
  for (i = 3; i &lt; 1000; i += 3)
    s += i;

  for (i = 5; i &lt; 1000; i += 5)
    {
      if(i % 3) s += i;
    }

  printf(&quot;%lu\n&quot;, s);

  return EXIT_SUCCESS;
}
</pre>
<p align="justify">
After you solve a problem and give correct answer, it shows in your registered account as solved and a link to the forum thread is also provided where you can see different kinds of solutions posted in different languages. It also shows how many people so far have solved the problem. Thats a good measure of your intelligence (if very few has solved it). Iam using C language for now to solve problems as C is the only language I know currently. I think you must go ahead and give Project Euler a try.
</p>
<p align="justify"> &nbsp;</p>
<p><em><br />
Copyright © 2012 Arnuld Uttre, Village &#8211; Patti, P.O &#8211; Manakpur, Tehsil &#8211; Nangal,  Distt. &#8211; Ropar, Punjab (INDIA)</p>
<p>Verbatim copying and distribution of this entire article are permitted worldwide, without royalty, in any medium, provided this notice, and the copyright notice, are preserved.<br />
</em></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/lispmachine.wordpress.com/646/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/lispmachine.wordpress.com/646/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lispmachine.wordpress.com&#038;blog=1624923&#038;post=646&#038;subd=lispmachine&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://lispmachine.wordpress.com/2012/05/28/project-euler-problem-1/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/f45bcf34b0e8389c9c6aaac3249f9e4d?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">arnuld</media:title>
		</media:content>
	</item>
		<item>
		<title>Go Programming Language</title>
		<link>http://lispmachine.wordpress.com/2012/05/25/go-programming-language/</link>
		<comments>http://lispmachine.wordpress.com/2012/05/25/go-programming-language/#comments</comments>
		<pubDate>Fri, 25 May 2012 07:17:15 +0000</pubDate>
		<dc:creator>arnuld</dc:creator>
				<category><![CDATA[community]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[go programming language]]></category>
		<category><![CDATA[google go]]></category>
		<category><![CDATA[google go comparison with C]]></category>
		<category><![CDATA[google go comparison with Haskell]]></category>
		<category><![CDATA[haskell vs google go]]></category>

		<guid isPermaLink="false">http://lispmachine.wordpress.com/?p=638</guid>
		<description><![CDATA[I was reading draft of new C++ standard a.k.a C++11 (you too must check out N3337.pdf) and somehow I came across Go Programming Lanaguage and on that same page I found this quote of Bruce Eckel: The complexity of C++ (even more complexity has been added in the new C++), and the resulting impact on [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lispmachine.wordpress.com&#038;blog=1624923&#038;post=638&#038;subd=lispmachine&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p align="justify">
I was reading draft of new C++ standard a.k.a C++11 (you too must check out N3337.pdf) and somehow I came across  <a href="http://en.wikipedia.org/wiki/Go_%28programming_language%29">Go Programming Lanaguage</a> and on that same page I found this quote of Bruce Eckel: </p>
<blockquote><p>
The complexity of C++ (even more complexity has been added in the new C++), and the resulting impact on productivity, is no longer justified. All the hoops that the C++ programmer had to jump through in order to use a C-compatible language make no sense anymore &#8212; they&#8217;re just a waste of time and effort. Now, Go makes much more sense for the class of problems that C++ was originally intended to solve.
</p></blockquote>
<p>Now thats a pretty solid and strong statement, I got shakes reading that and it reminded me of <a href="http://www.google.co.in/search?q=the+case+for+D&amp;ie=utf-8&amp;oe=utf-8&amp;aq=t&amp;rls=org.mozilla:en-US:official&amp;client=firefox-a#hl=en&amp;client=firefox-a&amp;hs=bG9&amp;rls=org.mozilla:en-US%3Aofficial&amp;sclient=psy-ab&amp;q=the+case+for+d+alexandrescu&amp;oq=the+case+for+D+alex&amp;aq=0K&amp;aqi=g-K1&amp;aql=1&amp;gs_l=serp.3.0.0i30.7018.8099.0.10739.5.5.0.0.0.0.2155.3006.0j2j2j9-1.5.0.erf1.1.0.0.VS04HOzWM9I&amp;pbx=1&amp;bav=on.2,or.r_gc.r_pw.r_qf.,cf.osb&amp;fp=28fe21510ca2e35&amp;biw=1020&amp;bih=645">The Case for D</a> by Andrei Alexandrescu. Go is designed by a team consiting of our good old friends Rob Pike and Ken Thompson. It has some very good positive reviews. I still have to read the criticizm of it. As per computer language shootout results, C (using GNU&#8217;s gcc) is far faster but the code-size of Go was much less (almost 1/3rd). Next on comparison was C++ (GNU&#8217;s g++) and results were almost same. Next on my list were Lisp and ATS. <a href="http://shootout.alioth.debian.org/u64q/benchmark.php?test=all&amp;lang=go&amp;lang2=ats">checkout the results</a> yourself down here in graphs. </p>
<p align="justify">
I discussed this performance issue on Go language IRC channel (#go-nuts, freenode) and they gave me very logical and accurate explanation that Go is not mature yet and performance comparison is with very mature C and C++ libraries which are around for a decade or more. So I cna conclude comparison is not exactly a fair comparison. I think Go will catch up with performance issues very fast as user base is growing at electric pace. Reminds me of the times and discussion when Python&#8217;s user base was growing and they were trying to resolve all the issues they could with full hard work.
</p>
<p align="justify">
Whenever a new language comes or whenever you want to learn an already established language, I think you must look into why that language was created in first place. <em>Does that match <strong>your why</strong> of learning </em> ? you must be using that language for some purpose, does the design goal suit your purpose ? In my case I think Go language suits, here is the excerpt from <a href="http://radar.oreilly.com/2010/06/does-the-world-need-yet-anothe.html">Does the world need another programming language ?</a></p>
<blockquote><p>
A couple of years ago, several of us at Google became a little frustrated with the software development process, and particularly using C++ to write large server software. We found that the binaries tended to be much too big. They took too long to compile. And the language itself, which is pretty much the main system software language in the world right now, is a very old language. A lot of the ideas and changes in hardware that have come about in the last couple of decades haven&#8217;t had a chance to influence C++. So we sat down with a clean sheet of paper and tried to design a language that would solve the problems that we have: we need to build software quickly, have it run well on modern multi-core hardware and in a network environment, and be a pleasure to use.
</p></blockquote>
<blockquote><p>
Go has the feel of a dynamic language like Python or Ruby or JavaScript, but it has the performance and safety of a language like Java or C or C++. So you get the lightweight feel of a modern scripting dynamic language but the robustness and performance of a more old-fashioned language.
</p></blockquote>
<p>Based solely on the above criteria I think I can start using Go right away and if I don&#8217;t have enough mature libraries or some specific functionality, then ATS is always there. When companies become big they become rigid, like a stubborn spoilt son of a businessman. They refuse to change to get edge over other software corporations because the change requires a lot of effort. I think the weight of word &#8220;Google&#8221; behind Go programming language will give it an edge over that rigidity. (same thinkg with Java and .NET).
</p>
<p align="justify">
<img src="http://i1160.photobucket.com/albums/q490/arnuld_uttre/Shootouts/Go-vs-Cpp-gcpp.png" alt="GO vs C++ (g++)" /><br />
<br />
<img src="http://i1160.photobucket.com/albums/q490/arnuld_uttre/Shootouts/Go-vs-C-gcc.png" alt="Go vs C (gcc)" /><br />
<br />
<img src="http://i1160.photobucket.com/albums/q490/arnuld_uttre/Shootouts/Go-vs-ATS.png" alt="Go vs ATS" /><br />
<br />
<img src="http://i1160.photobucket.com/albums/q490/arnuld_uttre/Shootouts/Go-vs-OCaml.png" alt="Go Vs OCaml" /><br />
<br />
<img src="http://i1160.photobucket.com/albums/q490/arnuld_uttre/Shootouts/Go-vs-Lisp.png" alt="Go Vs Lisp (SBCL)" /><br />
<br />
<img src="http://i1160.photobucket.com/albums/q490/arnuld_uttre/Shootouts/Go-vs-Haskell-GHC.png" alt="Go vs Haskell (GHC)" />
</p>
<p align="justify"> &nbsp;</p>
<p><em><br />
Copyright © 2012 Arnuld Uttre, Village &#8211; Patti, P.O &#8211; Manakpur, Tehsil &#8211; Nangal,  Distt. &#8211; Ropar, Punjab (INDIA)</p>
<p>Verbatim copying and distribution of this entire article are permitted worldwide, without royalty, in any medium, provided this notice, and the copyright notice, are preserved.<br />
</em></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/lispmachine.wordpress.com/638/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/lispmachine.wordpress.com/638/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=lispmachine.wordpress.com&#038;blog=1624923&#038;post=638&#038;subd=lispmachine&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://lispmachine.wordpress.com/2012/05/25/go-programming-language/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/f45bcf34b0e8389c9c6aaac3249f9e4d?s=96&#38;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">arnuld</media:title>
		</media:content>

		<media:content url="http://i1160.photobucket.com/albums/q490/arnuld_uttre/Shootouts/Go-vs-Cpp-gcpp.png" medium="image">
			<media:title type="html">GO vs C++ (g++)</media:title>
		</media:content>

		<media:content url="http://i1160.photobucket.com/albums/q490/arnuld_uttre/Shootouts/Go-vs-C-gcc.png" medium="image">
			<media:title type="html">Go vs C (gcc)</media:title>
		</media:content>

		<media:content url="http://i1160.photobucket.com/albums/q490/arnuld_uttre/Shootouts/Go-vs-ATS.png" medium="image">
			<media:title type="html">Go vs ATS</media:title>
		</media:content>

		<media:content url="http://i1160.photobucket.com/albums/q490/arnuld_uttre/Shootouts/Go-vs-OCaml.png" medium="image">
			<media:title type="html">Go Vs OCaml</media:title>
		</media:content>

		<media:content url="http://i1160.photobucket.com/albums/q490/arnuld_uttre/Shootouts/Go-vs-Lisp.png" medium="image">
			<media:title type="html">Go Vs Lisp (SBCL)</media:title>
		</media:content>

		<media:content url="http://i1160.photobucket.com/albums/q490/arnuld_uttre/Shootouts/Go-vs-Haskell-GHC.png" medium="image">
			<media:title type="html">Go vs Haskell (GHC)</media:title>
		</media:content>
	</item>
	</channel>
</rss>
