<?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: tanishparashar</title>
    <description>The latest articles on DEV Community by tanishparashar (@tanishparashar).</description>
    <link>https://dev.to/tanishparashar</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%2F2036781%2Fd2e50518-f87d-4a33-8e57-b435c07e8946.jpg</url>
      <title>DEV Community: tanishparashar</title>
      <link>https://dev.to/tanishparashar</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tanishparashar"/>
    <language>en</language>
    <item>
      <title>Rate Limiting Microservice in Rust</title>
      <dc:creator>tanishparashar</dc:creator>
      <pubDate>Mon, 12 May 2025 00:44:35 +0000</pubDate>
      <link>https://dev.to/tanishparashar/rate-limiting-microservice-in-rust-5pi</link>
      <guid>https://dev.to/tanishparashar/rate-limiting-microservice-in-rust-5pi</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a submission for the &lt;a href="https://dev.to/challenges/aws-amazon-q-v2025-04-30"&gt;Amazon Q Developer "Quack The Code" Challenge&lt;/a&gt;: Exploring the Possibilities&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Built
&lt;/h2&gt;

&lt;p&gt;I recently embarked on an ambitious project to build a high-performance, multi-tenant rate limiting service in Rust. Despite being a Rust novice (I'm still learning the language!), I managed to create a sophisticated microservice that serves as a critical entry point for modern distributed architectures.&lt;/p&gt;

&lt;h3&gt;
  
  
  Rate Limiter v2: A Comprehensive Solution
&lt;/h3&gt;

&lt;p&gt;My rate limiter service isn't just a simple API throttler—it's a full-featured system designed for production environments with the following capabilities:&lt;/p&gt;

&lt;h4&gt;
  
  
  Multi-Tenant Architecture
&lt;/h4&gt;

&lt;p&gt;The service supports multiple tenants with complete isolation between them. In this context, tenants represent different applications, services, or customers that need rate limiting capabilities. Each tenant can have:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Their own API key for authentication&lt;/li&gt;
&lt;li&gt;Custom rate limiting rules and quotas&lt;/li&gt;
&lt;li&gt;Different service tiers (free, standard, premium, enterprise)&lt;/li&gt;
&lt;li&gt;Isolated usage tracking and metrics&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Multiple Rate Limiting Algorithms
&lt;/h4&gt;

&lt;p&gt;I implemented four different rate limiting algorithms to suit various use cases:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Token Bucket&lt;/strong&gt;: Provides smooth rate limiting with burst capability&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Leaky Bucket&lt;/strong&gt;: Ensures constant outflow rate limiting&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fixed Window&lt;/strong&gt;: Offers simple time-window based limiting&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Sliding Window&lt;/strong&gt;: Delivers more accurate time-window limiting with less boundary issues&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Comprehensive Observability
&lt;/h4&gt;

&lt;p&gt;Monitoring and debugging are critical for production services, so I integrated:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;OpenTelemetry tracing&lt;/strong&gt;: For distributed request tracing across services&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Prometheus metrics&lt;/strong&gt;: For collecting and exposing performance metrics&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Grafana dashboards&lt;/strong&gt;: For visualizing metrics with pre-configured dashboards&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Jaeger UI&lt;/strong&gt;: For exploring and analyzing traces&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Resilient Storage Options
&lt;/h4&gt;

&lt;p&gt;The service supports multiple storage backends:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In-memory storage for high performance&lt;/li&gt;
&lt;li&gt;Redis for distributed deployments&lt;/li&gt;
&lt;li&gt;Hybrid storage with Redis + memory fallback for resilience&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  API Documentation and Testing
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Swagger/OpenAPI&lt;/strong&gt;: For interactive API documentation&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Load testing scripts&lt;/strong&gt;: To validate performance under various conditions&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Containerization
&lt;/h4&gt;

&lt;p&gt;The entire solution is containerized with Docker and Docker Compose, making it easy to deploy and scale.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Amazon Q Developer Experience
&lt;/h3&gt;

&lt;p&gt;What makes this project truly remarkable is how I built it. Despite my limited Rust knowledge, I was able to develop this complex system with the help of Amazon Q Developer. The experience was transformative—it felt like I was managing Amazon Q while it handled 90% of the coding work.&lt;/p&gt;

&lt;p&gt;We followed an iterative development process where Amazon Q:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Helped plan out the project iterations&lt;/li&gt;
&lt;li&gt;Generated the core code structure&lt;/li&gt;
&lt;li&gt;Implemented complex algorithms and patterns&lt;/li&gt;
&lt;li&gt;Assisted with integrating various technologies&lt;/li&gt;
&lt;li&gt;Provided debugging support when issues arose&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;It was genuinely shocking to experience firsthand the reality of AI-assisted development, where I could focus on architecture decisions and requirements while the AI handled the implementation details. This is the future—developers managing AI agents that generate most of the code, dramatically accelerating development cycles.&lt;/p&gt;

&lt;p&gt;For my next iteration, I'm planning to implement gRPC for internal service communication instead of HTTP, which should further improve performance. I'm incredibly excited about continuing this project and exploring more ways to leverage Amazon Q in my development workflow.&lt;/p&gt;

&lt;h2&gt;
  
  
  Demo
&lt;/h2&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%2Fkwwpleu57lo67r2ty10i.png" 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%2Fkwwpleu57lo67r2ty10i.png" alt="Jaeger Dashboard" width="800" height="441"&gt;&lt;/a&gt;&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%2Fmqphjrg92sgulesephou.png" 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%2Fmqphjrg92sgulesephou.png" alt="Prometheus Targets" width="800" height="441"&gt;&lt;/a&gt;&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%2Fw8uztyy00pm162x91ea8.png" 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%2Fw8uztyy00pm162x91ea8.png" alt="Graphana Dashboard" width="800" height="441"&gt;&lt;/a&gt;&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%2Fht6yi88mo8t6kdl6mjdd.png" 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%2Fht6yi88mo8t6kdl6mjdd.png" alt="Graphana Dashboards with some metrics" width="800" height="441"&gt;&lt;/a&gt;&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%2Fsfvnup35v3f6i0fgsros.png" 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%2Fsfvnup35v3f6i0fgsros.png" alt="Swagger Doc" width="800" height="441"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Code Repository
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/tanishparashar/rate-limiter-final" rel="noopener noreferrer"&gt;https://github.com/tanishparashar/rate-limiter-final&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How I Used Amazon Q Developer
&lt;/h2&gt;

&lt;p&gt;Throughout the development of my Rate Limiter v2 service, Amazon Q Developer became my virtual coding partner—a software developer who worked alongside me, executing commands, writing &lt;br&gt;
code, and debugging issues. This collaboration transformed my development workflow in ways I hadn't anticipated.&lt;/p&gt;

&lt;h3&gt;
  
  
  An Iterative Development Approach
&lt;/h3&gt;

&lt;p&gt;My journey with Amazon Q began when I decided to take an iterative approach to building the rate limiter. I simply prompted, "This is iteration 1, code for me," and Amazon Q responded by &lt;br&gt;
generating the initial codebase. This moment marked the beginning of a new development paradigm for me—one where I could focus on the big picture while Amazon Q handled the implementation &lt;br&gt;
details.&lt;/p&gt;

&lt;p&gt;For each iteration, I followed a process that looked something like this:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Planning: I'd describe the features and components needed for the current iteration&lt;/li&gt;
&lt;li&gt;Code Generation: Amazon Q would generate the necessary Rust code&lt;/li&gt;
&lt;li&gt;Review &amp;amp; Refinement: I'd review the code, ask questions, and request modifications&lt;/li&gt;
&lt;li&gt;Integration: We'd integrate the new code with existing components&lt;/li&gt;
&lt;li&gt;Testing &amp;amp; Debugging: Amazon Q would help identify and fix issues&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Overcoming Challenges
&lt;/h3&gt;

&lt;p&gt;The journey wasn't without its challenges. There was a particularly difficult moment when I faced over 100 compilation errors in my Rust code. I felt overwhelmed and considered abandoning &lt;br&gt;
the project—it seemed impossible to fix so many issues, especially with my limited Rust knowledge.&lt;/p&gt;

&lt;p&gt;After taking a break to clear my head, I returned to the project and decided to tackle the errors one by one with Amazon Q's help. I shared the error messages, and Amazon Q:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Explained what each error meant in plain language&lt;/li&gt;
&lt;li&gt;Identified patterns among the errors&lt;/li&gt;
&lt;li&gt;Suggested systematic fixes for groups of related issues&lt;/li&gt;
&lt;li&gt;Provided corrected code snippets&lt;/li&gt;
&lt;li&gt;Explained the underlying Rust concepts so I could learn from the experience&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This debugging marathon not only saved my project but also significantly improved my understanding of Rust's ownership model, lifetimes, and type system.&lt;/p&gt;

&lt;h3&gt;
  
  
  Tips for Effective Collaboration with Amazon Q
&lt;/h3&gt;

&lt;p&gt;Based on my experience, here are some insights for working effectively with Amazon Q Developer:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Provide Clear Context: The more context you provide about your project, the better Amazon Q can assist you. Include information about your project structure, dependencies, and goals.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Iterate Incrementally: Break your development into small, manageable iterations rather than trying to build everything at once.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Ask Specific Questions: When you encounter issues, be specific about what you're trying to achieve and what's not working.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Learn from the Code: Don't just copy-paste the generated code. Take time to understand it, which will improve your skills and help you make better requests in the future.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Verify and Test: Always review and test the generated code. Amazon Q is powerful but not infallible.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use Natural Language: Explain your requirements in plain language, as if you were talking to a human developer.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  The Transformation
&lt;/h3&gt;

&lt;p&gt;Amazon Q has helped me become a better and more productive developer. It's not just about writing code faster—it's about having a knowledgeable companion throughout the development process&lt;br&gt;
who can explain complex concepts, suggest best practices, and help troubleshoot issues.&lt;/p&gt;

&lt;p&gt;The experience has changed my perspective on AI-assisted development. Rather than replacing developers, tools like Amazon Q amplify our capabilities, allowing us to tackle more complex &lt;br&gt;
projects and focus on the creative aspects of software development.&lt;/p&gt;

&lt;p&gt;I'm incredibly grateful for this challenge and the opportunity to work with Amazon Q. It's opened new possibilities for what I can build, even with technologies I'm still learning.&lt;/p&gt;

</description>
      <category>devchallenge</category>
      <category>awschallenge</category>
      <category>ai</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Why i dropped Golang and started rust.</title>
      <dc:creator>tanishparashar</dc:creator>
      <pubDate>Sun, 16 Mar 2025 18:20:06 +0000</pubDate>
      <link>https://dev.to/tanishparashar/why-i-dropped-golang-and-started-rust-1al3</link>
      <guid>https://dev.to/tanishparashar/why-i-dropped-golang-and-started-rust-1al3</guid>
      <description>&lt;p&gt;&lt;strong&gt;Why I dropped Golang and started Rust.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;So, I was learning Golang and then became obsessed with the raw performance of a language. That's when I discovered Rust. Everyone was saying Rust is the GOAT, as fast as C, can build anything, and has various attractive features like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Async&lt;/li&gt;
&lt;li&gt;Strict types&lt;/li&gt;
&lt;li&gt;Memory safety&lt;/li&gt;
&lt;li&gt;Fast performance&lt;/li&gt;
&lt;li&gt;Concurrency features&lt;/li&gt;
&lt;li&gt;Hard to reverse engineer (Beware, if I ever attack you, you won't know)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So here I am, dropped Golang and now struggling with Rust, haha. Let's see what happens on this journey.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>rust</category>
      <category>go</category>
      <category>programming</category>
    </item>
    <item>
      <title>Post2: Golang Print Functions</title>
      <dc:creator>tanishparashar</dc:creator>
      <pubDate>Wed, 11 Dec 2024 11:34:06 +0000</pubDate>
      <link>https://dev.to/tanishparashar/post2-golang-print-functions-2lki</link>
      <guid>https://dev.to/tanishparashar/post2-golang-print-functions-2lki</guid>
      <description>&lt;h2&gt;
  
  
  series: Golang
&lt;/h2&gt;

&lt;h2&gt;
  
  
  Printing Functions in Golang
&lt;/h2&gt;

&lt;p&gt;In Golang, several functions are available for printing text, and each serves specific use cases. Here's an explanation of the most commonly used printing functions:&lt;/p&gt;

&lt;h2&gt;
  
  
  1. &lt;code&gt;fmt.Print&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Description:&lt;/strong&gt;&lt;br&gt;
Prints the provided arguments as plain text without adding a newline. It does not format the output.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Use Case:&lt;/strong&gt;&lt;br&gt;
For simple concatenated text or values where no specific formatting is required.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Hello"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;          &lt;span class="c"&gt;// Output: Hello&lt;/span&gt;
&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"World"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;          &lt;span class="c"&gt;// Output: HelloWorld&lt;/span&gt;
&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;123&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;" GoLang"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;   &lt;span class="c"&gt;// Output: HelloWorld123 GoLang&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  2. &lt;code&gt;fmt.Println&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Description:&lt;/strong&gt;&lt;br&gt;
Prints the provided arguments as plain text and appends a newline at the end.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Use Case:&lt;/strong&gt;&lt;br&gt;
For simple outputs where you want automatic line breaks after printing.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Hello"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;         &lt;span class="c"&gt;// Output: Hello (with newline)&lt;/span&gt;
&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"World"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;         &lt;span class="c"&gt;// Output: World (on a new line)&lt;/span&gt;
&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;123&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"GoLang"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;   &lt;span class="c"&gt;// Output: 123 GoLang (on a new line)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  3. &lt;code&gt;fmt.Printf&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Description:&lt;/strong&gt;&lt;br&gt;
Formats and prints text according to a specified format string. Does not add a newline unless explicitly included in the format string.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Use Case:&lt;/strong&gt;&lt;br&gt;
For dynamic or formatted outputs (e.g., integers, floats, strings, etc.).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="s"&gt;"Alice"&lt;/span&gt;
&lt;span class="n"&gt;age&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="m"&gt;25&lt;/span&gt;
&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"My name is %s and I am %d years old."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;age&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c"&gt;// Output: My name is Alice and I am 25 years old.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Common Formatting Verbs:
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Verb&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;th&gt;Example&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;%s&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;String&lt;/td&gt;
&lt;td&gt;&lt;code&gt;fmt.Printf("%s", "Go")&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;%d&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Integer (base 10)&lt;/td&gt;
&lt;td&gt;&lt;code&gt;fmt.Printf("%d", 123)&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;%f&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Floating-point&lt;/td&gt;
&lt;td&gt;&lt;code&gt;fmt.Printf("%.2f", 3.14)&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;%v&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Default format for any value&lt;/td&gt;
&lt;td&gt;&lt;code&gt;fmt.Printf("%v", true)&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;%T&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Type of the variable&lt;/td&gt;
&lt;td&gt;&lt;code&gt;fmt.Printf("%T", name)&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;%+v&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Struct with field names&lt;/td&gt;
&lt;td&gt;&lt;code&gt;fmt.Printf("%+v", obj)&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  4. &lt;code&gt;fmt.Sprintf&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Description:&lt;/strong&gt;&lt;br&gt;
Formats text like &lt;code&gt;fmt.Printf&lt;/code&gt;, but instead of printing to the console, it returns the formatted string.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Use Case:&lt;/strong&gt;&lt;br&gt;
For preparing strings for later use (e.g., logging, building responses).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;formatted&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Sprintf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Hello, %s!"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Alice"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;formatted&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c"&gt;// Output: Hello, Alice!&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>webdev</category>
      <category>go</category>
      <category>programming</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Why learn Golang?</title>
      <dc:creator>tanishparashar</dc:creator>
      <pubDate>Sun, 24 Nov 2024 21:17:38 +0000</pubDate>
      <link>https://dev.to/tanishparashar/why-learn-golang-95d</link>
      <guid>https://dev.to/tanishparashar/why-learn-golang-95d</guid>
      <description>&lt;p&gt;I was diving deep into JavaScript for a while, but eventually, I hit that “meh” phase. You know the one where you’re itching for something fresh? That’s when I thought, why not try Golang? So, here I am, learning this new language, and I’m excited to share the journey with you! 🚀&lt;/p&gt;

&lt;p&gt;Let’s start with the basics: &lt;strong&gt;Why should you even care about Go?&lt;/strong&gt; Why did the creators feel the need for another programming language? And what’s the buzz around its scope? Let’s unpack all that.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why was Go designed?
&lt;/h2&gt;

&lt;p&gt;Go (or Golang, if you’re feeling fancy) was cooked up by Robert Griesemer, Rob Pike, and Ken Thompson at Google back in 2007. So, what made Google say, “Yeah, we need a whole new language”?&lt;/p&gt;

&lt;p&gt;Well, at the time, Google’s developers were grappling with some pretty frustrating challenges while building big, scalable systems.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Here’s what was bugging them:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Complexity: C++ and Java were powerhouses but had become way too complex. Writing clean, efficient, and scalable code felt like wrestling an octopus.&lt;/li&gt;
&lt;li&gt;Concurrency: With CPUs adding more cores, writing concurrent programs that could actually use those cores efficiently was a nightmare in most existing languages.&lt;/li&gt;
&lt;li&gt;Compilation Speed: Developers were twiddling their thumbs waiting for C++ code to compile. Ain’t nobody got time for that!&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;To address these challenges, the creators of Go aimed to design a language that was:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Their vision? Create a language that’s:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Simple: Clean and minimalistic, so it’s easy to learn and use without a 500-page manual.&lt;/li&gt;
&lt;li&gt;Concurrent: Built-in tools to handle concurrency like a pro, making it faster and safer to write multi-core programs.&lt;/li&gt;
&lt;li&gt;Fast: Quick compilation because waiting for your code to build shouldn’t feel like eternity.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  What Does Golang Have to Offer?
&lt;/h2&gt;

&lt;p&gt;Golang (or Go, for short) comes packed with features that make it a superstar for building scalable, concurrent, and efficient systems. Let’s take a quick tour of what makes Go so awesome:  &lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Language Features&lt;/strong&gt;
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Simplicity&lt;/strong&gt;: Go’s clean and minimalistic syntax is like a breath of fresh air. It’s super easy to pick up, even if you’re new to programming.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Statically Typed&lt;/strong&gt;: No nasty surprises at runtime! Go catches errors during compile time, so your code behaves as expected.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Compiled Language&lt;/strong&gt;: Go compiles to machine code, which means it runs fast—like &lt;em&gt;really fast&lt;/em&gt;.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Garbage Collection&lt;/strong&gt;: Say goodbye to manual memory management. Go’s built-in garbage collector handles it for you.
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Concurrency Features&lt;/strong&gt;
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Goroutines&lt;/strong&gt;: Think of goroutines as lightweight threads but with way less overhead. They make writing concurrent programs a breeze.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Channels&lt;/strong&gt;: Need goroutines to talk to each other? Channels are here to help, making communication between them efficient and safe.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mutexes and Locks&lt;/strong&gt;: When you need to control access to shared resources, Go’s mutexes and locks have your back.
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We’ll dive deeper into these features soon because, honestly, I’m amazed at how tempting they are! Stay tuned. 🚀  &lt;/p&gt;

&lt;h2&gt;
  
  
  In What Technologies Is Golang Being Used?
&lt;/h2&gt;

&lt;p&gt;Ever wondered where Golang shines? Spoiler alert: it’s everywhere! From cloud computing to web development, Go has carved a niche in some of the most exciting areas of tech. Let’s check out where it’s making waves:  &lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Cloud and Infrastructure&lt;/strong&gt;
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Google Cloud&lt;/strong&gt;: Go is all over Google Cloud, powering tools like Google Cloud Storage, Google Cloud Datastore, and Google Cloud Pub/Sub.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Amazon Web Services (AWS)&lt;/strong&gt;: Even AWS is on the Go bandwagon! Services like Amazon S3, DynamoDB, and Lambda have Go under the hood.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Microsoft Azure&lt;/strong&gt;: Azure’s got love for Go too, using it in Azure Storage, Cosmos DB, and Functions.
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Networking and Distributed Systems&lt;/strong&gt;
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Kubernetes&lt;/strong&gt;: Yep, the legendary container orchestration tool is written in Go.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Docker&lt;/strong&gt;: The backbone of containerization? Go plays a huge role in its core components.
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Web Development&lt;/strong&gt;
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Netflix&lt;/strong&gt;: Go powers parts of Netflix’s web services, including its API gateway and load balancer.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Dropbox&lt;/strong&gt;: From file uploads to downloads, Go helps keep Dropbox fast and efficient.
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;DevOps and Automation&lt;/strong&gt;
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Terraform&lt;/strong&gt;: This popular infrastructure-as-code tool is a Go creation.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ansible&lt;/strong&gt;: While mostly Python, Ansible taps into Go for some of its components.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Prometheus&lt;/strong&gt;: The monitoring tool you probably love? It’s written in Go.
&lt;/li&gt;
&lt;/ol&gt;




&lt;p&gt;As you can see, Go’s versatility makes it a powerhouse in tech. It’s exciting to see how much ground it’s covered—and it’s just getting started!  &lt;/p&gt;

</description>
      <category>webdev</category>
      <category>go</category>
      <category>api</category>
      <category>cloud</category>
    </item>
    <item>
      <title>JavaScript's Secret Sauce: How Single-Threaded Becomes Asynchronous</title>
      <dc:creator>tanishparashar</dc:creator>
      <pubDate>Sun, 22 Sep 2024 15:48:44 +0000</pubDate>
      <link>https://dev.to/tanishparashar/javascript-asynchronous-behavior-what-makes-it-possible--30kf</link>
      <guid>https://dev.to/tanishparashar/javascript-asynchronous-behavior-what-makes-it-possible--30kf</guid>
      <description>&lt;p&gt;&lt;strong&gt;JavaScript is single-threaded&lt;/strong&gt;, so how does it manage asynchronous operations? The answer is simple: it doesn't—at least not directly.&lt;/p&gt;

&lt;p&gt;JavaScript delegates these tasks to the browser or Node.js runtime, which is more than just the V8 engine executing JavaScript code.&lt;/p&gt;

&lt;p&gt;Here's what really happens behind the scenes:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Web APIs&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;These are provided by the browser (or Node environment) to handle asynchronous tasks. Examples include setTimeout, XMLHttpRequest, and DOM events.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Callback Queue&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Once an asynchronous operation (like a timeout or an AJAX request) is completed, its associated callback is placed into a callback queue.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Event Loop&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The event loop is constantly checking the call stack (where JavaScript code executes). If the stack is empty, the event loop picks the next callback from the callback queue and pushes it onto the stack for execution. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let’s look at a piece of code that demonstrates how the event loop manages asynchronous operations:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$.on('button', 'click', function onClick() {
    setTimeout(function timer() {
        console.log('You clicked the button!');    
    }, 2000);
});

console.log("Hi!");

setTimeout(function timeout() {
    console.log("Click the button!");
}, 5000);

console.log("Welcome to loupe.");

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

&lt;/div&gt;



&lt;p&gt;Remember, JavaScript doesn't wait for &lt;code&gt;setTimeout&lt;/code&gt; or other async functions to finish before moving on. It delegates those tasks, and once they're done, the callback is added to the queue.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Hi!
Welcome to loupe.
Click the button!
You clicked the button!

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;strong&gt;What Happens Here?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Synchronous Tasks:&lt;/strong&gt; When JavaScript runs, the call stack executes the tasks in order. First, it logs &lt;code&gt;"Hi!"&lt;/code&gt;, then &lt;code&gt;"Welcome to loupe."&lt;/code&gt; because these are synchronous operations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Asynchronous Tasks:&lt;/strong&gt; The setTimeout function creates timers. But instead of blocking execution, these tasks are handed off to the browser’s Web APIs to wait for 2000ms and 5000ms, respectively.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Callback Execution:&lt;/strong&gt; Once the specified time elapses, the callbacks (console.log("You clicked the button!") and console.log("Click the button!")) are moved into the callback queue. The event loop checks if the call stack is empty and then pushes these callbacks back onto the stack to be executed.&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%2Fyw9l13fxmpgjtljnkh6d.png" 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%2Fyw9l13fxmpgjtljnkh6d.png" alt="Image description" width="800" height="499"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Visualizing the Call Stack&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;JavaScript’s call stack is LIFO (Last In, First Out). Only one task is processed at a time. If there's a long-running task (like a loop), it blocks the stack, which is why asynchronous callbacks like &lt;code&gt;setTimeout&lt;/code&gt; help avoid blocking, allowing smoother execution.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;The Importance of Asynchronous Callbacks&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Understanding JavaScript’s event loop, call stack, and Web APIs is crucial because it gives insight into how asynchronous operations are handled, enhancing the efficiency and responsiveness of web applications.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In JavaScript, asynchronous callbacks are not optional. They're necessary to avoid blocking the main thread, especially for tasks like AJAX requests or &lt;code&gt;setTimeout&lt;/code&gt;. This ensures your app runs smoothly, with no interruptions to the user experience.&lt;/p&gt;

&lt;p&gt;To truly master JavaScript's asynchronous behavior, understanding the event loop is key. Be sure to check out this &lt;a href="https://www.youtube.com/watch?v=8aGhZQkoFbQ" rel="noopener noreferrer"&gt;video&lt;/a&gt; and visualize the process with &lt;a href="http://latentflip.com/loupe/" rel="noopener noreferrer"&gt;Loupe&lt;/a&gt;. &lt;/p&gt;

</description>
    </item>
    <item>
      <title>How JS works behind the scenes?</title>
      <dc:creator>tanishparashar</dc:creator>
      <pubDate>Wed, 18 Sep 2024 05:04:52 +0000</pubDate>
      <link>https://dev.to/tanishparashar/how-js-works-behind-the-scenes-1knn</link>
      <guid>https://dev.to/tanishparashar/how-js-works-behind-the-scenes-1knn</guid>
      <description>&lt;h2&gt;
  
  
  How JavaScript Works
&lt;/h2&gt;

&lt;p&gt;JavaScript operates in a single-threaded environment, meaning it executes one task at a time. It handles the execution of code in Execution Contexts (EC), which can be either Global or Functional.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Global Execution Context (GEC)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Created when the code file is loaded.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The GEC is responsible for setting up the global object (in browsers, it's window) and the (&lt;code&gt;this&lt;/code&gt;) keyword.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;All variables and functions declared in the global scope are stored in the Global EC.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Execution Context Phases&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Memory Creation Phase:&lt;br&gt;
During the memory phase, JavaScript allocates memory for variables and functions.&lt;br&gt;
Variables are assigned the value undefined initially, while functions are stored in memory with their full definition.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Execution Phase:&lt;br&gt;
After the memory allocation phase, JavaScript starts executing the code line by line.&lt;br&gt;
Variables are assigned actual values and functions are executed.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Functional Execution Context (FEC)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Whenever a function is invoked, JavaScript creates a new Execution Context specifically for that function.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Execution context for each function has two phases:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Memory Phase: Memory is allocated to the local variables, and functions inside the function.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Execution Phase: The function body is executed, and variables get their actual values.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;After execution, the function's execution context is destroyed, freeing up memory.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Return Statements&lt;/strong&gt;&lt;br&gt;
Once a function reaches a return statement, the function immediately exits, and its execution context is removed from the Call Stack. Any code written after a return statement won't execute.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Call Stack&lt;/strong&gt;&lt;br&gt;
JavaScript uses the Call Stack to manage execution contexts.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;LIFO (Last In, First Out) concept is used:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;When a function is called, its execution context is placed on top of the stack.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Once the function completes (or reaches return), its execution context is popped off the stack.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;JavaScript is Single-Threaded&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Single-threaded means JavaScript can only perform one operation at a time but still it can perform asynchronous operations isn't that interesting in my next post we will discuss about this amazing functionality of JavaScript.  &lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
