Index: /trunk/DocHFI_L2/sdg.tex
===================================================================
--- /trunk/DocHFI_L2/sdg.tex	(revision 1014)
+++ /trunk/DocHFI_L2/sdg.tex	(revision 1015)
@@ -8,4 +8,7 @@
 %  Extension de symboles mathematiques
 \usepackage{amssymb}
+
+% package a mettre pour faire du pdf
+\usepackage{palatino}
 
 %  Definition de taille de page
@@ -23,5 +26,8 @@
 \begin{titlepage}
 \vspace{1cm}
-\rule{110 mm}{0.5 mm}\makebox[50 mm]{\bf Planck HFI L2}
+\vspace{1cm}
+\makebox[34mm][c]{\includegraphics[width=3cm]{hfi_icon_vsmall.eps}}
+\raisebox{12mm}{\rule{80 mm}{0.5 mm}\makebox[50 mm]{\bf Planck HFI L2}}
+\vspace{2cm}
 \vspace{2cm}
 \begin{center}
@@ -37,5 +43,5 @@
 {É. Aubourg} & {\tt aubourg@hep.saclay.cea.fr} \\
 % {É. Lesquoy} & {\tt lesquoy@hep.saclay.cea.fr} \\
-% {C. Magneville} & {\tt cmv@hep.saclay.cea.fr} \\
+{C. Magneville} & {\tt cmv@hep.saclay.cea.fr} \\
 \end{tabular}
 
@@ -51,18 +57,35 @@
 
 \newpage
-% \tableofcontents
 
 \section{Introduction}
 We intend to gather gradually in this document the guidelines 
-for the development of Planck HFI Level 2 data processing softwares.
+for the development of Planck HFI Level 2 data processing software.
 We assume throughout this document that C++ is the baseline option
 as the programming language for the development of Planck HFI 
-Level 2 processing software.
-
-\section{Integration of software modules in different languages}
-We review here some of the problems which may arise when integrating software 
-modules written in other languages into C++ programs.
-
-\subsection{C and C++}
+Level 2 processing software, we review here briefly some of 
+the properties of the C++ and Java language and interoperability
+with other language, mainly C and Fortran.
+
+
+\section{C++}
+{\bf C++ \ } is an object-oriented programming language which 
+has been developed by extending the {\bf C \ } language.
+Some of the additional possibilities incorporated in C++ are:
+\begin{itemize}
+\item Introduction of object and classes
+\item function overloading
+\item Operator overloading
+\item function and operator inlining 
+\item virtual functions (polymorphism)
+\item public, protected and private members
+\item dynamic memory management operators
+\item Exception handling
+\item generic (template) function and classes
+\end{itemize}
+
+We discuss here the some of the problems and solutions arising when 
+integrating software modules written in other languages into C++ programs.
+
+\subsection{Calling C code from C++} 
 C++ extends the possibilities offered by the C language. 
 All of the C language data types and function call syntax are thus 
@@ -75,5 +98,5 @@
 int fo(double a, double b);
 \end{verbatim}
-Using {\bf C}, one would have written:
+Using {\bf C \ }, one would have written:
 \begin{verbatim} 
 int foi(int a);
@@ -83,5 +106,5 @@
 C++ compilers use internally a name containing the encoding of the
 argument list. In order to instruct the compiler to use simple 
-names, {\bf C} functions should be declared as \\
+names, {\bf C \ } functions should be declared as \\
 {\tt extern "C" }. This is usually included in the header
 file (.h). In the example above, the header file (.h) file
@@ -99,5 +122,5 @@
 \end{verbatim}
 
-\subsection{Fortran and C++}
+\subsection{Calling Fortran code from C++}
 Fortran is a simple language and uses only basic data types.
 Although the exact mapping between Fortran and C/C++ basic data types 
@@ -137,23 +160,23 @@
 \end{verbatim}
 
-The case of character string arguments in fortran subroutines
+The case of character string arguments in Fortran subroutines
 needs a bit more attention, and the string length needs to be passed 
 as an additional integer type argument.
-As with {\bf C} functions, fortran functions or subroutines 
-have to be delared {\tt extern "C"} to be used within {\bf C++}
-programs. {\bf C/C++} driver routines can easily be written for
-extensively used fortran modules, simplifying calling sequences.
-
-It should also be noted that the fortran support libraries have to be 
+As with {\bf C \ } functions, Fortran functions or subroutines 
+have to be declared {\tt extern "C"} to be used within {\bf C++ \ }
+programs. {\bf C/C++ \ } driver routines can easily be written for
+extensively used Fortran modules, simplifying calling sequences.
+
+It should also be noted that the Fortran support libraries have to be 
 included for the link with the C++ driver.
-It is also possible to translate the whole fortran source code 
-into {\bf C} code using {\bf f2c} program. The call syntax 
+It is also possible to translate the whole Fortran source code 
+into {\bf C \ } code using {\bf f2c \ } program. The call syntax 
 will be exactly the same as with a Fortran compiler, and 
 {\tt libf2c.a} should be used when linking the program.
 
-It is very difficult to use C++ classes directly from fortran.
-However, high level functionalities based on a C++ libray can 
-be wrapped in a fortran style function which can be 
-called from fortran. One looses of course many of the 
+It is very difficult to use C++ classes directly from Fortran.
+However, high level functionalities based on a C++ library can 
+be wrapped in a Fortran style function which can be 
+called from Fortran. One looses of course many of the 
 possibilities offered by underlying C++ library.
 
@@ -220,47 +243,96 @@
 
 
+\section{Java}
+Java \footnote{Information on the Java platform and language 
+can be found at {\bf http://java.sun.com} }
+is a rather recent object-oriented programming language. It is 
+based on the concept of a virtual machine, and a very extended 
+standard library.
+
+Java compilers produce "byte-codes" that are interpreted in a virtual 
+machine (JVM). Thus, pure Java programs are platform-independent and 
+portable. The very extended libraries that are available for the 
+language make it a very good choice for user interfaces, network 
+programming, distributed objects, database access. Numeric 
+computation libraries start to appear but are still in early stages 
+of development.
+
+The Java language is strongly typed, with dynamic typing information. 
+It is dynamic in essence as class bytecodes can be loaded into the 
+JVM on request.
+It uses a garbage collector for memory management. Memory leaks and 
+memory access errors cannot exist. All this makes debugging easier 
+than with C++.
+
+The overhead of interpreting the bytecodes in the virtual machine is 
+alleviated by the development of "JIT" (Just In Time) compilers, that 
+do a dynamic compilation. Java programs are typically 3 times slower 
+than their equivalent in C++, but the exact figure might vary between 
+1 and 5 depending on the type of program.
+
+Two features convenient for numeric library development and usage 
+present in C++ are missing in Java: templates and operator overloading. 
+Typically, a single code cannot be specialised for 
+floats and doubles automatically, and one must write, if A, B and C 
+are matrices, {\tt C = A.mult(B) instead of C = A*B} . 
+
+\subsection{Calling C/C++ code from Java }
+
+A Java library (JNI, Java Native Interface) allows to call C/C++ code 
+from Java programs. Of course, portability is then lost.
+Methods in Java objects can be declared {\tt native}. A tool then 
+produces C/C++ headers for coding these methods in C/C++. This code 
+can call existing C/C++/Fortran code, and even map the Java object to 
+a C++ object.
+
+Because the layout of objects in memory is not fixed in the JVM 
+specifications, all accesses to methods and member variables are done 
+through interface pointers. Accessing arrays can imply a copy of the 
+array on input, and a copy back on return if the array was modified.
+
+Since Java memory management is garbage-collector-based, C/C++ 
+programs that want to hold references to Java objects, or create Java 
+objects, must interact with the garbage collector explicitly.
+
+JNI allows also C/C++ programs to instantiate a JVM and Java objects, 
+and access them.
+
+\subsection{Java and CORBA}
+
+Another solution to call C++ objects from Java, or vice-versa, is to 
+use CORBA. CORBA is a standard distributed objects framework, and 
+Java 2 comes with a CORBA-2 compliant ORB (Object Request Broker), 
+JavaIDL.
+
+Objects distributed through CORBA must have their interface defined 
+in a specific language, IDL. Tools then creates stubs for any 
+language, as well as implementation skeletons.
+
+An object can then physically exist on a machine, implemented in C++, 
+and be manipulated remotely through Java stubs, as if it were a local 
+Java object. CORBA offers thus language-independent distributed 
+objects.
+
+It adds overhead compared to JNI, because of the presence of a 
+network layer, but offers more functionality. In particular, the C++ 
+objects are platform-dependent, but the Java code that uses them, 
+being pure Java code, remains portable.
+
+
 \newpage
 \appendix
 
-\section{The C++ language}
+\section{C++ standard and compilers}
 \vspace{5 mm}
-{\bf C++} is a very powerful Object Oriented language. 
-It has been developped by extending the {\bf C} language, 
-keeping in mind the efficiency and performance, 
-as well as easy integration with existing softwares.
-It incorporates new possibilities such as:
-
-\begin{itemize}
-\item Introduction of object and classes
-\item function overloading
-\item Operator overloading
-\item function and operator inlining (optimisation)
-\item virtual functions (polymorphism)
-\item public, protected and private members
-\item dynamic memory management operators
-\item Exception handling
-\item generic (template) function and classes
-\end{itemize}
 
 {\bf C++} can be considered now as a mature language. 
-C++ class library covering various areas, including
-numerical data processing are available as freeware 
-or commercial products. Many software tools feature
-a standard C++ API. 
-\par \vspace{3mm}
 The current standard for C++ and C are defined by
 \footnote{Available from {\bf http://www.ansi.org/ } }: 
 \begin{itemize}
-\item[] {\bf ISO/IEC 14882-1998(E)} Programming languages -- C++ 
-\item[] {\bf ANSI/ISO 9899-1990} for Programming Languages C  
+\item[] {\bf ISO/IEC 14882-1998(E) \ } Programming languages -- C++ 
+\item[] {\bf ANSI/ISO 9899-1990 \ } for Programming Languages C  
 \end{itemize}
 
-
-\newpage
-\section{C++ compilers}
-
-
-Powerful compilers are available on most platforms, 
-including:
+Powerful compilers are available on most platforms, including:
 
 \begin{itemize}
