answersLogoWhite

0


Want this question answered?

Be notified when an answer is posted

Add your answer:

Earn +20 pts
Q: Why do we need to translate a source code in to the machine code?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Why do need translate a program written a high level language into machine language?

the reason why we translate is that source code may be in assembly( low level language) or high level language and the only language computer understand is 0s and 1s which is binary code so the program written in either assembly or high level language must be convert or translate to binary and program written in HLL are in English form while the assembly are equivalent machine language.


Why is there a need for compiler?

Compilers are needed to convert human readable source code into machine executable code.


Why there is need of translators?

Translators are used to translate code in one language to another. There is a need of translators because computers understand machine language so they convert HLL into machine language.


What translator is needed for C programming language?

To translate the C source code program, you need a program called a "C compiler".


Why do you need a programming language to communicate with a system?

Writing programs using the machine's native language (machine code) is laboriously time-consuming and highly prone to human error. Every high-level concept must first be translated into low-level instructions. Moreover, machine code is machine-dependent; porting code between machines requires that the code be entirely re-written from scratch. Assembly languages make writing machine code simpler, however the code remains non-portable and everything must still be written in minute detail at the machine-level. High-level programming languages allow the programmer to work in a more machine-independent manner using high-level abstractions that are easy for humans to understand, making it much easier for programmers to translate concepts into code. The computer itself can be programmed to translate (compile) the high-level language into the required machine code, thus the same source code can be recompiled on any computer with a suitable compiler implementation.


What does compiler mean in programming?

A compiler is a program that converts the language into machine code, also known as binary (1s and 0s). Not all programming languages need compilers. Some are assembly and still others can just be straight and utter machine code.


How do you compile a file in C?

First you need to create a text file containing the source code written in the C language. Then, you call the compiler to check the syntax of your source code and translate it into machine code. The exact means of calling the compiler depends on the operating system you are using and the vendor of the C compiler. For example, in some Unix systems the C compiler may be called as: cc CC xlC xlC_r aCC gcc and others ...


Why are machine and assembly languages known as low level languages?

Machine code isn't just low-level, it is the native language of the machine; the only language the machine actually understands. When we say low-level or high-level we are referring to the amount of abstraction between the source code and the machine code. The source code must be translated into machine code and the more closely that code resembles the machine code the more low-level it is. Assembly is extremely low-level because there is very little in the way of abstraction; the assembly instructions map 1:1 with the machine code. C is also low-level because C statements map very closely to the machine code, but offer a higher level of abstraction than assembly. Assembly language is machine-dependant because every type of machine requires its own distinct version of assembly language whereas C's slightly higher level of abstraction means it can be used to write non-machine-dependant code, more portable code. However, the source code must be recompiled for each machine. Java, on the other hand, is extremely high-level because the source code bears no resemblance whatsoever to the machine code. Indeed, the source code does not even compile to machine code it compiles to Java byte code suitable for interpretation by the Java virtual machine. In other words, the source code is compiled against a non-existent machine, but one that has common architecture across all platforms that support Java (which is pretty much everything today). This makes the code extremely portable because the Java virtual machine handles the low-level conversion from the Java byte code to the physical machine's native code; the same byte code can be executed upon any platform without the need to recompile.


Why do compiler writers need formal grammars?

Just as a person requires knowledge of the syntax (structure) and semantics (meaning) of a spoken language, so too does the compiler need to "understand" how to interpret what is being given to it. A formal grammar provides the rules of syntax and semantics.


Which compiler is best compiler and why in computer graphics?

Compilers have nothing to do with graphics. Compilers translate source code into object code, nothing more. Graphics is hardware-dependant and is a function of a graphics library specific to that hardware. Graphics libraries do not need to be compiled, they simply need to be linked to your code.


Why do you need programming language?

Without programming languages it would be impossible to program a computer to perform a specific task, let alone reprogram it to perform a variety of different tasks. Machine code is the native language of the machine and is therefore a programming language in its own right (in the early days of computing, it was the only language available). Even if we couldn't reprogram the machine, we'd still need some means of providing it with the machine code that would determine the computer's function, even if that means encoding those instructions on a permanent memory chip such as a ROM. This necessitates that we also need to know which "dialect" of machine code the machine specifically understands, because machine code is a machine-dependent language. That is, the machine code to program one type of machine cannot be used to program another type of machine -- each has its own specific version of machine code. We can, of course, use low-level and high-level languages that we can more easily understand, but in order for the computer to be able to understand those languages we must still program it to translate the source code to its native machine code, which means we need a programming language. In the absence of any other programming languages, we must use machine code -- which is exactly what we used with the very first computers. Once we have one translation program, we can use it to create newer and better translators, newer and better languages. Today, we can use virtually any high-level programming language on any machine in order to produce machine code for any other machine. But it all started with just one machine and one programming language -- machine code.


Why are translators used to translate the computer programming languages?

They are not translators, they are either compilers or interpreters. High-level source code cannot be executed in its native form, it must be converted to machine code, the native language of the computer. Compiled languages compile the entire source code into a standalone machine code executable. Once compiled, the executable can be transferred to other computers. Interpreted languages require additional software, an interpreter, to execute. So long as a machine has the required interpreter, the source code can be executed. This is achieved by converting statements to machine code one statement at a time. C++ is an example of a compiled language and is used to produce much of the software running on computers today. Some versions of BASIC, such as QBASIC, are interpreted. Source code is not compiled, it is interpreted by the QBASIC interpreter which is built into the code-editor. Java is an example of a language that is both compiled and interpreted. Rather than compiling to machine code it compiles to byte code which can then be executed by the Java Virtual Machine. Java programs are highly portable as they need only be compiled once and can be executed on any device that has a JVM. By comparison, C++ programs must be compiled separately for each platform. That is, a Microsoft Windows executable will not run on an Apple Mac -- the source code must be compiled separately for each. Such code must be crafted to cater for each platform, with filters to exclude or include platform-specific code as appropriate for the current compilation.