From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,aea4cc77526f5e4a X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local02.nntp.dca.giganews.com!nntp.bt.com!news.bt.com.POSTED!not-for-mail NNTP-Posting-Date: Sat, 23 Feb 2008 07:43:00 -0600 From: Brian Drummond Newsgroups: comp.lang.ada Subject: Re: Separate Compilation in Programming Languages Date: Sat, 23 Feb 2008 13:44:25 +0000 Reply-To: brian@shapes.demon.co.uk Message-ID: References: X-Newsreader: Forte Agent 1.7/32.534 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 81.158.34.181 X-AuthenticatedUsername: NoAuthUser X-Trace: sv3-4xNVMReKfj5A2w9W6GUpVv06KE1PogqLen21KThcpfbOAOMQFbKrNx5KyJl1BXYH5DihsRT2qdmrJrU!eI52xDxYFVTWIRRlwxj+9uZQxqbd3ygLAIg46xSnnWfXh1r+wHDiS2zBjC6/woIKi7t1PT5LSh4W!b4Q= X-Complaints-To: abuse@btinternet.com X-DMCA-Complaints-To: abuse@btinternet.com X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.37 Xref: g2news1.google.com comp.lang.ada:20024 Date: 2008-02-23T13:44:25+00:00 List-Id: On Fri, 22 Feb 2008 17:35:33 GMT, wrote: >Recently, I have been engaged in some conversations with colleagues about the >value of >separate compilation. This is one of my favorite features in Ada. In fact, >as nearly as >I can tell, none of the other popular languages includes this feature in as >well-developed >a form as Ada. One language which does have an equivalent mechanism (perhaps not surprisingly, given its origin), and in which a similar debate is currently active, is VHDL. There, the separation takes the form of the "component" specification, within the consumer of a component. The consumer can instantiate a "component", (similar to declaring a variable of a type defined separately) whose interface is guaranteed consistent with its use by the compiler - and at this stage, nothing is known about the implementation. Separately, the component is defined as an "entity", and implemented as an "architecture", which are again guaranteed consistent with each other during compilation. It is only at elaboration that an attempt is made to find an "entity" to match each "component" specification; if there are any failures to match, of course, elaboration fails with an error. But there is also a way to bypass separate compilation by direct entity instantiation, in which an entity specification is embedded in the consumer, in the place of the component specification. In this case, the matching entity must be found (already compiled and correct) for the consumer to compile. Interestingly, in comp.lang.vhdl, the concensus seems to be that direct instantiation is to be preferred where possible. (google comp.lang.vhdl for "direct entity instantiation" if you need more of the debate). Two reasons are usually mentioned: the component specification is just one more piece of code to write and maintain; (and VHDL is perceived as verbose enough without it), and forcing the entity/arch to compile concurrently with the consumer is perceived as catching any errors earlier (i.e. compile time vs elaboration). In other words, as said here for Java, compilation is cheap. >This morning, after an especially interesting argument about this feature and, >"Why would >anyone want to do such a thing?" style questions, I decided to approach this >forum. What >is your view of Ada-style separate compilation when compared to that in other >languages? >Do you find it useful in your own practice? I am out on a limb in still using components, and I'm not entirely clear why I do, other than mild personal preference, and because the toolset I use encourages it; it works perfectly well for me. Though I have occasionally had elaboration failures due to component mis-specification, they haven't caused any real headaches. I'm not clear why the theoretical advantages of separate compilation aren't seen as advantages in practice (in the VHDL world); the outspoken critics are respected consultants and trainers; possibly they are in one-man or small-team environments rather than million line projects. Possibly separate compilation was a big win when you had 8K of core and a drum store, but a bit less important nowadays? (coming back to "compilation is cheap" again) I'm in a one-man project environment myself, where I can't see a clear win for either side of the debate; separate compilation certainly doesn't impose significant drag, except where tool bugs prevent making good use of packages and libraries. But that's another issue... - Brian