<?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: Sushant Ranjan</title>
    <description>The latest articles on DEV Community by Sushant Ranjan (@sushantranjan4u).</description>
    <link>https://dev.to/sushantranjan4u</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%2F677158%2F642827be-5f97-49f9-9fe1-fc379c538f08.jpeg</url>
      <title>DEV Community: Sushant Ranjan</title>
      <link>https://dev.to/sushantranjan4u</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sushantranjan4u"/>
    <language>en</language>
    <item>
      <title>Avoid using IDEs for programming - if you are an absolute beginner</title>
      <dc:creator>Sushant Ranjan</dc:creator>
      <pubDate>Sat, 19 Mar 2022 05:36:38 +0000</pubDate>
      <link>https://dev.to/sushantranjan4u/avoid-using-ides-for-programming-if-you-are-an-absolute-beginner-4efc</link>
      <guid>https://dev.to/sushantranjan4u/avoid-using-ides-for-programming-if-you-are-an-absolute-beginner-4efc</guid>
      <description>&lt;p&gt;When I started learning my first programming language, my teacher told me to try to do more programming on paper and depend less on IDEs. I didn’t realize the importance of it at that time. Now that I look back I realize she was right. And that is what serves as motivation for this article.&lt;/p&gt;

&lt;p&gt;So, are you thinking of getting into tech through programming? Or planning to learn a new programming language? Or simply want to build cool stuff through coding? The usual first step almost every course will tell you - Install the IDE for that language. IDEs are super useful for maintaining large code files, debugging, even writing code. But if you are just starting your programming journey and have taken the first step into this world, my advice - don’t install an IDE.&lt;/p&gt;

&lt;p&gt;At first glance that sounds a bit counterintuitive, doesn’t it? Why wouldn’t anyone install the support structure for learning a new language? Borrowing from Zed Shaw’s Learning Python the Hard Way - “Do not use an Integrated Development Environment while you go through this book”. He mentions it only for his book but I suggest you consider it for any language you plan to learn.&lt;/p&gt;

&lt;p&gt;The reason I am suggesting such a weird thing is because IDEs are supposed to support you in your life as a developer. But when you use them while learning the basics they tend to become the crutches on which the entire weight of your coding skill hangs upon. Let’s look at some of the “features” of modern IDEs that actually hamper a newbie:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;You need to learn the basic keywords, get into the habit of typing code, and above all build your muscle memory by writing basic programs so that tomorrow when you look at a blank screen you know what it is you are going to type, why you are doing it, and how you plan to proceed. Modern IDEs tend to autocomplete/autosuggest language specific keywords, variable names on the fly. While this reduces the amount of typos you make, it also reduces the chance of you learning from your mistakes.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;IDEs today have become very advanced. They don’t just beautify your code and provide good indentation. They keep checking your code as you type it and throw errors even before you are finished with the code, for e.g. missing parenthesis. This is all well and good for a developer in a rush to release a new product and or someone trying to fix a bug. But as a newbie you want to be able to figure these things out for yourself. They help you grow as a developer.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Then comes the learning curve of the IDE. You don’t want to be worried about how to run the IDE, what extensions to install, how to resolve any issues with the IDE itself etc. As a beginner in the world of coding you want to focus your entire attention onto the language, it’s syntax, and semantics. &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If IDEs have so many long term effects then why do most developers suggest them? Simple, it makes their lives easier. But they are seasoned developers. They have already done the hard work learning the language. Now they are doing the smart work to get more efficient.&lt;/p&gt;

&lt;p&gt;Your brain should train for the programming needs. Not for the IDE.&lt;/p&gt;

&lt;p&gt;Now the question arises, what should one use when starting out in the exciting world of coding. My suggestion is, any regular text editor is good enough to start learning any programming language as it helps build confidence in the language that you are learning and have a better future.&lt;/p&gt;

&lt;p&gt;This is my take on the use of IDEs while learning to code. Do share your experience in the comments section. I will be writing more articles on learning to code. Follow this blog to stay updated. If there is any specific topic you want me to write on, let me know in the comments.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>programming</category>
      <category>codenewbie</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Fundamentals of Short-circuiting with JavaScript</title>
      <dc:creator>Sushant Ranjan</dc:creator>
      <pubDate>Wed, 16 Mar 2022 11:35:30 +0000</pubDate>
      <link>https://dev.to/sushantranjan4u/fundamentals-of-short-circuiting-with-javascript-5cnj</link>
      <guid>https://dev.to/sushantranjan4u/fundamentals-of-short-circuiting-with-javascript-5cnj</guid>
      <description>&lt;p&gt;Conditional blocks are an integral part of any programming language. The same goes for JavaScript. As beginners, we are taught to either use if-else blocks or switch-case statements to control the flow of our program. As we move ahead we encounter ternary operators which can be used in place of single if-else blocks to write cleaner code. But when the code doesn’t require an else block using a ternary kind of becomes redundant and the concept of DRY(Don’t Repeat Yourself) kicks in.&lt;/p&gt;

&lt;p&gt;This is where short-circuiting comes in. Short-circuiting is basically using logical operators to write flow control logic or render things conditionally.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Logical Operators&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Logical Operators are used for connecting two expressions and return true or false depending on the expression. The logical operators we are interested in for short-circuiting purposes are &amp;amp;&amp;amp; and || (pipe symbol above the Enter key). These operations come from Boolean algebra will help us understand why short-circuiting works the way it does.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&amp;amp;&amp;amp; - The logical AND operator&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The behavior of an AND operator is shown in below truth table:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;strong&gt;Input1&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Input2&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Output&lt;/strong&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;For our purposes, 0 is false and 1 is true. If we look closely at the first two rows we can see that AND doesn’t really care whether the second input is true or false if the first input is false and the output becomes false. For better understanding, we can condense the above table as follows:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;strong&gt;Input1&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Input2&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Output&lt;/strong&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;X&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Here “X” denotes that AND doesn’t care about the input value so we don’t as well. Hence, if Input1 is falsy we don’t need to check the second and can immediately say that the output will be false. However, if Input1 is true then we need to check the Input2 to decide what the output of our AND operation will be. This same logic is used in JavaScript (and other programming languages) to assign values conditionally using lesser code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let allowLogin = userExists &amp;amp;&amp;amp; passwordIsCorrect
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above code snippet, the passwordIsCorrect will only be checked if the userExists variable has a truthy value. If userExists has a falsy value, allowLogin will simply be assigned false because the value of passwordIsCorrect doesn't matter anymore.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;|| - The logical OR operator&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The behavior of an OR operator is shown in below truth table:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;strong&gt;Input1&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Input2&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Output&lt;/strong&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;For our purposes, 0 is false and 1 is true. If we look closely at the first two rows we can see that OR doesn’t really care whether the second input is true or false if the first input is true and the output becomes true. For better understanding, we can condense the above table as follows:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;strong&gt;Input1&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Input2&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Output&lt;/strong&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;X&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Here “X” denotes that OR doesn’t care about the input value so we don’t as well. Hence, if Input1 is truthy we don’t need to check Input2 and can immediately say that the output will be true. However, if Input1 is falsy then we need to check the Input2 to decide what the output of our OR operation will be. This same logic is used in JavaScript (and other programming languages) to assign values conditionally using lesser code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let displayName = userName || "guest"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above code snippet, the displayName will be assigned the value of "guest" if the userName variable has a falsy value. If userName has a truthy value, displayName will simply be assigned the value of userName.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>tutorial</category>
      <category>programming</category>
    </item>
    <item>
      <title>Importance of code comments</title>
      <dc:creator>Sushant Ranjan</dc:creator>
      <pubDate>Wed, 10 Nov 2021 10:56:45 +0000</pubDate>
      <link>https://dev.to/sushantranjan4u/importance-of-code-comments-5020</link>
      <guid>https://dev.to/sushantranjan4u/importance-of-code-comments-5020</guid>
      <description>&lt;p&gt;Few days back I was going through some of my old code for a personal project of mine and the difficulty I faced trying to understand my own code motivated me to write this article. All because I didn’t care to add comments. Similar to my previous article, this too is for the beginners. To guide and help them learn from my mistakes.&lt;/p&gt;

&lt;p&gt;So, why are comments so important in coding? As a beginner, especially when we start writing some basic code we are told to comment out code properly. But we, in our excitement to see our code running and the output being displayed on the screen don’t really pay heed to it. We code, make sure the output is correct, and move on to the next one. This slowly becomes a habit and even in professional situations we forget to comment out code. What happens then is that when we need to go back to look at a piece of code which we wrote even just a few months back we end up wasting hours just trying to make sense of what we did and why we did. Trust me it happens.&lt;/p&gt;

&lt;p&gt;Similarly, if we get a code from another developer which does not have comments or has badly written code comments, we have to waste precious hours (hours which can be better utilized actually writing code) just making heads or tails of the code. Now, you don't want this to happen with you and further, you don't want your code to cause the same to someone else. Hence, the need to start adding code comments.&lt;/p&gt;

&lt;p&gt;Another way to look at this is, imagine working with a team of developers. You need to connect and coordinate to render the output. Not commenting would mean spending hours to understand what the program does and how. This adds to the time taken to build the project, costing both in terms of money and effort.&lt;/p&gt;

&lt;p&gt;Hope that makes sense. Let me try putting it in a different way. Here are a few ways commenting your code helps:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;It makes immediate sense to other coders reading it:&lt;/strong&gt; When working with a team of developers or an open source project with several contributors you want to make sure that your code makes sense to others working alongside you. This is where code comments come into the picture. Not only do good code comments explain what you are trying to achieve, but also reduce the chances of bugs and errors caused by misunderstanding between two developers working on common code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;It makes sense to you when you come back after a while:&lt;/strong&gt; Whether you are working in a professional setting or otherwise, more often than not, situations will arise where you will have to revisit old code. It may be for fixing a client issue or making an enhancement or simply to reuse the already-written code for your new project. Whatever be the case, good code comments make sure you don’t have to struggle to remember what you wrote and why it was done in that way. You might think, ”Oh, it’s my code I will remember” but you won’t. If you add good code comments while writing the code you need not go through this frustrating scenario.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Helps you in structuring your code better:&lt;/strong&gt; When you have read code from different developers for a long time, you will feel some of the code is just so elegant and free flowing that the next step feels obvious. Code comments help in writing such clean code. Writing code comments along with your code helps you think in a certain way. Sort of like steps in a recipe. This helps you structure your code better and overall flow of the code improves.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Experimenting with your code:&lt;/strong&gt; Sometimes while tackling a problem you might come up with multiple solutions for the same or while learning you might want to try the same problem in a different manner. Code comments can help you here as well. Instead of deleting the working code or starting in an entirely new file, simply comment out the part you want to implement differently and experiment away. This makes sure you don’t break anything while trying something new.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Documentation generation:&lt;/strong&gt; Most of you might not know this but code comments are a superb way for generating software documentation(user guides/manuals). If you have good code comments within your code, the documentation step becomes a lot easier. It further reduces the time and effort required, making the software ready to ship.&lt;/p&gt;

&lt;p&gt;Most of the time coding is a community exercise involving more than one person usually. The habit of commenting makes sure your code is more readable and well structured making life easier for you and your peers in the long run.&lt;/p&gt;

&lt;p&gt;There’s the other side of the coin as well. Too many comments. You don’t want a program of 30 lines to have 40 lines of comments. You don’t have to comment on each and every line of code. Parts of code which are self-explanatory don't require code comments. For example, a print statement doesn’t need a comment saying “This line prints something”. Don’t write vague comments. They just complicate things.&lt;/p&gt;

&lt;p&gt;Remember, code comments should be at places where they are necessary for the code to make sense to a completely new reader. Comments should be a helping hand not a burden.&lt;/p&gt;

&lt;p&gt;So, the question that comes here is, how exactly do we decide where to comment and where to not?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Golden Rule for Commenting Code&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;As a general rule of thumb, you can put comments in places where you are using a specific approach to solve a problem which otherwise might not be apparent to someone else. Basically, the idea is to state why you did what you did. One line explanations for code blocks like functions. Places where the flow of your code changes.&lt;/p&gt;

&lt;p&gt;As you can see it is very important to add comments to your code. Badly commented code is as bad as not commented code if not more. Hence, it is important to build a habit of commenting code from the start.&lt;/p&gt;

&lt;p&gt;That was it from my side on the importance of commenting. Follow this blog to stay updated. If there is any specific topic you want me to write on, do let me know in the comments. Till then, Keep coding, Keep learning, Cheers !!!&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>codenewbie</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
