0

When is a compiled language more preferable to an interpreted language and vice versa ?

I know compiler compiles the whole code at once and produces the object code whereas interpreter interprets the code line by line. When is one more advantageous to to the other?

Michal Rosa
  • 2,459
  • 2
  • 15
  • 28

1 Answers1

1

Advantages of compiled languages :

  • Programs that are compiled into native machine code tend to be faster than interpreted code. This is because the process of translating code at run time adds to the overhead, and can cause the program to be slower overall.

Disadvantages of compiled languages :

  • Additional time needed to complete the entire compilation step before testing
  • Platform dependence of the generated binary code

Advantages of interpreted languages :

  • Interpreted languages tend to be more flexible, and often offer features like dynamic typing and smaller program size.
  • Also, because interpreters execute the source program code themselves, the code itself is platform independent.

Disadvantages of interpreted languages :

  • The most notable disadvantage is typical execution speed compared to compiled languages.

When one type of language is preferred over the other is based on the type of our application and our preference and priority like portability or cross-platform (interpreted may be preferred), speed or performance (compiled may be preferred) and various other factors.

One example :- If source code hiding is your priority- With natively compiled code the developer deploys the executable macine code of the program and data. With interpreted code the source code itself has to be deployed which can then be inspected and reverse-engineered wit much less effort than what it is to reverse-engineer native machine code .

But it will vary from task to task and also preference of the user/organization which will be using the language and would depend more on the functionalities provided by the language and how well its suited for that particular application rather than the type of language itself. There are lot of other factors that are enormously more consequential than compiled vs interpreted.

Also, if you are considering any software or website, they are seldom written in a single language. So, both the type of language - compiled and interpreted can be the part of same kind of application.

Community
  • 1
  • 1
Abhishek Bhagate
  • 5,583
  • 3
  • 15
  • 32