String Immutability My Turning Point My first real introduction to the power of string immutability came with a multi-threaded application. I had to deal with strings shared between multiple threads, and if they had changed unexpectedly, it could have led to code chaos. Immutability made sure that data was consistent, no matter how many threads were accessing the same information. This first hand experience showed me how immutability could save my programming efforts from disaster. What It Taught Me After that, I became more aware of the following: -Safety matters: String immutability provides confidence that sensitive strings, like passwords or file paths, will remain the same. -Performance isn’t always obvious: Immutability allows certain programming languages to optimize memory usage. -Predictability is priceless: The biggest benefit I encountered when adopting immutability was error debugging got easier. #Programming #CSharp #CodingTips #Immutability #MyCodingJourney
String Immutability: Ensuring Consistent Data in Multi-Threaded Apps
More Relevant Posts
-
Lightweight code editors exist for a reason. They use memory resources better and can be used on rather under-powered machines. Some of these code editors / hashtag #IDEs are actually coded using languages that work natively within an operating system's userspace. Think C++/C to Free Pascal. We tried out 5 and they do offer potential in place of the Electron-powered VSCode. Read more: 5 Lightweight hashtag #VSCode Alternatives https://lnkd.in/dWRBMSSK hashtag #codeeditors hashtag #software hashtag #programming
To view or add a comment, sign in
-
-
Conditional statements help make decisions in code. If condition true → execute Else → another path Programming is all about logic 🔥 #PHPCoding #ConditionalLogic #BackendDev
To view or add a comment, sign in
-
-
.𝗡𝗘𝗧 𝗚𝗮𝗿𝗯𝗮𝗴𝗲 𝗖𝗼𝗹𝗹𝗲𝗰𝘁𝗼𝗿 is incredibly efficient at managing memory. But efficient doesn't mean immune to bad code. Some patterns you write make it work 10x harder than it needs to. The GC organizes objects in generations to optimize how it reclaims memory: • 𝗚𝗲𝗻𝟬 is where every object is born. Collections here are fast and cheap because the GC only looks at a small portion of the heap. Most objects should die here. • 𝗚𝗲𝗻𝟭 is a buffer zone. Objects that survived a Gen0 collection land here. The GC collects Gen1 less frequently, and it's still relatively lightweight. • 𝗚𝗲𝗻𝟮 is where long-lived objects end up, along with the Large Object Heap (objects >= 85KB). Collecting Gen2 is the most expensive operation because the GC has to scan the entire managed heap and pause your threads to do it. Not everything in Gen2 is a problem. Singletons, caches, connection pools, static configurations... these objects belong in Gen2 and that's fine. The real issue is when objects that should be short-lived keep getting promoted to Gen2 because of how your code is written. Having awareness of what actually needs to live long vs what's landing in Gen2 by accident is one of the most impactful things you can do for performance. Do you know what generation your objects are reaching? That's worth checking before blaming the framework for a latency spike or memory climbing. And if your first instinct is to call 𝙶𝙲.𝙲𝚘𝚕𝚕𝚎𝚌𝚝() to fix it... we need to talk. Next post. #dotnet #csharp #garbagecollector #performance #benchmarkdotnet #programming #dotnetdeveloper
To view or add a comment, sign in
-
-
While implementing STL containers in C++, I noticed something interesting 🤯 Both map and multimap are internally implemented using balanced trees (like Red-Black Trees). Both provide find() to search for a key. So I asked myself: 👉 If find() already tells us whether a key exists, why does count() exist? Here’s the catch 👇 In map, keys are unique count(key) → returns 0 or 1 In multimap, keys can be duplicate count(key) → returns number of occurrences So technically: find() → gives iterator (access to element) count() → gives frequency (especially useful in multimap) Even though map will only return 0 or 1, STL keeps interface consistency across associative containers. Small observation. But this is the kind of detail that sharpens STL understanding. ⚡ Curious — do you use find() or count() for existence checks in map? And do you think STL keeps count() just for interface consistency? #CPP #STL #CppDevelopers #DataStructures #Programming #SoftwareEngineering #DSA #CompetitiveProgramming #CodingJourney #Map #Multimap #LearningInPublic
To view or add a comment, sign in
-
-
Would it be reasonable to say that Agentic Frameworks and Agents are the new “programming language”? Perhaps that’s a little “Captain Obvious”…
To view or add a comment, sign in
-
Software has already witnessed its own version of the triumph of monotheism over polytheism. These days the term "functional programming" is redundant, because all other theories - such as Object Oriented Programming, Vibe Coding, Procedural Programming, Assembly Wizardry, etc - have been refuted, and only one theory of programming remains: Type Theory. Instead of "functional programming", I insist upon the term "programming" for this: There are not multiple types of programming - only one. Programming languages differ in quality, but there is only one framework against which quality is measured. There are not multiple schools of thought, there is no such thing as "multi-paradigm", etc, unless you consider "understanding software" and "not understanding software" as separate paradigms. Software only has one system of truth.
To view or add a comment, sign in
-
zero to one: foundational engineering paradigm > concepts arrays, linked list , fast pointers > notes > problem: middle of the linked list -> a good introductory problem to understand the idea of fast and slow pointers -> writing the code requires a bit of dry run; because of one off errors -> good exercise to deepen programming logic > problem: linked list contains cycle -> I had solved this earlier, but not entirely from scratch. -> I was able to get the core idea right this time. Using slow and fast pointers was a natural choice this time. NeetCode
To view or add a comment, sign in
-
Solved “Counting Bits (0 → n)” on NeetCode today. Instead of checking every number’s binary representation individually, I used a pattern-based approach. Here’s the key idea: Every time we hit a new power of 2, we update an offset. Because numbers between: 2^k and 2^(k+1) are just the previous sequence + 1 extra leading bit. So we can use: res[i] = 1 + res[i - offset] Which gives us an O(n) solution with clean dynamic programming. Try it.
To view or add a comment, sign in
-
-
If a pointer holds a memory address, & a reference 𝗽𝗼𝗶𝗻𝘁𝘀 to data in memory, what makes them different? Since a variable is just a 𝗻𝗮𝗺𝗲 𝗯𝗶𝗻𝗱𝗶𝗻𝗴 to a memory address. A pointer is therefore a variable that stores another variable's memory address. A reference is the abstract 𝗰𝗼𝗻𝗰𝗲𝗽𝘁 of "referring to data somewhere else." Pointers are one type of 👉 𝗶𝗺𝗽𝗹𝗲𝗺𝗲𝗻𝘁𝗮𝘁𝗶𝗼𝗻 of that concept. When languages say "we have references" - 𝘁𝗵𝗲𝘆'𝗿𝗲 𝘂𝘀𝗶𝗻𝗴 𝗽𝗼𝗶𝗻𝘁𝗲𝗿𝘀 𝘂𝗻𝗱𝗲𝗿 𝘁𝗵𝗲 𝗵𝗼𝗼𝗱. They just won't let you access the raw memory addresses. Higher-level languages give you the behaviour without the control. C gives you both. #𝘀𝗼𝗳𝘁𝘄𝗮𝗿𝗲𝗲𝗻𝗴𝗶𝗻𝗲𝗲𝗿𝗶𝗻𝗴 #𝗽𝗿𝗼𝗴𝗿𝗮𝗺𝗺𝗶𝗻𝗴
To view or add a comment, sign in
-
-
zero to one > concepts linked list, arrays, dynamic programming > notes > problem: rotate linked list -> very good foundational problem; required to rotate a linked list by k values to the right -> the core idea is relatively simple; most of the time was spent on debugging edge cases > problem: jump game -> this problem can be solved using dp as well as greedy approaches -> dp comes to mind for the reason that the problem does have a substructure; essentially one problem relies on another subproblem -> greedy though does something drastically better; O(n) compared to O(n^2) with caching in DP -> greedy simply requires to iterate through the list from the end and keep updating the target values; we just check if a particular index can be reached from any one of the previous indices, if yes, we update the target value. -> target value reaching zero implies that the end of the list can be reached from one or more combinations of the elements in between NeetCode
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