comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: Separate Compilation in Programming Languages
Date: Mon, 25 Feb 2008 08:12:26 -0500
Date: 2008-02-25T08:12:26-05:00	[thread overview]
Message-ID: <wccir0ddvt1.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: %Ntwj.12620$Ch6.11402@newssvr11.news.prodigy.net

<adaworks@sbcglobal.net> writes:

> Perhaps.  But I still don't see how one can defer the dependency of a
> Java signature to the implementation of the Java class and prevent
> the need for recompiling the entire architecture when the signature of
> a parent class changes.   The ripple effect through the entire chain
> of dependencies when one of those signatures changes is almost
> certain to be affected by such a change of signature.

I think perhaps what you are missing is that in Java, you can use the
same "trick" all along the chain.  (The "trick" illustrated by the
examples I showed.)

E.g., in Ada, you are advocating something like this:

    E spec (no with's)
    E body (says "with D")

    D spec (no with's)
    D body (says "with C")

    C spec (no with's)
    C body (says "with B")

    B spec (no with's)
    B body (says "with A")

    A spec (no with's)
    A body (no with's)

...to the extent possible, pushing with's into bodies.
So if, say, B spec changes, you need to recompile
B body and C body, but not (down the chain) D or E.
Here, we have 10 source files.

The analogous thing with interfaces is:

    E interface (no with's)
    E.Implementation (says "with D")

    D interface (no with's)
    D.Implementation (says "with C")

    C interface (no with's)
    C.Implementation (says "with B")

    B interface (no with's)
    B.Implementation (says "with A")

    A interface (no with's)
    A.Implementation (no with's)

In Ada, each "implementation" is a spec and a body, whereas in Java it's
just one class file -- but that's irrelevant.  In Ada, we have 15 source
files (5 of which are empty or nearly so), but in Java, only 10, as in
the previous Ada case.

If you change B interface, you have to recompile B.Implementation (spec
and body) and C.Implementation (spec and body), but not anything down
the chain (D/E).

Note that in this method, there are no dependences on the Implementation
packages, or very few.  Clients such as C.Implementation do NOT say
"with B.Implementation"!

(I'm ignoring private parts and generics, which throw a monkey wrench
into the works.)

>...If Java can
> somehow accomodate that change automatically, ...

Ah, maybe that's the problem.  No, it's not automatic.
In Java, you have to choose to split out all those interfaces,
all down the chain.  And you have to take care to make every
implementation class depend on interfaces, rather than other
implementations.  A simpler structure is:

    E (says "with D")

    D (says "with C")

    C (says "with B")

    B (says "with A")

    A (no with's)

(except Java doesn't call it "with").  In this simpler structure, you do
indeed have the ripple effect you're worried about.

>...it must be some
> kind of magic that is not immediately apparent, even to the Java
> developers I know.

It's not magic!  It requires effort.  It is perhaps easier in Ada.
But I think the "trick" (or "technique") is well known among
Java programmers.

- Bob



  reply	other threads:[~2008-02-25 13:12 UTC|newest]

Thread overview: 72+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-22 17:35 Separate Compilation in Programming Languages adaworks
2008-02-22 17:52 ` Dirk Heinrichs
2008-02-23  0:23   ` adaworks
2008-02-22 18:10 ` Ray Blaak
2008-02-22 23:53   ` adaworks
2008-02-23  1:40     ` Ray Blaak
2008-02-23  7:29       ` adaworks
2008-02-23 18:42         ` Ray Blaak
2008-02-22 18:18 ` Niklas Holsti
2008-02-23  0:14   ` adaworks
2008-02-23  7:23     ` Niklas Holsti
2008-02-23  7:31       ` Niklas Holsti
2008-02-23 16:00         ` adaworks
2008-02-23 12:27     ` Georg Bauhaus
2008-02-23 12:37   ` Dirk Heinrichs
2008-02-23 13:03     ` Niklas Holsti
2008-02-22 19:11 ` Dmitry A. Kazakov
2008-02-23  0:16   ` adaworks
2008-02-22 19:33 ` Larry Kilgallen
2008-02-22 20:47 ` Simon Wright
2008-02-22 21:27 ` Robert A Duff
2008-02-23  0:12   ` adaworks
2008-02-23 10:28     ` framefritti
2008-02-23 12:45     ` Dirk Heinrichs
2008-02-23 15:16     ` Robert A Duff
2008-02-23 16:47       ` adaworks
2008-02-23 18:47         ` Ray Blaak
2008-02-24  7:40           ` adaworks
2008-02-24  9:42             ` Ray Blaak
2008-02-24 20:41               ` adaworks
2008-02-25  2:37                 ` Ray Blaak
2008-02-25  7:06                   ` adaworks
2008-02-25 13:12                     ` Robert A Duff [this message]
2008-02-25 17:44                     ` Ray Blaak
2008-02-25 22:16                       ` Ray Blaak
2008-02-26  5:10                         ` John W. Kennedy
2008-02-26 19:08                           ` Ray Blaak
2008-02-26  7:11                         ` adaworks
2008-02-26 13:38                           ` Stephen Leake
2008-02-26 14:56                             ` adaworks
2008-02-26 19:15                               ` Ray Blaak
2008-02-26 19:13                           ` Ray Blaak
2008-02-26 21:25                             ` Ray Blaak
2008-02-27  1:15                               ` Robert A Duff
2008-02-26  7:06                       ` adaworks
2008-02-26 11:42                       ` Alex R. Mosteo
2008-02-26 15:05                         ` adaworks
2008-02-26 15:15                           ` Alex R. Mosteo
2008-02-24 17:26             ` Robert A Duff
2008-02-23 20:46         ` Robert A Duff
2008-02-24  7:31           ` adaworks
2008-02-24 17:20             ` Robert A Duff
2008-02-24 20:33               ` adaworks
2008-02-25  1:07                 ` Robert A Duff
2008-02-26  7:29                   ` adaworks
2008-02-26 19:22                     ` Ray Blaak
2008-02-27  1:58                       ` adaworks
2008-02-27 20:34                         ` Ray Blaak
2008-02-27 22:31                           ` Robert A Duff
2008-02-27 23:35                             ` Ray Blaak
2008-02-28  0:19                               ` Randy Brukardt
2008-02-28  9:18                               ` Georg Bauhaus
2008-02-29  5:57                             ` adaworks
2008-02-29  6:04                               ` Ray Blaak
2008-02-29 10:48                                 ` Alex R. Mosteo
2008-02-29 17:05                                 ` adaworks
2008-02-29 18:33                                   ` Ray Blaak
2008-02-29  6:10                           ` adaworks
2008-02-22 22:16 ` Jeffrey R. Carter
2008-02-23 13:44 ` Brian Drummond
2008-02-23 17:19   ` adaworks
2008-02-25  7:53 ` Jean-Pierre Rosen
replies disabled

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