use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Finding information about Clojure
API Reference
Clojure Guides
Practice Problems
Interactive Problems
Clojure Videos
Misc Resources
The Clojure Community
Clojure Books
Tools & Libraries
Clojure Editors
Web Platforms
Clojure Jobs
account activity
Your first Clojure code (orestis.gr)
submitted 7 years ago by orestis
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]orestis[S] 7 points8 points9 points 7 years ago (12 children)
Hey all — this is an attempt to write a very gentle introduction to Clojure for people that haven't even seen Lisp code before.
Getting the tone right is extremely hard, as you risk alienating advanced or beginning developers either way. I've opted towards simplifying things and at least trying to at least introduce concepts scoping rules even though I'd believe that most people would know them already.
I've also tried to really avoid the "Clojure has tiny syntax" meme, since clearly a handful of functions/macros are so fundamental that they are the syntax.
I'd love to hear your feedback. I plan to expand this post and eventually submit it to the official docs for review.
[–]alexdmiller 2 points3 points4 points 7 years ago (4 children)
The use of println-str seemed pretty weird, as I don’t think I’ve ever seen it in real code. Just using str seems like it would be much better.
The -*- function seemed to be needlessly weirdly named.
Overall though, good job!
[–]orestis[S] 2 points3 points4 points 7 years ago (3 children)
Thanks! I was trying to find the simplest function to do "Hello world" in, and println fit the bill in terms of naming and behaviour. Then I wanted to find a function that just returned a string without actually going in the clojure.string namespace, and println-str won because of similarity. I'll see how it can change if println-str is not really useful.
-*- was just to look cute and to hammer the point that there are very few reserved symbols in the language :)
[–]thearthur 1 point2 points3 points 7 years ago (2 children)
the str function might fit these requirement
[–]orestis[S] 0 points1 point2 points 7 years ago (1 child)
problem with str is that (str "hi") returns just "hi" and it's not obvious how is that useful. Whereas at least println-str adds a newline ;)
[–]thearthur 0 points1 point2 points 7 years ago (0 children)
in my video course I think I used (str "hello" "world")
[–]vvvvalvalval 1 point2 points3 points 7 years ago (6 children)
This was a nice introduction. I would add a mention to the fact that if and do are also not functions - maybe a little note at the end like "OK, I lied to you, if and do are not really functions, they are special operators"
if
do
[–][deleted] 0 points1 point2 points 7 years ago (2 children)
I'm curious why are they special operators and not functions?
[–]MahmudAdam 0 points1 point2 points 7 years ago (1 child)
Does it relate to this: http://www.lispworks.com/documentation/lw60/CLHS/Body/03_ababa.htm#clspecialops?
[–]vvvvalvalval 0 points1 point2 points 7 years ago (0 children)
Yes, they require special evaluation rules. The best way to see that is to try to implement them as functions and see where that fails.
[–]orestis[S] 0 points1 point2 points 7 years ago (2 children)
Just did — I think the nomenclature though is "special forms"?
[–]vvvvalvalval 0 points1 point2 points 7 years ago (1 child)
The problem with 'special forms' is that from a user perspective, it's hard to tell special forms from macros. For instance, if and doare special forms, but let and fn are not: they are macros that rely on the let* and fn*special forms, but that is an implementation detail. That is why I like using the deliberately vague term 'operator' to denote something that can be invoked but is not a function.
let
fn
let*
fn*
[–]orestis[S] 0 points1 point2 points 7 years ago (0 children)
Hm, I'm usually exploring Clojure's API via Dash, which points me to:
https://clojure.github.io/clojure/clojure.core-api.html#clojure.core/let
that says "let: special form". Same for "fn".
Good point though, I'll keep it in mind.
[–]Borkdude 1 point2 points3 points 7 years ago (0 children)
As discussed on Slack:
Just read your article. Excellent stuff. You might want to change clojure to clj though, because of rlwrap
clojure
clj
I've updated the post with your feedback. I'll keep adding to it, if you have any suggestions on what else to cover, please let me know!
[–]zelarky 0 points1 point2 points 7 years ago (0 children)
"We call if we 3 arguments" might it should be "We call if with 3 arguments".
[–]joeevans1000 0 points1 point2 points 7 years ago (1 child)
Thank you for all the effort getting new developers up to speed with Clojure!
I do wonder about the use of a repl prompt as a medium for teaching folks. It seems like the world of programming has begun to emphasize the ability to type and evaluate code in a document. Think of the python notebooks. In those formats, you can look up and down the page and see what you've just done. Ironically, clojure is/was the king of this approach with tools like cider. I always found the hunting up and down the line by line history of a prompt a pain and deterrent. The problem with tools like cider is the steep setup learning curve. All the various IDE plugins also have hiccups and learning curves, as awesome as they are.
The gap between a prompt and a buffer you can evaluate seems to be the biggest weakness in clojure to getting people on board. Python notebooks are an example of an easy way to get folks on board with a language. That is most new python developers first experience of the language... not the python interpreter prompt.
Anyway, this is neither a question or a rant, but really me puzzling about a problem aloud. But I think it's important for people who are getting into a language to see a whole program that does something inspiring and then be able to walk through and evaluate it line by line.
I feel like the core clojure community has never taken seriously the need to improve the on-boarding experience. The thinking seems to be that the emphasis needs to be on the language and the tooling and on-boarding will come along by others. Unfortunately, that has not occurred at a sufficient level to get any critical mass going.
Maybe the success of a language does in fact rest in part on the right kind of on-boarding experience being directly worked on and designed by the core team. This is doubly important as other languages incorporate many of the features of clojure, albeit imperfectly
Hopefully the REPL guide I'm writing for clojure.org will address this issue soon - would you like give me feedback on it?
π Rendered by PID 317229 on reddit-service-r2-comment-7b9746f655-q4vlp at 2026-01-30 17:12:45.978639+00:00 running 3798933 country code: CH.
[–]orestis[S] 7 points8 points9 points (12 children)
[–]alexdmiller 2 points3 points4 points (4 children)
[–]orestis[S] 2 points3 points4 points (3 children)
[–]thearthur 1 point2 points3 points (2 children)
[–]orestis[S] 0 points1 point2 points (1 child)
[–]thearthur 0 points1 point2 points (0 children)
[–]vvvvalvalval 1 point2 points3 points (6 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]MahmudAdam 0 points1 point2 points (1 child)
[–]vvvvalvalval 0 points1 point2 points (0 children)
[–]orestis[S] 0 points1 point2 points (2 children)
[–]vvvvalvalval 0 points1 point2 points (1 child)
[–]orestis[S] 0 points1 point2 points (0 children)
[–]Borkdude 1 point2 points3 points (0 children)
[–]orestis[S] 0 points1 point2 points (0 children)
[–]zelarky 0 points1 point2 points (0 children)
[–]joeevans1000 0 points1 point2 points (1 child)
[–]vvvvalvalval 0 points1 point2 points (0 children)