By this point I highly recommend actually writing some code to solidify your Clojure knowledge if you haven't started already.
While I will be among the quickest to acknowledge that there is great value to be gained by typing in example code, without structured exercises, the article might be providing a fine tutorial or feature list or cookbook, but it is not a course.
Courses look more like "Learn Python the Hard Way" than blog entries. They're hard to make and one for Clojure is sorely needed. The easy parts of Clojure are the syntax and the common idioms. That's why Lisps have a long history as introductory programming languages. The hard part is learning to apply them to the sort of hard problems that one applies other programming languages to.
All that to say, that there's nothing wrong with the article as an article. In fact I think it represents an admirable amount of work for a positive purpose. My only criticism is that it is not what it says it is, and the only reason that is a criticism is that it claims to do heavy lifting which it does not.
Clojure language crash course is meant to distinguish these aspects from the other aspects of Clojure: the environment, the artifact ecosystem, and the mindset. I mention this distinction in the introduction: http://www.braveclojure.com/
Other chapters begin to cover the mindset, or how to do things the Clojure way. "The Joy of Clojure" also covers this, from what I understand. Rich Hickey's talks are also great, of course.
There's nothing to apologize for. It's just that it isn't a crash course, or a course of any kind for any meaningful meaning of "course".
And I meant what I said about the amount of effort and thought that the article represents being worthy of praise...and what I said about there being a need for actual courses in Clojure.
It absolutely is a crash course, for the most common colloquial definition of the term "crash course," although in a very nitpicky fashion the blog entry is not a "true course of study." The reality is when people say "crash course" in common English they almost never mean a formal course of study. Usually it's used in the context of someone needing to learn something quickly in order to do something else. A professor might spend 10 minutes at the beginning of a class doing a "crash course" on binary arithmetic, because it's needed for something else that's on the lesson plan for the day. Such a crash course might have no exercises and no materials whatsoever, but nobody reasonable is going to object to the term.
The blog entry is focused, brisk, and thorough, the key elements of a course intended to be completed rapidly for a specific purpose. Does it fail to fill a learning gap that clojure needs filled? Probably. But that doesn't make it wrong to call it a crash course.
The professor covering binary arithmetic does not hear objections for several reasons. While the social context of the classroom and the explicit expert-novice relationship are among them, the analogy is undermined because teaching Clojure is not a precursor to teaching something else. In the article it is the end, itself.
Under the usage you are suggesting, "A crash course in the JVM" in the context of teaching Clojure would fit the analogy better.
Clojure has been around long enough that people have wrappers around most of the interesting common use java libs. If you're looking for something domain specific then it's usually better to find which java libs cover the domain and work from there.
Here is a talk on it: http://www.infoq.com/presentations/Clojure-Java-Interop
I confess I haven't watched that talk yet and only remembered hearing about it as I wrote this. But I imagine it is a good Launchpad.
Navigating the Java terrain is comical. Often, performing what I would consider a library's basic use-case involves the collaboration of multiple objects I never could've reverse-engineered from the API docs. Yet the library doesn't throw me a bone with any sort of `## Usage` overview.
Fortunately, it seems nobody else knows how to do trivial things with Java (or libraries like Bouncy Castle) either, so I've found it reliable to lean on google queries to find the 1,000 questions that have already been asked and answered.
The repl and window examples were just what I needed as a complete Emacs newbie. The Emacs chapter was similarly good. It seemed to be aimed at someone who wanted to start writing code quickly. This is the first time in years that I've worked through an Emacs tutorial without firing up vim to edit a config file (at which point I usually realize that I won't be switching to Emacs that day).
Thank you for taking the time to write all of this.
The api actually feels pretty similar to Python (eg rest-param ~= args) so it mapped over nicely for me. I studied functional programming some years ago and have tinkered with the like of erlang in the past so none of the concepts you presented felt too foreign.
I might be going insane but it looks like you have a typo in there - 'whether the ;; the part's name'*.
1. Install Leiningen http://leiningen.org/ you do not need to install clojure, lein will grab clojure for you.
2. `lein new playground` from the command line to create a 'playground' project
3. Open Light Table
4. ctrl-space `woto` for "Toggle Workspace tree"
5. Add the playground project folder you just created
6. cmd-o `core.clj` to open the main clojure file for the project
7. On an empty line type `(+ 1 1)` and hit cmd-enter
Things will grind away for a while as all the dependencies are downloaded and the JVM starts up. Get a cup of coffee or something. Eventually you'll see a green `2` show up.
You can then type anything in the tutorial and hit cmd-enter to evaluate it or cmd-shift-enter to evaluate the entire file. Think of the file as a shell with an editable history instead of something you'd want to commit to source control.
Documentation is searchable via ctrl-shift-d or moving your cursor on top of a function name and hitting ctrl-d. Autocomplete is available on tab, you can jump to definition with cmd-. and back with cmd-,
Additional question: I noticed how on the clojurescreencasts site the author of the videos uses InstaREPL in split screen mode. I couldn't figure out how to do that with my own installation of LT. Do you know?
1. LightTable might be better for new Clojure users who aren't yet attached to Emacs
2. You can use (some) Emacs key bindings in LightTable
/not to start an editor war/
Light Table does the integration right. You load up a clojure file, hit eval, and it works without having to mess with it. Additionally, it works well with Clojurescript, which I never really got working with Vim fireplace. The doc system is integrated, autocomplete works. The Light Table vim plugin provides decent but not great vim emulation (e.g. the b text object is missing, which is important for a lisp) and while it's not as nice for editing as my heavily customized home vim setup, I'm happier doing Clojure in LT than in Vim.
This weekend I decided to try out emacs with evil-mode and now I've switched permanently to that set up, it's the best of all worlds, you get to have all the emacs/clojure integration goodness while still having super-powerful vi keybindings and editing capabilities.
I'd recommend you give it a shot at least :)
Once I installed Evil-mode (Vim bindings), an Emacs buffer felt so similar to Vim that I was immediately productive.
From there, I could just focus on the other things like how to open a file (C-x f) and how to launch nREPL and begin evaluating code within Clojure source files.
I'm much happier now that I'm just using vim-fireplace.
This is really great writing. As an Emacs user who hasn't yet gotten very far into a lisp, I look forward to having time to sit down and really dig into this tutorial.
Thanks for creating this!
My only suggestion : it would be great to have a small reference/cheatsheet/table to convert equivalent data structures and other syntactic details from closure to other languages. I found myself scrolling back up a lot to remember what "def" meant (coming from python this was confusing), whether "vector" was a dict or a list, etc. It interrupted the reading for a few seconds every time until "ah ha!" I found it.
I remember spending about 50% of my time learning Mongo syntax just checking out their mysql <-> mongo syntax table - I assume most people checking out your tutorial will have experience with some previous form of programming (like me).
(def severity :mild)
(def error_message "OH GOD! IT'S A DISASTER! WE'RE ")
(if (= severity :mild)
(def error_message (str error_message "MILDLY INCONVENIENCED!"))
(when (= severity :terrible)
(def error_message (str error_message "DOOOOOOOMED!"))))
(def failed_protagonist_names [
"Doreen the Explorer"
"The Incredible Bulk"
(assoc failed_protagonist_names 0 "Gary Potter"))
;; => ["Gary Potter" "Doreen the Explorer" "The Incredible Bulk"]
user=> (def a [1 2 3])
user=> (def b a)
user=> (def a ["a" "b" "c"])
["a" "b" "c"]
[1 2 3]
- "Like all Lisps, it employs a uniform structure"
- "All Clojure code is written in a uniform structure"
- "Forms have a uniform structure."
- "In other languages, different operations might have different structures depending on the operator and the operands."
- "No matter what operator you're using or what kind of data you're operating on, the structure is the same."
It's pretty obvious that forms don't have a uniform structure (e.g. the structure of a number is pretty different from the structure of a vector), and that the structure depends on the operator (e.g. `def` special form vs. `or` macro).
Yes, Clojure syntax is relatively simple, no need to oversell it.
Still, that's a minor issue that doesn't detract from the overall quality and usefulness of the work.
However, all Clojure code does have the same uniform structure. It's all composed of s-expressions, which are either atoms or other s-expressions enclosed in parentheses (for lists), braces (for maps), or brackets (for vectors).
Thanks again for this feedback, having to explain this has given me some ideas for how to improve the chapter :)
I don't have much time now and I'll try to reply with more later, but macros, special forms, and functions do indeed all have the same structure of opening parenthesis, operator, operands, closing parenthesis.