With C spirit (on)

zhaozj2021-02-12  154

C's spirit

Greg colvin

6, 21, 2004

Translation: Small knife

Summary:

The experienced developer Greg Colvin retracted C, C and Java development process with a better future.

text:

Is there anything in the meaning of C, C , and Java to use the same spirit? From the top level, they seem to be similar. For example, the following code snippet, if put in a suitable context, in all these three languages, they will calculate the maximum number of conventions with the Euclid algorithm

INT GCD (int M, int N) {

While (m> 0) {

IF (n> m) {

INT T = m; m = n; n = T;

}

m - = n;

}

Return n;

}

But when we talk about sharing the same spirit, we will talk about some of their essential common points, beyond pure syntax. When studying the essence, let's take a look at the theoretical basis of the first ANSI C standard:

Maintaining the main goal of this committee is to protect the traditional spirit of C. There is a lot of aspects of C's spirit, but its essence is the view of the fundamental principles based on C language. Some aspects of the spirit of C can be overview as short sentences are as follows:

I believe the programmer.

Don't prevent programmers from doing those need to do.

Keep language short care.

One way to do one action.

Make it fast enough, although it does not guarantee that it will be portable.

The last proverbs need to be explained. Potentially high efficiency code generation is the most important force. To help ensure that there is no code explosion occurs in a very simple operation, some operations are explained to the hardware of the target machine how to do it rather than a regular abstract rule.

In many aspects B programming languages ​​are the true avatars of this spirit, and future development can be considered alternating in these five aspects. More the latter.

"20 years of school education and they make you a day day" (Bob Dylan)

First talk about my own history of myself and C. Back in 1983, as a Ph.D. who had just got a degree, I joined my mentor Peter OsSorio's artificial intelligence research. I was arranged to do language analysis, but when I was there, I quickly understood the most important work is programming. The company has a contract to deliver a text analysis and retrieval system running on the latest VAX computer at that time, and only one prototype system written in Fortran. It is not the quite standard Fortran that can be accepted by the VMS compiler at that time, but an older, and a large number of extensions are no longer supported. Our residential mathematician, just when I correctly correct the prototype code, he came in, and resolutely said that I used C to re-edit this software. "Why use C?" I asked. "Because", he still concise and gives me a copy of Kernigan & Ritchie.

We were too poor and no longer rent a VAX, so we had to share a PC clone machine. It has 128K memory and two 320K hard drives, a Lattice C compiler and library, and another weighing our code, whether it is running under 64K memory, because MSDOS should use another 64K. Now recalling that the 8088 CPU clock frequency at the time is 4.77 MHz. Now look back and see that there is nothing in such an environment in addition to a small and simple language. Therefore, we started working with the C compiler in the K & R and hard drives. When I don't expect my matrix algebraic code (the real programmer can write out the fortran in any language) and our mathematician will turn his mode match theory to the intensive pointer algorithm of the collection, C is very important. It has become obvious. The efficiency of C has become very prominent, because all our code and memory coordination and running speed exceed all of us all possible expectations. When we have a confidence in our existing code, we plan to use VAX near the nearby university to port to VMS. It is only two days and only two bugs because I think Int can only have 16 bits. I was at the next day, I thought about there was a student at the time that I had a student who said: "What is this?" "C code," I said. "What is C?" He asked. "Portable structure assembly language," I said. "This is what the world needs," he said, and I can't affirm that he is serious or ironic. But I have fell in love with C, and there is no reliance. Need to be a mother (anonymous)

So what is the extraordinary tool called C? In 1969, Ken Thompson and Dennis Ritchie, Doug Mcilroy and others started a Fortran compiler for the UNIX operating system built in his PDP-7, as mentioned by Ritchie: As I recalled, I lasted with Fortran. week. Instead, it is a definition of the new language B made and a compiler. B is affected by the BCPL language, and other impact is the experience of Thompson against Sparta grammar, and the compiler is very suitable for very small space. Like BCPL, b is a variety of various types of operations that have a variety of machine characters, which can have integer, bit mode, characters, data addresses, and function addresses. We can easily rewrite the example of the maximum number of conventions as B code: GCD (M, N) {while (m> 0) {if (n> M) {auto t = m; m = n; n = T; } M = m - n;} return n;}

B how is it very good to reflect this spirit? Almost perfect, in my point of view. "Believe programmers" and "Don't prevent programmers from doing what you need to do" is a significant feature of a non-type language. A 8 kilobyte spatial limit and Thompson's Sparta experience together, "keep language small and simple" -auto specifiers are only the syntax Cruft. With so few grammar people even fortunately find "a way to do one action", and only by operating the local machine, there is no obstacle to a quick execution here. So since B (language) is just from heaven, what else can be developed?

转载请注明原文地址:https://www.9cbs.com/read-6716.html

New Post(0)