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-Thread: 103376,aa955fc1adc2b46d X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local01.nntp.dca.giganews.com!nntp.scarlet.biz!news.scarlet.biz.POSTED!not-for-mail NNTP-Posting-Date: Sun, 07 May 2006 08:01:05 -0500 From: Ludovic Brenta Newsgroups: comp.lang.ada Subject: Re: of possible interest References: <1146769504.421510.21010@j73g2000cwa.googlegroups.com> <8764klwpz5.fsf@ludovic-brenta.org> Date: Sun, 07 May 2006 14:54:47 +0200 Message-ID: <87u082ouzs.fsf@ludovic-brenta.org> User-Agent: Gnus/5.110004 (No Gnus v0.4) Emacs/21.4 (gnu/linux) Cancel-Lock: sha1:cu80zmIuxa6HDCU3niYkBO8rqb8= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii NNTP-Posting-Host: 62.235.59.247 X-Trace: sv3-DcA6MhfmCr8TTsO9eI8FnUEpOqAq3VCM+ebeH6SNCl8alaZnYbmSDJzvYRQcbeEr3R3KWxuimAfqt2W!3UWJVRDfbaIA4h87FKsKXvKxmqWsaCHDxMs/uHLjHBHgt+vmoS0PhqvCxUaDFOdOtaXoEOdaZA== X-Complaints-To: abuse@scarlet.be X-DMCA-Complaints-To: abuse@scarlet.biz X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.32 Xref: g2news2.google.com comp.lang.ada:4128 Date: 2006-05-07T14:54:47+02:00 List-Id: "Nasser Abbasi" writes: > "Ludovic Brenta" wrote in message > news:8764klwpz5.fsf@ludovic-brenta.org... > >> derived from Java, a notoriously unsafe language, while at the same > > I heard some bad things about java, mostly complaints about its speed or > lack thereof. > > But never heard Java being described as "notoriously unsafe language" > before. > > If Java is notoriously unsafe language, what will that make C? :) > > What makes you say that java is "notoriously unsafe language"? can you > please give some specific examples? > > If you are referring to it being used for real-time, and the uncertainty it > brings there due to the GC kicking in and running for some undetermined > time, making hard-time scheduling difficult, then that is something > different. Or are you thinking of some other cases/examples? > > You can say that java is not suitable for real-time. But that is different > from saying it is unsafe language. Do you agree? > > Nasser Yes, I agree. By unsafe, I meant type-unsafe. Specific reasons why are: - Java does not support user-defined numeric types, only "int", "long" and other predefined types which reflect the virtual machine's internal types but not the problem domain of the programmer. This allows you to mix apples and oranges, which is unsafe. Ada programmers define their own types such as Number_Of_Apples and Number_Of_Oranges, and then the compiler prevents them to mix them, unless the programmer has also defined a way to mis them. - Java up to version 1.4 did not have generics, therefore the entire class library is defined in terms of descendants of the Object class. Since everything is an Object, you constantly have to perform type conversions at run time. These are unsafe, because they might throw ClassCastException at any point in your program. Ada, through the use of generics, allows building type-safe libraries. Even in Java 1.5 which has generics, the class library is unsafe because it supports backward compatibility with the unsafe Java 1.4. - Java allows programmer to ignore the return value of functions. What if the return value was important? This is unsafe. - Java inserts implicit type conversions in too many places. This is unsafe. Safety-critical sotware only wants *explicit* type conversions under control of the programmer. Additionally: - There is no way in Java to restrict which features you want to use. - There is no way in Java to remove the garbage collector and control memory for yourself. - There is no way in Java to avoid dynamic dispatching (see the recent thread in this newsgroup on why dynamic dispatching is difficult to certify in safety-critical software). -- Ludovic Brenta.