Skip to content

Instantly share code, notes, and snippets.

@BrianPurgert
Last active June 9, 2024 04:41
Show Gist options
  • Save BrianPurgert/e795e9f5932400634e08eb5650bd8f45 to your computer and use it in GitHub Desktop.
Save BrianPurgert/e795e9f5932400634e08eb5650bd8f45 to your computer and use it in GitHub Desktop.
Yehuda Package Managers Comparison of Package Managers Bundler vs. Yarn vs. Cargo

Comparison of Package Managers Bundler vs. Yarn vs. Cargo

Ruby JavaScript Rust
Bundler Yarn Cargo
Manages gem dependencies for Ruby projects Manages packages and dependencies for JavaScript projects Manages packages and dependencies for Rust projects
Gems Packages/Modules Crates
Packages of Ruby programs and libraries Packages of JavaScript programs and libraries Packages of Rust programs and libraries
Gemfile package.json Cargo.toml
Specifies the gem dependencies for a Ruby project Specifies the dependencies and scripts for a JavaScript project Specifies the dependencies and configurations for a Rust project
Gemfile.lock yarn.lock Cargo.lock
Records the exact versions of gems installed Records the exact versions of packages installed Records the exact versions of crates installed
Rake Gulp/Grunt Cargo tasks
A build automation tool written in Ruby, similar to Make Build automation tools for JavaScript Integrated build automation in Cargo using commands like cargo build, cargo test, etc.

Default Behaviors

Ruby (Bundler)

  • Default Install Location: vendor/bundle (when using bundle install --path vendor/bundle)
  • Automatically installs missing gems listed in the Gemfile.
  • Ensures all gem dependencies are met and consistent with the Gemfile.lock.
  • Allows creating a consistent environment across different machines by using the same versions of gems.

JavaScript (Yarn)

  • Default Install Location: node_modules
  • Automatically installs all dependencies listed in the package.json.
  • Ensures consistency across environments using yarn.lock by locking the dependency tree.
  • Supports running scripts defined in the package.json for tasks like testing and building.

Rust (Cargo)

  • Default Install Location: target directory for compiled outputs and .cargo/registry for downloaded crates.
  • Automatically downloads and compiles dependencies listed in Cargo.toml.
  • Ensures consistency across builds using Cargo.lock by locking the dependency tree.
  • Provides built-in commands for building, testing, and running projects (cargo build, cargo test, cargo run).

Popular Version Managers

Ruby JavaScript Rust
RVM (Ruby Version Manager) nvm (Node Version Manager) rustup
rbenv volta

Popular Packages and Equivalents

Functionality Ruby (Gems) JavaScript (Packages) Rust (Crates)
Web Framework Rails Express Rocket
Testing RSpec Jest Cargo test
HTTP Client Faraday Axios Reqwest
Authentication Devise Passport jsonwebtoken
JSON Parsing Oj JSON (built-in) serde_json
Database ORM ActiveRecord Sequelize Diesel

Additional Details

  • Bundler: Often used in conjunction with Ruby on Rails to manage gems and ensure compatibility across different environments. It integrates tightly with the Rails framework.
  • Yarn: Known for its speed and reliability, Yarn addresses several issues found in npm, including dependency resolution and network performance. It is widely used in large JavaScript projects.
  • Cargo: An integral part of the Rust ecosystem, Cargo handles not only dependencies but also project building and testing, making it a comprehensive tool for Rust developers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment