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

  • Thread starter Turamnvia Suouriviaskimatta
  • Start date
J

Jerry Coffin

Martin Krischik wrote:

[ ... ]
No, I was making a different point here. You are right: they are
alphabetical and I have overlooked that. But the important part of my
question was: but why didn't marketing use an alphabetical order when
writing the web side?

Look at it from their perspective for a moment: why would they?
So my point stands: marketing effort or perhaps "coolness" has more
to influence then actual technical facts. Which I find sad, but is
true for as long I can think back for all sorts of technologies.

Marketing people generally think none of this stuff is even sligtly
"cool" or anything like it. They are influenced very strongly by facts,
but under the circumstances, the facts they care about almost certainly
come from their accounting department. IOW, they emphasize C over Ada
not because they think it's cool but because it makes money.
 
D

Dmitry A. Kazakov

they emphasize C over Ada
not because they think it's cool but because it makes money.

Rather they think it would make more money because it is cool ...
 
M

Martin Krischik

Jerry said:
Look at it from their perspective for a moment: why would they?

Indeed why would they :-( .
IOW, they emphasize C over Ada
not because they think it's cool but because it makes money.

For marketing people that's the same: Cool is only what makes money - but
that does not make the world a better place, don't it.

Martin
 
G

Guest

Ioannis Vranos said:
Well, if it [Ada] becomes more freely available, no permission from any ministry for making a
compiler or something is required, I think it can become mainstream. I think it would make
more sense if Delphi was based on Ada than Object Pascal for example.
It is rather odd that, after all these years, many people still think Ada is
the property of the U.S. Government. The Ada Language Reference
Manual contains the specification for the language. Anyone who wants
to create a compiler is free to do so. Ada is being used for military
and non-military projects all over the world. One of the largest military
projects in the world that uses Ada is in Mainland China. In fact, the
Chinese have created their own Ada compilers. My book, Ada Distilled,
has been downloaded by people in places such as Oman, Cuba,
Iran, France, Sweden, and many other places. I'm pretty sure that
any downloading my book is also downloading the GNAT Ada
compiler.

Certain Ada libraries, such as the Common Ada Missiles Package
(CAMP) are classified. The software written in Ada for weapons
systems is classified. But the language itself is free for everyone to
use, in any way they wish.

Richard Riehle
 
C

Chad R. Meiners

Jerry Coffin wrote
I was talking specifically about Airbus' use, and looking at:
http://www.esil.univ-mrs.fr/~spc/rcs02/slides/Baufreton.pdf
and:
http://www.systemes-critiques.org/jslc2001_slides/FrancoisXavier_Dorm...
indicates that they're consistently using C, not Ada.

No the slides do not indicate this. For all we know the project that
the slides are talking about has to target hardware for which there is
only a C compiler. It could be that Airbus only uses such tools on
such hardware.

Using presentation slides as such an indicator is usually a bad idea.
Presentation slides are made for a specific context, and time frame.
They often lack full and complete information. The slides don't
explicitly support your claim.
 
C

Chad R. Meiners

Jerry said:
Second, this seems to assume that all the code is generated by SCADE,
and none written directly. This does NOT seem to be the case -- if you
look at page 6 of:
http://scilabsoft.inria.fr/events/05_11_03/ESTEREL.pdf
you'll see that they only claim 70% of the code was generated by SCADE.
Given the size of project we're talking about, the remaining 30% is a
_significant_ amount of code. It seems likely to me that if they were
using Ada for the hand-written code, they'd generate Ada as well.

First, this nine slide sales pitch doesn't actually mention any
language other than SCADE. Second, the 70% could have been the user
interface, which communicated with a seperate subsystem that made up
the bulk of the the remaining 30%. If a language like SCADE can't
generate 95-99% of the code that it needs for a project, it isn't a
very good formal tool. 30% is an aweful lot of room to invalidate any
assurances that SCADE provided about the 70%. It would be my educated
guess that SCADE was used in a subsystem which represented about 70% of
the total code of the complete system. Anyway, when you deal with code
generators size is deceptive. Generated code can be bloated very
easily.

As I mentioned previously, you are jumping to conclusions that are not
supported by your evidence
 
C

Chad R. Meiners

Jerry Coffin wrote
You clearly don't understand even the simplest logic. Being able to do
all the same things directly implies having similar capabilities.

If we were using that destinction, discussing the differences being
Turing-complete languages would be pretty pointless. That would be the
logical conclusion of what you just said. ;-)
 
H

Hyman Rosen

Martin said:
Disclaimer: Both sources might not be in working order - everytime I switch
compiler (IBM C++ -> MS-C++ -> G++) the code need reworking and the switch
to GNU is not finished yet.

I looked at Ada Array and immediately found errors
(eg., in 'typename TheIndex const First;' the 'typename'
keyword is not permitted). I suggest you try out your
code on Comeau, God's Own C++ Compiler (they ought to
trademark that phrase :) It's available on the web at
<http://www.comeaucomputing.com/tryitout/>.
 
H

Hyman Rosen

Jerry said:
I see. So what is it that (you incorrectly believe) the C preprocessor
can do that a Lisp macro can't do?

Can Lisp macros manipulate the text of the macro arguments?
For example,

#define cat1(a, b) a ## b
#define cat2(a, b) cat1(a, b)

#define A x
#define B y
cat1(A, B) // produces AB
cat2(A, B) // produces xy
 
J

Jerry Coffin

Martin Krischik wrote:

[ ... ]
For marketing people that's the same: Cool is only what makes money -
but that does not make the world a better place, don't it.

I'd say rather the opposite: a large part of the reason capitalism is
so successful is that there really _is_ a fairly strong correlation
between making money and making the world better -- and no need to
point out the multitudes of exceptions -- I'm aware of them, which is
why I said "fairly strong."
 
J

Jerry Coffin

Chad said:
First, this nine slide sales pitch doesn't actually mention any
language other than SCADE.

And so? What part of "it seems likely" don't you understand?
Second, the 70% could have been the
user interface, which communicated with a seperate subsystem that
made up the bulk of the the remaining 30%.

And so? The point is that picking the language for that 70% seems to
take one choice in one list box -- i.e. the most utterly trivial amount
of work possible. With that given, are you honestly suggesting that
it's particularly likely that they'd choose to generate C if they were
planning to write the remainder in Ada?
If a language like
SCADE can't generate 95-99% of the code that it needs for a
project, it isn't a very good formal tool.

I don't recall anybody here having suggested that SCADE is the be-all
and end-all of format tools. OTOH, I have to point out that unless
their claims are flat-out falsehoods, it's been selected by people
you'd expect to be reasonably well-qualified to be used in some
projects that give every appearance of being quite important to those
involved.
30% is an aweful lot
of room to invalidate any assurances that SCADE provided about
the 70%. It would be my educated guess that SCADE was used in
a subsystem which represented about 70% of the total code of
the complete system. Anyway, when you deal with code
generators size is deceptive. Generated code can be bloated very
easily.

As I mentioned previously, you are jumping to conclusions that are not
supported by your evidence

I drew exactly two conclusions: 1) that 100% minus 70% leaves 30%, and
2) that these _seem_ to be sufficiently large projects that 30% of them
still constitutes a substantial amount of code.

Since you claim that my conclusions (plural) are unsupported by the
evidence, and I only drew two conclusions to start with, your claim
must apply to both. So, let's start with the first: please expound on
your form of math in which 100 minus 70 doesn't equal 30.
 
D

Dave Thompson

Is alloca part of the C++ standard? I thought not, but I could be
wrong. Anyway, alloca doesn't really do all that Ada can do in this

No, nor standard C either.
regard (avoiding heap usage for dynamic-sized things). In this case,
the Ada feature is both more efficient and safer than alloca.
Where available, alloca does allocate on the stack. AFAICS this can
do, at a lower/less-safe level, everything Ada can do at function
scope. It can't do allocation _and deallocation_ for a block within a
function, nor cross-function like function-return-unconstrained. It
almost has to be special-cased/inlined so it should be efficient.


- David.Thompson1 at worldnet.att.net
 
P

Paul Mensonides

Hyman said:
Can Lisp macros manipulate the text of the macro arguments?
For example,

#define cat1(a, b) a ## b
#define cat2(a, b) cat1(a, b)

#define A x
#define B y
cat1(A, B) // produces AB
cat2(A, B) // produces xy

Lisp macros cannot produce partial syntax either, whereas C/C++ macros can (e.g.
on macro can create a '{' and another separate invocation can create the closing
'}'). In the general case (obviously) Lisp (and Scheme) macros are far more
powerful than C/C++ macros.

As an aside, given suitable input, it is possible to create a compiler or
interpreter with the C/C++ preprocessor--with a relatively small number of
macros.

Jerry is correct to say that they do similar things--they parametize code with
code. The main differences is that in Lisp (etc.) their are syntactic
constraints (which is both good and bad in various scenarios) and that Lisp
executes in an environment (even when compiled) that can interpret code created
at runtime.

Regards,
Paul Mensonides
 
J

Jerry Coffin

Chad said:
Jerry Coffin wrote

No the slides do not indicate this. For all we know the project that
the slides are talking about has to target hardware for which there
is only a C compiler. It could be that Airbus only uses such tools
on such hardware.

First of all, at least in my dictionary, "indicate" is defined with
words like "points to" and "suggests", NOT "proves" or anything very
similar.

Second, I have to wonder whether you really have a good idea of the
size of project we're talking about. Just for example, Airbus is
currently working on the A350, which is fairly based fairly closely on
the A340, to the point that it's expected to share a common type rating
with the 340 (meaning as far as flying them goes, they're considered
the same plane).

Despite that derivation, the A350 is expected to take about 6 years and
cost (at least) 3,500,000,000 Euros to develop. Developing an entirely
new plane runs in the vicinity of twice that.

This leads to two points: first of all, neither Airbus nor anybody else
is designing hundreds or even dozens of these at a time -- IOW, knowing
what they're doing in only one or two projects really _does_ tell you a
lot about what the company as a whole is doing, and for an extended
period of time at that.

Second, unless porting Ada compilers is a LOT more expensive than
porting C++ compilers, pre-existing availability of a particular
compiler is NOT much of a consideration for this size of project. Just
for the sake of argument, let's assume a compiler port costs a half
million US dollars. If you figure that up in terms of how time spent on
the project, it comes to a matter of hours -- i.e. the compiler port
would only have to save them a couple of hours overall to pay for
itself.

Now, it's certainly true that software alone doesn't account for nearly
all the expenditure -- but it's significant enough to figure in the
same basic terms. The compiler might have to save a whole day to pay
for itself, but almost certainly would not have to save (say) a whole
month to pay off.
Using presentation slides as such an indicator is usually a bad idea.
Presentation slides are made for a specific context, and time frame.
They often lack full and complete information. The slides don't
explicitly support your claim.

I'll openly admit that the slides don't absolutely _prove_ nearly as
much as we'd like to know. They're generally vague, lacking detail,
definition or rigor -- but despite that they still constitute roughly
95% of the hard evidence presented so far in this entire thread!
 
J

Jerry Coffin

Chad said:
Jerry Coffin wrote


If we were using that destinction, discussing the differences being
Turing-complete languages would be pretty pointless. That would be
the logical conclusion of what you just said. ;-)

If I ever teach a class, anybody who tries to abuse Turing completeness
like this will be requird to write his entire treatise on the
blackboard several times as punishment.

Turing's theorem shows, in essence, that a programming language can
implement any algorithm, but that's about it.

If you look at the percentage of a typical program that's devoted
strictly to implementing the fundamental algorithms, you'll quickly
realize that this is FAR from the entire set of capabilities of a real
language.

I should also point out that while C++'s templates are Turing complete,
C's macros are not, so Turing completeness is clearly misplaced as a
consideration here.
 
L

Ludovic Brenta

Dmitry A. Kazakov said:
Ludovic Brentawrites: [...]
package Ada.Exceptions.Extra is
type Extra_Information is abstract tagged null record;

procedure Raise_Exception (E : in Exception_Id;
Information : in Extra_Information'Class);

function Exception_Information (X : Exception_Occurrence)
return Extra_Information'Class;
end Ada.Exceptions.Extra;
[...]

A pair of simple questions:

1. Dispatching to non-existing methods of Extra_Information?

You'd have to "down-cast", which would raise Constraint_Error if the
Extra_Information was not of the expected type.
2. Accessibility rules for members of Extra_Information. Technically
Extra_Information is a sort of result value. As such it requires special
handling of all access values (pointers) it may do to local objects.

I would say that the actual type (that extends Exra_Information) must
be visible in the exception handler and at the point of
Raise_Exception.
3. Extra_Information should probably be controlled, what about
finalization rules?

I hadn't thought about that. For the mechanism to be useful, I
suppose that finalization would have to occur at the end of the
exception handler. However it may not be desirable that
Extra_Information be controlled, as this would make it possible for
Deallocate to raise an exception.
4. Two copies of Extra_Information if the exception was raised in a
rendezvous? Protected type Extra_Information? (protected types are
still untagged)

The Extra_Information doesn't have to be protected, it can contain an
access to a protected object. This would make it quite easy to raise
two copies of it in two tasks.
5. When and where Extra_Information gets deallocated?

I would say, at the end of the last exception handler (i.e. the one
that doesn't reraise the exception).
I think that before making any detailed proposals we should consider a
contract model of exceptions. Points 1..5 might look very different if
there were exception contracts.

What do you have in mind?
 
L

Ludovic Brenta

Georg said:
How about

declare
...
procedure bounce is
begin
set_up_information_to_pass;
end;
begin
raise with bounce'access;
end;

You mean that the "Extra_Information" I was contemplating would be
replaced with an access-to-procedure, and the exception handler would
be free to call the procedure?

Maybe this would address Dmitry's concerns about accessibility and
finalization. The existing accessibility rules are quite clear on
what procedure Bounce can see, and also prevent passing an access to
it to places where Bounce does not exist.

Your proposal is quite interesting.
 
L

Ludovic Brenta

Ioannis said:
Being able to do whatever you want can certainly cause confusion for
anyone who is used to be helped how to program.

However, if you know the language, you know what to do and what to
not do. Also this way is more powerful.

Ah, that same old argument again. I don't know about you; you may be
the Perfect Programmer Who Knows What They're Doing, in which case I
don't know excactly why you are even condescending to read mere
mortals' babbling. As for me, I have been programming in 10 languages
or so for 15 years, and I still appreciate all the help I can get. In
fact, the more experience I get, the more I appreciate it.

But my point was not just about being helped; it was also about the
mathematical purity of the concept of exceptions. If an exception can
be anything at all, then what is so exceptional about it? I'm not
entirely decided on this point (being a mere engineer and not a
mathematician), I'm just uneasy at the thought, and I remember
badly-written programs I've seen before.

Pascal Obry once made an interesting remark: what is important for the
safety of a language is not what it allows but what it forbids.
:) Being able to walk alone can also lead to confusion. Isn't it
better if you walk with assistance?

Ah but *I* am the one assisting people, not to walk but to fly
aircraft. To some extent, they depend on me for their lives, and I
take that seriously. So, yes, as a program maintainer, I appreciate
any and all help, assurance and guarantees I can get.

A C++ program that throws a Window or a Button object or a
Database_Connection object violates the Law of Least Astonishment. If
I read C++ code, I must be prepared to see such things happen, and be
astonished. If I read Ada code, I know that this cannot happen, so I
can move on to more interesting considerations.
No, they do not have to. One can (and in most times does) throw an
exception object on the stack.

Please explain. I am not a compiler writer, and I fail to understand
how the compiler can allocate on the stack, and then propagate the
exception up the stack.
 
I

Ioannis Vranos

Ludovic said:
But my point was not just about being helped; it was also about the
mathematical purity of the concept of exceptions. If an exception can
be anything at all, then what is so exceptional about it?

As a means of error handling.


Pascal Obry once made an interesting remark: what is important for the
safety of a language is not what it allows but what it forbids.


You can't protect a bad programmer from doing bad programming, unless you forbid him to
continue programming. :)

Ah but *I* am the one assisting people, not to walk but to fly
aircraft. To some extent, they depend on me for their lives, and I
take that seriously. So, yes, as a program maintainer, I appreciate
any and all help, assurance and guarantees I can get.


So if you like to be as much constrained as possible, I think VB is much better for this.
Or even Logo. Plus it provides a turtle to help you.

A C++ program that throws a Window or a Button object or a
Database_Connection object violates the Law of Least Astonishment. If
I read C++ code, I must be prepared to see such things happen, and be
astonished.



I have never seen code that throws a button as an exception, although it is feasible to do
that. The language is supposed to provide some protection from accidental mistakes, not
from intentional coding or irrational minds.

Please explain. I am not a compiler writer, and I fail to understand
how the compiler can allocate on the stack, and then propagate the
exception up the stack.


#include <iostream>


class SomeException: public std::exception
{
const char *errorMessage;

public:
SomeException(const char *error):errorMessage(error) {}

const char *what( ) const throw()
{
return errorMessage;
}
};


int main() try
{
throw SomeException("Something is wrong!");
}


catch(std::exception &e)
{
std::cerr<<e.what()<<"\n";
}


C:\c>temp
Something is wrong!

C:\c>



The exception gets copied as it is propagated up to the stack (with the use of the copy
constructor). I am not a compiler writer either.


--
Ioannis Vranos

http://www23.brinkster.com/noicys

[I am using 90 characters word-wrapping - (800/640) *72= 90 or better described as:
(800/640) *80 - 10 for quotation= 90. If someone finds it inconvenient, please let me know].
 
L

Ludovic Brenta

Ioannis said:
So if you like to be as much constrained as possible, I think VB is
much better for this. Or even Logo. Plus it provides a turtle to
help you.

Ah yes, embedded, real-time, certified Logo :) Come on.
#include <iostream>


class SomeException: public std::exception
{
const char *errorMessage;

public:
SomeException(const char *error):errorMessage(error) {}

const char *what( ) const throw()
{
return errorMessage;
}
};


int main() try

^
Isn't there a missing { here?
{
throw SomeException("Something is wrong!");
}


catch(std::exception &e)
{
std::cerr<<e.what()<<"\n";
}

And a missing } here? In which case I don't see any propagation of
your exception up the stack, as there is only one stack frame.
C:\c>temp
Something is wrong!

C:\c>



The exception gets copied as it is propagated up to the stack (with
the use of the copy constructor). I am not a compiler writer either.

Since you don't provide a copy constructor, only a shallow copy takes
place. Where is the message string allocated, and how do you know it
is still accessible when you catch the exception in a location remote
from the throw statement?

Also, copying the exception once for each stack frame seems quite
inefficient to me. I doubt that compiler writers would do that,
especially in the general case of C++ where the exception object can
be arbitrarily large.
 

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

No members online now.

Forum statistics

Threads
474,202
Messages
2,571,057
Members
47,663
Latest member
josh5959

Latest Threads

Top