Why is one d file compiled into two files object file & executable.

Andre Artus via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Feb 11 00:49:39 PST 2015


On Wednesday, 11 February 2015 at 07:42:31 UTC, Kagamin wrote:
> On Wednesday, 11 February 2015 at 05:08:16 UTC, Venkat Akkineni 
> wrote:
>> I am coming from Java. What is the purpose of an object file & 
>> why is it generated at compile time in addition to an 
>> executable. I know C generates an object file too, but I don't 
>> know what the use is.
>
> Java uses a similar process: it has to generate .class files 
> before they can be packed into a .jar file.

I thought about making that analogy myself, but then decided that 
it is likely to be more confusing than helpful. There are 
similarities, but there are also  numerous distinctions.

First to  mind is that in Java .class files are executable (in 
Java runtime), while object files are not.

A .jar file is just a organized collection of .class files (in a 
compressed container). In that sense a .jar file is perhaps more 
akin to a .lib file.


More information about the Digitalmars-d-learn mailing list