Hi folks

In the last ten years or so, source code formatters with limited/no
configuration have become popular. Go is the most well-known example,
shipping with gofmt, but there are similar tools in Rust, JavaScript,
Python, and Elixir.

Clojure and Lisps, in general, have historically allowed very flexible
formatting of s-expressions. This can aid readability but adds a cognitive
overhead for readers used to different styles. It can also be challenging
to match existing source code formatting if you are using a different
editor to the original author.

*I believe it would be useful for the Clojure community to be able to
develop (or adopt) a single source-code formatter which is able to format
Clojure source code to a canonical format.* It seems unlikely that 100%
(maybe not even 50%) of the community would want such a tool, but I feel
like there is enough desire for a common formatting tool that this could
still be valuable.

I've created a discussion thread
<https://clojureverse.org/t/clj-commons-building-a-formatter-like-gofmt-for-clojure/3240>
on ClojureVerse about building a Clojure/ClojureScript source code
formatter as part of CLJ Commons <https://clj-commons.org/>. There are a
few differences in goals between this tool and the existing ones that
exist. I go into more detail in the thread, but I'm proposing the creation
of

* A fairly canonical format for Clojure code, e.g. reindenting code,
reformatting namespace declarations. A format that has idiomatic opinions.
* A formatting spec and test suite that multiple different tools and
editors can implement, not a spec defined by the implementation of a single
tool.
* The creation of a reference implementation formatter.
* A formatter with few (maybe zero?) options

It's possible that 10 years after Clojure's creation, it's going to be too
difficult for the community to coalesce around a canonical format, and it
will be necessary to add some configuration options. I'm not really sure,
which is why I'm asking for community members to join in the discussion.

I realise that I'm touching the third rail
<https://en.wikipedia.org/wiki/Third_rail_of_politics> here, and lots of
people have strong opinions about formatting. I don't expect that everyone
would like or want to adopt such a strict formatting tool, and that's
totally ok! For those of you that *do* like the idea of building/having
such a tool, please jump in on the discussion on ClojureVerse, and on a
GitHub repo discussing the different aspects of formatting at
https://github.com/clj-commons/formatter.

Thanks, Daniel.

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at https://groups.google.com/group/clojurescript.

Reply via email to