There is a growing common interest on the Infinite Conversations/Cosmos site to explore e-governance and e-currencies, and we have had a number of fruitful exchanges with developers of Holochain and also the CoGov modules that are being built in relation to Holochain. Over the past few weeks I downloaded the development environment for Holochain to my computer and have been working my way through the tutorials in order to begin experimenting with the environment. Several others have expressed interest in doing this also. In addition, there are ongoing discussions about its relationship to other e-governance and e-currency initiatives such as blockchain and bitcoin. So I propose to use this thread to support our learning efforts but also to encourage further discussion about these issues.
I am working on a Mac - unfortunately, those on Windows computers will have different issues. However, I propose to expose some of my âteething issuesâ here, and try to keep separate Mac issues from Unix, Holochain and CoGov issues.
Basically, to get Holochain up and running on my computer, I went to the Holochain.org website and selected the menu item âGet Startedâ. They provide detailed instructions for downloading the code for each type of platform. Holochain is built inside a kind of extended programming environment called github.com - it is essentially a community of developers working across a broad range of projects of which Holochain is only one. Once github is installed, you are then ready to download the holochain code itself.
Mac issues on downloading and installing
My primary problems were all related to the fact that I have not really done any Unix work in decades. The MacOS is built on top of Unix. For most users, this fact is simply an obscure issue they pay no attention to, but it means that the Mac is also a powerful Unix computer. To access the Unix environment, you need to use a Utility app built into the Mac called âTerminalâ. Terminal gives you access to a command line interpreter for Unix (where you type commands in to do stuff, instead of using the mouse).
The terminal screen looks like this :
It basically allows you to access the directory structure of your Mac using typed instructions. In Unix, of course, there are standard ways of doing this. When you first get onto Terminal and open a window, you get something like this :
Itâs a bit daunting!
if you type in âpwdâ the system tells you what directory you are in (present working directory, or something like that).
pwd
==> /Users/geoffreyedwards
So it tells me that I am in the Users directory in the subdirectory with my name. My computer has more than one account, hence that location.
To get stuff installed, you are going to have to be in the root directory. To get there, you use the âcdâ (change directory) command. The simplest way to do this is to use, in the example I have given, âcd âŚâ twice. âcd âŚâ tells Unix to move up a level in the directory structure.
So
cd âŚ
cd âŚ
pwd
==> /
So now I am at the root level.
The instructions for holochain will install holochain, by default into a set of directories and subdirectories that it creates for you. But the instruction also tell you to make some changes to some of the root files, which is why I have shown you how to get there. In particular, you are asked to change the â.bash_profileâ file. File names that begin with a â.â are normally hidden in Unix. A command such as âlsâ will give you a list of all the files in the directory, but wonât always show the hidden files.
Now, to get into a file, you are going to need an editor. Fortunately, Unix has a number of built-in editors you can use. The simplest is something called âviâ, although it has been updated, and is now called âvimâ. You simply type âvimâ and the name of the file you either want to create or want to edit (if it is an existing file), and, presto, you are inside the editor. You need to find some documentation on vim to use it properly, however (here is a pdf manual I quite like - I find a pdf file useful in a manual since I donât have multiple screens on my computer so having everything on line can be awkward flipping between different windows). I just hunted around on the web for a manual, my vim skills had gotten rusty!
Anyway, I made the changes asked for by the holochain installation instructions, but I did something really stupid. The two lines they want you to put into the â.bash_profileâ file include quotation marks. I typed in my usual quotation marks, and went ahead with the process, and the thing stalled. Worse, you had to run âbashâ to get everything working, and the program just hung - it wouldnât take any commands or do anything at all. So I spent a considerable amount of time reading up on âshellsâ (bash is a Unix shell - a separate command line environment from the default one Unix uses when you first come into it, with somewhat different commands), Unix commands, what have you. I was stuck. So I emailed Ray Powell and he pointed out, when I sent him a copy of my code, that I had used âsmart quotesâ and not basic quotes. Of course the compiler doesnât recognize smart quotes! Problem fixed, and everything went forward again.
As I mentioned above, running bash means that not all the Unix commands I knew worked the way I expected them to. So I hunted around on the net and found someone who had developed an extensive â.bash_profileâ that provides all the right aliases I needed to work the way I expected to *see Nathaniel Landauâs page. If you are new to Unix, this probably isnât very useful - for me it was a godsend, since without it, all my âreflexesâ were wrong. The rather extensive lists you see in the first Terminal image are the results of this extended .bash_profile running in the background - it lists files even when I just hit a carriage return.
Eventually, with a bit more work, you get to the point where you can code in following the tutorials. My JavaScript programming skills were also rusty, not just Unix, so I looked up a JavaScript manual and refamiliarized myself with JavaScript. You almost donât need to do this to work through the tutorials, the language reads without much difficulty and the tutorials are well designed, but since you are going to be programming yourself eventually, it makes sense to do this.
I had some debugging to do - missing commas, etc. - all programming environments require you to check character by character what you have done, and itâs easy to omit something or make a small mistake copying.
The HoloWorld tutorial (essentially the first tutorial they propose) is quite extensive. There are some structural issues. I was reminded of a Jane Siberry song âwhat you do over here, you have to do over thereâ. You make changes to one file but you have to make appropriate and matching changes to another file. Itâs okay when you are following a tutorial, but when you are developing a new programme yourself, you are going to have to keep track of these things.
One thing that took me a while to work out. The tutorials ask you to work in two types of files (with two types of extensions), â.jsonâ and â.jsâ files. Why those two? I kept asking myself. Eventually I looked it up. The â.jsâ files are the JavaScript code files, as one might expect. The â.jsonâ are essentially data files, that is, they contain relevant data that is used by the â.jsâ files - I think this is part of a principle of separating data off from code. However, JSON is a data exchange format used by a wide variety of programming languages, not just JavaScript. JSON (for JavaScript Object Notification) is constructed using JavaScript syntax, which is where the confusion arises, but it is a much more general purpose kind of file.
At the end of the HoloWorld tutorial, you are asked to run code which opens a port (â4141â). Donât forget to do this in your browser - open a page at the address âhttp://localhost:4141â. I forgot to do this and the program hung again in the Terminal window. To break out of a âhungâ program, press âControl-Câ.
More Unix issues
By now it should be apparent you will also need a primer on Unix commands if you are working in this environment. There are lots around (hereâs one that I find useful), and you can always type âhelpâ in directly in Unix and get a list of acceptable commands.
By the time you have HoloWorld up, you now have a deep directory structure. Mine is â~/go/src/github.com/holochain/holochain-proto/testApps/holoWorldâ to give you an idea. Since when you sign onto a new Terminal window you enter near the root directory, it is awkward and time consuming to type this long directory in every time (there are other tricks however that simplify the process). So I re-entered the â.bash_profileâ file and added new aliases that assigned these long commands to âcdholoâ and âcdhwâ, so thatâs all I have to type in now to get to the right directory.
I think that covers things for my first programming issues in relation to Holochain. I think one needs to work through several tutorials to really begin to understand how to program in Holochain. I will let you know how that goes.