clojure

New to Clojure? Try the #beginners channel. Official docs: https://clojure.org/ Searchable message archives: https://clojurians-log.clojureverse.org/
2021-04-14T01:39:25.010Z

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?

thheller 2021-04-14T06:19:44.010900Z

circleci has a bunch of images for clojure related things: https://github.com/CircleCI-Public/circleci-dockerfiles/tree/master/clojure/images

2021-04-14T19:55:33.030800Z

Thanks!

Jakob Durstberger 2021-04-14T08:36:15.013300Z

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?

2021-04-14T08:40:43.013400Z

Structure and Interpretation of Computer Programs could help in general

👍 2
jacekschae 2021-04-14T08:49:04.013600Z

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)

👍 3
restenb 2021-04-14T08:50:22.014300Z

is there a way to control the text color with timbre console logging?

2021-04-14T08:53:24.014600Z

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

nilern 2021-04-14T08:53:30.014800Z

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.

👍 1
nilern 2021-04-14T08:55:53.015200Z

In specific cases like Ring/Reitit/Re-frame middleware/interceptors are quite prominent for cross-cutting concerns

nilern 2021-04-14T08:58:14.015700Z

https://pragprog.com/titles/dswdcloj3/web-development-with-clojure-third-edition/ is helpful although quite opionated (the author also made https://luminusweb.com/)

nilern 2021-04-14T08:58:45.016Z

...if you are doing web stuff

Jakob Durstberger 2021-04-14T08:58:52.016200Z

Thanks that’s already great stuff. I don’t mind opinionated as a starting base 🙂

Jakub Holý 2021-04-14T09:48:51.016800Z

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

Jakob Durstberger 2021-04-14T09:51:01.017200Z

Ah thank you for those links. These might be actually very close to what I have been looking for recently 😄

❤️ 1
nilern 2021-04-14T09:56:50.017400Z

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 😅

4
restenb 2021-04-14T11:09:48.018300Z

what are people using for websockets with ring/jetty these days?

ghadi 2021-04-14T11:13:26.018800Z

Clojure Applied is a good book too

Jakob Durstberger 2021-04-14T11:23:42.019Z

Just realised that I bought that one, but never read it 😄

NoahTheDuke 2021-04-14T13:19:27.019900Z

I love Sente

danielglauser 2021-04-14T14:45:54.020100Z

This is working well for us in production: https://github.com/sunng87/ring-jetty9-adapter

danielglauser 2021-04-14T14:50:21.020400Z

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.

cjsauer 2021-04-14T16:50:48.023300Z

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:

nilern 2021-04-14T16:52:11.023400Z

I just Ctrl+Alt+L in Cursive so the answer is... no?

👍 2
dpsutton 2021-04-14T16:53:09.023600Z

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

cjsauer 2021-04-14T16:53:19.023800Z

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.

cjsauer 2021-04-14T16:53:36.024Z

At the detriment of my productivity at times 🙂

pavlosmelissinos 2021-04-14T17:11:46.024400Z

> some think this is useless diff -bhttps://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

🤯 1
Ed 2021-04-14T17:12:29.024600Z

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

Lyderic Dutillieux 2021-04-14T17:23:44.027800Z

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.

👍 1
nilern 2021-04-14T17:29:16.028Z

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

1
nilern 2021-04-14T17:30:42.028200Z

I think Cursive does a little bit of this already but that is not ideal for everybody

👀 1
2021-04-14T17:35:26.028400Z

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)

💯 1
Lyderic Dutillieux 2021-04-14T17:35:53.028600Z

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.

Lyderic Dutillieux 2021-04-14T17:38:36.029Z

That's definitely worth digging, thanks for the pointers

cjsauer 2021-04-14T18:11:09.029500Z

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.

cjsauer 2021-04-14T18:13:04.029700Z

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.

2021-04-14T19:55:41.031100Z

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

Jakub Holý 2021-04-16T07:29:12.152800Z

I think this question is a good fit for #find-my-lib even though you ask for Java

borkdude 2021-04-14T19:58:00.031600Z

@huxley lanterna

seancorfield 2021-04-14T19:58:09.032Z

https://docs.stevelosh.com/clojure-lanterna/terminals/

blak3mill3r 2021-04-14T19:59:33.033Z

https://github.com/theophilusx/tui which is ~4yrs old

borkdude 2021-04-14T19:59:40.033200Z

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

👍 1
❤️ 1
2021-04-14T20:01:21.034300Z

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

blak3mill3r 2021-04-14T20:01:37.034500Z

https://gitlab.com/klamonte/jexer

blak3mill3r 2021-04-14T20:01:51.034900Z

another Java API

2021-04-14T20:02:06.035Z

I know, I've used it, I think we've even talked about it before

2021-04-14T20:03:32.035300Z

Hah my apologies, couldn’t resist when I saw the subject come up 😛

2021-04-14T20:03:59.035600Z

Did it work ok for your needs or did you run into issues?

2021-04-14T20:04:07.035900Z

there is the same problem with jexer, it mimics courses and tries to replace the traditional GUI with overlapping windows and other horrible things.

2021-04-14T20:05:00.036100Z

It's great, but today we have graalvm and I would rather stay with native binaries and get away from nodejs

flowthing 2021-04-14T20:05:39.037100Z

No merge, just diff, but maybe relevant: https://fazzone.github.io/autochrome.html

🙌 1
2021-04-14T20:09:21.037300Z

Another even simpler solution is to use https://github.com/vadimdemedes/ink

2021-04-14T20:10:21.037600Z

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.

2021-04-14T20:12:08.037800Z

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.

2021-04-14T20:13:09.038Z

Interesting. Do you happen to know why?

2021-04-14T20:13:45.038200Z

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.

2021-04-14T20:14:44.038400Z

If nothing has changed, INK does not have the ability to place other components in squares

2021-04-14T20:15:50.038600Z

there were only buttons that could have text inside and trying to put something more complex in there ruined everything

2021-04-14T20:16:41.038800Z

It seems like that changed as the examples indicate a Box with Boxes in them

2021-04-14T20:17:19.039400Z

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

2021-04-14T20:19:23.039600Z

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

2021-04-14T20:26:50.040200Z

Also of note, you can use graalvm to build from js as well as java.

borkdude 2021-04-14T20:27:11.040500Z

there is also https://github.com/lambdaisland/trikl which is not actively worked on

borkdude 2021-04-14T20:27:59.041500Z

and there was also this project which abstracted UI for browsers, tui, etc. forgot the name, it looked really ambitious

2021-04-14T20:28:25.041600Z

thanks! Looks like it's working, I already know what I'm doing tomorrow : >

2021-04-14T20:29:16.041800Z

I haven't tried to use graalvm to compile js yet, but there is another fundamental problem. imho clojure > clojurescript.

2021-04-14T20:30:27.042100Z

I know what project you're talking about, I'll find the link

2021-04-14T20:34:43.042600Z

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

2021-04-14T20:42:01.044Z

I checked all my starred repos on github because I was sure I gave it one, but no.

phronmophobic 2021-04-14T20:46:47.045200Z

I just updated the example project that uses lanterna, https://github.com/phronmophobic/terminal-todo-mvc.

❤️ 1
2021-04-14T20:47:48.045500Z

thanks!, looks awesome

2021-04-14T20:48:20.045800Z

Somehow I forgot that it can render ui in terminal

phronmophobic 2021-04-14T20:49:25.046800Z

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

2021-04-14T20:51:13.047200Z

❤️

2021-04-14T20:52:01.047300Z

When you finish, share your results, I'd love to see

borkdude 2021-04-14T20:54:51.047600Z

yes, that one!

borkdude 2021-04-14T20:55:17.047900Z

@smith.adriane is that still based on lanterna 2?

phronmophobic 2021-04-14T20:56:47.048300Z

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

borkdude 2021-04-14T20:57:09.048500Z

oh you are using lanterna directly, not clojure-lanterna. nice

👍 1
phronmophobic 2021-04-14T20:58:23.048800Z

I don't use any of the built in widgets, I just use lanterna for the raw graphics and events

hipster coder 2021-04-14T23:34:26.049700Z

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 ?

hipster coder 2021-04-14T23:34:47.050200Z

that way I can use Clojure to write all of my command line scripting, dev ops, on linux

hipster coder 2021-04-14T23:35:23.050900Z

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 2021-04-14T23:36:12.051600Z

Yes, take a look at Babashka https://github.com/babashka/babashka

👍 1
hipster coder 2021-04-14T23:37:05.052300Z

@brennan.holten thank you. this helps a lot.

hipster coder 2021-04-14T23:47:05.052600Z

just tried it, it works, awesome @brennan.holten

🙌 3
hipster coder 2021-04-14T23:48:01.052800Z

lsenjov 2021-04-14T23:48:33.052900Z

We have non-devs who access the codebase, so it all gets the zprint pre-commit hammer