Notes on Computer Basics-Dynamic Language, Static Language, Scripting Language

Dynamic Language (Dynamic Language) and Static Language (Static Language) are the two main types of programming languages. They have different characteristics in language design and code execution. The following is a brief introduction to the characteristics of these two types:

Static Language

Static languages ​​are languages ​​that perform type checking at compile time. When writing a program using a static language, the type of the variable needs to be explicitly specified when it is declared, and type checking will be performed during the compilation phase. The compiler checks whether the variable's types match and whether there are potential type errors. If there is a type error, the compiler will issue an error during compilation and will not be allowed to generate executable code. Common static languages ​​include Java, C, C++, etc.

advantage:

  • Performing type checking at compile time can detect potential type errors early and avoid some runtime errors in advance.
  • It can provide better automatic code completion, refactoring and debugging support, enhancing development efficiency and code quality.

shortcoming:

  • More type declarations are required when coding, which may increase the code volume and coding complexity.
  • Program development and testing will be relatively more rigorous and may require more time.

Dynamic Language

Dynamic languages ​​are languages ​​that perform type checking at runtime. When writing a program using a dynamic language, the type of the variable does not need to be explicitly specified at the time of declaration, but the type is determined at runtime based on the value assigned to the variable. Dynamic languages ​​perform type checking during code execution. Common dynamic languages ​​include Python, JavaScript, Ruby, etc.

advantage:

  • Flexibility is high, and the flexibility of variable types allows for cleaner code.
  • Development can be faster, eliminating the need for some type declaration steps.

shortcoming:

  • Since type checking occurs at runtime, type errors may occur at runtime, making debugging more difficult.
  • The editor's auto-completion and refactoring support may be relatively weak and not as good as for static languages.

Summary:
Choosing a dynamic or static language depends on the needs of the project and the preferences of the development team. Dynamic languages ​​are generally more suitable for rapid prototyping and flexible projects, while static languages ​​are more suitable for large projects and scenarios with higher requirements for type safety and efficiency. Each language type has its advantages and disadvantages, and in practical applications, appropriate choices need to be made based on specific circumstances.

scripting language

Scripting Language is a programming language mainly used for writing scripts. It is usually used to automate specific tasks or execute a series of instructions. Compared with compiled languages, scripting languages ​​do not require explicit compilation steps, but are interpreted and executed line by line at runtime.

Scripting languages ​​have the following characteristics:

  1. Interpreted execution: The script language is interpreted and executed line by line at runtime, without the need for explicit compilation steps. Code can be interpreted and executed line by line rather than compiled into machine code ahead of time.

  2. Flexibility: Scripting languages ​​are generally flexible, allowing variables, functions, and data structures to be dynamically added or modified at runtime.

  3. Dynamic typing: Variables in scripting languages ​​usually do not need to be typed when declared; their types are dynamically determined based on the values ​​assigned to them.

  4. Cross-platform: Scripting languages ​​are usually cross-platform and can run on different operating systems, as long as the corresponding interpreter or runtime environment is installed.

  5. Imperative programming: A scripting language is usually an imperative programming language in which programmers write a series of instructions to achieve a specific task.

  6. Versatility: Scripting languages ​​are widely used in automation tasks, rapid prototyping, batch scripting, configuration file processing, web development, data processing, and text processing.

Common scripting languages ​​include:

  • Python: A concise, easy-to-read and write high-level programming language that is versatile and suitable for a variety of tasks.
  • JavaScript: Used primarily for front-end web development, but can also be used for server-side development.
  • Ruby: An elegant, easy-to-read and write programming language widely used in web development.
  • Shell scripts (such as Bash): used for automation and batch tasks on the operating system.
  • PHP: Mainly used for server-side web development, especially for interacting with databases.

Scripting languages ​​often have concise and readable syntax, as well as rich library and tool support, making them ideal for daily tasks and rapid prototyping. However, due to the characteristics of interpreted execution, scripting languages ​​may not be as efficient as compiled languages ​​in terms of execution efficiency. Therefore, in scenarios that require high performance and strict type checking, you may want to choose a compiled language.

non-scripting language

Non-scripting languages ​​usually refer to compiled languages. Unlike scripting languages, the code of compiled languages ​​needs to go through the compilation process of a compiler before execution, converting the source code into a machine code (or bytecode) file, and then executed by the computer's processor.

Compiled languages ​​have the following characteristics:

  1. Compilation process: When writing a program using a compiled language, the programmer first writes the source code file, and then needs to use a special compiler to convert the source code into machine code or bytecode files. This process is called compilation. The compiler will perform strict type checking and optimization on the code and generate executable files or intermediate code.

  2. Execution efficiency: Because compiled languages ​​perform type checking and optimization during the compilation phase, their execution efficiency is usually higher. The machine code generated by compilation can be executed directly on the computer without further interpretation.

  3. Static typing: Compiled languages ​​are usually statically typed, meaning that the types of variables need to be specified explicitly during the compilation phase. The compiler will perform type checking at compile time to ensure type safety.

  4. Cross-platform issues: Since the machine code generated by compilation is related to a specific hardware architecture, some compiled language executable files cannot run directly on different platforms. Need to be compiled separately for different platforms.

Common compiled languages ​​include:

  • C: A general-purpose, high-level programming language widely used for system and application development.
  • C++: It is a programming language developed on the basis of C language. It supports object-oriented programming and is also widely used in system and application development.
  • Java: Although Java is also a compiled language, it uses intermediate bytecode as an intermediate form and is executed through the Java Virtual Machine (JVM) to achieve cross-platform functionality.

Compared with scripting languages, compiled languages ​​have the advantage of high execution efficiency and strict type checking, making them suitable for projects with high performance and type safety requirements. However, the development cycle of compiled languages ​​is usually longer and requires compilation and linking processes, which may be slightly more cumbersome than the real-time execution of scripting languages. When choosing a programming language, the appropriate choice should be made based on the specific project needs and the technical reserve of the development team.

Guess you like

Origin blog.csdn.net/qq_40140808/article/details/131991689