Skip to content

barisozmen/language-comparisons

Repository files navigation

Programming Language Comparisons

This project aims to compare various programming languages across multiple dimensions including:

  • Performance (execution time)
  • Code conciseness (lines of code)
  • Expressivity
  • Maintainability
  • Implementation complexity of design patterns

Project Structure

language-comparison/
├── README.md
├── algorithms/
│   ├── fibonacci/
│   │   ├── fibonacci.py
│   │   ├── fibonacci.js
│   │   ├── fibonacci.c
│   │   ├── fibonacci.cpp
│   │   ├── fibonacci.rs
│   │   ├── fibonacci.scm
│   │   └── README.md
│   ├── mandelbrot/
│   │   └── ...
│   ├── merge_sort/
│   │   └── ...
│   ├── prime_sieve/
│   │   └── ...
│   └── ...
├── design_patterns/
│   ├── observer/
│   │   ├── observer.py
│   │   ├── observer.js
│   │   ├── observer.cpp
│   │   ├── observer.rs
│   │   └── ...
│   ├── factory/
│   │   └── ...
│   ├── singleton/
│   │   └── ...
│   └── ...
├── benchmark.sh
├── generate_report.py
└── reports/
    ├── algorithms_performance.md
    ├── algorithms_loc.md
    ├── design_patterns_complexity.md
    └── ...

See DIRECTORY_STRUCTURE.md for the aspired structure, in more detail

Languages to Compare

Initial set of languages:

  • Python
  • JavaScript
  • C
  • C++
  • Rust
  • Scheme

Additional languages to consider adding later:

  • Go
  • Java
  • Kotlin
  • Swift
  • Haskell
  • Racket
  • TypeScript
  • Lua
  • Ruby
  • Scala
  • Erlang
  • Elixir
  • OCaml
  • F#

Algorithms to Implement

  1. Computational algorithms:

    • Fibonacci sequence (recursive and iterative)
    • Mandelbrot set generation
    • Prime number sieve
    • Merge sort
  2. Applied algorithms:

    • JSON parsing
    • Regular expression matching
    • File I/O operations
    • Simple cryptography (AES, SHA256)
  3. Data structures:

    • Binary search tree
    • Hash table implementation
    • Graph algorithms (BFS, DFS)
    • Priority queue

Design Patterns to Implement

  1. Creational Patterns:

    • Factory Method
    • Abstract Factory
    • Builder
    • Singleton
  2. Structural Patterns:

    • Adapter
    • Bridge
    • Composite
    • Decorator
    • Proxy
  3. Behavioral Patterns:

    • Observer
    • Strategy
    • Command
    • State
    • Visitor

Measurement Methodology

Performance Benchmarking

The benchmark.sh script will:

  1. Compile the compiled languages with optimization flags
  2. Run each implementation multiple times to get an average execution time
  3. Record system resource usage (CPU, memory)
  4. Generate a performance report in markdown format

Example benchmark command:

./benchmark.sh algorithms/fibonacci

Lines of Code Analysis

We'll use loc to count lines of code:

loc algorithms/fibonacci > reports/fibonacci_loc.md

Expressivity and Maintainability Assessment

For each implementation, we'll provide:

  • A subjective rating (1-10) of code readability
  • Notes on language features that aided or hindered implementation
  • Assessment of error handling capabilities
  • Documentation on gotchas or language-specific considerations

How to Run

  1. Clone this repository
  2. Install required languages and compilers
  3. Run the benchmark script:
    ./benchmark.sh [algorithm_folder]
  4. Generate the report:
    python generate_report.py

Future Directions

  1. Additional Metrics:

    • Memory usage profiling
    • Startup time measurement
    • Concurrency performance tests
  2. Expanded Scope:

    • Web framework comparisons
    • Database interaction benchmarks
    • Network programming tests
    • GUI application development comparisons
  3. Tooling Enhancements:

    • Interactive web dashboard for results
    • Continuous benchmarking on different hardware
    • Visualization of performance characteristics
    • Deeper static analysis of codebases
  4. Community Involvement:

    • Expert reviews from language specialists
    • Optimized implementations for each language
    • Historical tracking of language evolution
  5. Specialized Domains:

    • Machine learning algorithm implementations
    • Audio/video processing benchmarks
    • Image processing comparisons
    • Embedded systems code (where applicable)

Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create your feature branch
  3. Implement the algorithm/pattern in your language of choice
  4. Ensure your code is well-documented
  5. Submit a pull request

When adding a new implementation, please follow the existing structure and include comments explaining language-specific techniques.


This project is inspired by the need for objective, reproducible comparisons between programming languages that go beyond simple microbenchmarks and consider the full development experience.

GitHub: cgag/loc will be used for line counting.


Prompt used to generate this README.md:

This is a project for comparing programming languages in terms of speed on various algorithms, and also comparing them on their expressivity and maintainabilty on complex software projects.

in this repo, create bunch of folders with algorithm names, for example finbonacci, mandelbrot, merge sort, cryptography, and many others. For each folder, write the same algorithm in python, javascript, c, c++, rust, and scheme. Then, run a bash script that runs all of them and record how much time they take, and prepare a .md report on the folder itself based on their speed, line of codes for each and vice versa.

Then, for some repos, implement various software design patterns in each language, and with a bash report report how long they take. Use @https://github.com/cgag/loc project to count line of codes.

Before creating repos, and other things, populate the README.md file with how you will structure and organize this creative project. 

On top of that, think about next steps and what else can be done, and also note them down in README.md
This is a request to create a project comparing programming languages across various dimensions like performance, expressivity, and maintainability. Let me structure a comprehensive README.md for this project.

Key elements to include:

  1. Project overview and purpose
  2. Repository structure
  3. Languages to compare
  4. Algorithms/problems to implement
  5. Metrics for comparison
  6. How to run the benchmarks
  7. How to contribute
  8. Future directions

The user wants to use the loc tool from https://github.com/cgag/loc to count lines of code, which is a good choice for this type of project.

I should also note that this kind of comparative analysis is quite valuable for the programming community, so I'll try to make this README comprehensive and well-structured.

About

Language comparisons in terms of speed/expressivity/syntax

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published