How Java Programmers Get Started with C++ Efficiently and Elegantly

How can Java programmers get started with Cpp efficiently and gracefully? Due to work needs, they need to write some modules in C++. Regarding the knowledge structure of C++, although I have the experience of quickly learning many new languages, I am also a veteran of C++, but I still need to be in awe. This article will develop an efficient learning route from the perspective of a Java programmer to get started quickly. C++. Java is for employment, C++ is for faith. (C++ is a collection of three originally mutually exclusive concepts of teaching, belief, and business (these three concepts are also three stages, which can just grow up with us)).

Basic ideas about C-like languages ​​can set the tone for learning C++. The following is a list of several "central ideas" through Stroop (the inventor of C++)'s suggestions for Java programmers, plus my understanding and summary. Don't try to write Java programs in C++. Can't rely on the garbage collector anymore. Both are object-oriented languages, but use C++'s own abstraction mechanism [classes and templates].
To understand that C++ and C are programming languages ​​that differ in every way (although C++ first appeared as "C with classes"), don't write code in C for false familiarity.
The C++ standard library is important, efficient, and very familiar.
C++ programming emphasizes rich types and lightweight abstractions, and I hope to experience it in detail.
C++ is particularly suitable for resource-constrained applications and is one of the few programming languages ​​that can produce high-quality software.
C++ is growing very fast, and it needs to keep pace with the times.
Be sure to have unit tests and an error handling model.
C++ maps both built-in operations and built-in types directly to hardware, providing efficient memory usage and low-level operations.
C++ has a flexible and low-cost abstraction mechanism [core mastering] (in the form of a library if possible), rather than simply creating a unique base class for all classes like Java.
Try not to use reference and pointer variables, instead, use local variables and member variables.
Use scoped resource management.
Use destructors when objects are deallocated instead of mimicking finally: avoid pure new and delete, use containers (such as vector, string and map) and handle classes, (such as lock and unique_ptr) use independent functions to minimize coupling, Use namespaces to limit the scope of individual functions.
Don't use exception specification.
A C++ nested class has no access to the enclosing class. C++ provides minimal runtime reflection: dynamic_cast and type_id, and should rely more on compile-time features. The zero-overhead principle must not waste even a single byte or a processor clock cycle (C++ is a belief).
C++ is a system programming language (such as drivers, communication protocol stacks, virtual machines, operating systems, standard libraries, programming environments and other systems with high technical depth), while Java is a business development language (such as XXX management systems, e-commerce Websites, WeChat service accounts and other upper-level UED-related applications based on the B/S architecture), make judgments against each other (it makes sense to despise the chain).

The most important thing in learning C++ is to focus on fundamental concepts (such as type safety, resource management, and invariants) and programming techniques (such as resource management with scoped objects and iterators in algorithms), but be careful not to get lost in language technical details.
Learning C++ must avoid wasting a lot of time into the details and features. Knowing the most uncommon language features or using a larger number of features is not something worth showing off, Shang Xue Tang Bai Zhan programmer teacher Chen pointed out that learning The real purpose of detailed knowledge of C++ is to be able to combine language features and library features to support good programming style in the context provided by good design.

Therefore, it is very necessary to use libraries to simplify programming tasks and improve system quality. Learning the standard library is an integral part of learning C++. (If you encounter a problem, look for a library first, which I think every Java programmer thinks so deeply, and won't drill into the details.) Understanding programming and design techniques is more important than understanding all the details. And don't worry too much about the details, through the accumulation of time, continuous practice will naturally master.

How can Java programmers get started with Cpp efficiently and gracefully, C++ has a huge number of standard libraries and toolsets in addition to the standard library, there are now thousands of C++ libraries, it is impossible to keep up with the changes of all these libraries, so it is still above In those words, it is necessary to support good programming style by using a combination of language features and library features, so familiarity with the field of these libraries (without having to dig into them one by one) and understanding programming design techniques are the core points.
 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325510987&siteId=291194637