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
Thanks!
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?
Structure and Interpretation of Computer Programs could help in general
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)
is there a way to control the text color with timbre
console logging?
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
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/)
...if you are doing web stuff
Thanks that’s already great stuff. I don’t mind opinionated as a starting base 🙂
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 😅
what are people using for websockets with ring/jetty these days?
Clojure Applied is a good book too
Just realised that I bought that one, but never read it 😄
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:
I just Ctrl+Alt+L in Cursive so the answer is... no?
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.
At the detriment of my productivity at times 🙂
> 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 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
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)
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
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.
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 think this question is a good fit for #find-my-lib even though you ask for Java
@huxley lanterna
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
I know, I've used it, I think we've even talked about it before
Hah my apologies, couldn’t resist when I saw the subject come up 😛
Did it work ok for your needs or did you run into issues?
there is the same problem with jexer, it mimics courses and tries to replace the traditional GUI with overlapping windows and other horrible things.
It's great, but today we have graalvm and I would rather stay with native binaries and get away from nodejs
No merge, just diff, but maybe relevant: https://fazzone.github.io/autochrome.html
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.
Interesting. Do you happen to know why?
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
It seems like that changed as the examples indicate a Box with Boxes in them
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
Also of note, you can use graalvm to build from js as well as java.
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
thanks! Looks like it's working, I already know what I'm doing tomorrow : >
I haven't tried to use graalvm to compile js yet, but there is another fundamental problem. imho clojure > clojurescript.
I know what project you're talking about, I'll find the link
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 checked all my starred repos on github because I was sure I gave it one, but no.
I just updated the example project that uses lanterna, https://github.com/phronmophobic/terminal-todo-mvc.
thanks!, looks awesome
Somehow I forgot that it can render ui in terminal
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
❤️
When you finish, share your results, I'd love to see
yes, that one!
@smith.adriane is that still based on lanterna 2?
fyi https://clojurians.slack.com/archives/C03S1KBA2/p1618430380033200
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
oh you are using lanterna directly, not clojure-lanterna. nice
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
Yes, take a look at Babashka https://github.com/babashka/babashka
@brennan.holten thank you. this helps a lot.
just tried it, it works, awesome @brennan.holten
We have non-devs who access the codebase, so it all gets the zprint pre-commit hammer