Tuesday, February 27, 2007

NING ... is IN ??

I happen to come across a cool web application ...
Ning http://www.ning.com/
.. and they have a v good idea ...
It allows even the most novice of web users to create their own and highly customized social network in moments.
Unlike there beta release ... a year back ... it required some knowledge but not now in this new version
its quite possible the scene of social networking may soon change ..
who knows ??
:)

JAVA PUZZLES ... session @ sun tech days 07

JAVA PUZZLES by Raghavan N. Srinivas

This was undoubtedly the best session of the conference
Over all presentation goal was .. learning some of the quirks of programming in general and Java Programming language in particular

try getting the answer to the following code snippets
Keep in mind that i didn't try checking and running these programs .. so its quite possible that a syntax error might have crept it ... as i concentrated on concept not syntax when posting

lets start with an easy one ...

Class Example1
{

public static void main(String args[])
{
System.out.print("H"+"a");
System,out,print('H'+'a');
}
};


this is a good one ...


Class Example2
{

public Example2(Object o)

{

System.out.println("object");

}

public Example2(double[] d_a)
{

System.out.println("double array");

}


public static void main(String args[])
{

new Example2(null);

}
}



this one is simply awesome ...


Class Example3
{

public void main(String[] args)

{

Set s = new HashSet();

for(int i=0;i<100;i++)

s.add(randomInt());

System.out.println(s.size());

}


private static Integer randomInt()
{

return new Integer(new Random().nextInt());

}

};


a little tricky .. but comparatively easy ...


class Example4
{

public static synchronized void main (String args[])

{

Thread t = new Thread()

{

public void run()

{

pong();

}

};

t.run();

System.out.println("ping");

}

static synchronized void pong()
{
System.out.println("pong");
}
}

again a very good one ... must try

class Example5
{

public static void main(String args[])
{
// NOte : \u000A this is a comment
Char c =0x000A;
System.out.println(c);

}
}


a simple one again ...


class Example6
{

public static void main(String args[])
{

System.out.println(func());

}

public boolean func()
{

try
{

return true;

}

finally
{

return false;

}

}
}

Ans : Example 1
the output will be Ha169
Moral of story ...
use string con cation operator with care .. at least one of the two must be a string .. If it isn't then cast or convert

Ans : Example2
double array .. the most specific constructor is called and not the most GENERIC
We must use casting to fix it

Ans : Example3
the output will be a number close to 1
because the seed of the pseudo random number generator don't change .. as its time stamp based
may be if we put a sleep in between then the output is a number close to 100
but .. later after the session a guy came up with his laptop and ran the program in Java6 or may be java5 and the answer was a number close to 100.
when he showed it Raghavan he was surprised too said that he had checked the output on many JVMs .. ans was number close to one but strange that its 100

Ans : Example4
Wat'sthe output of above program
a) PingPong
b) PngPing
c) It varies

ans is pongping .. as its not a multi threaded program at all ... as it didn't call the start()


Ans : Example5
there will be a compile time error ,,as the \u000A in the comments will cause the comment to break up
and that in turn will give error

Ans : Example6
the ans will be false as the finally block will always be executed

There was another Example in which he tried to make a class called 'String'
and surprisingly ... it gave run time error and not compile time error

One VM : Many Scripting languages session @ Sun Tech Days 07

One VM : Many Scripting languages

Why Scripting ??
  • Java Language != Java Platform
  • Write one run anywhere is platform
  • VM runs language eutral buytecode
  • Rich sets of class lib are lang neutal
Scripting API
  • JSR 223 define scripting framework
  • theres a javax.script package for the same
  • part of javaSE6
  • Available for Java 5.0
  • javax.scriptpackage has classes like
    • ScriptEngine
    • ScriptContext , Bindings
    • ScriptEngineFactory
    • ScriptEngineManager
http://java.sun.com/javase/6/docs/api/javax/script/package-summary.html
gives you more detail about the same


During JavaOne 2003, JSR 223 was filed and announced. It caught the attention of many people because it is the first official mentioning of the term "scripting language" in the Java community.

JSR 223 is all about interaction and inter-operability between Java and scripting languages. It is about using Java objects within scripting languages, and emphasizes on the situation of web applications. The original motivation looks like accepting pages written in other (scripting) languages, such as PHP, into the J2EE framework.

It will officially open the door of the Java world to other scripting languages... it will benefit Java technology to become a universal resource on all platforms.

Issues of Using Scripting Languages On Java Platform
developers need to make a choice and stick to it
If Java platform becomes the basis for all scripting language, it can avoid a lot of wasted efforts in the computing communities. For any particular features, open-source developers need just develop a Java version rather than dialects for Perl, Python, Ruby, PHP, Tcl, ... and port them onto different platforms if they are written in C/C++.

JRuby Session @ Sun Tech Days 07

JRuby session by charles Oliver Nuter
It was one of the sessions i was looking forward too .. and was without doubt the most informative
may be coz i have been trying my hands on other java technologies ...
and this will be the one i probably should try now...

Heres what i could grasp from the session

Ruby ...
  • Open Source written in C
  • It was started in 93 with the aim of making a language that was powerful than Perl and more Object Oriented than Python
  • Current version is 1.8 ... 1.9 is under development
  • There are certain cases where it can be slow
  • Everything in it is an Object ... that means we can call the code like "abc".meyjod1() and 1.method2()
  • It is dynamically typed
  • It supports "Meta-programming" ...
    • that means .. one can dynamically generate classes & methods
    • modify existing classes

JRuby
http://jruby.sourceforge.net
  • started in 2002
  • Java implementation of the ruby language
  • One can call Ruby from Java using JSR 223
  • Currently work is going on for 0.9.2
  • NetBeans support
  • Why Jruby ? advantages over Ruby ??
    • Better Performance
    • Unicode Support
    • Integartion with java Lib
  • Why Java User Wants Jruby
    • powerful
    • less lines of code

Rails
Rails has been in development since the Basecamp project started in mid/late 2003 ... released until the 24th of July 2004
It implements MVC architecture
Not something to build business on... but developers are excited about it
sites like http://www.rubyonrails.org/screencasts
have articles like that tell " in 15 mins we go from scratch to complete weblog engine "
woooow ...
talk about ease of coding
even i am excited to know more about it
:)

Friday, February 23, 2007

Experience @ sun tech days 07

Tough to write the first line for my Sun tech days 07 experience ... so could think of just one word
!! AWESOME !!
It really was .. although i was not quite satisfied with the technical coverage of JSF nad Ajax session ...
may be coz i have been trying my hands on them for past 6 months ... on the flip side demos were same as the ones available on sun's web site that was a little discouraging and unexpected ..
but other sessions were really informative
and really am impressed with the NetBeans IDE .... best feature according to me Embedded Java DB ..
initially it was not easy to try out all tutorials that had DB interactivity ... but now guess one can... pretty easily

It all started with a grand welcome session ... and it was really the best i have ever been attended...
I was surprsied to know that the sessions in hyderabd were being broad casted LIVE in bombay , pune , and delhi
and also wondered why not in Banglore ??
I guess as far as IT is concerened the communities are more active there than anywhere else in India
And there were 10,000 attendee in all

after the session by Bhaskar Pramanik, President – India GEM, Sun Microsystems, India.
B. Ramalinga Raju, Chairman, Satyam Computer Services Ltd.
and last but not the least Rich Green, Executive Vice President, Software, Sun Microsystems, Inc. and then the much avaited show started IN STYLE .. some technical demos that were truly amazing and out of world

On stage came up Two teams of Java evangelist ... Each one trying to outshine other with kind of Killer demo0 they had
Team A
they 1st showed us mp3 player with great features like
the user could search music for track having a similar melody like the one playing .. that too on just click of a button moreover one can represent all the albums on one's hard disk in a 3D world and then make a play list by choosing two points ( i.e. albums ) in the space .. for example .. user chooses song 1 which happens to be a fast track and another end point as song 2 which in could be a slow song and the player will automatically make a list that will start from the fast track and move towards the slower one ...
how ever they didn't mention the name of the player .. but i guess it might be on open-solaris .. if not present then may be in upcoming version

Team B
They were a little slow on there first demo
they build a jsf + ajax application ... in which one could use Google's JSF component and directly pin point a location on Google earth ... just key-in the name of city and press enter and there you go .. get Google map on the city staright away , cool but not so impressive .. as they used a JSf component that was built by Google ...

Team A again
they showed us a tool on open solaris called " performance analyzer " .. they had a simple scenario .. Fibonacci in java .. Fibonacci in C .. using the tool one can see the time taken by both programs to run .. and also the machine code genertaed by these two ..

Team B
Now was Team B's turn they had too be good or else Team A would have won ... and they didn't let that happen .. they told us about a new technology called "Form follows function" in short f3 .. the kind of applications that one can build with f3 can have similar interactivity like Flash
more about it on
http://blogs.sun.com/chrisoliver/resource/f3.html
Must try demos
http://blogs.sun.com/chrisoliver/category/F3

Team A
How can they be left behind ... They showed us a demo of SPOT ...
more about it on http://research.sun.com/projects/dashboard.php?id=145
what they had on stage was three wheely robots ... and using a GUI interface they made robot 1 chase robot 2 and robot 2 chase robot 3 and robot 3 chase robot 1 again .... on pressing the go button all three robots started chasing each other ... i had often seen such things on discovery but this was the first time i had a chance to see that in person ... although i didn't understand how was Java related to all this ... may be i should have attended SPOT session , but there were other better sessions .. i didn't wanted to miss those

Team B
VRML ... VRML (Virtual Reality Modeling Language) more about it on http://en.wikipedia.org/wiki/VRML
Demo was cool one ... the screen was divided in two parts the first one containing objects like cone , sphere and backgrounds .. and section below it containing a screen .. the user would just say words like "cone" .. "sphere" on mic and the corresponding objects appeared on screen !! ..
cooooolll application .... the concept behind it was even better ... Ajax application in general are supposed to process text request and give text responses ... but here ajax was taking voice request and sending it to server via scrpit and modifying DOM accordingly .. that too in a 3D world
I wonder how would they do something like XMLHttpRequest.send() ??

Big question .. Who won ??
Well i guess the audience ... it opened our minds !!
:)
More later ...