473,748 Members | 5,230 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 29615

Ioannis Vranos <iv*@remove.thi s.grad.com> writes:
Pascal Obry wrote:
Note that it is for this very reason that Java was born (a safer C++). Java
has indeed removed lot of unsafe constructs from C++.

Please do not start a real flame! Java is far behind C++. It is a silver


Sorry I do not intend to. This is history and as described by Java
creators. Please read my other post.

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 #301
Ki*******@SpamC op.net (Larry Kilgallen) wrote in message
Nobody objects to someone using the name ADA in a program written in Ada.
The comments are about someone using improper capitalization in text
written in English, a language which is case-sensitive.
As many people on this thread noticed, it was only a (bad?) joke. I
simply wanted to remark that I was somewhat tired of reading the same
story of Ada L. when some innocent soul dared to write "ADA" :)
3. Many of you want us to believe that ADa performs ra nge checking
without loss of performance: it can be true at compile time with fixed
ranges, but it can't definitely be done without chechinkg array bounds
every time data is accessed if we don't know these bounds before
compiling (e.g.: typical cases where dynamic allocation of memory is
used)


As has been stated, it is _much_ more efficient that do-it-yourself
range checking written in C++, because the compiler has more data.
For those who insist on _no_ range checking (compute intensive inner
loops), turn off the range checking if it gets in the way for that
one area of code. But be certain it gets in the way first - it
is common to make bad guesses about whether range checking will
affect overall performance. Ada programmers are better able than
C* programmers to know that, because in Ada it is easier to turn
range checking on and off.


Yes, but consider the existence of STL that lets you not to
"do-it-yourself" when storing or accesing data ;)
mechanisms, only interfaces (pure virtual classes)[2]. To me, it
sounds reasonable to work with the last version of a compiler when
possible.


That does not seem so reasonable to people working on a mission-critical
30 year project. In many cases such circumstances warrant working with
the compiler originally used for the project.


You are right: if something works, it is usually better not to touch
it, but in this case, you are stuck with Ada83!
Jul 23 '05 #302
Pascal Obry wrote:
That's not a misunderstandin g. That's how Sun has described Java. They started
from C++ and have removed many unsafe features. They eventually stop the
process at some point and this has given birth to Java. That's history.

The bottom line is that as a language itself it has less abilities than
C++, the framework being another case.

There is an upcoming ECMA C++/CLI standard (that will be finished
probably this month), which is about ISO C++ extensions for taking
advantage of a CLI VM when one is available (it replaces and extends
Microsoft's current "managed extensions" for C++).
You may download the latest draft from here:

http://www.plumhall.com/C++-CLI%20draft%201.8.pdf
With C++/CLI and VC++ 2005, C++ becomes the systems programming language
of CLI (and .NET):
You may take a look at these:

http://msdn.microsoft.com/msdnmag/is...s/default.aspx

http://pluralsight.com/blogs/hsutter...0/05/2672.aspx

http://blogs.msdn.com/branbray/archi.../07/51007.aspx

http://www.accu.org/conference/prese...keynote%29.pdf
And a page of mine:

http://www23.brinkster.com/noicys/cppcli.htm

With C++/CLI, C++ has two worlds: The unmanaged world and the managed world.

In the managed world every CLI (.NET) feature is provided separately
from the unmanaged world features.

--
Ioannis Vranos

http://www23.brinkster.com/noicys
Jul 23 '05 #303
>"Interesting ", indeed. ;-) Unfortunately, about half of this
information is complete nonsense -- about both languages!


I would like to believe that people like you would point out the
nonsense preventing people like me from consuming it.

Jul 23 '05 #304
Ioannis Vranos wrote:
Pascal Obry wrote:
package API is
pragma Remote_Call_Int erface;

procedure Call_Me (Str : in String);
end API;

What is it doing?


pragma Remote_Call_Int erface categorizes the package "API"
as a remote call interface library unit.

LRM E.2.3:
7. A remote call interface (RCI) is a library unit to which the pragma
Remote_Call_Int erface applies. A subprogram declared in the
visible part of such a library unit is called a remote subprogram.

It might be worth mentioning that Ada programs can constist of
partitions. They can be distributed programs then. A remote
call interface is assigned to one partition.

Georg

Jul 23 '05 #305
Dmitry A. Kazakov wrote:
Heap is far slower than stack. Also stack is much safer, because objects
allocated on the stack have visible scopes, as compared to adventures with
pointers. Do you want to add one more indirection layer - smart pointers,
or do it even worse by using GC?

Regarding Storage_Error exception, C++'s one is bad_alloc, which is
guaranteed to *never fail* in case of memory starvation.

About stack. Strictly speaking, C++ standard does not define any stack
apart from a stack container , but "automatic storage" and "dynamic
storage".
It is common though the first to be called "stack" and the second "heap"
or "free store".
It is an implementation' s/platform's job to provide stack and heap.
Usually the stack is limited in comparison to the heap, and it sounds
strange to me that in Ada there is a large stack. My guess is that you
are using the heap for data storage implicitly(?) and you think you are
using the stack.
Are you familiar with "Resource Acquisition is Initialisation" (RAII)
technique? This is supported by C++ and used by all standard library
containers.


--
Ioannis Vranos

http://www23.brinkster.com/noicys
Jul 23 '05 #306
Ioannis Vranos wrote:
Usually the stack is limited in comparison to the heap, and it sounds
strange to me that in Ada there is a large stack. My guess is that you
are using the heap for data storage implicitly(?) and you think you are
using the stack.


Nope. And you can control in portable Ada how big the stack for a given
task must be.
Jul 23 '05 #307
Ioannis Vranos wrote:
Regarding Storage_Error exception, C++'s one is bad_alloc, which is
guaranteed to *never fail* in case of memory starvation.

About stack. Strictly speaking, C++ standard does not define any stack
apart from a stack container , but "automatic storage" and "dynamic
storage".
It is common though the first to be called "stack" and the second "heap"
or "free store".
It is an implementation' s/platform's job to provide stack and heap.
Usually the stack is limited in comparison to the heap, and it sounds
strange to me that in Ada there is a large stack. My guess is that you
are using the heap for data storage implicitly(?) and you think you are
using the stack.

As is the case when I use a vector<int> for example. The object itself
is in the stack, however internally it allocates memory in the heap to
store its members, which releases with its destructor when it is
destroyed (e.g. in the end of its scope).

Are you familiar with "Resource Acquisition is Initialisation" (RAII)
technique? This is supported by C++ and used by all standard library
containers.

In summary RAII is a technique which is used to encapsulate resources
(as vector does for memory and is used as a general array, and string
also and is used as a string type), with the constructor allocating the
resources and the destructor releasing them, and thus producing
bullet-proof code.
When an exception is thrown or the object reaches the end of its scope,
the object gets destroyed releasing the resources via its destructor.
RAII can be used for any kind of resources, IP connections, memory,
files, etc. All standard library containers use RAII.

--
Ioannis Vranos

http://www23.brinkster.com/noicys
Jul 23 '05 #308
In article <e3************ **************@ posting.google. com>, az****@yahoo.es (Alberto) writes:
Ki*******@SpamC op.net (Larry Kilgallen) wrote in message


Somebody no longer attributed wrote:
> mechanisms, only interfaces (pure virtual classes)[2]. To me, it
> sounds reasonable to work with the last version of a compiler when
> possible.


That does not seem so reasonable to people working on a mission-critical
30 year project. In many cases such circumstances warrant working with
the compiler originally used for the project.


You are right: if something works, it is usually better not to touch
it, but in this case, you are stuck with Ada83!


I have made many changes in the past 6 months to a 16 year old program
written in Ada 83. There are now about 200,000 source lines of code,
and since the changes were all to do "more of the same" I never felt
any lack of capability in the language. The problems I encountered
while debugging were almost all in three or so modules _not_ written
in Ada.

But similar to what we agreed about compilers, I am not about to
switch programming languages on those few modules at this point.
Jul 23 '05 #309

"Dmitry A. Kazakov" <ma*****@dmit ry-kazakov.de> skrev i en meddelelse
news:qe******** *************** ******@40tude.n et...
On Fri, 11 Mar 2005 10:42:51 +0100, Peter Koch Larsen wrote:
"Dmitry A. Kazakov" <ma*****@dmit ry-kazakov.de> skrev i en meddelelse
news:97******** *************** ******@40tude.n et...
> 2. C++ is unable to allocate objects of indefinite size on the stack.

Well, we have alloca() for this ;)

Try to return such object from a function. Ada can

declare
Object : T'Class := Read_It_From_Fi le;

Here neither the specific type, nor the size of the object are known at
compile time. Another example:

declare
Line : String := Read_Source_Lin e (File);

Or even:

Put_Line (Read_Source_Li ne (File));


The solution is simple here - just allocate your memory on the heap.


Heap is far slower than stack. Also stack is much safer, because objects
allocated on the stack have visible scopes, as compared to adventures with
pointers. Do you want to add one more indirection layer - smart pointers,
or do it even worse by using GC?


I believed the object might have to be returned? Read the post once again.
If this is so, you can not allocate it on the stack without having to copy
when you return the object. Surely the copy must be more expensive than the
allocation?
Ordinary heap-based speed is not so slow and if you need to get the last
cpu-cycle away, you can simply use an arena for your allocation.
Also you will of course use a smart pointer in the situation above. A C++
programmer with respect for himself only rarely uses new without putting the
result in some kind of smart pointer. Personally, I do not remember when i
did that last.

/Peter
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

Jul 23 '05 #310

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

Similar topics

20
2356
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
1827
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
1536
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
1998
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
4376
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
2858
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
1714
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
3893
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
8830
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9544
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
9372
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
9324
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,...
1
6796
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
6074
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4606
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
3313
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
2783
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.