Fork me on GitHub
#clojure
<
2019-10-22
>
Clypto00:10:25

so after friend, and then buddy, is there a new/actively maintained webb security library?

andy.fingerhut00:10:26

I do not know, not having used such libraries, but do friend and/or buddy still work? Some libraries in Clojure are stable and working, even if they haven't been changed in a while.

Clypto00:10:25

yeah I still have an app in production with friend

didibus04:10:53

I think one can also make use of Apache Shiro directly: https://shiro.apache.org/index.html

Arto Kalishian05:10:34

I am learning Clojure and would like to know if I am the right track from experienced developers who preceded me in their learning path. So far what I accomplished is: 1. Studying all the basics of Clojure Language from different sources like Clj for brave true.. & Quick Clojure (awesome book btw). 2. Learn all the basics of Clojurescript from a web dev ebook. 3. Tried to delve into Fulcro and studied until 3.8 but could not continue for several reasons not relative to mention here. 4. Studied Luminus framework, liking it from Web Dev 2nd edition book. But I realized that I am still not so good with Clojure basics so went back to revise before I continue. What I meant to say that my learning style is coming back and forth a lot and is very dynamic. I wonder if this is how most of you learned and if there is a more efficient way to learn through practice for example to know the best practices. Highly appreciated.

sgerguri05:10:48

I learned enough of the basics to get going, did some 4Clojure, then landed a job writing Clojure. I personally don't think there's much point in reading up too much unless you actually intend to use the language - either for a hobby project, or in production. So my suggestion would be to do just that - if you like the language, find a way to use it "in anger", the rest of the learning will follow. Books will only take you so far.

๐Ÿ‘ 4
โž• 4
gibb05:10:07

Agree with @sgerguri - Iโ€™m writing a cljs frontend for my company and just seeing how it works out.

gibb05:10:56

Learning from books is fine but I only really learn when trying to build something, preferably on a deadline..

๐Ÿ‘ 4
โž• 4
didibus06:10:20

Going through http://www.4clojure.com/ exercised can help with getting acquainted learning the basic functions, doing things like loops, conditions, manipulating data-structures etc.

didibus06:10:40

Books can help with overall application design hints. But like other said, practice makes perfect

didibus06:10:13

I think doing a lot of coming back and forth is normal and good for learning

๐Ÿ‘ 4
didibus06:10:25

I definitely did a lot of it.

Arto Kalishian08:10:41

Thank you a lot for all the advice. Really helps. I'll definitely try 4clojure and yes I have project in mind. Is there a way to work for any company over seas for free through assignments?

sgerguri09:10:40

That's one other thing I wouldn't do either. Build a project of your own, or extend something that you're using already. Better yet, find a place where you can sneak Clojure in at your current place - there's bound to be some scope for an internal miniproject where nobody will honestly care what technology you're using as it's not going to be critical for project delivery. Build support and excitement for the language, run learning groups, etc. It's a lot easier (and better in the long term) to try and build support for something you care about where you are than trying to jump through hoops to land something remote overseas.

๐Ÿ‘ 12
thheller10:10:25

quick questions about clojure.datafy/nav. the first argument coll is the result of the previous clojure.datafy/datafy right? not original object passed to datafy?

thheller10:10:25

wondering if I should implement nav on the original object or via metadata on the datafy result

kelveden10:10:43

Given a system that is already happily configured for logging using a combination of logback and slf4j, have folks found any compelling reasons to migrate to using timbre?

gabriele10:10:03

the words "happily" "logging" "logback" "slf4j" are so rare in one phrase that i would keep stuff like they are ๐Ÿ˜„

kelveden12:10:09

Well, happiness is a subjective thing...

lukasz14:10:30

After running multiple (15+) Clojure apps in production I found that what happens with logs after they're being produced is way more important, how you log is a secondary concern ๐Ÿ˜‰ We use tools.logging + logback with a custom formatter and MDC in few places and it doesn't feel like we need to change anything. What would be your reason for migrating to timbre if current setup is working?

seancorfield15:10:39

We thought Timbre looked like a great idea and used it for several years @kelveden but we recently migrated our entire code base (back) to tools.logging, log4j2, and its various bridges/adapters. There's a lot to be said in favor of industry standard logging...

kenny15:10:51

We have pretty much the exact same setup as @U0JEFEZH6.

jumar20:10:51

timbre is really horrible if you want more customized log message and really easy for things like changing log level dynamically at runtime (which is much harder with tools.logging & log4j2)

kelveden21:10:26

Thanks for the thoughts guys, really interesting. It confirms my gut instinct: if it ain't broke don't fix it, particularly when it is a tried and tested stack used across the industry.

Arto Kalishian10:10:46

Doesn't the as-> macro make clojure's immutability strength pointless?

mccraigmccraig10:10:23

you didn't mutate anything there @UNQ70RULA - you just rebound foo

mccraigmccraig10:10:33

here's the macroexpansion of your expression:

mccraigmccraig10:10:38

(let* [foo 1 foo (inc foo)] (println foo))

Arto Kalishian10:10:33

You mean we over written foo's value so in that case it's not considered mutation because it was on purpose?

mccraigmccraig10:10:27

it's not mutation - you are effectively creating a new foo which shadows the old one, but you aren't mutating any values. if the value of the original foo was stored anywhere, it is not changed by the inc

๐Ÿ‘ 4
yuhan11:10:06

Is the above screenshot from some sort of tutorial? That looks very misleading for beginners

Arto Kalishian11:10:59

Quick Clojure book

Arto Kalishian11:10:02

I'm still confused a bit but telling myself perhaps when I practice it will be more clear.

yuhan11:10:35

hmm, I'm not sure how good a reference that book is.. from the chapter previews it looks like it's written from quite an imperative standpoint

mccraigmccraig11:10:28

does this make it any clearer @UNQ70RULA

(let [bar-a (atom nil)]
  (as-> 1 foo
    (reset! bar-a foo)
    (inc foo)
    (println foo))
  (println @bar-a))
;; 2
;; 1
;; nil

Arto Kalishian11:10:42

I like it to be honest because it attempts to be concise whereas most books try to be comprehensive which is not a good start for beginners.

yuhan11:10:30

The chaper on "Sequences" starts off by introducing doseq and saying looping over collections to carry out side effects is a common task in Clojure ๐Ÿ˜ฆ

yuhan11:10:17

(that is definitely not the case)

Arto Kalishian11:10:47

Thanks Craig. Yes it does. But in the first example we printed foo's shadow =2... is that considered still safe to use in any app without risk of a value changing without our consent? In other words is it safe to use as-> or it makes an app less safe?

Arto Kalishian11:10:36

@UCPS050BV I'm surprised since this book is probably the most recent of all my collection being in 2017... most other books are probably 2015-16

Arto Kalishian11:10:19

Or maybe to rephrase @U0524B4UW... isn't it safer to create a new variable to assign it the increment or that's pointless?

mccraigmccraig11:10:04

@UNQ70RULA it's still safe - as-> isn't doing anything special, it's just saving you the work of writing some let bindings and hopefully making the intent of your code easier to divine... (although, that said, i rarely use as->)

๐Ÿ‘ 4
mccraigmccraig11:10:00

you certainly can create a new variable to assign the increment, but that has its own difficulties (it's very easy to accidentally refer to the un-incremented variable in later code, especially after some refactoring)

๐Ÿ‘ 4
Arto Kalishian11:10:36

Nice thoughts ๐Ÿ‘

Arto Kalishian11:10:24

I remember when i learned some rust they used a similar concept of shadowing rather than creating a new variable.

๐Ÿ‘ 4
mccraigmccraig11:10:27

i generally prefer the thread macros which don't bind a variable... -> and ->> - there are no such issues with them

๐Ÿ‘ 4
mccraigmccraig11:10:40

that may just be my personal preference though

Arto Kalishian11:10:26

I make thumbs up it disappears for some reason... ๐Ÿ˜„

seancorfield15:10:59

Another issue I'd have with that example is that as-> is designed to be used inside -> hence the "odd" argument order.

seancorfield15:10:38

I hadn't heard of Quick Clojure but based on this thread I think I would recommend avoiding it.

Arto Kalishian15:10:33

Maybe "avoiding immutability" was just misplaced and it can improve in next book version. To be honest the rest of the book was enjoyable so far..

seancorfield15:10:28

I'd never heard of that author. Searching for his name and Clojure only yields that book so it's hard to tell his credentials. There are certainly bad Clojure books out there. Enjoyable != good, necessarily ๐Ÿ˜

Arto Kalishian15:10:45

I have posted the complete section where he mentioned the as-> macro for fairness

Arto Kalishian15:10:06

The reason I also included this is to be clear that the author used as-> to avoid the alternative complicated version he mentions.

seancorfield15:10:32

That's pretty horrible stuff. Now I'll definitely recommend people avoid that book!

Arto Kalishian15:10:03

Glad to have your opinion about this to be aware.

Arto Kalishian15:10:31

I thought Apress are selective.

seancorfield15:10:37

He's coming at this from completely the wrong angle -- and the comment about doseq in the sequences chapter confirms that.

seancorfield15:10:04

Apress is better than Packt but...

Arto Kalishian15:10:58

So if you recommend 3 books for beginners... what they'd be?

seancorfield15:10:59

A lot of these publishers churn out books just so they have something in a given section.

seancorfield15:10:03

Living Clojure and Getting Clojure are probably the first two that come to mind. When I'm at my desk I can be more sure if that.

๐Ÿ‘ 4
alexmiller15:10:45

I skimmed through some examples on amazon and I agree with Sean. This is a badly written book (as is common with many Packt books)

alexmiller15:10:32

I concur with Sean's recs, or Clojure for the Brave and True, or Programming Clojure

๐Ÿ‘ 4
alexmiller15:10:04

(I am a co-author of the last so I am biased here :)

Arto Kalishian15:10:22

My only concern that books published in 2015.. 4 years passed. Probably back then clojure was 1.7? Some things changed right?

seancorfield15:10:44

A good old book is better than a bad new book.

๐Ÿ™‚ 4
alexmiller15:10:27

Clojure changes slowly enough that it really doesn't matter much

seancorfield15:10:30

Clojure changes fairly slowly, by design. A few things that have been added are important, but a lot of Clojure 1.3/1.4 era advice is still good.

seancorfield15:10:06

Transducers (1.7), Spec (1.9), the new CLI/`deps.edn` (1.10). Those are important additions, but the core is very similar.

seancorfield15:10:33

I would avoid anything that was based on 1.2 tho' since the Contrib libraries went through a massive change between 1.2 and 1.3.

alexmiller15:10:19

clj/deps was actually 1.9

seancorfield15:10:25

https://github.com/clojure/clojure/blob/master/changes.md gives a good sense of what has changed in each version. It's almost always pure additive and very stable (it's why we've run alpha/beta builds in production since Clojure 1.3).

alexmiller15:10:44

Programming Clojure is based on Clojure 1.9 and includes spec, clj, etc

seancorfield15:10:47

Ah, it isn't listed in the changes log (which makes sense) so I was just trying to put "large" features into release buckets ๐Ÿ™‚

alexmiller15:10:22

Getting Clojure is either 1.8/1.9 era, can't remember

alexmiller15:10:32

Living Clojure is 1.6 era

alexmiller15:10:09

Clojure for the Brave and True is probably similar, can't remember

Arto Kalishian10:10:48

Or maybe there is something not clear for me?

Arto Kalishian10:10:46

I mean if we're going to work around it anyway we might as well use javascript or java... no?

sogaiu12:10:38

@thheller i think @seancorfield and/or @lilactown should be able to answer your question about datafy/nav if you haven't gotten an answer already

thheller13:10:11

shortly after I asked I realized that next.jdbc had support for this so I just looked there. so yeah it is the result of datafy not the original value

seancorfield15:10:28

@thheller I wrote a blog post about the principles behind datafy/`nav` that might help... https://corfield.org

thheller15:10:11

oh nice. must have missed that before. thx.

Arto Kalishian13:10:19

Guys, is there any book for clojure app design patterns?

Vachi15:10:51

elements of clojure from Zach Tellman is wonderful book too

โค๏ธ 8
seancorfield15:10:39

We thought Timbre looked like a great idea and used it for several years @kelveden but we recently migrated our entire code base (back) to tools.logging, log4j2, and its various bridges/adapters. There's a lot to be said in favor of industry standard logging...

seancorfield15:10:59

Another issue I'd have with that example is that as-> is designed to be used inside -> hence the "odd" argument order.

dpsutton15:10:28

ah. reading it its not avoiding the immutability as much as avoiding bindings. Ie, you don't have to name things if you thread it through

papachan15:10:14

which book is this one?

seancorfield16:10:30

It's definitely poor wording (and that can be seen in previews for other chapters too).

Ben Hammond15:10:21

are the bindings in a let clause guaranteed to be evaluated in lexical order? If I write something like

(let [start-time (java-time/local-time)
      result (do-really-long-computation)
      finish-time (java-time/local-time)]
  {:start-time start-time
   :result result
   :finish-time finish-time
   :elapsed-secs (java-time/as (java-time/duration start-time finish-time) :seconds)})
might I sometimes get a nasty surprise with the measurements?

bfabry15:10:05

yes. no.

๐Ÿ‘ 4
bfabry15:10:08

longer explanation: clojure isnโ€™t lazily evaluated and you can refer to the letโ€™s defined above the one youโ€™re currently defining so it couldnโ€™t work another way

andy.fingerhut15:10:02

You could get a nasty surprise if do-really-long-computation returned a lazy sequence very quickly, and that wasn't what you expected to be measuring.

๐Ÿ‘ 8
bfabry15:10:48

is there a way to configure prn to print 'foo instead of (quote foo)?

dpsutton15:10:55

โœ” ๎‚ฐ clj
Clojure 1.10.0
user=> (prn 'foo)
foo
nil
user=>

dpsutton15:10:22

where do you get (quote foo) from?

bfabry15:10:44

(prn (quote (quote foo))) or (prn (read-string โ€œโ€™fooโ€)) I actually want to print a quoted foo not a foo

sova-soars-the-sora16:10:22

Hi Clojurians, what is your favorite library for authentication? A friend wants to use Pedestal with something fairly out-of-the-box friendly

sova-soars-the-sora16:10:44

I am aware of Buddy, but I don't know much about the current sample size, so I figured I'd ask. Danke.

benzap17:10:39

I think buddy is the most comprehensive and most used

kulminaator17:10:10

how many deps does buddy drag along ? ๐Ÿ™‚

ghadi17:10:17

I would scrutinize the cryptographic routines very closely

kulminaator17:10:25

uhh, just checked, bouncy castle, cheshire, jackson ... this stuff is heavy ๐Ÿ™‚

vaer-k17:10:54

what alternative do you suggest?

ghadi17:10:20

I think the auth/z stuff in it is well-done, but would consider using something very simple and hard to mess up for encryption

ghadi17:10:39

like libsodium / NaCl designs -- or something that doesn't give you knobs

kulminaator17:10:42

@vincent493 i think it depends on the problem i'd have to solve ๐Ÿ™‚

ghadi17:10:59

no algorithmic selection of JWT signing algos

vaer-k17:10:13

authentication for a basic json api?

kulminaator17:10:34

if you dont care about client cpu time - jwt is perfectly fine

kulminaator17:10:47

with a public-private key algo like rsa

kulminaator17:10:51

jjwt has gone nicely modular recently , so you can ship your own lightweight json engine instead of jackson ... and use the crypto stuff from within jdk itself. works pretty ok in my experience with rsa and even some ec keys

kulminaator17:10:28

ec is quite a wild zoo though ๐Ÿ™‚

vaer-k17:10:37

But the original question posed stated: > A friend wants to use Pedestal with something fairly out-of-the-box friendly

vaer-k17:10:21

Remind me to never ask a clojurian to recommend me a car stereo

๐Ÿ‘Ž 4
kulminaator17:10:27

buddy certainly sounds like it gets you going quickly ๐Ÿ™‚

vaer-k17:10:45

because we will absolutely end up talking about wheel design

kulminaator17:10:41

well ... i think some stuff is on the other end of the spectre

kulminaator17:10:03

a person needs a wheel to turn some wheels and we tend to give them the whole carfactory

kulminaator17:10:51

buddy people already have made some stuff modular, i hope they continue their path and make some light-weight setup possible too

kulminaator17:10:40

i don't think people have to do everything by hand, but nicely modular things are better ๐Ÿ™‚ (and i wouldn't touch clojure with a stick if it'd tell me to install scala runtime, half of apache spark and spring boot just to make it bring up a repl)

kulminaator17:10:34

in a weird way i hope clojure core parts will remain as they are. the weight feels just about right.

vaer-k17:10:12

Iโ€™m just becoming skeptical of whether I could ever take clojure seriously for something I care about. Modular is nice, but back to cars โ€” I still prefer to just buy a car rather than build one myself from spare parts. I have other things to do

kulminaator17:10:33

yes of course, you should be able get a car that just works

kulminaator17:10:49

but if you pull in jackson - that thing alone is bigger than clojure

kulminaator17:10:03

and bouncycastle is even bigger and you will likely use 5% of it or less

kulminaator17:10:21

which is especially weird if your jdk supports the needed crypto parts out of the box

vaer-k17:10:55

itโ€™s a shame there isnโ€™t a better alternative in place by now

vaer-k17:10:16

how long have people been building web apps with clojure now?

kulminaator17:10:19

well if buddy guys could make you choose between jackson and data.json for start

vaer-k17:10:23

this is basic stuff

kulminaator17:10:24

this would be nice, no ?

kulminaator17:10:05

i only do data processing with clojure, no webapps. (those in my architecture are plain boring old java, sorry)

vaer-k17:10:08

lol someone thumbed me down above

bfabry17:10:50

I donโ€™t think being sarcastic about people making a best effort to give helpful advice is good behaviour

โœ”๏ธ 8
bfabry17:10:01

even if you disagree with their advice

kulminaator17:10:31

many of these topics are the ones where even disagree with ourselves ๐Ÿ˜„

vaer-k17:10:32

Iโ€™m not being sarcastic at all. I thought we were having a nice conversation. Sorry if I offended you @kulminaator. Iโ€™ve been very interested in what you have had to say

kulminaator17:10:45

you didn't offend me ๐Ÿ™‚

kulminaator17:10:50

i think this is a healthy discussion

vaer-k17:10:57

thank you I thought so too

kulminaator17:10:42

people want lightweight tooling . lightweight for usage patterns (when you just start out) and lightweight to own (which you get to once you have piled up all possible deps for years)

vaer-k17:10:59

So do you have any thoughts about why a lightweight library doesnโ€™t yet exist in clojure for such a common need?

kulminaator17:10:06

i'm not sure. i don't even think adding another library will improve things much. it would be better if people motivated would get involved in slicing up buddy more ๐Ÿ™‚

kulminaator17:10:44

if you look at rubygems and npm world ... having 5 libraries too many for a problem hasn't really solved issues

bfabry17:10:05

my guess: crypto is scary, the java libs are very mature and well maintained if clunky, so people just use the clunky java libs

๐Ÿ‘ 4
kulminaator17:10:16

i have a ruby project around here that depends on about 100 open source libraries "collected" 10-5 years ago

kulminaator17:10:30

you can only shiver thinking about how many of those are still properly maintained

kulminaator17:10:57

crypto is somewhat scary yes. messing up is very easy to do.

andy.fingerhut17:10:05

The README for buddy says that it has 4 independently-usable parts. I haven't used it, but perhaps that split already helps avoid unnecessary dependencies, if you figure out which one part you want to use?

kulminaator17:10:24

but then again, if you pull in jackson which has had a handful of remote code execution issues over the last 2 years ... uh oh ๐Ÿ˜ž

vaer-k17:10:57

ooh that is scary

kulminaator17:10:59

andy the ones i mentioned were in buddy-core

kulminaator17:10:21

i didn't even look into the other ones

kulminaator17:10:28

thumbs up to cheshire people at least that they bumped up their jackson dependency with the security updates released to jackson :thumbsup:

vaer-k18:10:46

Well, again thanks for your thoughts on this @kulminaator. Itโ€™s very helpful to hear about this from the perspective of somebody with much more experience

Clypto18:10:12

what library doesn't exist? for auth and security?

seancorfield18:10:45

We ended up using the Apache OLTU stuff (including jose.jws) for our OAuth-based auth/security stuff. It seemed simpler than either Buddy or Friend, TBH, but the docs are pretty poor.

unbalanced18:10:57

Speaking of which, I'm implementing an OpenID/Oauth2.0 compliant identity server (ring/datomic w00t!) Does anyone have any good identity server projects to point to (any language really, but preferably Clojure)

seancorfield18:10:50

@goomba Let me know if you find any -- that was the hardest part for us. There seem to be lots of libraries for OAuth2 clients but almost nothing for servers (which is why we eventually settled on Apache OLTU).

unbalanced18:10:23

I'm not really seeing anything, but if I get it figured out I'll do a writeup.

unbalanced18:10:40

More security on the web is better!

bskinny19:10:33

@goomba I came from Ping Identity where we had a OIDC/Oauth2 server product. There is quite a bit of work involved here but you probably donโ€™t need all the features we incorporated. I am happy to look at a writeup of requirements if you like.

unbalanced19:10:05

I'll message you ๐Ÿ™‚

seancorfield18:10:48

The source code for OLTU and the RFC spec for OAuth2 processes were our guide ๐Ÿ™‚

seancorfield18:10:13

(so we ended up with separate Auth, Login, and API services based on that)

unbalanced19:10:49

10-4... I'll take a look!

Arto Kalishian19:10:11

http://4clojure.com is so much fun, thanks to whoever who built it!

๐Ÿ‘ 8
noisesmith19:10:52

amalloy hangs out on freenode irc #clojure, I'll pass that along

๐Ÿ‘ 8
noisesmith19:10:23

he's also the one behind flatland/useful which is a good example of clojure code style and a good utility lib

noisesmith19:10:21

oh it moved but google knows where it moved https://github.com/clj-commons/useful

โค๏ธ 4
Arto Kalishian19:10:38

So in what way are these functions useful?

Arto Kalishian19:10:28

Like in large projects?

andy.fingerhut19:10:19

I believe in general they are things that the author found generally useful across multiple projects they worked on, similar to how many functions in clojure.core are generally useful.

seancorfield19:10:42

In much the same way we found several "almost-core" functions to be useful enough to put them in a library: https://github.com/worldsingles/commons/blob/master/src/ws/clojure/extensions.clj

Arto Kalishian19:10:34

Perfect, Bookmarked!

Arto Kalishian19:10:15

The beauty of such extensions seems to reduce / compress lots of boilerplate code.

Arto Kalishian19:10:28

1 line replace 20...

Clypto19:10:51

@seancorfield it looks like apache OLTU is also marked as retired (is this some sort of trend), did the implementation get picked up somewhere else?

seancorfield19:10:30

@clypto Good question! I haven't checked to see if it was superseded by something else or just moved elsewhere. Finding the basis of an OAuth2 server setup was hard so I hope there is still a version of it or an alternative somewhere that is well-maintained ๐Ÿ˜

Space Guy20:10:11

We use Keycloak (Red Hat, Java) as an identity server, then our application sends users through it as an OpenID 'redirect flow' and talks to it as an OpenID API client

Clypto20:10:41

interesting, it looks like Keycloak is robust - at least with identity brokering, and account federation

Space Guy20:10:33

Right, that's why we wanted it - it means we don't have to build 'either user/password, or SSO via this SAML server' or other stuff like 'configure password restrictions' in the main application

Space Guy20:10:26

In the application side we're using a Java library "Nimbus Oauth 2.0" to parse requests/make response URIs - just implements the spec/JWT/JSON, track your own state

Space Guy20:10:52

Both of those are open source - I've read bits of Keycloak source to see what's going on

Clypto21:10:12

thanks - that's very helpful, I wasn't aware of either of those