{"id":2236,"date":"2014-06-04T03:25:06","date_gmt":"2014-06-04T08:25:06","guid":{"rendered":"http:\/\/www.patheos.com\/blogs\/crywoof\/?p=2236"},"modified":"2014-06-05T19:58:31","modified_gmt":"2014-06-06T00:58:31","slug":"tools-for-learning-clojure","status":"publish","type":"post","link":"https:\/\/www.patheos.com\/blogs\/crywoof\/2014\/06\/tools-for-learning-clojure\/","title":{"rendered":"Tools for Learning Clojure"},"content":{"rendered":"<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD HTML 4.0 Transitional\/\/EN\" \"http:\/\/www.w3.org\/TR\/REC-html40\/loose.dtd\">\n<html><head><meta http-equiv=\"content-type\" content=\"text\/html; charset=utf-8\"><meta http-equiv=\"content-type\" content=\"text\/html; charset=utf-8\"><\/head><body><p>As I wrote on Saturday, I\u2019m learning to program in <a href=\"http:\/\/clojure.org\" class=\" decorated-link\" target=\"_blank\" rel=\"nofollow\">Clojure<\/a>; and being a tool user at heart I immediately went looking for the right tools for the job.  Here\u2019s what I wanted:<\/p>\n<ol>\n<li> A REPL at which to experiment with Clojure code, with good command-line editing and command history.\n<\/li><li> An editor in which to edit Clojure code, integrated with the REPL.\n<\/li><li> An easy way to build a stand-alone application in Clojure.\n<\/li><li> A solution that works on both Mac and Windows.\n<\/li><\/ol>\n<p>\u201cREPL\u201d stands for \u201cread-eval-print loop\u201d, and it\u2019s a LISP-ism for a terminal-style interface to a language.  You type a command at the language interpreter, it reads it, evaluates it, and returns the result.  Then you type something else, and it responds to that, and so on.  It makes it possible to develop programs interactively, and test your code as you write, and it\u2019s very cool.  <\/p>\n<pre>\r\n    user=&gt; <b>(defn square [x] (* x x))<\/b>\r\n    #'user\/square\r\n    user=&gt; <b>(square 5)<\/b>\r\n    25\r\n    user=&gt;\r\n<\/pre>\n<p>LISP programmers like to talk as though they invented the REPL, which they did, and they keep using the term \u201cREPL\u201d, which most people don\u2019t; they just call it an interpreter.  (And then they tell you that it isn\u2019t really interpreted, it\u2019s all compiled under the covers.) The first programming language I learned was BASIC on a PDP-11; it was an interpreter, and when you started it up you got a command prompt and developed your program interactively.  REPLs went into a decline about the time BASIC lost its line numbers, but have since resurged; and most of the new languages I see have something like one.<\/p>\n<p>Anyway, in order to learn Clojure properly, you need a REPL so that you can experiment and see how the language works.  The easiest way is just to download the Clojure \u201c.jar\u201d file, and use Java to execute it.  For example, I can go the Terminal app on my Mac, switch to a folder that contains the Clojure \u201c.jar\u201d file, and type this at the command line:<\/p>\n<pre>\r\n% <b>java -cp clojure.jar clojure.main<\/b>\r\nClojure 1.6.0\r\nuser=&gt; <b>(+ 1 1)<\/b>\r\n2\r\nuser=&gt;\r\n<\/pre>\n<p>It\u2019s a perfectly good REPL; except that it\u2019s perfectly unusable to anyone used to using this kind of terminal interface.  Almost every program that provides a command prompt these days has some variant of what\u2019s usually called \u201creadline\u201d support: you can use the Left and Right arrow keys to edit the line you\u2019re on, and you can use the Up arrow key to recall previously entered commands.  As a programmer, I live at the command line, and my muscle memory expects those things to just work.  In this REPL they don\u2019t.  Instead, you get funny control characters which do nothing good for your code.<\/p>\n<p>Consequently, I needed something better.<\/p>\n<p>The first program I tried is the aptly named <a href=\"http:\/\/www.lighttable.com\" class=\" decorated-link\" target=\"_blank\" rel=\"nofollow\">Light Table<\/a>.  Light Table is an attempt to completely rethink the traditional programmer\u2019s IDE, giving instant and immediate feedback about the state of the programmer\u2019s application even as he\u2019s coding it.  Light Table is written in a variant of Clojure called ClojureScript, and has built-in support for Clojure editing; it also has a built-in \u201cInstaREPL\u201d.  It runs on Mac and Windows and Linux.  So I downloaded it and gave it a try.<\/p>\n<p>It\u2019s\u2026interesting.  Most programmer\u2019s editor\u2019s these days do something called syntax coloring, to make the syntax of the language stand out, and Light Table does it a little differently than most:<\/p>\n<p><a href=\"https:\/\/wp-media.patheos.com\/blogs\/sites\/384\/2014\/06\/LightTableSyntax.png\" class=\" decorated-link\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/wp-media.patheos.com\/blogs\/sites\/384\/2014\/06\/LightTableSyntax.png\" alt=\"\" title=\"LightTableSyntax\" width=\"504\" height=\"113\" class=\"aligncenter size-full wp-image-2243\"><\/a> <\/p>\n<p>LISP by its nature has lots and lots of parentheses; Clojure has fewer, but makes up for it by having many more brackets and braces.  And they all have to come in nested pairs, which can get confusing.  If you look at the screen shot just above, notice that the parens, brackets and braces are colored based on how deeply they are nested.  This is very cool, and is Light Table\u2019s best feature in my view.<\/p>\n<p>The InstaREPL, on the other hand, is not so good.  It tries hard, mind you.  Here\u2019s what it looks like:<\/p>\n<p><a href=\"https:\/\/wp-media.patheos.com\/blogs\/sites\/384\/2014\/06\/InstaREPL.png\" class=\" decorated-link\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/wp-media.patheos.com\/blogs\/sites\/384\/2014\/06\/InstaREPL.png\" alt=\"\" title=\"InstaREPL\" width=\"394\" height=\"96\" class=\"aligncenter size-full wp-image-2245\"><\/a><\/p>\n<p>It isn\u2019t like a normal REPL, where the user and the language take turns in a kind of dialog.  As soon as you start typing, Clojure is trying to make sense of it.  And when it makes sense, it shows the result to the right of what you were typing.  Above, for example, you see \u201c4\u201d to the right of \u201c(square 2)\u201d, which makes sense.  On the line above, you see \u201c2 2 2\u201d, which appears to be the value of variable \u201cx\u201d each time it appears in the definition of \u201csquare\u201d, for the last thing you entered.  This is the \u201clight\u201d in \u201cLight Table\u201d: you can immediately see what your code is doing.<\/p>\n<p>I wanted to like Light Table a whole lot.  But there\u2019s something about how the InstaREPL works that confuses me.  Every time I\u2019ve tried to use it, I\u2019ve somehow ended up confusing it, or me, or both, such that the code I\u2019m typing in doesn\u2019t work when it should.  I spent forty-five minutes trying to figure out why something I was trying wasn\u2019t working, and assuming that it was all my fault as a clueless newbie.  Turned out my code was perfectly good; the InstaREPL was mis-interpreting it.  It\u2019s still my fault, mind you: there\u2019s something about the InstaREPL\u2019s behavior that I\u2019m not understanding that\u2019s leading me astray.  But after a couple of wasted programming sessions, I decided I needed to find something more traditional. (Let me be clear: Light Table is an interesting tool, and it\u2019s going to remain on my radar for the time being.  Your mileage may vary.)<\/p>\n<p><i>To Be Continued!  Why?  Because it interests me, even if it interests no one else!<\/i> <\/p>\n<\/body><\/html>\n","protected":false},"excerpt":{"rendered":"<p>As I wrote on Saturday, I\u2019m learning to program in Clojure; and being a tool user at heart I immediately went looking for the right tools for the job. Here\u2019s what I wanted: A REPL at which to experiment with Clojure code, with good command-line editing and command history. An editor in which to edit [&hellip;]<\/p>\n","protected":false},"author":1131,"featured_media":2243,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[74],"tags":[427,439],"class_list":["post-2236","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-woof-guide-to-technology","tag-clojure","tag-light-table"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Tools for Learning Clojure<\/title>\n<meta name=\"description\" content=\"As I wrote on Saturday, I&#039;m learning to program in Clojure; and being a tool user at heart I immediately went looking for the right tools for the job.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.patheos.com\/blogs\/crywoof\/2014\/06\/tools-for-learning-clojure\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Tools for Learning Clojure\" \/>\n<meta property=\"og:description\" content=\"As I wrote on Saturday, I&#039;m learning to program in Clojure; and being a tool user at heart I immediately went looking for the right tools for the job.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.patheos.com\/blogs\/crywoof\/2014\/06\/tools-for-learning-clojure\/\" \/>\n<meta property=\"og:site_name\" content=\"Cry &#039;Woof&#039;\" \/>\n<meta property=\"article:published_time\" content=\"2014-06-04T08:25:06+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2014-06-06T00:58:31+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/wp-media.patheos.com\/blogs\/sites\/384\/2014\/06\/LightTableSyntax.png\" \/>\n\t<meta property=\"og:image:width\" content=\"504\" \/>\n\t<meta property=\"og:image:height\" content=\"113\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"willduquette\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"willduquette\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.patheos.com\/blogs\/crywoof\/2014\/06\/tools-for-learning-clojure\/\",\"url\":\"https:\/\/www.patheos.com\/blogs\/crywoof\/2014\/06\/tools-for-learning-clojure\/\",\"name\":\"Tools for Learning Clojure\",\"isPartOf\":{\"@id\":\"https:\/\/www.patheos.com\/blogs\/crywoof\/#website\"},\"datePublished\":\"2014-06-04T08:25:06+00:00\",\"dateModified\":\"2014-06-06T00:58:31+00:00\",\"author\":{\"@id\":\"https:\/\/www.patheos.com\/blogs\/crywoof\/#\/schema\/person\/ff6351804d01f835d127aa686467fa2c\"},\"description\":\"As I wrote on Saturday, I'm learning to program in Clojure; and being a tool user at heart I immediately went looking for the right tools for the job.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.patheos.com\/blogs\/crywoof\/2014\/06\/tools-for-learning-clojure\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.patheos.com\/blogs\/crywoof\/2014\/06\/tools-for-learning-clojure\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.patheos.com\/blogs\/crywoof\/2014\/06\/tools-for-learning-clojure\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.patheos.com\/blogs\/crywoof\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Tools for Learning Clojure\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.patheos.com\/blogs\/crywoof\/#website\",\"url\":\"https:\/\/www.patheos.com\/blogs\/crywoof\/\",\"name\":\"Cry &#039;Woof&#039;\",\"description\":\"And let slip the dogs of whimsy!\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.patheos.com\/blogs\/crywoof\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.patheos.com\/blogs\/crywoof\/#\/schema\/person\/ff6351804d01f835d127aa686467fa2c\",\"name\":\"willduquette\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.patheos.com\/blogs\/crywoof\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/8075b1526bb772efdba031f0e814158b?s=96&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/8075b1526bb772efdba031f0e814158b?s=96&r=g\",\"caption\":\"willduquette\"},\"url\":\"https:\/\/www.patheos.com\/blogs\/crywoof\/author\/willduquette\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Tools for Learning Clojure","description":"As I wrote on Saturday, I'm learning to program in Clojure; and being a tool user at heart I immediately went looking for the right tools for the job.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.patheos.com\/blogs\/crywoof\/2014\/06\/tools-for-learning-clojure\/","og_locale":"en_US","og_type":"article","og_title":"Tools for Learning Clojure","og_description":"As I wrote on Saturday, I'm learning to program in Clojure; and being a tool user at heart I immediately went looking for the right tools for the job.","og_url":"https:\/\/www.patheos.com\/blogs\/crywoof\/2014\/06\/tools-for-learning-clojure\/","og_site_name":"Cry &#039;Woof&#039;","article_published_time":"2014-06-04T08:25:06+00:00","article_modified_time":"2014-06-06T00:58:31+00:00","og_image":[{"width":"504","height":"113","url":"https:\/\/wp-media.patheos.com\/blogs\/sites\/384\/2014\/06\/LightTableSyntax.png","type":"image\/png"}],"author":"willduquette","twitter_card":"summary_large_image","twitter_misc":{"Written by":"willduquette","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.patheos.com\/blogs\/crywoof\/2014\/06\/tools-for-learning-clojure\/","url":"https:\/\/www.patheos.com\/blogs\/crywoof\/2014\/06\/tools-for-learning-clojure\/","name":"Tools for Learning Clojure","isPartOf":{"@id":"https:\/\/www.patheos.com\/blogs\/crywoof\/#website"},"datePublished":"2014-06-04T08:25:06+00:00","dateModified":"2014-06-06T00:58:31+00:00","author":{"@id":"https:\/\/www.patheos.com\/blogs\/crywoof\/#\/schema\/person\/ff6351804d01f835d127aa686467fa2c"},"description":"As I wrote on Saturday, I'm learning to program in Clojure; and being a tool user at heart I immediately went looking for the right tools for the job.","breadcrumb":{"@id":"https:\/\/www.patheos.com\/blogs\/crywoof\/2014\/06\/tools-for-learning-clojure\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.patheos.com\/blogs\/crywoof\/2014\/06\/tools-for-learning-clojure\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.patheos.com\/blogs\/crywoof\/2014\/06\/tools-for-learning-clojure\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.patheos.com\/blogs\/crywoof\/"},{"@type":"ListItem","position":2,"name":"Tools for Learning Clojure"}]},{"@type":"WebSite","@id":"https:\/\/www.patheos.com\/blogs\/crywoof\/#website","url":"https:\/\/www.patheos.com\/blogs\/crywoof\/","name":"Cry &#039;Woof&#039;","description":"And let slip the dogs of whimsy!","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.patheos.com\/blogs\/crywoof\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.patheos.com\/blogs\/crywoof\/#\/schema\/person\/ff6351804d01f835d127aa686467fa2c","name":"willduquette","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.patheos.com\/blogs\/crywoof\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/8075b1526bb772efdba031f0e814158b?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/8075b1526bb772efdba031f0e814158b?s=96&r=g","caption":"willduquette"},"url":"https:\/\/www.patheos.com\/blogs\/crywoof\/author\/willduquette\/"}]}},"_links":{"self":[{"href":"https:\/\/www.patheos.com\/blogs\/crywoof\/wp-json\/wp\/v2\/posts\/2236","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.patheos.com\/blogs\/crywoof\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.patheos.com\/blogs\/crywoof\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.patheos.com\/blogs\/crywoof\/wp-json\/wp\/v2\/users\/1131"}],"replies":[{"embeddable":true,"href":"https:\/\/www.patheos.com\/blogs\/crywoof\/wp-json\/wp\/v2\/comments?post=2236"}],"version-history":[{"count":0,"href":"https:\/\/www.patheos.com\/blogs\/crywoof\/wp-json\/wp\/v2\/posts\/2236\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.patheos.com\/blogs\/crywoof\/wp-json\/wp\/v2\/media\/2243"}],"wp:attachment":[{"href":"https:\/\/www.patheos.com\/blogs\/crywoof\/wp-json\/wp\/v2\/media?parent=2236"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.patheos.com\/blogs\/crywoof\/wp-json\/wp\/v2\/categories?post=2236"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.patheos.com\/blogs\/crywoof\/wp-json\/wp\/v2\/tags?post=2236"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}