Directory of this document
- First, computer knowledge
- Development history of programming language
- Iii. A brief History of C language
- Iv. features of the C language
- V. The role of C language
- Version issues in the six and C languages
The basics of iOS development, such as learning what to prepare for iOS development, the outlook for iOS development, and so on, have been described earlier. In the beginning of this talk said: In fact, iOS development is to develop Iphone\ipad software, and to develop a software, first of all to learn the programming language. iOS development needs to learn the main programming languages are: C language, C + +, objective-c, where C + +, Objective-c are based on the C language, derived from the C language. Starting with this, we are temporarily throwing away the knowledge of iOS and learning about the legendary C language. Formal study before, first remind a sentence: Learning a language grammar is more boring things, very much like in the study is equal to a few, it is impossible to say, learning C language grammar process can immediately make some good-looking iphone interface effect. We should sink to live gas, so-called Kujinganlai, no grammar accumulation, how to write a good-looking interface?
Back to the top one, computer knowledge
Before you learn the C language, you need to know some computer knowledge
1. Computers can only recognize 0 and 1
- As we all know, the computer to power to work, plainly speaking, it is the same as TV, washing machine, are electrical appliances. Electrical appliances all have a common ability: know how to judge power or power, power can work, power off to stop working. Thus, fundamentally, a computer can only recognize electrical signals: high-level signals (power-on), low-level signals (power outages), which only knows whether a switch is powered on or off. We use 1 for the high level and 0 for the low level.
- It also says that computers can only recognize 0 and 1.
2. Binary
Because computers can only recognize 0 and 1, the commands and data that the computer recognizes are represented by binary numbers (0 and 1). The so-called binary, is to use 0 and one to represent all the numbers. But the most commonly used in our daily life is the decimal, with 0~9 to represent all the numbers
1> binary directives
By instilling instructions on the computer, it can perform the appropriate operation, and the computer can only recognize instructions made up of 0 and 1. In the early days of computer development, the computer's instruction length was 16, that is, 16 binary numbers (0 or 1) to form an instruction, for example, with 1011011000000000 this instruction, is to let the computer to do an addition operation. Therefore, if you want a computer to perform a series of operations, you have to write a number of 0 and 1 instructions, as you can imagine, this workload is so huge.
2> binary Data
Some of the data we store in our computers, such as documents, photos, videos, etc., are stored in the form of 0 and 1. It's just that the computer parses this whole heap of 0 and 1, and presents the data in the form of a graphical interface to our eyes.
Back to top second, the development of programming language
We can use the programming language to write programs, and then run the compiled program to the computer, the computer can be as described in the program to do. Since the birth of computer, the programming language has undergone 3 stages of development: machine language, assembly language, high-level languages. Among them, C is a high-level language.
1. Machine language 1> What is machine language
In the early days of the calculator, all computer programs were written directly using the binary instructions that the computer could recognize, meaning that all the code was 0 and 1. This programming language is "machine language". These binary instructions, made up of 0 and 1, are also called "machine instructions."
2> Advantages
- Since the code written by the machine language can be directly recognized by the computer, the machine language is directly to the hardware, and the execution efficiency of the program is very high.
- Machine language can directly access and control the computer's various hardware devices, such as disk, memory, CPU, I/O port and so on.
3> Disadvantages
- In machine language programming, programmers must first memorize all the instructions and instructions of the computer used, instructions and more difficult to remember.
- The program is all 0 and 1 of the instruction code, poor readability, but also error-prone.
- Because the machine language is directly to the hardware, the dependence on the hardware is very strong, so different models of computer machine language is not the same. In other words, if 2 different models of machines want to achieve the same function, you need to write 2 sets of completely different code.
It can be seen that machine language is difficult to master and promote, now in addition to computer manufacturers of professionals, the vast majority of programmers have no longer to learn machine language.
2. Assembly language 1> What is assembly language
- Because of the various disadvantages of machine language, the development efficiency is seriously affected, and then the assembly language is appeared behind. Assembly language is actually symbolic machine language, it uses a symbol (English words, numbers) to represent a machine instruction. For example, in machine language, with 1011011000000000 this instruction is to let the computer do an addition operation, and in assembly language, in the English word "ADD" can represent the addition operation. A meaningful English word, obviously more than a bunch of smelly and long binary instructions, intuitive to remember more.
- Because the computer can only recognize 0 and 1, the code written in assembly language can not be recognized by the computer, like just the "ADD", the computer must not know what the meaning. Therefore, the code written in assembly language needs to be translated into binary instructions before it can be recognized by the computer. This translation work is given to the "compiler" to do.
2> Advantages
- Comparison of machine language, assembly language code readability good
- assembly language, like machine language, can directly access and control the computer's various hardware devices, such as disk, memory, CPU, I/O port. With assembly language, you can access all the hardware and software resources that can be accessed.
- The target code is short (the target code is the binary code that is translated by the compiler), which consumes less memory and executes faster. (All programs in the computer run in memory, so the performance of the memory affects the computer very much.) It is used to temporarily store the operational data in the CPU, as well as the data exchanged with external memory such as the hard disk. As long as the computer is running, the CPU will transfer the data needed for operation into memory, and when the operation is completed, the CPU will transmit the result, and the running of the memory determines the stable operation of the computer. The memory of the computer is limited, so an application runs with as little memory as possible.
3> Disadvantages
- Assembly language is machine-oriented and is typically designed specifically for a particular computer or series of computers. Therefore, different machines have different assembly language syntax and compilers, the code is not portable, that is, a program can only be run on one machine, to other machines can not run.
- assembly language symbols are very many, difficult to remember, even the completion of simple functions also require a lot of assembly language code, it is easy to produce bugs, difficult to debug
- The use of assembly language must be very understanding of the hardware, development efficiency is very low, long and monotonous cycle
3. Advanced language
Because the assembly language relies on hardware, the code portability is poor, the symbols are many and difficult to remember, so humans invented a very close to natural language high-level language. The C language to learn later is the high-level language.
1> Advantages
- Simple, easy to use, easy to understand, syntax and structure similar to ordinary English, and away from the direct operation of the hardware, so that the average person after learning can be programmed, not too familiar with the hardware knowledge
- The written procedure is more concise. For example, to calculate the 2 number of the and, in the high-level language can be written very concise: d=a+b;. But in machine language and assembly languages, several or even dozens of instructions are required, and different machines have to write different instruction codes.
- The same program written in a high-level language can also be run on different machines with portability
2> Note
Programs written in high-level languages cannot be directly recognized by the computer and need to be translated into binary instructions by the compiler before they can be run on the computer
Back to the top iii. brief History of C language
- The C language was invented in 1972 and was first used to rewrite the Uinx operating system (Unix was written primarily in assembly language, which laid the foundation of the operating system)
- With the success of Unix operating system, C language has been greatly promoted, has been used in large, medium and small, micro-host, is still the world's most popular, the most widely used high-level programming language One
- C language is a process-oriented language, non-object-oriented language. (What is the process-oriented, object-oriented, for the time being not to understand, just need to know that C language is process-oriented OK)
The following is the March 2013 popular leaderboard for programming languages
Since the birth of C language, its heat has not been reduced, the top two are basically Java and C
Back to the top four, C language features 1. Rich operators
The basic function of a computer is computing, so the computational power of a programming language is very important. The C language provides 34 operators, which are extremely rich in computational types, including the most basic subtraction operations.
2. Rich data types
- The vitality of C language is strong, a large part of it is because it has a rich data type.
- Because the C language data type is rich, the computing ability is very strong, so many databases are written in C language, such as DB2, Oracle and so on.
3. Can operate the hardware directly
Like assembly language, C can directly manipulate the hardware, allowing direct access to bits, bytes, addresses (Bits, bytes, address is the most basic computer work unit), can say that there is almost no C language to do things.
4. High-efficiency target code
The target code is a binary code that is translated by the compiler. The target code of the C language is very efficient to execute.
5. Good portability
Programs written in the C language in one environment can be migrated to another completely different environment without modification or modification.
All of the above are the advantages of the C language, and it has a very obvious drawback: grammar restrictions are not strict. This results in a beginner's understanding of the C language grammar, and there are many easy-to-ignore problems in the development process.
Back to the top v. role of the C language
- Because C language has the powerful data processing ability, and allows direct access to memory address, directly to the hardware operation, it is suitable for writing system software, graphics processing, microcontroller program, embedded system development and even for scientific research.
- A lot of games are written in C language.
- Many of the underlying operating systems are written in C, such as Android
Back to top six, C language version issues
Since the success of UNIX operating system, C language has been widely used, from large mainframe to small microcomputer, have C language active figure, also derived a lot of versions of C language. In the long run, C language will probably become a multi-variant, loose language. A formal language, must have a standard to do, otherwise it will be out of order. In order to change this situation, the United States National Standards Bureau (American Nation Standards Institute, abbreviated as ANSI) set up a committee to begin work on the C language standard. 1989 C language Standard is approved, this version of the C language standard is commonly referred to as ANSI C
C Language Chapter 11