473,805 Members | 2,017 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
Ioannis Vranos wrote:
I can't understand why native Java would be better.

A mute point since the source has now been released, but Java
compilation into native CPU machine code, presents the most efficient
expression of the OO concept in the embedded area. Bytecode, JIT and JVM
have their place, but not in space & speed limited chips.
Most Game developers use ASM and more recently C;


And more recently (years) C++. :-)

Can't argue with your correction here, however I find it is the tool,
graphic and IDE engine vendors that are driving this. The original
engine sources tended to be C with assembler booster code (Quake,
HalfLife and derivatives). Microsoft, Nvidia, SGI (where are they now!)
and GL developer packages are offered as C++ libraries. So you are still
correct.
Schools teach Basic;


Actually I think they teach Pascal and perhaps some C. But it depends on
the countries I guess.


I can only speak to the UK and USA; and just parts therein also.
Education is in the hands of the educator. Some of my colleges are
teaching Java to 11-16 year olds, thus it would not surprise me to learn
Pascal or even C is being taught to the same age group.

Note however: there are implementations of Basic that surpass both
Pascal and C. VAX Basic, for instance, was taught in an area of Florida
I lived in. Students studied it from 11yrs through to University.

Different horses, different courses. Different countries, different
methods. Different goals....

Nme. God Bless.
Jul 23 '05 #391
In article <14************ ****@linux1.kri schik.com>,
Martin Krischik <ma****@krischi k.com> wrote:
...
And they havn't got 100% compliance - as the Ada compiler vendors have. And
they can indedd claim that - Ada has the ACATS test - pass the test you are
100% compliant - fail the thest and (almost) no customer will consider your
offer.


Out of curiosity how old is the ACATS test, and how many
compilers currently pass it?
--
Greg Comeau / Comeau for the Mac? Stay tuned.
Comeau C/C++ ONLINE ==> http://www.comeaucomputing.com/tryitout
World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90.
Comeau C/C++ with Dinkumware's Libraries... Have you tried it?
Jul 23 '05 #392
In article <45************ ****@linux1.kri schik.com>,
Martin Krischik <ma****@krischi k.com> wrote:
Ioannis Vranos wrote:
Martin Krischik wrote:
For the '98 standart yes - but how about the '03 standard. As I said -
one release behind.
C++03 is C++98 bug fixed. You can have a look at the list of fixes:

http://www.acceleratedcpp.com/author.../revisions.pdf
Ups, right C++ 2003 is only the 5 year bug fix. But then: that isn't good
news. The C++ 98 is out for 7 years and you still have to look hard to find
a fully compliant compiler.
And they havn't got 100% compliance - as the Ada compiler vendors have.
Today in the latest compiler releases of the major vendors, compliance
is at least >98% (*there are* 100% compliant implementations ).


I still look for one. Not trolling here - I would realy love to see at least
one fully compiant compiler.

As for major vendors: MS-C++ 7.1 and digital mars do not know about
"export". In my book 98% does not apply when a hole keyword is missing.

Side note: All Ada templates are "export" - so it is possible implement
export.


export was implemented in C++, a few years ago now, so it's
agree it is possible to implement export. At least Comeau C++
provides export and is "100%" compliant, whatever it is that
that means.
And
they can indedd claim that - Ada has the ACATS test - pass the test you
are 100% compliant - fail the thest and (almost) no customer will
consider your offer.

There are compliance tests for C++ too.


With ISO number? If so tell me - I love to know.


Through 3rd party commercial products.
Without ISO: better then
nothing but not as helpfull to get companies like M$ to comply.


MS has disclosed the major features that they don't support.
How would it change things?
--
Greg Comeau / Comeau for the Mac? Stay tuned.
Comeau C/C++ ONLINE ==> http://www.comeaucomputing.com/tryitout
World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90.
Comeau C/C++ with Dinkumware's Libraries... Have you tried it?
Jul 23 '05 #393
In article <1110655701.196 383@athnrd02>,
Ioannis Vranos <iv*@remove.thi s.grad.com> wrote:
Martin Krischik wrote:
Well actualy: since 4 is not a valid value for the enum four_val the Ada
compiler won't compile the code - Ada does not automaticy convert enums
into integer.

The way you would do it in Ada is

pragma Assert (x'Valid);

The 'Valid attribute checks if a variable contains a valid value.

Now that I am thinking of it, isn't it a value range?
int main()
{
enum four_val {a,b,c,d};

four_val x;

x = 4;
}
C:\c>g++ temp.cpp -o temp.exe
temp.cpp: In function `int main()':
temp.cpp:7: error: invalid conversion from `int' to `main()::four_v al'


In C++ but not in C it's an error, but it can also be "invalidly"
cast to the enum.
--
Greg Comeau / Comeau for the Mac? Stay tuned.
Comeau C/C++ ONLINE ==> http://www.comeaucomputing.com/tryitout
World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90.
Comeau C/C++ with Dinkumware's Libraries... Have you tried it?
Jul 23 '05 #394
Greg Comeau wrote:
Now that I am thinking of it, isn't it a value range?
int main()
{
enum four_val {a,b,c,d};

four_val x;

x = 4;
}
C:\c>g++ temp.cpp -o temp.exe
temp.cpp: In function `int main()':
temp.cpp:7: error: invalid conversion from `int' to `main()::four_v al'

In C++ but not in C it's an error, but it can also be "invalidly"
cast to the enum.

Yes, the subject in this thread is C++ and Ada. :-)

Also casting this means that you know what you are doing, and thus not
excused for mistakes. :-)

Thus you can't do that by accident.


--
Ioannis Vranos

http://www23.brinkster.com/noicys
Jul 23 '05 #395
Ed Falis wrote:
On Sat, 12 Mar 2005 12:46:11 -0500, CTips <ct***@bestweb. net> wrote:
For example, look at the Ada equivalent of the following code.
typedef enum {0, 1, 2, 3} four_val;
four_val x;
x = (four_val) some_int;
....
assert( x < 4);

type Four_Val is range 0 .. 3;
X : Four_Val;


pragma Volatile (X); -- ;-)
begin
X := Four_Val (Some_Int);
...
pragma Assert (X < 4, "Something is seriously honked here");
-- Currently supported by GNAT; part of Ada 2005
-- Or write your own subprogram in Ada 95 as I did for AUnit
Do_Something_Wi th (X);
Are you sure? After all 4 is not a valid value for Four_Val. I would rather
go for either:

pragma Assert (X <= Four_Val'Last, "Something is seriously honked here");

or:

pragma Assert (X'Valid, "Something is seriously honked here");
Sounds to me as though you just like to argue, because this one was pretty
silly.


Of course it is silly - mostly because the C example isn't using volatile
which you should if you fear hardware intervention - otherwise X might be
cached inside a register and you never notice the problem anyway.

Martin
--
mailto://kr******@users. sourceforge.net
Ada programming at: http://ada.krischik.com

Jul 23 '05 #396
Greg Comeau wrote:
In article <14************ ****@linux1.kri schik.com>,
Martin Krischik <ma****@krischi k.com> wrote:
...
And they havn't got 100% compliance - as the Ada compiler vendors have. And
they can indedd claim that - Ada has the ACATS test - pass the test you are
100% compliant - fail the thest and (almost) no customer will consider your
offer.

Out of curiosity how old is the ACATS test, and how many
compilers currently pass it?


The latest (I believe) is dated 2002 but will certainly be getting
updated to test Ada2005. See http://www.ada-auth.org/acats.html

All compiler vendors claim some level of conformance and some publish
their results. Also, all compiler vendors will have a large number of
suplimentary tests of there own. These tend to include propriatory code
from customers, so usually aren't published.

Cheers

-- Martin

Jul 23 '05 #397
Ioannis Vranos wrote:
Martin Krischik wrote:
Well actualy: since 4 is not a valid value for the enum four_val the Ada
compiler won't compile the code - Ada does not automaticy convert enums
into integer.

The way you would do it in Ada is

pragma Assert (x'Valid);

The 'Valid attribute checks if a variable contains a valid value.

Now that I am thinking of it, isn't it a value range?
int main()
{
enum four_val {a,b,c,d};

four_val x;

x = 4;
}
C:\c>g++ temp.cpp -o temp.exe
temp.cpp: In function `int main()':
temp.cpp:7: error: invalid conversion from `int' to `main()::four_v al'


True - C++ won't convert int to enum either without a static_cast. You know
what I realy miss in C++: dynamic_cast for discreed number:

long X = f();
short Y = dynamic_cast <short> (X);

with a throw range_error when X is to large for Y.

Yes - I have a template for that. But a template need two parameters
<from_type, to_type> and won't optimize as well as a build in function.
And with -W3 you need a lot of specialized versions to avoid all sorts of
"conditiona l ist constant" warnings.

Martin
--
mailto://kr******@users. sourceforge.net
Ada programming at: http://ada.krischik.com

Jul 23 '05 #398
Robert A Duff wrote:
Martin Krischik <ma****@krischi k.com> writes:
And they havn't got 100% compliance - as the Ada compiler vendors have.
And they can indedd claim that - Ada has the ACATS test - pass the test
you are 100% compliant - fail the thest and (almost) no customer will
consider your offer.


Now wait. Let's be fair. Sure, the ACATS test suite is a good thing.
But no test suite can ensure 100% compliance with the language
standard. Ada compilers do have bugs that are not caught by the ACATS!


Shure, you are right. However in the end the 100% stuff is all about
marketing - as you said - no compiler is bug free. And in fact nowadays
most of the "chosing a compiler" stuff is about marketing. Not the best
wins but the one average one with the best marketing does.

And here a CCATS and C++CATS would help a lot. Or could you imagine any Ada
vendor not submitting to running the ACATS?

Note to the C/C++ community: when we speak of ACATS we also speak of the Ada
Conformity Assessment Authority (http://www.ada-auth.org/) which actualy
runs the test. Shure anybody can run the test (i.E. with gcc you use "make
-C gcc check-ada" - you need configured gcc sources and a gcc with Ada
enabled) but that is of no marketing value.

Martin
--
mailto://kr******@users. sourceforge.net
Ada programming at: http://ada.krischik.com

Jul 23 '05 #399
In article <1110700112.230 910@athnrd02>,
Ioannis Vranos <iv*@remove.thi s.grad.com> wrote:
Greg Comeau wrote:
Now that I am thinking of it, isn't it a value range?
int main()
{
enum four_val {a,b,c,d};

four_val x;

x = 4;
}

C:\c>g++ temp.cpp -o temp.exe
temp.cpp: In function `int main()':
temp.cpp:7 : error: invalid conversion from `int' to `main()::four_v al'


In C++ but not in C it's an error, but it can also be "invalidly"
cast to the enum.


Yes, the subject in this thread is C++ and Ada. :-)

Also casting this means that you know what you are doing, and thus not
excused for mistakes. :-)

Thus you can't do that by accident.


*You* can not, but somebody else can :) :)
--
Greg Comeau / Comeau for the Mac? Stay tuned.
Comeau C/C++ ONLINE ==> http://www.comeaucomputing.com/tryitout
World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90.
Comeau C/C++ with Dinkumware's Libraries... Have you tried it?
Jul 23 '05 #400

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
10607
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...
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
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
2
3843
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3007
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.