<?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>Hrishikesh Barua &#124; code@deepinspace &#187; java</title>
	<atom:link href="http://code.deepinspace.net/tag/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://code.deepinspace.net</link>
	<description></description>
	<lastBuildDate>Wed, 25 Jan 2012 14:23:52 +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>Falling through</title>
		<link>http://code.deepinspace.net/2010/11/23/falling-through/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=falling-through</link>
		<comments>http://code.deepinspace.net/2010/11/23/falling-through/#comments</comments>
		<pubDate>Tue, 23 Nov 2010 11:19:16 +0000</pubDate>
		<dc:creator>hrish</dc:creator>
				<category><![CDATA[c]]></category>
		<category><![CDATA[grok]]></category>
		<category><![CDATA[introspection]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://code.deepinspace.net/?p=159</guid>
		<description><![CDATA[When I was studying for my CS degree, the programming language we were taught was C. To be honest, I didn&#8217;t code much C in college &#8211; just what was necessary to scrape through the lab assignments. I did stay up one night writing Tetris in C with 2 close friends for an internal contest, [...]]]></description>
			<content:encoded><![CDATA[<p>When I was studying for my CS degree, the programming language we were taught was C. To be honest, I didn&#8217;t code much C in college &#8211; just what was necessary to scrape through the lab assignments. I did stay up one night writing Tetris in C with 2 close friends for an internal contest, but such occasions were rare. Pointers? Grokked them, but I suspect it was a very shaky understanding. For the rest of my years there, it was C for all lab projects. I didn&#8217;t dislike C, but I did find it tough for a first language. So as soon as I got a chance, I set out to do some side projects in Java (atleast I thought was writing Java). That was the end of my relationship with C, because my first (and current) job <a href="http://www.pramati.com"> post-college was and still is in a Java shop</a>.</p>
<p><br/>Fast forward 8 years. The products I&#8217;ve worked on till now have been in Java. Serverside Java, Infrastructure Java, Applications Java. An <a href="http://server.pramati.com/">appserver</a>, a <a href="http://www.dekoh.com/">desktop app</a>, a <a href="http://tellafriend.socialtwist.com/">SaaS app</a>. Abstractions, APIs, SPIs, Specifications, Javadocs, Objects talking to each other &#8211; it&#8217;s a satisfying, pleasant world if you like high level order.</p>
<p><br/>I made occasional forays into <a href="http://www.jroller.com/talonx/entry/learning_german_learning_python">Python</a> and <a href="http://code.deepinspace.net/2009/12/26/a-ruby-script-to-search-bookstores-online/">Ruby</a> for some side projects and scripting.</p>
<p></br>But lately, I&#8217;ve been wanting to code in a really low level language. Yes, like C. Let me rephrase that. I&#8217;ve been wanting to write code where I can be as close to the OS as possible, learn bit twiddling hacks, make low level system calls. I&#8217;m not sure what this desire was born out of. Maybe 8 years of Java. Maybe wanting low level control over what I was doing.<br />
<br/></p>
<p>So I&#8217;ve ploughed through K&#038;R the last couple of months. Bought Deep C Secrets. Regrokked pointers &#8211; properly, this time. Had a brief period of not knowing where to go after this, which resolved itself in the form of Unix Network Programming (Richard Stevens). I&#8217;m working through Vol 1 right now. It&#8217;s slow going at times, but I&#8217;m loving every moment. I&#8217;ve fallen through &#8211; the abstractions, the bytecode, the layers of objects &#8211; and reached the ocean floor.<br/><br />
<em>&lt;In the background, the <a href="http://en.wikipedia.org/wiki/Toccata_and_Fugue_in_D_minor,_BWV_565">Toccata ends, and the Fugue begins.</a>&gt;<br />
</em><br/></p>
<script type="text/javascript" src="http://cdn.socialtwist.com/2008071112-2/script.js"></script><a class="st-taf" href="http://tellafriend.socialtwist.com" onclick="return false;" style="border:0;padding:0;margin:0;"><img alt="SocialTwist Tell-a-Friend" style="border:0;padding:0;margin:0;" src="http://images.socialtwist.com/2008071112-2/button.png"onmouseout="STTAFFUNC.hideHoverMap(this)" onmouseover="STTAFFUNC.showHoverMap(this, '2008071112-2', 'http%3A%2F%2Fcode.deepinspace.net%2F2010%2F11%2F23%2Ffalling-through%2F', 'Falling+through')" onclick="STTAFFUNC.cw(this, {id:'2008071112-2', link: 'http%3A%2F%2Fcode.deepinspace.net%2F2010%2F11%2F23%2Ffalling-through%2F', title: 'Falling+through' });"/></a>]]></content:encoded>
			<wfw:commentRss>http://code.deepinspace.net/2010/11/23/falling-through/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Instance Initializers in Java</title>
		<link>http://code.deepinspace.net/2010/05/22/instance-initializers-in-java/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=instance-initializers-in-java</link>
		<comments>http://code.deepinspace.net/2010/05/22/instance-initializers-in-java/#comments</comments>
		<pubDate>Sat, 22 May 2010 16:27:11 +0000</pubDate>
		<dc:creator>hrish</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://code.deepinspace.net/?p=101</guid>
		<description><![CDATA[Take a look at this simple code Code Snippet 1 What do you think the output is? It&#8217;s this - In the beginning was the command line Created an instance The &#8216;hanging&#8217; braces at the start of the class definition are instance initializers. Most of us are more familiar with static initializers - Code Snippet [...]]]></description>
			<content:encoded><![CDATA[<p>Take a look at this simple code</p>
<p><span style="color: #0000ff;">Code Snippet 1</span></p>
<pre class="brush: java; title: ; notranslate">
public class Init {
    {
        System.out.println(&quot;In the beginning was the command line&quot;);
    }

    public Init()
    {
        System.out.println(&amp;quot;Created an instance&amp;quot;);
    }

    public static void main(String[] args)
    {
        Init init = new Init();
    }
}
</pre>
<p>What do you think the output is? It&#8217;s this -</p>
<pre>    In the beginning was the command line
    Created an instance
</pre>
<p>The &#8216;hanging&#8217; braces at the start of the class definition are instance initializers. Most of us are more familiar with static initializers -</p>
<p><span style="color: #0000ff;">Code Snippet 2</span></p>
<pre class="brush: java; title: ; notranslate">
static
{
    //Do stuff
}
</pre>
<p>Instance initializers (II) are not seen often in everyday Java code &#8211; so they might seem odd at first. They are executed every time an instance of that class is created, before the statements in the constructor are executed. (See <em>The Java Language Specification 3 </em>section 8.6).</p>
<p>One use of IIs can be to execute something whenever an instance is created, and the class has multiple constructors, without calling it in every single constructor.<br />
Another one which has become popular is populating collections during declaration, in the style of Ruby or Python single-line initializers -</p>
<p><span style="color: #0000ff;">Code Snippet 3</span></p>
<pre class="brush: java; title: ; notranslate">
private Set&lt;String&gt; names = new HashSet&lt;String&gt;() {
    {
        add(&quot;Rigel&quot;);
        add(&quot;Vega&quot;);
        add(&quot;Antares&quot;);
    }
};
</pre>
<p>This idiom was how I encountered IIs first while reading somebody&#8217;s blog.<br />
What is actually happening here?</p>
<ol>
<li>An anonymous inner class is created.</li>
<li>An instance initializer block is added to the anon inner class.</li>
<li>Objects are added to the instance of that class when the names variable is initialized.</li>
</ol>
<p>Now take this scenario<br />
<span style="color: #0000ff;">Code Snippet 4</span></p>
<pre class="brush: java; title: ; notranslate">
public class WrongUsage {

    private Set&lt;String&gt; names;

    {
        add(&quot;pleiades&quot;);
    }

    public void WrongUsage()
    {
        names = new HashSet&lt;String&gt;();
    }

    public void add(String name)
    {
        names.add(name);
    }
}
</pre>
<p>Based on what we have seen above, the names set is used before it&#8217;s initialized. So this throws a NullPointerException.<br />
Let&#8217;s take another case &#8211; similar to the above but involving inheritance.</p>
<p><span style="color: #0000ff;">Code Snippet 5</span></p>
<pre class="brush: java; title: ; notranslate">
public class MyHashSet extends HashSet {
    {
        add(&quot;pleiades&quot;);
        System.out.println(&quot;Added&quot;);
    }

    public MyHashSet()
    {
        super();
        System.out.println(&quot;After calling super&quot;);
    }

    public static void main(String[] args)
    {
        Set set = new MyHashSet();
    }
}
</pre>
<p>This runs, with the output being</p>
<pre>    Added
    After calling super
</pre>
<p>In this case, add() internally uses the inner HashMap inside HashSet which is initialized in the HashSet constructor. This implies that the instance initializer is invoked before the class constructor, but after the superclass constructor (The super call is redundant here. It will be called anyway).</p>
<p>So the sequence is</p>
<ol>
<li> Superclass initialization (this includes superclass instance initializers and constructor)</li>
<li> Current class&#8217;s Instance initializers</li>
<li> Current class&#8217;s Constructor</li>
</ol>
<p>This is why the code in Code Snippet 3 does not throw an NPE &#8211; because it&#8217;s a case of inheritance (the anon inner class is a subclass of HashSet)</p>
<script type="text/javascript" src="http://cdn.socialtwist.com/2008071112-2/script.js"></script><a class="st-taf" href="http://tellafriend.socialtwist.com" onclick="return false;" style="border:0;padding:0;margin:0;"><img alt="SocialTwist Tell-a-Friend" style="border:0;padding:0;margin:0;" src="http://images.socialtwist.com/2008071112-2/button.png"onmouseout="STTAFFUNC.hideHoverMap(this)" onmouseover="STTAFFUNC.showHoverMap(this, '2008071112-2', 'http%3A%2F%2Fcode.deepinspace.net%2F2010%2F05%2F22%2Finstance-initializers-in-java%2F', 'Instance+Initializers+in+Java')" onclick="STTAFFUNC.cw(this, {id:'2008071112-2', link: 'http%3A%2F%2Fcode.deepinspace.net%2F2010%2F05%2F22%2Finstance-initializers-in-java%2F', title: 'Instance+Initializers+in+Java' });"/></a>]]></content:encoded>
			<wfw:commentRss>http://code.deepinspace.net/2010/05/22/instance-initializers-in-java/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Wondering about the state of Java Developers</title>
		<link>http://code.deepinspace.net/2009/08/29/wondering-about-the-state-of-java-developers/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=wondering-about-the-state-of-java-developers</link>
		<comments>http://code.deepinspace.net/2009/08/29/wondering-about-the-state-of-java-developers/#comments</comments>
		<pubDate>Sat, 29 Aug 2009 17:41:15 +0000</pubDate>
		<dc:creator>hrish</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[software development]]></category>
		<category><![CDATA[interview]]></category>

		<guid isPermaLink="false">http://code.deepinspace.net/?p=38</guid>
		<description><![CDATA[A friend of mine forwarded this article by Yakov Fain on sys-con.com - http://in.sys-con.com/node/1040135 The essence of the article is this The author interviewed a lot of people for developer positions, and most of them who call themselves Java developers and cite extensive experience in J2EE lack basic knowledge of core Java. This might sound [...]]]></description>
			<content:encoded><![CDATA[<p>A friend of mine forwarded this article by Yakov Fain on sys-con.com -</p>
<p><a title="http://in.sys-con.com/node/1040135" href="http://in.sys-con.com/node/1040135" target="_blank">http://in.sys-con.com/node/1040135</a></p>
<p>The essence of the article is this</p>
<p><em>The author interviewed a lot of people for developer positions, and most of them who call themselves Java developers and cite extensive experience in J2EE lack basic knowledge of core Java</em>.</p>
<p>This might sound suspiciously like a gross generalization, but I believe that&#8217;s not the case. I had a similar experience when I interviewed people for developer positions on my team last month. The position called for both Java and Javascript experience. These are the things I encountered -</p>
<ul>
<li>Most people who have worked solely on services (read outsourced) projects list all J* technologies on their resume, but know very little in depth of Java programming.</li>
<li>There are people who lack any kind of programmer mentality or skills at all and put their current role as something like Programmer Analyst, and this fact cannot be ascertained from their resume alone. They often try to highlight other (non-software development) achievements.</li>
<li>SCJP certification is no guarantee that a person can code in Java (Surprise? Not at all)</li>
<li>There are people who have 3.5 years of experience, with multiple services projects under their belts, and familiarity with a host of technologies, who cannot write a Java class which will print out the prime numbers between 0 and 100.</li>
<li>Most core CS concepts are forgotten after 2-3 years of working in services projects.</li>
</ul>
<p>Please note that I am not generalizing, but these facts do indicate a problem somewhere. These developers actually a represent a very small distinct sample of the worldwide developer community, since all my interviews were done in India (both face to face in my Hyderabad office and over the phone).</p>
<p>Another interesting point I noted was that most non-Javascript developers think that Javascript is used only for form validation. Such usage also qualifies as &#8216;extensive Javascript knowledge&#8217; in their resumes. <br/><br />
What should I conclude from this? Is this malaise widespread in other parts of the world as well? Is it specific to developers in India working on outsourced projects? (No, as the link by Yakov Fain shows) Is it a result of outsourcing, leading to a lack of innovation? Or is the innovation there, but the signal to noise ratio too low?<br/><br/></p>
<script type="text/javascript" src="http://cdn.socialtwist.com/2008071112-2/script.js"></script><a class="st-taf" href="http://tellafriend.socialtwist.com" onclick="return false;" style="border:0;padding:0;margin:0;"><img alt="SocialTwist Tell-a-Friend" style="border:0;padding:0;margin:0;" src="http://images.socialtwist.com/2008071112-2/button.png"onmouseout="STTAFFUNC.hideHoverMap(this)" onmouseover="STTAFFUNC.showHoverMap(this, '2008071112-2', 'http%3A%2F%2Fcode.deepinspace.net%2F2009%2F08%2F29%2Fwondering-about-the-state-of-java-developers%2F', 'Wondering+about+the+state+of+Java+Developers')" onclick="STTAFFUNC.cw(this, {id:'2008071112-2', link: 'http%3A%2F%2Fcode.deepinspace.net%2F2009%2F08%2F29%2Fwondering-about-the-state-of-java-developers%2F', title: 'Wondering+about+the+state+of+Java+Developers' });"/></a>]]></content:encoded>
			<wfw:commentRss>http://code.deepinspace.net/2009/08/29/wondering-about-the-state-of-java-developers/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

