Introducing VS Code
In my previous blog post I wrote a guide on setting up Overtone and starting it on your computer. If you are interested in live coding you should definitely check it out. I concluded that article with a thought that the true power of Clojure and Overtone can be really experienced through using it with an IDE/editor. There are several of them out there that do the job well, and I am going to mention one that is popular nowdays – Visual Studio Code. The important thing is that no matter which editor/IDE you’re using you will be able to follow along this and the future articles and try out the code yourself. I chose to describe the setup process for VS Code because lots of people are already using it for their various programming needs, and I figured that it will be easier for someone to try something new if it’s somewhat familiar.
Why is this important?
Writing and executing Clojure code in an editor with integrated REPL brings us many benefits. For example, many editors with Clojure environments have Paredit enabled, which handles parenthesis balance and lets us concentrate on the code we’re writing and not on counting parenthesis. This makes things so much easier. This setup also enables us to execute (or evaluate) parts of our code in a file whenever we want it, which is very helpful for live coding. There are of course many more benefits, but we’ll take a look at them when we dive further into our journey. For now, let’s set up our editor/IDE!
VS Code + Calva
The IDE we’re going to take a look in this article is Visual Studio Code OSS with Calva development environment for Clojure. I choose to mention this combination first because of massive popularity of VS Code as a programming environment. I found it fairly easy to setup and use, so I think you won’t have any problems if you choose to use this environment. Once you install VS Code, open it and go to File -> Preferences -> Extensions
or use the shortcut Ctrl+Shift+X
. Search for Calva in extension marketplace and install it.
Now that we have everything set up, let’s open our Clojure project folder (it is important to load the whole directory). If you haven’t created the project and added Overtone as dependency yet, learn how to do that in my previous blog post Overtone: Basic Setup. Go to File -> Open Folder...
or hit Ctrl+K Ctrl+O
. If that shortcut confuses you just hold Ctrl key and then press K, release K while still holding Ctrl, and press O. This style was inspired by another editor which I’m going to describe in great detail in the next article. Now with folder selection window open, just select your Clojure Overtone project directory and click OK. Once the project loads into editor, on the left side there will be ‘Explorer’ tab with tree structure of your project. Here’s a screenshot of mine, you can see that i opened the core.clj file and it’s location within the project:
VS Code + Calva Project:
Now go