Thursday, December 12, 2019
Computer Programming free essay sample
Each feature of C++ exists because it has proven important for some area of industrial programming. With the language standard nearly complete, compilers that implement most of the new standard features are available now on most architecture. Real-world programmers are more interested in problems than in languages: a programming language is a way to solve a problem. When you use the right mix of languages and language features, the solution to a problem is much easier to describe and implement, with better results. C++ remains an essential tool for software engineers not because anybody thinks its the best possible language, but because its a single, portable language that works better than any alternative in each of several areas. This article explores the strengths of C++, and how to exploit them in your projects. * Why Use C++? C++ is a general purpose programming language designed to make programming more enjoyable for the serious programmer. We will write a custom essay sample on Computer Programming or any similar topic specifically for you Do Not WasteYour Time HIRE WRITER Only 13.90 / page For many uses, C++ is not the ideal language. You might prefer Tcl/Tk for writing a user interface, SQL for relational database queries, Java for network programming, or Yacc for writing a parser. C++ is used because it works well when the ideal language is (for whatever reason) not available, and because it interfaces easily with the libraries and the other languages you use. Its no accident that you can interface C++ with almost any language interpreter or library you find. You rarely find a big program written all in one language, or without using libraries, so easy integration with other languages and libraries was a key design goal. Most problems have no specialized language to solve them; some because none has (yet) been worth creating, and others because an interpreter would add too much overhead. When you cant afford a specialized language for part of a problem, a library may suffice. C++ was designed with libraries always in mind, and its most useful features are those that help you write portable, efficient, easy-to-use libraries. Reference: www. cantrip. org Why use C++ instead of Java? Java needs to be interpreted or JIT compiled, while C++ is compiled directly into machine code. At compile time the compiler with knowledge of the CPU can heavily optimize the code which is not possible in a JIT that has much stricter run time requirements. It depends on what you compare. There are shootouts that compare C++ code compiled for a 386 with 387 FPU with Suns Hot Spot engine on a current CPU. Since the java engine knows the CPU that it is running on, it can optimize for the MMX and SSE units and the more subtle issues of that specific CPU. Those shootouts are usually used to prove that java was faster than C++. If your compiler optimizes your C++ code for the CPU it will be running on, the compiler still can do more sophisticated optimizations that a Java JIT never will be able to do in the short time it has for compilation. There are also some things in the languages. Java is a more dynamic language than C++. A C++ compiler can e. g. do heavy in lining of non-virtual methods. In java all methods are what a C++ virtual method would be. Templates are completely interpreted at compile time, where generics are more or less a feature for mass casting, which needs run time support in Java. There are many more sometimes subtle differences in the languages, where well written C++ code is better for compiler optimizations than java code can ever be without losing the promises the language gives to the programmer. Of course last, not least C++ lets the programmer decide about memory management. That makes things more complicated for the programmer, but on the other hand he can decide for the memory management that is optimal for his code. A small shell until that uses a fixed block of memory every time it runs may need no memory management at all. There is no way to do that with Java, the GC is always there. Another application may be best of with pooled memo
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.