comp.lang.ada
 help / color / mirror / Atom feed
From: "Dan'l Miller" <optikos@verizon.net>
Subject: Re: Teaching C/C++ from Ada perspective?
Date: Tue, 3 Jul 2018 20:10:39 -0700 (PDT)
Date: 2018-07-03T20:10:39-07:00	[thread overview]
Message-ID: <f7878185-925d-4752-9b3f-75506cce7deb@googlegroups.com> (raw)
In-Reply-To: <8dc19505-b68a-403c-a164-f1de1864f3f1@googlegroups.com>

On Tuesday, July 3, 2018 at 3:54:10 PM UTC-5, Maciej Sobczak wrote:
> > > There is nothing that C++ lacks in this area when compared to Ada.
> > 
> > Oh really!  Read Lakos's book then.
> 
> > John Lakos's _Large Scale C++ Software Design_ (1995).
> > All 852 pages of it effectively say:
> >  C++ is almost an unmitigated disaster in controlling physical dependencies unless you walk the very
> > narrow path that he lays out.
>
> No, they don't (and since I'm already used to your trolling style, I'm not surprised). The abstract is
> available here:
> 
> https://www.amazon.com/Large-Scale-Software-Design-John-Lakos/dp/0201633620
> 
> and relates to addressing physical challenges of large codebases.

You are factually incorrect.  Please read the quotations from Lakos's book in this reply, both here and below.  His entire 144-page chapter 6 is dedicated to untangling the disastrous entanglement that is C++ declarations in textually-included header files.  Specifically, Chapter 6 crescendos up to pages 399 to 405.  Pages 399 to 405 of Lakos's book (•not• Guru-of-the-Week •years• later) introduce the Pimpl idiom (originally named “fully-insulating concrete classes” in Lakos's seminal work) to demote vast amounts of content from the private members of classes in #inculde-d .h header files to the compilation-unit .c files.

page 335 in §6.2 C++ Constructs and * Compile-Time Coupling:
* The word ‘excessive’ is practically screamed in context here, as in:  C++ headers' excessive compile-time coupling.
“It is •easy• in C++ to •inadvertently• introduce implementation details into the physical interface of a component.  Whenever we place any part of the implementation of a component in its header file, we •fail• to insulate clients from that part of our implementation.”

> Considering the fact that the compilation model of Ada and C++ is basically the same (some of this
> might be related to the fact that they use, well, exactly the same compiler)

Janus Ada and Visual Studio C++ are exactly the same compiler, eh?  who knew?

> the challenges that are addressed by this book exists in both languages

Oh really!  On page 3 (i.e., the beginning of the book, setting the overarching tone of the next 848 pages), Lakos correctly observes, “… Not being able to understand or use any part of a system independently is a symptom of a cyclically dependent design.  ••C++ objects have a phenomenal tendency to get tangled up in each other••.  This insidious form of tight physical coupling is illustrated in Figure 0-1. … The definition for each of these three object types reside in separate physical components (translation units) in order to improve modularity.  Even though the implementations of these individual types are fully encapsulated by their interfaces, however, the .c files for each component are ••forced to include the header files of the other two••.  The resulting dependency graph for these three components is cyclic. …”

Ada specifications do not utilize primitive header-file textual inclusion mechanisms.  Ada specifications & bodies are by their nature not becoming co-dependent on each other by simply with-ing.  Indeed, cyclic nonprivate with-ing is prohibited in Ada.

Indeed, Lakos even goes even a little bit farther than your “the challenges that are addressed by this book exists in both languages” claim.  He says that these challenges are worse in C++ than they were in C:

§0.2.3 Excessive Compile-Time Dependencies, page 9, setting the overarching tone for the remaining 842 pages:
“There are many other causes of unwanted compile-time dependencies.  A large C++ program tends to have many more header files than an equivalent C program.  The unnecessary inclusion of one header file by another is a common source of excessive coupling in C++.”

§0.2.5 Logical vs. Physical Design, page 12:
“C++ supports an overwhelmingly rich set of logical design alternatives. … Misdiagnosing a situation … can lead to inefficiencies in both time and space, and can obscure the semantics of the architecture to a point where the entire system becomes difficult to maintain.  Knowing when (and when not) to use a particular language construct is part of what makes the /experienced/ C++ developer so valuable.” (Lakos's emphasis there) 

“¶Logical design does not address issues such as •where• to place a class definition.  …  ¶ There are several good books on logical design ….  Unfortunately, there are also many problems, which arise only as programs get larger, that these books don't address.  This is because much of the material relevant to successful large-system design falls under a different category, referred to in this book as /physical design/.”  (Lakos's emphasis there)

and here is what people complain about regarding Ada so much:  finding a logical design that the compiler will accept, as the compiler enforces all the physical-design wisdom that is built into the Ada language that is absent in C++:
“¶ Good physical design, however, involves more than passively deciding how to partition the existing logical entities of a system.  Physical design implications often dictate the outcome of logical design decisions.  …  ¶ Simultaneously satisfying the constraints of both logical and physical design may, at times, prove challenging.  In fact, ••some logical designs may have to be reworked or even replaced•• in order to meet the physical design quality criteria. …”  [Hence, the walking along the narrow path that Lakos lays out, as I was saying]

§0.6 Summary, page 18, hence the almost unmitigated disaster of C++ unless walking Lakos's narrow path:
“C++ is a whole lot more than just an extension of C.  Cyclic link-time dependencies among translation units can undermine understanding, testing, and reuse.  Unnecessary or excessive compile-time dependencies can increase compilation cost and ••destroy maintainability••.  A disorganized, undisciplined, or naïve approach to C++ development will ••virtually guarantee•• that these problems occur as projects become larger.  … ¶ … But tools cannot make up for a lack of inherent design quality in large C++ systems.  •••This book is about how to design in that quality.•••” [because C++-the-language provided so little guidance]

> > By comparison, in Ada's entire history spanning 5 decades, no one needed to write an analogous
> > 852-page tome on that topic.
> 
> You have problems with fundamental logic. The fact that such a book does not exist for Ada does not
> mean that it was never needed.

It does if HOLWG and Jean Ichbiah precluded pre-1983 the entire cyclic-dependency problem that permeates throughout C++ that the C++ community didn't have a book to teach them the errors of their ways until 1995 and onward.  (And given that Pimpl had to be rediscovered and renamed several years after that, means that some people were later to arrive at the party than 1995.)

> Interestingly, the theoretical book "Large-Scale Ada Software Design" might not be needed at all thanks
> to the fact that Ada problems at the large scale can be addressed with the techniques presented in the
> C++ book.

So let me get this straight.
1) HOLWG and Jean Ichbiah must have had a time machine that travels to some year post-1994.
2) Then they must have read Lakos's 1995 book or even Guru of the Week 'blog in 1997.
3) Then they must have traveled back in time to pre-1983 to conspire nefariously amongst themselves, “Hey, that Lakos is really on to something 12 to 17 years in the future in 1994 (reprised several years later by Herb Sutter in Guru of the Week #7 in 1997).  In Ada, let's steal their thunder by precluding that level of too-much-private-declaration in header files by having no textual-inclusion-based header files, separate compilation of private portions of packages, rather-early freezing rules, and prohibition on cyclic dependencies among frozen declarations.”
4) Then time-traveling Ada luminaries swiped the idea from C++ luminaries via this time travel (instead of the way it sure looks:  C++ world (during a period of duress & distress) looked over Ada world's shoulder to see how Ada-the-mentor solved the problem then devised C++ knock-offs of Ada's already-established wisdoms in these areas).

> After all, they use the same compiler.

You don't really think that RR Software's Janus Ada and Microsoft's Visual Studio C++ are the same compiler, do you?

You don't really think that there is only one compiler for Ada (i.e., GNAT), do you?

You don't really think that the source code & inner workings of GNAT's Ada front-end (prior to the GIGI tree-transducer to GIMPLE) has even one iota to do with the source code & inner workings of GCC's C++ front-end (prior to GENERIC/GIMPLE), do you?

Btw,
Kouaoua, even though this discussion/debate between Maciej & I seems to generate more heat than light (at least from his side), there are some wonderful gems for your class content:  Lakos's physical design is omitted by nearly all C++ coursework (except as excepted smidgeons such as Pimpl have drifted by osmosis into mainstream C++ culture).  The self-discipline •prescribed• by Lakos for C++ is avoiding the portions/bad-habits of C++ that don't scale to very large software systems, many of which are •proscribed• by Ada at compile-time.  Through the backdoor, we actually have covered another aspect of your OP question via C++'s versus Ada's prescribed versus proscribed differing/diametrically-opposed approaches to the rules-of-wisdom for how to successfully physically design multimillion or multi-tens-of-millions of lines of source-code for software-in-the-large integrated massive systems.  During the late 1980s and early 1990s, software-in-the-very-large was intended to be the A#1 key marketspace to be addressed by both Ada and its knockoff language C++.  In the end, Ada ended up accomplishing it better than C++.  Either you can be honest with your students that C++-in-the-small is written much differently than C++-in-the-large or you can overtly teach the content in Lakos's book (updated for modern C++, much as Guru of the Week GotW has been) as an Ada-esque reinterpretation of C++.

  reply	other threads:[~2018-07-04  3:10 UTC|newest]

Thread overview: 117+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-30 18:04 Teaching C/C++ from Ada perspective? kouaoua16
2018-06-30 18:15 ` Luke A. Guest
2018-06-30 19:27   ` Dan'l Miller
2018-06-30 19:07 ` Dan'l Miller
2018-07-01 16:12 ` kouaoua16
2018-07-01 17:08   ` Luke A. Guest
2018-07-01 19:19     ` Dan'l Miller
2018-07-02  6:12       ` Maciej Sobczak
2018-07-01 20:52 ` Maciej Sobczak
2018-07-01 21:35   ` Dan'l Miller
2018-07-02  5:56     ` Maciej Sobczak
2018-07-02  9:58       ` Marius Amado-Alves
2018-07-02 11:03         ` Maciej Sobczak
2018-07-02 13:52           ` Marius Amado-Alves
2018-07-04 12:10             ` Dan'l Miller
2018-07-02 20:14         ` Paul Rubin
2018-07-03  9:48           ` Marius Amado-Alves
2018-07-04  2:52             ` Paul Rubin
2018-07-02 18:52       ` Dan'l Miller
2018-07-03  8:00         ` Maciej Sobczak
2018-07-03 12:40           ` Dan'l Miller
2018-07-03 20:54             ` Maciej Sobczak
2018-07-04  3:10               ` Dan'l Miller [this message]
2018-07-04  7:59                 ` Maciej Sobczak
2018-07-04  8:37                   ` Marius Amado-Alves
2018-07-04 12:22                     ` Maciej Sobczak
2018-07-04 14:13                       ` Simon Wright
2018-07-04 14:56                         ` Maciej Sobczak
2018-07-04 15:52                           ` Dmitry A. Kazakov
2018-07-04 16:24                             ` Alejandro R. Mosteo
2018-07-04 20:00                               ` Jeffrey R. Carter
2018-07-05 18:35                                 ` Randy Brukardt
2018-07-05 19:39                                   ` Jeffrey R. Carter
2018-07-06 18:45                                     ` Randy Brukardt
2018-07-04 20:13                             ` Maciej Sobczak
2018-07-04 21:09                               ` Dmitry A. Kazakov
2018-07-05  5:49                                 ` Maciej Sobczak
2018-07-05  7:37                                   ` Dmitry A. Kazakov
2018-07-05 13:14                                     ` Maciej Sobczak
2018-07-05 15:18                                       ` Dmitry A. Kazakov
2018-07-05 19:16                                       ` Randy Brukardt
2018-07-07 15:09                                         ` Lucretia
2018-07-05 19:12                                     ` Randy Brukardt
2018-07-05 20:10                                       ` Maciej Sobczak
2018-07-06 19:01                                         ` Randy Brukardt
2018-07-06 19:35                                           ` Dmitry A. Kazakov
2018-07-05  7:43                                   ` Alejandro R. Mosteo
2018-07-05 18:53                                   ` Randy Brukardt
2018-07-05 19:06                                     ` Dan'l Miller
2018-07-06 18:47                                       ` Randy Brukardt
2018-07-05 20:12                                     ` Maciej Sobczak
2018-07-06 18:51                                       ` Randy Brukardt
2018-07-06 19:43                                         ` Dmitry A. Kazakov
2018-07-06 20:18                                           ` Dan'l Miller
2018-07-07  8:39                                             ` Dmitry A. Kazakov
2018-07-07 11:53                                           ` Björn Lundin
2018-07-06 20:22                                         ` Maciej Sobczak
2018-07-06 23:26                                           ` Paul Rubin
2018-07-07  6:17                                             ` J-P. Rosen
2018-07-07  6:37                                               ` Micronian Coder
2018-07-07  8:48                                                 ` Privacy and child packages (Was: Teaching C/C++ from Ada perspective?) Jacob Sparre Andersen
2018-07-07 20:19                                               ` Teaching C/C++ from Ada perspective? Maciej Sobczak
2018-07-08 15:25                                           ` Simon Wright
2018-07-08 20:00                                             ` Maciej Sobczak
2018-07-09  9:04                                               ` Alejandro R. Mosteo
2018-07-05 15:30                               ` Dan'l Miller
2018-07-05 20:38                                 ` Maciej Sobczak
2018-07-05 21:05                                   ` Dan'l Miller
2018-07-05 18:47                               ` Randy Brukardt
2018-07-04 16:01                           ` Simon Wright
2018-07-04 17:12                           ` G. B.
2018-07-04 20:18                             ` Maciej Sobczak
2018-07-04 21:03                               ` G.B.
2018-07-04 17:21                           ` Dan'l Miller
2018-07-04 20:36                             ` Maciej Sobczak
2018-07-04 22:44                               ` Dan'l Miller
2018-07-05  2:01                                 ` Luke A. Guest
2018-07-05  5:03                                   ` Dan'l Miller
2018-07-05  5:58                                 ` Maciej Sobczak
2018-07-05 19:25                                   ` Randy Brukardt
2018-07-05 19:22                                 ` Randy Brukardt
2018-07-05 18:31                       ` Randy Brukardt
2018-07-06  3:32           ` Dan'l Miller
2018-07-06 12:05             ` Dan'l Miller
2018-07-06 20:42             ` Maciej Sobczak
2018-07-06 21:32               ` Dan'l Miller
2018-07-07 20:43                 ` Maciej Sobczak
2018-07-08 17:36                   ` Dan'l Miller
2018-07-08 18:39                     ` Bill Findlay
2018-07-08 19:28                       ` Dan'l Miller
2018-07-09 12:34                         ` Bill Findlay
2018-07-09 15:19                           ` Dan'l Miller
2018-07-09 19:34                             ` Bill Findlay
2018-07-09 22:03                               ` Dan'l Miller
2018-07-09 22:35                                 ` Bill Findlay
2018-07-10  1:56                                   ` Lucretia
2018-07-10 23:14                         ` Randy Brukardt
2018-07-11 14:05                           ` Dan'l Miller
2018-07-11 20:20                             ` Randy Brukardt
2018-07-08 20:43                     ` Maciej Sobczak
2018-07-08 23:17                       ` Dan'l Miller
2018-07-09  6:13                         ` Maciej Sobczak
2018-07-09 16:35                           ` Dan'l Miller
2018-07-10 23:20                       ` Randy Brukardt
2018-07-10 23:51                         ` Britt
2018-07-02 17:10   ` kouaoua16
2018-07-02 17:28     ` Dennis Lee Bieber
2018-07-02 18:22     ` Maciej Sobczak
2018-07-02 20:27     ` G.B.
2018-07-02  0:11 ` Paul Rubin
2018-07-02 14:26 ` kouaoua16
2018-07-02 19:57 ` G.B.
2018-07-02 20:17   ` Dan'l Miller
2018-07-03  9:56 ` Brian Drummond
2018-07-04 12:18 ` Olivier Henley
2018-07-04 14:17   ` kouaoua16
2018-07-12  5:38 ` robin.vowels
replies disabled

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