Have an amazing solution built in RAD Studio? Let us know. Looking for discounts? Visit our Special Offers page!
IDE

15 Tips to Graduate from Classroom C++ to Modern C++ Part 3/3

digital particles
  1. Adopt the latest standards

C++ is a great programming language with it’s standards dating from 1998. The C++ standard is not about teaching how to use C++; it is a formal and very detailed technical document intended primarily for people writing C++ compilers and standard library implementation. This allows developers to code knowing that their code will work on other toolchains implementing the same standard, and also add the latest new things for developer needs in the standard.

The latest C++17 standard is supported by most C++ compilers. More information about core language features can be found here. C++ 20 is a new standard and needs adaptation time. The latest standards or compatible codes with all standards may make your C++ codes more modern.

In some cases, old methods (for example, C standards are much more friendly with all C++ compilers) can be more useful, faster, and optimized specifically by the developer. The author thinks that the Modern C++ term not only stands with the latest standards used but also means it can be used by other compilers or platforms on the latest devices.

For example, auto comes with C++11, and this great feature is used to define data types automatically as below.

There are many new features of CLANG standards that come with C++98, C++11, C++14, C++17, C++20. Just survey them.

Tip 10: Use new features of CLANG standards, like C++11, C++14, C+17, and C++20.

  1. Use modern I/O operations

In the modern world, operating systems have moved from 32 bits to 64 bits to support more data usage and from ASCII format to Unicode format to support all world languages. 

File names, and file formats are modernized to support applications worldwide. Input-output methods are very important on text files or nontext (binary, blob, image, etc.) files.

Instead of old handle-based I/O operations like fopen(), fclose(), FileOpen(), and FileClose(), use the latest standard methods or file-streaming methods. Some specific methods can be used to load and save data files.

For example, this is a well-known handle-based file reading operation in C++:

Instead of this, use new file I/O methods in C++, as below:

For example, using file streams is more modern in C++ Builder.

Tip 11: Use modern I/O operations on files to support Unicode and wide string formats worldwide.

  1. Use latest third-party libraries, components

    As mentioned in the beginning of this article, C++ is a very broad field in the programming language world. It has many properties and methods used in a standard package. For example, a simple GNU C/C++ has more than 400 include files, while C++ Builder comes with more than 7,000 include files supporting other OS platforms. Visual C++ also has many include files. Each included header has numerous properties or methods that you can use. 

In addition to these standard libraries, C++ can be extended and supported by other libraries, C++ source codes, dynamic libraries, APIs, components, and other tools. That makes C++ world huge. For example, to use Nvidia graphic cards, you need their SDK. Most IoT apps come with their SDKs, and some specific software comes with its own SDKs or APIs.

Some IDE’s may come with Package Managers with 3rd party libraries, components and more. For example C++ Builder has the GetIt Package Manager that allows you to search and browse the latest 3rd party packages and it’s official packages. By using Get-It, you can easily and safely install, uninstall, update, or subscribe to these packages.

If you need a third-party library, start with the most common one that has at least one or two years of support. Avoid using very old or rare libraries that have less support from developers. Rare, free or open libraries can be also used, but be sure that it is necessary and that, if there is no more support, you can handle all the issues of this library. 

Try to obtain libraries with their source code if possible. 

Tip 12: Use the latest third-party libraries, components, and APIs, and obtain them with their source codes if possible.

  1. Design responsive UI forms and application

Design tools measure width and height in pixels, and displays have resolutions that have pixels in both horizontal and vertical arrangements. If we design a fixed element, it may not fit other resolutions if it has a low resolution or may have a lot of space if the other resolution is higher. We can support all kinds of display resolutions by aligning parts of designs in groups, panels, layouts, or areas of UI elements. In general this is called responsive design.

When you design the user interface of your application, use responsive design methods. Align your panels, boxes, tables, layouts, texts, and grids in a smart way. First your design should be simple and useful. Align most used or main parts of your application to one side (top, bottom left, right). You may need to anchor some UI elements or their corners. Margining and Padding UI elements are also important. Decide which part of your application will be stable,  which parts will be changed when your application is resized or when the user rotates the device from landscape to portrait or portrait to landscape. Maybe you should design for only portrait mode. Some unnecessary UI elements can be hidden when your app shrinks. Smart layouts, panels,  group panels, grids and other UI elements will modernize your application. Finally add some skins or styles. On Runtime, check resize operations on your application windows and determine whether your application runs on landscape or portrait mode. 

Below is a UI design example from the RAD Studio, C++ Builder. For a responsive design, in general, consider that we have at least nine spaces: top, bottom, left, right, top-left, top-right, bottom-left, bottom-right, and the client part, which can be a part that is not defined, generally the central zone of the design. This is the most generic design that can be responsive on all platforms in portrait or landscape mode, on mobile or desktop.

15 tips cppbuilderalign

Tip 13: Use responsive UI designs.

  1. Learn Other New Features of Modern C++ IDE and Compiler

If you have an C++ IDE with a compiler, they have many other features, like debugging; watching; designing applications; binding databases; data modules for databases; deployment or packaging tools to release professional apps on MS Store, Apple Store, Google Play, and so on; migration tools, third-party tools, and more. 

Most of these kinds of new features will modernize your C++ applications.

Tip 14:  Modernize your C++ applications with new features of Modern C++ IDE and compilers.

  1. Be aware!

Watch the latest C++ conferences and read the latest news and academic papers about C++, C++ compilers, and IDEs. Try to follow some other programming languages and their features. These may give you some ideas or help you decide on new ways to modernize your codes.

Tip 15: Follow the technology news on C++ and in the programming world.

Summary

Tip 1: Your College C or C++ knowledge is necessary to move on to Modern C++ and to decide on the field in which you want to work. Also, note that most of them can be used in modern applications.

Tip 2: Try to use multi-platform compilers. If you can’t focus on one OS platform, consider that it will be a multi-OS platform.

Tip 3: Use a professional compiler with IDE, like Visual C++, C++ Builder, etc. 

Tip 4: Code with a CLANG-enhanced C++ compiler, or code as much as in CLANG standards as possible.

Tip 5:  Use wide strings or Unicode strings in string formats to support worldwide languages; avoid using fixed char arrays as much as possible. 

Tip 6: Develop GUI-based applications to make easy, understandable apps with stunning graphics.

Tip 7: Use UI element properties as an output or UI element methods to output your data.

Tip 8: Use UI element properties as an input or use UI element methods to get input.

Tip 9: Use optimized methods and features of standard libraries as much as possible.

Tip 10: Use new features of CLANG standards like C++11, C++14, C++17, and C++20.

Tip 11: Use modern I/O operations on files to support Unicode and wide string formats worldwide.

Tip 12: Use the latest third-party libraries, components, and APIs if you need; obtain them with their source codes if possible.

Tip 13: Use responsive UI designs.

Tip 14: Modernize your C++ applications with new features of Modern C++ IDE and compilers.

Tip 15:  Follow the technology news on C++ and in the programming world.

Conclusion

C++ is a great programming language to develop native applications on all platforms. It is faster and more reliable than others. In some parts, it might be a little bit hard, but be assured that there is nothing that you can’t do with C++. The latest standards, libraries, and IDEs with the new optimized compilers have many more features, making a very big programming world and communities. It is simple in some parts but also getting complex in other parts.  In one podcast, Bjarne Stroustrup, who implemented and designed C++, said that a good programming language should get more complex to satisfy all the needs of its users. Today, some other popular programming languages, like Python, Java, and Ruby, look simple and easy to use, but when you need a specific solution, you need to do their modules, libs, extensions with C++, or assembler programming language to have faster and optimum processes.

In conclusion, the tips listed above can be extended to more, but know that you just need to follow the technology in C++. It appears that  C++ will remain one of the world’s most popular programming languages because of its rich features.

Read part 1 of this blog post here

Read part 2 of this blog post here

In our picks for your next read, we have the C++ bit set ready to help you increase productivity in programming with its modern features.


Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Start Free Trial   Upgrade Today

   Free Delphi Community Edition   Free C++Builder Community Edition

About author

Dr. Yilmaz Yoru has 35+ years of coding with more than 30+ programming languages, mostly C++ on Windows, Android, Mac-OS, iOS, Linux, and some other operating systems. He graduated and received his MSc and PhD degrees from the Department of Mechanical Engineering of Eskisehir Osmangazi University. He is the founder and CEO of ESENJA LLC Company. His interests are Programming, Thermodynamics, Fluid Mechanics, Artificial Intelligence, 2D & 3D Designs, and high-end innovations.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

IN THE ARTICLES