comp.lang.ada
 help / color / mirror / Atom feed
From: Ole-Hjalmar Kristensen <ole-hjalmar.kristensen@substitute_employer_here.com>
Subject: Re: Ada Popularity: Comparison of Ada/Charles with C++ STL (and Perl)
Date: 24 Sep 2004 11:44:22 +0200
Date: 2004-09-24T09:44:23+00:00	[thread overview]
Message-ID: <wvbrr7osm26h.fsf@ellex06.Norway.Sun.COM> (raw)
In-Reply-To: e749549b.0409231111.7d98264d@posting.google.com

kevin.cline@gmail.com (Kevin Cline) writes:

> Ole-Hjalmar Kristensen <ole-hjalmar.kristensen@substitute_employer_here.com> wrote in message news:<wvbrd60dusx0.fsf@sun.com>...
> > >>>>> "KC" == Kevin Cline <kevin.cline@gmail.com> writes:
> > 

<snip>

> > I usually find that my ability to create programs is limited by my
> > thought process, not my typing speed :-
> 
> Mine too.  For the Perl program, the thought process was limited to
> this:
> 
>   read input: while (<>)
> 
>   split into sequences of alphabetic characters: 
>      foreach my $word (split (/[a-zA-Z]+/))
> 
>   count words: ++$count{$word}
> 
>   sort words by frequency: sort { $map{$a} <=> $map{$b} ) keys %count
> 
>   print first 10: $n = 0; foreach ( ... ) { print ...; last if ++$n >=
> 10; }
> 
> The only bits that required much thought at all were figuring out the
> right comparison function for sorting (I looked at an example), and
> getting the loop exit right.  The rest was written nearly
> instantaneously.
> 
> Are you really claiming that you can think of:
> 
>   procedure Insert (Word : in String) is
> 
>       procedure Increment_Count
>         (K : in     String;
>          N : in out Natural) is
> 
>          pragma Warnings (Off, K);
>       begin
>          N := N + 1;
>       end Increment_Count;
> 
>       C : Wordcount_Maps.Cursor;
>       B : Boolean;
> 
>    begin -- Insert
>       Insert (M, Word, 0, C, B);
>       Update_Element (C, Increment_Count'Access);
>    end Insert;
> 
> As quickly as I can think of: 
>   ++concordance[word] 
> or
>   ++$count{$word} ?
> 

No, not at all. But I usually write programs where the logic tends to
be a bit more complicated, and where the instantiation of
templates/generics and similar boiler plate is not dominating.

> Multiply this 1000 times for a medium to large program and I think Ada
> really suffer from unnecessary verbosity.
> 
> It's reasonable to claim that Ada is better than C++ for
> safety-critical embedded programming, but if you really want to
> understand why Ada is not more popular for desktop applications I
> think the evidence is here.  The real question I have is why Perl and
> similar high-level languages are not more popular.

If I wanted something more high-level I would use Lisp, not Perl.  

Now consider the following implementation of a polygon clipper (an old
test program I had lying around to test the relative speed of a
recursive and non-recursive version of essentially the same polygon
clipper)

Do you really believe this program had been any more readable or easy
to program in C++ or Perl?

with Vector; use Vector; -- Contains basic vector and plane stuff

-- Pipelined Sutherland-Hodgson type polygon clipper
-- Pipeline implemented by recursive calls

procedure Sutherland is

   -- Polygon container
   type Vertex_Array is array(Integer range <>) of Vector3;

   -- Stage in pipeline
   type Stage is record
      Pl : Plane;    -- Clipping plane
      S : Vector3;   -- Start point
      F : Boolean := true;   -- First visit?
      Closing : Vector3; -- Closing point
   end record;

   -- 6 planes for frustum clipping
   Stages : array(1..6) of Stage;

   procedure Reset_Stages is
   begin
      for I in Stages'Range loop
         Stages(I).F := True;
      end loop;
   end Reset_Stages;

   -- Test if vertex is inside plane
   function Inside(Test_Vertex : Vector3; clip : Integer) return Boolean is
   begin
      return Inside(Test_Vertex, Stages(Clip).Pl);
   end Inside;

   -- Return intersect of vector from S to P with plane
   function Intersect(S : Vector3;
                      P : Vector3;
                      Clip : Integer ) return Vector3 is
   begin
      return Intersect(S,P,Stages(Clip).Pl);
   end Intersect;

   -- Output vertex to next stage of clipper
   procedure Output_Point(Clip_Stage : Integer; P : Vector3);

   -- Clip vertex to plane given by Clip_Stage
   procedure Clip_Vertex(Clip_Stage : Integer; P : Vector3) is
      Clipped_P : Vector3;
   begin
      -- Initialize start if first time
      if Stages(Clip_Stage).F then
         Stages(Clip_Stage).S := P;
         Stages(Clip_Stage).Closing := P;
         Stages(Clip_Stage).F := False;
      else
         if Inside(P,Clip_Stage) then
            if Inside(Stages(Clip_Stage).S,Clip_Stage) then
               Output_Point(Clip_Stage,P);
            else
               Clipped_P := Intersect(Stages(Clip_Stage).S,P,Clip_Stage);
               Output_Point(Clip_Stage,Clipped_P);
               Output_Point(Clip_Stage,P);
            end if;
         else
            if Inside(Stages(Clip_Stage).S,Clip_Stage) then
               Clipped_P := Intersect(Stages(Clip_Stage).S,P,Clip_Stage);
               Output_Point(Clip_Stage,Clipped_P);
            end if;
         end if;
         Stages(Clip_Stage).S := P;
      end if;
   end Clip_Vertex;

   -- Output vertex to next stage of clipper
   procedure Output_Point(Clip_Stage : Integer; P : Vector3) is
   begin
      if Clip_Stage >= Stages'Last then
         null; 
      else
         Clip_Vertex(Clip_Stage + 1, P);
      end if;
   end Output_Point;

   procedure Empty_Pipeline is
   begin
      for I in Stages'Range loop
         if not Stages(I).F then
            Clip_Vertex(I,Stages(I).Closing);
         end if;
      end loop;
   end Empty_Pipeline;

   -- Clip polygon by clipping each vertex in turn
   procedure Clip_Poly(In_Poly : Vertex_Array) Is
   begin
      for I in In_Poly'Range loop
         Clip_Vertex(Stages'First,In_Poly(I));
      end loop;
      Empty_Pipeline;
   end Clip_Poly;

   procedure Init_Stages is
   begin
      Reset_Stages;
      -- Front
      Stages(1).Pl := Create_Plane((0.0,0.0,0.0),
                                   (100.0,0.0,0.0),
                                   (100.0,0.0,100.0));
      -- Back
      Stages(2).Pl := Create_Plane((100.0,100.0,0.0),
                                   (0.0,100.0,0.0),
                                   (0.0,100.0,100.0));
      -- Left
      Stages(3).Pl := Create_Plane((0.0,100.0,0.0),
                                   (0.0,0.0,0.0),
                                   (0.0,0.0,100.0));
      -- Right
      Stages(4).Pl := Create_Plane((100.0,0.0,0.0),
                                   (100.0,100.0,0.0),
                                   (100.0,100.0,100.0));
      -- Bottom
      Stages(5).Pl := Create_Plane((0.0,0.0,0.0),
                                   (0.0,100.0,0.0),
                                   (100.0,100.0,0.0));
      -- Top
      Stages(6).Pl := Create_Plane((0.0,0.0,100.0),
                                   (100.0,0.0,100.0),
                                   (100.0,100.0,100.0));

   end Init_Stages;

   Test_Poly : Vertex_Array(1..3) := ((0.0,0.0,1.0),
                                      (150.0,200.0,1.0),
                                      (200.0,150.0,1.0));

begin
   Init_Stages;
   for I in 1..100000 loop
      Clip_Poly(Test_Poly);
      Reset_Stages;
   end loop;
end Sutherland;


-- 
   C++: The power, elegance and simplicity of a hand grenade.



  parent reply	other threads:[~2004-09-24  9:44 UTC|newest]

Thread overview: 229+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-09-22  0:21 Ada Popularity: Comparison of Ada/Charles with C++ STL (and Perl) Kevin Cline
2004-09-22  2:16 ` Pylinius
2004-09-22  8:50 ` Björn Persson
2004-09-22 13:38   ` Benjamin Ketcham
2004-09-22 14:07     ` Hyman Rosen
2004-09-22 15:16     ` Cesar Rabak
2004-09-23  8:22     ` Kevin Cline
2004-09-23 10:52     ` Anders Wirzenius
2004-09-23 10:54       ` stephane richard
2004-09-23 11:17       ` Jean-Pierre Rosen
2004-09-23 11:47       ` Marius Amado Alves
2004-09-23 13:34         ` Anders Wirzenius
2004-09-23 16:53           ` Warren W. Gay VE3WWG
2004-09-23 18:30           ` Kevin Cline
2004-09-23 19:00             ` Marius Amado Alves
2004-09-24  6:04               ` [OT]Screen ergonomics, was " Anders Wirzenius
2004-09-26  7:22               ` Kevin Cline
2004-09-23 17:19         ` Cesar Rabak
2004-09-23  8:51   ` Kevin Cline
2004-09-23 11:01     ` Georg Bauhaus
2004-09-23 15:59       ` Matthew Heaney
2004-09-23 16:38       ` Kevin Cline
2004-09-24  2:47         ` Matthew Heaney
2004-09-24 13:43           ` Hyman Rosen
2004-09-24 17:47             ` Mark Lorenzen
2004-09-24 18:16               ` Matthew Heaney
2004-09-29 19:29                 ` Mark Lorenzen
2004-09-29 22:44                   ` Matthew Heaney
2004-09-25 14:09             ` Martin Krischik
2004-09-26  7:08           ` Kevin Cline
2004-09-26 15:13             ` Matthew Heaney
2004-09-23 19:10     ` jayessay
2004-09-23 21:13       ` Adam Ruth
2004-09-27  2:12         ` Keith H Duggar
2004-09-27 14:21           ` Adam Ruth
2004-09-27 14:51             ` Chris Humphries
2004-09-27 17:10               ` Adam Ruth
2004-09-27 20:16               ` Keith H Duggar
2004-09-27 21:15                 ` Chris Humphries
2004-09-28  4:46                   ` Keith H Duggar
2004-09-27 20:34             ` Kevin Cline
2004-09-27 21:15               ` Adam Ruth
2004-09-23 23:05     ` Brian May
2004-09-24  3:06       ` Matthew Heaney
2004-09-24  3:52       ` Randy Brukardt
2004-09-24  5:15         ` Matthew Heaney
2004-09-24 19:12         ` Kevin Cline
2004-09-24 20:54           ` Randy Brukardt
2004-09-24 21:23             ` Matthew Heaney
2004-09-27 13:22           ` Chris Humphries
2004-09-27 13:45             ` Chris Humphries
2004-09-27 21:31             ` Kevin Cline
2004-09-27 23:51               ` Brian May
2004-09-28 12:21               ` Chris Humphries
2004-09-26 17:10         ` jayessay
2004-09-26 20:00           ` Georg Bauhaus
2004-09-27 14:45             ` jayessay
2004-09-24  0:19     ` Stephen Leake
2004-09-24 14:54       ` Cesar Rabak
2004-09-22 15:27 ` James Alan Farrell
2004-09-22 21:24   ` Simon Wright
2004-09-23  0:03     ` Brian May
2004-09-23  9:17       ` Kevin Cline
2004-09-23  0:44     ` Jeffrey Carter
2004-09-23 11:08       ` Georg Bauhaus
2004-09-23  8:15     ` Martin Krischik
2004-09-23 16:20       ` Matthew Heaney
2004-09-23 19:23         ` Simon Wright
2004-09-24  7:19         ` Martin Krischik
2004-09-24 16:31           ` Matthew Heaney
2004-09-24 19:24           ` Kevin Cline
2004-09-25 14:04             ` Martin Krischik
2004-09-26 10:36               ` Robert Kawulak
2004-09-26 15:35                 ` Martin Krischik
2004-09-28 17:46                   ` Robert Kawulak
2004-09-29  7:49                     ` Martin Krischik
2004-09-29 12:01                       ` Xenos
2004-09-29 18:16                       ` Robert Kawulak
2004-09-30 15:55                         ` Martin Krischik
2004-09-27 22:22               ` Kevin Cline
2004-09-28  7:51                 ` Martin Krischik
2004-09-29  3:04                   ` Kevin Cline
2004-09-29  6:03                     ` Dale Stanbrough
2004-09-29 13:31                     ` Georg Bauhaus
2004-09-29 13:46                     ` Matthew Heaney
2004-09-30  3:42                       ` Kevin Cline
2004-09-30  7:54                         ` Dale Stanbrough
2004-09-30 16:50                         ` Matthew Heaney
2004-10-01  0:04                           ` Kevin Cline
2004-10-01 12:25                             ` Georg Bauhaus
2004-10-02  7:35                               ` K
2004-10-02 10:00                                 ` Brian May
2004-10-02 20:39                                   ` Kevin Cline
2004-10-03  2:17                                     ` Brian May
2004-10-02 13:40                                 ` Matthew Heaney
2004-10-02 23:33                                 ` Randy Brukardt
2004-10-03 12:47                                   ` Stephen Leake
2004-09-30 19:01                         ` Björn Persson
2004-09-30 23:54                           ` Kevin Cline
2004-10-01 16:11                             ` Björn Persson
2004-10-02  6:48                               ` K
2004-10-02 10:41                                 ` Björn Persson
2004-10-02 13:32                                 ` Matthew Heaney
2004-10-04  9:02                                 ` Ole-Hjalmar Kristensen
2004-09-23  9:00   ` Kevin Cline
2004-09-23 11:27     ` Ole-Hjalmar Kristensen
2004-09-23 19:11       ` Kevin Cline
2004-09-23 21:01         ` Alexander E. Kopilovich
2004-09-26  6:53           ` Kevin Cline
2004-09-26 15:29             ` Alexander E. Kopilovich
2004-09-23 21:54         ` Eric Jacoboni
2004-09-24  9:44         ` Ole-Hjalmar Kristensen [this message]
2004-09-24  9:50         ` Georg Bauhaus
2004-09-24 13:47           ` Matthew Heaney
2004-09-24 14:14             ` Dmitry A. Kazakov
2004-09-25 14:17               ` Martin Krischik
2004-09-27  8:12                 ` Dmitry A. Kazakov
2004-09-27 12:59                   ` Georg Bauhaus
2004-09-27 13:53                     ` Dmitry A. Kazakov
2004-09-26  7:17               ` Kevin Cline
2004-09-27  8:19                 ` Dmitry A. Kazakov
2004-09-27 13:03                   ` Georg Bauhaus
2004-09-27 14:00                     ` Dmitry A. Kazakov
2004-09-24 16:28           ` Kevin Cline
2004-09-24 17:45             ` Georg Bauhaus
2004-09-24 20:14             ` Matthew Heaney
2004-09-24 20:10               ` Frank J. Lhota
2004-09-27  8:29                 ` Dmitry A. Kazakov
2004-09-26  7:13               ` Kevin Cline
2004-09-26 15:15                 ` Matthew Heaney
2004-09-27 14:31                   ` Kevin Cline
2004-09-27 15:05                     ` Dmitry A. Kazakov
2004-09-28  4:22                       ` Kevin Cline
2004-09-28  8:20                         ` Dmitry A. Kazakov
2004-09-28 23:26                           ` Robert Kawulak
2004-09-29 12:19                             ` Dmitry A. Kazakov
2004-09-30 18:52                               ` Robert Kawulak
2004-10-01  7:55                                 ` Dmitry A. Kazakov
2004-10-03 19:35                                   ` Robert Kawulak
2004-10-04 10:24                                     ` Dmitry A. Kazakov
2004-10-06 17:28                                       ` Robert Kawulak
2004-10-07  8:24                                         ` Dmitry A. Kazakov
2004-10-10 21:09                                           ` Robert Kawulak
2004-10-11  8:08                                             ` Dmitry A. Kazakov
2004-10-15  9:34                                               ` Robert Kawulak
2004-10-15 16:58                                                 ` Martin Krischik
2004-09-29 15:44                             ` Matthew Heaney
2004-09-30 18:27                               ` Robert Kawulak
2004-09-28 17:21                       ` Robert Kawulak
2004-09-29  1:38                         ` Georg Bauhaus
2004-09-29 18:08                           ` Robert Kawulak
2004-09-30 18:30                             ` Georg Bauhaus
2004-09-29  8:08                         ` Dmitry A. Kazakov
2004-09-29 18:11                           ` Robert Kawulak
2004-09-30  8:57                             ` Dmitry A. Kazakov
     [not found]                               ` <cji06f$17a$2@atlantis.news.tpi.pl>
2004-10-01  8:58                                 ` Dmitry A. Kazakov
2004-10-03 19:53                                   ` Robert Kawulak
2004-10-04 10:15                                     ` Dmitry A. Kazakov
2004-10-04 12:16                                       ` Matthew Heaney
2004-10-04 13:21                                         ` Dmitry A. Kazakov
2004-10-06 17:20                                       ` Robert Kawulak
2004-10-07 10:08                                         ` Dmitry A. Kazakov
2004-10-10 22:21                                           ` Robert Kawulak
2004-10-11  8:46                                             ` Dmitry A. Kazakov
2004-10-15  9:25                                               ` Robert Kawulak
2004-10-15 11:56                                                 ` Dmitry A. Kazakov
2004-10-20 20:06                                                   ` Robert Kawulak
2004-10-21  2:51                                                     ` Kevin Cline
2004-10-21  8:39                                                     ` Dmitry A. Kazakov
2004-10-27 21:41                                                       ` Robert Kawulak
2004-10-01 13:02                                 ` Robert Kawulak
2004-10-28 10:26                                 ` Larry Kilgallen
2004-09-27 16:21                     ` Matthew Heaney
2004-09-28  2:47                       ` Kevin Cline
2004-09-28  4:03                         ` Brian May
2004-09-28  4:46                         ` Matthew Heaney
2004-09-29  3:14                           ` Kevin Cline
2004-09-29  3:50                             ` Matthew Heaney
2004-09-29  3:52                               ` Matthew Heaney
2004-09-29 13:44                             ` Matthew Heaney
2004-09-26  6:32           ` Kevin Cline
2004-09-26 15:05             ` Matthew Heaney
2004-09-27 14:35               ` Kevin Cline
2004-09-23 19:30       ` jayessay
2004-09-23 19:42     ` Alexander E. Kopilovich
2004-09-22 21:05 ` Georg Bauhaus
2004-09-23  9:20   ` Kevin Cline
2004-09-23 16:58     ` Warren W. Gay VE3WWG
2004-09-23  6:24 ` Matthew Heaney
2004-09-23 11:23   ` Jeff C r e e.m
2004-09-23 11:35     ` Georg Bauhaus
2004-09-23 17:05       ` Pascal Obry
2004-09-23 17:07       ` Pascal Obry
2004-09-23 18:30     ` Matthew Heaney
2004-09-23 19:31       ` Simon Wright
2004-09-24  0:09         ` Stephen Leake
2004-09-25 10:41           ` Simon Wright
2004-09-23 18:24   ` Kevin Cline
2004-09-23 17:12 ` Dan Andreatta
2004-09-23 18:10   ` Pascal Obry
2004-09-23 19:21     ` Eric Jacoboni
2004-09-23 19:31       ` Ed Falis
2004-09-23 19:37         ` Eric Jacoboni
2004-09-24 20:09       ` Kevin Cline
2004-09-25  0:18         ` Eric Jacoboni
2004-09-26  6:37           ` Kevin Cline
2004-09-26 14:57             ` Matthew Heaney
2004-09-23 19:24     ` Eric Jacoboni
2004-09-23 21:30       ` Eric Jacoboni
2004-09-26 11:44         ` Jacob Sparre Andersen
2004-09-26 17:02         ` jayessay
2004-09-24  8:26       ` Ole-Hjalmar Kristensen
2004-09-23 22:08     ` Anders Gidenstam
2004-09-24  8:10     ` Ole-Hjalmar Kristensen
2004-09-24 17:43       ` Dan Andreatta
2004-09-24 17:40     ` Dan Andreatta
2004-09-24 18:50       ` Pascal Obry
2004-09-23 22:34 ` Randy Brukardt
2004-09-23 23:11   ` Dale Stanbrough
2004-09-24  1:57     ` Matthew Heaney
2004-09-24  6:32       ` Dale Stanbrough
2004-09-24 21:01         ` Randy Brukardt
2004-09-24  0:43   ` Jeffrey Carter
2004-09-24  1:51   ` Matthew Heaney
2004-09-24 20:21     ` Kevin Cline
2004-09-26 11:09 ` Jacob Sparre Andersen
2004-09-27 13:49   ` Björn Persson
2004-10-12  5:21 ` Ada Popularity: Comparison of languages Brian May
2004-10-12 11:43   ` Peter Hermann
replies disabled

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