Home Backend Development PHP Tutorial Random Talk on Programming Languages

Random Talk on Programming Languages

Jul 25, 2016 am 08:43 AM




Written in front: We know that the programming paradigms of existing languages ​​are: procedural, object-oriented, functional, and logical. With the popularization of software industrialization and the increasing complexity of software, the development history of programming languages ​​has also evolved from the initial procedural (imperative) language c to the object-oriented language represented by java programming language. Logic programming languages ​​ ( represented by prolog) and functional languages ​​ (lisp series) are also mostly used in academic and artificial intelligence fields. In recent years, with the advent of multi-core, the era of cloud computing has emerged. Functional programming languages ​​are gradually emerging. The most classic languages ​​​​are represented by scheme, common-lisp, ml, clojure, go.And the recent jdk8 has also gradually added functional, closure, lambda, etc. Grammar, and the authors of scala are increasingly advocating that coders approach coding with functional language thinking. It can be seen that the development of programming languages ​​is constantly changing to meet the changes of the times. From the development process, we can see that the development of technology is developed around solving the basic need of "complexity of software".

1. Overview of Programming Language
Programming language is a symbol of a computer and a language for communication between humans and computers. When we learn a new programming language, what characteristics of the language should we observe? The author of the book "SICP" listed three points:

* primitive elements.
* means of combination.
* means of abstraction.

The above three features basically cover the features of all programming languages, and they are also something that a language designer must consider from the beginning. My understanding of these three points: primitive elements represent the basic symbols of the language (basic data types, keywords, etc.), which is the lexical part. Means of combination is a means of constructing large-scale programs through the process of combination using basic elements. Different languages ​​provide different means of combination. Means of abstraction means abstraction. Abstraction is an important means to solve the complexity of software and improve the readability, scalability, reusability, etc. of the software. The following will compare language characteristics from the perspective of combined elements and abstraction methods.

2. Combination means
Assembly language: It is the simplest lexical and grammatical form, and is called a low-level language. The assembler translates the assembly code into native code (cpu instruction set) through the process of literal translation. The primitive elements provided include: numbers, characters, -, +, *, /, case, if, break, go, instructions and other basic elements; these elements are combined into computer execution sequence symbols.

汇 C language is more advanced than the assembly language, allowing programmers to leave the work of the CPU, register, and memory directly, providing more combination methods: such as array, structure and other data structures.

The Java language claims to be an object-oriented language, so it goes one step further than the C language and uses a powerful type system to combine properties and methods.

The go language is very similar to the ML language, with "interface", "higher-order function", "closure", "duck type", "returning multiple values", and provides goroutine, etc. for combination.

The prolog language is completely a logic language for pattern matching. His thinking is based on: All the theorems in the world are derived from the simplest theorem, just like the basis of mathematics is "1+1=2", and only then can the laws of "universal gravity" and "relativity" be derived.

The lisp dialect uses s-expression (the famous S-expression) to combine data and functions. There is no distinction between data and functions in Lisp, everything is data.
IThe outsider: LISP dialect is in line with the thought of Turing machine. When encoding, you can't feel the computer architecture. Other languages ​​are more designed based on von Loyman's calculation and storage ideas, either a "stack" structure or a "register" structure.

3. Abstraction means
Starting from the C language, functions are used as units to provide an abstraction of the program. This greatly improves the reusability and modularity of the program. Make teamwork coding possible too.

Object-oriented programming: Basically hiding the details of the computer, developers abstract specific business through objects. But strictly speaking, java also belongs to the category of imperative-lang and is called by value. In comparison, Python and Ruby are more object-oriented. Python combines object-oriented and functional programming paradigms and is closer to natural language.

Functional languages ​​represented by lisp: Functions are the basic and only abstraction; common-lisp also develops a set of object-oriented programming methods based on macros. I prefer functional programming concepts: no side effects of functions (no need to consider thread safety, especially for perverted Haskell), higher-order functions, closures, lambdas, etc.

4. Type system
People often say: JavaScript is a weakly typed language, and Java language is a strongly typed language. It's also interesting to differentiate programming languages ​​from a type system perspective. Generally speaking, weakly typed languages ​​are more like natural languages, and their grammar is also more free and lively. The trend of today's languages ​​​​is also trending in the direction of weak types.

Computers are highly structured, and an error in a binary bit on the stack will lead to overflow, bus and other errors. Therefore, freedom at the language level benefits from the compiler or interpreter. For example, languages ​​such as Java and C have strong compile-time type detection mechanisms. The benefits of strong typing drive coders to write code with few syntax and semantic errors. The support for IDEs is also convenient, which is the cornerstone of cooperation for large technical teams.

                Weakly typed languages ​​allow us to gain freedom (no type information is required) and allow programmers to type a lot less keyboard keys. Freedom comes at a price, and type inference (infer type) is built into the compiler or interpreter; (type inference uses the normalization method, based on the explicit type of variables, operators, return values ​​and other information in the context, using the stack and The type is deduced through the process of gradual replacement.) Although weak types can be easily compiled (or do not need to be compiled but interpreted and executed), there is also a type checking process, but this process is delayed until runtime. Therefore, weakly typed languages ​​are not very structured, it is difficult to ensure correct types when coding, and IDE support is difficult. However, some analyzers can continuously detect syntax and semantic errors, which is equivalent to achieving the IDE effect of a strongly typed language. In recent years, the direction of language has gradually moved away from computer architecture and evolved in the direction of natural language. Programmers can freely describe it with code like artists.

5. Compilation/Interpretation
Is the Java language interpreted or compiled? It's hard to say, from the process of the procedural javac compiler from java source code -> class byte code. However, the process of executing byte code on the JVM may be interpreted or compiled. Both the interpreted and compiled types internally follow the process of compilation principles: lexical analysis -> syntax analysis -> semantic analysis -> compiler backend -> native code process. But they have their own advantages:

Interpreter: Loads code quickly; the interpreter needs to maintain information such as runtime context. So the necessary code is loaded and the fragment is interpreted and executed. However, it would be redundant to go through the compilation process for the same code, resulting in a waste of time.

Compiler: Fast execution. Moreover, the compiler back-end is also easier to optimize the intermediate code, because the optimization process is a structured process: it is often necessary to traverse the entire intermediate code, optimize the code as a whole, and improve operating efficiency.

Runtime: Generally speaking, interpreted languages ​​need to maintain runtime context information in memory to serve the search, binding, scope, etc. of variables during the running process. Compiled languages ​​execute code based on the register stack model. Basically, data binding is completed in the stack structure, and the running speed is slightly faster.

                      hotspot-jvm combines the respective advantages of interpretation and compilation; it first interprets the execution process. If the method is executed frequently and reaches a hotspot, jvm will start the compilation process, compile the sub-code into native-code, and then cache it , the next call can be executed directly. hotspot-jvm executes bytecode based on stack instructions, which is also based on cross-platform considerations at the expense of register instructions; (the dalvik virtual machine based on the android operating system is based on register instructions);
Therefore, the design of the language is often It is a balancing process; the more "freedom" you gain, the greater the "sacrifice".

6. Summary: 初 In order to solve Leibnitz's proposal: Whether there is a general model to solve the proposition of all computing tasks, and invented the Turing theory. Until von Leyman simulated the thinking process of human brain neurons and produced the first computer based on memory and arithmetic unit, ENIAC. So far, computer hardware technology has not changed substantially. It is just that with the collapse of Moore's Law, people have developed multiple levels of Cache, multi-core, and multi-CPU technologies are used to support increasingly larger computing tasks. In this process, as people continue to study logic, semiotics, and algorithms, the languages ​​used to interact with computers are becoming more and more abstract and rich. We use this image symbol to abstract time and space, use this image symbol to solve the complexity of software, and use this image symbol to communicate our thoughts to the computer.


Due to restrictions on uploading attachments and text, sometimes some pictures and text may not be displayed. For details, please see: http://mp.weixin.qq.com/s?__biz=MzI5ODI3NzY2MA==&mid=100000725&idx=2&sn=fde9b2af17a00679c89f3f6fc8be64c8#rd
Everyone is welcome to communicate.
Scan the QR code below to get more and more beautiful articles! (Scan the QR code to follow for unexpected surprises!!)



Random Talk on Programming Languages You are also welcome to join [Everyone Technology Network Discussion QQ Group], group number: 256175955, please note your personal introduction! Let’s talk about it together!



Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1664
14
PHP Tutorial
1266
29
C# Tutorial
1239
24
PHP and Python: Comparing Two Popular Programming Languages PHP and Python: Comparing Two Popular Programming Languages Apr 14, 2025 am 12:13 AM

PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

PHP in Action: Real-World Examples and Applications PHP in Action: Real-World Examples and Applications Apr 14, 2025 am 12:19 AM

PHP is widely used in e-commerce, content management systems and API development. 1) E-commerce: used for shopping cart function and payment processing. 2) Content management system: used for dynamic content generation and user management. 3) API development: used for RESTful API development and API security. Through performance optimization and best practices, the efficiency and maintainability of PHP applications are improved.

Explain secure password hashing in PHP (e.g., password_hash, password_verify). Why not use MD5 or SHA1? Explain secure password hashing in PHP (e.g., password_hash, password_verify). Why not use MD5 or SHA1? Apr 17, 2025 am 12:06 AM

In PHP, password_hash and password_verify functions should be used to implement secure password hashing, and MD5 or SHA1 should not be used. 1) password_hash generates a hash containing salt values ​​to enhance security. 2) Password_verify verify password and ensure security by comparing hash values. 3) MD5 and SHA1 are vulnerable and lack salt values, and are not suitable for modern password security.

PHP: A Key Language for Web Development PHP: A Key Language for Web Development Apr 13, 2025 am 12:08 AM

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

What are HTTP request methods (GET, POST, PUT, DELETE, etc.) and when should each be used? What are HTTP request methods (GET, POST, PUT, DELETE, etc.) and when should each be used? Apr 09, 2025 am 12:09 AM

HTTP request methods include GET, POST, PUT and DELETE, which are used to obtain, submit, update and delete resources respectively. 1. The GET method is used to obtain resources and is suitable for read operations. 2. The POST method is used to submit data and is often used to create new resources. 3. The PUT method is used to update resources and is suitable for complete updates. 4. The DELETE method is used to delete resources and is suitable for deletion operations.

Explain the difference between self::, parent::, and static:: in PHP OOP. Explain the difference between self::, parent::, and static:: in PHP OOP. Apr 09, 2025 am 12:04 AM

In PHPOOP, self:: refers to the current class, parent:: refers to the parent class, static:: is used for late static binding. 1.self:: is used for static method and constant calls, but does not support late static binding. 2.parent:: is used for subclasses to call parent class methods, and private methods cannot be accessed. 3.static:: supports late static binding, suitable for inheritance and polymorphism, but may affect the readability of the code.

How does PHP handle file uploads securely? How does PHP handle file uploads securely? Apr 10, 2025 am 09:37 AM

PHP handles file uploads through the $\_FILES variable. The methods to ensure security include: 1. Check upload errors, 2. Verify file type and size, 3. Prevent file overwriting, 4. Move files to a permanent storage location.

How does PHP type hinting work, including scalar types, return types, union types, and nullable types? How does PHP type hinting work, including scalar types, return types, union types, and nullable types? Apr 17, 2025 am 12:25 AM

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values ​​and handle functions that may return null values.

See all articles