C++11 (and modern C + + style)

Source: Internet
Author: User
Tags compact

The past year I Microsoft Research Asia do input method, our product is called "engkoo Pinyin Input Method" (download beta version), if you have used "Engkoo dictionary" (now renamed to Bing Dictionary), you should Know "Engkoo" This name (in fact, a large part of our core development team comes from the old members of the Engkoo team). The entire project was the result of Microsoft Research Asia's Natural Language processing group, Internet and our Center, as well as the Microsoft Office Business Software (MODC) group. As for the innovative feature of our input method, and the interesting stories behind these feature ... This article is not discussed at this stage. Although I was involved in a lot of feature's ideas and designs throughout the process, 90% of the responsibilities were developed, so as one of the core developers of the client, I wanted to share this year's full use of c++11 in the project and the modern C + + style (Elements of Modern C + + Style) to do all the development experience.

Free Membership Network

The development environment we use is VS2010 SP1, which already supports quite a few of the c++11 features: lambda expressions, rvalue references, auto type derivation, static_assert,decltype,nullptr,exception_ptr, and so on. C + + has been plagued by "College School" label, but this label is very unfair, C++11 's new feature is not a school from the perspective of the design, all of the above mentioned feature in our project has been suitable for its use, and has brought great benefits. Especially lambda expressions.

Said I and C + + is also a considerable fate, 03 is still in the undergraduate course, the first published in the programmer's article is the source of the Boost library analysis, that time the boost library in the domestic is really quite spring snow, has been nearly ten years, the Boost library is now written C + + Code indispensable library, known as the "quasi-standard library", C + + TR1 Basic is derived from the boost of a series of sub-Libraries, and TR2 also a large number of materials from the boost library. After several years, my blog on CSDN was almost purely a cutting-edge technical article for C + +, including the "C++0x Ramble" series that began in 06. (later written technical articles written less, also the blog from the CSDN blog independent out, is now the mindhacks.cn). Since the independent blog, I have not written a C + + related articles (but still has been the development of C + + has maintained a certain attention), on the one hand I like to focus on the forefront of progress, finished the boost source profiling series and C + + 0x Ramble Series I think the progress of this wave has been written about in large ways, so I don't want to take any more time. On the other hand, although I have a deep focus on C + +, practical experience has always been "alternative experience", that is, from other people's perspective, not their first-hand. The Engkoo Input Method project, which was deeply involved in the past year, made up for this shortcoming, so I decided to start writing a little c++11 of practical experience. is a summary of the first edition of the project to be launched for a year.

09 After the entry Microsoft Research Asia, the first two years with C + + basically no, the project is in C + +, but work on the existing code base, time is relatively short. The second item is Bing Image search, which writes the front end with JavaScript, and the third project writes code Clone Detection to Visual Studio 2012, in C # and WPF. Until a year ago Engkoo Input Method This project, is my fourth project in the Institute, is also the largest one, a year I am very happy, because back to C + +.

Free Membership Network

This project we start from scratch, and the client side of the core developers are also very compact, only 3. There are many special things about this project, and the challenge of efficient rapid iterative development ("practice-driven Research (Deployment-driven-research)", which the institute advocates, requires us to respond quickly to the needs of our users):

    1. Long-term time pressure: from zero to release, only one year, we have to be on the main feature and mainstream input method, but also need to implement our own unique innovation feature, so that can be separated from other input method products.
    2. Short-term time pressure: Input method in China is a very mature market, who can not guarantee the boring head for a year to get out of the thing on a cannon and red, so we from the first day to enter the demo-driven quasi-iterative development, the whole process must have periodic output, look at the road better than Bulkhead walk. But one of the two hardest problems that engineers have to worry about is the short-and long-term paradox that, in order to continue to produce short-term results, it is often necessary to work in some places, and the results of a rush can lead to compromises in design and code quality that are also known as technical debt (technical debt). There is no project without technical debt, just how much, and the difference in the way of repayment. Our goal is not to eliminate technical debt, but to stop the snowball accumulation of technical debt by continually improving code quality.
    3. C + + is a hard-to-use language: the wrong way of using it can cause a lot of damage to the quality of the code base. The misuse of C + + is particularly numerous.
    4. IME is a very special application, under Windows, Input method is loaded into the target process space in the DLL, so, the input method on the quality of the high requirements, other software error crashes the big deal reboot, and input method if the crash will cause the entire target process crashes, If the user's document is not saved, it is possible to lose valuable user data, so the input method should not crash. But as long as people write code how can there be no bug? So the key is how to reduce bugs and their impact and how to respond and fix bugs as quickly as possible. So our approach is divided into three steps: 1). Reduce the chance of bug generation with modern C + + technology. 2). Minimize the impact on the user, even if the bug is created. 3). A sound bug reporting system allows developers to have enough information to fix bugs the first time.

Why use C + + instead of C? For us the reason is very realistic: time tight task heavy, with C words need to invent the wheel too many, C + + level of abstraction, code is less, the relative will be less, modern C + + memory management is completely automatic, so that I do not remember at the beginning of the memory management related bugs, modern C + + The error handling mechanism is also very suitable for rapid development without worrying about bug flying, plus the strong support of C++11 is even more powerful, of course, all of this must be based on the core team must use the premise of C + +, which for our compact small team This is not a problem, Because everyone has a better C + + background, there is no steep learning curve to crawl. (As for C + + in the large-scale team each of the C + + of the situation brought about some of the burden of the article also does not discuss, hehe, the language of the struggle not to find me. )

C++11 (and modern C + + style)

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.