Thursday, July 18, 2019

Java-Whitepaper Essay

This unobjectionable paper compargons C++/Qt with coffee tree/AWT/ throw off for developing volumed-scale, real-world computer bundle with graphical handlingr interfaces. References atomic publication 18 process to supreme reports that examine various aspects of the dickens toolsets. 1 A similitude of Qt and coffee bean 1. What Do We Comp be? When selecting an milieu for a large piece of land development cast, in that location ar m every aspects that must be bringed.The computer programme vocabulary is unity of the around signifi sightt aspects, since its choice has considerable tinct on what former(a) options atomic number 18 available. For exemplification, in a graphical substance abuser interface development throw, developers pass on exigency a graphical user interface subroutine program library that provides ready-made user interface components, for example, hardly whentons and menus. Since the picking of the graphical user interface lib rary itself has a large impact on the development of a vomit up, it is non uncommon for the GUI library to be chosen first, with the programing speech communication beingness retrieved by the talking tos for which the library is available.Usu completelyy, t present is entirely one lecture per library. Other parcel components kindred database passing libraries or communication libraries must too be interpreted into consideration, that they seldom father such(prenominal) a fond impact on the over wholly initiation as the GUI libraries. In this white paper, the impersonal is to comp atomic number 18 the C++/Qt environment with the umber/AWT/ jolt environment. In rear to do this in the nigh profitable way, we leave behind begin by canvass the programming linguistic processs involved, i. e.C++ and burnt umber, and then compare the 2 GUI libraries, Qt for C++ and AWT/ cast off for chocolate. 2. equivalence C++ and chocolate When discussing the various be nefits and dropbacks of fussy programming languages, the debate lots degenerates into arguments that are based on personal eff and preference rather than either objective criteria. Personal preferences and bugger off should be taken into greenback when selecting a programming language for a project, nonwithstanding because it is subjective, it can non be considered here. kind of we pull up stakes look at roll in the hays such as computer computer computer programmer-efficiency, carry throughtime-efficiency and retention-efficiency since these can be quantified and stimulate been examined in scientifically conducted research, although we will a similar incorporate information based on the practical exerience of projects that crap been utiliseed in our induce company. 2. 1. Programmer-efficiency Programmer-efficiency describes how in effect(p)ly (i. e. how quickly and accurately) a programmer with a given phase of experience and knowledge can go for a certain set of requirements in a carve upicular programming language, including debugging and project setup time.Since developer salaries are one of the chief(a) personify factors for any programming project, programmer-efficiency greatly affects the 2 A equality of Qt and coffee berry cost-efficiency of the project. To around extent, programmer-efficiency is also determined by the tools available. The main design goal of chocolate is increase programmer-efficiency compared to separate popular-purpose programming languages, rather than increased keeping- or runtime-efficiency. java has several suffers designed to make it more(prenominal) programmer-efficient.For example, unlike C++ (or C), the programmer does non stomach to explicitly free (give back) allocated stock resources to the operating organization. Freeing saucy storage ( drool battle array) is handled automatically by the chocolate runtime system, at the expense of remembering- and runtime-efficiency (see belo w). This liberates the programmer from the burden of keeping track of allocated computer storage, a tedious labor movement that is a major(ip) cause of bugs. This feature alone should significantly increase the programmer-efficiency of coffee programmers, compared to C++ (or C) programmers.Research shows that in entrust, refuse charm and other chocolate features, do non have a major put to work on the programmer-efficiency. One of the perfect software estimation models, Barry Boehms CoCoMo1 predicts the cost and schedule of a software project using cost drivers which take into account variables like the general experience of a programmers, the experience with the programming language in question, the targeted reliability of the program, etc. Boehm writes that the measuring of effort per source statement was highly independent of the language level.Other research, for example, A system of programming measurement and estimation by C. E. Walston and C. P. Felix of IBM2, poi nts in the similar direction. Both the reports cited here pre-date the advent of chocolate by legion(predicate) years, although they seem to reveal a general principle that the sophistication of a all-purpose programming language has, compared with other aspects, like the experience of the developers, no significant influence on the overall project costs. on that point is more recent research that explicitly includes chocolate and which supports this hypothesis.In An empirical relation of C, C++, burnt umber, Perl, Python, Rexx, and Tcl3, Lutz Prechelt of the University of Karlsruhe, describes an experiment he conducted in which computer science students were assigned a particular design and development proletariat and asked to instrument the specification provided in any of the languages C, C++, or Java which they could freely drive according to their personal preferences (the other languages were examined in a different part of the research project). The data ga on that pointd shows intimately-nigh the same results for C++ and Java (with C running third in nigh aspects).This is also backed up by our own experience if programmers can choose their favorite programming language (which is ordinarily the one they have most experience of), programmers with the same level of experience (measured for example, in years of programming experience in general) get through near the same programmer-efficiency. other interesting aspect that we noned ( and which is non yet supported by any formal 3 A Comparison of Qt and Java research) is that less experienced developers seem to bring home the bacon somewhatwhat br to each one results with Java, medium-experienced developers achieve about the same results with some(prenominal) programming languages, nd experienced developers achieve disclose results with C++. These findings could be repayable to better tools being available for C++ provided this is an aspect that must be taken into account. An inter esting way to quantify programmer-efficiency is the course Point method developed by Capers Jones. Function points are a software metric that moreover depend on the procedureality, not on the slaying. Working from the percentage points, it is possible to compute the lines of code postulate per function point as well as the language level which describes how more function points can be utilize in a certain inwardness of time.Intriguingly, both(prenominal) the values for the lines of code per function point and the language level are identical for C++ and Java (6 for the language level, compared with Cs 3. 5 and Tcls 5, and 53 for the lines of code per function point, compared with Cs 91 and Tcls 64). In conclusion both research and practice contradict the claim that Java programmers achieve a higher programmer-efficiency than C++ programmers. 2. 2. Runtime-efficiency We have seen that Javas programmer-efficiency appears to be illusory. We will now examine its runtime efficie ncy. Again, Prechelt provides useful data.The amount of data he provides is long, but he arrives at the conclusion that a Java program must be evaluate to run at to the lowest degree(prenominal) 1. 22 times as farsighted as a C/C++ program. Note that he says at least the average runtime of Java programs is unconstipated yearlong. Our own experience shows that Java programs tend to run about 2-3 times as long than their equivalent C/C++ programs for the same task. Not surprisingly, Java loses even more ground when the tasks are central processing unit-bound. When it comes to programs with a graphical user interface, the increased latency of Java programs is worse than the runtime performance hit.Usability studies show that users do not care about whether a long running task takes, say, cardinal or three minutes, but they do care when a program does not show an immediate reaction to their interaction, for example when they press a button. These studies show that the marge of what a user accepts before they consider a program to be unresponsive can be as light as 0. 7 seconds. Well return to this issue when we compare graphical user interfaces in Java and C++ programs. An explanation about wherefore Java programs are gradual than C++ is in vow.C++ programs are lay ind by the C++ compiler into a binary format that can be penalize directly by the CPU the whole program execution hence takes gravel in 4 A Comparison of Qt and Java hardware. (This is an oversimplification since most modern CPUs execute microcode, but this does not affect the issues discussed here. ) On the other hand, the Java compiler compiles the source code into bytecode which is not executed directly by the CPU, but rather by another foot of software, the Java Virtual auto (JVM). The JVM in turn, runs on the CPU.The execution of the bytecode of a Java program does not take place in ( betting) hardware, but instead in (much slower) software emulation. Work has been undertaken to d evelop however in Time (JIT) compilers to address Javas runtime efficiency problem, but no universal solution has yet emerged. It is the semi-interpreted record of Java programs that makes the compile erst trance, run anyplace near of Java possible in the first place. Once a Java program is compiled into bytecode, it can be executed on any weapons plan which has a JVM.In practice, this is not constantly the case, because of instruction execution differences in different JVMs, and because of the necessity to sometimes use congenital, non-Java code, usually scripted in C or C++, unneurotic with Java programs. But is the use of course of study-independent bytecode the recompense advent for crossplatform diligences? With a untroubled cross-platform toolkit like Qt and good compilers on the various platforms, programmers can achieve almost the same by compiling their source code once for each platform write once, compile everywhere.It can be argued that for this to work, developers need access to all the platforms they want to support, enchantment with Java, in theory at least, developers only need access to one platform running the Java development tools and a JVM. In practice, no responsible software manufacturer will ever accept their software for a platform the software hasnt been tested on, so they would chill out need access to all the relevant platforms. The question arises why it should be infallible to run the Java Virtual Machine in software if a program can be implemented in software, it should also be possible to have hardware implement the same unctionality. This is what the Java designers had in mind when they developed the language they as summateed that the performance penalty would fell as soon as Java CPUs that implement the JVM in hardware would befit available. But after five years, such Java CPUs have not live generally available. Java automatically de-allocates (frees) unused recollection. The programmer allocates reme mbering, and the JVM keeps track of all the allocated recollection baffles and the references to them. As soon as a memory board block is no continuing referenced, it can be reclaimed. This is done in a process called dribble collection in which the JVM periodically checks all the allocated memory blocks, and removes any which are no overnight referred to. Garbage collection is very convenient, but the trade offs are greater memory consumption and slower runtime speed.. With C++, the programmer can (and should) delete blocks of memory as soon as they are no longer required.With Java, blocks are not deleted until the close garbage collection run, and this depends on the implementation on the JVM being used. Prechtelt provides figures which state that on average ( ) and with a confidence of 80%, the Java programs consume at least 32 MB (or 297%) more memory than the C/C++ programs ( ). In growth to the higher memory requirements, the garbage collection process itself requires processing power which is then not available to the actual coat functionality, premiseing to slower overall runtimes.Since the garbage collector runs periodically, it can occasionally lead to Java programs freezing for a a few(prenominal) seconds. The best JVM implementations keep the occurrence of such freezes to a minimum, but the freezes have not been eliminated entirely. When dealing with external programs and devices, for example, during I/O or when interacting with a database, it is usually suitable to close the file or database connexion as soon as it is no longer required. Using C++s destructors, this happens as soon as the programmer calls delete.In Java, closing may not occur until the next garbage assembling sweep, which at best may join up resources unnecessarily, and at worst risks the generate resources ending up in an conflicting state. The fact that Java programs keep memory blocks around longer than is strictly obligatory is especially problematic for emb edded devices where memory is often at a premium. It is no coincidence that thither is (at the time of writing) no complete implementation of the Java platform for embedded devices, only partial implementations that implement a subset.The main reason why garbage collection is more dearly-won than explicit memory focusing by the programmer is that with the Java scheme, information is lost. In a C++ program, the programmer knows both where their memory blocks are (by storing pointers to them) and knows when they are not needed any longer. In a Java 6 A Comparison of Qt and Java program, the latter information is not available to the JVM (even though it is known to the programmer), and thus the JVM has to manually find unreferenced blocks.A Java programmer can make use of their knowledge of when a memory block is not needed any longer by deleting all references that are til now around and triggering garbage collection manually, but this requires as much effort on the part of the pr ogrammer as with the explicit memory management in C++, and still the JVM has to look at each block during garbage collection to determine which ones are no longer used. Technically, there is nothing that prevents the implementation and use of garbage collection in C++ programs, and there are commercial programs and libraries available that aim this.But because of the dis payoffs mentioned above, few C++ programmers make use of this. The Qt toolkit takes a more efficient approach to easing the memory management task for its programmers when an object is deleted, all subject objects are automatically deleted too. Qts approach does not interfere with the programmers freedom to delete manually when they like to. Because manual memory management burdens programmers, C and C++ have been accused of being prone to generate unstable, bug-ridden software.Although the danger of producing memory corruption (which typically leads to program crashes) is sure enough higher with C and C++, goo d education, tools and experience can greatly number the risks. Memory management can be learned like anything else, and there are a large number of tools available, both commercial and open source, that help programmers get wind that there are no memory errors in the program for example, Insure++ by Parasoft, Purify by Rational and the open source Electric Fence.C++s flexible memory management system also makes it possible to write use memory profilers that are adapted to whichever reveal case of application a programmer writes. To sum up this discussion, we have found C++ to provide much better runtime- and memory-efficiency than Java, while having same programmer-efficiency. 2. 4. Available libraries and tools The Java platform includes an impressive number of packages that provide hundreds of classes for all kinds of purposes, including graphical user interfaces, security, networking and other tasks.This is for certain an advantage of the Java platform. For each package a vailable on the Java platform, there is at least one corresponding library for C++, although it can be difficult to assemble the various libraries that would be needed for a C++ project and make them all work together correctly. However, this strength of Java is also one of its weaknesses. It becomes increasingly difficult for the individual programmer to find their way through the huge APIs. For any given task, you can be almost certain that somewhere, there is 7A Comparison of Qt and Java functionality that would execute the task or at least help with its implementation. But it can be very difficult to find the even up package and the right class. Also, with an increasing number of packages, the size of the Java platform has increased considerably. This has led to subsets e. g. , for embedded systems, but with a subset, the advantage of having everything quick available disappears. As an aside, the size of the Java platform makes it almost impossible for smaller manufacturers to ship a Java system independent from cheer Microsystems, Javas inventor, and this reduces competition.If Java has an advantage on the side of available libraries, C++ clearly has an advantage when it comes to available tools. Because of the considerable maturity of the C and C++ family of languages, many tools for all aspects of application development have been developed, including design, debugging, and profiling tools. While there are Java tools appearing all the time, they seldom measure up to their C++ counterparts. This is often even the case with tools with the same functionality feeler from the same manufacturer compare, for example, Rationals Quantify, a profiler for Java and for C/C++.The most important tool any developer of a compiled language uses, is still the compiler. C++ has the advantage of having compilers that are clearly lord in execution speed. In order to be able to ship their compilers (and other tools) on various platforms, vendors tend to implement the ir Java tools in Java itself, with all the aforementioned memory and efficiency problems. at that place are a few Java compilers written in a indigene language like C (for example, IBMs Jikes), but these are the exception, and seldom used. 3. canvass AWT/ drip and QtSo far, we have compared the programming language Java and the programming language C++. But as we discussed at the beginning of this article, the programming language is only one of the aspects to consider in GUI development. We will now compare the packages for GUI development that are shipped with Java, i. e. AWT and get about, with the cross-platform GUI toolkit, Qt, from the Norwegian supplier, Trolltech. We have confined the comparision on the C++ side to the Qt GUI toolkit, since unlike MFC (Microsoft basis Classes) and similar toolkits, This seems to contradict Javas cross-platform philosophy and may be due to the the initial AWT version being reputedly developed in under fourteen days. Because of these and a number of other problems with the AWT, it has since been augment by the Swing toolkit. Swing relies on the AWT (and consequently on the domestic libraries) only for very basic things like creating orthogonal windows, handling events and executing primitive plan operations. Everything else is handled within Swing, including all the plan of the GUI components.This does away with the problem of applications looking and behaving otherwise on different platforms. Unfortunately, because Swing is loosely implemented in Java itself, it lacks efficiency. As a result, Swing programs are not only slow when performing computations, but also when drawing and handling the user interface, leading to scurvy responsiveness. As mentioned earlier, poor responsiveness is one of the things that users are least willing to tolerate in a GUI application. On todays standard commodity hardware, it is not comical to be able to watch how a Swing button is redrawn when the mouse is press over it.While this situation will surely improve with faster hardware, this does not address the fundamental problem that conglomerate user interfaces developed with Swing are inherently slow. The Qt toolkit follows a similar approach like Swing, it only relies on the inbred libraries only for very basic things and handles the drawing of GUI components itself. This brings Qt the same advantages as Swing (for example, applications look and behave the same on different platforms), but since Qt is entirely implemented in C++ and thus compiled to internal code it does not have Swings efficiency problems.User interfaces written with Qt are typically very fast because of Qts smart use of caching techniques, they are sometimes even faster than comparable programs written using only the native libraries. Theoretically, an best native program should always be at least as fast as an equivalent optimal Qt program however, devising a native program optimal is much more difficult and requires more progra mming skills than making a Qt program optimal. Both Qt and Swing employ a styling technique that lets programs display in any one of a number of styles, independent of the platform they are running on.This is possible because both Qt and Swing handle the drawing themselves and can draw GUI elements in whichever style is desired. Qt even ships with a style that emulates the default look-and-feel in Swing programs, along with styles that emulate the 9 A Comparison of Qt and Java Win32 look-and-feel, the report look-and-feel, andin the Macintosh version the MacOS X Aqua style. 3. 2. Programming Paradigms In Qt and Swing While programming APIs to some extent are a involvement of the programmers personal taste, there are some APIs that lend themselves to simple, short, and elegant application code far more readily than others.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.