Tuesday, October 18, 2011

A lazy and intricate start

This post may appear contradictory to what the name of the blog suggests. But it is not the case - only because my inability to provide a detailed background - scientific,historical,spiritual, this post is appearing complex.

I will first mention the trigger :
http://anupamk-blog.posterous.com/self-modifying-code

I and my friend used to have long chats about many things that are termed as 'insane' in today's era. I am posting my comment on the above post as a post on this blog - I strongly recommend the readers to first read the post that the link points to !

My comment/(post) :

Sorry to begin with a negative note but I need to be very cautious,henceforth,before I ask you about something/to read something.The reason is simple - I don't wanna accelerate my(and maybe yours,too) descendance to insanity ;)
Before I proceed,I will like to highlight a crevice in your question - you think that code is intelligent/self-learning etc. But code is nothing but the implementation - your father knows that one tight slap and you will be as straight-laced as a lamb;the 'slap' here is the code.Now depending upon the intensity of the situation,your father will decide how many,how intense and where the slaps must be delivered :P
Even if you disagree to above statement,I suggest you read this piece of *hit to the end !!!
Let me make an Adolf Hitler attempt towards victory :P
You wrote :
self-modifying code => reflection => self-reference (=> self-awareness??) => meta-cognition => intelligence
Now the first concept that popped in my mind was that of the 'sample space' we learned in Maths.Or to be more naive,we can use the term 'context',as known in English or Computing domain. I,hereby,list the terms and notions that can help us to start solving this jig-saw puzzle :
1. Sample space/Context
Had Sir Einstein been here,he would have given you a call to explain his dreaded 'Theory of Relativity' and then I would have been subjected to the pain of seeing you been shackled in a remote mental asylum :D
2. Based on above the term, comes the term 'Intelligence' which according to me is purely relative term. Intelligence can be logical,instinctive,statistical,emotional or EVERYTHING of it !!!
Ex : Man survives all weathers because he can collect data and analyse it - in a way,it is problem solving based on the data set. Animals lack this - they have a fixed set of hard-wired instructions but they too have limited learning capabilities - a puppy initially isn't scared if u pick a stone but as it grows into a dog,the gesture of picking a stone scares it. On the other hand, man lacks the instincts given to the animals - he can't sense earthquakes or other natural calamities.But again,he learns to observe the animal behaviour to deduce dangers.
3. Self-awareness - this term is grossly vague and undoubtedly,the subset of the notion-2 - when I say that I am 'self-aware',it is nothing more than the claim 'I have exhaustively analysed all the data sets I know and now I can predict how will my body and mind react in a given situation'.
But the spiritual explanation of self-awareness,at a naive level(where we stand),is 'an unending journey towards the ultimate Truth - who am I,why am I so,who made me,what is the objective of my life,what makes me different from others,where do I fit in the big picture' and all those deranged thoughts :P
To suffice,when you say that you are 'self-aware',it is again purely contextual - I may be aware of what I want,what I can do to get it etc. but that in NO WAY makes you intelligent OUTSIDE your sample space/context.
To be a bit deductive,take the example of Skynet in the Terminator series - it becomes 'self-aware' when it is switched on by Lt.Gen. Robert Brewster and soon takes over the entire technical backbone structures of earth. But it still takes years to come up with a plan to destroy the human leadership - it comes up with a notion that humans need something to believe in.Hence,it falsely inactivates few of it's bots and makes the Resistance leaders believe that the bots rely on a radio wave from the Skynet HQ. But again,John Connor uses his 'emotional' intelligence/instincts and turns out to be the only surviving top-brass !!!
I will just write a crude code snippet which I wrote to get rid of the goddamned switch cases in a servlet for redirecting requests to the correct model code/classes(actually,this is what all the frameworks and *hit,even JRE does :D )
package com.javaee.controller;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet implementation class Controller
*/
public class Controller extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public Controller() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
* response)
*/
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
* response)
*/
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
/*
* Step-1 : Retrieve the action ID(the int used in the normal switch
* case)
*/
/*
* Step-2 : Get the destination for this request - a jsp/a java class/a
* URL from DB/properties file etc.
*/

/*Step - 3 : Use reflection API to invoke the java class*/

/*Step - 4 : Forward the request using request dispatcher*/
}
}
Now step-4 is where the 'reflexive,self-modifying' code lies.
From the servlet's perspective,that code is 'intelligent' as it correctly decides the destination.
But from the JVM perspective,it's just an above-average worker code !
Now go back to the dad's slap example :P
As you know how horrendous I can be when it comes to drawing,art and stuff,else would have provided a pictorial depiction.
Please note that I have changed my residence.Hence,no point in rushing to my old place with an intention to kill me :P