Part 2 — A complete beginner’s guide to Computer Programming with Clojure: Installation.

Image for post
Image for post
Photo by Sebastian Herrmann on Unsplash

For any book or guide, the installation section is usually the most frustrating. Why? Because a number of different components must be installed and come together in a cohesive manner.

Unfortunately, system dependencies and differing operating system versions or constraints often prevent this from being an issue-free process. In reality, you follow the instructions laid out before you and nothing works as it should. After many hours you may succeed in your installation endeavors, else give up on the idea of a computer programming career!

Virtualization

To overcome this issue of ‘why does it work on your computer and not mine’, I have created a Virtual Computer (known as a VM or virtual machine) with everything pre-installed.

Virtualbox and Vagrant

Nevertheless, to work with my Virtual machine you will require two free pieces of software. These are Oracle’s Virtualbox and Hashicorp’s Vagrant. Both these programs are designed for trouble-free installation and work on both Apple and Microsoft Windows computers. You should encounter no issues providing your machine is no older than 5 years and has at least 4Gb of RAM.

The following two links will take you to the respective VirtualBox and Vagrant websites and each provides full installation instructions:

In addition, there are a number of video guides on Youtube that cover installing Virtualbox and Vagrant but this should not be necessary. I have, however, written detailed documentation for another Virtual machine I created. These articles provide further instructions on configuring Virtualbox machines and can be read here:

https://ironbridge.associates/part-1-installing-ironbridge-virtual-machine/

Once both Virtualbox and Vagrant are installed, you can go ahead and install the Clojure Virtual machine developed specifically for this course.

Installing the Clojure Virtual Machine

First, we will create a directory. I have opened a terminal on my Apple Mac and I wish to call the folder Coding.

mkdir Coding
Image for post
Image for post

I will then change into the directory called Coding.

cd Coding
Image for post
Image for post

As we have installed Vagrant and Virtualbox we can now download and use the Vagrant box specifically created for this course from my Vagrant account.

Image for post
Image for post

To install this Vagrant Box onto your machine, simply type

vagrant init HarvixDesign/clojure
Image for post
Image for post

You will see the following message

Image for post
Image for post

Now just type the vagrant up command to initialize the download

vagrant up
Image for post
Image for post

You should see something similar to this

Image for post
Image for post

Eventually, you will see this

Image for post
Image for post

The section in green states you have downloaded the vagrant box. More importantly, you should also see that Virtualbox has opened with a live machine!

Click Show to engage our Clojure virtual machine.

Image for post
Image for post

If you get a message similar to the following, just click Switch

Image for post
Image for post

The password is all in lower case: clojure

You may get a message like so

Image for post
Image for post

Just choose to install or be reminded later

If you choose to Install Now, you will need to re-enter the password clojure and then click OK

Image for post
Image for post

For any system messages, just click OK to remove them

Image for post
Image for post
Image for post
Image for post

On the Desktop you have these icons. Rubbish Bin is where files go before deletion.

LXTerminal is the command line window where you will run and engage with various tools, including Clojure specific tools.

Geany is one of many available text editors, aka development environment, for writing Clojure code. I will use this editor but you can use another installed editor if you prefer.

Databases is just a simple text files with instructions for engaging with a number of preinstalled databases. I have installed MySQL, MongoDB, PostgreSQL and SQLite. This should be enough for the majority of projects.

The bar at the bottom is similar to that found within many other operating systems and can be modified to add other shortcut links.

Image for post
Image for post
Image for post
Image for post

The very first icon situated at the far left of the bottom bar is a menu system similar to that found on Windows.

Image for post
Image for post

Also situated on the bottom bar is a duel window icon.

The dark blue square states you are in window one.

I have opened a terminal (LXTerminal) window and engaged the lein repl to run a simple piece of Clojure code that adds two numbers.

Image for post
Image for post
Image for post
Image for post
Image for post
Image for post

If I click the adjacent square I get a new window like so:

Image for post
Image for post

Once you have finished you can power down using the off-switch icon located on the bottom bar next to the clock.

Image for post
Image for post

You are presented with a number of choices. Just choose the appropriate one for you.

Image for post
Image for post

Virtualization

Hopefully, all went well and you have a fully working shiny new VM (virtual machine) to play with. If you have read my other blog posts, you will know how to fully configure, clone, and export a VM. There is nothing to stop you just installing lein and configuring your own computer to create and run clojure programs. However, you will be missing out on the many advantages of using the course VM. For instance, my Clojure VM has a number of other features such as pre-installed databases, plus a number of IDE’s (integrated development environments) and text editors. For Computer Science students, I have also installed Python and a number of Python-specific IDE’s. In short, this VM can be used to teach a number of computer-related subjects.

It’s worth noting that Virtual Machines are also part of the DevOps toolkit. DevOps is effectively an umbrella term for the words, Development and Operations. Development encompasses computer programming and software creation. Whereas, Operations covers the infrastructure designed to contain and run the aforementioned Development work. Unfortunately, physical machines and operating systems are very nuanced and what works on ‘my computer’ does not always work on ‘your computer’. For a number of years, this created conflict and distrust between Developer and Operation’s teams. To get around this, DevOps culture created tools and techniques to integrate those resources traditionally supplied by Operations with the completed software product. A VM is one such tool. Here, we create a computer out of software that has been created to run our specific program or programs. The installed software will always work as it is married to the perfect operational resource. Nevertheless, for many, this VM is too much ‘bulk’ and unnecessary.

Introducing Containers and Container technology. A Container is essentially the operational bare-bones, or system dependencies, necessary to run the specific software created by the Development team. This is a lot lighter than a VM and has the advantage that it can sit inside both a physical and virtual machine. Again, like a VM, Containers can be cloned and stored like a file. There are both advantages and disadvantages to favoring one specific DevOps technology over another. For instance, Containers are extremely light whereas a VM encompasses greater security, primarily due to it being a sandboxed environment (a sandbox provides the running software with a separate operating system). A number of tools are available for creating bespoke Containers with Docker being one of the most mature and popular.

SUMMARY

Clearly, this post covers much more than a simple set of Clojure installation instructions. This chapter introduces Virtualisation and DevOps culture. Both these subjects are deep and covered by a multitude of technologies, reference materials, books, and educational courses. Hopefully, this post has extended your vocabulary and given you some insight into modern software development. Note, we utilized Vagrant in conjunction with Virtualbox. As with everything discussed, there is a lot more to Vagrant!

Previous

Part 3 — Introducing LEIN and REPL

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store