comp.lang.ada
 help / color / mirror / Atom feed
From: Ludovic Brenta <ludovic@ludovic-brenta.org>
Subject: Re: of possible interest
Date: Sun, 07 May 2006 14:54:47 +0200
Date: 2006-05-07T14:54:47+02:00	[thread overview]
Message-ID: <87u082ouzs.fsf@ludovic-brenta.org> (raw)
In-Reply-To: EBh7g.2551$fb2.2534@newssvr27.news.prodigy.net

"Nasser Abbasi" <nma@12000.org> writes:

> "Ludovic Brenta" <ludovic@ludovic-brenta.org> 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.



  parent reply	other threads:[~2006-05-07 12:54 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-05-04 19:05 of possible interest Marco
2006-05-04 19:26 ` Ludovic Brenta
2006-05-04 23:30   ` Georg Bauhaus
2006-05-05  2:49     ` Ed Falis
2006-05-05 14:40     ` Ludovic Brenta
2006-05-07  7:46   ` Nasser Abbasi
2006-05-07 11:50     ` Larry Kilgallen
2006-05-07 12:54     ` Ludovic Brenta [this message]
     [not found]       ` <0gcs52lejunc5qar09mf2mng2kg8kumedk@4ax.com>
2006-05-07 20:37         ` Frederic Praca
2006-05-07 22:25           ` Georg Bauhaus
2006-05-08  7:26             ` Ludovic Brenta
2006-05-09  0:41             ` Robert A Duff
2006-05-11 22:25               ` David Emery
2006-05-12 15:45                 ` Pascal Obry
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox