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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,dc94fe39f71093ec X-Google-Attributes: gid103376,public From: Robert A Duff Subject: Re: The revolution will not be standardized Date: 2000/01/05 Message-ID: #1/1 X-Deja-AN: 568826347 Sender: bobduff@world.std.com (Robert A Duff) References: <82p7hu$l1q$1@nnrp1.deja.com> <82ppc9$1u6$1@nnrp1.deja.com> <385252E8.FF140CD2@acenet.com.au> <8333q3$9rh$1@nnrp1.deja.com> <8335ip$b8f$1@nnrp1.deja.com> <38561D9A.70B61403@acenet.com.au> <835ukh$uiv$1@nntp2.atl.mindspring.net> <385685B2.7E341C32@quadruscorp.com> <3856d861.30417176@news.netidea.com> <3856EA29.7B4C0A95@quadruscorp.com> <838mhs$cii$1@nnrp1.deja.com> <385F6039.65A1B1B4@acenet.com.au> <83od9d$1i8$1@nnrp1.deja.com> <83osai$ekj$1@nntp2.atl.mindspring.net> <83sb2d$r1i$1@nnrp1.deja.com> <83ubgv$mlv$1@nntp5.atl.mindspring.net> Organization: The World Public Access UNIX, Brookline, MA Newsgroups: comp.lang.ada Date: 2000-01-05T00:00:00+00:00 List-Id: Richard D Riehle writes: > In article <83sb2d$r1i$1@nnrp1.deja.com>, > Robert Dewar wrote: > > >In article , > > Robert A Duff wrote: > >> Richard D Riehle writes: > >> > >> Speaking of which, I've heard many people say that Java is > >just like > >> Ada, except that it uses C syntax. That is nonsense, in my > >opinion: > >> Java inherits many error-prone "features" not present in Ada. > > > > > >Naturaly it goes without saying that it would be VERY useful > >if yoou could expand on the above statement :-) > > I did not originate that assessment of Java. I think it was > part of some other posting earlier. It is now so far from the > source, nested within some other reply, that I am not sure of > its origins. I'm the one who wrote the "Speaking of which..." quote above. Robert replied challenging me to expand on that statement. I could write a book on the subject. I didn't answer Robert because I don't have time to be writing books right now. ;-) Anyway, here are some examples of what I had in mind. These are cases of error-prone features in Java that are not present in Ada. Some (not all) of these features are inherited from C. My contention is that Java went to a lot of trouble to eliminate problems in C that would cause *security* problems, but Java didn't try very hard to eliminate plain old *bugs*. Or "programming mistakes", if you prefer. ;-) The dangling else problem. Alternatives of a switch statement fall through, unless you use break -- but you almost never want to fall through. No full-coverage rules on switch statements -- if there's no default, it does nothing. Everything's a reference, so everything is aliased. (Well, *almost* everything.) Who knows what might hang on to a pointer to so-and-so? In other words, the whole point of local variables is defeated -- local variables can sneakily escape their scope, and you can't tell by reading the code. Elaboration/initialization rules. Wrap-around semantics on integer arithmetic. The integer types are, in general, very machine-oriented. Bit-wise logical operators and shifts have the same status as addition and subtraction. Ada's modular types have the same problem, but at least in Ada, you can usually use a signed integer type for counting things and whatnot, and get more reasonable semantics. (Modular types are not my favorite Ada feature. Shall I post a diatribe on that point? ;-) ) 21 is a different number than 2l. 0011 is different from 11. Java encourages side-effects buried within expressions. Container types lose compile-time type checking. This is because there are no generics. (On the other hand, I must say: it's nice to have lots of container types predefined and standard!) No proper constant declarations (in the Ada sense). No 'in'-mode parameters (because everything's a pointer). No packing. No named-notation calls. I hate reading 10000000 when I could read 10_000_000 instead. No subranges. No new integer types. No enumeration types. ================================================================ On the other hand, there are some counter-examples to my point above. For example, Java makes a distinction between boolean and integers. This is not necessary for security, but it does help prevent bugs, make programs more readable, and all that good stuff. Java also has some features that are *less* error-prone than Ada: Garbage collection. Treatment of uninitialized variables. Declaring what exceptions are propagated. (Although the design is imperfect -- it leads to "crying wolf" too often, IMHO.) No dead code allowed. Fewer implementation-dependent cases. Implementation dependence causes trouble because it's easy to write code that accidentally depends on some implementation-dependent thing, but happens to work using the current compiler on the current machine. Then the bug is found later, after the original programmer has forgotten or gone. ================================================================ I guess the one thing I admire most about Java is its strict insistence on portability. I think that's a Good Thing. On the other hand, in practise, what matters is what implementations do, which is not something the language designer can control. - Bob