NaJA |
Memory management |
from java to naja
The writing language does not matter,
the thinking language does.
What is NaJA ?
NaJA stands for Native C++ Java-like API. The Java API is
is a rich, standard and quite good design object library. There
is no complete equivalent usable directly with C++. C++
developers must reuse old C libraries or a big set of C++
libraries, each with its own design. This make C++ difficult
and code not as readable as it should be. The main NaJA goal
is to provide what standard ANSI C++ library and STL don't.
NaJA also intends to bring C++ as easy as
java can be
while letting hackers free to decide whenever they need
assistance (and then, accept some limitations, no magic!) or
not. Not providing at all pointers and multiple inheritance
because they are hard to use is not a solution !
NaJA features
Automatic memory management
Garbage collection is one of the nicest feature of java, and
memory management is often the main problem to get C/C++ programs
work well. So NaJA includes a tiny garbage collection. Tiny,
because it is not as transparent as it could be. It is designed
to be as simplest as possible and optional : use it when you
want even if there remind some work to complete this goal.
package
Packages can help software designers to structure sources
files, libraries. C++ namespaces can be an equivalent and helps
prevent from ambiguous class names. But java packages brings
a special class member visibility : package private (this is
the default when none visibility is given). This is very
useful and complete nicely in most cases where C++ friend keyword
can't. NaJA provides the package_private macro to offer this
facility.
Container templates
There is no really need for new templates since STL
availability. NaJA templates are not so good, they just reuse
NaJA tiny garbage collector for memory management and have the
same interface than Java ones. Then as those containers became
templates, those awful systematic static casting as java's
containers only manage the root Object class.
Threads, socket, graphic toolkit...
Progressively, all standard tools provided with java API will
have a NaJA equivalent. It's a colossal job and all
help is welcome.
Author's home page (French)