The text/hao

primers

Before WRITING this article, I want to put up a picture





In fact, the programming principle is very simple, as we all know, our computers, whether mobile phones or PCS, are not beyond the von Neumann architecture. The bottom layer is made up of two potentials, zero and one, and all of our programming instructions eventually have to be zero and one for the computer to understand them. We know that the CPU is only responsible for calculation, not intelligence itself. You type in a command, it runs once, and then it stops and waits for the next command. These instructions are binary, called opcode, and this is what the puncher inputs. A series of operation instructions form a set of instruction set (ISC). At present, the common instruction set in the world includes RISC (simple instruction set) and CISC (complex instruction set). Simply put, a simple instruction set specifies only very simple binary processor instructions, and complex instructions are only the most basic combination of instructions. Complex instruction sets themselves have a very large instruction set library, many built-in instruction libraries, only need to call. The former mainly represents the ARM architecture, while the latter mainly represents the X86 architecture. The ARM architecture is popular in the mobile and 5G era due to the low power consumption brought by the simple core.

Classical layering

Of course, binary was unreadable to humans, who invented assembly. Assembly is actually a mnemonic form of binary instructions, and instructions are basically one-to-one correspondence (with a few abstractions), as long as the assembly is mapped to binary, it can be directly executed by the CPU, so it is the lowest level of low-level language.

The villain who bragged that he could read binary directly took the idea of hierarchical architecture of bento computers in the first film, which is the essence of human intelligence. From semiconductor physics to cloud computing, each layer is an abstraction of the next layer, and the upper layer does not need to care about the implementation of the lower layer, only what it is giving the input and output to the next layer.

On top of assembly, there are more human-friendly high-level languages such as C, which describes code in an English-like syntax to express it, which is then compiled into assembly by the GCC compiler. Here is a simple C code and its compiled form on the macbook i7:

int main (a) {
  return 1 + 2;
}
Copy the code
_main:                                 
	.cfi_startproc
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset %rbp, - 16
	movq	%rsp, %rbp
	.cfi_def_cfa_register %rbp
	movl	$0.4 -(%rbp)
	movl	$3, %eax
	popq	%rbp
	retq
	.cfi_endproc
Copy the code

As we can see, C is closer to natural language than assembly, which deals with instructions and registers.

Chinese programming

In fact, developers around the world are trying to design programming language syntax based on their mother tongue. Some are commercially available and active today. In the Chinese circle is more famous is easy language, and a while ago produced the topic of classical Chinese programming.

Many people are a little dismissive when they hear easy language, but this language is a top language in a gray area. This domain is game plug – in and black produce Trojan horse. More than 80 percent of the domestic plug – in and theft procedures from easy language. Whether a language can catch on or not is related to the opportunity to enter the subfield. For example, C language, which solves the problem of cross-source portability, has become the preferred language for writing operating systems and underlying protocols. Java has jumped on the enterprise informatization bandwagon with strong typing, garbage collection, and object-oriented high-level abstractions that make architecting large enterprise applications less of a disaster. The popularity of JS lies in the discord among major browser manufacturers. Js has become the only out-of-the-box language for all browsers. It happens to catch up with the rise of Web2.0 technology, and JS is irreplaceable. It is a natural expansion of the JS language beyond the browser host, benefiting from good performance and a large user base. Python, with its expressive power and mathematical standard library, is popular in the field of artificial intelligence. Chinese programming, however, hits a small group of people, who are not trained, or even have no education background, have natural rejection of English, have a little intelligence, and have a strong desire to do something. With nearly a million registered users on the official forum, there must be something special about being successful in a niche, even if the user base of Eilinguo is different from the original intention of the developers.

Without making fun of the era style of Win 98, the IDE provides a very friendly visual layout interface and debugging capability. From basic programming ability to almost cover all library functions of the operating system call. You can develop download tools, instant messaging, players, websites, and many other types of applications, all with official and third-party templates. Ide code editing part is also done very carefully, often people ridicule the “if” fast or if fast, in fact, as long as the INPUT rG pinyin first letter in the IDE can quickly complete the statement block, the entire IDE experience, do not need to cut Chinese input method. However, the development difficulty of plug-ins is not simple, from LSP injection to driver injection, and even kernel overloading, VT debugging, using inline assembly to hijack memory data. These are not things that a dilettantes who can’t spell English can do. Easy language in plugins popular, in fact, there is a layman do not understand the inside: plugins are in the edge of the law to test, hackers generally do not sell plugins directly, but packaged into DLL incomplete plugins form delivered to the black downstream to escape sanctions. Easy language to say the core only does one thing, tune the library.

Extend the JS

Speaking of these, it seems that Chinese programming as a brother easy language is not much glory, however, this matter for us but some reference. Easy languages, as closed commercial software, are not destined to become mainstream, but we can do something similar simply by customizing JS. The following is a direct normal operation of the JS program:

varCanvas = Get canvas ('#canvas'.'2d')
if(exists (canvas)) {canvas. Fill color ('red') Canvas. Draw rectangle (10.10.55.50)}Copy the code

If that’s not friendly enough, we can simply extend js with lexical analysis:

var iamotherjs...

` `'Easy language to set canvas to get canvas ('#canvas', '2d') if (exists (canvas)): canvas. Fill the canvas with color (' red '). Draw rectangle (10, 10, 50, 50)Copy the code

In the above code, we define a grammar boundary called “easy language”, and then divide the string within the boundary into tokens through lexical analysis. Then the tokens are generated into abstract syntax tree AST, which is converted back to ordinary JavaScript, so that we can easily extend JS. Make it more expressive of Chinese, and can rely on the perfect ecology of JS.

More natural language

The above way can only lower the threshold of programming entry, but it still needs strict grammar delimitors. From the perspective of information theory, reducing entropy means increasing manpower, and this part of complexity has not been reduced or transferred. We need a more natural language to describe logic, and that’s NLP. There are five difficulties with natural language that make computer processing difficult:

  • Diversity, such as “I beat Xiaoming”, “Xiaoming was beaten by me” there are not many rules in natural language, but we can understand a variety of sentence patterns, indicating that there are still internal rules.
  • Ambiguity, if not connected with the context, lack of environmental constraints, language has great ambiguity, such as “play mermaid”, want to listen to Hans Christian Andersen’s fairy tales, or want to watch Stephen Chow’s movies, or listen to Jay Chou’s songs?
  • Robustness, language more words less typos noise, such as this sentence you will not feel without understanding.
  • Common sense, natural language depends on knowledge, like driving a car, driving a car or driving a car?
  • Context, conversation context, user identity, user profile.

For the code in the summary above, we’ll use a more glib way of saying “draw a red square at xx on the page”. This sentence, translated into code, has information that is missing. For example, what is the DOM selector corresponding to the xx position? What is the value of red? What is the right size for a square? Canvas or SVG? In practice, we can add more context constraints to simplify sample processing:

  • Programming languages: Chinese programming languages, for example, are very structured and tightly constrained
  • Templates: Suitable for restricted class scenarios, digging holes
  • Visual choreography: for example, logic is expressed by drawing flow, which is essentially strong structural constraints
  • Expert system: need to pass rules, analysis to the missing information, and then further dialogue questions

thinking

Why do we need Chinese programming? The traditional development tool link efficiency, in essence, does not solve any problems, but replaces part of the human labor with a machine, and the machine is efficient and error-free. A requirements lifecycle, from the business side coming up with an idea, to the product experience being codized into a PRD, to being fed to the programmer, forcing the programmer to go online. This process, we discovered, we’re all talking about the same thing, just describing it in different ways. The demander uses natural language and the coder uses procedural language. In this process, a large part of the workload is repeated by both sides, but the expression language is different. Can we identify more missing information earlier in the requirements review process? Can more common parts be found, expressed in a more structured way, or understood in a more intelligent way?