This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-04-14
Channels
- # babashka (53)
- # beginners (158)
- # calva (25)
- # cider (21)
- # clara (1)
- # clj-kondo (12)
- # cljsrn (6)
- # clojure (94)
- # clojure-australia (2)
- # clojure-bay-area (6)
- # clojure-europe (40)
- # clojure-nl (10)
- # clojure-spec (16)
- # clojure-uk (18)
- # clojurescript (95)
- # cursive (14)
- # data-science (1)
- # datascript (6)
- # datomic (18)
- # depstar (2)
- # duct (36)
- # emacs (15)
- # events (4)
- # fulcro (16)
- # graalvm (10)
- # helix (25)
- # honeysql (6)
- # jackdaw (4)
- # jobs (2)
- # leiningen (24)
- # lsp (4)
- # malli (10)
- # off-topic (3)
- # pathom (3)
- # polylith (19)
- # practicalli (4)
- # prelude (1)
- # re-frame (6)
- # reagent (13)
- # reitit (3)
- # remote-jobs (10)
- # ring (12)
- # ring-swagger (2)
- # shadow-cljs (54)
- # testing (17)
- # tools-deps (10)
- # xtdb (14)
If my memory serves, there were some docker images for using open-jdk + node I think, which I am looking to use for a shadow-cljs project. Anyone recall a solid docker image like that?
circleci has a bunch of images for clojure related things: https://github.com/CircleCI-Public/circleci-dockerfiles/tree/master/clojure/images
Hello, I have been learning Clojure for a while now and feel quite comfortable building smaller things. Something I struggle with is how to organise and architect in a functional language. I come from OO so that way of thinking is really engrained in me, are there any good books or talks on how to architect Clojure programs?
Probably Clojure Applied is something that you might want to take a look at - https://a.co/1HL2XPF (link from https://clojure.org/community/books)
Namespace-wise it's not really that different from a procedural language (e.g. plain C). For stateful components dependency injection is still good e.g. https://github.com/weavejester/integrant. And you won't run into Haskell-style "stacking monads" organization challenges.
In specific cases like Ring/Reitit/Re-frame middleware/interceptors are quite prominent for cross-cutting concerns
https://pragprog.com/titles/dswdcloj3/web-development-with-clojure-third-edition/ is helpful although quite opionated (the author also made https://luminusweb.com/)
Thanks that’s already great stuff. I don’t mind opinionated as a starting base 🙂
Just realised that I bought that one, but never read it 😄
I'm a big fan of the book Elements of Clojure https://elementsofclojure.com/ and it's precisely about how to architect clojure programs (you'd need another book like Clojure Applied for learning the language itself)
https://github.com/trhura/clojure-term-colors
you can use that library in combination with timbre’s option :fmt-output-fn
to format desired string
A thought I want to share. I am reading the awesome https://mitpress.mit.edu/books/software-design-flexibility book and came upon these there: > [..] families of parts that are built around a standardized interface specification can be mixed and matched to make a great variety of systems. > [..] be liberal in what you accept from others [i.e. accept a wider range of inputs than strictly necessary] and it hit me that JavaScript (when applying https://www.manning.com/books/data-oriented-programming?a_aid=viebel&a_bid=d5b546b7) and Clojure can be seen as languages designed for flexibility according to these: • representing information using the general data structures (maps, arrays) creates such a standardized interface - you can plug in any data-processing library into your pipeline (for instance I've used a data diffing lib to verify that refactoring produces the same results as the old code) - that is impossible with OOP and its unique-for-use-case types (without reflection black magic) • best practice in Clojure, equally possible in JS, is that you only check inputs for the presence of what you require but allow any additional data in there, i.e. being liberal about inputs; thus somebody upstream can start sending additional data to somebody downstream w/o affecting all functions in between
Ah thank you for those links. These might be actually very close to what I have been looking for recently 😄
In Haskell you get a similar data interface with lenses etc. and any number of lenses can be added for any type at any time! But the learning curve is vim-tastic 😅
I love Sente
This is working well for us in production: https://github.com/sunng87/ring-jetty9-adapter
We have about 50 lines of code in a ns
that implements on-connect
, on-close
, on-error
, on-pong
with a little additional ceremony.
How much time do you find you spend making clojure code “look good”, visually speaking? I really enjoy designing the code, artistically. Forming it into tables, aligning things, checking rhythms and flows… :male-artist:
sometimes you have to manually do it, aligning vectors, match clauses, etc. Teams can be quite strongly attached to alignment as well. Some like maps to be aligned, some think this is useless diff and invites needless conflicts on rebase/merge etc
Haha, yea I use the auto align/format tools a ton for macro layout, but sometimes I’ll go in and tweak subtle things to polish it.
> some think this is useless diff
-b
https://git-scm.com/docs/git-diff#Documentation/git-diff.txt--b`-w`https://git-scm.com/docs/git-diff#Documentation/git-diff.txt--b, so I don't share the sentiment!
From the git manual:
> -b
> --ignore-space-change
> Ignore changes in amount of whitespace. This ignores whitespace at line end, and considers all other sequences of one or more whitespace characters to be equivalent.
>
> -w
> --ignore-all-space
> Ignore whitespace when comparing lines. This ignores differences even if one line has whitespace where the other line has none.
magit has opt-in flags for both, see screenshot, not sure about other editors
I use align-regex
in emacs reasonably often to tidy up the vertical alignment of thing that cider doesn't do with C-c SPACE
... it doesn't suck up much time... and I've had bad experiences with all the code formatting tools that I've used ... but I like whitespace changes to generally be their own commit, so they can be dealt with independently and say that they're introducing no functional changes
I’ve been liking calva’s alignCurrentForm
for vertical alignment. There’s something deeply satisfying about table-like data. I think it’s well worth its costs.
Daniel Gregoire had a https://www.youtube.com/watch?v=b5UK-VHbJlQ&list=PLZdCLR02grLpMkEBXT22FTaJYxB92i3V3&index=20 about tables and their use in code at Conj 2018.
We have non-devs who access the codebase, so it all gets the zprint pre-commit hammer
I stumbled upon "Code aware merges" or "Semantic Merges" like this one for C# : https://semanticmerge.com/ I'm wondering if such a technology exists for Clojure ? What could possibly prevent us from making a "sexp/clojure aware merge algorithm" ? That would be very convenient.
Nothing except lack of trying 🙂 There are lots of data diffing and patching libs for Clojure already, maybe there would be some challenges combining that with rewrite-clj but maybe not
I think Cursive does a little bit of this already but that is not ideal for everybody
Just to illustrate some use case : Let's say I have a function
1. (defn compute [arg1 arg2] ...)
and a first contributor adds a commit that call the function
1. (defn compute [arg1 arg2] ...)
...
5. (compute 1 2)
...
and a second contributor renames and calls the function
1. (defn multiply-by [arg1 arg2] ...)
...
18. (multiply-by 3 4)
Then in this case, the classical git merge will merge successfully and keep the 5th line with compute
whereas a code aware merge/helper would at worst issue a conflict without any suggestion, and at best suggesting to replace
compute by multiply-by
.That's definitely worth digging, thanks for the pointers
No merge, just diff, but maybe relevant: https://fazzone.github.io/autochrome.html
the question doesn't really fit anywhere, but it probably fits best here anyway does java have any libraries for creating TUIs? Something like rs-tui from rust or termui from golang? https://github.com/fdehau/tui-rs https://github.com/gizak/termui
I know this isn’t 100% what you asked for but https://github.com/eccentric-j/cljs-tui-template might be another option 😅
It's great, but today we have graalvm and I would rather stay with native binaries and get away from nodejs
Another even simpler solution is to use https://github.com/vadimdemedes/ink
That’s adjacent to what the template uses, though that reminds me to try it out and see if it would be better than blessed + react bindings.
A lot depends on how complex a UI you intend to make. INK is not particularly suitable for displaying large amounts of content as on some dashboards.
but for me it worked great where the user simply had to select one of many things to choose from to trigger some application action.
If nothing has changed, INK does not have the ability to place other components in squares
there were only buttons that could have text inside and trying to put something more complex in there ruined everything
I'm not a native speaker, by saying box I don't mean a <box> component but creating borders and dividing the view into smaller elements with clear edges
However, I see now that it seems to have changed a bit over the last year when I last checked. I'll check right now to see if it's possible to make a nested box
I haven't tried to use graalvm to compile js yet, but there is another fundamental problem. imho clojure > clojurescript.
Depends on the trade-offs for a given problem space in my experience. May try switching the cljs-tui template to ink this week though as it seems better maintained
I think this question is a good fit for #find-my-lib even though you ask for Java
I know this isn’t 100% what you asked for but https://github.com/eccentric-j/cljs-tui-template might be another option 😅
https://github.com/theophilusx/tui which is ~4yrs old
lanterna also has some clojure wrappers. but it's still based on version 2 afaik. I made a start with upgrading to version 3 here: https://github.com/babashka/clojure-lanterna
I was just about to write that there is a lantern, but curses are not exactly what anyone would want to use today 😉 it is traditionally ugly
another Java API
there is the same problem with jexer, it mimics courses and tries to replace the traditional GUI with overlapping windows and other horrible things.
there is also https://github.com/lambdaisland/trikl which is not actively worked on
and there was also this project which abstracted UI for browsers, tui, etc. forgot the name, it looked really ambitious
I just updated the example project that uses lanterna, https://github.com/phronmophobic/terminal-todo-mvc.
The lanterna backend has less use than some of the others so don't hesitate to ping me if you run into any issues or have questions
@smith.adriane is that still based on lanterna 2?
I'm not sure it was ever based on lanterna 2. The dependency was 3.0.2 and I just updated it to 3.1.1
I don't use any of the built in widgets, I just use lanterna for the raw graphics and events
is there a way to turn a clojure exe (jar) into a command line script... so I don't have to call it with java jar ?
that way I can use Clojure to write all of my command line scripting, dev ops, on linux
very specific example is.... git custom commands... it doesn't care what the script is written in... just needs to be executable ./script-name
@brennan.holten thank you. this helps a lot.