Naja Summary E-mail
NaJA a java review download

From Java API to NaJA API

    NaJA | Memory management | from java to naja

    NaJA is C++ not Java

    Most ideas of NaJA are taken from Java, but NaJA is a C++ library and C++ is not Java. So NaJA purpose is not to get source compatibility from Java to C++. NaJA simply try to adapt the best of java to C++.

    NaJA elements

    Container templates

    All java containers are main object class containers. This means that those structures handle only Object class or subclass instances. So checks that should be done at compile time will be at run time, and systematic casting is necessary when reading data from containers. NaJA, like STL only provides class templates. This way, strong type control is preserved at compile time and casting at reading is unnecessary.

    Using a java Vector.
    Vector v=new Vector();
    v.add(new String("un"));
    v.add(new String("deux"));
    String e1=(String)v.get(0);
    String e2=(String)v.get(1);
    NaJA TVector
    NAJA<TVector<String> >  v=new TVector<String>();
    v->add(*new String("un"));
    v->add(*new String("deux"));
    NAJA<String> e1=v->get(0);
    NAJA<String> e2=v->get(0);

    Operators redefinition

    Java does not accept operators redefinition. So, to compare object methods are needed. If this is not really changing anything in the matter a program will run, usage of such methods is boring to write and not as readable as it should be. This avoids common ambiguity found in C++ code but is finally not clearer.

    Java object comparison
    Object o1;
    Object o2;
    ...
    if (o1==o2) {
    	// o1 and o2 refers the same object
    }
    if (o1.equals(o2)) {
    	// o1 and o2 are two distinct equal objects
    }
    NaJA objects comparison
    NAJA<Object> o1;
    NAJA<Object> o2;
    ...
    if (o1==o2) {
    	// o1 and o2 refers the same object
    }
    if (*o1==*o2) {
    	// o1 and o2 are two distinct equal object
    }
    if (o1->equals(*o2)) {
    	// an in-line equals function is provided for convenience
    }

    Specific C++ operators

    Of course all C++ operators may be reused where they fit for best code quality.

    java appends
    StringBuffer sb=new StringBuffer();
    sb.append("chaine 1\n");
    sb.append("chaine 2\n");
    C++ converts
    NAJA<StringBuffer> sb=new StringBuffer();
    sb << "chaine 1" << endl
       << "chaine 2" << endl ;
NaJA | a java review | download last update 01/19/2004 - 20:22