One of the topics of C + + programming: compilers

Source: Internet
Author: User
Tags ole variables

There are a lot of different compilers on the Internet to compare things, I'm not writing these things to support or deny something, because I always think that in the field of programming, I'm just a beginner, and I'm not qualified to judge (and I don't want to judge), I just want to talk about how I feel on the road of personal learning.

A prerequisite for learning programming is that you have a platform for practice--a corresponding compiler, without which everything is empty talk. Before selecting the compiler, the first choice is the language (which I don't want to explain more), and here I assume you chose C or C + +.

Now the most popular compiler I'm afraid it should be Microsoft's VC, before I go on, I'd like to mention one more point: VC is a compiler, just a tool to make C + + code into an executable file (of course I have some simplification, but it's important to recognize this, Although you can see similar words in many places, I would like to mention that I hope that everyone who learns to program is best to know it from the beginning rather than to wake up after a lot of detours. Another powerful compiler is the Borland C + + Builder (which I will replace with BCB).

If you are using VC, I would like to ask, why do you use it? I think a lot of people simply can not answer this question, most can not answer the reason is obvious: 1 heard, VC is the best; 2 Microsoft's products; 3 only know this. Of course, even more is the beginning of the VC as a language to learn, oh, I believe there must be such people! Whenever I talk about these problems, I will feel that a lot of times, the software industry is not the best software technology, VC must be the best? Why is VC so successful? I have to admire Microsoft's business strategy. As to how successful VC is, I strongly recommend an article--"C + + Jihad," author Levi, "Programmer" Magazine for 2001.1 months.

What exactly does a compiler bring to us? In the early days, compilers were a simple text editor + library (header) file + compiler, and many early programmers used other editors to write their own programs and then compile them using the compiler. The compiler we use now is often called the Integrated development Environment (IDE), a type of development environment that provides us with a lot of things: a convenient way to develop, a perfect help system, a rich library, and some unique features.

Programming on a particular platform there are two main things you need to be concerned about: 1. Support the language you are using; 2. Platform features (Windows Platform SDK provides us with everything). Under the Windows platform, we can use C + + to program, the rest is the platform features. Windows provides us with a rich array of API functions, and these functions are slightly different on different versions of Windows. The early Widnows compiler supports platform features in a simple C + + compiler, and does not provide much more, and if you only intend to use the Windows API, the compiler's choice may simply be to compile the optimization level (perhaps you should choose BCB, It is said to be better than VC optimization, I do not have real data to compare, but Borland company's compiler optimization has always been considered excellent. What really changes is the beginning of the class library encapsulation. Microsoft provides an MFC class library, and Borland provides an owl class library. The so-called class library is to provide a package of Windows API, I believe that every person who has written Windows API program has an experience, a simple Windows window program requires dozens of lines of code, which is enough to deter beginners, in contrast to the DOS classic routines "Hello World "only needs a short line of code (so I miss the DOS era-simple, clear.) OH). The emergence of class libraries to solve this problem, the Windows class library is mainly to encapsulate the API functions under Windows to achieve this purpose: 1 simplifies the repetitive and simple work of our programming (creating only Windows and creating message loops) 2) Make our work more in line with the object-oriented style. such as a window in MFC:

CWnd Mywindow;

Mywindow.create (...); /The argument is omitted here

All we need to do is create a Window object, create a window through the object's creation method, and do nothing to care about the underlying things, the whole process is like a factory production process--that's what the object-oriented spirit is (if you can't understand this now, don't worry, After a while, will naturally understand.

It all sounds a case of epiphany. Does learning com/ole especially need religious belief? I think it's because these techniques require a high degree of abstraction, which makes quickly's cheerful delight so great that it feels like a "sudden miracle". In fact, you and I both understand. However, the breakthrough of Knowledge point is by the accumulation of knowledge.

A lot of times, do you feel this way when you look back and think about the problems that you didn't understand before? I believe the answer is yes. I think the crux of the matter lies in the end of the passage: Knowledge point of Breakthrough, is by the accumulation of knowledge to me, when I contacted the BCB after a period of time, I suddenly understand, it and VC is only a package of different classes of compiler, the real key problem is C + +! It was then that I began to really get started, and it was a matter of more than a year since I learned to program. If there is no chance, I contacted once BCB, perhaps until now I can not understand those are VC provided, those are standard C + + provided. MFC and owl have become trivial compared to C + + (I don't underestimate them).

I hope that all of us will not repeat the way I have learned, my road is tortuous, at least in the course of learning I wasted a lot of time (I was naïve to think that the current programming is only the expansion of the function, such as the Windows SDK, completely ignoring the object-oriented thinking exists). I always think VC is a good compiler, but when you build an MFC program, many books introduced the way the introduction appears relatively loose, giving you the feeling of using a large Windows function library rather than a class library, many textbooks ignore the MFC in the object-oriented concept of strengthening, But only some functional realization, but in the BCB, the object-oriented idea is relatively strengthened.

I'm not writing to illustrate what kind of compiler is good and what kind of compiler is bad, the final option may not be in your hands, and many times it is a platform or other constraints that cause you have to use some kind of compiler. I'm just trying to explain some ideas because I can't distill the problems I want to explain, so loosely written a lot, and ultimately what I want to say is not to reject--never! for unnecessary reasons.

The above content only represents the personal opinion, if has the improper, welcome the discussion.

VC and BCB used their different ways (MFC and Owl) to encapsulate, we use the means of each other, it is difficult to say which is better, the only MFC should be the advantages of the operating system. In contrast, I personally think that at least in the process of generating BCB better (in fact BCB I personally also browse a bit, a total of 2-3 days, but only to do an understanding), in VC, if you for a common control such as CListCtrl associated with a variable, the person who wrote the program should know , the compiler is generated as a class member variable, and in BCB, the variable is in the form of a class member pointer, what's the difference? A large number of local variables can cause the stack to overflow, which is why you cannot create a char largestr[100000000]. If you use a lot of these variables in VC programs, God knows what will happen (although variable access in the stack is more efficient).

Some time ago, I also had a lot of very bad and naïve ideas, until one day, I understand a lot. In fact, many computer-learning people will have the same feeling, the following paragraph from Mr Hou's prose:

The South Pope and the northern Pope, Epiphany and enlightenment

The Dharma has an epiphany, but no learning. If someone says that I suddenly enlightened on Java one day, enlightened on OO, Enlightened on MFC ..., I think it was a deliberate (to show off) or not deliberately (because of forgetting) to ignore what he called "WU" the day before all the efforts. Yes, it's called gradual awakening, not epiphany.

Inside OLE Book author Kraig Brockschmidt in his preface with this passage:

One Sunday afternoon in January 1993, when I was doing something completely unrelated to OLE, I suddenly got the so-called OLE Nirvana state. The branches of OLE are all suddenly in position. After six months of vague mind, I suddenly saw OLE.

Essential COM Book author Don Box also has a similar word in his preface:

Luckily for one day (August 8, 1998), suddenly, like a miracle, COM became more aware of me, but I finally understood the motives of COM. How to apply this programming model to the programming problems encountered every day, it seems to understand again.

Related Article

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.