Posted By:
5 Feb, 2014 10:59 am PST

Advantages/Disadvantages of Java over C

 How Java Differs From c

Although Java was modelled after C, it differs from C in many ways. Java does not incorporate a number of features available in C. For the benefit of C programmers, we point here a few major differences between C and Java languages.

 Java and C

Java is a lot like C but the major difference between Java and C is that Java is an object-oriented language and has mechanism to define classes and objects; whereas C is a procedure oriented language. In an effort to build a simple and safe language, the Java team did not include some of the C features in Java.

·   JAVA is Object-Oriented while C is procedural. Different Paradigms, that is, most differences between the features of the two languages arise due to the use of different programming paradigms. C breaks down to functions while JAVA breaks down to Objects. C is more procedure-oriented while JAVA is data-oriented.

·  Java is an Interpreted language while C is a compiled language.

·  C is a low-level language while JAVA is a high-level language.

      ·  C uses the top-down {sharp & smooth} approach while JAVA uses the bottom-up {on the rocks} approach. In C, formulating the program begins by defining the whole and then splitting them into smaller elements. JAVA (and C++ and other OOP languages) follows the bottom-up approach where the smaller elements combine together to form the whole.

      ·  JAVA supports Method Overloading while C does not support overloading at all: JAVA supports function or method overloading-that is we can have two or more functions with the same name (with certain varying parameters like return types to allow the machine to differentiate between them). That is to say, we can overload methods with the same name having different method signatures. JAVA (unlike C++), does not support Operator Overloading while C does not allow overloading at all.

       ·  Unlike C, JAVA does not support Preprocessors, & does not really need them. The preprocessor directives like #include & #define, etc are considered one of the most essential elements of C programming. However, there are no preprocessors in JAVA. Since Java does not support preprocessors; we cannot use #define,   #include, and #ifdef statements. JAVA uses other alternatives for the preprocessors. For instance, public static final is used instead of the #define preprocessor. Java maps class names to a directory and file structure instead of the #include used to include files in C.

      ·  Java does not include the C unique statement keywords goto, sizeof, and typedef.

      ·  Java does not contain the data types struct, union and enum.

      ·  Java does not define the type modifiers keywords auto, extern, register, signed, and unsigned.

      ·  Java source and binaries are entirely portable (subject to availability of appropriate libraries), since the source format is standardized, and the binaries run on a software emulation of a standardized processor, which also slows execution. In C, binaries are not usually portable from one platform to another, because they use the platform's native hardware processor directly, and so run faster.

      ·  Java does not support an explicit pointer type. Pointer go backstage in JAVA while C requires explicit handling of pointers. When it comes to JAVA, we don’t need the *’s & &’s to deal with pointers & their addressing. More formally, there is no pointer syntax required in JAVA. It does what it needs to do. While in JAVA, we do create references for objects.

      ·  Java does not support any mechanism for defining variable arguments to functions.

      ·Java requires that functions with no arguments must be declared with empty parenthesis and not with the void keyword as done in C.

      ·  Java adds new operators such as instanceof and >>>.

      · Java adds labelled break and continue statements.

      ·  The standard Input & Output Functions: Although this difference might not hold any conceptual (intuitive) significance, but it’s maybe just the tradition. C uses the printf & scanf functions as its standard input & output while JAVA uses the System.out.print & System.in.read functions.

      ·  Java adds many features required for object-oriented programming.

 Advantages of Java over C language

  ·        We all know what a compiler does. It takes your code & translates it into something the machine can understand-that is to say-0′s & 1′s-the machine-level code. That’s exactly what happens with our C code-it gets ‘compiled’. While with JAVA, the code is first transformed to what is called the bytecode. This bytecode is then executed by the JVM (Java Virtual Machine). For the same reason, JAVA code is more portable.

  · C is a low-level language (difficult interpretation for the user, closer significance to the machine-level code) while JAVA is a high-level lagunage(abstracted from the machine-level details, closer significance to the program itself).

  · The Behind-the-scenes Memory Management with JAVA & The User-Based Memory Management in C: malloc’ & ‘free’ are the library calls used in C to allocate & free chunks of memory for specific data (specified using the keyword ‘sizeof’). Hence in C, the memory is managed by the user while JAVA uses a garbage collector that deletes the objects that no longer have any references to them.

   ·  Exception Handling in JAVA And the errors & crashes in C:When an error occurs in a Java program it results in an exception being thrown. It can then be handled using various exception handling techniques. While in C, if there’s an error, there IS an error.

  ·  Java programs may be easier to develop since:

a. dynamic memory management is handled largely automatically, and

b. Diagnostic exceptions are thrown for illegal operations (such as accessing through a null reference, or accessing beyond the bounds of an array).

· Improved software-development productivity: Object-oriented programming is modular, as it provides separation of duties in object-based program development. It is also extensible, as objects can be extended to include new attributes and behaviours. Objects can also be reused within an across applications. Because of these three factors – modularity, extensibility, and reusability – object-oriented programming provides improved software-development productivity over traditional procedure-based programming techniques.

      ·  Improved software maintainability: For the reasons mentioned above, object-oriented software is also easier to maintain. Since the design is modular, part of the system can be updated in case of issues without a need to make large scale changes.

      · Faster development: Reuse enables faster development. Object-oriented programming languages come with rich libraries of objects, and code developed during projects is also reusable in future projects. 

       · Lower cost of development: The reuse of software also lowers the cost of development. Typically, more effort is put into the object-oriented analysis and design, which lowers the overall cost of development.

        · Higher quality software: Faster development of software and lower cost of development allows more time and resources to be used in the verification of the software. Although quality is dependent upon the experience of the teams, object oriented programming tends to result in higher-quality software.

 

Disadvantages of Java over C language

 ·       Larger program size: Object-oriented programs typically involve more lines of code than procedural programs.

      ·        Not suitable for all types of problems: There are problems that lend themselves well to functional-programming style, logic-programming style, or procedure-based programming style, and applying object-oriented programming in those situations will not result in efficient programs.

      ·  Steep learning curve: The thought process involved in object-oriented programming may not be natural for some people, and it can take time to get used to it. It is complex to create programs based on interaction of objects. Some of the key programming techniques, such as inheritance and polymorphism, can be challenging to comprehend initially.

      ·  C programs will usually run faster, since dynamic memory management (which is often not required) is fully under the programmer's control, and there are no checks for illegal operations.

· In C it’s easier to work with hardware directly. Also C programs are usually more efficient.

 

 

 

Attachment:None


Video is posted for better understanding of the concept.

Was it useful?  



How Java Differs From c?

Although Java was modelled after C, it differs from C in many ways. Java does not incorporate a number of features available in C. For the benefit of C programmers, we point here a few major differences between C and Java languages.

 

Java vs C

Java is a lot like C but the major difference between Java and C is that Java is an object-oriented language and has mechanism to define classes and objects; whereas C is a procedure oriented language. In an effort to build a simple and safe language, the Java team did not include some of the C features in Java.

  1. JAVA is Object-Oriented while C is procedural. Different Paradigms, that is, most differences between the features of the two languages arise due to the use of different programming paradigms. C breaks down to functions while JAVA breaks down to Objects. C is more procedure-oriented while JAVA is data-oriented.
  2. Java is an Interpreted language while C is a compiled language.
  3. C is a low/mid-level language while JAVA is a high-level language.
  4. C uses the top-down {sharp & smooth} approach while JAVA uses the bottom-up {on the rocks} approach. In C, formulating the program begins by defining the whole and then splitting them into smaller elements. JAVA (and C++ and other OOP languages) follows the bottom-up approach where the smaller elements combine together to form the whole.
  5. JAVA supports Method Overloading while C does not support overloading at all: JAVA supports function or method overloading-that is we can have two or more functions with the same name (with certain varying parameters like return types to allow the machine to differentiate between them). That is to say, we can overload methods with the same name having different method signatures. JAVA (unlike C++), does not support Operator Overloading while C does not allow overloading at all.
  6. Unlike C, JAVA does not support Preprocessors, & does not really need them. The preprocessor directives like #include & #define, etc are considered one of the most essential elements of C programming. However, there are no preprocessors in JAVA. Since Java does not support preprocessors; we cannot use #define,   #include, and #ifdef statements. JAVA uses other alternatives for the preprocessors. For instance, public static final is used instead of the #define preprocessor. Java maps class names to a directory and file structure instead of the #include used to include files in C.
  7. Java does not include the C unique statement keywords goto, sizeof, and typedef.
  8. Java does not contain the data types struct, union and enum.
  9. Java does not define the type modifiers keywords auto, extern, register, signed, and unsigned.
  10. Java source and binaries are entirely portable (subject to availability of appropriate libraries), since the source format is standardized, and the binaries run on a software emulation of a standardized processor, which also slows execution. In C, binaries are not usually portable from one platform to another, because they use the platform's native hardware processor directly, and so run faster.
  11. Java does not support an explicit pointer type. Pointer go backstage in JAVA while C requires explicit handling of pointers. When it comes to JAVA, we don’t need the *’s & &’s to deal with pointers & their addressing. More formally, there is no pointer syntax required in JAVA. It does what it needs to do. While in JAVA, we do create references for objects.
  12. Java does not support any mechanism for defining variable arguments to functions.
  13. Java requires that functions with no arguments must be declared with empty parenthesis and not with the void keyword as done in C.
  14. Java adds new operators such as instanceof and >>>.
  15. Java adds labelled break and continue statements.
  16. he standard Input & Output Functions: Although this difference might not hold any conceptual (intuitive) significance, but it’s maybe just the tradition. C uses the printf & scanf functions as its standard input & output while JAVA uses the System.out.print & System.in.read functions.
  17. Java adds many features required for object-oriented programming.

Was it useful?  




Please login to reply to this problem.