James Rogers wrote in message news:... > kanze@gabi-soft.fr wrote in > news:d6652001.0306100323.338a2a1c@posting.google.com: > > That doesn't mean C++ is perfect, of course. I'd rather have a > > language in which all of the defaults were fundamentally safe, but > > with the freedom to override them if you had special constraints, > > or even in cases where you came across a case which the language > > authors hadn't considered. I don't know such a language, however; > > it may exist somewhere, but if it does, it certainly isn't very > > popular or wide spread. > Since this was cross-posted to comp.lang.ada I think it is fair to > mention that there is a language that meets your description above. > That language is Ada. Permit me to be sceptical. If your claim is that Ada has more of the safe defaults than C++, I doubt anyone would dare argue it. If your claim is even that most of the defaults are the safe version, from what little I know of the language, it would seem true. But to say that in 1983, they got everything right, including problems that weren't even understood until significantly later. Well, I'm sceptical. Perfection just isn't of this world. One point where I'm pretty sure Ada 83 didn't have the right default (although they may have fixed it in Ada 95): garbage collection. While there are places where it is necessary to turn garbage collection off (which seriously limits the use of a language in which you cannot have untraced pointers, which the garbage collector cannot see), the safe option is obviously to have it on by default, no? > Its defaults are fundamentally safe. It provides the ability to > override the safety constraints whenever you choose to. Note how Ada > differs from Java. You cannot turn off array bounds checking for > Java. In Ada you can. In fact, many Ada compilers will optimize out > bounds checking when they can determine the checks are unnecessary. I believe that this is standard practice in all languages which support array bounds checking. > In other words, you can arrive at the same level of safety which is > the default for C++. And you're bragging about it:-) ? Seriously, I am aware that 1) Ada generally adopts the safe option, and 2) you can generally "work around" the safety checks if necessary (hopefully on a case by case basis, using source code constructs; e.g. by writing array.unsafe_at( index ) rather than array[ index ]). In my original statement, I'll admit that I wasn't thinking so much about Ada, as about some other, more popular languages which claim a lot of safety that they don't necessarily give. Still, even thinking about Ada, I don't think I'd change it. As I say, I simply cannot believe that the language is perfect. > With Ada, however, you need to remove safety checks to get > there. Manually removing safety checks is not usually needed for > performance reasons. Most of the time, when you want to remove safety checks, it is because you are writing low level software. On another level, I'm quite happy that the operating systems I use don't normally allow me to write to raw disk. But if I'm writing a file system manager, I will need this permission. Similarly, address arithmetic is something to be avoided at all costs. Unless, of course, you are writing a garbage collector (or in C++, an array class). > Most programmers will use a language in the manner which requires > minimum effort. This is why safety checks are not terribly common in > C++. It is also why manually turning off safety checks is not terribly > common in Ada. I would certainly not claim that the defaults for C++ are safer than for Java. I've been using C++ now for close to fifteen years, and almost exclusively for ten (except for a short excursion into Java). Certain avoidance manoevers have become instinctive, but I know that they are missing in 99% of the code I see. I suspect that I would need a lot less avoidance manoeuvres in Ada -- perhaps none in day to day coding. But I really doubt that there would never be a case where I couldn't do better than the default. -- James Kanze GABI Software mailto:kanze@gabi-soft.fr Conseils en informatique orient�e objet/ Beratung in objektorientierter Datenverarbeitung 11 rue de Rambouillet, 78460 Chevreuse, France, T�l. : +33 (0)1 30 23 45 16 [ Send an empty e-mail to c++-help@netlab.cs.rpi.edu for info ] [ about comp.lang.c++.moderated. First time posters: do this! ]