S
S
sirius_fantom2018-10-10 23:06:02
IT terminology
sirius_fantom, 2018-10-10 23:06:02

Source, Machine and Object Codes - Difference?

In C++ . Describe as clearly as possible what is the difference between these three concepts. Examples are welcome.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
stul5tul, 2018-10-11
@sirius_fantom

Source code or source code is text in a programming language that is written by a person (usually a person). This is a plain text file (usually).
But the processors in computers/smartphones, etc. are rather dumb devices that can only understand extremely simple machine code.
Therefore, any program is directly or indirectly converted from source code into machine code, and only after that it is executed by a computer / smartphone, etc.
Object code is an intermediate representation of the code. Still not machine, but not the original. Used at the stage of assembling a program from several pieces (possibly written in source code by different people and at different times).
Machine code - ready for execution. That is, just take it, nothing more is needed. Do a double-click, for example, and the program starts.
Source code example - easy:

package example

func Add(p int) int {
   return p + p
}

An example of object code and machine code is meaningless. Both object and machine codes of this program
are not intended for human reading.
This will look like abracadabra to you.
!<arch>
__.PKGDEF       0           0     0     644     30328     `
go object windows 386 go1.11 X:framepointer
build id "ZKpaYf_Flzmm6jns9NJp/RbNW-F32vdlI8SgqpfEX"
----


$$B
i

And this is not the whole object code - there is a large file.
Machine code is even more abracadabra, I couldn't even insert it here. The text editor does not skip this bunch of special characters, etc.
The chain you mentioned (source-object-machine) is about programming languages ​​compiled to machine code:
C/C++/Go/Rust/Pascal.
Some languages ​​are designed to be compiled to bytecode. It can not be called either machine or object. This is Java/Kotlin/C#. If this code were executed directly by the processor (CPU), it could be called machine code. But it is performed only through a special program.
The Ruby/Python/JavaScript languages ​​do not generate anything similar to machine code.

X
xmoonlight, 2018-10-11
@xmoonlight

Source - the source code of the program
Object - intermediate modules for assembly and linking into machine code
Machine - assembled object into executable instructions
220px-Linker.svg.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question