1.源代码:
源代码是指由人员/程序员生成的高级代码或汇编代码。源代码易于阅读和修改。它是由程序员使用任何人类可读的高级语言或中级语言编写的。源代码包含供程序员更好理解的注释。
源代码提供给语言翻译器,后者将其转换为机器可理解的代码,称为机器代码或目标代码。计算机不能理解直接的源代码,计算机可以理解并执行机器代码。它被认为是计算机的基本组成部分。简单来说,我们可以说源代码是一组指令/命令和语句,它们是由程序员使用诸如C,C++, Java, Python,汇编语言等计算机编程语言编写的。因此,用任何编程语言编写的语句都被称为作为源代码。
2.目标代码:
目标代码是指机器可以理解的低级代码。目标代码是在经过编译器或其他转换器之后从源代码生成的。它是可执行的机器代码格式。目标代码包含中央机器理解并执行的一系列机器可理解的指令。
目标文件包含目标代码。它被视为另一种机器代码。一些目标文件示例是常见的目标文件格式(COFF),COM文件和“ .exe”文件。它是编译器或其他翻译器的输出。我们可以理解源代码,但不能理解目标代码,因为它不是源代码形式的纯文本,而是二进制格式。
下图说明了源代码和目标代码:
源代码和目标代码之间的区别:
S.No. | SOURCE CODE | OBJECT CODE | |
---|---|---|---|
01. | Source code is generated by human or programmer. | Object code is generated by compiler or other translator. | |
02. | Source code is high level code. | Object code is low level code. | |
03. | Source code is written in plain text by using some high level programming language. | Object code is translated code of source code. It is in binary format. | |
04. | Source code is human understandable. | Object code is not human understandable. | |
05. | Source code is not directly understandable by machine. | Object code is machine understandable and executable. | |
06. | It is written in high level language like C, C++, Java, Python etc or assembly language. | It is written in machine language through compiler or assembler or other translator. | |
07. | It can be easily modified. | It can not be modified. | |
08. | It contains comments for better understanding by programmer. | It does not contain comments for understanding by machine. | |
09. | It contains less number of statements than object code. | It contains more number of statements than source code. | |
10. | It is less close. towards machine. | It is more close towards machine. | |
11. | Performance of source code is less than object code as it is less close towards machine. | Performance of object code is more than source code as it is more close towards machine. | |
12. | Source code is input to compiler or any other translator. | Object code is output of compiler or any other translator. | |
13. | Source code is not system specific. | Object code is system specific. | |
14. | It can be changed over time. | Source code needs to be compiled or translated by any other translator to get modified object code. |