Fork me on GitHub
#clojure
<
2017-04-08
>
raspasov04:04:10

question to all: is there a way to do “quick surveys” here or a dedicated channel to do this? I’m trying to figure out what’s the split in the Clojure community in here between Postgres vs MySQL (for example)

byron-woodfork04:04:17

I normally just do something like this.... If you use X reply with :thumbsup: if you use Y reply with :thumbsdown:

raspasov04:04:33

the reason is because of an open source lib I’m thinking about

raspasov04:04:46

@byron-woodfork thanks for the idea 🙂

raspasov04:04:21

posted in #off-topic thanks again! 🙂

yonatanel10:04:21

@raspasov Care to share your thoughts on that open source lib?

lmergen12:04:58

what library are people using nowadays for kafka 0.9+ ?

lmergen12:04:06

there seems to be quite a lot of choice

nbomberger14:04:05

Used in production

lmergen14:04:48

ok, that’s good to know

nbomberger14:04:32

Also recommend https://github.com/tolitius/mount to help manage state. Worked as expected.

nbomberger14:04:00

I think tolitius hangs out here.

tbaldridge14:04:15

@lmergen I also recommend straight Java Interop (this applies to almost any library with native Java bindings). 9 out of 10 times wrapper libs will miss some feature or forget to provide an escape hatch to something the Java libs expose. Or there can be bugs in the wrapper, or the wrapper could be written by someone who doesn't understand performance tradeoffs of Clojure abstractions...etc.

tbaldridge14:04:33

Also it's harder to get support questions answered if you have a wrapper library in the way.

lmergen14:04:14

@tbaldridge yeah that's what @michaeldrogalis just told me as well

nbomberger14:04:14

True. Also, Open source means you can support yourself in many cases. Call me lazy but if I look at the source and feel it is simple enough for me to use and saves me time I go for it. Consulting will do that to a man.

tbaldridge14:04:45

Heh, @nbomberger consulting turned me cynical. I got tired of fixing bugs in OSS code written by people who didn't understand the needs of a system in production. As my co-worker explained here: https://stuartsierra.com/2013/07/28/the-amateur-problem

tbaldridge14:04:13

(reminder to read amateur = "not doing it for money" not "unqualified")

lmergen14:04:08

as with all things, it's a trade off. I personally find myself choosing libraries based upon what others use. would be good if there is a reputation system some way.

pesterhazy14:04:26

Github stars!

pesterhazy14:04:51

more seriously, number of issues closed in the last 12 months

tolitius15:04:49

"Java vs. wrapper" as with everything follow the "it depends" formula. in case of kafka, they keep it in good scala traditions and break backwards compatibility every time someone wakes up and decides to rename a method or a property. having consistent API, via a wrapper (could be a Java wrapper btw), does help. There is also a "baggage effect": when you carry helper functions for "this library" from project to project, and then decide: "why don't I just decouple it into its own thing + someone else may find it useful". As with anything, all general statements "use this, don't use this" stay.. general. "context" is king. It all comes down to understanding Java itself, a concrete library in question and the Clojure code that helps with it. For example I would rather use https://github.com/weftio/gregor than kafka Java API, since I understand its code, the library behind it + what and why it wraps. if I find something missing / wrong, I am going to submit a pull request.

matan16:04:52

@tolitius Yep the scala tradition lol

matan16:04:53

defstruct v.s. defrecord question: why shouldn't I use a plain struct which means the clojure-like key syntax, and use records which require the java interop dot notation and all of that? I just need a repeating structure of data, and figured I'd use a defstruct rather than just a regular map, just to enforce the structure

matan16:04:10

The docs say "Most uses of StructMaps would now be better served by records."

matan16:04:27

But Structmaps look nicer

noisesmith16:04:10

why would records require dot notation for anything?

noisesmith16:04:21

that's a bad example

matan16:04:38

how would it go without dots then?

noisesmith16:04:42

when you run (defrecord Foo []) clojure automatically creates ->Foo which is a function

noisesmith16:04:55

and it also creates map->Foo which takes a hash-map

matan16:04:37

are you sure it's a bad example? shall I put a better one in there in the docs?

noisesmith16:04:07

it would be more idiomatic if it used ->record-class instead of record-class.

noisesmith16:04:48

also, it's too bad that none of the examples show usage of the map->Foo style constructor function

matan16:04:00

I'll see what I can do about that

noisesmith16:04:43

eg. (map->record-class {:alpha 1 :beta 2})

matan16:04:55

to sum up my understanding then, so then one should really always prefer records over structs as the docs say?

noisesmith16:04:48

yes - I have yet to see a reason to use a struct in new code

matan16:04:32

thanks a lot! I'd never had guessed the doc was off there without you

noisesmith16:04:52

well - the code works, it's just not doing things the way we usually would

matan16:04:26

no need to be so gentle, I'd call it wrong if the sole example given in a doc is non-idiomatic

matan16:04:43

not sure I follow about map->Foo

matan16:04:02

is that a constructor function generated by defrecord?

noisesmith16:04:42

yes, it generates ->Foo and map->Foo

noisesmith16:04:12

->Foo is positional, map->Foo uses arg names in a hash-map

matan16:04:40

what might be an intuition to help me flow along with map-> being a constructor prefix?

noisesmith16:04:01

-> commonly indicates a conversion of types

noisesmith16:04:08

err, at least often? hah

matan16:04:27

oh, I think I can hold on to that

matan16:04:44

:thumbsup:

noisesmith16:04:02

now that I check, that isn't used in clojure.core though

noisesmith16:04:32

except Throwable->map - that's one

matan16:04:48

so they use the dot notation?!

noisesmith16:04:03

there aren't many records in clojure.core

matan16:04:13

and that's good to know!

noisesmith16:04:38

I think clojure.core would just use java instead of a record type

matan16:04:39

map->Foo looks very intuitive now in context of giving it a map to initialize the record

matan16:04:28

still feeling a bit odd using objects in clojure (records now) but I guess enforcing a certain constraint on data has its price 😄 otherwise I'd use a plain map if I felt I can do without an explicit constraint

mobileink17:04:17

need some macro help. my app code looks like this: (dom/lambda [bindValue] (str "hello: " bindValue)). My dom/lambda macro tries this: (let [bindValue "{{foobar}}"] (map eval (rest args))). When I eval the app code, I get “Unable to resolve symbol: bindValue”. What I want in this case is “hello: {{foobar}}” What I’m trying to do is use the binding syntax for sth that is not really a fn definer; lambda returns some data, not a function. So I guess my question is: what mechanism can I use (e.g. let) in my macro so that I can bind syms in the body at compile time. if that makes sense.

mobileink17:04:45

p.s. if it helps, I’m trying to put a clojure syntax on Polymer binding annotations https://www.polymer-project.org/1.0/docs/devguide/data-binding

selfsame18:04:08

@mobileink probably need (let [~'a :foo] ~'a) or (let [a# :foo] a#). Might want to skim over https://aphyr.com/posts/305-clojure-from-the-ground-up-macros if you haven't worked with them a lot.

mobileink18:04:39

thanks. problem is the body is passed to the macro so i can't use quoting with e.g. a#. it occured to me after i posted the the source for defn or fn might tell me what i need to do. my dom/lambda is essentially a data lambda. thanks for the link, haven't seen that one before. i've done a fair amt of macro work but have never really mastered them - i usually end up beating on them till they seem to work, even if i don't understand why.😄

mobileink18:04:02

also, in my macro, the above let expression is unquoted, and it's what fails at compile time. but it seems like it should work. any idea why it doesn't?

selfsame18:04:53

check it out with macroexpand, it'll show up as (let [your.ns/bindValue "etc"]), so you need to emit a symbol instead

mobileink18:04:19

aha. so it's the namespacing.

mobileink18:04:58

away from my machine, but i bet adding a (bind [ns ...]...) will work. maybe.

selfsame18:04:33

ah yeah, your evaling it so if the binding is correct maybe its missing the closure

mobileink18:04:40

makes sense. shoulda thought of that, i've dealt with it before. thanks bigly!