Java4C

From Java4c

[edit] Java4C

Goals:

  • Using Java-programming language for embedded software in cooperation with C (and C++-) software.
  • Using a ObjectOriented style of programming also in C!
  • Using Java-like basic routines inclusive operation-system-calls.
  • Using Java for program and test, and translate the sources to C.

[edit] Why Java?

Java is not only a language for internet applications. Java is a programming system for common usage. The first approach to develop Java in 1994 was: Creation of a portable language for embedded applications. Java is used in some embedded applications like mobil phones, routers. It is present with a JTRES: Java Technology for Realtime Embedded Systems provided by companies like Sun/Oracle, Aicas, Aonix/Atego and others.

The Java-syntax for expressions is similar like C. Java is strong declarative, like C. The differences to C are:

  • ObjectOrientation
  • It is a Language of a new generation. The C-style of programming was born in 1970 with orientation to structured programming. Java was born in 1994.
  • Java supports a better test of algorithms. If there are any errors for example in the addressing (indexing) of arrays, it is detected safely in runtime. The algorithms need not be tested step by step to prevent such errors. A paradigma compile 'n run can be used. The time for testing can be reduced drasticly without reducing the quality of software respectively more complex algorithms can be tested in the same time like simple algorithm in C or C++.

Java uses dynamic data. The approach of dynamic data helps to handle with variegated data in many threads in large applications. For example the String-processing needs dynamic memory. But it is also possible to handle with static data (allocated on startup). For example, String processing using a StringBuilder-instance and the CharSequence-interface can execute without allocation of memory. Static data are proper to use for embedded systems often.

[edit] Why not C++?

C++ is ObjectOriented and a modern programming language too. It is downward-compatible with C.

But the usual programming style in C++ divergates from the style in C. There are handled with dynamic memory in some basic classes, complex constructs using the template concept are usual. An ordinary C++-program can't be used for embedded programming often.

The disadvantages of the C-language: Unsafe pointer arithmetic, arbitrary casts, unchecked array addressing are all present in C++ too. C++ doesn't help for testing such errors like C.

Personal tools