comp.lang.ada
 help / color / mirror / Atom feed
* Re: What's the best language to learn? [was Re: Should I learn C
       [not found] <ACFVZuraG3@belous.munic.msk.su>
@ 1996-08-27  0:00 ` Arkady V.Belousov
  1996-08-27  0:00   ` Levels of abstraction (was Re: What's the best language to learn?) Robert I. Eachus
  0 siblings, 1 reply; 2+ messages in thread
From: Arkady V.Belousov @ 1996-08-27  0:00 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 3204 bytes --]


Hello!

On 21-Aug-96 03:42 in <01bb8f12$6dbb5f00$32ee6fce@timhome2>
Tim Behrendsen (tim@airshields.com) wrote:
 > Szu-Wen Huang <huang@mnsinc.com> wrote in article
 > <4vdnod$5i8@news1.mnsinc.com>...
 > > Mark Wooding (mdw@excessus.demon.co.uk) wrote:

 > > :  char buf[...];
 > > :  char *p;
 > > :  ...
 > > :  while (buf[0]==' ')
 > > :  {
 > > :    for (p=buf;p[0]=p[1];p++)
 > > :      ;
 > > :  }
 > > :  while (buf[strlen(buf)-1]==' ')
 > > :    buf[strlen(buf)-1]=0
[]
 > > : Anyone who asks `what's wrong with that' will be shot.
 > > This code works, by the way, as far as I can tell.  It's even portable.
                                                              ^^^^^^^^^^^^^
 > > I suggest you show us somebody with equivalent experience in general
 > > computing as this individual but started on assembly language and see how
 > > this person fares with the problem.  Oh, and give them the same amount
 > > of time.
 > You're missing the point.  The point is how can *anyone* commit such
 > a monument to inefficient coding?  Yet, someone did.  That someone
 > obviously sees four lines of code, and therefore it must be OK.
 > Now, if that someone had an assembly background, and could see how
 > these statements were going to compile, they would instantly feel
 > the horror that a good and moral programmer should feel over this
 > code.

     Yes! Your words are balm for me.

______________O\_/_________________________________\_/O______________
// strrnspn like strspn scan a string for a segment that is a subset of
// a set of characters, but they reverse starting at specified position
// This code tested and optimized
size_t strrnspn(const char src[], const char sp[], size_t n){
        size_t pos = n;
        while(pos--){
                register char ch = src[pos];
                for(const char *ss = sp; *ss && *ss != ch; ss++);
                if(*ss != ch) break;
        }
        return (n - pos - 1);
}

// Remove border segments, which contain only characters from specified set
// This code not tested
void trim(char s[], const char sp[] = " \t"){
        size_t len = strlen(s);
        len -= strrnspn(s, sp, len);    // Remove "right" (last) border
        size_t cut = strspn(s, sp);
        memmove(s[0], s[cut], len -= cut); // Remove "left" border
        s[len] = '\0';                  // Terminate resulting string
}
_____________________________________________________________________
              O/~\                                 /~\O

     This code something more complicated, but they also "even portable" and
MUCH!!!! more efficient. (BTW. I think, first mentioned approach and codes
are used in the Borland and Microsoft judging by they products). %~(

P.S. Not much, but my (not showed there) trim function is more efficiency,
because they manipulate on instance of String class, which know they length.

 * When we hear - Jump, we ask - How far?
--
                Best regards! Sincerely yours, ������ ���������.
       ����̣���� ���� �������� ��������, � ���������� ������ ����������.





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

* Levels of abstraction (was Re: What's the best language to learn?)
  1996-08-27  0:00 ` What's the best language to learn? [was Re: Should I learn C Arkady V.Belousov
@ 1996-08-27  0:00   ` Robert I. Eachus
  0 siblings, 0 replies; 2+ messages in thread
From: Robert I. Eachus @ 1996-08-27  0:00 UTC (permalink / raw)



In article <AF_cdvr0BL@belous.munic.msk.su> "Arkady V.Belousov" <ark@belous.munic.msk.su> writes:

  > ...This code something more complicated, but they also "even
  > portable" and MUCH!!!! more efficient...

  > P.S. Not much, but my (not showed there) trim function is more
  > efficiency, because they manipulate on instance of String class,
  > which know they length.

  In Ada 95, there is not one Trim for strings, there are 11 (or 22 if
you count the corresponding packages for Wide_Strings).  I won't list
them all here, but basically there are four different profiles on
three (or six) different string representations.  Of course, in any
Ada implementation the bodies of those subprograms are going to be
written in Ada.

    I'm bringing this up, not as an argument that Ada is better, but
to show that there are different levels of abstraction, and trying to
decide that one language is better than another based on level of
abstraction is totally missing the point.  Programmers need to operate
at the level of abstraction which is appropriate for the problem at
hand.  As long as a software engineer has a set of tools in his
toolbox that can work at all necessary levels, the tool from his
personal toolbox that he chooses may not be the best tool for the job,
but it will be a good tool for that job, and one he or she is
comfortable with.

    Now I could argue that for down and dirty programming assembler is
best, at a slightly higher level you should switch to C, and above
that use an OO language.  Or I could just work in Ada at all levels
and gain the advantages of a seamless development environment.  (Which
I will choose depends on the project.  On small projects at a single
level of abstraction, and where the code will not be maintained for a
long period, the answer will often be some language other than Ada.)
                    
     To get back to the original question that prompted this thread,
one reason that Ada is a very good first programming language is that
it is one in which you can operate at all levels of abstraction.  (and
first year student should NOT be exposed to too many of them!)

--

					Robert I. Eachus

with Standard_Disclaimer;
use  Standard_Disclaimer;
function Message (Text: in Clever_Ideas) return Better_Ideas is...




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

end of thread, other threads:[~1996-08-27  0:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <ACFVZuraG3@belous.munic.msk.su>
1996-08-27  0:00 ` What's the best language to learn? [was Re: Should I learn C Arkady V.Belousov
1996-08-27  0:00   ` Levels of abstraction (was Re: What's the best language to learn?) Robert I. Eachus

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