Home > Backend Development > PHP Tutorial > Random Talk on Programming Languages

Random Talk on Programming Languages

WBOY
Release: 2016-07-25 08:43:31
Original
963 people have browsed it



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!



Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template