Learning a New Programming Language Part 1: Getting Started - Interpreted vs. Compiled
(Page 5 of 5 )
Interpreted scripting languages are now being used in areas that once were the sole domain of lower level application languages such as C or C++. If you aren't familiar with the difference, it's pretty simple to understand.
A language such as C or C++ is translated into code that a computer can understand using a compiler application. The syntax of a compiled language, or any other programming language, is there for your convenience only. It gives you an interface to issue commands to a computer that is as close to human language as can be managed and still allow the desired functionality.
An interpreted language is normally not compiled, but run as is by an application (usually written in C or maybe assembly) called an interpreter. The interpreter handles the communication between your code and the computer at run time (when your program runs). At one time this was considered a much slower approach, but it has its advantages.
One of the biggest advantages is that, when you are developing and debugging an application, there is no need to compile your code to test what may be a minor bug. Other advantages include speed of development and increased control over code execution at run time.
When you program in C, all you have is the core language. The core C language is plenty powerful, but you must do everything from scratch unless you use another programmer's work in the form of a code library.
In contrast, an interpreted language comes with many functions built into the interpreter that extend beyond the core language. For instance, if you want to trim the white space from either side of a string in PHP, you use a built in function called trim(). This is much easier and faster than writing it yourself. Using these functions is fast and easy. There is no need to write a function like that when someone else already has.
The increasing speed of computer systems has actually erased significant speed differences in many operations between interpreted and compiled languages. In addition, the software engines that drive these scripting environments often provide extensibility through compiled C and C++ code to allow functionality to the system that still requires the speed of a compiled language. This provides the best of both worlds.
A skilled PHP coder, for instance, can go far if they know both C and PHP. This would enable them to code and compile their own extensions that take advantage of features not available in the core PHP language. It also could allow them to contribute to the PHP language itself if they were so inclined, by becoming a part of that project. This goes for many of the more popular or even less popular languages today. Most of these are open source projects.
Some languages, such as Java and C#, are compiled into what is called "byte code," which is an intermediate level between straight language interpretation and full compilation to machine code. An application called a "Virtual Machine" or "VM" is then used to interpret the byte code. In some cases, this approach runs faster.
In the next installment we will examine object oriented, procedural and functional language types.
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |