<?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>Forem: Ali Ahsan</title>
    <description>The latest articles on Forem by Ali Ahsan (@aliahsan0).</description>
    <link>https://forem.com/aliahsan0</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%2F1098373%2F0f5900e3-6e2b-4453-88c1-99272f93a659.jpeg</url>
      <title>Forem: Ali Ahsan</title>
      <link>https://forem.com/aliahsan0</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/aliahsan0"/>
    <language>en</language>
    <item>
      <title>Angular vs. React vs. Vue: Which is the Best Framework in 2024?</title>
      <dc:creator>Ali Ahsan</dc:creator>
      <pubDate>Tue, 01 Oct 2024 10:17:21 +0000</pubDate>
      <link>https://forem.com/aliahsan0/angular-vs-react-vs-vue-which-is-the-best-framework-in-2024-i1d</link>
      <guid>https://forem.com/aliahsan0/angular-vs-react-vs-vue-which-is-the-best-framework-in-2024-i1d</guid>
      <description>&lt;p&gt;When deciding which frontend framework to use, developers are often faced with a choice between Angular, React, and Vue. Each of these frameworks has its own strengths, target audience, and use cases. Here's a breakdown of their key features to help you choose the best one for your next project.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Angular: A Complete Framework&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;What it is: Angular is a full-fledged frontend framework developed and maintained by Google. It's often considered a complete solution as it includes built-in features like routing, state management, forms, HTTP client, and more.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Key Features:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Two-way data binding:&lt;/strong&gt; Angular's two-way data binding simplifies synchronization between the model and the view.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;TypeScript-first:&lt;/strong&gt; It’s built with TypeScript, which adds static typing and modern JavaScript features, leading to more robust applications.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Opinionated structure:&lt;/strong&gt; Angular provides a standardized structure, which makes it ideal for large-scale applications.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When to use:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Enterprise-level apps&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Complex, large applications with many developers&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Applications requiring long-term maintainability and scalability&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Learning Curve:&lt;/strong&gt; Steeper compared to React and Vue due to its extensive ecosystem and TypeScript.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;React: The Flexible Library&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;What it is:&lt;/strong&gt; React, developed by Facebook (now Meta), is a library focused solely on the UI layer. Its flexibility allows developers to use it alongside other libraries or frameworks to meet their needs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Key Features:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Component-based architecture:&lt;/strong&gt; React’s component-driven approach makes it easy to build reusable and testable UI components.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Virtual DOM:&lt;/strong&gt; Efficiently updates and renders only the components that have changed, leading to better performance.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Ecosystem freedom:&lt;/strong&gt; You can choose your tools for state management (like Redux or Context), routing (React Router), and more.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Wide adoption:&lt;/strong&gt; With a large developer community, you’ll find a ton of resources, third-party libraries, and job opportunities.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;When to use:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Applications requiring flexibility&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Building dynamic, interactive UIs&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Startups and rapid prototyping&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Learning Curve:&lt;/strong&gt; Moderate. While the basics are easy to pick up, mastering state management and complex setups can take time.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Vue: The Progressive Framework&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;What it is:&lt;/strong&gt; Vue is a progressive framework that combines the best features of Angular and React, offering flexibility and simplicity. It’s known for being easy to integrate into projects and for having an approachable learning curve.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Key Features:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Two-way data binding:&lt;/strong&gt; Similar to Angular, but simpler and more intuitive for smaller projects.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Component-based:&lt;/strong&gt; Like React, Vue uses components but with a simpler syntax, making it accessible to developers of all levels.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reactivity system:&lt;/strong&gt; Vue's reactivity system provides a seamless way to handle state changes without complex state management libraries.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Lightweight:&lt;/strong&gt; Vue is lightweight, making it an excellent choice for smaller applications that still need robust functionality.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;When to use:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Smaller to medium-sized applications&lt;/li&gt;
&lt;li&gt;Teams looking for a flexible but structured framework&lt;/li&gt;
&lt;li&gt;Projects that may start small but need to scale over time&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Learning Curve:&lt;/strong&gt; Easiest of the three, with a focus on getting up and running quickly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Comparison Table
&lt;/h2&gt;

&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%2F8k2kgult2e7v57h05be2.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%2F8k2kgult2e7v57h05be2.PNG" alt="Image description" width="785" height="524"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion:&lt;/strong&gt; Which Should You Choose?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Angular:&lt;/strong&gt; Best for large enterprise-level applications that need a robust structure and long-term scalability.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;React:&lt;/strong&gt; Ideal if you need flexibility and are working on dynamic, complex UIs or plan to integrate with various third-party libraries.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Vue:&lt;/strong&gt; Perfect for smaller projects or teams that want a straightforward, progressive framework that can scale as needed.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each framework has its place in the development ecosystem, and the best choice ultimately depends on the project's requirements, the team's expertise, and the future scalability needs.&lt;/p&gt;

</description>
      <category>angular</category>
      <category>react</category>
      <category>vue</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Adding Speech Recognition with Grammar Support to Your Angular Application</title>
      <dc:creator>Ali Ahsan</dc:creator>
      <pubDate>Thu, 01 Aug 2024 11:51:48 +0000</pubDate>
      <link>https://forem.com/aliahsan0/adding-speech-recognition-with-grammar-support-to-your-angular-application-3m35</link>
      <guid>https://forem.com/aliahsan0/adding-speech-recognition-with-grammar-support-to-your-angular-application-3m35</guid>
      <description>&lt;p&gt;Speech recognition can greatly enhance user interactions in web applications by allowing users to input text or commands using their voice. In this tutorial, I'll show you how to integrate speech recognition into an Angular application and enhance it with grammar support.&lt;br&gt;
(only chrome supported)&lt;br&gt;
&lt;strong&gt;Prerequisites&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Basic knowledge of Angular.&lt;/li&gt;
&lt;li&gt;Angular CLI installed.&lt;/li&gt;
&lt;li&gt;An existing Angular project or create a new one using ng new speech-recognition-app.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Step 1: Set Up the Speech Recognition Service
&lt;/h3&gt;

&lt;p&gt;First, we need to create a service to handle speech recognition. This service will use the Web Speech API's webkitSpeechRecognition and SpeechGrammarList.&lt;/p&gt;

&lt;p&gt;Create a new service:&lt;br&gt;
&lt;code&gt;ng generate service speech-recognition&lt;/code&gt;&lt;br&gt;
Now, update the generated speech-recognition.service.ts:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { Injectable, NgZone } from '@angular/core';
@Injectable({
  providedIn: 'root',
})
export class SpeechRecognitionService {
  recognition: any;
  isListening: boolean = false;

  constructor(private zone: NgZone) {
    const { webkitSpeechRecognition, webkitSpeechGrammarList }: IWindow = window as any;
    this.recognition = new webkitSpeechRecognition();
    this.recognition.continuous = false;
    this.recognition.interimResults = false;
    this.recognition.lang = 'en-US';

    const grammar = '#JSGF V1.0; grammar colors; public &amp;lt;color&amp;gt; = red | green | blue | yellow ;';
    const speechRecognitionList = new webkitSpeechGrammarList();
    speechRecognitionList.addFromString(grammar, 1);
    this.recognition.grammars = speechRecognitionList;
  }

  startListening(): Promise&amp;lt;string&amp;gt; {
    return new Promise((resolve, reject) =&amp;gt; {
      if (this.isListening) {
        reject('Already listening');
      }

      this.isListening = true;

      this.recognition.onresult = (event: any) =&amp;gt; {
        this.zone.run(() =&amp;gt; {
          const result = event.results[0][0].transcript;
          this.stopListening();
          resolve(result);
        });
      };

      this.recognition.onerror = (event: any) =&amp;gt; {
        this.zone.run(() =&amp;gt; {
          this.isListening = false;
          reject(event.error);
        });
      };

      this.recognition.onend = () =&amp;gt; {
        this.zone.run(() =&amp;gt; {
          this.isListening = false;
        });
      };

      this.recognition.start();
    });
  }

  stopListening(): void {
    if (this.isListening) {
      this.recognition.stop();
      this.isListening = false;
    }
  }
}

interface IWindow extends Window {
  webkitSpeechRecognition: any;
  webkitSpeechGrammarList: any;
}

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

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 2: Create the Component
&lt;/h3&gt;

&lt;p&gt;Next, we'll create a component to utilize our speech recognition service. This component will have a textarea and a microphone icon. When the user clicks the icon, speech recognition will start, and the recognized text will be added to the textarea.&lt;br&gt;
Update app.component.ts:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { Component } from '@angular/core';
import { SpeechRecognitionService } from './speech-recognition.service';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css'],
})
export class AppComponent {
  note: string = '';
  isListening: boolean = false;

  constructor(private speechRecognitionService: SpeechRecognitionService) {}

  toggleListening() {
    if (this.isListening) {
      this.speechRecognitionService.stopListening();
      this.isListening = false;
    } else {
      this.isListening = true;
      this.speechRecognitionService.startListening().then(
        (result: string) =&amp;gt; {
          this.note = result;
          this.isListening = false;
        },
        (error: any) =&amp;gt; {
          console.error('Speech recognition error', error);
          this.isListening = false;
        }
      );
    }
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 3: Update the Template
&lt;/h3&gt;

&lt;p&gt;In the template, we'll bind the click event to our toggle method and use Angular's ngClass directive to add a glow effect when the microphone is listening.&lt;/p&gt;

&lt;p&gt;Update app.component.html:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div class="textarea-container"&amp;gt;
  &amp;lt;textarea
    maxlength="150"
    class="form-control"
    id="message-text"
    rows="3"
    [(ngModel)]="note"
  &amp;gt;&amp;lt;/textarea&amp;gt;
  &amp;lt;i
    (click)="toggleListening()"
    class="mdi mdi-microphone mic-icon"
    [ngClass]="{ 'glow': isListening }"
  &amp;gt;&amp;lt;/i&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Step 4: Add Styling
&lt;/h4&gt;

&lt;p&gt;Add some styles to position the microphone icon and add a glow effect when it is listening.&lt;/p&gt;

&lt;p&gt;Update app.component.css:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.textarea-container {
  position: relative;
  display: inline-block;
}

.textarea-container textarea {
  width: 100%;
  box-sizing: border-box;
}

.mic-icon {
  position: absolute;
  top: 10px;
  right: 10px;
  cursor: pointer;
  font-size: 24px;
  color: #333;
  transition: box-shadow 0.3s ease;
}

.mic-icon.glow {
  box-shadow: 0 0 10px 2px rgba(255, 0, 0, 0.8);
}

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

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 5: Test Your Application
&lt;/h3&gt;

&lt;p&gt;Run your Angular application using:&lt;br&gt;
&lt;code&gt;ng serve&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Navigate to &lt;a href="http://localhost:4200/" rel="noopener noreferrer"&gt;http://localhost:4200/&lt;/a&gt; in your browser. You should see the textarea with a microphone icon. When you click the icon, it will start listening, and the icon will glow. Speak a color from the grammar list (red, green, blue, yellow), and the recognized color will be added to the textarea.&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;You've successfully added speech recognition with grammar support to your Angular application. This feature can be expanded to recognize more complex commands and integrate seamlessly with various functionalities in your application. Experiment with different grammars and speech recognition settings to see what works best for your use case.&lt;br&gt;
&lt;a href="https://www.linkedin.com/in/ali-ahsan-cust/" rel="noopener noreferrer"&gt;Follow me on linkedin&lt;/a&gt;&lt;br&gt;
Happy coding!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>tutorial</category>
      <category>angular</category>
    </item>
  </channel>
</rss>
