Share the things you know about assembly,compiler,interpreter & executable file? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5

Share the things you know about assembly,compiler,interpreter & executable file?

I want to know about these things!

11th Jan 2018, 6:55 AM
Shadow Windster
Shadow Windster - avatar
3 Answers
+ 3
There are 2 types of programming languages: compiled and interpreted. C++, for example, is compiled. When you want to run your program, every source file gets transformed into an object file, written in machine language(assembly), by a compiler. Next, each object file is linked by a linker program and the final file is created, written in assembly. This is the executable file. Java, on the other hand, is interpreted. When you want to run the program, each .java file is transformed into a bytecode file, or .class file, by a compiler. Then, when you start the program, Java Virtual Machine (JVM) - an interpreter - takes each line of code, translates it into assembly and executes it. The advantage of an interpreter is that the program is not platform-dependent. If you have Windows 7 and you make a C++ executable file, you cannot run it on Linux, Mac OS etc. or with a different CPU. If you make a Java executable archieve (.jar), you can run it on any platform, as the JVM knows the system specifications. The disadvantage is that java programs are slower than c++ executables.
11th Jan 2018, 8:15 AM
Codrut
Codrut - avatar
+ 2
computer can only understand machine language. But it differs for different architecture,also its hard to understand and debug. So we came up with assembly, it is nothing more than english representation of machine language. so suppose 1 is instruction to move data from one address to another we can now do it using mov command in assembly. Now as computers can only understand machine language at its core we need to compile to ML, compiler for assembly is usually called assembler. But assembly is also not very easy to work with. So we came up with languages like fortran, b, bpcl, & c. These languages use more english like words.It was now much easier to write and debug program. These languages also need to be converted to ML in order to be executed. So a compiler compiles it. some 30-40 years back it was not done using compiler but by hand. You would write a program on paper, give it to people who will punch it on cards according to the program you wrote on paper & then these cards are made to run in the computers(compiler only automates this task). now an interpreter is similar to a compiler but the difference is compiler converts text to machine codes in advance so you can run it later on. An interpreter on the other other hand interprets the text to machine code during runtime. So you would need an interpreter during runtime to execute your commands. Note: compilers, interpreter & assemblers are also programs which are usually compiled and now you are using them for compilation.
11th Jan 2018, 9:00 AM
shobhit
shobhit - avatar
+ 1
simply compiler convert human language to machine language ,we need compiler because machine know only 0 and 1
11th Jan 2018, 7:34 PM
ajay
ajay - avatar