<?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: Vaibhav Kubre</title>
    <description>The latest articles on DEV Community by Vaibhav Kubre (@kubre).</description>
    <link>https://dev.to/kubre</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%2F475206%2F51a04df3-8ef7-40e0-b799-05aa25417533.jpg</url>
      <title>DEV Community: Vaibhav Kubre</title>
      <link>https://dev.to/kubre</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kubre"/>
    <language>en</language>
    <item>
      <title>Why make a game as a Web Dev?</title>
      <dc:creator>Vaibhav Kubre</dc:creator>
      <pubDate>Tue, 06 Feb 2024 00:00:00 +0000</pubDate>
      <link>https://dev.to/kubre/why-make-a-game-as-a-web-dev-388i</link>
      <guid>https://dev.to/kubre/why-make-a-game-as-a-web-dev-388i</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwc8xoq7rco4rny6ofdyj.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwc8xoq7rco4rny6ofdyj.jpg" alt="Header" width="800" height="524"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When I was kid we had a Samsung CRT TV. Nothing special about but it had few embedded games. One of it was a game where you shoot from left side of the screen and balloons appear on right side. The moment you miss it's game over. It was bare bones had nothing other than moving ellipses as balloons and no levels or any fancy stuff. But I loved that interactive experience so much, This was the first game I experienced. This got me introduced to video games. After that I played many games and since school I always wanted to make one myself. This was the initial reason even why I decided even to study Computer Science in the first place.&lt;/p&gt;

&lt;h2&gt;
  
  
  Experience
&lt;/h2&gt;

&lt;p&gt;I've looked into making games before multiple failed attempts at using game engines like unity, unreal or even the one that don't require you to learn code. But due to multiple reasons I really never finished and released something out. Unlike web dev projects where I was not only able to learn and work on vast variety of problems but also able to showcase them and eventually start as freelancer and then as a full time.&lt;/p&gt;

&lt;p&gt;I wasn't only looking to just cobble up some code together but wanted add some polish the output. Polish in form of levels, pause options, graphics, and simple narrative and even music if time lets me do it.&lt;/p&gt;

&lt;p&gt;Over period of two weeks during my free time I downloaded Godot Engine and reuse one of my old project to make this new game. There were so many new things I ended up learning here are just few,&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Trying to come with game mechanics and story.&lt;/li&gt;
&lt;li&gt;Making art (I'm not an artist), and frame by frame animation.&lt;/li&gt;
&lt;li&gt;Cohesive Art style.&lt;/li&gt;
&lt;li&gt;Physics and collision detection.&lt;/li&gt;
&lt;li&gt;New language (GDScript) and data structures.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I also so many parallel problems that I already face in web but now in different context.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Managing state of the running game. (I struggled with this a lot)&lt;/li&gt;
&lt;li&gt;How to update the state (In Godot you can emit a signal and other nodes can listen to it).&lt;/li&gt;
&lt;li&gt;Save and loading game state. (For this game I wanted to store game levels, unlocks and score as a JSON file, I hand wrote serialization and deserialization code for this. Not recommended but certainly fun).&lt;/li&gt;
&lt;li&gt;Input handling and feedback on action to the user. (Ex: When player fires cannon, there is small progress bar that empties and then fills up letting user know when they can fire again).&lt;/li&gt;
&lt;li&gt;Modularizing code and composing entire game from nodes. (Like components in React)&lt;/li&gt;
&lt;li&gt;Building and deploying game.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you want to find more about the game you can find game design document I wrote for this game &lt;a href="https://kubre.in/work/depot-gato"&gt;here&lt;/a&gt;. It's not too big or technical but it's a small overview of what went behind in making the Depot Gato.&lt;/p&gt;

&lt;h2&gt;
  
  
  🤔 Why make a game as a Web Dev?
&lt;/h2&gt;

&lt;p&gt;Other than personal nostalgia it's just great idea to step out of your comfort zone and try something new. If you're custom to certain flow and knowledge you're not challenging yourself enough. Working on game you get to enter this new domain of unknown challenges and problems. It's a great way to test yourself whether you've grown as a problem solver or you've been merely remembering things. Coding practices to problems would change but the core skills of your ability to solve complex problems by breaking them down to smaller ones and then solving them would remain same.&lt;/p&gt;

&lt;p&gt;Did I enjoy this experiment, Yes! Would I do it again Yes!! Would I leave my job and become a game developer full time No! If you're working in certain field and you have been only been programming single language or working on single type of project, you're missing out on so much. This is not just about making a game, honestly you might not even like playing games. But you can challenge yourself in different shapes and form. I constantly like to take look at new libraries, frameworks, languages or even new paradigms, and much more. My goal is to never to be expert in all of those but rather discover in what ways people are solving problems. This was the same reason I gave functional programming a try few years back didn't like it to be turn my self into Monad enjoyer, but to this day I learned to love immutability and iterators, and pattern matching common in functional languages.&lt;/p&gt;

&lt;p&gt;This was a short post about me mostly blabbering about my experience hope you enjoyed it.&lt;/p&gt;

</description>
      <category>softwareengineering</category>
      <category>story</category>
      <category>videogame</category>
      <category>steppingoutofcomfortzone</category>
    </item>
    <item>
      <title>X does not work and I must use Y</title>
      <dc:creator>Vaibhav Kubre</dc:creator>
      <pubDate>Sun, 13 Aug 2023 00:00:00 +0000</pubDate>
      <link>https://dev.to/kubre/x-does-not-work-and-i-must-use-y-2f6</link>
      <guid>https://dev.to/kubre/x-does-not-work-and-i-must-use-y-2f6</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqaa79htiw3djvidzzb3l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqaa79htiw3djvidzzb3l.png" alt="Header" width="800" height="522"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So you’re working on something that you usually don't work on, out of your field but you’re going to learn something new. So you dive in. Your entire application has been written over years and is messy and unbearable to look at, so bad you did not let the clean code guy near it in fear of them having a heart attack.&lt;/p&gt;

&lt;p&gt;A team call, everybody joins and the manager talks about how our application is unable to scale to meet the requirements. As soon as the requests start flooding in you see the constant stream of 504 Gateway timeouts and you wonder, Why?&lt;/p&gt;

&lt;p&gt;Now there are two approaches here. let me take you to the wrong one first (In my objective opinion).&lt;/p&gt;

&lt;h2&gt;
  
  
  X does not work and I must use Y
&lt;/h2&gt;

&lt;p&gt;So, you think maybe your Nginx server is having issues serving requests, and you scour the internet for a solution you implement multiple solutions suggested to you with no luck, and now the server is handling even handling fewer requests than it did before.&lt;/p&gt;

&lt;p&gt;You and the team find yourself stuck and then someone in the team says maybe X is just not capable of handling the requests. They saw big tech use Y in their tech stack. what if we use Y or Y before it? and more variations of this sentence. So begins the journey of throwing in solutions of fancy things that helped big tech scale. But all of you are new to those solutions and still keep having issues with performance. After all this, you keep wondering how others are scaling up easily and you’re stuck in here with the same tech as them.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Also why all the alternatives to Y are like Y but smaller, Y but written in rust, and best one Y with functional syntax.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  The “better approach”
&lt;/h2&gt;

&lt;p&gt;You were not wrong in the beginning you tried to think about where the problem might lie in the system. But you did not do one thing you should have started profiling your application while doing the performance testing. The problem in X does not work and I must use Y you failed to get to the core of the problem. You’d probably find sever failing to handle so many requests even despite hardware being more than capable enough was your application was having some tuning issues. Maybe there was a line of code that was performing blocking IOs or regex that was too clever (a personal story for some other day), or too much memory was being created too fast so GC keeps kicking in, etc. Using the results you finally fixed the issues and now the server is having no issues scaling to more requests.&lt;/p&gt;

&lt;p&gt;I’m not saying you might never need Y, there is a reason it’s made and its being used. But once you need Y you will find you understanding why you need Y and not I think Y will solve my problem because I think so.&lt;/p&gt;

&lt;p&gt;The above example I gave was around ~performance but there are more areas in which this can apply. The example could be you’re doing a rewrite of part of the applications so you end up using something completely new because it’s what is the trend. I’m looking at everyone who completely left server rendering because SPA where all the buzz. Or you heard this new js framework is blazingly faster than the one you’re using, so must rewrite your entire application in it. So many scenarios where people completely switch parts or entire tech stacks without taking time to give thought to their core problems.&lt;/p&gt;

&lt;p&gt;I’m not blaming anyone because I’ve done this so many times and I unconsciously do this even today. But now from next time if you’re just deciding to just throw Y at something consider taking in time to understand why is X failing for you.&lt;/p&gt;

</description>
      <category>softwareengineering</category>
      <category>story</category>
    </item>
    <item>
      <title>Level up years of experience before graduating</title>
      <dc:creator>Vaibhav Kubre</dc:creator>
      <pubDate>Sun, 26 Feb 2023 00:00:00 +0000</pubDate>
      <link>https://dev.to/kubre/level-up-years-of-experience-before-graduating-h27</link>
      <guid>https://dev.to/kubre/level-up-years-of-experience-before-graduating-h27</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0jdidxwxr7wcf5z0dw21.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0jdidxwxr7wcf5z0dw21.png" alt="Header" width="789" height="403"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;If you're currently in college or approaching graduation, you might be wondering how to enhance your skills for your future career or personal development. It can be challenging to know where to start and how to gain practical experience, as well as connect with experienced individuals who can guide you. Fortunately, there are several ways you can gain valuable experience and improve your skills even before you graduate.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;List of ways to level up your experience before graduating:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Projects&lt;/li&gt;
&lt;li&gt;Internships&lt;/li&gt;
&lt;li&gt;Freelancing&lt;/li&gt;
&lt;li&gt;Other Activities&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;br&gt; Though not in any particular order, I'll be going through each of them and explaining what they are and their pros and cons.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Projects
&lt;/h2&gt;

&lt;p&gt;One of the easiest ways to add value to your profile is by starting with projects. If you're a computer science student, you've likely heard of "side projects" or "personal projects." These are projects that you work on independently or with a group, ranging from a simple website to a complex application. The goal is to learn something new and apply it to your project, and you can use these projects to demonstrate your skills to potential employers or clients.&lt;/p&gt;

&lt;p&gt;Projects offer a great opportunity for continuous learning and growth. When it comes to selecting a project to work on, it's entirely up to you. However, if it's your first project, I suggest starting small, ideally, something that can be completed within a week or two (ex if you want to be a web developer simple Shopify, medium, notion clone). This will help you get a sense of what it's like to build something from scratch, as well as teach you the basics of the tools you're using. Once you've finished your first project, you can move on to larger and more complex projects.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;What is the limit? How many projects should I have?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;There is no limit to how many projects you can have. The more the better(generally). But I would recommend having at least 3-4 projects. This will help you showcase your skills and also help you learn new things. If you're applying for a job don't be discouraged while you're in the middle of building these projects.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Internships
&lt;/h2&gt;

&lt;p&gt;In my opinion, internships are the best way for college students to gain practical experience in their field of study. However, the tricky part is getting one in the first place. Usually, you would have to go through an interview process, which can be challenging for some people, especially if they don't have much experience or are unsure of what questions to expect.&lt;/p&gt;

&lt;p&gt;Although this post is not about how to land an internship, the first step is to start building projects. Creating and sharing personal projects on platforms like GitHub can showcase your skills and demonstrate your passion for the field. This can make a significant impact on recruiters who are looking for candidates with experience and passion for the work.&lt;/p&gt;

&lt;p&gt;But why are internships so valuable? Landing a good internship can provide you with the opportunity to work in a team, with a clear direction, and typically with a deadline. This will allow you to learn so many essential skills, such as how to break down projects into smaller requirements and see how different people approach them.&lt;/p&gt;

&lt;p&gt;Moreover, you will have the opportunity to work alongside experienced professionals who can guide you and answer any questions you may have. Always remember to focus on understanding the problem rather than merely solving it. Take your time to think about the best approach and ask for guidance when you feel stuck.&lt;/p&gt;

&lt;p&gt;In an internship, you don't need to rush to complete tasks as it is not a competition or a race. Instead, take the time to understand the problems thoroughly and think about the best ways to solve them. This will enable you to learn more than you ever imagined and help you develop the confidence needed to excel in your career.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Freelancing
&lt;/h2&gt;

&lt;p&gt;If you don't want to work in a company and have a business idea, freelancing might be a good choice for you. As someone who paid most of their college tuition fees with the money earned from freelancing, I can attest to the fact that it is an excellent way to learn and grow.&lt;/p&gt;

&lt;p&gt;During my time freelancing, I gained a variety of valuable skills, such as understanding people's problems, collecting requirements, creating proposals and bargaining, estimating the time and cost of building projects, balancing my college work and freelancing work, working with people from different industries and specialties, delivering projects, applying feedback, and handling expectations when things take the time or go wrong.&lt;/p&gt;

&lt;p&gt;Freelancing made me a better engineer overall, and I still believe it is one of the best ways to learn and grow. While there are several ways to find freelancing work, I usually worked with people I knew or those referred to me by previous clients. Helping local businesses with their websites and apps can be a great way to get started and feel like you're making a difference in your community.&lt;/p&gt;

&lt;p&gt;However, freelancing also has its challenges. You may only get in small, one-off projects that don't allow you to learn new things or get trapped in a large project that lasts for years. Additionally, freelancing can be a solitary experience since you have to do everything on your own, which can help you develop a broader range of skills, but you may not specialize in a specific area.&lt;/p&gt;

&lt;p&gt;Despite these challenges, I would still recommend trying freelancing to learn and grow as a professional. While there are websites to help you find clients, most of them do not allow you to meet the actual clients, making it difficult to build your network. Nonetheless, a few of my friends have built their businesses out of freelancing, making it a viable career choice for those who want to work for themselves.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Other Activities
&lt;/h2&gt;

&lt;p&gt;In my opinion, participating in college clubs, hackathons, competitions, and conferences can be a great way to enhance your skills and confidence. These activities often involve collaborating with other students and professionals, which can allow you to solve problems together, divide tasks, and learn from each other.&lt;/p&gt;

&lt;p&gt;While these experiences can come with challenges such as different ideas and getting stuck, overcoming them can help you grow and develop valuable skills for handling similar situations in the future.&lt;/p&gt;

&lt;p&gt;Although these activities may not offer a clear sense of goal or monetary reward, they can complement internships and freelancing. Participating in competitions can also provide a benchmark for improvement and offer the opportunity to travel to new places.&lt;/p&gt;

&lt;p&gt;In conclusion, taking part in college clubs, hackathons, competitions, and conferences can be a valuable addition to your skill-building journey.&lt;/p&gt;

&lt;p&gt;There are other options like courses, etc but these are the ones I highly recommend. If you chose one or all of them, don't forget to understand your limits doing too much will in end just exhaust you, which will lead to burnout. This can hold you back and you might lose confidence in yourself.&lt;/p&gt;

</description>
      <category>computerscience</category>
      <category>skills</category>
      <category>ideas</category>
      <category>internships</category>
    </item>
    <item>
      <title>Learn JavaScript and use Typescript</title>
      <dc:creator>Vaibhav Kubre</dc:creator>
      <pubDate>Sun, 03 Jul 2022 00:00:00 +0000</pubDate>
      <link>https://dev.to/kubre/learn-javascript-and-use-typescript-316k</link>
      <guid>https://dev.to/kubre/learn-javascript-and-use-typescript-316k</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F20qee72ee20r3s52e8vh.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F20qee72ee20r3s52e8vh.jpg" alt="Header" width="800" height="234"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Experience
&lt;/h2&gt;

&lt;p&gt;You're comfortable with javascript now. You've finally been able to learn the fancy functional methods. Write out the &lt;code&gt;reduce()&lt;/code&gt; instead of a loop. It runs the same as a loop but makes your code look smarter. But people are shifting to something else now. It's typescript! It's just like JavaScript but better. How? Well, you see, it has a type, “Pun intended.” So you jumped on the hype train and started a typescript project. But it felt off. You're writing code that does the same thing as JavaScript but amounts to far more code. You wonder if it was even worth the trouble. I'm going back to the good old javascript and living in a typeless environment. VS Code no longer provides intelligent suggestions, but it did, and the simpler mistakes you pass around are null and undefined and no longer being caught. But does it have to turn out this way?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;No&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  So, how do I get started with Typescript?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Learn javascript and use typescript&lt;/strong&gt; , Yes the title of this blog post. What does it even mean? Just write JavaScript inside the typescript file.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;That's it!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Let's understand with an example.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;allPosts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Post One&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;category&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;one&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Post Two&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;category&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;two&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;];&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;getPosts&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;category&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;category&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;allPosts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;post&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;post&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;category&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nx"&gt;category&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;allPosts&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;getPosts&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;getPosts&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;one&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I'm using vscode which has a linter built-in. It lets you know the issues with Javascript or TypeScript directly in the editor itself. With the default configuration for typescript (i.e., if you used one from &lt;code&gt;npx tsc --init&lt;/code&gt; will show you an error at the &lt;code&gt;getPosts()&lt;/code&gt; function call with a warning &lt;code&gt;An argument for 'category' was not provided&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;But we know our function does handle cases when the category is not present. But typescript doesn't. By default, it will treat the argument as a required parameter. We can just add &lt;strong&gt;?&lt;/strong&gt; at the end of the category and let the typescript know an undefined state is considered.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;getPosts&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;category&lt;/span&gt;&lt;span class="p"&gt;?)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Linter will also complain about the category being type &lt;strong&gt;any&lt;/strong&gt;. If you don't know it means in simple terms your variable can hold value with any of the types javascript supports. Let's change this behavior. We know that category is a string, so we can explicitly type the argument with a string datatype.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;getPosts&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;category&lt;/span&gt;&lt;span class="p"&gt;?:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Linter is no longer complaining, and we are good. Only those changes? Yes, One of the best tips I've gotten looking at projects built by people who use typescript on daily basis, and even the advanced user just writes javascript and lets the typescript infer if it complains then add the type. This way the learning curve is minimal.&lt;/p&gt;

&lt;p&gt;If you go deep, you will find it interesting to learn but difficult to maintain for day-to-day coding. And that's fine! All those fancy features that Typescript provides are for people who write and maintain packages. That is how we receive the great linting and the sweet IntelliSense. But for people who are building user-facing websites and applications, getting the typescript compiler happy is enough. Once you start using it on every project you will learn new things in typescript but it's a slow and gradual learning curve. You will only learn what you will use in the project.&lt;/p&gt;

&lt;p&gt;I had a hard time starting with typescript at first, but now I've switched over to full-time. by simply only adding in types when typescript complains about it. And every other time, I just let typescript infer the type for me. This is called implicit typing, and it helps a lot to reduce the amount of code that doesn't add any features for the users. This also keeps you from getting strictly locked into the typescript itself. At work, I still have to use JavaScript, and it won't go anywhere soon. Javascript is improving day by day and people will keep using it. Some are moving back to Javascript from Typescript also.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>typescript</category>
      <category>learntypescript</category>
    </item>
  </channel>
</rss>
