Some notes on "modern C++". The C++ programming language was first released in 1985. There have been multiple updates to it that are labeled by the year, C++03, C++14, C++20, etc. With a few tiny exceptions, a newer compiler that defaults to a newer version of C++ will still compile code written based on the original release. Some of the additions to C++ have been things every code could benefit from. An example is RAII (Resource Acquisition Is Initialization), which prevents memory leaks. The big change in C++ over the years is the ability to make template libraries and a rich set of template library functionality that comes with C++. Templates are generic functions. For example, numeric functions where you write one function and it automatically converts to float, double, or integer data types. Many of the additions to C++ have been designed for writing template libraries. Along with the changes to the language, we have gotten changes to the way books recommend using the language which are called "Modern C++". Modern C++ coding styles typically utilize features in C++14. Modern C++ coding style relies heavily on using the included template libraries, and writing code like it were a template library. I recently looked at a piece of open source scientific simulation software that was heavily templated. Much of their coding style didn't give any benefit to their purpose of writing good simulation software, and indeed made the code harder to follow and modify. It had more complex syntax and layers of code. This is a coding style I call "smart but not wise". Unfortunately, some books on C++ are written assuming everyone is writing template libraries. These books don't show wise choices for writing applications software using C++. Part of good software development is making wise choices for your application, not just copy and pasting examples designed for a different type of software.
C++ Evolution: Modern C++ Best Practices for Application Software
More Relevant Posts
-
ISO C23 for Systems Programming: Understanding the C Standard in Practice ======================== My first encounter with the C programming language dates back to 1989, when I began working with it using Borland’s Turbo C environment. At that time, C was demanding, unforgiving, and required a level of precision that was challenging for a beginner. A few years later, with the emergence of C++, the transition felt natural. Object-oriented programming, stronger abstraction mechanisms, and improved code organization made C++ an attractive evolution of C, and it became my primary professional language throughout the 1990s. With time and experience, however, it became increasingly clear that despite the rise of newer languages, C has never lost its central role in computing. While languages such as C++ and Rust continue to evolve and address different problem domains, C remains foundational in areas where predictability, minimal abstraction, and direct control over memory and execution are essential. C continues to dominate or strongly influence fields such as: • Operating Systems, where kernels and core subsystems rely on C for precise control and stable interfaces. • Embedded Systems, where limited resources and hardware proximity demand explicit and efficient code. • Compiler and Toolchain Development, where C’s simplicity and portability make it a natural implementation language. • Low-Level and Systems Programming, where understanding memory, calling conventions, and execution models is essential. These realities motivated the decision to write this book using the current ISO C standard, C23. The choice of C23 is not driven by novelty, but by correctness: it represents the most up-to-date, clarified, and officially standardized form of the C language. This book focuses on the domains where C has always been strongest, rather than attempting to reshape it into something it was never designed to be.
To view or add a comment, sign in
-
Dynamic Programming is the topic that fails most engineers. Not because it’s hard. Because nobody explains it properly. Let me simplify it in 2 minutes. DP is just a smarter way to avoid doing the same work again and again. It works only when two things are present - 1.) OVERLAPPING SUBPROBLEMS This means the same smaller problem is solved many times. Imagine you are solving a big problem, and again and again you reach the same situation. Same index. Same remaining value. Same position. If your recursion keeps visiting the same situations, that’s overlapping. Instead of solving it every time, DP saves the answer once and reuses it. Simple. 2.) OPTIMAL SUBSTRUCTURE This means: The best answer to a big problem can be built using best answers of smaller problems. You don’t need to rethink everything. You just trust smaller solutions and build forward. A VERY SIMPLE EXAMPLE You are climbing stairs. You can climb 1 step or 2 steps. To reach step 5, you must come from: Step 4 or Step 3. So: Ways(5) = Ways(4) + Ways(3) Same steps repeat again and again. That’s overlap. And each step depends on smaller ones. That’s optimal substructure. WHY DP IS FAST Normal recursion keeps solving the same step again and again. DP remembers: “I already solved this.” And uses it instantly. Less work. Much faster. WHEN DP WILL NOT HELP DP helps only when states repeat. If every call is new and never repeats, there’s nothing to save. No repetition → no DP benefit. DP MENTAL MODEL Where am I? (state) What can I do? (choices) Where does it go? (smaller state) Have I solved this before? (store) If it repeats , use DP. Solve once. Reuse forever. HOW TO IDENTIFY A DP PROBLEM • Find max or min • Count ways • Check possible or not • Longest / shortest • Recursion feels slow Repeated states = DP. THE UNIVERSAL DP FRAMEWORK Define state Try choices Use smaller answers Store result Build forward COMMON DP MISTAKES • Forgetting base case • Defining wrong state • Not covering all choices • Recomputing instead of storing • Filling DP in wrong order Most DP bugs come from these. HOW TO PRACTICE DP SMARTLY Start with recursion first. Understand the brute force. Then: Add memo to make it DP. Finally: Convert to table (bottom-up). This builds real understanding. EASY MEMORY TRICK If problem says: Best / Count / Can we / Longest / Minimum Think: “Is this DP?” Usually yes. FINAL THOUGHT DP is not about big arrays. It’s about avoiding repeated work. Once that clicks, DP becomes simple logic. If this helped you understand DP better, react to it and save it for later. You’ll thank yourself before interviews. Question for our experts and LinkedIn fam - Q.) How do you usually decide whether a problem needs Greedy or Dynamic Programming? Would love to hear your approach in comments 🔽 Don’t forget to follow or connect account: Sachin Vyas and stay tuned !!
To view or add a comment, sign in
-
-
Write up on Tech Geek History: C programming Significance of the Study Chapter 1: Introduction To Arrays: In C programming, one of the frequently problem is to handle similar types of data. For example: if the user wants to store marks of 500 students, this can be done by creating 500 variables individually but, this is rather tedious and impracticable. These types of problem can be handled in C programming using arrays. An array in C Programing can be defined as number of memory locations, each of which can store the same data type and which can be references through the same variable name. It is a collective name given to a group of similar quantities. These similar quantities could be marks of 500 students, number of chairs in university, salaries of 300 employees or ages of 250 students. Thus we can say array is a sequence of data item of homogeneous values (same type). These values could be all integers, floats or characters etc. We have two types of arrays: 1. One-dimensional arrays. 2. Multidimensional arrays. One Dimensional Arrays: A one-dimensional array is a structured collection of components (often called array elements) that can be accessed individually by specifying the position of a component with a single index value. https://lnkd.in/e8x5nkYN
To view or add a comment, sign in
-
"Functions Are Objects: A Gentle Introduction to Functional Programming - Stanley Okonkwo You may be hearing a lot about functional programming lately; contrary to popular trends, it is one of the oldest programming paradigms around, being an application of the lambda calculus by Alonzo Church (of the Church-Turing hypothesis), with the discovery of the Y-combinator by Haskell B. Curry (who has a programming language for every name he has). It is also perhaps a little unintuitive if you are a self-taught programmer or perhaps a little alien if you are used to mathematical functions, but don't worry, it is, in my opinion, simpler than object orientation, and way more fun. A few terms to help us here with functional programming: Variables declared in a function signature are called "bound variables," and variables declared inside a block are called "free variables": def fn(a, b): c = a + b d = a a In the example above, a and b are bound variables where c and d are free variables. This helps distinguish between what variables are in the mechanism of calling a function and which are used in implementing the function. Functions, as they relate to functional programming, are special because… They are not special! They behave just like any other object with properties and can be passed around as other objects, like lists, dictionaries, or numbers can be. To prove that functions are objects, like lists or dictionaries, you can assign properties to functions! >>> def my_function(): ... return 'Hello world' ... >>> my_function.data = 'I bet no one will go looking for this!' >>> my_function.data 'I bet no one will go looking for this!' >>> print(my_function.data) I bet no one will go looking for this! >>> print(my_function()) Hello world The Journey Ahead Functional programming isn't just a trend; it's a fundamental way of thinking about code that has stood the test of time. Whether you're working with Python, JavaScript, Haskell, or any modern language, understanding functional concepts will make you a better programmer.
To view or add a comment, sign in
-
-
I automated the process of creating and sharing word documents, for our college programming labs. Let’s be honest: The hardest part of a coding lab isn't the code—it’s the documentation. I found myself spending hours every week manually formatting Word documents, copy-pasting code, and fixing alignment issues. It was repetitive and boring. So, I wrote a script to do it for me. LabTool CLI – An automated word document generator built with Python. What it does: ✅ Instantly recognizes .java, .py, .c, and .cpp files. ✅ Instant Formatting: Generates a professional .docx report with Heading, Aim, and Source Code using python-docx. ✅ Background Automation: Uses Multithreading to email the document to desired address in the background while I start the next task. ✅ Robustness: Handles file-locking conflicts (if Word is open) and includes self-healing configuration for secure SMTP login. 🛠️ Tech Stack: Language: Python 3.10 Libraries: python-docx, smtplib (Email), threading (Concurrency), tkinter (GUI dialogs). Packaging: Compiled to a standalone .exe using PyInstaller (No Python required to run!). Version Control: Git & GitHub Releases. This project taught me a ton about File I/O, race conditions, and packaging software's. &&&NOTE&&& :- This project currently generates a single word template.(Aim, Source Code, Output) The tool is Open Source and available for anyone to use! Check it out here: https://lnkd.in/gPuPS9Vz
To view or add a comment, sign in
-
Best programming language is C++ of course. It is because is possible write unsafe code. And because it is possible override operators. Or define operators for custom types. But also C++ has problems. The main problem is custom operators. It is fixed set of operator names and same operator can do different fucntions. For example << could be binary shift or stream output or any other stuff, if overwritten. And it is not good use more than one symbol for operator name. All programming languages takes special symbols from very old ASCII 7-bit table. And some operators have two or more characters. For example <= . Although exist character ≤. So operator override in C++ defines functions with special names. Would be better if C++ developer could use any operator visualization image and add any number of diffrerent operators. And operators could be defined in special headers: #operatordef <mycomapre_opeators.h> and then I would have my special opeators. if (a kindof_similar b) poweup a; where kindof_similar, poweup could be some characterlike image (like emoji). Built in operators should not be overridden from my opinion. It mainly confuses and makes illusion of simple implementation. So better do not use << as stream output operator. If needed - redefine it as function.
To view or add a comment, sign in
-
🚀 C# Async Best Practices: Handling Single & Multiple Task Exceptions ⚙️ Asynchronous programming in C# improves performance and responsiveness. But poorly structured exception handling can make async code hard to read, debug, and maintain 🐛 👉 In real-world scenarios, keeping exception handling simple is often the most professional choice. ================================================ 🔹 Single async operation — one task, one exception 🎯 When awaiting a single async operation, the exception is thrown directly. A single catch (Exception) is usually sufficient when the handling logic is the same. public async Task<Order> GetOrderAsync() { try { return await _orderRepository.GetAsync(); } catch (Exception ex) { _logger.LogError(ex, "Failed to retrieve order"); throw; } } ✔️ Simple ✔️ Explicit ✔️ Clear responsibility boundaries 🧭 ================================================ 🔹 Multiple async operations — Task.WhenAll ⚡ When executing multiple tasks in parallel, all failures are grouped inside an AggregateException. Handle it explicitly to capture all individual errors. try { await Task.WhenAll( LoadCustomerAsync(), LoadOrdersAsync(), LoadPaymentsAsync() ); } catch (AggregateException aggEx) { foreach (var ex in aggEx.InnerExceptions) { Console.WriteLine($"Captured error: {ex.Message}"); } } 📌 Always handle the AggregateException to capture all errors and understand what really failed. ================================================ ✅ Key Takeaways 📋 🎯 Single task (await) → direct exception ⚡ Multiple tasks (Task.WhenAll) → AggregateException 🧼 Keep it simple = cleaner, more maintainable async code 💡 Clean async exception handling improves observability 🔍, reduces production bugs 🛠️, and keeps your codebase maintainable. #CSharp #DotNet #Async #AsynchronousProgramming #ExceptionHandling #CleanCode #SoftwareDevelopment #CodingTips #TechLeadership #SvetlanaVrabie
To view or add a comment, sign in
-
-
C++ Overview What is C++? C++ was developed by Bjarne Stroustrup, as an extension to the C language. Despite being an 80s creation, C++ has been a popular programming language throughout these years. C++ is a cross-platform language that can be used to create high-performance applications and software systems. C++ is very close to the hardware making it comparatively easy for programmers to give the instructions directly to the system without any intermediary giving programmers a high level of control over system resources and memory. Why should we learn C++/ Features of C++? C++ is one of the world's most popular programming languages. In today's operating systems, GUIs, and embedded systems, C++ is widely used. It is one of the most popular programming languages for its object-orientedness. C++ is an object-oriented programming language that gives a clear structure to programs and allows code to be reused, lowering development costs. With C++, you can develop applications or heavy games that can run on different platforms. As C++ is close to other programming languages such as C# and Java, which makes it easy for programmers to switch to C++ or vice versa while it is actually very easy to learn. How is it different from C? The syntax of C++ is almost identical to that of C, as C++ was developed as an extension of C. In contrast to C, C++ supports classes and objects, while C does not.
To view or add a comment, sign in
-
In continuation to previous post https://lnkd.in/gh-53USP Once you have a grip on Mono, Flux, and the basic operators, it’s time to talk about what actually makes the engine run under the hood. In reactive programming, we have something called Schedulers. The key thing to understand here is that by default, reactive code is not necessarily multi-threaded. It runs on whatever thread starts the subscription. But to get the real prowess out of your system, you need to decide which "worker" handles which task. In libraries like Project Reactor, we use operators like subscribeOn and publishOn to switch the context. When we talk about Schedulers, the first question that pops up is whether the whole thing is multi-threaded or not. I'm damn sure many people get confused here thinking Reactive means Multi-threaded by default. Yeah, you read it right—it isn’t. Unless you specify a Scheduler, the code just runs on the current thread. But the real prowess of Reactive programming comes when you start using these Schedulers to distribute the load across multiple threads. Let's look at the logic of which ones actually bring multi-threading to the table: • Schedulers.immediate(): No multi-threading here. It stays on the same thread. It’s as simple as that. • Schedulers.single(): This one is technically a separate thread, but it’s just one worker for everyone. So, it's not "multi-threaded" in the sense of parallel execution; it’s just offloading work to a single background worker. • Schedulers.parallel(): This is where true multi-threading happens. It creates a pool of threads based on your CPU cores. If you have 8 cores, it can run 8 tasks at the same time. It’s perfect for CPU-heavy logic where you want to squeeze every bit of performance out of your machine. • Schedulers.boundedElastic(): This is also multi-threaded. It creates a pool of threads that grows and shrinks based on the need. It's the best choice when you're dealing with "delves" like slow database calls or API hits, as it ensures one slow task doesn't block the whole system. Example: Flux.just("User1", "User2") .subscribeOn(Schedulers.boundedElastic()) // Start here for I/O .map(name -> name.toUpperCase()) .publishOn(Schedulers.parallel()) // Switch to parallel for heavy processing .subscribe(System.out::println); The key thing to understand here is that you are the one in control. By choosing parallel() or boundedElastic(), you are telling Java to get rid of the single-thread hurdle and use the full power of the hardware. Go ahead and play around with those Schedulers, but don't blame me if you accidentally create a thousand threads and your laptop starts sounding like a jet engine ready for takeoff 😂. Until then, bye bye!
Senior Software Engineer | Distributed Systems | Kafka | 7M+ Events/Day | Java, Python | AI Agents (GPT)
In continuation to previous post https://bit.ly/4bsoGg0 Once you get basics of Reactive programming, it becomes more interesting as we delve into further details. Let's talk about further components which come from libraries like Project Reactor. There are something called Mono and Flux. Both are different types of Publishers supported in reactive programming. Understanding these is as simple as reading a line of code. With the concept of Mono and Flux, you deal with a stream of data and not just the static data itself. Lets break it with an example. When we are fetching a unique user from a database based on id, we use Mono. Mono deals with fetching at most one object (0 or 1) or an error. Flux can be used to fetch 0 to N number of items, like a list of active users from a database. Instead of going into more details and confusing you, let's talk about other buzz words we use in reactive programming. Operators: In reactive programming, we don't just "get" data. We transform it as it flows. There are different operators which can be used for transformation without those for-loops which we were bound to use in imperative Java. Map: For synchronous transformation, like changing the type of a variable on the fly. FlatMap: Used for asynchronous transformations, like performing a database call for every item in a Flux. Filter: Filter out only the data which meets a given criteria. Concept of Backpressure: A very critical concept which should be carefully used in reactive programming; otherwise, the situation could go worse than imperative programming. Backpressure is a concept where the consumer can send a signal to the producer like "Hey, slow down, I can only handle five items at a time right now." In this way, the system maintains its own balance and eventual crashing of an application can be prevented. A Simple Example: Look at the logic below. In older Java, you'd wait for the whole list. In Reactive, you handle it as it comes. The stream starts, filters out the "C++" hurdle, transforms the rest, and then finally prints them. No curly brace hurdles, no complex declarations. Trust me, once you start thinking in streams, going back to the old way feels like taking a step backward. It might take extra time to master the operators, but the ultimate satisfaction of building a non-blocking, resilient system is worth the effort.
To view or add a comment, sign in
-
-
In continuation to previous post https://bit.ly/4bsoGg0 Once you get basics of Reactive programming, it becomes more interesting as we delve into further details. Let's talk about further components which come from libraries like Project Reactor. There are something called Mono and Flux. Both are different types of Publishers supported in reactive programming. Understanding these is as simple as reading a line of code. With the concept of Mono and Flux, you deal with a stream of data and not just the static data itself. Lets break it with an example. When we are fetching a unique user from a database based on id, we use Mono. Mono deals with fetching at most one object (0 or 1) or an error. Flux can be used to fetch 0 to N number of items, like a list of active users from a database. Instead of going into more details and confusing you, let's talk about other buzz words we use in reactive programming. Operators: In reactive programming, we don't just "get" data. We transform it as it flows. There are different operators which can be used for transformation without those for-loops which we were bound to use in imperative Java. Map: For synchronous transformation, like changing the type of a variable on the fly. FlatMap: Used for asynchronous transformations, like performing a database call for every item in a Flux. Filter: Filter out only the data which meets a given criteria. Concept of Backpressure: A very critical concept which should be carefully used in reactive programming; otherwise, the situation could go worse than imperative programming. Backpressure is a concept where the consumer can send a signal to the producer like "Hey, slow down, I can only handle five items at a time right now." In this way, the system maintains its own balance and eventual crashing of an application can be prevented. A Simple Example: Look at the logic below. In older Java, you'd wait for the whole list. In Reactive, you handle it as it comes. The stream starts, filters out the "C++" hurdle, transforms the rest, and then finally prints them. No curly brace hurdles, no complex declarations. Trust me, once you start thinking in streams, going back to the old way feels like taking a step backward. It might take extra time to master the operators, but the ultimate satisfaction of building a non-blocking, resilient system is worth the effort.
To view or add a comment, sign in
-
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development