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

  • Thread starter Turamnvia Suouriviaskimatta
  • Start date
D

dave

Ioannis said:
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.
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.
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.
 
G

Greg Comeau

...
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?
 
G

Greg Comeau

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.



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.
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?
 
G

Greg Comeau

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_val'

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

Ioannis Vranos

Greg said:
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.
 
M

Martin Krischik

Ed said:
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_With (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
 
M

Martin Dowie

Greg said:
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?[/QUOTE]

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
 
M

Martin Krischik

Ioannis said:
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_val'

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
"conditional ist constant" warnings.

Martin
 
M

Martin Krischik

Robert said:
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
 
G

Greg Comeau

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 :) :)
 
G

Greg Comeau

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

All compiler vendors claim some level of conformance

In what ways? This sounds like a different statement
than I thought others were saying/implying.
and some publish their results.

Again, seems a different statement.
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.

I'm sure.

I'm also sure this is all workable, and to work well.
As I'm sure it's not the only way to do it (not saying
you said it was, just adding to the table).
 
G

Greg Comeau

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 don't forget comments such as that found in
http://www.ada-auth.org/acats.html: "Formal test disputes should
submitted to the agent ..." meaning bugs and other things can
pop up in other areas too.
And here a CCATS and C++CATS would help a lot. Or could you imagine
any Ada vendor not submitting to running the ACATS?

Probably can't imagine it, but in the end, the playing field
seem level.
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.

Probably. FWIW, C++ has always succeeded against horrible
marketing. It's unclear whether that is a plus or not,
or whether some other way is.
 
M

Martin Krischik

I am not convinced yet this integer range topic is that a big issue.

The JPEC viruses work in integer range overruns - and that is an issue since
a virus inside an JPEC picture is nasty. Every Web-Page has dozends of
JPEC's - no web browser would consider a JPEC a security risc.
One
can easily write his own test routine (function, template), if the
default provided assert() doesn't do the job.

But assert() only work if the programmer won't forget to insert one. And the
programmers for libjpec for Linux as well as the Microsoft employees which
did a similar lib for Windows forgot.

Not one pogrammer forgot: both *teams* forgot. Not matter if OpenSource team
or comertial team - both forgot to check the integer range inside a JPEC
picture.

For this I go for the template version - and I do indeed have a template
called Ada::Range for C++. And this template can check any range (i.E.
typedef Ada::Range <short, 1, 31> Day_Of_Month;) and not only short, long
overruns. Very helpfull indeed.

And yes, I have a template called numeric_cast <class From, class To> as
well - just build in would be better.

Martin
 
M

Martin Krischik

Greg said:
Greg said:
In what ways? This sounds like a different statement
than I thought others were saying/implying.

The Ada standart consists of the core language and optional features like
real-time system and distributed systems.
Again, seems a different statement.

You might want to read the first chapter of http://www.ada-auth.org. Usualy
the test is done by third part laboratories and then the vendor publish
"pass" for there major releases - but they might not publish for
intermediate releases :-( .

BTW: In the past it was Ada(tm) and only compilers with pass the test where
allowed to use the trademark Ada. For better or worse that is gone now -
and with it the need for a vendor to publish the result.

Also: The test is OpenSource and it is even part the gcc source tree - so if
you have the gcc sources handy you can just run the test yourself.
I'm sure.

I'm also sure this is all workable, and to work well.
As I'm sure it's not the only way to do it (not saying
you said it was, just adding to the table).

The important point that it puts more pressure on the vendors as most
customers won't consider a compiler which won't pass the test.

Martin
 
M

Martin Dowie

All compiler vendors claim some level of conformance
The Ada standart consists of the core language and optional features like
real-time system and distributed systems.

I only meant "publish" as in 'here's our results on our website'. I'm
sure all vendors would make their results available if you asked their
sales/marketing/support.

Cheers

-- Martin
 
J

Jerry Coffin

Martin Krischik wrote:

[ ... ]
Did they? Or did they just implemented some 80% of the new features?
My experience with C/C++ (and I have 10 years + of that) is that at
no time there was a fully compiant C compiler available. There where
allways a lot of compiler avaliable who claimed to be
<small>almost</small> complinant - but never one which realy was.

Partily because - unlike Ada (http://en.wikipedia.org/wiki/ISO_18009)
- there is not official testsuite to test a C/C++ compiler and
runtime library. Such an official testsuite would do C/C++ all sorts
of good.

I'm quite impressed with the statements above -- lots of Usenet posts
contain errors, but most of them are pretty obvious. You've managed to
fit more plausibile-sounding errors into fewer sentences than nearly
any other post I've ever seen.

Let's address the Ada side first. Official Ada validation was done
under the auspices of NIST, who delegated this task to the Ada Joint
Program Office. The AJPO ceased to exist years ago, and the job was
never turned over to anybody else when that happened. Meanwhile, NIST
has discontinued _all_ of its compiler validation programs, not just
the Ada program. Currently, both the ISO standard at a number of FIPS
pubs _require_ Ada compilers to be officially validated, but at least
in the US, there is absolutely NO agency to do that.

The situation on the C side isn't nearly as different as you seem to
think. After the C standard was published, NIST and BSI (to name only
two that I know of with certainty) started doing validation of C
compilers. BSI certified at least one C implementation in 1990, the
same year the ISO C standard was approved. While that first one was for
code-checking, not production of executables, other implementations
(e.g. at least one version from Borland) were certified as well.

As mentioned above, NIST no longer validates/certifies compilers, so at
least in the US, there is no such thing as an officially validated
compiler for C, Ada, or any other language.
What do you mean by "exists today"? C99 is 5 years old and still no\
compiler is available which support all C99 features. "restrict" -
missing in MS-C (even thrue restrict can be implemented as "no
operation") - VA - arrays (savety critical feature) - missing in
MS-C, buggy in GCC.

I take it you've never used or even tested the Comeau compiler?
Maybe just maybe - if there realy was any standart compiler available
- but there isn't - the C/C++ compiler vendors are allways one
release behind the actual ISO standart.

I see Greg has entered the thread, so he can speak for himself, but
unless memory serves me particularly poorly today, he had C++ 2003
implemented _before_ it was officially approved.

In fairness, I should add that I found a _few_ defects in the Borland
compiler that was certified -- but back when I worked in Ada, I found
defects in every certified Ada compiler I used as well. In both cases
the defects were small and easily avoided, but the defects in the C
compilers were smaller and more easily avoided.

[ ... ]
It is true that a programming language need some minimum features set
to be usefull. And that feature set is a lot larger then most belive.
If a successfull language does not provide that set it will be bolted
on later. If anything the current C/C++ ISO standards clearly show'
that the advocates for slim languages hat been wrong all along.

More nonsense, I'm afraid. First of all, the argument is defective from
the beginning: changes in C and/or C++ absolutely cannot prove anything
about languages in general. Second, some extremely slim languages have
clearly been useful at times, easily disproving your conclusion on
minimum feature sets as well.

None of this proves, or even provides evidence, directly related to
what is claimed by most advocates of smaller languages. Most have said,
for example, that all else being equal, a smaller feature set is easier
to understand completely. Now you may be convinced that a larger
feature set outweighs this fact, and you might even be right -- but
that doesn't make them wrong.

IMO, arguments of the benefits of "small" ("slim", etc.) vs. larger
languages mostly miss the point though. IMO, there's a much more
fundamental and useful distinction to be considered. That is the
distinction between those where the language itself is the major
player, and those were the language is mostly a way of producing and/or
using libraries.

Ada certainly provides facilities useful for writing libraries, but at
least to me seems to fall into the former group -- it works well for
writing code directly, but attempting to write good libraries in it
tends to be frustrating.

C++, while certainly providing some features useful for direct coding,
is strongly oriented toward the language providing facilities for
building libraries, and much (in many cases, MOST) of what the end-user
does is uses the libraries.

Looking at things from this perspective, Ada may be the last of its
line. 30 years ago, Lisp was nearly the only library-oriented language,
with a miniscule market share.

Now, the library oriented languages dominate. Fortran and Cobol may
never die, but they're certainly not the market leaders they once were.
PL/I is dead, and Ada is hardly dominant. C++ has already been
mentioned. Java is a fairly small language with a huge library. The
next obvious step is .NET, which de-emphasizes languages to the point
that .NET itself IS simply a huge library, with facilities to make it
easy to use that library from any (or all) of a large and growing
collection of languages.

Of course, if you want to discuss slim languages, there's always
Smalltalk -- the language itself is absolutely puny, providing little
more than the ability to send messsages to objects, and receive back
results. Everything else is in the standard library, even such basics
as creating an object. This means the language needs a fairly large,
pre-existing standard library to be able to do anything at all.
 
I

Ioannis Vranos

Jerry said:
The next obvious step is .NET, which de-emphasizes languages to the point
that .NET itself IS simply a huge library, with facilities to make it
easy to use that library from any (or all) of a large and growing
collection of languages.



More precisely, it is a CLI compliant VM environment which provides a
fairly large, high-level, Windows-oriented API which is common for all
languages.


However C++/CLI design ideals, are not only C++ to be used for
application programming as a first class citizen CLI (.NET) citizen, but
*also* for .NET library writing (managed dlls).


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/issues/05/01/COptimizations/default.aspx

http://pluralsight.com/blogs/hsutter/archive/2004/10/05/2672.aspx

http://blogs.msdn.com/branbray/archive/2003/11/07/51007.aspx

http://www.accu.org/conference/pres...Relevant_on_Modern_Environments_(keynote).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.
 
E

Ed Falis

Ada certainly provides facilities useful for writing libraries, but at
least to me seems to fall into the former group -- it works well for
writing code directly, but attempting to write good libraries in it
tends to be frustrating.


Interesting way of thinking about things. But for writing libraries, I
tend to prefer Ada and Eiffel (in that order). I don't really see what
leads to the frustration you talk about above - wouldn't mind hearing your
opinions about that.
Admittedly, creating a library written in either of these two languages
for use by other languages requires some special steps in packaging, but
they can be easily automated. Java, of course, requires anything written
in other languages to be specially packaged for it to be a client (perhaps
excepting components accessible via RMI or another component model). And
most component models require special packaging anyway.

- Ed
 
G

Greg Comeau

Greg said:
Greg Comeau wrote:

Still looking for this number if anybody has it handy.

The Ada standart consists of the core language and optional features like
real-time system and distributed systems.



You might want to read the first chapter of http://www.ada-auth.org. Usualy
the test is done by third part laboratories and then the vendor publish
"pass" for there major releases - but they might not publish for
intermediate releases :-( .

BTW: In the past it was Ada(tm) and only compilers with pass the test where
allowed to use the trademark Ada. For better or worse that is gone now -
and with it the need for a vendor to publish the result.

These points certainly "lessen the gap" then (if there was one)
and make it much closer to the C++ situation then.
Also: The test is OpenSource and it is even part the gcc source tree - so if
you have the gcc sources handy you can just run the test yourself.


The important point that it puts more pressure on the vendors as most
customers won't consider a compiler which won't pass the test.

I not convinced it puts "more pressure." I'm sure it puts some
pressure but "different pressure".

In the C++ world, customers do consider compilers which won't pass.
And it's no secret that this is the case, even w/o all the specifics.
(And I don't think this disses standardization efforts.)

As just one counter-example, and I've leaving out many many details,
but MS was not keeping up, and customer pressure came even w/o
"official tests", and they reacted, to their credit. So the
official tests need not be a requirement and one can get similar
end results through alternative means. No one way is perfect.
 
R

Robert A Duff

Yes, I just said Pascal had that.

Oh, sorry, I must have thought you said "...in addition to what Pascal
has..." or something. My bad.

Anyway, nested functions are really nested in any useful sense if you
can't do uplevel addressing, right?

- Bob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,202
Messages
2,571,057
Members
47,667
Latest member
DaniloB294

Latest Threads

Top