Fork me on GitHub
#clojure
<
2021-04-14
>
jaide01:04:25

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?

Jakob Durstberger08:04:15

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?

delaguardo08:04:43

Structure and Interpretation of Computer Programs could help in general

👍 6
jacekschae08:04:04

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)

👍 9
nilern08:04:30

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.

👍 3
nilern08:04:53

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

nilern08:04:45

...if you are doing web stuff

Jakob Durstberger08:04:52

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

ghadi11:04:26

Clojure Applied is a good book too

Jakob Durstberger11:04:42

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

noisesmith17:04:26

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)

💯 3
restenb08:04:22

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

delaguardo08:04:24

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

Jakub Holý (HolyJak)09:04:51

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&amp;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 Durstberger09:04:01

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

❤️ 3
nilern09:04:50

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 😅

12
restenb11:04:48

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

Noah Bogart13:04:27

I love Sente

danielglauser14:04:21

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.

cjsauer16:04:48

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:

nilern16:04:11

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

👍 6
dpsutton16:04:09

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

cjsauer16:04:19

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.

cjsauer16:04:36

At the detriment of my productivity at times 🙂

pavlosmelissinos17:04:46

> 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

🤯 3
Ed17:04:29

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

cjsauer18:04:09

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.

lsenjov23:04:33

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

Lyderic Dutillieux17:04:44

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.

👍 3
nilern17:04:16

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

3
nilern17:04:42

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

👀 3
Lyderic Dutillieux17:04:53

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 Dutillieux17:04:36

That's definitely worth digging, thanks for the pointers

flowthing20:04:39

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

🙌 3
ribelo19:04:41

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

jaide19:04:06

I know this isn’t 100% what you asked for but https://github.com/eccentric-j/cljs-tui-template might be another option 😅

ribelo20:04:06

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

jaide20:04:32

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

jaide20:04:59

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

ribelo20:04:00

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

ribelo20:04:21

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

jaide20:04:21

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.

ribelo20:04:08

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.

jaide20:04:09

Interesting. Do you happen to know why?

ribelo20:04:45

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.

ribelo20:04:44

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

ribelo20:04:50

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

jaide20:04:41

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

ribelo20:04:19

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

ribelo20:04:23

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

jaide20:04:50

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

ribelo20:04:25

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

ribelo20:04:16

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

jaide20:04:43

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

ribelo20:04:01

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

Jakub Holý (HolyJak)07:04:12

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

borkdude19:04:40

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

👍 3
❤️ 3
ribelo20:04:21

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

blak3mill3r20:04:51

another Java API

ribelo20:04:07

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

borkdude20:04:11

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

borkdude20:04:59

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

ribelo20:04:27

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

ribelo20:04:01

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

phronmophobic20:04:47

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

❤️ 3
ribelo20:04:48

thanks!, looks awesome

ribelo20:04:20

Somehow I forgot that it can render ui in terminal

phronmophobic20:04:25

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

borkdude20:04:51

yes, that one!

borkdude20:04:17

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

phronmophobic20:04:47

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

borkdude20:04:09

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

👍 3
phronmophobic20:04:23

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

hipster coder23:04:26

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 coder23:04:47

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

hipster coder23:04:23

very specific example is.... git custom commands... it doesn't care what the script is written in... just needs to be executable ./script-name

bholten23:04:12

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

👍 3
hipster coder23:04:05

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

hipster coder23:04:05

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

🙌 9