answersLogoWhite

0


Best Answer

The advantages are that the compiler can see each translation unit as a whole and can therefore optimise the resultant machine code accordingly. For instance, trivial functions that are accessed often, such as array suffix operators, can benefit from inline expansion, thus eliminating the need for an otherwise costly function call.

Also, constant expressions can be evaluated at compile time using compile-time evaluation. For instance, consider the following code:

constexpr int fac (constexpr num) {

return num==1?1:fac (num-1);

}

void f() {

int x {fac (7)};

// ...

}

A good compiler will replace the recursive function call fac(7) with the constant value 5040.

In addition, compilers (along with the corresponding linker) help eliminate many common errors such as static type errors, syntax errors and linkage errors. They can also test programmer's assumptions through static assertions. The more errors detected and eliminated at compile time, the fewer errors there will be at runtime, which will primarily consist of logic errors.

The disadvantage of compilers is that compilation can take a long time, particularly with large projects. Each time the program is modified, it must be recompiled. compilation times can be reduced by precompiling headers that are not expected to change very often, creating intermediate files that are much faster to compile. There is also no need to recompile translation units that are unaffected by changes in code, most of which only occur due to changes with a common header. Nevertheless, a non-trivial application can still take several minutes to produce a working executable and the more time spent compiling the less time you can spend debugging the runtime logic.

Interpreted languages are executed in real-time without the need for compilation. However, execution times are very much slower due to the need to constantly translate high-level source code into low-level machine code.

There are, however, languages that are both compiled and interpreted. Java is a typical example. The source code is first compiled to an intermediate code known as Java byte code which can then be interpreted by the Java virtual machine to produce the machine code. Unlike traditional compilers which produce native machine code that only runs one the architecture it was intended for, Java byte code is completely portable and can be executed upon any machine with a suitable Java virtual machine implementation, which is pretty much everything these days. However, interpreted languages (including Java) are not suitable for low-level programming, they are only suitable for applications programming. Compiled languages such as C and C++ are suitable for all types of programming, hence they are termed general purpose languages.

User Avatar

Wiki User

8y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

11y ago

Using run-time languages or frameworks such as .NET, allow the compiled applications to be smaller in size as the common workings are in the framework. If there becomes updates to the framework, it could potentially cause problems with the application.

Using fully compiled applications, such as from Delphi, allow the apps to not have to depend on a framework and contain all they will need.

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

They produce programs that run very fast.

They can spot syntax errors during compile time of the program.( i.e you are informed of any grammatical errors before you try to run a program).

This answer is:
User Avatar

User Avatar

Wiki User

9y ago

Well, an Assembler is made to be used with the Assembly language, transferring it to machine code. A Compiler is used for any one specific language, and also transferring it to machine code. Compilers can be for any .NET languages, Ruby, Python, Java, anything. If you want to specifically learn 6502 Assembly or anything else pertaining to that, go for an Assembler. Otherwise, you're wasting time.

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

if our college teacher will study u compiler than there is many disadvantages otherwise compiler having alot of advantages......

This answer is:
User Avatar

User Avatar

Wiki User

15y ago

Yahoo.com

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What are the advantages and disadvantages of a compiler?
Write your answer...
Submit
Still have questions?
magnify glass
imp