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,703c4f68db81387d X-Google-Thread: 109fba,703c4f68db81387d X-Google-Thread: 115aec,703c4f68db81387d X-Google-Thread: f43e6,703c4f68db81387d X-Google-Attributes: gid103376,gid109fba,gid115aec,gidf43e6,public X-Google-Language: ENGLISH,UTF8 Path: g2news1.google.com!news3.google.com!newshub.sdsu.edu!logbridge.uoregon.edu!usenet01.sei.cmu.edu!news.sei.cmu.edu!not-for-mail From: John Hudak Newsgroups: comp.lang.ada,comp.lang.c++,comp.realtime,comp.software-eng Subject: Re: [OT] Re: Teaching new tricks to an old dog (C++ -->Ada) Date: Tue, 08 Mar 2005 10:02:34 -0500 Organization: Software Engineering Institute Message-ID: <422DBE8A.6010502@sei.cmu.edu> References: <4229bad9$0$1019$afc38c87@news.optusnet.com.au> <1110032222.447846.167060@g14g2000cwa.googlegroups.com> <871xau9nlh.fsf@insalien.org> <3SjWd.103128$Vf.3969241@news000.worldonline.dk> <87r7iu85lf.fsf@insalien.org> <87is4598pm.fsf@insalien.org> <1110054476.533590@athnrd02> <1110059861.560004@athnrd02> NNTP-Posting-Host: pcyb.sei.cmu.edu Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: usenet02.sei.cmu.edu 1110294154 7225 128.237.11.63 (8 Mar 2005 15:02:34 GMT) X-Complaints-To: abuse@sei.cmu.edu NNTP-Posting-Date: Tue, 8 Mar 2005 15:02:34 +0000 (UTC) To: Ioannis Vranos In-Reply-To: <1110059861.560004@athnrd02> X-Accept-Language: en-us, en User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041217 Xref: g2news1.google.com comp.lang.ada:8859 comp.lang.c++:44604 comp.realtime:1064 comp.software-eng:4616 Date: 2005-03-08T10:02:34-05:00 List-Id: Ioannis Vranos wrote: > Pascal Obry wrote: > >> >> And what about: >> >> int main() >> { >> int i; >> for(i=0; i<10; ++i) >> ; >> >> i=7; >> } >> >> What is important for safety is not what a language permits but what >> it forbids. As long as you have traps in a language you know that some >> programmers will fall into it at some point. > > > > Every variable is visible inside the scope that it was defined. > > If you want to use i inside a for loop only, then define it in the for > loop. > > > The restriction that you imply you desire, limits flexibility. > > Once again, I have nothing against learning Ada, however personally I > like the most powerful languages. The next thing I am going to learn > after C++ (because I haven't learned it all yet), is probably some form > of assembly language. What????????????????????????????????????????????????? Assembly language? powerful? If you decide to write a X GUI interface in assembly, I'll check in on you in 20 years to see how your doing.... Higher level languages handle broader abstract concepts better than low level languages. Assembly is great if you are optimizing device drivers or banging bits at the hardware register level...not good at implementing scientific algorithms, GUIs, databases, etc. There are thousands of reasearch papers that extol the problems of assembly language approach to things, and yes, there are places and reasons to use it, but classifying it as a 'higher level language' and something more powerful is incorrect.... -John > > > For example I like that I can do: > > #include > #include > #include > #include > > class SomeClass > { > std::string s; > > public: > SomeClass() > { > s="This is a text message"; > } > }; > > > int main() > { > using namespace std; > > SomeClass obj; > > unsigned char *p= reinterpret_cast(&obj); > > // Displays the individual bytes that obj > // consists of as unsigned chars. > for(unsigned i=0; i cout<<"character: "< > cout<<"\n"; > > > p= reinterpret_cast(&obj); > // Displays the decimal values of the > // individual bytes that obj consists of. > for(unsigned i=0; i cout<(p[i])<<" "; > > cout<<"\n\n"; > > > // Displays the bits of each byte that consist > // this SomeClass object > p= reinterpret_cast(&obj); > for(unsigned i=0; i { > // A byte is not necessarily 8 bits > // numeric_limits::digits retrieves the number > // of byte's bits, which *is* 8 usually. > bitset::digits> bits(p[i]); > > for(unsigned j=0; j cout< > cout<<"\n"; > } > } > > > C:\c>temp > character: ⁿ > character: = > character: > > character: > > 252 61 62 0 > > 00111111 > 10111100 > 01111100 > 00000000 > > C:\c> > > > I am sure that many ADA developers will say that this one is not needed > (the ability to access the individual bytes of objects is needed in many > cases, e.g. to create low level exact copies of objects ) and it is > unsafe (yes it is, low level stuff are unsafe and it all depend on the > programmer knowing what he does). > > > It is up to oneself to learn whatever languages fits his purposes. For > example, a "safe" language is not an interest for me. > > Someone who places much hopes on the language to protect him from his > mistakes, probably ADA is better than C++ on this. > > > There is no language that provides satisfies all people desires, just > because some desires are in contrast between them. > > >