JavaScript and React course ยท Module 1: React Basics

Comparison with other frameworks

3 min read ยท
In this lesson4

In the cosmos of frontend technologies, many different planet-frameworks orbit. Each has its own ecosystem, atmosphere, and inhabitants. Let's look at how React compares to other popular solutions:

React vs Angular

Angular, created and supported by Google, is a comprehensive framework that provides everything you need to build an application, from a routing system to form management and HTTP communication.

The difference between React and Angular can be compared to the difference between a modular spaceship (React) that you can configure freely, and a complete space station (Angular) that already has everything built in.

Advantages of Angular over React:

  • Complete framework with many built-in tools
  • Strong typing support thanks to TypeScript
  • Clear project structure (fewer decisions to make)

Advantages of React over Angular:

  • Smaller learning curve
  • Greater flexibility in choosing tools
  • Lighter and often more performant
  • Larger community and ecosystem

React vs Vue

Vue.js, sometimes called a "progressive framework," offers a middle ground between React's lightness and Angular's comprehensiveness.

This can be compared to the difference between a research vessel (React), designed for exploration and discovery, and a universal transporter (Vue), which is friendly for both beginners and advanced pilots.

Advantages of Vue over React:

  • Gentler learning curve
  • More intuitive template syntax
  • Built-in solutions for commonly used features

Advantages of React over Vue:

  • Larger ecosystem and community support
  • Better support for mobile applications (React Native)
  • Greater availability of experienced developers in the job market

React vs Svelte

Svelte represents a new generation of frameworks where the magic happens primarily during compilation, not in the user's browser.

It's like comparing a traditional combustion engine (React), which needs fuel (CPU time) to operate, with a modern electric engine (Svelte), which is more efficient and simpler in design.

Advantages of Svelte over React:

  • Smaller output code size
  • Often better performance, especially on weaker devices
  • More intuitive syntax, closer to "pure" HTML/CSS/JS

Advantages of React over Svelte:

  • More mature ecosystem and more libraries
  • Larger community and educational resources
  • Better support for large, complex applications

Performance comparison

Performance is one of the key aspects when choosing a framework. However, it's worth remembering that in most real-world use cases, performance differences between popular frameworks are often imperceptible to the end user.

Performance metrics:

FrameworkSize (KB)Load time (ms)Interaction time (ms)
React~42~300~100
Angular~63~350~120
Vue~33~280~90
Svelte~10~250~80

Remember that these values are approximate and can vary significantly depending on the project specifics, optimizations, and use case. Often the biggest impact on performance comes not from the framework choice but from the quality of the code written in it.

Code for this lesson: App.jsx
import React from 'react';

// Component for comparing frameworks
function FrameworkComparison({ framework, logo, pros, cons, popularApps, color }) {
  const [isExpanded, setIsExpanded] = React.useState(false);

  return (
    <div style={{
      border: `2px solid ${color}`,
      borderRadius: '12px',
      padding: '20px',
      margin: '15px 0',
      backgroundColor: 'white',
      boxShadow: '0 4px 6px rgba(0, 0, 0, 0.1)',
      transition: 'transform 0.2s',
      transform: isExpanded ? 'scale(1.02)' : 'scale(1)'
    }}>
      <div style={{
        display: 'flex',
        alignItems: 'center',
        marginBottom: '15px',
        cursor: 'pointer'
      }}
      onClick={() => setIsExpanded(!isExpanded)}
      >
        <div style={{
          fontSize: '40px',
          marginRight: '15px'
        }}>
          {logo}
        </div>
        <h3 style={{
          color,
          margin: 0,
          fontSize: '1.5rem'
        }}>
          {framework}
        </h3>
        <div style={{
          marginLeft: 'auto',
          fontSize: '20px',
          color: '#666'
        }}>
          {isExpanded ? 'โ–ผ' : 'โ–ถ'}
        </div>
      </div>

      {isExpanded && (
        <div>
          <div style={{
            display: 'grid',
            gridTemplateColumns: '1fr 1fr',
            gap: '20px',
            marginBottom: '20px'
          }}>
            <div>
              <h4 style={{ color: '#28a745', marginBottom: '10px' }}>Pros</h4>
              <ul style={{ margin: 0, paddingLeft: '20px' }}>
                {pros.map((pro, index) => (
                  <li key={index} style={{ marginBottom: '5px' }}>{pro}</li>
                ))}
              </ul>
            </div>

            <div>
              <h4 style={{ color: '#dc3545', marginBottom: '10px' }}>Cons</h4>
              <ul style={{ margin: 0, paddingLeft: '20px' }}>
                {cons.map((con, index) => (
                  <li key={index} style={{ marginBottom: '5px' }}>{con}</li>
                ))}
              </ul>
            </div>
          </div>

          <div style={{
            backgroundColor: '#f8f9fa',
            padding: '15px',
            borderRadius: '8px'
          }}>
            <h4 style={{ margin: '0 0 10px 0', color: '#495057' }}>Popular Applications</h4>
            <div style={{
              display: 'flex',
              flexWrap: 'wrap',
              gap: '8px'
            }}>
              {popularApps.map((app, index) => (
                <span key={index} style={{
                  backgroundColor: color,
                  color: 'white',
                  padding: '4px 12px',
                  borderRadius: '15px',
                  fontSize: '14px'
                }}>
                  {app}
                </span>
              ))}
            </div>
          </div>
        </div>
      )}
    </div>
  );
}

// Interactive component for comparing performance
function PerformanceComparison() {
  const [selectedFramework, setSelectedFramework] = React.useState('React');

  const frameworks = {
    React: { size: 42, loadTime: 300, interactionTime: 100, color: '#61dafb' },
    Angular: { size: 63, loadTime: 350, interactionTime: 120, color: '#dd0031' },
    Vue: { size: 33, loadTime: 280, interactionTime: 90, color: '#4fc08d' },
    Svelte: { size: 10, loadTime: 250, interactionTime: 80, color: '#ff3e00' }
  };

  const current = frameworks[selectedFramework];

  return (
    <div style={{
      backgroundColor: '#f8f9fa',
      padding: '25px',
      borderRadius: '12px',
      margin: '20px 0'
    }}>
      <h3 style={{ textAlign: 'center', marginBottom: '20px', color: '#333' }}>
        Framework Performance Comparison
      </h3>

      <div style={{
        display: 'flex',
        justifyContent: 'center',
        marginBottom: '25px',
        flexWrap: 'wrap',
        gap: '10px'
      }}>
        {Object.keys(frameworks).map(framework => (
          <button
            key={framework}
            onClick={() => setSelectedFramework(framework)}
            style={{
              padding: '10px 20px',
              backgroundColor: selectedFramework === framework ? frameworks[framework].color : '#fff',
              color: selectedFramework === framework ? 'white' : '#333',
              border: `2px solid ${frameworks[framework].color}`,
              borderRadius: '25px',
              cursor: 'pointer',
              fontSize: '14px',
              fontWeight: 'bold',
              transition: 'all 0.3s'
            }}
          >
            {framework}
          </button>
        ))}
      </div>

      <div style={{
        display: 'grid',
        gridTemplateColumns: 'repeat(auto-fit, minmax(200px, 1fr))',
        gap: '20px'
      }}>
        <div style={{
          backgroundColor: 'white',
          padding: '20px',
          borderRadius: '8px',
          textAlign: 'center',
          border: '1px solid #dee2e6'
        }}>
          <h4 style={{ margin: '0 0 10px 0', color: '#666' }}>Bundle Size</h4>
          <div style={{ fontSize: '2rem', fontWeight: 'bold', color: current.color }}>
            {current.size} KB
          </div>
          <div style={{
            height: '10px',
            backgroundColor: '#e9ecef',
            borderRadius: '5px',
            margin: '10px 0',
            overflow: 'hidden'
          }}>
            <div style={{
              height: '100%',
              backgroundColor: current.color,
              width: `${(current.size / 70) * 100}%`,
              transition: 'width 0.5s'
            }}></div>
          </div>
        </div>

        <div style={{
          backgroundColor: 'white',
          padding: '20px',
          borderRadius: '8px',
          textAlign: 'center',
          border: '1px solid #dee2e6'
        }}>
          <h4 style={{ margin: '0 0 10px 0', color: '#666' }}>Load Time</h4>
          <div style={{ fontSize: '2rem', fontWeight: 'bold', color: current.color }}>
            {current.loadTime} ms
          </div>
          <div style={{
            height: '10px',
            backgroundColor: '#e9ecef',
            borderRadius: '5px',
            margin: '10px 0',
            overflow: 'hidden'
          }}>
            <div style={{
              height: '100%',
              backgroundColor: current.color,
              width: `${(current.loadTime / 400) * 100}%`,
              transition: 'width 0.5s'
            }}></div>
          </div>
        </div>

        <div style={{
          backgroundColor: 'white',
          padding: '20px',
          borderRadius: '8px',
          textAlign: 'center',
          border: '1px solid #dee2e6'
        }}>
          <h4 style={{ margin: '0 0 10px 0', color: '#666' }}>Interaction Time</h4>
          <div style={{ fontSize: '2rem', fontWeight: 'bold', color: current.color }}>
            {current.interactionTime} ms
          </div>
          <div style={{
            height: '10px',
            backgroundColor: '#e9ecef',
            borderRadius: '5px',
            margin: '10px 0',
            overflow: 'hidden'
          }}>
            <div style={{
              height: '100%',
              backgroundColor: current.color,
              width: `${(current.interactionTime / 150) * 100}%`,
              transition: 'width 0.5s'
            }}></div>
          </div>
        </div>
      </div>

      <p style={{
        textAlign: 'center',
        marginTop: '20px',
        fontSize: '14px',
        color: '#666',
        fontStyle: 'italic'
      }}>
        * Values are approximate and may vary depending on the project specifics
      </p>
    </div>
  );
}

export default function App() {
  const [activeTab, setActiveTab] = React.useState('comparison');

  return (
    <div style={{
      fontFamily: 'Arial, sans-serif',
      maxWidth: '1000px',
      margin: '0 auto',
      padding: '20px'
    }}>
      <header style={{
        textAlign: 'center',
        marginBottom: '30px',
        padding: '25px',
        background: 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)',
        color: 'white',
        borderRadius: '12px'
      }}>
        <h1 style={{ margin: '0 0 10px 0', fontSize: '2.2rem' }}>
          React vs Other Frameworks
        </h1>
        <p style={{ margin: 0, fontSize: '1rem', opacity: 0.9 }}>
          Comparison of the most popular frontend solutions
        </p>
      </header>

      <div style={{
        display: 'flex',
        justifyContent: 'center',
        marginBottom: '30px',
        gap: '10px'
      }}>
        <button
          onClick={() => setActiveTab('comparison')}
          style={{
            padding: '12px 24px',
            backgroundColor: activeTab === 'comparison' ? '#667eea' : 'white',
            color: activeTab === 'comparison' ? 'white' : '#333',
            border: '2px solid #667eea',
            borderRadius: '8px',
            cursor: 'pointer',
            fontWeight: 'bold'
          }}
        >
          Feature Comparison
        </button>

        <button
          onClick={() => setActiveTab('performance')}
          style={{
            padding: '12px 24px',
            backgroundColor: activeTab === 'performance' ? '#667eea' : 'white',
            color: activeTab === 'performance' ? 'white' : '#333',
            border: '2px solid #667eea',
            borderRadius: '8px',
            cursor: 'pointer',
            fontWeight: 'bold'
          }}
        >
          Performance
        </button>
      </div>

      {activeTab === 'comparison' && (
        <div>
          <FrameworkComparison
            framework="React"
            logo="โ—†"
            color="#61dafb"
            pros={[
              "Flexibility in choosing tools",
              "Huge ecosystem",
              "Strong community",
              "React Native for mobile",
              "Gentle learning curve"
            ]}
            cons={[
              "Requires additional libraries",
              "Rapidly changing ecosystem",
              "JSX can be confusing at first"
            ]}
            popularApps={["Facebook", "Instagram", "Netflix", "Airbnb", "Uber"]}
          />

          <FrameworkComparison
            framework="Angular"
            logo="A"
            color="#dd0031"
            pros={[
              "Complete framework",
              "Strong TypeScript support",
              "Clear structure",
              "Powerful CLI",
              "Enterprise-ready"
            ]}
            cons={[
              "Steep learning curve",
              "Larger bundle size",
              "Can be overkill for small projects"
            ]}
            popularApps={["Google", "Microsoft Office", "Samsung", "Deutsche Bank"]}
          />

          <FrameworkComparison
            framework="Vue.js"
            logo="โ—†"
            color="#4fc08d"
            pros={[
              "Gentle learning curve",
              "Intuitive syntax",
              "Good documentation",
              "Progressive approach",
              "Smaller size"
            ]}
            cons={[
              "Smaller ecosystem",
              "Fewer job offers",
              "Younger community"
            ]}
            popularApps={["GitLab", "Adobe", "Nintendo", "BMW", "Louis Vuitton"]}
          />

          <FrameworkComparison
            framework="Svelte"
            logo="โ—†"
            color="#ff3e00"
            pros={[
              "No Virtual DOM",
              "Very small bundle",
              "Build-time compilation",
              "Syntax simplicity",
              "Great performance"
            ]}
            cons={[
              "Small ecosystem",
              "Limited tools",
              "Young technology",
              "Few developers"
            ]}
            popularApps={["The New York Times", "Apple", "Spotify", "IKEA"]}
          />
        </div>
      )}

      {activeTab === 'performance' && <PerformanceComparison />}

      <div style={{
        backgroundColor: '#e8f5e8',
        padding: '25px',
        borderRadius: '12px',
        marginTop: '30px'
      }}>
        <h3 style={{ color: '#2e7d32', textAlign: 'center', marginBottom: '15px' }}>
          Which Framework to Choose?
        </h3>
        <div style={{
          display: 'grid',
          gridTemplateColumns: 'repeat(auto-fit, minmax(200px, 1fr))',
          gap: '15px'
        }}>
          <div style={{ textAlign: 'center', padding: '15px' }}>
            <h4 style={{ color: '#1976d2' }}>For Beginners</h4>
            <p style={{ margin: 0 }}>Vue.js or React</p>
          </div>
          <div style={{ textAlign: 'center', padding: '15px' }}>
            <h4 style={{ color: '#1976d2' }}>For Enterprise</h4>
            <p style={{ margin: 0 }}>Angular</p>
          </div>
          <div style={{ textAlign: 'center', padding: '15px' }}>
            <h4 style={{ color: '#1976d2' }}>For Performance</h4>
            <p style={{ margin: 0 }}>Svelte</p>
          </div>
          <div style={{ textAlign: 'center', padding: '15px' }}>
            <h4 style={{ color: '#1976d2' }}>For Ecosystem</h4>
            <p style={{ margin: 0 }}>React</p>
          </div>
        </div>
      </div>
    </div>
  );
}

Spotted a mistake in this lesson?

Check yourself

Answer the questions from this lesson. Pick an answer to see right away whether it is correct.

  1. 1. How does React differ from full frameworks like Angular?

  2. 2. What does declarative programming mean in React?

  1. QuestionReact vs frameworks
  2. QuestionDeclarative paradigm in React

Useful articles