In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Today, the editor will share with you the relevant knowledge of what the Python computer is composed of. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article. Let's take a look at it.
I. computer composition
computer has become the core device of our time, and we need it all the time. It is no longer the desktop or server that people think of, but has evolved into any object around us, such as mobile phones, tablets and laptops, and many people do not realize it subjectively. But the actual equipment does contain "computer" devices, such as televisions, microwave ovens, cars, and even intelligent robots for children to play with. It is no exaggeration to say that the computer has become an extension of the human body, the extension of the brain, has become an indispensable part. In the future, the computer will really enter the human body, enter the brain, and really become a part of the human body. For example, in the sci-fi movie Matrix, when the protagonist is stuck in the neck with a super needle, he can learn quickly, change the brain's neural network and become a kung fu master in a few seconds. Computer, commonly known as computer (Computer), is an electronic machine used for high-speed computing. It is one of the greatest scientific and technological inventions in the 20th century. It can not only carry out numerical calculation and logical judgment, but also have the functions of storage, memory and data processing. A complete computer system consists of hardware and software systems, as shown in the following figure:
1.1 hardware system
hardware system can be divided into mainframe and peripherals, which refers to the physical entities that make up the computer system, which are mainly composed of a variety of electronic devices and electromechanical devices. From the ENIAC (the world's first computer) to the most advanced computer, the hardware system is designed using the von Neumann architecture, as follows:
Arithmetic unit: responsible for the arithmetic and logical operation of data, that is, the processing of data
Controller: the central nervous system of a computer that coordinates the work of various components of the computer as well as access to memory and peripherals
Among them: the arithmetic unit and the controller are collectively referred to as the central processing unit, namely CPU
Memory: a part that performs memory functions to store information such as programs, data, commands, and various signals, and to provide such information when needed.
Input device: to input information such as programs, original data, text, characters, control commands or data collected on the spot into the computer
Output device: to output the intermediate or final results generated by computer processing, including various data symbols, text, control signals and other information
1.2 Software system
software system can be divided into system software and application software, which refers to all kinds of programs needed to ensure the normal operation of the computer, and is the main object of our programming practice, which is composed as follows:
System software: to ensure the normal work and performance of computer hardware, and to provide computer users with an intuitive, friendly and convenient interface.
Operating system: system software that is convenient for users to control and manage computer software and hardware resources, with complex functions, and is the basis and core of the normal operation of all software.
Compiler: also known as a language processor, which translates programs written by programmers in various programming languages, such as Java and Python, into machine languages that can be executed by computers.
Application software: application software is the part of software provided by computers to meet the needs of different users. it can broaden the application field of computer systems and improve the performance of hardware.
Social office category: Wechat, QQ, WPS, Tencent Conference, Nail, Momo, etc.
Leisure and entertainment: QQ Music, Tencent Video, Steam, Happy fighting landlords, etc.
II. Program operation mechanism
machine language, also known as machine code, is a set of instructions that can be analyzed and executed through CPU. Computers can only recognize machine codes of 0 and 1, and cannot receive machine codes similar to Chinese, English or other human languages. Therefore, in order to realize the interaction between human and computer, a variety of programming languages came into being, such as C++, Java, PhP and Python and so on.
2.1 compiled and interpreted
Analysis: can the computer directly recognize the following Python code?
"" Analysis: can the computer directly handle the following Python code output in the console? "" print ("Hello world!") # print () is a built-in function in Python, which is mainly used to output the contents in parentheses, similar to System.out.println ("Hello world!") in Java.
obviously, the above code consists mainly of English letters and punctuation marks, but as mentioned earlier, the computer can only recognize machine codes (0 and 1), that is, it does not recognize this code at all.
so, how do we control the computer to work through code?
The process of human-computer interaction is like when a local communicates with a foreigner. If both parties want to understand each other's ideas, they need an intermediary that can transform each other's language into a language that they can understand in some way, and vice versa. Therefore, if a computer wants to understand the code we write, it needs to convert it into machine code that it can recognize, and according to the conversion process, programming languages are divided into compiled and interpreted types.
Compiled: compiled language can directly convert the code into machine code that the computer can recognize and execute, such as C++.
Interpretive: interpretive languages first convert code into bytecode, and then translate it into computer-recognizable machine code, such as Python.
2.2 flow of computer processors
The user opens the program and the program begins to execute
The operating system sends the program content and related data into the computer memory.
CPU reads instructions from memory according to the program content.
CPU analyzes, processes instructions, and prepares for the next instruction
Read the next instruction, analyze and process it, cycle through until all the instructions in the program are processed, and finally put the calculation result into the memory address specified by the instruction.
2.3 History of computer language
algorithm is the soul of computer, and programming language is the tool that makes computer have soul. With the development of computer hardware, computer programming language has also experienced the evolution from low-level to high-level, and the core idea of each change is to "make people easier to program". The faster the speed, the smaller the size and the lower the cost of computer hardware, the more scenarios will be applied to human society, then the more complex the algorithm will be, and the more advanced the computer programming language will be. ENIAC, which initially weighs dozens of tons but can only operate 5000 times a second, can only do very small applications, such as ballistic calculations. Today, the computing power of anyone's mobile phone can beat the sum of all the computing power of the earth in those days. The easier the language is, the more people use it; the more people use it, the more people collaborate; the more people collaborate, the more complex objects can be created. In modern society, it is possible for a software to cooperate with dozens or hundreds or even thousands of people, which naturally provides a "human basis" for the development of complex software. This is a common social phenomenon of human beings, the easier it is to use tools, through the use of a number of people, through the cooperation of a large number of people, completely change an industry and even human society. The next 30 years will be a world of software talents. In addition to ordinary software, a large number of artificial intelligence software, such as autopilot, robot babysitter and robot girlfriend, will come into our lives. Even computer technology and genetic engineering are combined to achieve immortality. Interested people can read the brief History of the Future: from Homo sapiens to Homo sapiens.
Machine language: the primitive stage equivalent to human beings
machine language consists of all instructions made up of numbers. When you are asked to write hundreds or even thousands of numbers in digital programming, you can boldly predict that "100% of the programmers will have mental problems." Machine language usually consists of strings of numbers (eventually reduced to binary zeros and ones), and machine language is too cumbersome for humans. Using machine language, humans cannot write complex programs.
Assembly language: the Handicraft stage equivalent to Human beings
for the convenience of programming and solving more complex problems, programmers began to improve the machine language, using English abbreviations of mnemonics (words) to represent basic computer operations. These mnemonics form the basis of assembly language, such as LOAD, MOVE, etc., which make it easier for people to remember and use them. It feels much better to recognize hundreds of words than hundreds of numbers. Assembly language is equivalent to human handicraft society, which needs extremely skilled craftsmen, but the development efficiency is also very low. Although assembly language can write efficient programs, it is not easy to learn and use, and it is difficult to debug. Another complex problem is that assembly language and early computer languages (Basic, Fortran, etc.) do not consider structured design principles, but use Goto statements as the main method of program flow control. The consequence of this is that a lot of confusing transfer statements make the program almost impossible to read. For programmers of that era, being able to understand the code they wrote last month was a challenge. Even so, assembly language is still used in the field of industrial electronic programming, software encryption and decryption, computer virus analysis and so on.
High-level programming language: equivalent to the stage of human industry
for simple tasks, assembly language is competent. However, with the development of computers and their gradual penetration into all aspects of work and life, some complex tasks have emerged. Assembly language appears to be inadequate (it should be said that programmers use assembly language to solve complex problems). As a result, there are high-level languages, such as C++, Java and so on. The more advanced the language is, the closer it is to human thinking, and the more convenient it is to use it. High-level languages, especially object-oriented languages, such as Java, Python, etc., make programming more and more difficult and difficult. At present and for the foreseeable future, computer languages are still in the "third generation high-level language" stage, which allows programmers to write programs using instructions close to everyday English. For example, to implement a simple task: A+B=C, the implementation using machine, assembly, and high-level languages is as follows:
III. The birth and development history of Python language.
Python is a dynamic data type, object-oriented interpretive language, which is mainly used in various fields of artificial intelligence, such as machine learning, crawler and data analysis, deep learning, computer vision and so on.
TIOBE programming language ranking:
3.1 birth and development
Background: hardware limitations
Author of Python, Guido von Rossum (Guido van Rosum), Dutch. In 1982, Guido earned a master's degree in mathematics and computer science from the University of Amsterdam. However, although he is a mathematician, he enjoys the fun of computers more. In his words, although he has both math and computer qualifications, he always tends to do computer-related work and is keen to do anything related to programming. At that time, Guido came into contact with and used languages such as Pascal, C, Fortran and so on. The basic design principle of these languages is to make the machine run faster. In the 1980s, although there was a wave of personal computers (personal computer) in IBM and Apple, the configuration of these PCs was very low. For example, in the early Macintosh, only 8MHz's CPU main frequency and 128KB's RAM, a large array can fill up memory. The core of all compilers is to optimize so that the program can run. In order to improve efficiency, language also forces programmers to think like computers so that they can write programs that better suit machine tastes. At that time, programmers wanted to squeeze every inch of the computer with their hands. Some people even think that C language pointers are a waste of memory. As for dynamic types, automatic memory management, object-oriented... Forget it, it will paralyze your computer.
Shell: essentially calling commands, it's not a real language.
is a programming style that bothers Guido. Guido knows how to write a function in C, but the whole writing process takes a lot of time, even if he already knows exactly how to implement it. His other option is shell. As the interpreter of UNIX system, Bourne Shell has existed for a long time. UNIX administrators often use shell to write simple scripts for system maintenance, such as regular backups, file system management, and so on. Shell can be like glue, connecting many functions of the UNIX system together. Many programs with hundreds of lines of C language can be completed in only a few lines under shell. However, the essence of shell is to invoke commands, and it is not a real language. For example, shell does not have numeric data types, and addition operations are complex. In short, shell can not fully mobilize the functions of the computer.
ABC language: readable and easy to use, with obvious disadvantages
Guido wants to have a language that, like C, can fully invoke the computer's functional interface, and can be programmed easily like shell. The ABC language gives Guido hope. ABC was developed by the Institute of Mathematics and computer Science in the Netherlands. Guido works at the institute and is involved in the development of the ABC language. ABC language is for the purpose of teaching. Unlike most languages at the time, the goal of the ABC language was to "make users feel better". The ABC language hopes to make the language easy to read, use, remember and learn, so as to stimulate people's interest in learning programming.
however, the ABC language compiler requires a high computer configuration to run, and the users of these computers are usually proficient in computers, so they are more concerned with the efficiency of the program than the difficulty of learning it. On the other hand, the following fatal design problems are the reason why it has not become popular:
Poor scalability: ABC is not a modular language, and if you want to add functionality to it, such as support for graphics, you need to change a lot.
IO cannot be done directly: ABC cannot directly manipulate the file system, that is, it cannot read and write data directly. The difficulty of input and output is fatal to the computer. Can you imagine a sports car that can't open the door?
Overinnovation: ABC expresses the meaning of programs in the form of natural language. For example, it uses How to to define a function, while programmers are more used to using function or define.
Propagation difficulties: the ABC compiler is very large and must be saved on tape, which means that if you want to use it, you must first prepare a large tape.
Python gestation and growth: an easy-to-learn and fully functional language between C and Shell
in 1989, to spend the Christmas holiday, Guido began to write a compiler for the Python language. The name Python comes from Guido's beloved TV series Monty Python's Flying Circus. He hopes that the new language called Python will meet his ideal: a fully functional, easy-to-learn, extensible language somewhere between C and shell. Guido, as a language design lover, has tried to design language. This time, it is only a pure hacking behavior.
in 1991, the first Python compiler was born. It is implemented in C language and can call the library files of C language. From birth, Python has had classes, functions, exception handling, core data types including tables and dictionaries, and module-based extension systems. A lot of Python syntax comes from C, but it is strongly influenced by ABC language. Some rules from the ABC language are controversial to this day, such as mandatory indentation, but these grammatical rules make Python easy to read. On the other hand, Python wisely chose to obey some conventions, especially those of the C language, such as restoring equal sign assignments. Guido believes that if something is established in "common sense", there is no need to get too tangled up. Python has been particularly concerned about extensibility from the very beginning. Python can be extended at many levels. At a high level, you can import .py files directly. At the bottom, you can reference the library of the C language. Python programmers can quickly use Python to write .py files as extension modules. But when performance is an important consideration, Python programmers can go deep into the bottom, write C programs, compile them into .so files and introduce them into Python. Python is like building a house with steel, defining a large framework under which programmers are quite free to expand or change.
The original Python of was developed entirely by Guido himself. Python was welcomed by his colleagues in Guido. They quickly give feedback on how to use it and participate in the improvement of Python. Guido and some of his colleagues form the core team of Python. They spend most of their spare time on hack Python. Subsequently, Python expanded beyond the institute. Python hides many technical details to the compiler and highlights the programming thinking at the logical level. As a result, Python programmers can spend more time thinking about the logic of the program than the specific implementation details. This feature attracted a large number of programmers, and Python became popular. Computer hardware is becoming more and more powerful and Python is easy to use, so many people begin to turn to Python. Guido maintains a mail list,Python user to communicate via email. Python users come from many fields, have different backgrounds, and have different requirements for Python. Python is quite open and easy to expand, so when users are not satisfied with the existing functions, it is easy to expand or transform Python. These users then send the changes to Guido, and it is up to Guido to decide whether to add new features to Python or the standard library. It would be a great honor if the code could be incorporated into Python itself or the standard library. Because of Guido's supreme decision-making power, he was called the "benevolent dictator for life". On July 12, 2018, after completing PEP (Python Enhancement Proposals) 572, Guido decided to withdraw from the core decision-making layer of Python.
The powerful capabilities of Python and its standard libraries are the contributions of the entire community. The developers of Python come from different fields, and they bring the advantages of different areas to Python. For example, regular expressions (Regular expression) in the Python standard library refer to Perl, while functions such as lambda, map, filter, reduce, and so on refer to Lisp. Some of the functions of Python itself and most of the standard libraries come from the community. Python's community is growing, leading to its own newsgroup, website, and fund. Since Python 2.0, Python has changed from mail list development to completely open source development. The community atmosphere has been formed, the work is shared by the whole community, and Python has achieved more rapid development. Today, the framework of Python has been established. Python language organizes the code with the object as the core, supports a variety of programming paradigms, adopts dynamic types, and automatically collects memory. Python supports interpretive operation and can be extended by calling the C library. Python has a powerful standard library. As the standard library system has been stable, so the ecosystem of Python began to expand to third-party packages. These packages, such as Django, web.py, wxpython, numpy, matplotlib, PIL, upgrade Python into a species-rich tropical rainforest.
Python, which advocates beauty, clarity and simplicity, is an excellent and widely used language. Python ranks eighth on the TIOBE list. It is the third largest development language of Google, the basic language of Dropbox, and the server language of Douban. As a representative, the development history of Python can bring us a lot of enlightenment. The community plays an important role in the development of Python. Guido thinks he is not an omnipotent programmer, so he is only responsible for making frameworks. If the problem is too complicated, he will choose to go around it, that is, cut the corner. These problems are ultimately solved by others in the community. There are so many talented people in the community that some people are willing to deal with things that are a little far away from development, such as creating websites and raising funds. Today's project development is becoming more and more complex and large. Cooperation and an open mind will be the key to the ultimate success of the project.
Python has learned a lot from other languages, whether it's ABC, which is already in history, or C and Perl, which are still in use, and many other languages that are not listed. It can be said that the success of Python represents the success of all the languages it borrows from. Similarly, Ruby borrows from Python, and its success also represents the success of some aspects of Python. Every language is a hybrid, has its advantages, but also has a variety of defects. At the same time, the judgment of a language "good or bad" is often subject to external reasons such as platform, hardware, times and so on. Programmers have experienced many language battles.
3.2 Design philosophy
Get Python design philosophy: after successfully installing Python software (next project), open any editing environment and type import this to run it.
Summary: simple, elegant and scalable, practical flat is the key, the best solution only one???
3.3 advantages and disadvantages
Advantages:
Easy to learn and extensible: reading a good Python program is like reading a beautiful article, although it is very strict, such as forced indentation to improve the readability of the code. This pseudo-code nature of Python allows us to focus more on problem-solving logic than on understanding the language itself, such as low-level details such as memory management. If we want a piece of critical code to run faster (C is more than 50 times faster than Python) or if we want some algorithms not to be made public, we can write some programs in C or C++ and call them in Python programs.
Free and open source portable: Python is one of the FLOSS (Free / Open Source Software), which means we are free to release a copy of the software, read its source code, make changes to it, and use some of it in new free software. Because of its open source nature, Python can be ported to many computer platforms, such as Windows, Linux and so on.
Object oriented: Python supports both process oriented programming and object oriented programming. In a "process-oriented" language, programs are built from procedures or simply functions that are reusable code. In an "object-oriented" language, programs are built from objects that are a combination of data and functions. Compared with other programming languages such as C++ and Java, Python implements object-oriented programming in a very powerful and simple way, and encapsulation, inheritance and polymorphism are the key to becoming a god.
Dynamic language: dynamic language, also known as weakly typed language, means that a variable does not need to declare a type when it is created, and the specific type is determined according to the data type in the memory unit pointed to, that is, the type is what it points to. In contrast, static languages (strongly typed languages) need to declare types when defining variables, and the data types that can be stored in the memory units that the variables point to are fixed. For example, an integer variable is defined as num = 10 in Python and int num = 10; in Java. Summary: dynamic type, point variable, content in memory unit immutable; static type, point immutable, content changeable.
Interpretive language: compiled languages, such as programs written by C++, can be converted from source files (C++) to a language used by your computer, that is, binaries (0 and 1). This process is done through the compiler and different tags and options. When we run the program, the connection reloader software copies our program from the hard disk to memory and runs it. Programs written in Python do not need to be compiled into binary code. We can run the program directly from the source code. Inside the computer, the Python interpreter converts the source code into an intermediate form called bytecode, which is then translated into machine code used by the computer and run. Since we only need to copy our Python program to another computer, it will work, which makes it easier to port Python programs.
Rich libraries: including standard libraries and third-party libraries that come with Python. The standard library of Python can help us deal with all kinds of work, including regular expression, document generation, threading, database, HTML, GUI and so on. This is called Python's "full-featured" concept. In addition to standard libraries, Python also supports the installation of third-party libraries, such as wxPython, Twisted, and Python image libraries.
Cons: the Python language is perfect and has no obvious shortcomings and shortcomings. The only deficiency is the slow execution efficiency, which is common to interpretive languages, but this defect will be weakened with the continuous improvement of computer hardware performance.
3.4 Application scenarios above are all the contents of the article "what are the components of Python computers?" Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.