From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f5d71,d275ffeffdf83655 X-Google-Attributes: gidf5d71,public X-Google-Thread: 109fba,d275ffeffdf83655 X-Google-Attributes: gid109fba,public X-Google-Thread: 1108a1,d275ffeffdf83655 X-Google-Attributes: gid1108a1,public X-Google-Thread: 101b33,d275ffeffdf83655 X-Google-Attributes: gid101b33,public X-Google-Thread: 103376,d275ffeffdf83655 X-Google-Attributes: gid103376,public X-Google-Thread: 10a146,bab58563a24f525a X-Google-Attributes: gid10a146,public From: mgk25@cl.cam.ac.uk (Markus Kuhn) Subject: Re: Ada vs C++ vs Java Date: 1999/01/15 Message-ID: <77nhuv$29c$3@pegasus.csx.cam.ac.uk> X-Deja-AN: 432959574 References: <369C1F31.AE5AF7EF@concentric.net> <369CAB38.404C0610@praxis-cs.co.uk> Organization: U of Cambridge Computer Lab, UK Newsgroups: comp.lang.c++,comp.lang.java,comp.java.advocacy,comp.object,comp.lang.java.programmer,comp.lang.ada Date: 1999-01-15T00:00:00+00:00 List-Id: Here my quick comparison between Ada95, Java, and C++, from someone who has used all three languages: Complexity: C++ is by far the most complicated and most difficult to learn of the three languages, Java is perhaps somewhat simpler to learn than Ada95, though I think that generally Java and Ada95 provide roughly an equal level of complexity. Rumours that some eminent academics spread in the early 1980s that Ada is "much too complex" become laughable to anyone who has read both the Ada 95 and C++ ISO standards. Object Orientation: All three are full OO languages. Ada was originally a procedural languages, and the Ada95 OO extensions are clearly an add-on feature. Nothing in Ada forces you to program using OO concepts, but if you want to do OO programming then all the mechanisms you need are there. The Ada terminology is a bit different than the classical OO terminology, for instance a "class" is called a "tagged record" in Ada95. Many typical modern OO features such as overloading, exceptions and name spaces were already in Ada83 long before anyone was talking about OO, therefore only minor extensions where necessary in Ada95 such as class inheritance. C++ is like Ada95 an add-on OO language that enables but does not enforce OO-style interfaces, while Java forces the programmer right from the beginning into an OO corset. Both Ada95 and Java avoid the pitfalls of multiple inheritance, Java using interfaces and Ada95 using include inheritance. Security and Low-Level Access: Both Ada and Java support a pointer-arithmetic free programming style that allows to use the compiler as a powerful tool to detect the most dangerous memory corruption errors. Java forces the programmer to use only high-level garbage collected data structures, while Ada allows them to be used, but for special low-level tasks (device drivers) also provides carefully controlled means to bypass the security features and to all the low-level hacking that is possible in Assembler and C(++). Ada is even more comfortable than C in many respects with regard to low-level bit manipulation, because it provides strict control over record layouts and memory arrangement. One distinguishing feature of Ada is that it gives very good low-level control about numerical types and numerical precision in a very portable way. C/C++ programmers have to use a lot of dirty tricks or configuration files to obtain assurances that Ada programmers can just specify directly to the compiler. Concurrency: Both Ada and Java have good language support for multi-threading and synchronization, while C++ leaves this to the OS and library with lots of portability problems arising (Ada and Java programmers do not have to worry about Win32 vs. POSIX.1 threads). Support: All three langauges are today well supported by the industry and are going to be around for a very long time. There is no doubt that you will get well maintained C++, Ada95, and Java development environments in 30 years from now, because the existing code base for all these languages has reached critical mass. There are production quality open source development environments available for all three languages. Efficiency: Java was designed primarily to run on intermediate code interpreters. It aims for portability and not so much for efficiency. Ada and C++ both produce fairly efficient code. It has been my experience that the Ada language encourages a somewhat safer clearer programming style and that therefore due to this style change, my Ada code is typically around 20% slower than my C code (but also easier to read for others). It is possible in Ada to produce exactly the same machine code that a C compiler can produce (at least with gcc and gnat), however if you try to do this, your Ada program might look a bit unnatural and becomes as unreadable as an optimized C code. In practice, the difference is only worth the effort in small inner loops in numerics or signal processing code, where raw assembler is often the best choice. Library support: This is probably the only weak spot of Ada. The ISO Ada95 standard library has a few bizarre features (e.g., the handling of form feeds in Ada.Text_IO), and most significantly, Ada still lacks an ISO standardized equivalent of the STL, even though the language is perfectly suited to define one. C++ has the advantage of inheriting all existing C library interfaces. Ada95 has simple mechanisms to call C libraries, but in practice this works only nicely for exported functions and variables, but not for the preprocessor constants that are often an important part of a C API. However one can use tools that semiautomatically convert C's .h files into proper Ada bindings, and therefore access to C libraries is not too critical in practice for Ada95 programmers. In general: Ada95 is compared to C++ and Java certainly underhyped, which should not keep you from having a good look at the language. It nicely combines the security and concurrency of Java with the efficiency of C++ and of all three languages it provides the best support to design maintainable long-living programs where many other people will have to read your source code. With the recently gained maturity of the GNU compiler, I believe that Ada95 will have a bright future. Markus -- Markus G. Kuhn, Computer Laboratory, University of Cambridge, UK Email: mkuhn at acm.org, WWW: