473,805 Members | 1,995 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 29864
Dr. Adrian Wrigley wrote:
Even in simple cases, the encapsulation has to be broken


Free functions that help implement an abstraction don't break
encapsulation, they are part of it.
Jul 23 '05 #461
Robert A Duff wrote:
Because the "<" (or Hash) needs to know the internals of the thing.
It may be possible to order the objects through information
available from public accessors, so this is false.
In other words, at the point where you declare a type, you have to think
ahead: this type might want to live inside one of those containers, so
I'd better define the necessary operations.


False, as per above. In fact, the ordered containers can be instantiated
with order functions, so there need not be a single unique ordering for
a given type.

For example, any string type has a public way of delivering up the
characters it contains. That lets you define string containers which
hold their strings in alphabetical order, in case-insensitive order,
or even in pig-latin order if you want. None of this requires the
string implementor to anticipate such ordering requirements.
Jul 23 '05 #462
Robert A Duff wrote:
Such as... ?

I'm still not understanding your point. Are you referring to the fact
that the Java garbage collector cannot reasonably be implemented in
Java, and things like that?

Apart from these, let's talk about Pascal for example. I do not think
everything in its library can be written with the language itself.

--
Ioannis Vranos

http://www23.brinkster.com/noicys
Jul 23 '05 #463
Dr. Adrian Wrigley wrote:
This means that you can't write an implementation of a template/generic
function using a map/hash without changing some/all the implementations
and interfaces up the instantiation tree (am I right?).


No, you are wrong. Simply write your comparison or hash function at the
point where you need it. Use the public accessors to get the data you
need to perform the operations.
Jul 23 '05 #464
Hyman Rosen <hy*****@mail.c om> writes:
Robert A Duff wrote:
Because the "<" (or Hash) needs to know the internals of the thing.


It may be possible to order the objects through information
available from public accessors, so this is false.


OK, please let me amend my statement to "...*usuall y* needs to know...".

So "this is false" should be "this is sometimes false".
In other words, at the point where you declare a type, you have to think
ahead: this type might want to live inside one of those containers, so
I'd better define the necessary operations.


False, as per above. In fact, the ordered containers can be instantiated
with order functions, so there need not be a single unique ordering for
a given type.

For example, any string type has a public way of delivering up the
characters it contains. That lets you define string containers which
hold their strings in alphabetical order, in case-insensitive order,
or even in pig-latin order if you want. None of this requires the
string implementor to anticipate such ordering requirements.


Yes, if the thing has a natural "<" function, or some public information
from which that can be garnered, then "<" is not a problem. That's true
of character strings. And of course I understand that you can sort
backwards by using a different function (as in "<" => ">" in Ada
terms).

But if you want to hide most of the data of some abstraction, and
there's no "natural" meaning of "<", then you have to think ahead, and
define some "<" operation just in case somebody wants to put the thing
into a container. (Or, of course, go back and add that in to an
existing data type when you find it's needed.)

The same is true with Hash. For a character string type, you can
declare it on the fly, because such a type exposes all the data. But
for a type that's "private" in Ada, or has protected/private members in
C++, the Hash function, like the "<" function, often needs access to the
private data. In Ada, you can use a child (which does not require
modifying the original thing). In C++, you can use a friend. Or, in
either language, you can just put Hash or "<" in the original thing.

One possibility is to have a coding convention: always declare "<" and
Hash for every data type, just in case it might be needed for one of
these containers.

- Bob
Jul 23 '05 #465
On Tue, 15 Mar 2005 00:47:37 +0200, Ioannis Vranos wrote:
struct IntervalLessCom pare
{
inline bool operator() (interval a, interval b) const
{
using namespace std;

return difftime( mktime(&a.finis h), mktime(&a.start ) ) <
difftime( mktime(&b.finis h), mktime(&b.start ) );
}
};


Doesn't this break down for times beyond the end of the epoch,
which are valid tm values, but invalid time_t values?
You've ended up mapping all post-epoch times to the same entry!

Doesn't it also break down when someone adds a microsecond
value in the tm struct for some platforms? Seems like
a reasonable thing for someone to try to do, but breaks this
code. You have to then introduce a platform specific fix.
Maybe unlikely for ctime, but there are plenty of less stable
interfaces. What if it was mm.h's mem_core struct (Linux)?
What about things with floating point components, where
different values compare as equal (+0 and -0) and
identical values (NaN) give inconsistent comparison?

In general, you may need to use "private" implementation details
of the class when defining the operator, ending up with
broken code, broken "contracts" and broken encapsulation.

This is sounding too much like a troll, and I think the points
have been fully made by Robert and others. I have learnt that
there is a major gulf between users' expectations of C++ templates
and of Ada generics. "contract model" is the difference.
--
Adrian

Jul 23 '05 #466
On Mon, 14 Mar 2005 23:46:33 +0000, Hyman Rosen wrote:
Dr. Adrian Wrigley wrote:
This means that you can't write an implementation of a template/generic
function using a map/hash without changing some/all the implementations
and interfaces up the instantiation tree (am I right?).


No, you are wrong. Simply write your comparison or hash function at the
point where you need it. Use the public accessors to get the data you
need to perform the operations.


That's the point... there aren't any public accessor functions
for opaque data types such as non-limited generic formal parameters.
--
Adrian

Jul 23 '05 #467
Ioannis Vranos <iv*@remove.thi s.grad.com> writes:
Robert A Duff wrote:
Such as... ?
I'm still not understanding your point. Are you referring to the fact
that the Java garbage collector cannot reasonably be implemented in
Java, and things like that?


Apart from these, let's talk about Pascal for example. I do not think
everything in its library can be written with the language itself.


Pascal (as defined by Wirth) doesn't even support separate compilation,
so there is no concept of libraries in Pascal, so nothing in its
"libraries" can be written in Pascal.

- Bob
Jul 23 '05 #468
Robert A Duff wrote:
Pascal (as defined by Wirth) doesn't even support separate compilation,
so there is no concept of libraries in Pascal, so nothing in its
"libraries" can be written in Pascal.

Actually I had turbo pascal 6.x-7.x in mind.

--
Ioannis Vranos

http://www23.brinkster.com/noicys
Jul 23 '05 #469
In article <1110843401.905 302@athnrd02>, Ioannis Vranos <iv*@remove.thi s.grad.com> writes:
Robert A Duff wrote:
Such as... ?

I'm still not understanding your point. Are you referring to the fact
that the Java garbage collector cannot reasonably be implemented in
Java, and things like that?

Apart from these, let's talk about Pascal for example. I do not think
everything in its library can be written with the language itself.


Presuming that by "Pascal" you mean something meeting the "Extended Pascal"
standard rather than the Wirth original,

not a library, but...

When DEC implemented their A1 security kernel they did so in VAX Pascal
(to support provability) and required that the whole thing be written
in Pascal rather than using a runtime library written in some other
language.

==========

They cancelled the project during Field Test when they figured out that
those in the US government who wanted to see A1 systems were entirely
different from those in the US government who actually purchase systems.

I believe, in fact, those rooting most strongly for Multilevel Security
actually run "system high" in their own shops.
Jul 23 '05 #470

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

Similar topics

20
2366
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
1828
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
1538
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
2004
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
4379
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
2867
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
1720
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
3897
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
9716
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9596
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
10359
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
10364
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
10104
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...
0
9182
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6875
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
5677
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4317
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

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.