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, MSGID_RANDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,fee8802cc3d8334d X-Google-Attributes: gid103376,public X-Google-Thread: 10a146,fee8802cc3d8334d X-Google-Attributes: gid10a146,public From: Robert Dewar Subject: Re: Ada and Java. different behaviour. casting long to int problem. Date: 1999/06/13 Message-ID: <7jvcqv$od9$1@nnrp1.deja.com>#1/1 X-Deja-AN: 488976382 References: <7jt2c0$vrb@drn.newsguy.com> <7jv4bh$11rg@drn.newsguy.com> X-Http-Proxy: 1.0 x39.deja.com:80 (Squid/1.1.22) for client 205.232.38.14 Organization: Deja.com - Share what you know. Learn what you don't. X-Article-Creation-Date: Sun Jun 13 04:42:08 1999 GMT Newsgroups: comp.lang.ada,comp.lang.java.programmer X-Http-User-Agent: Mozilla/4.04 [en] (OS/2; I) Date: 1999-06-13T00:00:00+00:00 List-Id: In article <7jv4bh$11rg@drn.newsguy.com>, kirck@nospam.com wrote: > Ok, so the bottom line of all this, is that Java (and C and > C++) all blew it, and Ada did not. I disagree strongly with this statement. Java has well defined portable semantics for its arithmetic operations. It is the programmers responsibility to know these semantics and use them in an appropriate manner. A programmer who casually expects Java to check for overflow in a situation where it is well defined that it does not is incompetent, and it is unreasonable to blame Java for such incompetence. Now one may argue about whether Java's semantic choice is the right one, and I certainly prefer the Ada choice, but I think it is too harsh to say that "Java blew it", there is nothing fundamentally more moral or correct about Ada's semantics here. We are simply talking about the pragmatic issue of which semantic model makes it easier to write reliable programs. > I hope I do not see Java used to implement the software that > will launch the next rocket to space, or process my bank > financial statement. Competent programmers can certainly write realiable software in Java for these functions. I agree it is *easier* to write the same reliable software in Ada, but trying to imply that Java is somehow fundamentally unsafe is another case of excessive negative comment on non-Ada languages by Ada advocates and that is not helpful! > I'd rather see a language that catches such basic errors on > the spot like Ada did in the example, not hide them under the > cover. There is no basic error here in the Java case, just a misunderstanding by the programmer. If you don't know the rules of your language, you may well make a mess of things! In Java if you add 1 to the largest positive number, you get the most negative number. This is not an error, let alone a basic error, it is simply what adding 1 is defined to do! Now if this is NOT the function you need, and instead you need to check that the result does not exceed the largest positive number, you need to program the check that you need. Yes, it is easier in Ada to do this check, but that does not mean that there is something fundamentally unsafe about Java here. Robert Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't.