Friday, February 26, 2010

What are Interpreted Languages ???

A special mention about Sachin's knock on my article for the day , one thing that is ordeal with him has to be his continued passion for the game , for the past 20 years.

So let us cont.

Programming Languages , are classified on various aspects :

1) Fundamentally on design concepts :
    a) Object - oriented.
    b) Procedure - oriented.
    c) Function - oriented.

2) Type of runtime , as Interpreted or host-dependant compiler schemes.

 In Interpreted languages , the output of the compiler , is not directly to be hosted on a machine , for execution , instead it converts the source program , into a intermediate - form ,which is usually executed , by a "virtual-machine".

Some Examples:
Java , Python , Ruby , PHP ,Perl etc..

Advantages:
The main reason , for resorting , to interpreted languages , is the need for portability of programs.

Disadvantages:
They are inavoidably slow , as the execution , is under the supervision of  the virtual machine.

For a complete list of all interpreted languages visit:
http://en.wikipedia.org/wiki/Interpreted_language

Posted By:
Jayanthi GM(Course Instructor , Java @ PESIT)
Prashanth Raghu(Student Assistant)

Tuesday, February 23, 2010

Pointers in python

Hello guys , here is a small note on pointers in python . For all those unfamiliar with python , it is a interpreted , scripting , object - oriented and high level programming language , developed on C.

POINTER CONCEPT IN PYTHON:

Python , adopts a model , which is to be precise , very similar to java , ie all references , to objects are treated as pointers , but with very limited functionality over their addresses.

The following points , will clarify the concept presented above:

1) All objects in python , are references to memory locations and an assignment , such as a=b, assigns a reference of location of b to a.
But , in python , there is no explicit pointer arithmetic , very similar to java. The operations on the references , are well bound by the address of the pointed location of memory.

2) In python parameters , passed to functions , very similar to the assignment statement mentioned before.

3) In python , primitive types ,such as (int,str,tuple), are treated as immutable , such that their memory locations , cannot be modified , by accidental references.

Posted By:
Jayanthi GM(Course Instructor , Java ,PESIT)
Prashanth Raghu (Student Assistant)

Installing Ruby on Linux

This post talks about the installation , of ruby on debian and rpm based systems.

On debian systems:
On debian systems , the default package manager is the aptitude package manager.
Ex: Ubuntu , debian , Sedux etc ..

Command to install:
[]$sudo apt-get install ruby1.9.1-full

On RPM based systems:
The default package manager is the RPM -> Red Hat Packager manager.

Refer to this link : http://www.linuxweblog.com/ruby-on-rails-install

Posted By:
Jayanthi GM(Course Instructor , Java , PESIT)
Prashanth Raghu (Student Assistant)

Interactive online ruby Interpreter

Hi guys today , the web is being revolutionised , by technologies , such as PHP and Ruby . To try out ruby , on your browser ,


http://tryruby.org/

An interesting fact not to be missed , Ruby was developed by the Japanese.

Posted By:
Jayanthi GM(Course Instructor , Java , PESIT)
Prashanth Raghu(Student Assistant)

Most popular programming language

Hi everyone , in this age of web it is not surprising to note that more and more programmers are tending towards , web programming technologies.
A sample survey by develeperiq.in , shows the following result as of 23/02/2010.

  • Java -- 5702 votes
  • C/C++ -- 41053 votes
  • PHP -- 55398 votes
  • C# -- 3167 votes
  • VB -- 33841 votes
  • Python -- 5319 votes

Nice change , swing towards web programming languages.

Posted By:
Jayanthi GM(Course Instructor Java , PESIT)
Prashanth Raghu (Student Assistant)

Sunday, February 21, 2010

It is a mobile story -> Google's Android

When google comes up with a new product , it always has it's own distinct flavour and substance . Here is an article about the acquisition aspect of google.

We all know or have definitely heard about the Android, the mobile OS of google.
The one fact , we need to learn is that , Android Inc. was a small firm working in mobile OS , and was acquired by Google in 2005. Google , later went on to make the open mobile alliance , consisting of 47 companies , from hardware , software and telecommunication streams .

Android applications ,are developed in Java , through the libraries provided by Google.

So here we go , something in favour of start up's.

Posted by,
Jayanthi GM(Course Instructor , Java ,PESIT)
Prashanth R (Student Assistant)

The Sun finally sets down OOOracle

Today , as I script this page ,  I am internally feeling a sense of voidness . One of my favorite companies , none other than sun microsystems , has been acquired by the software giant , Oracle . The link sun.com , no longer leads you to the sun.com website , we are familiar to , but to oracle's page , which indicates the merger of the giants . Let us hope , Oracle keeps up it's promise , and maintains the standards and quality , provided by sun , for such a long time.

We miss you , may the sun never set upon you.

Posted by,
Jayanthi GM(Course Instructor , Java PESIT)
Prashanth Raghu ( Student Assistant )

Saturday, February 20, 2010

MultiHeaded python - Threading in python

Hi guys , as a student of multicore programming , I was just curious about threading facilities in higher level programming languages like python . So just revoking on the idea , I did find a good small ping application , using python.

Here is the source code : try it and make the changes to suite your local network.
I have made a comment , which shall help you .

original source : http://www.wellho.net/solutions/python-python-threads-a-first-example.html


import os
import re
import time
import sys
from threading import Thread

class testit(Thread):
   def __init__ (self,ip):
      Thread.__init__(self)
      self.ip = ip
      self.status = -1
   def run(self):
      pingaling = os.popen("ping -q -c2 "+self.ip,"r")
      while 1:
        line = pingaling.readline()
        if not line: break
        igot = re.findall(testit.lifeline,line)
        if igot:
           self.status = int(igot[0])

testit.lifeline = re.compile(r"(\d) received")
report = ("No response","Partial Response","Alive")

print time.ctime()

pinglist = []

for host in range(1,4): # Change the IP range here
   ip = "192.168.1."+str(host)
   current = testit(ip)
   pinglist.append(current)
   current.start()

for pingle in pinglist:
   pingle.join()
   print "Status from ",pingle.ip,"is",report[pingle.status]

print time.ctime()

 Posted by :
  Jayanthi GM (Course Instructor for Java , PESIT )
  Prashanth Raghu ( Student Assistant )

Wednesday, February 17, 2010

Core dumping of runtime allocated memory

Hello Folks , today we are going to demonstrate a simple application , which can generate the core dump of the memory allocated to objects at runtime.

Below is illustrated a simple c++ program , along with a trial run of the output try it and a fair analysis yields the fact about allocation of memory to the objects at runtime .

As an enhancement  , we can compile the program twice into 2 object files , and then run them simultaneously on two terminals , with considerable delay to affix the illustrated concept .

// The program is to be tested in any Linux environment
// We have tested the program in Fedora core 12

#define MARKERSIZE 5
#define BEGMARKER "" set it to
#define ENDMARKER "
" set it to
#include
#include
#include
#include
#include
#include


using namespace std;

class A
{
    char beginA[MARKERSIZE];
    int i;
    char b;
    char endA[MARKERSIZE];

public:
    A() : i(0xabcd), b('X')
    {
        std::cout << "CTOR" << std::endl;
        strcpy(beginA,BEGMARKER);
        strcpy(endA,ENDMARKER);
    }

    ~A()
    {
        std::cout << "DTOR" << std::endl;
    }

    void displayme()
    {
        printf("ADDR BEG = %p\n",beginA);
        printf("ADDR I = %p\n", &i);
        printf("ADDR B = %p\n", &b);
        printf("ADDR END = %p\n",endA);
    }
};


int main()
{
    for(int i=0 ; i<10 ; ++i)
    {
        A *a = new A();
        a->displayme();
        //delete a; remove this comment in the second run .
    }
        
       //send a SIGSEGV signal to generate core
    pid_t pid = getpid();
    kill(pid,11);
}

Trial Run :

ADDR BEG = 0x8fca008
ADDR I = 0x8fca010
ADDR B = 0x8fca014
ADDR END = 0x8fca015
CTOR
ADDR BEG = 0x8fca020
ADDR I = 0x8fca028
ADDR B = 0x8fca02c
ADDR END = 0x8fca02d
CTOR
ADDR BEG = 0x8fca038
ADDR I = 0x8fca040
ADDR B = 0x8fca044
ADDR END = 0x8fca045
CTOR
ADDR BEG = 0x8fca050
ADDR I = 0x8fca058
ADDR B = 0x8fca05c
ADDR END = 0x8fca05d
CTOR
ADDR BEG = 0x8fca068
ADDR I = 0x8fca070
ADDR B = 0x8fca074
ADDR END = 0x8fca075
CTOR
ADDR BEG = 0x8fca080
ADDR I = 0x8fca088
ADDR B = 0x8fca08c
ADDR END = 0x8fca08d
CTOR
ADDR BEG = 0x8fca098
ADDR I = 0x8fca0a0
ADDR B = 0x8fca0a4
ADDR END = 0x8fca0a5
CTOR
ADDR BEG = 0x8fca0b0
ADDR I = 0x8fca0b8
ADDR B = 0x8fca0bc
ADDR END = 0x8fca0bd
CTOR
ADDR BEG = 0x8fca0c8
ADDR I = 0x8fca0d0
ADDR B = 0x8fca0d4
ADDR END = 0x8fca0d5
CTOR
ADDR BEG = 0x8fca0e0
ADDR I = 0x8fca0e8
ADDR B = 0x8fca0ec
ADDR END = 0x8fca0ed
ADDR BEG = 0x8fca008
ADDR I = 0x8fca010
ADDR B = 0x8fca014
ADDR END = 0x8fca015
CTOR
ADDR BEG = 0x8fca020
ADDR I = 0x8fca028
ADDR B = 0x8fca02c
ADDR END = 0x8fca02d
CTOR
ADDR BEG = 0x8fca038
ADDR I = 0x8fca040
ADDR B = 0x8fca044
ADDR END = 0x8fca045
CTOR
ADDR BEG = 0x8fca050
ADDR I = 0x8fca058
ADDR B = 0x8fca05c
ADDR END = 0x8fca05d
CTOR
ADDR BEG = 0x8fca068
ADDR I = 0x8fca070
ADDR B = 0x8fca074
ADDR END = 0x8fca075
CTOR
ADDR BEG = 0x8fca080
ADDR I = 0x8fca088
ADDR B = 0x8fca08c
ADDR END = 0x8fca08d
CTOR
ADDR BEG = 0x8fca098
ADDR I = 0x8fca0a0
ADDR B = 0x8fca0a4
ADDR END = 0x8fca0a5
CTOR
ADDR BEG = 0x8fca0b0
ADDR I = 0x8fca0b8
ADDR B = 0x8fca0bc
ADDR END = 0x8fca0bd
CTOR
ADDR BEG = 0x8fca0c8
ADDR I = 0x8fca0d0
ADDR B = 0x8fca0d4
ADDR END = 0x8fca0d5
CTOR
ADDR BEG = 0x8fca0e0
ADDR I = 0x8fca0e8
ADDR B = 0x8fca0ec
ADDR END = 0x8fca0ed

A prerequisite b4 we run the program ,
run the following command:

[]#ulimit -l unlimited

to set the core dump size to unlimited .

Original Article at :http://cprogrammers.blogspot.com/2009/02/c-heap-marker-to-detect-memory-leaks.html

Authored by :

Jayanthi GM ( Course Instructor for Java ,PESIT )
Prashanth Raghu ( Student Assitant )

Thursday, February 11, 2010

A Small post on Java Virtual Machines

We have synonymously able to link java Virtual machines ( JVM ) and Sun Microsystems , but as we waded through the web , we found that there exists several proprietary implementations of the Virtual Machine.

As of today we just propose a link to the site . Enjoy this small post !!!!!

Link : http://en.wikipedia.org/wiki/List_of_Java_virtual_machines

Posted By,
Jayanthi GM ( Course Instructor for Java , PESIT )
Prashanth Raghu ( Student Assistant )

Friday, February 5, 2010

Accessing twitter data from java - jtwitter API jweet it !!!!!!!

This article is to be an introduction for usage of the jtwitter API. This code is a simple application which can obtain the profile images of the user who logs in .

Prerequisites :
1) Twitter account
2) Fundamentals of java.
3) Download the jtwitter API from :[jtwitter].
4) Use the code given below , after importing the jtwitter API to your project.

CODE :

package twitterclient;

import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import winterwell.jtwitter.Twitter;
import winterwell.jtwitter.Twitter.User;

/**
*
* @author Jayanth GM & Prashanth Raghu
*/
public class Main {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here

Twitter t = new Twitter("user name","password");
List followers = t.getFollowers("User twitter name");

Iterator iterator = followers.iterator();
while(iterator.hasNext()){
User current = iterator.next();
System.out.println(current.getProfileImageUrl());
}

}

}

Original Article : [original]

Posted By :
Jayanthi GM[Course Instructor Java , PES Institute of technology]
Prashanth Raghu[Student Assistant]

Feel free to comment.

Thursday, February 4, 2010

Java Card Technology - An Introduction

As Prof.Ali Toyserkani puts it :

                               Java Card = Java + Card   !!!!!!

The platform aims at enabling java for smart cards , to be deployed on small embedded devices , such as cost - effective moblie phones.

The best example of a smart card is the SIM Card       (SIM -> Subscriber Identity Module ) .
Other Examples are : Credit Card , Purchase Cards etc ..


The Java Card technology , when enabled on smart cards , are able to process architecture - independent java programs to enable it's functioning.
The Java Card enabled devices is strictly adhered to the standards of the Java Card Technology.

Smart Cards : 




       Reference :http://en.wikipedia.org/wiki/File:Differentsmartcardpadlayouts.jpg


A Java Card by model has these fundamental aspects :
1) A Java VM and a OS below it.
2)  Java API's .


The technology , interacts with an off court application , which is used for the back end support and user card entry.


The current version of Java Card Technology is 3.0 which is in two flavours :

1) Classic edition , which is used for backward compatibility with version Java Card 2.2.2.
2) Connected edition , which also adds netwok - oriented features .

For more information  visit :
 1) Smart Cards
  2) Java Card Technology

Please feel free to comment.


Article by :
Jayanthi GM ( Java Course Instructor , PES Insitute Of Technology)
Prashanth Raghu (Student Assistant)

Tuesday, February 2, 2010

JAVA SECURITY MODEL - JAVA SANDBOX

Strongly required across network environment


- Safety of network-mobile code.

A java program must play only inside its sandbox.

- Can do anything within the boundaries of its sandbox, but cannot take any action outside boundaries.


- It cannot create  a new process, load a new dynamic library and directly call a native method.


- Reading and writing to the local disk is not possible .


- Make network connections to any other host than the own server.


-Welcomes code from any source.


-Restricts code from untrusted sources , by making a distinction between the standard java API and the other sources.


-Hence, there is always  virus free or bug free code ( Taken care by sandbox).


- can create a sanbox ( using the java.security framework )and as well use sandbox created by others.

Components of sandbox:

  • Class loader architecture (Verifies the class files at load time).
  • Class file verifier( Verifies the integrity at runtime )
  • Security manager and java API
more details will be posted in the next post......keep blogging.............