comp.lang.ada
 help / color / mirror / Atom feed
* A couple of quick questions
@ 2012-12-28 15:02 Dufr
  2012-12-28 15:43 ` Thomas Løcke
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Dufr @ 2012-12-28 15:02 UTC (permalink / raw)


Hello, I am considering learning Ada, but first I need to know a couple of things:

1) Is comp.lang.ada the only online resource that can provide support to Ada learners? Any other resources such as forums, mailing lists, etc.?

2) do the available Ada libraries include all the modern tools which are a given in most languages (e.g. networking, graphics, audio, database, etc)? Any weak area in this regard?

Thanks 

Dufriz T.



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

* Re: A couple of quick questions
  2012-12-28 15:02 A couple of quick questions Dufr
@ 2012-12-28 15:43 ` Thomas Løcke
  2012-12-28 16:46 ` Georg Bauhaus
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 12+ messages in thread
From: Thomas Løcke @ 2012-12-28 15:43 UTC (permalink / raw)


On 12/28/2012 04:02 PM, Dufr wrote:
> Hello, I am considering learning Ada, but first I need to know a couple of things:
>
> 1) Is comp.lang.ada the only online resource that can provide support to Ada learners? Any other resources such as forums, mailing lists, etc.?


comp.lang.ada is a very good place to get help, but it is not the only
place where Ada'ists hang out. Other valuable places include:

1. The Ada reddit http://www.reddit.com/r/ada/
2. The G+ Ada community http://goo.gl/I347U
3. The freenode #ada IRC channel
4. The Ada wikibook http://en.wikibooks.org/wiki/Ada_Programming
5. Ada@rosettacode.org http://rosettacode.org/wiki/Category:Ada
6. The Ada-DK resources page http://wiki.ada-dk.org/ada_resources
7. Ada@stackoverflow.com http://stackoverflow.com/questions/tagged/ada

Those are some good places to start.

Enjoy! :o)

-- 
Thomas L�cke | thomas@12boo.net | http://12boo.net



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

* Re: A couple of quick questions
  2012-12-28 15:02 A couple of quick questions Dufr
  2012-12-28 15:43 ` Thomas Løcke
@ 2012-12-28 16:46 ` Georg Bauhaus
  2012-12-28 20:28 ` Dufr
  2012-12-31  8:56 ` Paul Colin Gloster
  3 siblings, 0 replies; 12+ messages in thread
From: Georg Bauhaus @ 2012-12-28 16:46 UTC (permalink / raw)


On 28.12.12 16:02, Dufr wrote:
> 2) do the available Ada libraries include all the modern tools which are a given in most languages (e.g. networking, graphics, audio, database, etc)? Any weak area in this regard


There are a few things to note, from which the answer follows.

Most of the modern _languages_ have none of the above mentioned
software facilities built in. They do allow easy linking with
function libraries, or with type libraries, that allow
programming networks, graphics, audio, database etc.

Ada programs can link with the same libraries, too.
Or with whatever is made available by the operating system
(as opposed to made available by the language).

(For example, C++, the language, does not have a single database
operator, but there are a number of ways to obtain access to a
database from a C++ program. The C# language has some built-in
support for a few database operations, named LINQ. But LINQ is
no help with almost any modern mobile devices; for proof, have your
favorite search engine find "LINQ" and "Android", or "LINQ" and
"iOS".)

There are, in any case, Ada centric solutions, for example, a
complete web server written in Ada, for use in Ada programs.

There are several ways an Ada program can talk to a database,
for example, via ODBC, or using embedded SQL.

Also, does Google Groups have an option to insert line breaks
into paragraphs? A source text oriented forum such as this, or
comp.lang.*, will profit greatly from lines, like source text
usually does.




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

* Re: A couple of quick questions
  2012-12-28 15:02 A couple of quick questions Dufr
  2012-12-28 15:43 ` Thomas Løcke
  2012-12-28 16:46 ` Georg Bauhaus
@ 2012-12-28 20:28 ` Dufr
  2012-12-28 23:27   ` Georg Bauhaus
                     ` (2 more replies)
  2012-12-31  8:56 ` Paul Colin Gloster
  3 siblings, 3 replies; 12+ messages in thread
From: Dufr @ 2012-12-28 20:28 UTC (permalink / raw)


One more question about Ada, if you don't mind. Ada has a reputation for being "bloated" and have having too many features. Frankly, I don't care about using only 10% of a language's features - I will simply ignore the features that I do not use. But I am concerned about performance. Is the efficiency of the compiled code by penalized in any way by the putative bloat of the language? 
Also, could you please provide some examples about the size of the executables (source / compiled sizes)?

Cheers

Dufriz



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

* Re: A couple of quick questions
  2012-12-28 20:28 ` Dufr
@ 2012-12-28 23:27   ` Georg Bauhaus
  2012-12-28 23:36     ` Georg Bauhaus
  2012-12-29  0:41   ` Yannick Duchêne (Hibou57)
  2012-12-29 10:47   ` Florian Weimer
  2 siblings, 1 reply; 12+ messages in thread
From: Georg Bauhaus @ 2012-12-28 23:27 UTC (permalink / raw)


On 28.12.12 21:28, Dufr wrote:
> Is the efficiency of the compiled code by penalized in any way by the putative bloat of the language?

No, usually, the language's features do not adversely affect
performance. This might be expected from a language that was required
to be suitable for hard real-time processing (hence cannot require
huge amounts of memory or processing power). One might instead
argue that its features contribute information useful to
optimizing compilers. (C's restrict keyword was added to C to
allow programmers to provide such information. OTOH, note that
Ada has always required that aliased objects be declared aliased.)

One noteworthy exception is overflow checking for arithmetical
operations. Its absence from C programs is a typical cause of
vulnerabilities every other week, which see. But these checks
are expensive and could therefore be turned on for sections of
an Ada program as needed. (I should hope they do that.)

For an example of a program that uses many of Ada's features,
yet is really fast (possibly because it does!), see
http://benchmarksgame.alioth.debian.org/u64q/performance.php?test=chameneosredux

IIRC the wikibook on Ada Programming has examples of executable file
sizes in typical Unix installations; they are about the same as file
sizes of C programs. Size is a consequence of linking libraries, or
linking a small or large run-time system.

Object code size is typically the same as for other languages in
case optimization is turned on, and even when some checks are on.

Here is an example to demonstrate the effect. The same program is
written in C, and in Ada, compiled by the same GCC, using the same
switches (note that only default checks are on for the Ada program):

$ gcc -c -O2 adaex.adb
$ gnatchop -r -w adaex.ada && gcc -c -O2 adaex.adb

The assembly listings are appended to the source text, to show
the extent of difference, if any.


#include <stdint.h>

typedef int16_t num;

num Cex(num a, const num b, const num eps)
{
   num result = b - a;
    
   while (result > eps) {
     a += result / 2;
     result = b - a;
   }
   return result;
}


package Adaex is
    
    type Num is range -(2**15) .. +(2**15)-1;
    
    function Ex(A, B : Num; Eps: Num) return Num;
    
end Adaex;

package body Adaex is
    
    function Ex(A, B : Num; Eps: Num) return Num is
       Copy : Num := A;
       Result : Num := B - A;
    begin
       while Result > Eps loop
          Copy := Copy + Result / 2;
          Result := B - Copy;
       end loop;
       return Result;
    end Ex;
    
end Adaex;


$ otool -tv cex.o
cex.o:
(__TEXT,__text) section
_Cex:
0000000000000000	movl	%esi,%eax
0000000000000002	movl	%edi,%ecx
0000000000000004	movl	%edx,%r9d
0000000000000007	subl	%edi,%eax
0000000000000009	movl	%esi,%r8d
000000000000000c	cmpw	%dx,%ax
000000000000000f	jle	0x00000038
0000000000000011	nopl	0x00000000(%rax)
0000000000000018	nopl	0x00000000(%rax,%rax)
0000000000000020	movl	%eax,%edx
0000000000000022	shrw	$0x0f,%dx
0000000000000026	addl	%edx,%eax
0000000000000028	sarw	%ax
000000000000002b	addl	%eax,%ecx
000000000000002d	movl	%r8d,%eax
0000000000000030	subl	%ecx,%eax
0000000000000032	cmpw	%eax,%r9d
0000000000000036	jl	0x00000020
0000000000000038	repz/ret
$ otool -tv adaex.o
adaex.o:
(__TEXT,__text) section
_adaex__ex:
0000000000000000	movl	%esi,%eax
0000000000000002	movl	%esi,%ecx
0000000000000004	movl	%edx,%r8d
0000000000000007	subl	%edi,%eax
0000000000000009	cmpw	%dx,%ax
000000000000000c	jle	0x00000027
000000000000000e	nop
0000000000000010	movl	%eax,%edx
0000000000000012	shrw	$0x0f,%dx
0000000000000016	addl	%edx,%eax
0000000000000018	sarw	%ax
000000000000001b	addl	%eax,%edi
000000000000001d	movl	%ecx,%eax
000000000000001f	subl	%edi,%eax
0000000000000021	cmpw	%eax,%r8d
0000000000000025	jl	0x00000010
0000000000000027	ret
$





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

* Re: A couple of quick questions
  2012-12-28 23:27   ` Georg Bauhaus
@ 2012-12-28 23:36     ` Georg Bauhaus
  0 siblings, 0 replies; 12+ messages in thread
From: Georg Bauhaus @ 2012-12-28 23:36 UTC (permalink / raw)


On 29.12.12 00:27, Georg Bauhaus wrote:
> $ gcc -c -O2 adaex.adb
$ gcc -c -W -O2  cex.c
> $ gnatchop -r -w adaex.ada && gcc -c -O2 adaex.adb

c&p mistake, sorry.




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

* Re: A couple of quick questions
  2012-12-28 20:28 ` Dufr
  2012-12-28 23:27   ` Georg Bauhaus
@ 2012-12-29  0:41   ` Yannick Duchêne (Hibou57)
  2012-12-29 10:47   ` Florian Weimer
  2 siblings, 0 replies; 12+ messages in thread
From: Yannick Duchêne (Hibou57) @ 2012-12-29  0:41 UTC (permalink / raw)


Le Fri, 28 Dec 2012 21:28:31 +0100, Dufr <dufriz@gmail.com> a écrit:

> One more question about Ada, if you don't mind. Ada has a reputation for  
> being "bloated" and have having too many features.

You may think of “Ada, a complex language for a complex world”. It comes  
with no more complexity than the real world has, and its “complexity” maps  
this only. That's not bloat, that's filling expectations.

A bloat is something unnecessary. Some things was made language‑native  
instead of library‑dependent (ex. tasking), and some of the  
language‑native things can hardly be provided by a library (ex. numeric  
ranges).

Bloats may also be seen when there are unnecessary multiple ways of doing  
one thing, and I don't believe Ada has too much of this (just a few).

By the way, bloats are more often encountered in libraries and  
applications than in languages (many of them claimed to be general  
purpose, suffering from over‑simplification, on the contrary).


-- 
“Syntactic sugar causes cancer of the semi-colons.” [1]
“Structured Programming supports the law of the excluded muddle.” [1]
[1]: Epigrams on Programming — Alan J. — P. Yale University



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

* Re: A couple of quick questions
  2012-12-28 20:28 ` Dufr
  2012-12-28 23:27   ` Georg Bauhaus
  2012-12-29  0:41   ` Yannick Duchêne (Hibou57)
@ 2012-12-29 10:47   ` Florian Weimer
  2012-12-29 16:15     ` Shark8
  2 siblings, 1 reply; 12+ messages in thread
From: Florian Weimer @ 2012-12-29 10:47 UTC (permalink / raw)


* Dufr:

> Is the efficiency of the compiled code by penalized in any way by
> the putative bloat of the language?

Yes, for some features.  Exception handling tables increase the size
of the program even if they are not used because no exceptions are
thrown.  Run-time checks (such as overflow checks and array bounds
checks) are typically bloat which increases instruction cache pressure
and decreases effective execution speed.  Code for abort deferral is
automatically inserted by the compiler and slows down the program,
even if no asynchronous transfer of control ever occurs.

Proper compiler flags can eliminate these overheads, in some cases
without any ill effects or observable differences in behavior (not so
for array bounds checks, obviously).



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

* Re: A couple of quick questions
  2012-12-29 10:47   ` Florian Weimer
@ 2012-12-29 16:15     ` Shark8
  2012-12-29 16:32       ` Bill Findlay
  2012-12-29 17:21       ` Florian Weimer
  0 siblings, 2 replies; 12+ messages in thread
From: Shark8 @ 2012-12-29 16:15 UTC (permalink / raw)


On Saturday, December 29, 2012 4:47:44 AM UTC-6, Florian Weimer wrote:
> * Dufr:
> 
> > Is the efficiency of the compiled code by penalized in any way by
> > the putative bloat of the language?
> 
> [...] Run-time checks (such as overflow checks and array bounds
> checks) are typically bloat which increases instruction cache pressure
> and decreases effective execution speed.

But you're doing Ada a bit of a disservice here: Ada compilers are typically smart enough to omit range-checks where the value can be guaranteed as valid, such as "FOR Index IN Array'Range Loop [...]", no check is needed because the type  of Index guarantees that it is valid.

> Code for abort deferral is
> automatically inserted by the compiler and slows down the program,
> even if no asynchronous transfer of control ever occurs.

Isn't this only an issue ONLY when the TASK (or possibly PROTECTED object) construct is used?
It seems rather contrary to optimization (which Ada compilers, in theory, can do more  effectively than, say, C++ or PHP) techniques.



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

* Re: A couple of quick questions
  2012-12-29 16:15     ` Shark8
@ 2012-12-29 16:32       ` Bill Findlay
  2012-12-29 17:21       ` Florian Weimer
  1 sibling, 0 replies; 12+ messages in thread
From: Bill Findlay @ 2012-12-29 16:32 UTC (permalink / raw)


On 29/12/2012 16:15, in article
ea507393-d4ff-4451-b1e8-4d055da9b794@googlegroups.com, "Shark8"
<onewingedshark@gmail.com> wrote:

> On Saturday, December 29, 2012 4:47:44 AM UTC-6, Florian Weimer wrote:
>> * Dufr:
>> 
>>> Is the efficiency of the compiled code by penalized in any way by
>>> the putative bloat of the language?
>> 
>> [...] Run-time checks (such as overflow checks and array bounds
>> checks) are typically bloat which increases instruction cache pressure
>> and decreases effective execution speed.
> 
> But you're doing Ada a bit of a disservice here: Ada compilers are typically
> smart enough to omit range-checks where the value can be guaranteed as valid,
> such as "FOR Index IN Array'Range Loop [...]", no check is needed because the
> type  of Index guarantees that it is valid.

Indeed.

Should the checking "overhead" be prohibitive in special cases, a selection
of particular checks can be suppressed over well-defined scopes.  However,
the real cost is often surprisingly small.

Here is some actual data, rather than speculation.
 
My KDF9 emulator is about 20KSLOC.  Compiled with all runtime checking
disabled, it runs 1.25% faster than when compiled with default checking.
That is 1.25 PERCENT faster, not 1.25 TIMES. 8-)
  
Interestingly, if I do not suppress absolutely all checks, but enable them
for "non-inner loop" modules, it runs a further 1.25% faster than when
completely unchecked.  More checks, but faster execution!

Another program of mine, an assembler of about 10KSLOC, runs about 1% faster
with default checking than it does with checking completely suppressed!

Such are the vagaries of performance with modern CPUs.  So for some
programs, at least, the overhead due to runtime checking is down at the
measurement noise level.

>> Code for abort deferral is
>> automatically inserted by the compiler and slows down the program,
>> even if no asynchronous transfer of control ever occurs.

Then use:

   pragma Restrictions(No_Abort_Statements);

-- 
Bill Findlay
with blueyonder.co.uk;
use  surname & forename;




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

* Re: A couple of quick questions
  2012-12-29 16:15     ` Shark8
  2012-12-29 16:32       ` Bill Findlay
@ 2012-12-29 17:21       ` Florian Weimer
  1 sibling, 0 replies; 12+ messages in thread
From: Florian Weimer @ 2012-12-29 17:21 UTC (permalink / raw)


* Shark8:

>> Code for abort deferral is automatically inserted by the compiler
>> and slows down the program, even if no asynchronous transfer of
>> control ever occurs.
>
> Isn't this only an issue ONLY when the TASK (or possibly PROTECTED
> object) construct is used?

When the code is compiled, the compiler does not know if the it will
eventually be linked into a process which uses asynchronous transfer
of control.  So the calls into the run-time library are still there,
but they do nothing.



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

* Re: A couple of quick questions
  2012-12-28 15:02 A couple of quick questions Dufr
                   ` (2 preceding siblings ...)
  2012-12-28 20:28 ` Dufr
@ 2012-12-31  8:56 ` Paul Colin Gloster
  3 siblings, 0 replies; 12+ messages in thread
From: Paul Colin Gloster @ 2012-12-31  8:56 UTC (permalink / raw)


On 2012-12-28, Dufr <Dufriz@GMail.com> sent:
|---------------------------------------------------------------------|
|"Hello, I am considering learning Ada,"                              |
|---------------------------------------------------------------------|

Good.

|---------------------------------------------------------------------|
|" but first I need to know a                                         |
|couple of things:                                                    |
|                                                                     |
|1) Is comp.lang.ada the only online resource that can provide support|
|to Ada learners? Any other resources such as forums, mailing lists,  |
|etc.?"                                                               |
|---------------------------------------------------------------------|

HTTP://Web.Archive.org/web/20060924084002/http://www.ijs.co.nz/ada_95.htm

|---------------------------------------------------------------------|
|"2) do the available Ada libraries include all the modern tools which|
|are a given in most languages (e.g. networking, graphics, audio,     |
|database, etc)? [. . .]                                              |
|                                                                     |
|Thanks                                                               |
|                                                                     |
|Dufriz T."                                                           |
|---------------------------------------------------------------------|

No.



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

end of thread, other threads:[~2012-12-31  8:56 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-28 15:02 A couple of quick questions Dufr
2012-12-28 15:43 ` Thomas Løcke
2012-12-28 16:46 ` Georg Bauhaus
2012-12-28 20:28 ` Dufr
2012-12-28 23:27   ` Georg Bauhaus
2012-12-28 23:36     ` Georg Bauhaus
2012-12-29  0:41   ` Yannick Duchêne (Hibou57)
2012-12-29 10:47   ` Florian Weimer
2012-12-29 16:15     ` Shark8
2012-12-29 16:32       ` Bill Findlay
2012-12-29 17:21       ` Florian Weimer
2012-12-31  8:56 ` Paul Colin Gloster

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