<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: himank</title>
    <description>The latest articles on DEV Community by himank (@himankbhalla).</description>
    <link>https://dev.to/himankbhalla</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F102055%2Fb26e30b5-d49c-4343-b029-0fac049903b5.jpg</url>
      <title>DEV Community: himank</title>
      <link>https://dev.to/himankbhalla</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/himankbhalla"/>
    <language>en</language>
    <item>
      <title>Concurrency Patterns 101</title>
      <dc:creator>himank</dc:creator>
      <pubDate>Thu, 16 Mar 2023 07:10:42 +0000</pubDate>
      <link>https://dev.to/himankbhalla/concurrency-patterns-101-93h</link>
      <guid>https://dev.to/himankbhalla/concurrency-patterns-101-93h</guid>
      <description>&lt;p&gt;Event loops and threads are two different concurrency patterns that can be used to manage multiple tasks simultaneously. Although both patterns achieve concurrency, they differ in the way they handle tasks and the underlying mechanisms used to manage concurrency. In this blog, I will explain the technical differences between event loops and threads.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Event Loop:&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1400%2F0%2AKAd39mvFwHCpLHof" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1400%2F0%2AKAd39mvFwHCpLHof" alt="Photo by Tine Ivanič on Unsplash"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;An event loop is a pattern commonly used in non-blocking I/O applications, such as web servers and user interfaces. In an event loop, a single thread is used to process multiple events and requests by continually monitoring a queue of events and processing them in a non-blocking manner. The event loop is an efficient way of managing concurrency as it avoids creating new threads for each request, which can lead to excessive overheads and slow down the application.&lt;br&gt;
Here’s an example of an event loop in Python:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import asyncio

async def coroutine():
   print(“Starting coroutine”)
   await asyncio.sleep(1)
   print(“Coroutine finished”)

loop = asyncio.get_event_loop()
loop.run_until_complete(coroutine())
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, we use the asyncio library to create an event loop. The coroutine() function is an asynchronous function that will be executed by the event loop. The run_until_complete() method is used to run the event loop until the coroutine() function has completed its execution.&lt;br&gt;
Another example of an event loop is JavaScript’s event loop. The JavaScript event loop is used in web applications to manage events such as user input and network requests. Here’s an example of how the JavaScript event loop works:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;console.log("Start");

setTimeout(() =&amp;gt; {
 console.log(“First”);
}, 2000);

setTimeout(() =&amp;gt; {
 console.log("Second");
}, 1000);

console.log("End");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, the console.log() statements are executed synchronously, followed by two asynchronous setTimeout() calls. The first setTimeout() is set to execute after two seconds, while the second setTimeout() is set to execute after one second. The event loop in JavaScript continuously monitors the queue of events and executes the callbacks associated with the setTimeout() calls when their time is up.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Threads:&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1400%2F0%2AkzDHw4M-g1TLtP3h" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1400%2F0%2AkzDHw4M-g1TLtP3h" alt="Photo by Stephane Gagnon on Unsplash"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Threads are a pattern commonly used in applications that require heavy computation or I/O operations. In a threaded application, multiple threads are used to execute tasks concurrently, and the operating system’s scheduler manages the threads’ execution. Threads can perform tasks simultaneously, leading to improved performance, but can also lead to synchronization and deadlock issues.&lt;br&gt;
Here’s an example of a threaded application in Python:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import threading

def print_numbers():
   for i in range(1, 11):
   print(i)

def print_letters():
   for i in range(ord('a'), ord('k')):
   print(chr(i))
t1 = threading.Thread(target=print_numbers)
t2 = threading.Thread(target=print_letters)
t1.start()
t2.start()
t1.join()
t2.join()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, we use the threading library to create two threads, t1 and t2. Each thread performs a different task, printing numbers and letters, respectively. The start() method is used to start the execution of the threads, and the join() method is used to wait for the threads to complete their execution.&lt;br&gt;
Another example of a threaded application is a web server that creates a new thread for each incoming request. Each thread handles a single request, and the operating system’s scheduler manages the threads’ execution.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Difference:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The main technical difference between event loops and threads is the way they handle concurrency.&lt;br&gt;
In an event loop, all tasks are executed in a non-blocking manner, meaning that when a task is waiting for I/O or another task to complete, the event loop can continue to process other tasks. This makes event loops very efficient in managing concurrency, as they avoid the overhead of creating and managing multiple threads.&lt;br&gt;
However, event loops may not be suitable for applications that require heavy computation, as long-running tasks can block the event loop and slow down the application.&lt;br&gt;
In contrast, threads are well-suited for applications that require heavy computation or I/O operations. They also require synchronization and coordination to avoid race conditions and deadlock issues. Additionally, creating and managing threads can be expensive, leading to higher overheads and sometimes decreased performance.&lt;/p&gt;

&lt;p&gt;In summary, event loops and threads are two different concurrency patterns that can be used to manage multiple tasks simultaneously. Each pattern has its advantages and disadvantages, and the choice of concurrency pattern depends on the application’s specific requirements.&lt;br&gt;
Originally published at &lt;a href="https://medium.com/@himankbh/concurrency-patterns-101-7f379b0c0887" rel="noopener noreferrer"&gt;medium&lt;/a&gt;&lt;/p&gt;

</description>
      <category>concurrency</category>
      <category>threads</category>
      <category>eventloop</category>
      <category>beginnercoding</category>
    </item>
    <item>
      <title>10 things that I wish I had known earlier!!</title>
      <dc:creator>himank</dc:creator>
      <pubDate>Sat, 11 Mar 2023 05:56:38 +0000</pubDate>
      <link>https://dev.to/himankbhalla/10-things-that-i-wish-i-had-known-earlier-1af6</link>
      <guid>https://dev.to/himankbhalla/10-things-that-i-wish-i-had-known-earlier-1af6</guid>
      <description>&lt;p&gt;Becoming a good programmer requires more than just learning programming languages and syntax. There are many things that can help you become a better programmer, and it’s important to know them earlier in your journey. Here are 10 things that I wish I had known earlier to become a good programmer:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Code readability is crucial&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8lInjMaS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://miro.medium.com/v2/resize:fit:1400/0%2A23VSU7_w9fLN3Ler" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8lInjMaS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://miro.medium.com/v2/resize:fit:1400/0%2A23VSU7_w9fLN3Ler" alt="Photo by Michał Parzuchowski on Unsplash" width="880" height="585"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Writing code that is easy to read and understand is essential to becoming a good programmer. It’s not just about making the code look pretty, but also about making it easier for other developers to understand and maintain. Always strive to write code that is easy to read and understand, and use comments to explain the more complex parts of your code.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Write reusable code&lt;/strong&gt;
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--LfvlNOy9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://miro.medium.com/v2/resize:fit:1400/0%2AZVc7QNJYeSZh6DBM" alt="Photo by Sigmund on Unsplash" width="880" height="586"&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Reusing code is one of the best ways to save time and make your code more efficient. If you find yourself writing the same code over and over again, it’s time to start creating reusable code. Learn how to write functions, classes, and libraries that can be used across multiple projects.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Debugging is a skill&lt;/strong&gt;
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--g1zc_sYt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://miro.medium.com/v2/resize:fit:1400/0%2AyGrbGIbI_0GKYdTv" alt="Photo by Sigmund on Unsplash" width="880" height="586"&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Debugging is a skill that every programmer needs to master. It’s not just about finding and fixing errors, but also about understanding why they happened in the first place. Learn how to use debugging tools and techniques, and practice debugging your code regularly.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Learn to collaborate&lt;/strong&gt;
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5ucWmiQp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://miro.medium.com/v2/resize:fit:1400/0%2AFcoHdnpM2rjoV6ch" alt="Photo by Brooke Cagle on Unsplash" width="880" height="586"&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Programming is often a collaborative effort, and learning how to work effectively with other developers is crucial to becoming a good programmer. Learn how to use version control systems like Git, and practice working on projects with other developers.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Keep learning&lt;/strong&gt;
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TjeZNERW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://miro.medium.com/v2/resize:fit:1400/0%2AEe2GFPqlW4GgyJpt" alt="Photo by Tim Mossholder on Unsplash" width="880" height="586"&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The technology industry is constantly evolving, and as a programmer, it’s important to keep up with the latest trends and technologies. Make it a habit to read blogs, attend conferences, and take online courses to stay up-to-date with the latest programming techniques and technologies.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Don’t be afraid to ask for help&lt;/strong&gt;
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--r-5vHvUV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://miro.medium.com/v2/resize:fit:1400/0%2Aq9mOnxEPHeVsq_d9" alt="Photo by Rémi Walle on Unsplash" width="880" height="583"&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Programming can be challenging, and there will be times when you get stuck on a problem. Don’t be afraid to ask for help from more experienced programmers. Join online communities like Stack Overflow and GitHub to ask for help and collaborate with other developers.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Understand the problem before you write code&lt;/strong&gt;
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xaeneuYh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://miro.medium.com/v2/resize:fit:1400/0%2AOA_8svVQ1AN_6Tam" alt="Photo by Andrew Measham on Unsplash" width="880" height="660"&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Before you start writing code, make sure you fully understand the problem you’re trying to solve. Take the time to analyze the problem and break it down into smaller, more manageable parts. This will help you write more efficient and effective code.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Write testable code&lt;/strong&gt;
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QN_fs2QT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://miro.medium.com/v2/resize:fit:1400/0%2AklQqHvxPX1OKYNPl" alt="Photo by Markus Spiske on Unsplash" width="880" height="575"&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Writing testable code is important to ensure that your code works as expected and can be easily maintained. Learn how to write unit tests and integration tests, and practice testing your code regularly.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Keep your code clean&lt;/strong&gt;
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kmSxaOP7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://miro.medium.com/v2/resize:fit:1400/0%2A_FUZ8Lnzla1gFIZS" alt="Photo by JESHOOTS.COM on Unsplash" width="880" height="586"&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Clean code is easy to read and understand, and is crucial for maintaining code quality over time. Learn how to write clean code, and make it a habit to refactor your code regularly.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Understand the business&lt;/strong&gt;
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--T1b1iedB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://miro.medium.com/v2/resize:fit:1400/0%2AulIDFaZ0jX5-6cf4" alt="Photo by Riccardo Annandale on Unsplash" width="880" height="705"&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;As a programmer, it’s important to understand the business goals of the project you’re working on. This will help you write code that aligns with the overall business objectives and ensures that your code is useful and valuable.&lt;/p&gt;

&lt;p&gt;In conclusion, becoming a good programmer requires more than just technical skills. It’s important to develop soft skills like collaboration, problem-solving, and communication, in addition to technical skills like programming languages and frameworks. By keeping these 10 things in mind, you can become a better programmer and create high-quality code that adds value to your projects.&lt;/p&gt;

</description>
      <category>programmer</category>
      <category>beginnercoding</category>
      <category>codenewbie</category>
      <category>programmingtips</category>
    </item>
    <item>
      <title>Tail Call Optimization: What it is? and Why it Matters?</title>
      <dc:creator>himank</dc:creator>
      <pubDate>Wed, 08 Mar 2023 08:56:03 +0000</pubDate>
      <link>https://dev.to/himankbhalla/tail-call-optimization-what-it-is-and-why-it-matters-k4n</link>
      <guid>https://dev.to/himankbhalla/tail-call-optimization-what-it-is-and-why-it-matters-k4n</guid>
      <description>&lt;p&gt;As developers, we often write recursive functions, especially when dealing with problems that involve traversing trees or lists. Recursive functions can make code more concise and easier to read, but they also come with a risk of stack overflow errors when dealing with large inputs. This is where tail call optimization comes in to save the day.&lt;/p&gt;

&lt;p&gt;Tail call optimization (TCO) is a technique used by programming languages to optimize recursive function calls. In simple terms, TCO allows a function to call itself without adding a new stack frame to the call stack. Instead, it reuses the existing stack frame and updates the parameters and the program counter.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Understanding TCO in Detail&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In programming languages, a function call creates a new stack frame that contains the function’s arguments, local variables, and the return address. When a function calls itself recursively, a new stack frame is added to the call stack for each call. This creates a chain of stack frames that can grow very large for large inputs, resulting in a stack overflow error.&lt;/p&gt;

&lt;p&gt;Tail call optimization allows a function to reuse the existing stack frame for a recursive call, eliminating the need for a new stack frame.&lt;/p&gt;

&lt;p&gt;This optimization is only possible if the recursive call is the last operation in the function, hence the name “tail call.” If there is any code that executes after the recursive call, TCO cannot be applied.&lt;/p&gt;

&lt;p&gt;To understand TCO more clearly, let’s look at an example in JavaScript. Consider the following function that calculates the factorial of a number using recursion:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function factorial(n) {
    if (n === 0) {
       return 1;
    } else {
       return n * factorial(n — 1);
   }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When we call factorial(5), the call stack looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;factorial(5)
  factorial(4)
    factorial(3)
      factorial(2)
        factorial(1)
          factorial(0)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each call to factorial() adds a new frame to the call stack, and the stack grows with each recursive call. This can cause a stack overflow error if the input is too large.&lt;/p&gt;

&lt;p&gt;Now, let’s rewrite the function to use TCO:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function factorial(n, acc = 1) {
  if (n === 0) {
    return acc;
  } else {
    return factorial(n - 1, acc * n);
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this version of the function, we have added an accumulator variable that keeps track of the result of each multiplication. Instead of returning n * factorial(n - 1), we pass the result of acc * n as the second argument to the next recursive call. This allows us to eliminate the need for a new stack frame for each recursive call.&lt;/p&gt;

&lt;p&gt;When we call factorial(5), the call stack looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;factorial(5, 1)
  factorial(4, 5)
    factorial(3, 20)
      factorial(2, 60)
        factorial(1, 120)
          factorial(0, 120)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So, here the compiler has the option to optimize this code and not create any new stack frame for the respective calls. Instead use the current one and update the parameters and program counter. Computationally, this code becomes equivalent to a solution using loops.&lt;/p&gt;

&lt;p&gt;TCO is not always easy to implement, especially in languages that do not support it natively. In some cases, you may need to rewrite your code to use TCO or use a library or tool that provides TCO support. However, the benefits of TCO are significant, especially for performance-critical code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Benefits of TCO&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There are several benefits of using TCO in your code:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It improves the performance of recursive functions by reducing the number of stack frames created, which can reduce the risk of stack overflow errors and improve the speed of your code.&lt;/li&gt;
&lt;li&gt;It allows you to write more concise and readable code by avoiding the need for loops or iteration in some cases.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Drawbacks of TCO&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;While TCO has many benefits, it also has some drawbacks:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;TCO is not supported by all programming languages, which can limit its use in some cases.&lt;/li&gt;
&lt;li&gt;TCO can make debugging more difficult because the call stack may not reflect the actual call order of the functions.&lt;/li&gt;
&lt;li&gt;TCO can be challenging to implement in some cases, especially if the function has side effects or relies on external state.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In conclusion, TCO is a powerful optimization technique that can improve the performance and reliability of your code. While it may require some extra effort to implement in some cases, the benefits are well worth it, especially for performance-critical code. Hopefully, this article has given you a better understanding of TCO and how it can be used to optimize your recursive functions.&lt;br&gt;
Originally published on &lt;a href="https://medium.com/@himankbh/tail-call-optimization-what-it-is-and-why-it-matters-ff73631e5ac9"&gt;medium&lt;/a&gt;&lt;/p&gt;

</description>
      <category>recursion</category>
      <category>tailcalloptimization</category>
      <category>optimizedcode</category>
      <category>programmingbasics</category>
    </item>
    <item>
      <title>What every developer should know about Text Encoding</title>
      <dc:creator>himank</dc:creator>
      <pubDate>Mon, 06 Mar 2023 05:41:03 +0000</pubDate>
      <link>https://dev.to/himankbhalla/what-every-developer-should-know-about-text-encoding-6pe</link>
      <guid>https://dev.to/himankbhalla/what-every-developer-should-know-about-text-encoding-6pe</guid>
      <description>&lt;p&gt;As a software engineer, understanding text encoding is a crucial skill. In today’s digital age, we interact with a vast amount of text data daily, and knowing how it is encoded is essential to ensure that the data is correctly interpreted by different systems and applications. In this blog, we will explore the fundamentals of text encoding and why software engineers need to know about it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Text Encoding — What is it?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In simple terms, text encoding is the process of converting human-readable characters into a machine-readable format. When we create a text file, we enter the text using our keyboard, and it gets stored in the file system. However, the computer cannot understand the text in the way humans do. To be able to process and store the text data in a machine-readable format, it needs to be encoded.&lt;/p&gt;

&lt;p&gt;Text encoding involves assigning a numerical value to each character in the text. These numerical values are then converted into binary code, which can be stored and processed by the computer. Different text encoding standards exist, each with its own set of numerical values and binary codes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Evolution of Text Encoding&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The earliest text encoding standards used a single byte (eight bits) to represent each character. These standards were sufficient to encode the characters used in the English language but could not accommodate characters from other languages. As a result, many different text encoding standards emerged, each with its own set of characters.&lt;/p&gt;

&lt;p&gt;One of the most popular text encoding standards is ASCII (American Standard Code for Information Interchange). ASCII uses a single byte to represent each character and can encode 128 different characters, including letters, numbers, punctuation, and control characters. It only uses 7 bits to represent the character and the last bit is always 0.&lt;/p&gt;

&lt;p&gt;However, as computers became more prevalent and people started communicating globally, it became clear that ASCII was not sufficient. There was not enough binary representations available to represent all the characters from different languages in ASCII since it only uses 7 bits.&lt;/p&gt;

&lt;p&gt;You might think that if 1 byte is insufficient. Why not use more than that like 4 bytes and represent any character?&lt;br&gt;
The issue with this approach is that it will take more space to represent small characters too. So it will be very memory inefficient.&lt;/p&gt;

&lt;p&gt;In the 1980s, a new standard called Unicode was developed to address this issue. It uses something known as code points to represent any character or even emojis.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code Points&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Code points are just a mapping of some numbers to the characters. These numbers are called code points. For example, code point 49 is mapped to the literal value 1. Similarly, code point 65 is mapped to the character ‘A’. So Unicode is not an encoding scheme rather, it is an information technology standard for encoding, representation and text handling.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;+-------------+-------+
| Code Point  | Value |
+-------------+-------+
|     38      |  &amp;amp;    |
|     49      |  1    |
|     65      |  A    |
|     66      |  B    |
|     67      |  C    |
|     ...     |       |
+-------------+-------+
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There are other different ways to encode these Unicode code points to bits. Let us see some of these text encoding schemes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Types of Text Encoding&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There are several different types of text encodings, including UTF-8, UTF-16, and others. The most widely used encoding is UTF-8, which is a variable-length encoding scheme that is backwards compatible with ASCII. This means that UTF-8 can represent all ASCII characters using one byte, but it can also represent non-ASCII characters using multiple bytes. It can have a maximum of 4 bytes. So, UTF-8 solves all the problems of other schemes in a memory efficient manner as it is a variable-length encoding scheme. That is why it has become the default encoding for many systems.&lt;/p&gt;

&lt;p&gt;UTF-16 is another encoding scheme that uses either two or four bytes to represent characters, but it is less commonly used than UTF-8. Other encoding schemes include ISO-8859 and Windows-1252, which are still used in legacy systems and applications.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Text Encoding Issues&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Text encoding issues can cause errors and unexpected behaviour in software. For example, if a program expects the text to be encoded using UTF-8 but receives text encoded using a different encoding scheme, the program may not be able to correctly interpret the text.&lt;br&gt;
Programming Language Support&lt;/p&gt;

&lt;p&gt;Many programming languages and frameworks provide built-in support for text encoding. For example, in Java, the String class supports Unicode encoding by default, and the InputStreamReader and OutputStreamWriter classes can be used to read and write text in different encoding schemes.&lt;br&gt;
Conclusion&lt;/p&gt;

&lt;p&gt;In conclusion, text encoding is a crucial concept in software engineering that enables characters to be represented electronically. Understanding text encoding is essential for developing software that can handle characters from different writing systems and languages.&lt;/p&gt;

</description>
      <category>textencoding</category>
      <category>utf8</category>
      <category>programmingbasics</category>
      <category>unicode</category>
    </item>
    <item>
      <title>How do they know your username is already taken so fast?</title>
      <dc:creator>himank</dc:creator>
      <pubDate>Wed, 01 Mar 2023 13:10:17 +0000</pubDate>
      <link>https://dev.to/himankbhalla/how-do-they-know-your-username-is-already-taken-so-fast-1hc3</link>
      <guid>https://dev.to/himankbhalla/how-do-they-know-your-username-is-already-taken-so-fast-1hc3</guid>
      <description>&lt;p&gt;How do some websites tell you immediately that your username is already in use? How can they search your username from disks so fast? The magic trick is an efficient data structure called Bloom Filters.&lt;/p&gt;

&lt;p&gt;Bloom filters are a space-efficient probabilistic data structure used to test whether an element is a member of a set. It is often used to reduce the number of disk I/O operations required to check if an element is in a set by avoiding disk access altogether. In this blog, we’ll explore the inner workings of bloom filters, how they are used, the advantages and limitations of this powerful data structure.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flpr7xvj9swe18nr80xiu.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flpr7xvj9swe18nr80xiu.jpeg" alt="Bloom Filter Pattern | Redis" width="517" height="348"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Implementation Details:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Bloom filters are implemented as a bit array with a set of hash functions that map elements to the indices in the bit array.&lt;/li&gt;
&lt;li&gt;When an element is added to the set, the hash functions are applied to the element, and the corresponding bits in the bit array are set to 1.&lt;/li&gt;
&lt;li&gt;When testing for membership of an element, the hash functions are applied to the element, and the corresponding bits in the bit array are checked.&lt;/li&gt;
&lt;li&gt;If all the bits are set to 1, then the element is probably in the set. Otherwise, it is definitely not in the set.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The main advantage of Bloom filters is that they allow for quick and efficient membership tests without the need for disk I/O operations. This is especially important for applications that require large sets and need to test for membership quickly and frequently. Another advantage of Bloom filters is that they can be implemented with a low false positive rate, which is the rate at which the Bloom filter returns that an element is in the set when it is actually not.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Applications:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;One of the main applications of Bloom filters is in the field of distributed systems, where they are used to reduce the number of network requests between nodes. For example, if a node needs to check if an element is in a set, it can first check its local Bloom filter before sending a request to another node. This can significantly reduce the number of network requests and improve overall system performance.&lt;/p&gt;

&lt;p&gt;Another application of Bloom filters is in network security, where they are used to detect malicious traffic. For example, a Bloom filter can be used to maintain a list of known malicious IP addresses and to test incoming traffic against the list to detect malicious traffic. This approach is much more efficient than checking every incoming IP address against a list of known malicious IP addresses, as the number of false positive results is kept to a minimum.&lt;/p&gt;

&lt;p&gt;Bloom filters can also be used in other areas, such as spell-checking, database indexing, username availability tests and text indexing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Limitations:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;One of the main limitations of Bloom filters is their limited capacity. As the number of elements in the set grows, the false positive rate increases, eventually reaching a point where the Bloom filter becomes less helpful. However, this can be mitigated by increasing the size of the bit array or by using more hash functions, although this will increase the amount of memory required by the Bloom filter.&lt;/p&gt;

&lt;p&gt;You can take advantage of this in redis as well. To know more please checkout this &lt;a href="https://redis.com/blog/bloom-filter/" rel="noopener noreferrer"&gt;link&lt;/a&gt;. Originally published at &lt;a href="https://medium.com/@himankbh/what-are-bloom-filters-50790a39add8" rel="noopener noreferrer"&gt;medium&lt;/a&gt;&lt;/p&gt;

</description>
      <category>bloomfilters</category>
      <category>redis</category>
      <category>systemdesign</category>
      <category>scalablearchitecture</category>
    </item>
    <item>
      <title>About Javascript from the very basics</title>
      <dc:creator>himank</dc:creator>
      <pubDate>Tue, 28 Feb 2023 05:14:15 +0000</pubDate>
      <link>https://dev.to/himankbhalla/about-javascript-from-the-very-basics-k26</link>
      <guid>https://dev.to/himankbhalla/about-javascript-from-the-very-basics-k26</guid>
      <description>&lt;p&gt;JavaScript is a popular programming language used in both browser and server-side applications. Understanding how JavaScript works in both environments is essential for developers looking to write efficient and optimized code. In this blog, we will explore how JavaScript works in browser and Node.js environments.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;JavaScript in the Browser&lt;/strong&gt;&lt;br&gt;
The browser is the most common environment in which JavaScript is used. When a user visits a website, their browser downloads the HTML, CSS, and JavaScript files associated with the page. The browser then executes the JavaScript code, which can modify the content of the page, add interactivity, and communicate with the server.&lt;br&gt;
There are two ways to include JavaScript code in a webpage: inline and external. Inline scripts are included directly in the HTML file using the &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; tag. External scripts, on the other hand, are stored in separate files and linked to the HTML file using the &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; tag.&lt;br&gt;
When a browser encounters a &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; tag, it downloads the associated JavaScript file and begins parsing it. During parsing, the browser creates an abstract syntax tree (AST) to represent the code. The AST is then passed to the engine, which compiles the code into machine-readable instructions. The engine then executes the instructions, modifying the Document Object Model (DOM) and Cascading Style Sheets (CSS) as needed.&lt;br&gt;
One of the unique features of JavaScript in the browser is its ability to interact with the DOM. The DOM is a tree-like structure that represents the content and structure of an HTML page. JavaScript can manipulate the DOM by adding or removing elements, changing attributes, and responding to events.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;JavaScript in Node.js&lt;/strong&gt;&lt;br&gt;
Node.js is an environment that allows JavaScript to run outside of the browser, on a server. Node.js provides a range of built-in modules, including a file system module, a networking module, and a module for interacting with the operating system. Node.js uses the V8 engine, the same engine used by the Google Chrome browser, to execute JavaScript code.&lt;br&gt;
One of the key differences between JavaScript in the browser and Node.js is the lack of a DOM in Node.js. Instead, Node.js provides a range of modules for interacting with the file system, networking, and other server-side functionality. This allows developers to build powerful server-side applications using JavaScript.&lt;br&gt;
Another difference between the two environments is the way code is loaded and executed. In the browser, JavaScript files are downloaded and parsed as they are encountered in the HTML file. In Node.js, JavaScript files are loaded using the require() function, which loads the code and any associated dependencies into memory. Once loaded, the code can be executed and any exported functions can be called.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Asynchronous Programming in JavaScript&lt;/strong&gt;&lt;br&gt;
Both the browser and Node.js environments support asynchronous programming, a programming paradigm that allows code to run concurrently without blocking the main thread. Asynchronous programming is essential for building responsive and scalable applications.&lt;br&gt;
In JavaScript, asynchronous programming is achieved using callbacks, promises, and async/await. Callbacks are functions that are passed as arguments to other functions and are called when the asynchronous operation is complete. Promises provide a cleaner syntax for asynchronous programming, allowing developers to chain multiple asynchronous operations together. Async/await is a more recent addition to JavaScript and provides a cleaner syntax for working with promises.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Threading and Concurrency in JavaScript&lt;/strong&gt;&lt;br&gt;
JavaScript is a single-threaded language, meaning that only one task can be executed at a time. This can pose challenges when working with time-consuming operations, such as network requests or file I/O. To address this limitation, JavaScript provides a range of concurrency techniques, including web workers and the event loop.&lt;/p&gt;

&lt;p&gt;Web workers allow developers to run JavaScript in separate threads, allowing time-consuming operations to be performed without blocking the main thread. Web workers communicate with the main thread using message passing.&lt;/p&gt;

&lt;p&gt;The event loop is a core feature of JavaScript’s runtime environment and is responsible for managing the execution of code. The event loop continuously checks the message queue for new messages and executes them in order, ensuring that the main thread is never blocked.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
JavaScript is a versatile language that can be used in both browser and server-side environments. Understanding how JavaScript works in these environments is essential for writing efficient and optimized code. In the browser, JavaScript can interact with the DOM to add interactivity and modify the content of a page. In Node.js, JavaScript can be used to build powerful server-side applications. Asynchronous programming is essential for building responsive and scalable applications, and JavaScript provides a range of techniques for achieving concurrency, including web workers and the event loop. By understanding these concepts, developers can write better JavaScript code and build more powerful applications.&lt;br&gt;
Originally published at &lt;a href="https://medium.com/@himankbh/about-javascript-here-and-there-b84d734822da" rel="noopener noreferrer"&gt;medium&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>node</category>
      <category>browser</category>
      <category>beginnerprogrammer</category>
    </item>
    <item>
      <title>Demystifying Metaprogramming: Understanding the Basics</title>
      <dc:creator>himank</dc:creator>
      <pubDate>Sat, 25 Feb 2023 03:28:22 +0000</pubDate>
      <link>https://dev.to/himankbhalla/demystifying-metaprogramming-understanding-the-basics-408h</link>
      <guid>https://dev.to/himankbhalla/demystifying-metaprogramming-understanding-the-basics-408h</guid>
      <description>&lt;p&gt;Metaprogramming is a technique in programming where code is written to generate or manipulate other code or to modify the behaviour of a program at runtime. This allows for greater flexibility and adaptability and can make code easier to maintain and reuse. Metaprogramming is used in many programming languages, including Python, Ruby, JavaScript, and Lisp, and is often associated with object-oriented programming. The whole paradigm is broad and can’t be summarized in a single blog. This blog aims to introduce the concept and show its basic usage in various languages. The readers are advised to go deeper into it in their preferred language.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Origin:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The origins of metaprogramming can be traced back to the development of Lisp in the 1950s. Lisp was one of the first programming languages to support the creation of new functions and data structures at runtime, which gave it a high degree of flexibility and extensibility. Later, the concept of metaprogramming was popularized by Smalltalk, a programming language developed in the 1970s, which introduced the idea of sending messages to objects at runtime.&lt;/p&gt;

&lt;p&gt;In modern programming languages, metaprogramming can take many forms, including dynamic code generation, dynamic method invocation, and reflection.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Dynamic code generation involves creating code at runtime, either by using code templates or by programmatically constructing code.&lt;/li&gt;
&lt;li&gt;Dynamic method invocation involves calling a method that is not known at compile time but is determined at runtime.&lt;/li&gt;
&lt;li&gt;Reflection involves querying and modifying the internal structure of a program at runtime, such as examining the type of an object or the attributes of a class.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Use cases:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;One of the main use cases for metaprogramming is to create more flexible and adaptable software. Metaprogramming can be used to create reusable code libraries that can be customized for different applications.&lt;/p&gt;

&lt;p&gt;Here are some of the use cases:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;By generating code programmatically, developers can avoid writing repetitive or error-prone code, and can create more abstract and expressive code.&lt;/li&gt;
&lt;li&gt;Metaprogramming can also be used to encapsulate complex implementation details, making code easier to understand and maintain.&lt;/li&gt;
&lt;li&gt;Metaprogramming can be used to improve performance and reduce memory usage. By generating code at runtime, developers can optimize code for specific use cases or hardware configurations.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here are some examples of metaprogramming in JavaScript, Python, and Ruby:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;JavaScript&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;JavaScript is a language that allows for some forms of metaprogramming, but not as much as other languages like Ruby. One way to achieve metaprogramming in JavaScript is by using the eval() function, which can execute a string of JavaScript code as if it were part of the original program.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const code = 'console.log("Hello, world!");';
eval(code); // Output: "Hello, world!"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Another example is using the Function() constructor to dynamically create a new function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const add = new Function('a', 'b', 'return a + b;');
console.log(add(2, 3)); // Output: 5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Python&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Python is a language that supports a wide range of metaprogramming techniques. One example is using decorators, which are functions that modify the behavior of other functions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def my_decorator(func):
    def wrapper():
        print("Before the function is called.")
        func()
        print("After the function is called.")
    return wrapper

@my_decorator
def say_hello():
    print("Hello!")

say_hello()  # Output: "Before the function is called.", "Hello!", "After the function is called."
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Ruby&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ruby is a language that strongly supports metaprogramming, with features like dynamic method creation, method aliasing, and class modification.&lt;/p&gt;

&lt;p&gt;One example is using method_missing, which is a special method that gets called when an object receives a message it doesn’t understand. This can be used to dynamically create new methods:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class MyClass
  def method_missing(name, *args)
    if name.to_s.start_with?('say_')
      self.class.send(:define_method, name) do
        puts "You called the method #{name} with arguments #{args}."
      end
      send(name, *args)
    else
      super
    end
  end
end

obj = MyClass.new
obj.say_hello("world") # Output: "You called the method say_hello with arguments ["world"]."
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Another example is using the class_eval method to modify the behavior of a class at runtime:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class MyClass
  def say_hello
    puts "Hello!"
  end
end

MyClass.class_eval do
  alias_method :old_say_hello, :say_hello
  def say_hello
    puts "Before saying hello..."
    old_say_hello
    puts "After saying hello."
  end
end

obj = MyClass.new
obj.say_hello() # Output: "Before saying hello...", "Hello!", "After saying hello."
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Overall, metaprogramming is a powerful technique that can be used to create more flexible, adaptable, and maintainable software. While it can be complex and require careful design, metaprogramming can provide significant benefits in many programming contexts.&lt;/p&gt;

</description>
      <category>metaprogramming</category>
      <category>python</category>
      <category>ruby</category>
      <category>scripting</category>
    </item>
    <item>
      <title>Why you should learn vim in 2023?</title>
      <dc:creator>himank</dc:creator>
      <pubDate>Fri, 24 Feb 2023 05:56:40 +0000</pubDate>
      <link>https://dev.to/himankbhalla/why-you-should-learn-vim-in-2023-1c43</link>
      <guid>https://dev.to/himankbhalla/why-you-should-learn-vim-in-2023-1c43</guid>
      <description>&lt;p&gt;As we enter 2023, Vim remains one of the most powerful and versatile text editors available. Despite being over 30 years old, Vim continues to be a popular choice for developers, sysadmins, and other power users. In this article, we’ll explore some of the benefits and capabilities of Vim and why it remains hard to ignore.&lt;/p&gt;

&lt;h2&gt;
  
  
  Benefits of Using Vim
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Speed and Efficiency&lt;/strong&gt;: Vim is designed to be an efficient text editor. Its modal editing and commands can help you work faster and more efficiently. You can use shortcuts and commands to perform complex operations with fewer keystrokes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Customizability&lt;/strong&gt;: Vim is highly customizable. You can customize the key bindings, colour schemes, and other settings to suit your preferences. You can even create your own plugins to extend Vim’s functionality.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Portability&lt;/strong&gt;: Vim is available on many different platforms, including Windows, macOS, Linux, and other Unix-like systems. This means that you can use Vim on any system that you have access to, without having to learn a new editor.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Versatility&lt;/strong&gt;: Vim can be used for many different types of text editing tasks, including coding, writing, and editing configuration files. It also has built-in support for many programming languages, including syntax highlighting and autocompletion.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Familiarity&lt;/strong&gt;: Vim has been around for over 30 years and has a large and dedicated user community. This means that there are many resources available, such as tutorials, documentation, and plugins, to help you learn and use Vim effectively.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Minimalistic Interface&lt;/strong&gt;: Vim has a minimalistic interface that allows you to focus on the text that you’re editing. This can help reduce distractions and improve productivity.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Vim has several capabilities that differentiate it from other editors like Vscode, IntelliJ Idea, and WebStorm.&lt;/p&gt;

&lt;p&gt;Here are some of the key differences:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Modal editing&lt;/strong&gt;: Vim’s modal editing system, where different keystrokes have different meanings depending on the mode you’re in, is very different from other editors. It can be challenging to learn, but it allows for fast and efficient text editing once mastered.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Keyboard-driven interface&lt;/strong&gt;: Vim is designed to be used primarily with the keyboard, with minimal use of the mouse. This can be more efficient for experienced users, but it may take some time to get used to for those who are accustomed to using the mouse extensively.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Lightweight and fast&lt;/strong&gt;: Vim is a lightweight editor that can run on virtually any computer, and it is very fast even on older hardware. This makes it a popular choice for working on remote servers and in low-resource environments.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Customization&lt;/strong&gt;: Vim is highly customizable, with a wide range of configuration options and plugins available. This allows users to tailor the editor to their specific needs and preferences.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Portability&lt;/strong&gt;: Vim is available on many different platforms, including Windows, macOS, and various Linux distributions. This means that users can use Vim on virtually any system they encounter, without having to switch to a different editor.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Low barrier to entry&lt;/strong&gt;: Vim is a simple, yet powerful editor that is easy to install and use. It doesn’t have as steep of a learning curve as some of the more complex IDEs out there, and users can quickly start using its basic capabilities with minimal training.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Some of the top features of Vim, along with an explanation of how to use them:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Modal Editing&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;Modal editing is the most fundamental feature of Vim. Vim has two modes: insert mode and normal mode. In insert mode, you can type and edit text like a regular text editor. In normal mode, you can perform various operations on the text. To enter normal mode, press the Esc key. To enter insert mode, press the i key.&lt;/p&gt;

&lt;p&gt;Example usage:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;To move the cursor one character to the left in normal mode, press the h key.
To move the cursor one word to the left in normal mode, press the b key.
To delete the character under the cursor in normal mode, press the x key.
To enter insert mode at the current cursor position, press the i key.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Commands&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;Vim has many commands that allow you to perform various operations on text. Commands in Vim typically begin with a colon : character. Commands can be used to save files, open new files, execute external commands, and more.&lt;/p&gt;

&lt;p&gt;Example usage:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;To save a file, type :w and press Enter.
To open a new file, type :e [filename] and press Enter.
To execute an external command, type :! [command] and press Enter.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Search&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Vim has powerful search capabilities that allow you to search for text in a file. You can search for text using regular expressions and Vim’s search patterns.&lt;/p&gt;

&lt;p&gt;Example usage:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;To search for the word “hello” in a file, type /hello and press Enter.
To search for the word “hello” and replace it with “world”, type :%s/hello/world/g and press Enter.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Autocompletion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Vim has a built-in autocompletion feature that can be very useful when you’re writing code. Autocompletion can help you save time by suggesting possible completions for the word you’re typing.&lt;/p&gt;

&lt;p&gt;Example usage:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;To activate autocompletion, press Ctrl-n or Ctrl-p in insert mode.
To complete the word you’re typing, press Tab.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Split Windows&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Vim allows you to split the window into multiple panes, each displaying a different part of the file. This can be very useful when you’re working on a large file and need to view multiple parts of the file at once.&lt;/p&gt;

&lt;p&gt;Example usage:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;To split the window horizontally, type :split [filename] and press Enter.
To split the window vertically, type :vsplit [filename] and press Enter.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Registers&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Vim has a feature called registers that allow you to store and retrieve text snippets. You can use registers to store and retrieve text, and even use them to perform complex editing tasks.&lt;/p&gt;

&lt;p&gt;Example usage:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;To copy a line to the clipboard, type yy.
To paste the text into the clipboard, type p.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Macros&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Vim allows you to record and playback macros, which can be very useful for automating repetitive tasks. Macros can be recorded and played back in normal mode. This feature is very interesting and can be used for a variety of repetitive tasks.&lt;/p&gt;

&lt;p&gt;Example usage:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;To record a macro, type q[register] to start recording, perform a series of commands, and then type q to stop recording.
To play back a macro, type @[register].
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Marks&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Vim has a feature called marks that allow you to place bookmarks in a file and quickly navigate to them later. Marks can be placed on specific lines or characters in a file and can be named to make them more easily identifiable.&lt;/p&gt;

&lt;p&gt;Example usage:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;To place a mark on the current line, type m[a-z] where a-z is a lowercase letter.
To jump to a mark, type ‘[a-z] where a-z is the letter of the mark.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Abbreviations&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Vim allows you to define abbreviations that can be expanded into longer text snippets. This can be useful for frequently used commands or long text snippets.&lt;/p&gt;

&lt;p&gt;Example usage:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;To define an abbreviation, type :ab [shortcut] [text] where [shortcut] is the abbreviation and [text] is the text that will be expanded when the abbreviation is used.
To expand an abbreviation, type the shortcut and then press the space bar.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Plugins&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Vim has a rich ecosystem of plugins that can extend its functionality even further. Plugins can be used to add new features, modify existing ones, and make Vim more powerful and easier to use.&lt;/p&gt;

&lt;p&gt;Example usage:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;To install a plugin, use a plugin manager like Vundle or Pathogen to manage the installation and setup.
To use a plugin, follow the instructions provided by the plugin’s documentation or README file.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Why Vim is Still Hard to Ignore&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Despite the many other text editors available, Vim remains popular for several reasons:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Learning Curve&lt;/strong&gt;: Vim has a steep learning curve, which can be intimidating for new users. However, this is also one of its strengths. Once users become proficient with Vim, they can become much more productive and efficient.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Community&lt;/strong&gt;: Vim has a large and active community of users and developers. This community has created a vast array of plugins and documentation that can help users get the most out of Vim.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Legacy&lt;/strong&gt;: Vim has a long history and has been used by developers for over 30 years. This legacy has helped to establish Vim as a reliable and powerful text editor.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In conclusion, Vim is a powerful text editor that has many advanced features that can make editing text faster, easier, and more efficient. It’s modal editing, commands, search capabilities, autocompletion, split windows, registers, macros, marks, abbreviations, and plugins make it a powerful tool for developers, sysadmins, and other power users. With its versatility and customizable features, Vim is still a text editor that is hard to ignore in 2023.&lt;br&gt;
Originally published at &lt;a href="https://medium.com/@himankbh/why-you-should-learn-vim-in-2023-a104ae2b3add" rel="noopener noreferrer"&gt;medium&lt;/a&gt;&lt;/p&gt;

</description>
      <category>vim</category>
      <category>vimlover</category>
      <category>texteditor</category>
      <category>vscode</category>
    </item>
    <item>
      <title>What is Monkey Patching?</title>
      <dc:creator>himank</dc:creator>
      <pubDate>Mon, 20 Feb 2023 03:08:00 +0000</pubDate>
      <link>https://dev.to/himankbhalla/what-is-monkey-patching-4pf</link>
      <guid>https://dev.to/himankbhalla/what-is-monkey-patching-4pf</guid>
      <description>&lt;p&gt;Monkey patching is a programming technique used in software development that allows developers to change or extend the behaviour of existing code without directly modifying the source code. This can be particularly useful when the code is closed-source or the developer doesn’t have access to the original code. In this post, we’ll explore the concept of monkey patching and provide several examples to illustrate how it works.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Monkey Patching?
&lt;/h2&gt;

&lt;p&gt;Monkey patching is a technique that allows developers to change the behaviour of an existing piece of code at runtime. This is done by modifying or adding attributes or methods to an object or class, which can then be called as if they were part of the original code. The term “monkey patching” comes from the idea of a monkey modifying or “patching” a codebase, much like a monkey might tinker with a tool or piece of machinery.&lt;/p&gt;

&lt;p&gt;Monkey patching is often used to fix bugs or add new features to third-party libraries, frameworks, or applications. In some cases, it can be used to add functionality to the language itself. However, monkey patching can be a double-edged sword. While it can be a powerful tool in the hands of experienced developers, it can also lead to unexpected behaviour and hard-to-find bugs.&lt;/p&gt;

&lt;p&gt;Examples of Monkey Patching:&lt;/p&gt;

&lt;p&gt;Here are a few examples that illustrate how monkey patching can be used in practice:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Modifying an Existing Function&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let’s say we’re working with a third-party library that contains a function that doesn’t quite do what we need it to do. Instead of modifying the library’s source code, you can use monkey patching to modify the function’s behaviour at runtime. Here’s an example in Python:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import third_party_library

def new_function(arg1, arg2):
    # new implementation
    return result

third_party_library.existing_function = new_function
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, we’re importing a third-party library and then defining a new function that we want to use instead of the existing function provided by the library. We then use monkey patching to replace the existing function with our new function.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Adding a New Method to a Class&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Another common use case for monkey patching is adding a new method to an existing class. Here’s an example in JavaScript:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class OriginalClass {
  originalMethod() {
    console.log('Original Method');
  }
}

OriginalClass.prototype.newMethod = function() {
  console.log('New Method');
};

let obj = new OriginalClass();
obj.newMethod(); 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, we’re creating a new method called “newMethod” and adding it to the prototype of the “OriginalClass” class. We can then create an instance of the “OriginalClass” and call the new method as if it were part of the original class.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fixing a Bug in a Third-Party Library&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Monkey patching can also be used to fix bugs in third-party libraries that you can’t modify directly. Here’s an example in Ruby:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;require 'third_party_library'

# Define a new method to fix the bug
class ThirdPartyLibrary::OriginalClass
  def fixed_method
    # new implementation
    return result
  end
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, we’re requiring a third-party library and then defining a new method called “fixed_method” that fixes a bug in the original library. We’re using the “::” operator to access the original class in the library and then adding our new method.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion:
&lt;/h2&gt;

&lt;p&gt;Monkey patching is a powerful technique that can be used to modify or extend the behaviour of existing code at runtime. While it can be a useful tool for fixing bugs or adding new features to third-party libraries, it can also introduce unexpected behaviour, hard to find bugs.&lt;br&gt;
Originally posted on &lt;a href="https://medium.com/@himankbh/monkey-patching-63defd49ba7a"&gt;medium&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>monkeypatching</category>
      <category>programmingbasics</category>
      <category>python</category>
      <category>ruby</category>
    </item>
    <item>
      <title>Gossip Protocol: The Secret Sauce of Decentralized Networks</title>
      <dc:creator>himank</dc:creator>
      <pubDate>Thu, 16 Feb 2023 06:38:39 +0000</pubDate>
      <link>https://dev.to/himankbhalla/gossip-protocol-the-secret-sauce-of-decentralized-networks-1m6f</link>
      <guid>https://dev.to/himankbhalla/gossip-protocol-the-secret-sauce-of-decentralized-networks-1m6f</guid>
      <description>&lt;p&gt;In the world of distributed systems, the gossip protocol is a powerful and versatile tool that is used to enable nodes to communicate with one another in a decentralized network. This protocol is designed to allow each node in a network to communicate with a select number of other nodes, and through these interactions, transmit information to the entire network. In this blog post, we will delve deeper into what gossip protocol is, how it works, and its various applications.&lt;/p&gt;

&lt;p&gt;So, what exactly is the gossip protocol and how does it work?&lt;/p&gt;

&lt;p&gt;At its core, the gossip protocol is a simple algorithm that relies on the exchange of messages between nodes in a network. When a node receives a message, it randomly selects a subset of its neighbours to pass the message on to. These neighbours then do the same, passing the message on to a randomly selected subset of their own neighbours, and so on, until the message has been spread throughout the network.&lt;/p&gt;

&lt;p&gt;But the real power of the gossip protocol lies in its ability to adapt to changes in the network. As nodes join or leave the network, the protocol dynamically adjusts the selection of neighbours to ensure that the message is still spread to the entire network. This means that the gossip protocol is extremely resilient and can continue to function even if a large number of nodes fail.&lt;/p&gt;

&lt;h2&gt;
  
  
  Applications:
&lt;/h2&gt;

&lt;p&gt;One of the most popular applications of gossip protocol is blockchain technology. In a blockchain network, nodes use the protocol to share information about transactions and new blocks. Each node in the network maintains a copy of the entire blockchain, and the gossip protocol ensures that each copy is kept up to date as new blocks are added.&lt;br&gt;
But the gossip protocol is not limited to blockchain networks. It can be used in any decentralized network where nodes need to communicate with one another. For example, it is used in peer-to-peer file-sharing networks to help nodes discover each other and share files. It is a highly scalable and fault-tolerant protocol that can function in a wide range of network topologies. And because it is a decentralized protocol, it is not vulnerable to central points of failure or attack.&lt;/p&gt;

&lt;h2&gt;
  
  
  Challenges:
&lt;/h2&gt;

&lt;p&gt;However, the gossip protocol is not without its challenges. Because it relies on a random selection of neighbours, there is a risk that some nodes may receive the message multiple times, while others may not receive it at all. This can lead to uneven distribution of the message throughout the network. There are also issues related to security and privacy, as the protocol relies on all nodes in the network to be trustworthy.&lt;br&gt;
Despite these challenges, the gossip protocol remains a powerful and essential tool for decentralized networks.&lt;/p&gt;

&lt;p&gt;In conclusion, the gossip protocol is a secret sauce of decentralized networks that is essential for enabling nodes to communicate with one another and disseminate information throughout the network. It is a simple and powerful algorithm that is adaptable, fault-tolerant, and scalable. Whether it is used in blockchain networks or other decentralized applications, the gossip protocol is a key ingredient in the recipe for building truly decentralized systems.&lt;/p&gt;

&lt;p&gt;Originally published at &lt;a href="https://medium.com/@himankbh/gossip-protocol-the-secret-sauce-of-decentralized-networks-59205eaf84fe"&gt;medium&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>gossipprotocol</category>
      <category>distributedsystems</category>
      <category>systemdesign</category>
      <category>decentralized</category>
    </item>
    <item>
      <title>Types of OOP</title>
      <dc:creator>himank</dc:creator>
      <pubDate>Tue, 14 Feb 2023 16:52:25 +0000</pubDate>
      <link>https://dev.to/himankbhalla/types-of-oop-gap</link>
      <guid>https://dev.to/himankbhalla/types-of-oop-gap</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqhtxqun6uhqix7iwsjhj.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqhtxqun6uhqix7iwsjhj.jpg" alt="OOP" width="800" height="533"&gt;&lt;/a&gt;&lt;br&gt;
Object-Oriented Programming (OOP) is a popular programming paradigm that many programming languages adopt. The idea is to model real-world concepts as objects, encapsulating data and behaviour within these objects and using these objects to solve complex problems.&lt;/p&gt;

&lt;p&gt;In this blog, we’ll take a closer look at the different types of OOP implementations that various languages adopt. By understanding the different approaches, we’ll gain a deeper appreciation for the power and flexibility of OOP and how it can be applied to solve a wide range of problems.&lt;/p&gt;

&lt;h2&gt;
  
  
  Classical OOP:
&lt;/h2&gt;

&lt;p&gt;Languages such as Java, C++, and Python use this classical implementation. It is based on the concepts of classes, objects, inheritance, polymorphism, and encapsulation. Classes define the blueprint for objects, and objects are instances of classes. Inheritance allows classes to inherit properties and behaviour from their parent classes, while polymorphism enables objects to take on different forms based on the context in which they are used. Encapsulation ensures that objects’ internal state is hidden and only accessible through defined methods.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prototype-based OOP:
&lt;/h2&gt;

&lt;p&gt;Languages such as JavaScript and Lua implement this style of OOP. It is based on the concept of prototypes. Prototypes are objects that serve as templates for other objects. Objects can inherit properties and behaviour from their prototypes. Modify the objects by adding new properties and behaviour at runtime. This approach allows for more dynamic and flexible object creation, but can also lead to difficulties in managing the inheritance chain.&lt;/p&gt;

&lt;h2&gt;
  
  
  Aspect-Oriented OOP:
&lt;/h2&gt;

&lt;p&gt;This implementation is used in languages such as AspectJ and is an extension of classical OOP. It allows developers to define “aspects” of the program that cut across multiple classes and objects, such as logging or security. These aspects can then be woven into the code at runtime, making it possible to add new behaviour to a system without modifying the existing code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Metaobject-Protocol OOP:
&lt;/h2&gt;

&lt;p&gt;Languages such as Common Lisp use this implementaion. It is a type of OOP that allows for customization of the behaviour of the object system itself. It means that developers can define how classes and objects behave in a program, rather than being limited by the default behaviour set by the language.&lt;br&gt;
For example, A developer could define how to create objects, what properties they have, and how they interact with each other. This level of customization provides greater flexibility and control over the object system, but it also requires a deeper understanding of the underlying system.&lt;br&gt;
In simple terms, Metaobject-Protocol OOP gives the ability to shape and mould the object system to fit their specific needs rather than being limited by the object system’s default behaviour.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion:
&lt;/h2&gt;

&lt;p&gt;In conclusion, each of these OOP implementations offers its own unique set of features and benefits. Understanding the different approaches will help you to make an informed decision and choose the implementation that best suits your needs. Whether you’re a seasoned developer or just starting, OOP is a powerful tool that will help you to create robust and maintainable software.&lt;/p&gt;

&lt;p&gt;Originally, published at &lt;a href="https://medium.com/@himankbh/types-of-oop-8885423d5a00" rel="noopener noreferrer"&gt;medium&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>oop</category>
      <category>programmingparadigm</category>
      <category>objectorientedprogramming</category>
      <category>prototypebasedoop</category>
    </item>
    <item>
      <title>Hashable vs Immutable Objects in python</title>
      <dc:creator>himank</dc:creator>
      <pubDate>Fri, 10 Feb 2023 07:38:07 +0000</pubDate>
      <link>https://dev.to/himankbhalla/hashable-vs-immutable-objects-in-python-2l9g</link>
      <guid>https://dev.to/himankbhalla/hashable-vs-immutable-objects-in-python-2l9g</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1400%2F0%2AvU26HDmNW6-LrI7M" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1400%2F0%2AvU26HDmNW6-LrI7M" alt="image" width="1400" height="1050"&gt;&lt;/a&gt;&lt;br&gt;
In Python, two important concepts to understand are hashable and immutable objects. These concepts determine how objects are stored and manipulated in memory, and they have a significant impact on the performance and functionality of our code.&lt;/p&gt;
&lt;h2&gt;
  
  
  Hashable Objects:
&lt;/h2&gt;

&lt;p&gt;A hashable object is an object that has a hash value that never changes during its lifetime. This means that its value can be used as a key in a dictionary or as an element in a set. Examples of hashable objects in Python include integers, floating-point numbers, strings, and tuples (if they contain only hashable elements).&lt;/p&gt;

&lt;p&gt;When you try to use an unhashable object as a key in a dictionary, Python will raise a TypeError. For example, lists are unhashable, so you cannot use them as keys in a dictionary:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;d = {[1, 2, 3]: "list"}  # Raises TypeError
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Python has a built-in hash method ( &lt;strong&gt;hash&lt;/strong&gt;() ) that can be used to compare other objects. If the hashable objects are equal then they have the same hash value.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print(hash(5))           # 5

print(hash("hello"))     # 6089416059157437065

print(hash(2+3))         # 5

print(hash("hello"))     # 6089416059157437065
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Immutable Objects:
&lt;/h2&gt;

&lt;p&gt;An immutable object is an object whose state cannot be changed after it is created. This means that once you create an object, you cannot modify its value. Examples of immutable objects in Python include integers, floating-point numbers, and strings. All immutable built-in objects in Python are hashable like tuples while the mutable containers like lists and dictionaries are not hashable.&lt;/p&gt;

&lt;p&gt;The advantage of using immutable objects is that they are safer to use in concurrent environments, as their state cannot be changed by another thread. This makes them easier to reason about and less prone to bugs.&lt;/p&gt;

&lt;p&gt;On the other hand, mutable objects (such as lists and dictionaries) are more flexible and can be used for more complex data structures, but they can be harder to understand and debug when used in concurrent environments.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/himankbhalla/why-should-i-care-about-immutables-in-python-4ofn"&gt;Checkout my other article about immutables in python.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Conclusion:&lt;/p&gt;

&lt;p&gt;In conclusion, understanding the difference between hashable and immutable objects is crucial for writing efficient and maintainable Python code. When choosing between mutable and immutable objects, consider the requirements of your code and the trade-offs between flexibility and safety. In general, it is recommended to use immutable objects whenever possible, as they are easier to understand and less prone to bugs.&lt;/p&gt;

</description>
      <category>python</category>
      <category>immutability</category>
      <category>hashable</category>
      <category>datastructure</category>
    </item>
  </channel>
</rss>
