Ask Questions?

View Latest Questions


 
 

Java vs. C
Posted on: July 26, 2006 at 12:00 AM
Is Java easier or harder than C?

Java: Java vs. C

Is Java easier or harder than C?

Java is harder because ...

  • Java is more powerful and can do much more than C. For example, C doesn't have a graphical user interface (GUI), and C doesn't have any way to do object-oriented programming (OOP). It's possible to write in Java in a C style, avoiding the new powerful features of Java. But that is foolish.
  • Java either checks for errors, or makes you check for errors. C lets you do many things that would cause errors (for example, convert strings to integers, or do I/O), but doesn't make you write code to handle the errors. Java makes you write try...catch statements around things that might cause problems.

Java is easier because ...

  • Java checks for errors. For example, Java checks subscripts to make sure they are in the correct range.
  • Java does things for you. There are a huge number of things that Java has already written for you. For example, expandable arrays, many data structures, etc. In C it would take a very long time to write and debug these things by yourself.
  • Java doesn't have the most dangerous things. The things in C which cause the most program errors are pointers, pointer arithmetic, and memory management. Java has replaced these with much, much safer things: references, subscription, and garbage collection.
The reason that everyone is very enthusiastic about Java is because it is easier (faster, cheaper, ...) to produce good programs.

From C++ to Java

If you know C or C++, you already know a lot of Java.

The Java language is based mostly on C and C++. You'll see that a lot of the basic language elements, for example, the primitive types, operators, and statements of Java are taken directly from C.

Primitive Java types are similar to C

Java includes types which are similar to those in C/C++ (char