Programming Language and natural language

Source: Internet
Author: User

Reprinted please indicate the source: http://blog.csdn.net/horkychen

 

The development of programming languages is similar to that of natural languages, which are basically driven by satisfying communication needs. There are also some barriers to communication. Here is a simple discussion!

 

1. What is language?

Language is a communication tool and is generated to exchange information. (The language includes two aspects: speaking and writing. Here we will mainly discuss writing .)

 

Every change in language (including words) from a knot to a modern language is intended to promote communication. At first, there was no need for language or text. There was nothing to remember. Later, there were more prey, and some things had to be written down to sum up experience. This is like a binary machine code. If a knot is entered, the value 1 is not 0. Knotting on a rope is similar to punching on a tape.
 

Later, there was a lot of material, and there was a problem with the exchanges between tribes. It may be necessary to write down the exchange of courtesy or even the war. knotting will definitely confuse people. So smart humans invented hieroglyphics. Hieroglyphics are patents of a few people and are not universal. This is like an assembly language, with different instruction sets in different systems. They share a common feature that is hard to read! Of course, some cool people are still talking about programming in assembly language, which also shows that it is a minority patent.

 

As we continue to develop, we need to record more and more things, communicate with people more closely, and more expressions are available. The emergence of paper and printing has promoted the development of text and the promotion of Classical Chinese, which has greatly promoted the development of language. This stage is similar to the emergence of advanced languages, such as C/FORTRAN. However, the classical Chinese text and daily life of the entire article are too far away, so the Modern Times began to write white text, because it is closer to people's daily thinking. The corresponding Java/C ++ era is approaching.

(OOP is more suitable for people's habits. The most obvious example is that after the division of labor is refined, personality independence and contract spirit become a natural thing. These contents are reflected in the development of programming languages .)

 

If you come up with friends now, you may say "dream like" to everyone, either admired or despised. But when we see each other, we have to look down on it. This is not a good way to communicate. The audience's needs determine how you speak. When writing code, is there a need to emphasize the encoding standard?

 

After my pull, the programming language and natural language have become very similar, essentially serving communication, but the communication between the former has two aspects: human and machine, people and people. So programming languages and natural languages connect the real world and the software world, which is equivalent to mathematical symbols.

 

2. Difficulties in Language Communication

Since it is communication, there must be barriers to communication.

A. language differences

The first thing is the differences between languages. If the language is not available, find a translation! So there are various agents, IPC, and so on in the software world. In order to achieve simultaneous translation, there will be mixed compilation.

 

B. Dialects

Dialect problems encountered in daily life also occur in the world of programming languages. The following is a database field name that I encountered in my previous work. It is abbreviated to PinYin:

[Cjsj]

Can you guess this is the abbreviation of chuqinshijian? There are still many such fields, and I have been very confused! Later, we finally found that the first developer of the original system was a hacker.

 

C. Mixed editing

Now there are more and more Chinese and English "mixing" students, especially it male. This is also common in programming languages. Let's look at the example of creating a database table (because of the correspondence between the table and the business logic, it is a high-risk region ):

Create Table [DBO]. [doormm] (

[BH] [varchar] (3) not null,

[MC] [varchar] (8) null,

[Mm] [varchar] (16) null,

[Manager] [bit] Null,

[Report] [bit] Null,

[Qzpass] [bit] Null

) On [primary]

 

At first glance, you must think it has something to do with the door, and there is a manager in it ). The first column should be bianhao for primary key.

......

No! The functions of this table are only available to developers.

 
D. specialized vocabulary in the field

In addition, the so-called common language problem occurs during the party. For example, the following joke is boring after my wife finishes reading it:

A couple of programmers married each other. A year later, they liked their son and named it "Ling". Another year later, they named it "Ling Yi", and two years later, they named it "Yi Ling "; after two years, the husband and wife agreed to give up a successful birth and name it "Yi ". Unexpectedly, the Health Check found that we were pregnant with twins. If our husband wants to reduce the number of children, his wife does not allow her to give birth. She had been thinking for a long time and said to her husband, "Old Five is called" Recalling the beginning "......

If you do not understand these professional terms, you are obviously Yun. This is an obstacle to the professional vocabulary of domain knowledge. For example, we generally know that "subject" means "topic" or "subject", but in statistics, it also means "subject. Is it difficult for the arrangesubject () function to "look at the context?

 

E. Grammar

Finally, it is a grammar problem. Some people speak in a concise and clear way, while others speak in the dark. There is another way of saying that I really don't know how to say it. This is hard to say! The same is true for writing articles. A good article looks smooth and smooth! Of course, "500 words are omitted here!" also appears in some articles !"!

It is scientific to clarify what is unclear, and to say what is hard to say is literature. The key is an organizational structure. There are many related words in the world corresponding to programming languages: structuring, design, hierarchy, abstraction ......

Let's compare helloworld with a diary:

Helloworld. cpp

Int main (INT argc, char * argv [])

{

Int I = 0;

Printf ("Hello, world! [% D]\ N ", I );

Do something else ......

Return 0;

}

 

 

 

 

In the morning, XXXXXXXX

Help Grandpa cross the road XXXXXXXX

Ah, a really happy day!

 

The structure has three parts:

I. Conditions

Ii. discover some things

Iii. Close and return

 

 

Conclusion:

Beck advocates three values in coding: communication, simplicity, and flexibility. It makes sense.

 

Take writing code as writing. First, ask for something, and then think about how others can understand my code? There are several simple tips:

A. Refined from top to bottom,

That is, there is an outline in writing.

For example, on the way to work, the idea can be simplified to: going downstairs, taking a bus, and walking to the company. Then we will refine some details and modify the important points.

 

Mind Map is valued because it conforms to people's habits.

 

B. Learn English and grasp keywords

When you see a word, you must think of the knowledge map behind it. Just like the link feature launched by Google ). You can use a mind map to record and form a system, which is very helpful for your knowledge.

 

In China, translation of English documents often shows several people. In the form of a rush, each person starts work in one or two chapters, and then starts selling out a shocking name. As a result, the quality of the book is not high, let alone the system. For more information, see this article. (programmers talk about how to master computer English ).

 

It usually takes some time to learn English and try to capture the latest information in English to avoid being misled.

 

C. Focus on practical details
It is very important to develop good naming and commenting habits. In particular, annotations may cause great confusion if the description is poor or even not synchronized with the code. You can find this information in <code Daquan>. You can take a look at this document (coding process: naming and commenting ).

 * By The Way, <code Daquan> and <programmer's practice> are both good books, but the title cannot be accepted!

  It's a bit superficial. please correct me!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.