473,699 Members | 2,302 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Teaching new tricks to an old dog (C++ -->Ada)

I 'm following various posting in "comp.lang. ada, comp.lang.c++ ,
comp.realtime, comp.software-eng" groups regarding selection of a
programming language of C, C++ or Ada for safety critical real-time
applications. The majority of expert/people recommend Ada for safety
critical real-time applications. I've many years of experience in C/C++ (and
Delphi) but no Ada knowledge.

May I ask if it is too difficult to move from C/C++ to Ada?
What is the best way of learning Ada for a C/C++ programmer?

Jul 23 '05
822 29442
Pascal Obry wrote:
Georg Bauhaus <ba*****@future apps.de> writes:

Can templates recurse?


No. (Though you can mix recursive subprograms, nesting, and template
instantiation .)

Hum, since you answered "no" and I answered "yes" it seems there is something
about "templates recurse" that I did not understand. In short what is a
recursive template in C++ ?


In Ada, you cannot instantiate a generic within itself (as Marius
has said elsewhere). In C++, you can, and you should provide
termination lest the instantiation loop exhausts something (at
link time, I believe):

template<typena me T>
struct G {
G<G> r;
};

Georg
Jul 23 '05 #201
In article <11************ *********@z14g2 000cwz.googlegr oups.com>, "Hans Malherbe" <ha***********@ gmail.com> writes:
Somewhere in this thread Loduvic writes:

* in Ada, loop variables (a) are constants and (b) do not exist outside
of the loop

This is safer, but limiting.
In C++ may want to declare the variable outside the loop,
break out early and use the loop variable. Let me guess: You can't
break out early in Ada, right?
You can, but if I want to export the loop variable I use something like:

for each_fluvark in fluvark_array'r ange loop
...
if some_value = 42
then
last_value_of_f luvark_index := fluvark_index;
exit;
end if;
...
end loop;

making quite explicit the difference between the changing value of the
index and the final value at which we exited the loop.
A few other questions:

Do you have nested functions like Pascal have?


Even Bliss has nested functions. What Ada has that Pascal has in addition
to nested functions is uplevel addressing, allowing an inner function to
access data declared in outer scopes.
Jul 23 '05 #202
Pascal Obry wrote:
Hum, since you answered "no" and I answered "yes" it seems there is something
about "templates recurse" that I did not understand. In short what is a
recursive template in C++ ?


One example in C++:

template<unsign ed N> struct factorial
{
static unsigned const value = N * factorial<N-1>::value;
};

// Partial template specialisation to terminate the recursion:
template<> struct factorial<0>
{
static unsigned const value = 1;
};

With this, 'factorial<7>:: value' will be a compile time constant equal to 5040.

Another example:

template<typena me T> struct pointer_info
{
typedef T base_type;
static unsigned const indir_level = 0;
};

// Partial template specialisation for types that are pointers:
template<typena me T> struct pointer_info<T* >
{
typedef typename pointer_info<T> ::base_type base_type;
static unsigned const indir_level = pointer_info<T> ::indir_level + 1;
};

With this, suppose that you have
typedef int***** foo_t;
Then 'pointer_info<f oo_t>::base_typ e' is a typedef (alias) for 'int' and
'pointer_info<f oo_t>::indir_le vel' is a compile time constant equal to 5.

Falk
Jul 23 '05 #203
Martin Dowie wrote:

[ ... ]
Hey! I did add a smiley! I just thought it was an opinion from a
reputable source that tied in with the post. :-) :-)
Sorry -- I rarely add an explicit smiley. Regardless of how my messages
might read, I rarely take much of it _terribly_ seriously.

[ ... ]
Would I be allowed to use embedded SQL in the Ada code (GNADE)? Or a
binding to Postgres or MySQL (APQ) or similar (ODBC)?


For the question at hand, I'd postulate that an embedded SQL
implementation simply wouldn't do the job. Binding to MySQL or using
ODBC would undoubtedly work, but using MySQL, Oracle, MS SQL Server,
etc., puts us back in the situation where we basically just have SQL
talking to a server written in C.

Now, I have no problem with that at all -- but it certainly doesn't
seem to be in keeping with what Richard was advocating.

Then again, your headers indicate that you post with Mozilla
Thunderbird running on Windows, connecting through BT Internet. What
percentage of the millions of lines of code used to write and transmit
your message do you suppose was written in Ada, and what percentage in
C and C++? :-)

Ada advocate: "The world WOULD be better if you used Ada."
C++ advocate: "The world IS better because of the cool code I wrote."

--
Later,
Jerry.

The universe is a figment of its own imagination.

Jul 23 '05 #204

Falk Tannhäuser <fa************ *@crf.canon.fr> writes:
One example in C++:

template<unsign ed N> struct factorial
{
static unsigned const value = N * factorial<N-1>::value;
};

// Partial template specialisation to terminate the recursion:
template<> struct factorial<0>
{
static unsigned const value = 1;
};

With this, 'factorial<7>:: value' will be a compile time constant equal to
5040.


Ok, thanks. This is definitly a recursive definition. AFAIK there is no such
thing in Ada.

Pascal.

--

--|------------------------------------------------------
--| Pascal Obry Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--| http://www.obry.org
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595
Jul 23 '05 #205
Jerry Coffin wrote:
Ada advocate: "The world WOULD be better if you used Ada."
C++ advocate: "The world IS better because of the cool code I wrote."


about Air Traffic Control:

C++ Advocate: "The world WOULDN'T be safer if they used C++"
Ada Advocate: "The world IS safer, because of the cool system we wrote"
about buffer overflows:

Ada advocate: "Networks WOULD be more secure if you used Ada"
C++ advocate: "Networks WOULD be more secure if we used Ada"
--
rien

Jul 23 '05 #206
Jerry Coffin wrote:
Martin Dowie wrote:
Hey! I did add a smiley! I just thought it was an opinion from a
reputable source that tied in with the post. :-) :-)

Sorry -- I rarely add an explicit smiley. Regardless of how my messages
might read, I rarely take much of it _terribly_ seriously.


I'll bare that in mind...

....did you see my implicit smiley!
For the question at hand, I'd postulate that an embedded SQL
implementation simply wouldn't do the job. Binding to MySQL or using
ODBC would undoubtedly work, but using MySQL, Oracle, MS SQL Server,
etc., puts us back in the situation where we basically just have SQL
talking to a server written in C.
Not necessarily, esp in the fields that Richard comes across day-in-day
out. I did have a link at work that was for a web page for a Relational
Database written in Ada that Lockhead(?) had developed.

Then again, your headers indicate that you post with Mozilla
Thunderbird running on Windows, connecting through BT Internet. What
percentage of the millions of lines of code used to write and transmit
your message do you suppose was written in Ada, and what percentage in
C and C++? :-)
I have no idea - quite possibly 0% but there are plenty of Ada apps
around - just not mass public market ones (that I know of). On the other
had there is a chance the packets that delivered this email went through
some Ada...

http://www.linuxjournal.com/article/3675

Ada advocate: "The world WOULD be better if you used Ada."
C++ advocate: "The world IS better because of the cool code I wrote."


What on earth would the C advocate say!! ;-)

Cheers

-- Martin
Jul 23 '05 #207
Jerry Coffin wrote:
Martin Dowie wrote:
Hey! I did add a smiley! I just thought it was an opinion from a
reputable source that tied in with the post. :-) :-)

Sorry -- I rarely add an explicit smiley. Regardless of how my messages
might read, I rarely take much of it _terribly_ seriously.


I'll bare that in mind...

....did you see my implicit smiley!
For the question at hand, I'd postulate that an embedded SQL
implementation simply wouldn't do the job. Binding to MySQL or using
ODBC would undoubtedly work, but using MySQL, Oracle, MS SQL Server,
etc., puts us back in the situation where we basically just have SQL
talking to a server written in C.
Not necessarily, esp in the fields that Richard comes across day-in-day
out. I did have a link at work that was for a web page for a Relational
Database written in Ada that Lockheed(?) had developed.

Then again, your headers indicate that you post with Mozilla
Thunderbird running on Windows, connecting through BT Internet. What
percentage of the millions of lines of code used to write and transmit
your message do you suppose was written in Ada, and what percentage in
C and C++? :-)
I have no idea - quite possibly 0% but there are plenty of Ada apps
around - just not mass public market ones (that I know of). On the other
had there is a chance the packets that delivered this email went through
some Ada...

http://www.linuxjournal.com/article/3675

Ada advocate: "The world WOULD be better if you used Ada."
C++ advocate: "The world IS better because of the cool code I wrote."


What on earth would the C advocate say!! ;-)

Cheers

-- Martin
Jul 23 '05 #208
On Wed, 9 Mar 2005 18:04:45 +0000 (UTC), Martin Dowie wrote:
Jerry Coffin wrote:

Ada advocate: "The world WOULD be better if you used Ada."
C++ advocate: "The world IS better because of the cool code I wrote."


What on earth would the C advocate say!! ;-)


C advocate: "The world WILL be better with the next cool patch for the cool
code I'm keep on writing."

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
Jul 23 '05 #209
"Martin Dowie" <ma**********@b topenworld.com> wrote in message
news:d0******** **@titan.btinte rnet.com...
What on earth would the C advocate say!! ;-)


Leave me alone, I've got work to do!

...
Jul 23 '05 #210

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
2352
by: Mediocre Person | last post by:
Well, after years of teaching grade 12 students c++, I've decided to make a switch to Python. Why? * interactive mode for learning * less fussing with edit - compile - link - run - debug - edit - compile - link - run -..... * lots of modules * I was getting tired of teaching c++! Bored teacher = bad instruction.
14
1822
by: Gabriel Zachmann | last post by:
This post is not strictly Python-specific, still I would like to learn other university teachers' opinion. Currently, I'm teaching "introduction to OO programming" at the undergrad level. My syllabus this semester consists of a bit of Python (as an example of a scripting language) and C++ (as an example of a compiled language). With C++, I go all the way up to meta-programming. My question now is: do you think I should switch over to...
3
1533
by: andy_irl | last post by:
Hi there I have been asked to teach HTML to a group in our local village community. It is nothing too serious, just a community development grant aided scheme. It will be a 10 week course of two hours per week and will mainly consist of mature students. I may or may not include GUI's depending if I can fit it all in to the time allocated. I was wondering if anyone could point me to any useful teaching resources for HTML on the web ie...
12
1995
by: Pierre Senellart | last post by:
I am going to teach a basic Web design course (fundamentals of HTML/CSS, plus some basic client-side (JavaScript) and server-side (PHP, perhaps XSLT) scripting). Most of the students do not have any previous knowledge of all of this. I am strongly considering teaching XHTML 1.0 Strict instead of HTML 4.01 strict, for the following reasons: - XML syntax is far more simple to teach than HTML/SGML, simply because there are not as many...
16
4371
by: msnews.microsoft.com | last post by:
I am teaching C# to my 11 year old child. One challenge is that all the C# books I own and that I have seen in bookstores are full of language that is not easily comprehended by a student at that age. Can anyone recommend books (or perhaps websites) tuned for younger audiences? BTW, its amazing how fast a student can absorb this kind of information at that age. Lucky them! Thanks, Bruce
24
2850
by: Richard Aubin | last post by:
I'm really new to vb.net programming and programming in general. I would like to teach myself on how to program effectively and I have the financial and time resources to do so. Can I anyone recommend and point me in the right direction where I should start? -- Richard Aubin
0
1712
by: e.expelliarmus | last post by:
check this out buddies. kool website for: * hacking and anti hacking tricks * anti hackng tricks. * registry tweaks * orkut tricks * small virus * computer tricks and loads of different tricks... www.realm-of-tricks.blogspot.com www.registrydecoded.blogspot.com
1
3890
by: JosAH | last post by:
Greetings, Introduction This week's tip describes a few old tricks that are almost forgotten by most people around here. Sometimes there's no need for these tricks anymore because processors nowadays are so fast and memory comes in abundance. But still, if we implement an algorithm that is better, or more efficient, than another one, those faster processors run the first algorithm faster than the other one. If an algorithm takes less...
0
9178
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9035
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8916
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8885
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6534
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4376
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3058
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2348
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2010
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.