First, what is software? What is a program? What is a computer language?
Software: is a combination of one or more program files that perform certain functions.
Program: The instruction to complete the specified function.
Computer language: Communication between people uses natural language. A person communicates with a computer using a computer language. In other words, computer language is used to communicate with computers.
Voss: Program = data structure + algorithm
The relationship between programs and software is similar to the relationship between blogs and books in life.
The history of computer language
The computer language starts from the 1940s and is broadly divided into 3 stages:
First-generation computer language: Machine language: Machine languages are all composed of 0 and 1. Can be executed directly by the computer. However, such a language is not easy to understand and remember.
Second-generation computer language: assembly language: assembly language is not more advanced than machine languages. Because assembly language is actually a mnemonic of machine languages. Although assembly language is only a mnemonic, it is actually more readable than machine language.
Third-generation computer languages: high-level languages: high-level languages are closer to the natural language we normally use.
The high-level language takes 1980 years to be a dividing point: the language before the 80 is a structured language, and after 80 it is an object-oriented language.
Third, interpreter and compiler
Using the high-level language to write out the code, the computer can not be directly executed, the middle of the need for a translation process.
There are two types of translators:
Compiler: Converts the program we write to binary at once. Similar to life will be the whole foreign language book translated into Chinese.
Common compiler languages: C # Java
Interpreter: Row by line explanation. Similar to simultaneous interpretation.
Common Explanatory language: PHP JavaScript Ruby
Compiled languages are faster than explanatory languages. But explanatory language is more flexible than a compiled language.
Iv. Procedure Design Steps
To write a program similar to our building, we need some steps first.
(1) Analysis of problems
The first thing we need to do before we develop the program is to analyze the problem. We have to be clear about what the problem is. What are the user requirements?
(2) Determining data structures and algorithms
Data structure: How to store the information in a computer.
Algorithms: Methods and steps to solve problems
(3) Compilation procedure
Start tapping code to implement specific functions
(4) Debugging problems
99% of the code we write is going to be wrong. Next we need to debug these errors until the expected results are achieved.
To a certain extent, our code is not written, but debugged.
V. Common Types of errors
(1) Syntax error
This type of error is not compiled. This error is most likely to be found and modified.
(2) Logic error
This error is all in accordance with the syntax specification, the code can be compiled, but logical thinking problems, resulting in not getting the expected results. This kind of error is often difficult to find
(3) Development error
Often refers to the development of the time deviated from the user's needs
(4) Run error
Grammar, logic, and direction of development are all correct, and such errors often arise in the algorithm of the entire program. This algorithm leads to memory leaks, insufficient storage space, and so on. So this time we need to change an algorithm.
Six, the algorithm: the so-called algorithm, refers to the solution of the problem and the process.
The algorithm can be divided into two major categories: numerical arithmetic and non-digital arithmetic algorithm.
Numerical arithmetic: Solve the numerical value, get the answer of a numerical value
Non-numerical algorithm: often applied transaction management areas, such as search engines, additions and deletions to change
Features of the algorithm:
Generally speaking, the algorithm has 5 features:
(1) Poor sex
An algorithm should contain a limited number of steps and cannot be infinite.
(2) Certainty
Each step in the algorithm should be meaningful, not ambiguous, ambiguous.
(3) 0 or more inputs
Depending on the algorithm, some algorithms are summarized in the implementation process, and some raw data needs to be entered.
(4) One or more outputs
The ultimate goal of the design algorithm is to solve the problem, so that each algorithm should have at least one or more outputs.
(5) Validity
Each step can be executed effectively.
Seven, the expression of the algorithm
Algorithms are represented in many ways, for example: natural language notation, pseudo-code notation, flowchart notation, n-s notation.
(1) Natural language representation
is to use the language we usually use, such as Chinese, English to express the algorithm.
Example: Exchanging ink Bottles
First step: Need an empty bottle
Step two: Pour the black ink inside the black ink bottle into the empty bottle
Step three: Pour the blue ink inside the blue ink bottle into the empty black ink bottle
Fourth step: Empty bottle of black ink pour empty blue ink bottle
Fifth Step: Exchange complete
(2) pseudo-code notation
A way between a natural language and a computer language. Use some text and symbols to represent the algorithm.
Example: Exchanging ink Bottles
1th step: A: Black ink bottle B: Blue ink bottle C: Empty bottle
2nd step: a→c (black ink pour empty bottle)
3rd Step: b→a (blue ink pour into black ink bottle)
4th step: C→b (empty bottle of black ink pour into blue ink bottle)
5th step: End of Exchange
(3) Flowchart notation
The flowchart is also called a block diagram, which uses a set of graphs and process lines to represent the algorithm.
JS Programming Basics