How to create a programming language, and content design decisions in?

Original link: http://www.cnblogs.com/qianpangzi/p/10570186.html

The first thing to consider when answering this question is: What is the programming language? If you ask Wikipedia this issue, you will find a programming language

It is a formal language, which contains a set of instructions to generate various outputs

This is certainly true, but in a real encyclopedia in the form of almost no help. It does give the right idea. Just write down some notes and some of the rules to express what they are doing, and you have created a programming language. If you use a little bit of fancy language to write these rules, you would call your language specification, and claims to have created a programming language.

 

Of course, in most cases, the programming language is not written specifications from the beginning of the exercise. Instead, a program starts with a programming language actually do something with the program. In general, it will be a program that reads some code written in a programming language, and then execute the code what is being said (a "interpreter" - to think step by step recipe) or a translator to understand the sequence of bits actual hardware the source code (although the strings of 1 and 0 may be considered as the hardware and interpreted programming language). There are some more exotic can be programmed to implement a programming language (for example, type checker only checks whether the source code in the correct format, that is, the language rules allow, but do not execute it) that various changes and compiler and interpreter (hybrid systems, compilers, is to "virtual hardware" that is designed to be easily mapped to the actual hardware low-level language compiler from a high-level programming language to another, or "publisher"), but the key is that these programs somehow "understood "language. If anything, norms usually occurs in the future.

 

Now, suppose you have started using their own programming language, then how to determine what language should be - what instructions are available, what the rules of language and grammar, semantics of what kinds of things are, and so on. Many issues need to be considered when making these decisions: how it works with the rest of the system? It is self-consistent it? Users make sense? By looking at the code, the user is able to guess what happened? Are we able to effectively let the hardware do things language should do? Whether precedents in some places, such as setting user expectations of how things should work in mathematics or other programming languages? If so, we deviate from this expectation, whether there are good reasons [1]? If we do something different or unexpected, we should provide both or should add at least some of the content to ensure that users can easily find the desired behavior left a legacy behavior and so on?

 

Finally, in every decision you make, you need to consider two things:

1) You must run its computers and

2) Be sure to read it in person.

Both are very important, but of course a trade-off between them, the language is different in this range. In Julia, we are working very hard to make the two can well understand a program (which is actually one of the original motivations Julia). It's not easy, and sometimes the need for hard switching (for example, check all arithmetic overflow will be good, but to do this by default, too slow on the current generation of machines), but we will try to ensure that a) we do default a reasonable choice b) whenever we have a trade-off in any direction, there is a way for users to make the opposite choice, but can be used without difficulty rest of the system. Julia multiple scheduling system is essential for the completion of this work (although the details are a completely separate topic).

 

For example, we have a policy usually spell out the name instead of using short abbreviations, so you might think "sine" and "cosine," the name is more consistent than the "sin" and "cos", but you have to fight 100 years of mathematics symbol. On the other hand, many languages ​​like using the "+" to the connection string. However, we think this is a serious error, because the + is for the exchange of string concatenation is not, this is what we use "*" as the reason string concatenation operator.

 

 

Reproduced in: https: //www.cnblogs.com/qianpangzi/p/10570186.html

Guess you like

Origin blog.csdn.net/weixin_30252709/article/details/94783924