Hanyu Blog

From a Jekyll blog to Ruby (Basics)

For someone who works primarily around Python & JavaScript (and recently started iOS dev with Obj-C and Swift), setting up this blog with Jekyll is my first experience to interact with everything Ruby. I had some struggles during development around understanding some terminologies and setting up the environment, but I found comparing them with what I know in Python and JavaScript works well for me.

Ruby, Gems, and RubyGems ๐Ÿ’Ž

Ruby is โ€ฆ ๐Ÿ’Ž

A dynamic, open source programming lanaguage with a focus on simplicity and productivity. (source)

This should be fairly straightforward, but I got interested in how the official websites describe the languages in 1 sentence. So here we go:

Python is โ€ฆ ๐Ÿ

a programming language that lets you work quickly and integrate systems more effectively. (source)

JavaScript is โ€ฆ ๐Ÿ•ธ

the worldโ€™s most popular programming language.

the programming language of the Web.

easy to learn. (source)

And into the iOS realm. Objective-C is โ€ฆ ๐Ÿ’ป

the primary programming language you use when writing software for OS X and iOS. itโ€™s a superset of the C programming language and provides object-oriented capabilities and a dynamic runtime. (source)

Finally, Swift is โ€ฆ ๐Ÿ’จ

a powerful and intuitive programming language for iOS, iPadOS, macOS, tvOS and watchOS. (source)

And back to the scheduled programmeโ€ฆ

For programs written in these languages, they can invoke some functionalities that are provided by packages (or libraries).

๐Ÿ In the world of Python, we call them Packages or Libraries. The tool we often use for managing these packages/libraries is PyPi. To install and manage them, we often use pip install. The configuration file requirement.txt is also commonly used to conveniently install the specified package with the specified version.

๐Ÿ•ธ Relatively, in the world of JavaScript, we also use Packages/Libraries to provide some additional functions to our program. The tool we use for managing them changes to NPM or Yarn and we use npm install or yarn add for installing packages. The configuration file package.json acts similiar to requirement.txt in terms of specifying the versions of the depencies (and with a lot more other responsibilities).

๐Ÿ’ป For Cocoa applications, the tools and config file we use change to Carthage and Cartfile. The command we use becomes carthage update.

๐Ÿ’Ž And now back to the world of Ruby, a Gem is just another saying for a package and library and RubyGem is a tool to install, create, manage and load these packages in the Ruby envrionment (source). A Gemfile is similiar to requirement.txt, package.json and Carfile, listing the gems used by the progrem. To install a gem, use gem install

For Jekyll specifically, a Bundler (also a gem) is used to install all gems in the Gemfile by using bundle install.

Gotchas when working with RubyGems ๐Ÿ’Ž

  • To install a gem without a Bundler, use gem install <gemName>. However, unlike NPM which provides both global install option with npm install -g and local install option with npm install, gem installation is always system wide, and the package is always available for any projects within the system.

  • When using --user-install option with gem install, RubyGems will install the gems to a directory inside your home directory. For programs installed there to be available, you need to add the destination to your PATH environment variable