Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Example applications and benefits of using C , C++ or Java [closed]

Tags:

java

c++

c

Ok, I'm revising for my upcoming year 2 exams on a CS course and its likely something like this will come up. my question is what is an ideal application that would especially benefit from the program features of each of the three languages? I have a vague idea but getting a second opinion could really help.

  • Java

    Portability, easy - good for GUIs.

  • C++

    Fast but may requite significant changes in order to be moved from system to system, good for image processing.

  • C

    I'm unsure here small embedded applications?

Some clarification on this would be really appreciated, thanks again StackOverflow

like image 996
Waltzy Avatar asked May 15 '10 18:05

Waltzy


People also ask

What is the difference between CC and Java?

C++ is derived from C and has the features of both procedural and object-oriented programming languages. C++ was designed for application and System development. Java is built upon a virtual machine which is very secure and highly portable in nature.


6 Answers

Where Java really is at its element is web applications. And thanks to the development of JIT compilers, nowadays its speed is often comparable to that of C++.

I believe that standard C++ is quite portable across platforms, the trouble comes when you want to use things which have never been standardized. The biggest of these which comes to my mind is threads.

Also, to make an efficient, fast and elegant C/C++ program, you need a lot of skills and experience. Lacking these, you can easily make inefficient, buggy and ugly C/C++ programs. Which is not to say you can't do this in Java (or any programming language), but making basic mistakes in C and C++ is much more deadly than in Java.

C is used in places close to the metal, and/or where performance and efficiency is an utmost requirement, including operating system kernels and device drivers.

like image 169
Péter Török Avatar answered Oct 21 '22 06:10

Péter Török


  • C: device drivers and other low level things
  • C++: applications where you don't want to annoy the user by having to install a runtime environment
  • C/C++: realtime applications; or in cases where the programs runtime is extremely short (the C/C++ program terminates before the jvm startup is done); in cases where memory footprint has to be small
  • Java: in nearly all other cases (provided no better suited domain specific language exists); mobile applications; web (especially on the server)

performance of java is IMHO no more an issue. It is at least comparable to C++, and in many cases it's even superior to that of C++ - we reimplemented a large number crunching application in java and it runs an order of magnitude faster than the old one implemented in C++. Surprising? Well, I think the main reason is better tooling support, faster turn-around cycles and less time spent for plugging existing libraries together: Using Java, we have more time to concentrate on algorithms. Plus, some things that can slow down C++ applications simply are not an issue with jave (like temporary object creation).

concerning GUI development, I think swing has come a long way and SWT is native, so here java is an option, too.

Standard C++ should be portable at the source level in theory, but in practice it's not. Not just threads, but also networking, file system access (i.e. no standard function to tell a files' size), etc.

And even incompatibility on one platform is an issue - we have std::string, but how many libraries still exist using their own string classes? If I build my GUI with one library and want to store data in a databse, I'll sure have to convert first.

Another example: If I want to use regular expressions, should I go for boost::regex or the GNU library?

like image 33
Axel Avatar answered Oct 21 '22 05:10

Axel


At least in me experience, it's quite difficult to compare C++ to Java because they follow rather different patterns. Nearly the only way to compare them in a meaningful fashion is to graph code complexity vs., program "size" for both:

alt text Black line = C++, Red line = Java.

Especially if you look primarily at really small projects, C++ can seem nearly impossible -- adding even a few features is a lot of work and adds a great deal of complexity to the code. This is (particularly) at a phase where nearly everything you do means finding, building, learning, etc., another library that's typically independent of the others.

For projects of this size, Java is often considerably more attractive -- it comes with a much larger standard library that (mostly) follows roughly a similar style, so what you know about one part extends reasonably well to other parts. You also get things like garbage collection, so your memory management tends to be relatively trivial.

For larger projects, the situation reverses -- the operator overloading that made some of the libraries hard to learn also makes them easier to use, once you know how. Likewise, the templates that were really hard to wrap your head around, let you solve a much wider range of problems without using new code. Instead of garbage collection to make memory management easy, you learn to apply RAII to make manage of virtually all resources easy.

Unfortunately, it's often pretty hard to estimate where any particular project lies on the horizontal axis. Worse, unless it's really close to the cross-over point, the difference between the two isn't usually something like 10 or 15% -- it's more likely to be on the order of 2:1 or 3:1. In many cases, the choice is the difference between a great success, and a horrible failure.

That said, I think most of your assessments are largely wrong.

Portability: just about even across the board. Not nearly as hard with C or C++ as most people believe, nor (unfortunately) nearly as easy with Java as they believe.

GUIs: Java makes GUIs easy -- and ugly and unresponsive. Qt (for one example) has about the same portability, only slightly more work, but much nicer results.

Speed: only rarely a reason to choose one over the other. Yes, C++ will usually win, but it won't make any real difference for most applications.

As far as C goes, yes, it's useful for smaller embedded systems. Its primary advantage is that it minimizes the environmental framework necessary to get a working system. C++ takes quite a bit more, and Java substantially more again (though this can be irrelevant if that environment is already guaranteed to be present, such as Java on many mobile phones).

like image 44
Jerry Coffin Avatar answered Oct 21 '22 07:10

Jerry Coffin


Well, i'm not quite sure about Java superiority concerning UI's anymore since these days C++ has Qt. But other than that, Java is very good concerning portability. These days with JavaFX Java is also a good option for RIA's and proprietary systems as well. And IMHO, indeed Java is way much more easier than C++.

I too think that C is mostly for embedded systems and places in general where you need to do stuff concerning hardware.

like image 31
JHollanti Avatar answered Oct 21 '22 05:10

JHollanti


  • Java -- Good for portability. Built in Garbage Collection
  • C++ -- Good for CPU intensive applications which would greatly benefit from OOP.
  • C -- Good for low level work including kernels, drivers, and embedded work(though C++ is seeing more action there too)
like image 44
Earlz Avatar answered Oct 21 '22 06:10

Earlz


Just like C is easier than asssembler, Java as a higher level language offers many benefits to the developer.

  • Memory management is simplified
  • Type safety
  • Significantly richer library availability - why reinvent the wheel.
  • Richer tool support.

Theres a reason why Java has taken over the world and its because developers can do a lot more in a lot less time with Java than C. Even Microsoft acknowledges this and is trying to encourage develoeprs to use dot net for business apps rather than c/c++. One day Office itself might bea managed app(under a VM) rather than unmanaged (c/c++).

The majority of the big sites of today use java and not c/c++.

  • Gmail
  • Google maps
  • Ebay
like image 35
mP. Avatar answered Oct 21 '22 05:10

mP.