Python self-study notes -2

Why do we need a programming language

The market a lot of programming languages, and different, but no matter what language you use to write programs, one thing you need to know - that is, the computer is actually running series of computer instructions. Direct manifestation of the sequence of instructions is a series of 0 and 1, which is the machine code. Not part of the machine code programming language, so the execution of the program is language-independent, computer imperceptible your language at runtime.

Since the practical implementation of computer programs and language-independent, so why should something come out of this language?

Obviously with the machine code of 0 and 1 These two characters to programming it is difficult and inefficient. In order to improve production efficiency, we need an easy writing and reading of tags to express machine code instructions. Use this program code is marked, then the complete coding these tags translated into machine code. Initially achieve this assembly language, assembler programming language is a language, but a low-level programming language, has a more direct one to one relationship between it and the machine code.

Extended: This "more direct one to one relationship" how to understand it? For example, you can even look-up table by the way, come to assembly language  MOV AX,66H corresponding to the hexadecimal machine code  B866, which is binary  1011100001100110.

So assembler  MOV AX,66H and machine code  1011100001100110 , respectively. This result can be reversed derivation.

Hex how transfer binary? With Python manual is not going to forget, execute Python code is  bin(int('B866', 16)) easy to get results.

With the development of computer technology, computing and storage capacity increased gradually, people on the program to be increasingly high, began to pursue a more diverse and more complex functions, assembly language development efficiency gradually stretched. Thus the evolution of a series of high-level programming languages ​​such as Fortran, Pascal, and the current widespread use of C, Java, Python and so on. It is called high-level programming language, because they are compared to machine code and assembly language have a higher level of abstraction, while there is no clear correlation with the machine code.

Expansion: the computer world "abstract" the word for shield the interior of the complicated details of direct contact with its core function, to establish a more efficient use of external entrance and method of operation easier to use.

After the article "abstract" The word is frequently mentioned, because it is the computer technology in a very important and instructive of a concept.

Why are there so many high-level language? Each language to use because there are different ideas and scenarios are designed. E.g:

  • C has a very high efficiency, and the efficiency of the development of so-so, in some areas and highly dependent on the efficiency of the underlying control champion, such as operating system development.
  • Java JVM to the aid across different operating systems and computer architecture and run Java programs. Java also has a good efficiency and stability, its efficiency compared with the C language, you can keep up on the same order of magnitude.
  • Java and Python and C have different large compared, Python is an interpreted language, there is no explicit compilation process, interpreted code may be directly executed by an interpreter, and the help of an interpreter, the code may be cross-platform operation. On the other hand it is a dynamic language that is more flexible to some extent. Python's philosophy is elegant and simple, although the efficiency of Java and C compared to about one to two orders of magnitude slower, but Python development efficiency is several times higher than they are.

Level language features of the program

There are so many different languages ​​different from, what their essence is it? In essence, these programming languages ​​are machine code or assembly language level of abstraction, abstracted from a variety of language features, you can use a more efficient way to express instructions to the computer.

Language core features

Instruction complete expression of the computer will only use a portion of the features of the language, here we called this part of the characteristics is a core feature. Although each language has a different way of expression (grammar), but the core features of expression, has a similar pattern, they can be said to be a common feature for most languages. Core features include:

  • type of data
  • Values ​​and compare
  • Variable definition, assignments
  • Arrays, strings
  • Branch Jump
  • cycle
  • function

Language Extension Properties

In addition to these core features necessary in order to make a stronger expressive language and ease of use, each language has its own characteristics some extensions. As used in Python are:

  • Exception mechanism
  • class
  • Module package
  • Built-in data structures
  • Built-in functions
  • Iterator
  • Builder
  • Decorator
  • Functional characteristics
  • Dynamic type
  • As well as other commonly used language features

Description: Although unusual mechanism, classes, modules and language extensions package is characteristic, but they are very common and unavoidable feature of Python is, when these three chapters organized into chapters core features language to be introduced.

Language and knowledge surrounding function

In addition to the core features and expansion characteristics, language general will integrate a number of functions other than language features, or associated with some of the language-related knowledge, here we call them the language and knowledge surrounding features. Such as the common:

  • Standard Library
  • IO operations
  • Process thread
  • Serialization
  • Code Specification
  • And operating environment-related, such as the Python interpreter, virtual environment, Java's JVM, etc.

These peripheral knowledge and function strictly speaking outside the scope of language features, but closely related and language, some of which are useful and even indispensable. They are usually operating system, framework, content related to the operating environment.

There are gradations of language features, there is also the focus of study

The above content is to let everyone have a comprehensive understanding of programming languages, so learning can be targeted. That particular how to learn Python it?

First, the core features of learning is the focus of this part is not much. Once you master the core features of the language, you can write a program to do all the computing functions. General characteristics if not controlled, subsequent learning as castles in the air.

Secondly, the characteristics of language extensions learning better. Expand language characteristics substantially increase the expressive power of language, so that the development can significantly reduce the amount of code to enhance the development efficiency. But the extension property is very complicated, there are many minutiae of things, some not necessarily be used in the development, it is not required to develop the characteristics of a language to fully grasp, simply grasp the commonly used part of the time in which to learn, other parts in the future the gradual accumulation of daily use can be.

Finally, the peripheral functions of language knowledge and language features do not belong to the category, but for some of them to learn knowledge is necessary. The standard library and IO operations in a large number of system calls the package, provides entrance into the program and the operating system (or outside the system) interactions. Further standard library also contains a large number of highly efficient and stable ready-code save the effort of the user create the wheel.

In fact, whether to learn Python or to learn other languages, understand the level of language features, and then have focused on learning, this is the only way to effectively master a new language. We will also take this as context to carry out the follow-up of Python programs for everyone.

Guess you like

Origin www.cnblogs.com/lindongjiangzhi/p/12325444.html