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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1014db,582dff0b3f065a52 X-Google-Attributes: gid1014db,public X-Google-Thread: 109fba,582dff0b3f065a52 X-Google-Attributes: gid109fba,public X-Google-Thread: 103376,bc1361a952ec75ca X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-08-10 08:01:19 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!paloalto-snf1.gtei.net!news.gtei.net!enews.sgi.com!newshub2.rdc1.sfba.home.com!news.home.com!news1.rdc2.on.home.com.POSTED!not-for-mail Message-ID: <3B73F747.D44DA95B@home.com> From: "Warren W. Gay VE3WWG" X-Mailer: Mozilla 4.75 [en] (Windows NT 5.0; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada,comp.lang.c,comp.lang.c++ Subject: Re: How Ada could have prevented the Red Code distributed denial of service attack. References: <3b690498.1111845720@news.worldonline.nl> <9kbu15$9bj@augusta.math.psu.edu> <9kbvsr$a02@augusta.math.psu.edu> <3B69DB35.4412459E@home.com> <9kp9n7$ivm$1@nh.pace.co.uk> <3B722166.AFBFE73A@home.com> <3B7329A2.959E04B4@home.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Fri, 10 Aug 2001 15:01:18 GMT NNTP-Posting-Host: 24.141.193.224 X-Complaints-To: abuse@home.net X-Trace: news1.rdc2.on.home.com 997455678 24.141.193.224 (Fri, 10 Aug 2001 08:01:18 PDT) NNTP-Posting-Date: Fri, 10 Aug 2001 08:01:18 PDT Organization: Excite@Home - The Leader in Broadband http://home.com/faster Xref: archiver1.google.com comp.lang.ada:11766 comp.lang.c:73411 comp.lang.c++:81556 Date: 2001-08-10T15:01:18+00:00 List-Id: Bart.Vanhauwaert@nowhere.be wrote: > Warren W. Gay VE3WWG wrote: > > So when you do a FETCH from an relational database, into a string > > column value, you're going to use a dynamic array? What initial > > I am going to use std::string. Why not? Well ESQL/C (Embedded SQL/C) for example will not give it to you in that format. Though, you _could_ use the API _functions_ for relational databases, but this is always a lot more tedious. I think most of them will also support C++ APIs now, but I don't know of any off of the top of my head, that will load a column value into std::string yet. There was another poster, speaking of Microsoft CString (I think), noting that it does not check array bounds. Hopefully the STL is better in this regard, but it pays to check your assumptions on a given platform (a given implementation may not check these bounds -- unless perhaps if the standard dictates that it should). > >> But once you start thinking this > >> was it ends up in your protocols (oeps, lucky we had some > >> reserved(1..12) of character at the end of our message!), in > >> your file formats, etc.. where the real problems are. > > APIs and protocols often have fixed sizes in them. Sheesh, where > > have you been? Have you looked at TCP/IP headers for example? > > Yes. And fixed four byte IP addresses cause enough headaches already. I hope you don't think that IPv6 is going to be any different in this regard. It will be fixed in size as well. > >> pipe(&my_vector[0]); > > OK, but will your junior programmer you just hired do that? Really? > > He probably will, but he will also probably not know that is > a potentially unspecified thing :) I don't understand your "potentially unspecified thing" remark, but what I have noticed is that people that are struggling with any new language end up using very basic features, until it starts to become 2nd nature to them. You can bet they will probably use C type arrays at the start, because it is a simpler thing to start with and to know. After all, this is what they'll have learned first. Arrays are much simpler for the junior to remember than all the baggage that comes in any class library. > Will your junior programmer you just hired program Ada? Really? Very likely, because 'First, 'Last and 'Length are part of the language and _very_ easy to use and remember. Just like C/C++ arrays, the students of the Ada language will always learn about these when arrays are taught. The "for" loop is always taught in conjunction with the array'Range (just short for array'First..array'Last), so it's not a topic that would be missed, or forgotten. > >> (Yes technically, the wording of the current C++ standard is not clear > >> enough, but there is a defect report that rectifies this; it works > >> for all current implementations of the STL already in anticipation > >> of this correction) > > That kind of assumption will "not fly" on rockets, aircraft or space > > stations. It should not be the kind of assumption that runs mutual > > fund companies, banks or insurance companies either. > > Yes it's a defect in the C++ standard. It got caught and it will > be corrected in the next iteration. (There is nothing dishonest > about multiple iterations of a standard is there?) I'm not criticising a need to revise or even fix standards or languages. I'm just focused on the difference between "safe and correct" use of arrays in this thread. > > You've not been listening, obviously. One last time: In Ada there is > > no reason to shy away from arrays. Additionally, as Ted Dennison has > > In C++ there is, but it is not a problem because you can use other > equivalent structures, some provided by the STL. > > Look : you are coming from an Ada background where arrays are > augmented up to a point where they became a generic object. Whoa! Be careful about your assumptions. I've built my career on C/C++, so don't assume that I come from an Ada background. I have just been enlightened with some Ada background -- that is the difference here. To address the 2nd issue here, yes, Ada lets you add primitives (methods) to scalars. So in this sense, yes Ada permits you to treat simple types like objects, and this does extend to arrays (although you cannot add new array semantics without wrapping it into an object (class). But extending scalars is a _feature_. ;-) For you to add functionality to an int or a double, requires you to wrap it into a class. The Ada compiler does not require this type of fuss, because conceptually at the end of the day, the implementation of a wrapper class for int is no different than just allowing the user to "extend the type" directly in Ada. It's just neater, safer and more conveniant in Ada. > But > only with different syntax on calling the operators than on > a real object. You keep side-stepping the issue, which is: Ada has safety built into the language. C++ does not, and users must rely on a library to get safety, from a library like the STL. Even Ada's unofficial Booch Components library (similar to STL) is safer, because the language's inherent safety is also applied to these library components. The criticism many have of the Booch Components, which might be fair, is that it is more difficult for beginners to instantiate for use. But once the user gets past the instantiation of the packages (ie. understands it), the components are no more difficult to use than the STL. > I think that is an inconsitency and shows the > time of the signes of early 80'ies when objects where not yet > as deeply entranched in peoples mind. At that time a 'better, > safer, array' was the best one could think of. Arrays are a perfectly natural element of _all_ programming languages, even your spiffy new functional languages will support them. The only difference is that many languages are more safety concious in their use, than C/C++ applies. But C/C++ are by no means the only renegades, because FORTRAN for example was remiss in this area (though they may have changed their stripe in more recent times). > In C++ you use a real generic object to represent an array. You can in Ada also btw, but it is not necessary. > Same syntax as all other generic objects. You can write array like > objects yourself but with different semantics if you really must. Again, if you need special array semantics, this can be done in Ada. But we were not talking about special semantics, only the ususally abused ones ;-) > (Like, YES, a typesafe fixed size array with bounds checking and > everything mentioned in this thread). But you have to run to your STL to do this. That is the _point_ I keep trying to impress upon you. The C++ STL is a fine piece of work, representing years of research and effort. I use it myself, when in C++. But don't lose track of the real issue here: In terms of _languages_, C++ is lacking in safety features. Ada has the strongest practical safety that I have been able to find. That is the only point of this particular thread. Just be aware of "your limitations", as one famous actor used to say ;-) -- Warren W. Gay VE3WWG http://members.home.net/ve3wwg