Compiled languages
Many of the traditional programming languages, such as Fortran, Ada, Pascal, C, C + +, and Java, are compiled languages. These languages require that the source code that we have written be converted into a target tag (object codes), and this process is called "compiling".
When you run the program, read the object code directly. Because the compiled object code is very close to the bottom of the computer, the execution is very efficient, which is the advantage of a compiled language.
However, since most of the compiled languages work on the ground floor, dealing with bytes, integers, floating-point numbers, or other machine-level objects, it is often necessary to implement a simple function that requires a lot of complex code. For example, in C + +, it's hard to do simple things like "copy all files from one directory to another."
Interpreted language
Interpreted language is also known as the "scripting language". when executing such a program, The interpreter (interpreter) needs to read the source code that we wrote and convert it to the target (object), which is then run by the computer. Because each execution of the program is more than the compilation process, so efficiency has decreased.
The advantage of using scripting languages is that they are mostly run at a higher level than the compiled language and can easily handle objects such as files and directories, and the disadvantage is that they are often less efficient than compiled languages. However, the tradeoff is that scripting is usually worthwhile: a simple script that takes one hours to write, the same functionality written in C or C + +, can take up to two days, and, in general, the speed of the script execution is fast enough to let people ignore its performance problems. Examples of scripting languages are awk, Perl, Python, Ruby, and Shell.
When to use the shell
Because the shell appears to be a common feature between UNIX systems and is standardized by POSIX. As a result, shell scripts can be applied to many systems once they are "written attentively". Therefore, the reason to use shell scripts is based on:
- Simplicity: The shell is a high-level language through which you can express complex operations succinctly.
- Portability: Using POSIX-defined features, scripts can be executed on different systems without modification.
- Easy to develop: a powerful and 妤 script can be completed in a short period of time.
However, given the command restrictions and efficiency of shell scripts, the following situations do not typically use the shell:
- resource-intensive tasks, especially when you need to consider efficiency (e.g., sorting, hashing, etc.).
- Mathematical operations that need to handle large tasks, especially floating-point operations, precision operations, or complex arithmetic operations (which are typically handled using C + + or FORTRAN).
- There are cross-platform (operating system) porting requirements (typically using C or Java).
- Complex applications where structured programming must be used (requires variable type checking, function prototypes, etc.).
- For mission-critical applications that affect the overall system.
- Tasks that require a high level of security, such as requiring a robust system to prevent intrusion, cracking, malicious destruction, and so on.
- A project consists of various parts of a chain of dependencies.
- Large-scale file operations are required.
- Support for multidimensional arrays is required.
- Support for data structures, such as linked lists or numbers, is required.
- Graphical interface GUI needs to be generated or manipulated.
- Requires direct operating system hardware.
- I/O or socket interface required.
- Interfaces that require the use of libraries or legacy old code.
- Private, closed-source applications (shell scripts put the code in a text file, as the world can see it).
If your app fits any of the above, consider a more powerful language-perhaps Perl, Tcl, Python, ruby--, or a higher-level compilation language such as C + + or java. Even so, you'll find that using the shell to prototype your application is also very useful in the development steps.
Compiled/interpreted language, when to use the shell