www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Why is one d file compiled into two files object file & executable.

reply "Venkat Akkineni" <venkatram.akkineni gmail.com> writes:
Hi

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.

Please point me to any detailed documentation u may have 
regarding object files.

Also does D have any facilities for dynamic code generation & 
compilation ?

Thankyou
Sincerely
Venkat
Feb 10 2015
next sibling parent "Andre Artus" <name.surname gmale.com> writes:
On Wednesday, 11 February 2015 at 05:08:16 UTC, Venkat Akkineni 
wrote:
 Hi

 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.
Hi Venkat, The object files are kind of an intermediate format produced by the compiler, to be used by the linker in generating the executable.
 Please point me to any detailed documentation u may have 
 regarding object files.
If you wish to learn more the following Wikipedia article is a reasonable starting point. http://en.wikipedia.org/wiki/Object_file
 Also does D have any facilities for dynamic code generation & 
 compilation ?
Yes, it does. D has good support for meta-programming, look at http://ddili.org/ders/d.en/ under the template and mixin sections, and also http://qznc.github.io/d-tut/meta.html
Feb 10 2015
prev sibling next sibling parent reply "Kagamin" <spam here.lot> writes:
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.
Feb 10 2015
parent reply "Andre Artus" <name.surname gmale.com> writes:
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.
Feb 11 2015
parent reply "Kagamin" <spam here.lot> writes:
On Wednesday, 11 February 2015 at 08:49:40 UTC, Andre Artus wrote:
 First to  mind is that in Java .class files are executable (in 
 Java runtime), while object files are not.
There was a library, which could load object files with D code, resolve symbols and execute it.
Feb 11 2015
parent "Kagamin" <spam here.lot> writes:
http://www.dsource.org/projects/ddl
Feb 11 2015
prev sibling parent "jklp" <jklp nowhere.fi> writes:
On Wednesday, 11 February 2015 at 05:08:16 UTC, Venkat Akkineni 
wrote:
 Hi

 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.

 Please point me to any detailed documentation u may have 
 regarding object files.

 Also does D have any facilities for dynamic code generation & 
 compilation ?

 Thankyou
 Sincerely
 Venkat
It's not D-specific, every compiler for a compiled language produces objects: http://en.wikipedia.org/wiki/Object_file
Feb 11 2015