C++ optimization is more about design choices.

In C++ programming, optimization goes beyond just tweaking code for performance gains. It fundamentally revolves around making smart design choices. Here’s why:

  1. Algorithm Selection: The choice of algorithm can drastically affect performance. Using an O(n log n) sort algorithm over an O(n^2) one is a prime example.
  2. Data Structures: Choosing the right data structure (e.g., using a hash table instead of a linked list for fast lookups) can lead to significant efficiency improvements.
  3. Memory Management: Efficient memory usage and minimizing allocations/deallocations can enhance performance. Techniques like memory pooling or using smart pointers properly can make a big difference.
  4. Concurrency and Parallelism: Designing systems that effectively use multiple threads or processes can improve performance. C++11 introduced standard support for threading, which aids in this.
  5. Avoiding Premature Optimization: Focusing on clean, maintainable code first and optimizing critical sections later is usually more effective.
Continue reading “C++ optimization is more about design choices.”

Abstracting technical layer details in C++ to mitigate the language’s learning curve.

Recently, I came across a LinkedIn post showing a C++ developer’s reaction to seeingfor the first time how array sorting is done in Python. Unsurprisingly, the simplicity of Python’s approach was shocking.

arr=[64,12,22,55,44]
bubble_sort(arr)
print("Sorted Array:",arr)
Continue reading “Abstracting technical layer details in C++ to mitigate the language’s learning curve.”

7 Tips to improve the C++ algorithms complexity (Big-O)

Understanding algorithm complexity, specifically Big-O notation, is crucial for analyzing and comparing the efficiency of algorithms. In C++, as in other programming languages, the complexity of an algorithm can significantly impact the performance and scalability of an application. So it’s useful to know how to improve the algorithm complexity. But before that let’s explore the most common algorithm complexities:

Continue reading “7 Tips to improve the C++ algorithms complexity (Big-O)”

In C++, the Macchina.io Edge SDK is your best choice for IoT applications.

The Internet of Things (IoT) refers to the network of physical objects—devices, vehicles, buildings, and other items—embedded with sensors, software, and other technologies to connect and exchange data with other devices and systems over the internet. IoT encompasses a wide range of applications, from consumer gadgets to industrial systems, transforming how we interact with the physical world.

Continue reading “In C++, the Macchina.io Edge SDK is your best choice for IoT applications.”

Boosting C++ Performance with Folly

The Folly library, developed by Facebook, is a collection of reusable C++ library components designed to complement the C++ standard library and boost the performance of C++ applications. Folly focuses on efficiency, providing highly optimized components that are particularly useful in performance-critical applications. Here are some key aspects of performance in the Folly library:

Continue reading “Boosting C++ Performance with Folly”

Another big tech company join the move away from C++ initiative, How we can stop this migration process?

Background

2011 marked the renaissance of C++, driven by the release of C++11 which introduced numerous features to modernize the language, such as lambda expressions, smart pointers, and a more efficient standard library. However, a decade later, major tech giants like Google, Microsoft, Amazon, Apple, and Meta are initiating processes to migrate away from C++. This shift highlights growing concerns about memory safety and the evolving landscape of systems programming.

Just recently there’s another big company joining the Moving away from C++ initiative. it concern Apple that recommend to replace C++ with Swift.

One could argue that the issue lies not with C++ itself, but with the developers using it. However, the reality is that big companies are shifting away from C++.

Continue reading “Another big tech company join the move away from C++ initiative, How we can stop this migration process?”

According to Tiobe C++ surpasses C for the first time in history, The Streisand Effect works :)

In the world of programming languages, C++ has long been a staple, valued for its power and performance. However, it’s also been the subject of significant criticism over the years. Interestingly, these criticisms often have an unintended consequence, making C++ even more popular—a phenomenon known as the Streisand Effect.

Recently, C++ faced widespread criticism, with even the White House advising against its use. Ironically, this led to an increase in its popularity. According to TIOBE, C++ has surpassed C in popularity for the first time in history.

Continue reading “According to Tiobe C++ surpasses C for the first time in history, The Streisand Effect works :)”

Could Herb Sutter’s call to action for C++ safety be acheived soon?

Recently, Herb Sutter wrote an excellent article on C++ safety. He discussed numerous ideas, but I’ll provide a summary of his perspective on what can be done in the medium term to enhance C++ safety.

In C++, by default enforce …(A) Solution for new/updated code (can require code changes — no link/binary changes)(B) Solution for existing code (requires recompile only — no manual code changes, no link/binary changes)
Type safetyBan all inherently unsafe casts and conversionsMake unsafe casts and conversions with a safe alternative do the safe thing
Bounds safetyBan pointer arithmetic Ban unchecked iterator arithmeticCheck in-bounds for all allowed iterator arithmetic Check in-bounds for all subscript operations
Initialization safetyRequire all variables to be initialized (either at declaration, or before first use)
Lifetime safetyStatically diagnose many common pointer/iterator lifetime error casesCheck not-null for all pointer dereferences
Less undefined behaviorStatically diagnose known UB/bug cases, to error on actual bugs in existing code with just a recompile and zero false positives:
Ban mathematically invalid comparison chains
(add additional cases from UB Annex review)
Automatically fix known UB/bug cases, to make current bugs in existing code be actually correct with just a recompile and zero false positives:
Define mathematically valid comparison chains
Default return *this; for C assignment operators that return C&
(add additional cases from UB Annex review)

But what are the current possibilities for achieving this goal?

Continue reading “Could Herb Sutter’s call to action for C++ safety be acheived soon?”

Try to understand the motivations behind the new C++ features to use them better when needed.

In the world of software development, languages evolve over time to improve efficiency, usability, and performance. C++ is not an exception. Understanding why a feature is added can significantly enhance how developers use it, leading to better, more maintainable code.

For C++ developers who have not yet mastered the new C++ features, it’s recommended to understand at least one key motivation behind each feature. This way, when a specific need arises, the developer can identify which feature might be useful and then delve deeper into learning how to implement it.

Here are the motivations behind some new C++ features:

Continue reading “Try to understand the motivations behind the new C++ features to use them better when needed.”