Last time, we discussed the grouping of code together into modules and packages and at the end I encouraged you to investigate your computer for software modules and also to have a go at putting your own modules together.
Today we're going to look into the ways in which our chosen languages offer other people's code modules for your delight and enjoyment. This is typically referred to as a language's package database and it is one of the many ways of getting hold of modules written by others without use of your operating system's package manager.
Perl
Perl is a very well established langauge and community. For a long time, the
go-to place for Perl modules has been CPAN (The Comprehensive Perl Archive
Network). Perl comes with a special module called CPAN
which can be used
to access the archive of modules without needing any other tooling. You can
interact with it by running:
$ perl -MCPAN -eshell
Follow through the configuration, let it have a jolly good fiddle and then it'll let you search for and install perl modules on your computer.
Python
Python's community went for a commandline tool rather than a REPL, and then being a super-special community they schismed a bit and so there's both pip and easy_install to choose from. You can install Python modules as simply as:
$ pip install <packagename>
Lua
Lua, having a much smaller and to some extent younger community around it has
only managed to grow a single package manager. It is called luarocks and
is closer in behaviour to pip
than to CPAN
.
$ luarocks install <packagename>
is all you need to get something installed for use with Lua.
Challenge
Today's task is to become comfortable using the package managers of the languages of your choice. Learn how to install and remove packages, and how to search and retrieve information about different packages in the respective databases. Then think of something fun to play with, install those packages, and have a jolly good time coding with the libraries you didn't have to write yourselves.