comp.lang.ada
 help / color / mirror / Atom feed
* example of machine generated Ada ?
@ 2013-10-02 17:37 Patrick
  2013-10-03  5:10 ` Robert Love
                   ` (5 more replies)
  0 siblings, 6 replies; 11+ messages in thread
From: Patrick @ 2013-10-02 17:37 UTC (permalink / raw)


Hi Everyone

I am just daydreaming about generating Ada from another language.

Several languages use C as an intermediate language but hand written C is hard to read and machine generated is even more painful. Ada might make for reliable, readable machine generated code.

Thanks-Patrick


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: example of machine generated Ada ?
  2013-10-02 17:37 example of machine generated Ada ? Patrick
@ 2013-10-03  5:10 ` Robert Love
  2013-10-03  6:14   ` Niklas Holsti
  2013-10-03  5:40 ` Simon Wright
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 11+ messages in thread
From: Robert Love @ 2013-10-03  5:10 UTC (permalink / raw)


On 2013-10-02 17:37:04 +0000, Patrick said:

> Hi Everyone
> 
> I am just daydreaming about generating Ada from another language.
> 
> Several languages use C as an intermediate language but hand written C 
> is hard to read and machine generated is even more painful. Ada might 
> make for reliable, readable machine generated code.
> 
> Thanks-Patrick

There was a product in the 90s called Matrixx, it let you draw flow 
charts and type in algorithms and drag connections between components 
your created graphically.  You pushed the button and out popped some of 
the ugliest Ada you can imagine.  My point is you can have code 
generators but there is no guarantee of the quality, readablity or 
maintainablity.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: example of machine generated Ada ?
  2013-10-02 17:37 example of machine generated Ada ? Patrick
  2013-10-03  5:10 ` Robert Love
@ 2013-10-03  5:40 ` Simon Wright
  2013-10-05  2:49   ` Randy Brukardt
  2013-10-03  9:01 ` gautier_niouzes
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 11+ messages in thread
From: Simon Wright @ 2013-10-03  5:40 UTC (permalink / raw)


Patrick <patrick@spellingbeewinnars.org> writes:

> I am just daydreaming about generating Ada from another language.
>
> Several languages use C as an intermediate language but hand written C
> is hard to read and machine generated is even more painful. Ada might
> make for reliable, readable machine generated code.

It depends on the aims of the person/organisation that develops the code
generator. My aims in ColdFrame[1], which amongst other things generates
package specs that users might need to look at, included that the
generated code should look as if it had been written by a human - and
should compile without warnings, especially style warnings. I see that I
actually suppress style warnings, but as I recall this was only because
users insisted on using very long names and in consequence I couldn't
avoid long lines. Perhaps I should revisit this now that GNAT allows
finer control? - no, it only allows you to switch particular style
checks off for specific entities, the non-specific form only allows
adding checks.

[1] https://sourceforge.net/projects/coldframe/


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: example of machine generated Ada ?
  2013-10-03  5:10 ` Robert Love
@ 2013-10-03  6:14   ` Niklas Holsti
  2013-10-05 15:46     ` Martin
  0 siblings, 1 reply; 11+ messages in thread
From: Niklas Holsti @ 2013-10-03  6:14 UTC (permalink / raw)


On 13-10-03 07:10 , Robert Love wrote:
> On 2013-10-02 17:37:04 +0000, Patrick said:
> 
>> Hi Everyone
>>
>> I am just daydreaming about generating Ada from another language.
>>
>> Several languages use C as an intermediate language but hand written C
>> is hard to read and machine generated is even more painful. Ada might
>> make for reliable, readable machine generated code.
>>
>> Thanks-Patrick
> 
> There was a product in the 90s called Matrixx, it let you draw flow
> charts and type in algorithms and drag connections between components
> your created graphically.  You pushed the button and out popped some of
> the ugliest Ada you can imagine.  My point is you can have code
> generators but there is no guarantee of the quality, readablity or
> maintainablity.

If I remember correctly, the motivation for including a goto statement
in Ada was that automatic code generators might need it. This perhaps
shows what kind of code was expected from such generators...

-- 
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
      .      @       .


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: example of machine generated Ada ?
  2013-10-02 17:37 example of machine generated Ada ? Patrick
  2013-10-03  5:10 ` Robert Love
  2013-10-03  5:40 ` Simon Wright
@ 2013-10-03  9:01 ` gautier_niouzes
  2013-10-03 11:38 ` Marius Amado-Alves
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: gautier_niouzes @ 2013-10-03  9:01 UTC (permalink / raw)


Actually, as you guess, you get plenty of advantages for free with machine-generated code: strong typing, type safety of enumerated types, data completeness etc.
You can generate from various sources.
In my hobby projects on Sourceforge, I have code generators from VRML, Doom 3 universes, Windows resources for instance.
Professionally I have moved many "invariant" data from databases into Ada sources.
The perfoermance and maintability gains are tremendous.
G.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: example of machine generated Ada ?
  2013-10-02 17:37 example of machine generated Ada ? Patrick
                   ` (2 preceding siblings ...)
  2013-10-03  9:01 ` gautier_niouzes
@ 2013-10-03 11:38 ` Marius Amado-Alves
  2013-10-03 13:12 ` Patrick
  2015-01-09 21:33 ` Paul Rubin
  5 siblings, 0 replies; 11+ messages in thread
From: Marius Amado-Alves @ 2013-10-03 11:38 UTC (permalink / raw)


Example generator that creates a (readable) thin binding to a C library:

http://sourceforge.net/p/aquaterm/git/ci/master/tree/adapters/ada/dump_c_interface.adb

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: example of machine generated Ada ?
  2013-10-02 17:37 example of machine generated Ada ? Patrick
                   ` (3 preceding siblings ...)
  2013-10-03 11:38 ` Marius Amado-Alves
@ 2013-10-03 13:12 ` Patrick
  2015-01-09 21:33 ` Paul Rubin
  5 siblings, 0 replies; 11+ messages in thread
From: Patrick @ 2013-10-03 13:12 UTC (permalink / raw)


Thanks everyone

I just wanted to add that Ada is so feature rich that there are likely few constructs in other languages that cannot be mapped to it. Furthermore it is high performance and the emitted code could be tied in with hand written code later


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: example of machine generated Ada ?
  2013-10-03  5:40 ` Simon Wright
@ 2013-10-05  2:49   ` Randy Brukardt
  2013-10-05  7:22     ` Simon Wright
  0 siblings, 1 reply; 11+ messages in thread
From: Randy Brukardt @ 2013-10-05  2:49 UTC (permalink / raw)


"Simon Wright" <simon@pushface.org> wrote in message 
news:lyr4c2ud2k.fsf@pushface.org...
> Patrick <patrick@spellingbeewinnars.org> writes:
>
>> I am just daydreaming about generating Ada from another language.
>>
>> Several languages use C as an intermediate language but hand written C
>> is hard to read and machine generated is even more painful. Ada might
>> make for reliable, readable machine generated code.
>
> It depends on the aims of the person/organisation that develops the code
> generator. My aims in ColdFrame[1], which amongst other things generates
> package specs that users might need to look at, included that the
> generated code should look as if it had been written by a human - and
> should compile without warnings, especially style warnings. I see that I
> actually suppress style warnings, but as I recall this was only because
> users insisted on using very long names and in consequence I couldn't
> avoid long lines. Perhaps I should revisit this now that GNAT allows
> finer control? - no, it only allows you to switch particular style
> checks off for specific entities, the non-specific form only allows
> adding checks.
>
> [1] https://sourceforge.net/projects/coldframe/

The Claw GUI builder had similar goals for the generated code. It looks 
pretty similar to the code I would have written by hand (partially because 
that's how it came to be, I wrote the generator to write code similar to the 
known working examples). 
http://www.rrsoftware.com/html/prodinf/claw/claw.htm

OTOH, if you have an abstraction inversion (say, taking compiler 
intermediate code and turning it into Ada), you're probably not going to get 
very understandable Ada. So it obviously depends on the generator and the 
goals.

                              Randy.




^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: example of machine generated Ada ?
  2013-10-05  2:49   ` Randy Brukardt
@ 2013-10-05  7:22     ` Simon Wright
  0 siblings, 0 replies; 11+ messages in thread
From: Simon Wright @ 2013-10-05  7:22 UTC (permalink / raw)


"Randy Brukardt" <randy@rrsoftware.com> writes:

> It looks pretty similar to the code I would have written by hand
> (partially because that's how it came to be, I wrote the generator to
> write code similar to the known working examples).

My process too!


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: example of machine generated Ada ?
  2013-10-03  6:14   ` Niklas Holsti
@ 2013-10-05 15:46     ` Martin
  0 siblings, 0 replies; 11+ messages in thread
From: Martin @ 2013-10-05 15:46 UTC (permalink / raw)


On Thursday, October 3, 2013 7:14:33 AM UTC+1, Niklas Holsti wrote:
> On 13-10-03 07:10 , Robert Love wrote:
> 
> > On 2013-10-02 17:37:04 +0000, Patrick said:
> 
> > 
> 
> >> Hi Everyone
> 
> >>
> 
> >> I am just daydreaming about generating Ada from another language.
> 
> >>
> 
> >> Several languages use C as an intermediate language but hand written C
> 
> >> is hard to read and machine generated is even more painful. Ada might
> 
> >> make for reliable, readable machine generated code.
> 
> >>
> 
> >> Thanks-Patrick
> 
> > 
> 
> > There was a product in the 90s called Matrixx, it let you draw flow
> 
> > charts and type in algorithms and drag connections between components
> 
> > your created graphically.  You pushed the button and out popped some of
> 
> > the ugliest Ada you can imagine.  My point is you can have code
> 
> > generators but there is no guarantee of the quality, readablity or
> 
> > maintainablity.
> 
> 
> 
> If I remember correctly, the motivation for including a goto statement
> 
> in Ada was that automatic code generators might need it. This perhaps
> 
> shows what kind of code was expected from such generators...


GOTOs in auto-generated code are not usual...in the late 80's Jackson Structured Programming (JSP) diagrams -> COBOL often used GOTOs...but that was fine...it allowed implementation of the "Backtracking" technique in the JSP method and also, "who cares" what the auto-generated code looks like - you're supposed to be only looking at the diagrams.

It's the same reason we don't care about the 'gotos' in the assembler from your-favourite-Ada-compiler :-)

-- Martin

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: example of machine generated Ada ?
  2013-10-02 17:37 example of machine generated Ada ? Patrick
                   ` (4 preceding siblings ...)
  2013-10-03 13:12 ` Patrick
@ 2015-01-09 21:33 ` Paul Rubin
  5 siblings, 0 replies; 11+ messages in thread
From: Paul Rubin @ 2015-01-09 21:33 UTC (permalink / raw)


Patrick <patrick@spellingbeewinnars.org> writes:
> Several languages use C as an intermediate language but hand written C
> is hard to read and machine generated is even more painful. Ada might
> make for reliable, readable machine generated code.

Pardon the response to a >1 year old post but ImProve can do this:

    https://github.com/tomahawkins/improve

Blurb from page:

    ImProve is an imperative programming language embedded in Haskell
    for high assurance applications. ImProve uses infinite state,
    unbounded model checking to verify programs adhere to
    specifications. Yices (required) is the backend SMT solver.

    ImProve compiles to C, Ada, Simulink, and Modelica for
    implementation and system simulation.

I've played with it a little bit and also with the author's other
language, Atom.

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2015-01-09 21:33 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-02 17:37 example of machine generated Ada ? Patrick
2013-10-03  5:10 ` Robert Love
2013-10-03  6:14   ` Niklas Holsti
2013-10-05 15:46     ` Martin
2013-10-03  5:40 ` Simon Wright
2013-10-05  2:49   ` Randy Brukardt
2013-10-05  7:22     ` Simon Wright
2013-10-03  9:01 ` gautier_niouzes
2013-10-03 11:38 ` Marius Amado-Alves
2013-10-03 13:12 ` Patrick
2015-01-09 21:33 ` Paul Rubin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox