comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeffrey R. Carter" <spam.jrcarter.not@spam.not.acm.org>
Subject: Re: Introductory Presentations, especially aimed at C++ programmers!
Date: Wed, 14 Dec 2016 17:00:49 -0700
Date: 2016-12-14T17:00:49-07:00	[thread overview]
Message-ID: <o2smd1$id0$1@dont-email.me> (raw)
In-Reply-To: <o2si7u$ld6$1@franka.jacob-sparre.dk>

On 12/14/2016 03:48 PM, Randy Brukardt wrote:
> "Jeffrey R. Carter" <spam.jrcarter.not@spam.not.acm.org> wrote in message
> news:o2q2o6$c16$1@dont-email.me...
>>
>> The difference is that, for every recursive call, the GNAT version
>> declares 2 buffers, and mine only declares 1.
>
> ...and generates a second one implicitly. Still no difference. The semantics
> of & require a copy, it can't be optimized out (with the possible exception
> of a direct assignment to something).

Maybe. I'm not a compiler writer, and I understand that GNAT's version may have 
been written with a deep understanding of what the GNAT compiler will do with 
the code. But from a general point of view, I take the view that the compiler 
can do a better job of optimization than I can, so letting it do an implicit 2nd 
declaration is the way to go.

Also

return Line & Get_Line;

is tail recursion; IIUC, Erlang compilers are required to optimize tail 
recursion away, so such an optimization must be reasonably easy to implement. 
Maybe an Ada compiler does it, too. Again, I'd rather give the compiler the 
ability to do that optimization.

>> ... Worrying about the efficiency of very rare situations, given the
>> general
>> inefficiency of Text_IO anyway, seems like a waste of time.
>
> Customers would disagree with you. I once had to refund a customer because
> they complained about the efficiency of our Text_IO vs. that of the similar
> C functions. I spent several weeks redoing Text_IO in part because of that
> experience (mostly so the performance of Get_Line from files is better).
>
> It's very usual that a new customer will write a trial program with their
> shiny new compiler that just reads some text file with Get_Line. Us old Ada
> hands know better than to expect great performance from that, but one does
> not want someone's first impression of Ada to be bad. Thus the performance
> of Get_Line is one of those things that has to be optimized absolutely as
> much as possible. (One cannot get into arguments of premature optimization
> if they are returning their compiler and switching to some other
> language!!!)

I suspect your customer was looking for an excuse not to use Ada. There's no way 
Text_IO can be as efficient as C equivalents. I'm not aware of a C equivalent of 
the Get_Line function. Anyway, since Janus/Ada is an Ada-95 compiler, you're 
talking about a different Get_Line.

-- 
Jeff Carter
"I was in love with a beautiful blonde once, dear.
She drove me to drink. That's the one thing I'm
indebted to her for."
Never Give a Sucker an Even Break
109


  reply	other threads:[~2016-12-15  0:00 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-10 12:24 Introductory Presentations, especially aimed at C++ programmers! John McCabe
2009-07-10 21:49 ` jimmaureenrogers
2009-07-10 23:37   ` wwilson
2009-07-11  0:07     ` jimmaureenrogers
2009-07-12  4:00       ` wwilson
2009-07-11  8:15 ` Stephen Leake
2009-07-15  6:43 ` Jean-Pierre Rosen
2016-12-07 17:06 ` john
2016-12-07 17:44   ` Luke A. Guest
2016-12-07 18:35     ` Jeffrey R. Carter
2016-12-07 23:03       ` Randy Brukardt
2016-12-07 23:47         ` Jeffrey R. Carter
2016-12-08  0:08           ` Paul Rubin
2016-12-09 22:01             ` Randy Brukardt
2016-12-09 22:18               ` Jeffrey R. Carter
2016-12-13  0:53                 ` Randy Brukardt
2016-12-13  3:21                   ` Jeffrey R. Carter
2016-12-13 21:15                     ` Robert A Duff
2016-12-13 22:05                       ` Jeffrey R. Carter
2016-12-13 22:52                         ` Robert A Duff
2016-12-14  0:02                           ` Jeffrey R. Carter
2016-12-13 23:05                         ` Randy Brukardt
2016-12-14  0:13                           ` Jeffrey R. Carter
2016-12-14 22:48                             ` Randy Brukardt
2016-12-15  0:00                               ` Jeffrey R. Carter [this message]
2016-12-15 10:46                                 ` Maciej Sobczak
2016-12-16  7:37                                   ` Paul Rubin
2016-12-15 20:14                                 ` Niklas Holsti
2016-12-15 20:27                                   ` Jeffrey R. Carter
2016-12-15 21:04                                     ` Niklas Holsti
2016-12-15 21:40                                       ` Jeffrey R. Carter
2016-12-16  7:41                                     ` Paul Rubin
2016-12-13 22:50                     ` Randy Brukardt
2016-12-14  0:08                       ` Jeffrey R. Carter
2016-12-14  1:01                         ` Shark8
2016-12-08  8:08           ` Maciej Sobczak
2016-12-08  8:38             ` Dmitry A. Kazakov
2016-12-08 10:25             ` Paul Rubin
2016-12-08 13:39               ` Maciej Sobczak
2016-12-09  1:30                 ` Paul Rubin
2016-12-09  8:31                   ` J-P. Rosen
2016-12-09  8:58                     ` Paul Rubin
2016-12-09  9:18                       ` J-P. Rosen
2016-12-09  9:27                         ` Paul Rubin
2016-12-09 10:49                           ` J-P. Rosen
2016-12-09 19:58                             ` Jeffrey R. Carter
2016-12-09  8:35                   ` G.B.
2016-12-09  8:57                     ` Paul Rubin
2016-12-09 22:15                     ` Randy Brukardt
2016-12-09 21:58           ` Randy Brukardt
2016-12-08  8:23     ` Maciej Sobczak
2016-12-08 18:54   ` Adam Jensen
replies disabled

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