Skip to content

srix/prog-lang-compare

Repository files navigation

Programming Language Comparison

A side-by-side comparison of popular programming languages. Compare syntax and concepts across 21+ programming languages including Python, JavaScript, Rust, Java, Go, and more.

🌐 Live Site: https://prog-lang-compare.netlify.app

Features

  • πŸ” 21+ Programming Languages: Compare syntax across Python, JavaScript, Rust, Java, Go, TypeScript, Ruby, Swift, Kotlin, and more
  • πŸ“š 108+ Programming Concepts: From basic datatypes to advanced concepts
  • 🎨 Modern UI: Dark mode support with beautiful syntax highlighting
  • πŸ€– AI-Generated Content: All explanations generated using OpenAI API
  • ⚑ 2,500+ Static Pages: SEO-optimized for search engines
  • πŸ“± Fully Responsive: Works great on mobile, tablet, and desktop

Quick Start

Prerequisites

  • Python 3.11+
  • Node.js 18+ (for JavaScript tests)
  • OpenAI API key (for content generation)

Installation

  1. Clone the repository:

    git clone https://github.com/srix/prog-lang-compare.git
    cd prog-lang-compare
  2. Set up Python environment:

    # Using uv (recommended)
    uv venv .venv-3.11 --python 3.11
    source .venv-3.11/bin/activate
    uv pip install -r requirements.txt
    
    # Or using standard pip
    python -m venv .venv
    source .venv/bin/activate  # On Windows: .venv\Scripts\activate
    pip install -r requirements.txt
  3. Configure API keys:

    cp .env.example .env
    # Edit .env and add your OpenAI API credentials
  4. Build the site:

    ./build.sh
  5. Preview locally:

    cd docs && python -m http.server 8000
    # Visit http://localhost:8000

Testing

Python Tests

Run tests for builder scripts:

# Activate virtual environment first
source .venv-3.11/bin/activate

# Run all tests
pytest

# Run with coverage
pytest --cov=builder --cov-report=html

# Run specific test file
pytest tests/test_helper.py

# View coverage report
open htmlcov/index.html

Current Test Coverage:

  • βœ… 17 tests passing
  • βœ… 100% coverage on plccache.py
  • βœ… 89% coverage on helper.py

JavaScript Tests

Run tests for frontend code:

# Install dependencies
npm install

# Run all tests
npm test

# Run with coverage
npm run test:coverage

# Run in watch mode
npm run test:watch

See TESTING.md for detailed testing documentation.

Project Structure

.
β”œβ”€β”€ builder/                    # Python build scripts
β”‚   β”œβ”€β”€ main.py                # AI content generator
β”‚   β”œβ”€β”€ generate_static_pages.py
β”‚   β”œβ”€β”€ generate_sitemap.py
β”‚   β”œβ”€β”€ helper.py              # Utility functions
β”‚   └── plccache.py            # Cache management
β”œβ”€β”€ docs/                      # GitHub Pages deployment
β”‚   β”œβ”€β”€ index.html             # Main page
β”‚   β”œβ”€β”€ script.js              # Frontend JavaScript
β”‚   β”œβ”€β”€ styles.css             # Styling
β”‚   β”œβ”€β”€ prog_lang_concepts.yaml
β”‚   β”œβ”€β”€ prog_langs.yaml
β”‚   └── concepts/              # 2,500+ static pages
β”œβ”€β”€ tests/                     # Python tests
β”‚   β”œβ”€β”€ test_helper.py
β”‚   └── test_plccache.py
β”œβ”€β”€ __tests__/                 # JavaScript tests
β”‚   └── script.test.js
β”œβ”€β”€ build.sh                   # One-command build script
β”œβ”€β”€ requirements.txt           # Python dependencies
β”œβ”€β”€ package.json               # JavaScript dependencies
└── TESTING.md                 # Testing guide

Development Workflow

Adding New Concepts

  1. Edit docs/prog_lang_concepts.yaml:

    NewCategory:
      NewConcept: "Explain {concept} in {lang} with examples."
  2. Run the builder:

    python builder/main.py
  3. Generate static pages:

    python builder/generate_static_pages.py
  4. Or use the all-in-one script:

    ./build.sh

Adding New Languages

  1. Edit docs/prog_langs.yaml:

    Programming Languages:
      - Python 3.10
      - Your New Language
  2. Rebuild:

    ./build.sh

Architecture

Content Generation Pipeline

prog_lang_concepts.yaml + prog_langs.yaml
    ↓
builder/main.py (OpenAI API + caching)
    ↓
docs/content-autogen/gpt_3_5_turbo/{language}.json
    ↓
builder/generate_static_pages.py
    ↓
docs/concepts/{language}/{concept}.html (2,500+ pages)
    ↓
builder/generate_sitemap.py
    ↓
docs/sitemap.xml

Key Features

  • Smart Caching: Only regenerates content when prompts change
  • Concurrent API Calls: Parallel processing for faster generation
  • SEO Optimized: Meta tags, structured data, sitemap
  • Responsive Design: Mobile-first with dark mode
  • Syntax Highlighting: Custom themes for light and dark modes

Technologies

Backend

  • Python 3.11: Build scripts
  • OpenAI API: Content generation
  • PyYAML: Configuration management
  • pytest: Testing framework

Frontend

  • Vanilla JavaScript: No framework dependencies
  • jQuery & DataTables: Interactive comparison table
  • Highlight.js: Syntax highlighting
  • Marked.js: Markdown rendering

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Run tests (pytest && npm test)
  5. Commit your changes (git commit -m 'Add amazing feature')
  6. Push to the branch (git push origin feature/amazing-feature)
  7. Open a Pull Request

Testing Guidelines

  • Write tests for new utility functions
  • Maintain >80% code coverage
  • Run pytest before committing
  • See TESTING.md for detailed guidelines

License

Licensed under the Apache License 2.0. See LICENSE for details.

Acknowledgments

  • Content generated using OpenAI API
  • UI inspired by modern developer tools
  • Community contributions and feedback

Links


Made with ❀️ by the Programming Language Comparison community

About

Compare programming concepts side by side for various computer language

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •