In this guide, I will try to explain the difference between compiled and interpreted languages and offer some pros/cons of each.
--Definitions--
Compiled Language: A compiled language is a programming language that uses a compiler to process your source code into machine code to be used on a particular type of processor (for example, programs compiled on a x86 Intel/AMD processor will not usually work on a PowerPC processor like those found in older Macs). Compilers are usually able to optimize compiled code significantly, resulting in speedy code.
Examples of compiled code include C/C++, Delphi/Pascal and Assembly.
Interpreted Language: An interpreted language, on the other hand, is executed by a program called the interpreter. With the interpreter, a source file can be directly executed, without having to be compiled first. The interpreter reads the source file and figures out what machine instructions to execute, so that it essentially translates your source code into machine code on-the-fly without compilation.
Examples include: Python, Perl, PHP, Java and Shell Scripting.
Compiled languages typically give the programmer a much higher degree of control over the allocation of memory and the nitty-gritty of memory access. Interpreted languages usually have memory allocation handled mostly or entirely by the interpreter.
This difference also explains why compiled languages are usually considered "low" to "medium" level languages, while interpreted languages are "high-level" languages. High level languages are "farther away" from the system, while low to medium languages operate closer to the system.
Pros of interpreted languages:
- Rapid prototyping - programmers spend less time working with low-level ideas and more time building algorithms
- Simplicity - it is usually easier to understand high-level code due to it's inherent ability to "hide" complicated low-level workings
- Ready access to hundreds of prebuilt libraries of code, for things like graphics manipulation
- Simple to implement certain tasks, such as string or array manipulation, which require far more work to do in compiled languages
Cons of interpreted languages:
- Slow, possibly high memory usage
- Some interpreted languages execute only source code; compiled languages can be distributed with only the binary and not the source
- Interpreted languages depend on an interpreter to be present, which may be difficult to fulfill for the end-user
This is by far not a complete list, but it should give you an idea of why you should know one of each type of language.
If you only knew a compiled language, you might find it difficult to complete many of the Permanent Programming challenges because many require a good algorithm, and implementing algorithms is easiest in an interpreted language due to rapid prototyping, while using a compiled language may take a lot of time.
If you didn't know a compiled language, it would be hard to make super-fast and efficient programs - many end users would prefer fast and lean programs over a program which is slow and requires an interpreter.
So, there are benefits to knowing both. Knowledge is power, as they say!
Cast your vote on this article *Note: the order of the votes has been reversed.
Comments: Published: 11 comments.
By: Loucetios - 05:25 pm Wednesday September 12th, 2007
Good article. Python actually comes with a compiler now called exemaker.
By: eljonto - 05:50 pm Wednesday September 12th, 2007
really? i wish perl came with one. i really dont want to pay for perlapp and all other perl compilers suck. nice article though
By: wspider - 07:47 am Thursday September 13th, 2007
Cool, I always thought, it was just a hybrid between the two kinds of programming languages.
By: nneonneo - 02:22 pm Thursday September 13th, 2007
@Loucetios: It is worth noting that exemaker is _not_ a compiler. It simply creates a loader for the .py file.
There is a library called py2exe which will produce full featured, independent EXEs for Windows.
Java is the really bad combination (opposing perl) which is mainly compiled (except it lacks some huge things like speed optimized speed and it depends upon the program executer java.)
Anyway java is kind 60% compiled and interpreted for the rest which is a bad combination it was made for the old Sun Unix platform which means that it was supposed to close source the language, but now that they are open source they should be reconsidering....
But anyway java isn't fully compiled only partially.
It is very confusing yes.
Not too sure what the guy above me is trying to say, but java is a bytecode compiled language. Essentially, bytecode compilation creates a form of binary code that the interperter (in this case the JVM) can easily read and execute.
nneonneo you are the BEST and only BEST in hts with Kane same level probably
This site is the collective work of the
HackThisSite staff. Please don't reproduce in part or whole without permission.
Page Generated: Tue, 14 Oct 2008 02:12:15 -0500 Exec:
9