Fork me on GitHub
#clojure
<
2017-10-19
>
seancorfield00:10:40

I see Phil is quite the evangelist for that position -- running counter to many others in the Clojure community, including Rich 🙂

seancorfield00:10:54

(and that is from three years ago -- with no action taken in Kibit I believe? 🙂 )

danielcompton00:10:46

More because of laziness than anything else 😛

danielcompton00:10:17

and 5.5 years ago

seancorfield00:10:50

Ah yes, the last comment -- yours -- came two years after the previous one!

taylor00:10:54

that Kibit warning is actually what introduced me to the notion that when might be preferable to an if with no else clause, because the codebases I was working on never used when

seancorfield00:10:19

Interesting. I'd always used when for a single branch, instead of if, and until today (yesterday?) I'd never heard the argument that there was any connection between when and side-effects.

seancorfield00:10:40

Maybe I just followed the lead of the code in clojure.core?

taylor01:10:18

I learned Clojure on a job where the prevailing style was a little different than what I’ve seen in the wild. Tools like Kibit, Eastwood, clj-format, etc. are very valuable for discovering “better” practices. I’ve learned a ton from static analysis tools in other langs too.

gklijs05:10:31

Very true in java also, hooking up some code analysis to my hobby project just got a higher priority.

qqq04:10:36

Question: How do I invoke a java method when I have it's hame as a clojure symbol ? 1. I have java class Foo 2. I do (:members (clojure.reflect/reflect Foo)) -- I get a list of members. 3. I do (:name (first (:members (clojure.reflect/reflect Foo))))) -- I now have the name of one of the functions, as a clojure symbol. 4. How do I invoke this? 5. Normally, I would do (.memberFunc Foo ... ) -- but right now, I have a var in clojure, whose value is memberFunc -- how do I invoke it ?

deactivateduser05:10:22

G'day! I've been trying to pull a text file from S3 using clojure.core/slurp, passing in a URL that contains a username & password element (e.g. ). It looks like slurp drops the username and password though, as I'm getting back 401s. Hitting the same URL from the command line (via wget) works fine, so it's not an issue with the URL. Any pointers?

qqq05:10:58

@rauh: that worked; thanks!

slipset07:10:47

slurp seems to expand into code like

slipset07:10:55

(.openStream (.toURL (java.net.URI. "")))

deactivateduser13:10:40

Sigh. Java can be so lame at times. Given some of the simple solutions described there, that don’t add new dependencies, is it worth submitting a patch for slurp?

jumar07:10:26

@deactivateduser10790 for anything more serious including authentication you should use something like https://github.com/dakrone/clj-http

deactivateduser13:10:07

Thanks. Yeah I’m well aware of clj-http (I use it elsewhere), but in this case preferred slurp’s flexibility around supporting local file paths or URLs.

slipset08:10:02

#planck will do this out of the box as well:

slipset08:10:59

Planck 2.8.1
ClojureScript 1.9.946
    Docs: (doc function-name-here)
          (find-doc "part-of-name-here")
  Source: (source function-name-here)
    Exit: Control+D or :cljs/quit or exit or quit
 Results: Stored in vars *1, *2, *3, an exception in *e

cljs.user=> (require '[planck.core :refer [slurp]])
nil
cljs.user=> (slurp "")

xtreak2909:10:32

Is there a way I can connect to a running JAR. Is socket server repl the way to do it? I want to run a JAR and then connect to it using a REPL and then be able to redefine some function or debug something in the function

fantomofdoom10:10:48

Hi, some one know good stack for work with reactive (choreography) architecture in clojure?

pesterhazy10:10:12

@xtreak29, yes the socket server is built for that. Also check out https://github.com/Unrepl/unravel

xtreak2911:10:04

@pesterhazy Thanks :thumbsup:

qqq13:10:18

this is a sanity check, as something is not working as expected: (.field-name SomeClass) should also work if field-name is a field name of a Superclass of Someclass right ?

bronsa13:10:14

if it's public, that is

bronsa13:10:31

and if SomeClass is actually some-class-instance

bronsa13:10:45

otherwise for static field use SomeClass/field instead

scknkkrer13:10:34

Is there any company owner here ? Company that is using clojure for production ?

scknkkrer13:10:23

What is your company aiming ? Web, Mobile or ?

scknkkrer13:10:06

Can you tell me about your expriences ? I think, I am going to create my own company. In four weeks. But I am scared. I have strong abstract background. But less practice.

val_waeselynck14:10:17

@U3JJH3URY well the question is a bit vague 🙂 are you afraid of starting a company, or just of choosing Clojure for it?

scknkkrer14:10:38

Clojure is unique. But I can choose a lot of platform and technologies for my company. Quick answer is: I am not sure what I’ll be faced with clojure ? It’s a rabbit hole. I think I need real world expriences for that choice. What is your opinion ? What are your expriences ?

val_waeselynck15:10:27

Migrating to Clojure was a tremendous success for us, after migrating to it from Node.js we gained huge and predictable productivity and quality, resulting in much more focus on business and a competitivity advantage. Some of our customers once told us "wow, you guys must gave at least 12 developers", when there was only 2 of us.

val_waeselynck15:10:23

@U3JJH3URY For us, most of the benefits came from REPL based development, access to Datomic, and general expressivity of the language.

val_waeselynck15:10:08

One thing I have not experienced yet is hiring, but I take it as a good sign, as I have not needed to hire at all. Most of the feedback I got from more experienced Clojure CTOs was that the hiring situation is pretty good, as you don't need to hire a lot of people, the candidates you get tend to be skilled, and Clojure provides a good argument for retention. So I would not worry too much about that.

val_waeselynck15:10:35

I don't think that Clojure is the best choice for any startup though. Here are some ideas to help you decide:

scknkkrer15:10:38

Omg. So cool. But. What about hiring ? I am living in Turkey and I think, I’ll be all alone for a long time. Maybe a few small projects. Just waiting and lookin for clojure developer. And also, what about your library selections ? Your company relay on community based libraries, right ?

val_waeselynck15:10:01

1. Clojure shines for making custom solutions, not for following conventions. Only use Clojure if you have enough 'architectural initiative'.

val_waeselynck15:10:50

@U3JJH3URY see my previous comment. Also, don't count on hiring experienced Clojure, just plan on teaching them on the job. It will be fine, Clojure is easy to learn.

val_waeselynck15:10:13

2. The more difficult the technical problems you solve, the more likely Clojure is to be relevant. (Modern web apps with non-trivial UX count as hard problems)

val_waeselynck15:10:33

Re libraries, mostly Datomic, http-kit, Ring, compojure, prismatic/schema, manifold, and scope-capture for tooling (disclaimer: I'm the author of that last one). If I had to start over though, I'd probably change to use Yada, Aleph, and Lacinia.

val_waeselynck15:10:48

maybe @U0509NKGK or @U052E4LPH will want to pitch in 🙂

scknkkrer15:10:45

Thank you. I am waiting thier opinions. 😊

robert-stuttaford15:10:32

what val said 🙂 https://www.infoq.com/presentations/Clojure-powered-Startups is relevant for you, @U3JJH3URY. it’s 5 years old, and (like much of Clojure that’s 5 years old) totally relevant.

scknkkrer17:10:25

These are gold informations for me. So do you guys have anything to tell me under any other topics ? Like Dev-Ops, Design Patterns ?

scknkkrer17:10:10

I have books but I really value your expriences.

val_waeselynck07:10:31

I've found "Web Development with Clojure" to be very instructive for practical matters, although I disagree with the author about several technological choices.

scknkkrer17:10:47

Me too. OMG. I am sure you have another opinions about that book. Also I have. But I agree with you.

scknkkrer17:10:27

What are the most valueable libraries in this very moment ? What do you think guys ? What is your companies’ selection on every type (Db, Auth, etc…)

scknkkrer17:10:25

Every words you will said, really important for me. Thank you guys.

Arno Rossouw13:10:39

how would you run clojure app with nginx ? (proxy_pass and supervisor)

val_waeselynck13:10:36

same as Java I guess? There must be a lot of material for Java out there

aisamu13:10:02

@qqq @rauh Hmm, so Reflector is bad... Alright, there you go

(let [s "String"
      m 'getBytes]
  (eval `(. ~s ~m)))
😭

qqq13:10:31

@aisamu: I don't have the names upfront, I have to query the JVM to get the names 🙂 // I guess this can be done at macro expansion time, but I'd prefer to avoid amcros if possible.

bronsa13:10:16

@aisamu why would you do that

aisamu13:10:50

@qqq You definitely want to avoid macros there... I should have put more 😭 's at the end!

bronsa13:10:00

using reflection is a much better solution if you actually need this, which you shouldn't

qqq14:10:03

(r/reflect Stream$StreamCanBuildFrom)

{:bases #{scala.collection.generic.GenTraversableFactory$GenericCanBuildFrom}, :flags #{:public}, :members #{#clojure.reflect.Constructor{:name scala.collection.immutable.Stream$StreamCanBuildFrom, :declaring-class scala.collection.immutable.Stream$StreamCanBuildFrom, :parameter-types [], :exception-types [], :flags #{:public}}}}

How do I call the constructor on the above? Please give me the exact line, as I have been getting errors.

tbaldridge14:10:10

@qqq don't think you're going to get a good answer to that. Scala mucks with Java types a lot. Probably better to write this interop code in Java, or to call Clojure from Scala.

tbaldridge14:10:30

The latter probably being the cleanest way. Clojure's java API is much cleaner than Scala's

maxfurman14:10:54

What’s the best way to get Rails-style db migrations in clojure?

maxfurman14:10:33

I’m starting a new Luminus project this morning, it comes with a lot of great stuff out of the box but I don’t want to write all my CREATE TABLE statements by hand

manutter5114:10:53

Luminus uses migratus, I believe

manutter5114:10:24

but I don’t think it reverse-engineers your db/model for you

tbaldridge14:10:50

Don’t be afraid of writing them by hand. Less can go wrong if you do semi manual dB management

maxfurman14:10:16

right, migratus doesn’t quite have what I want. It will generate an empty .up.sql and .down.sql for me but doesn’t have a dsl for column definitions etc.

tbaldridge14:10:19

Auto migrators always do something wrong it seems

tbaldridge14:10:03

Best system I've had with devs and DBAs is one where you have a base DB via a .sql text file, then incremental changes via commented .sql files, all named via a incrementing number.

tbaldridge14:10:22

Kindof like git for a DB.

mccraigmccraig14:10:20

there's also ragtime & joplin @maxfurman, but they don't have column def dsls either - but then they aren't tied to sql stores either, so column def dsls don't make much sense in their context

manutter5114:10:36

I always cheat: use a GUI SQL tool to lay out my db schema, then select “Copy CREATE TABLE Script…” or whatever.

tbaldridge14:10:03

DB diffing tools are also really nice for that

tbaldridge14:10:19

MS SQL had a "export diff as script" that was super helpful

manutter5114:10:46

Also console logs that capture your changes real-time as you edit columns/tables in the GUI.

dpsutton14:10:36

and if you're working with MS SQL in production, the red gate tools are worthwhile. for data diffing and schema diffing

tbaldridge14:10:40

The big thing is at some point you need to take the changes to prod, and as a former DBA I really really hate using tools for that. So much can go wrong.

maxfurman14:10:47

I guess I’m surprised the clj community hasn’t come up with a lib that matches what you get from rails or django

tbaldridge14:10:16

I'd more say that some of us consider what those frameworks do to be "the wrong way" 🙂

manutter5114:10:00

Though there are projects like http://sqlkorma.com

manutter5114:10:24

though I prefer HugSQL myself.

maxfurman14:10:53

I was looking at Korma, and it doesn’t have ddl

tbaldridge14:10:08

Dropping a bunch of indicies and FKs and then re-adding them may be fine for smaller databases, but I've seen SQL servers crash on stuff like that when you get 100M+ rows in a table. In those places you need surgical edits that are sympathetic to the underlying server design.

maxfurman14:10:14

so even if I wanted to add it (not sure if I want an ORM), I couldn’t use it in the migrations anyway

pesterhazy14:10:22

I've used this homegrown minimalist migration framework: https://gist.github.com/pesterhazy/9f7c0a7a9edd002759779c1732e0ac43

pesterhazy14:10:42

PostgreSQL only ^^

tbaldridge15:10:51

Yeah, as far as the ORM stuff goes HugSQL is pretty awesome. SQL is a powerful tool, leverage it don't hide it behind a DSL. And no need for a ORM when you have hashmaps

tbaldridge15:10:14

(what was that thing from Rich's talk? ORM = OMG 😛 )

maxfurman15:10:31

@pesterhazy Not quite what I’m looking for - I want to write my migrations in clj code and not write any sql

pesterhazy15:10:15

@maxfurman honestly I'd reconsider the approach - SQL is the root DSL for this

delaguardo15:10:23

)) I never scroll to this section ) thуn, sorry for noise )

maxfurman15:10:41

All I want is a cheeseburger and you guys keep handing me broccoli

tbaldridge15:10:47

But SQL gives you power 🙂 the more you understand your datastore the more you can leverage.

tbaldridge15:10:55

Sorry, we want you to be healthy 😛

pesterhazy15:10:57

writing code in a db-independent fashion is ultimately a fool's errant

danm15:10:17

We're using honeySQL ❤️

pesterhazy15:10:02

"we want to be able to switch out the db" is understandable but usually overengineering

mccraigmccraig15:10:08

honeySQL is nice when you want to generate queries from data... though there were some limitations when i last tried it

mccraigmccraig15:10:18

i've never worked on a bigger-than-trivial project which didn't come to depend on particular features of the underlying db, making switching out the db an arduous task

maxfurman15:10:23

Alright, I guess broccoli it is 🙃

igrishaev15:10:11

In our project, we are using HugSQL. It’s a library to generate clojure functions from raw sql queries.

igrishaev15:10:19

With yesql and its analogies, you may face a situation when you need some extra syntax that was not designed to be used with data structures.

igrishaev15:10:00

Say, Postgres carries lots of stuff you cannot express with vectors/maps

vemv15:10:38

- embed JRuby - use Rails migrations - profit! troll

misha15:10:07

what is the default method/library for solving systems of equations or sets of constraints?

misha15:10:04

I have several dimensions: some are defined scalars, some are defined ranges, and I need to solve for possible (say int ranges) combinations of undefined dimensions.

misha15:10:38

it is sort of knapsack problem, but I don't need to solve for the most optimal values; rather I'd like to get range of viable solutions

misha15:10:01

core.logic somehow feels overkill, can't explain why opieop

misha15:10:05

datomic's or datascript's datalog?

val_waeselynck16:10:27

@misha I'd go for core.logic

misha16:10:46

loco looks easy

misha16:10:23

oh noes, it is 2 years stale, looks like it is abandonware! kappa

val_waeselynck16:10:09

or maybe it's just stable. A lot of Clojure libs that work fine don't get a lot of new contributions because they're simple and don't have a lot of bugs.

misha16:10:05

that's why "kappa" is there :)

val_waeselynck08:10:20

Ah sorry didnt get that :)

misha16:10:47

[off topic] given that we are in lisp, why libs such as loco introduce their own symbols rather then reusing clojure's or, and, let, range, etc?

tbaldridge16:10:19

It's a pain to code that way, you have to remove the syms from the namespace via :exclude, and then quote everything clj/and. It's not hard, but it is a pain.

misha16:10:27

I was thinking about quoting entire expression, and butcher it with macros under the hood.

misha16:10:09

(def model
  [($in :x 1 6)
   ($in :y 3 7)
   ($= ($+ :x :y) 10)])

=> (solutions model)
would become something like
(def model
  '(let [x (range 1 6)
         y (range 3 7)]
     (= (+ x y) 10)))

misha16:10:14

loco - clojure only :(

dpsutton16:10:57

its wraps a java constraint solver

misha16:10:47

yeah, I see that, thanks, @dpsutton should have mentioned I need it to run on clients too

dpsutton16:10:01

sorry. i didn't mean to point out the obvious 🙂

Mudge17:10:50

Anybody know of a clojure library for manipulating jar files?

Mudge17:10:08

Anybody know of a clojure library for making custom jar files?

misha17:10:58

is there anything builtin for updating values across entire map?

(update-vals {:a 1 :b 2} (partial + 3)) ;;=> {:a 4, :b 5}

seancorfield17:10:01

@misha I bet Specter offers something...

seancorfield17:10:40

...otherwise I'd probably do (reduce-kv (fn [m k v] (assoc m k (+ 3 v))) {} {:a 1 :b 2})

misha17:10:46

I did it with reduce-kv, but feels like I can compose something existing

seancorfield17:10:33

I can think of a way with zipmap, juxt, and map but I think reduce-kv is much cleaner... 🙂

dominicm17:10:44

@misha map-vals is in most utility libraries. My go-to one for this is medley, which is very light.

ccann17:10:01

anyone else encountered broken leiningen plugins with 2.8 release? Eastwood and bikeshed fail for me now

schmee17:10:02

@misha Specter solution: (transform MAP-VALS (partial + 3) m)

misha17:10:04

@schmee for some reason I am still caution of using specter

seancorfield18:10:24

I still can't get over the (ugly) upper case names 😭

schmee17:10:07

don’t be, it’s a great library! 😄

schmee17:10:15

at least give a try and see if it works for you 🙂

misha17:10:05

I think it tends to be sort of all or nothing: either you use it all over the place, or don't use it at all

schmee17:10:28

yeah, it’s no fun to add a dependency just to use it in one place

schmee17:10:56

but you tend to see use-cases for specter that aren’t obvious at first when you start using it

yedi18:10:35

i kinda wish there was a more concise way of merging two maps in clj

yedi18:10:42

something like JS's spread operator

noisesmith18:10:16

@yedi what kind of merge do you want?

noisesmith18:10:31

I’m lacking imagination and have no idea how spread would help you merge maps

yedi18:10:04

so instead of something like this

(merge props
       {:key1 somethign
        :key2 something-else})
you'd have
{:key1 something
 :key2 something-else
 #...props}

yedi18:10:20

which isn't that much more concise heh

noisesmith18:10:40

(assoc props :key1 somethign :key2 somthing-else)

yedi18:10:52

my main issue i think is just the extra indentation of having the (merge) or (assoc) call

yedi18:10:09

which becomes an issue when writing hiccup code

noisesmith18:10:14

(assoc
 props
 :thing1 something
 :thing2 something-else)

noisesmith18:10:09

any decent editor should indent like that as long as the first arg is on the next line

yedi18:10:23

yea i guess that'd be fine, just the extra line because you have the assoc call

yedi18:10:39

it's a pretty silly thing for me to want tbh

yedi18:10:18

but that kinda spread operator would make the code ever so slightly more concise

noisesmith18:10:52

could it be a macro or reader literal instead of an operator?

noisesmith18:10:19

#spread[props :thing1 somethign :thing2 something2]

noisesmith18:10:39

can’t use {} because of reader rules, but it looks decent

ghadi18:10:13

this is a bizarre question

noisesmith18:10:14

you could even name it #… if you really want to

noisesmith18:10:29

@ghadi it seems like a syntax request to me really

ghadi18:10:46

yup: why send syntax in to do a function call's job?

yedi18:10:07

heh yea #_ could be cool

dpsutton18:10:15

#{:reasons}

noisesmith18:10:01

@yedi or just (def … assoc) and call it a day?

dpsutton18:10:10

(set (vector :i-can-understand))

noisesmith18:10:44

oh, reader macros mean you can define that but not call it directly, too bad

karan20:10:33

anyone experienced using kafka? I’m setting it up and wondering what the experience is using java APIs vs wrappers like franzy https://github.com/ymilky/franzy

viesti20:10:17

Have seen success with clj-kafka for 0.8 version of Kafka (https://github.com/pingles/clj-kafka) and with gregor for current versions of Kafka (https://github.com/weftio/gregor)

noisesmith20:10:13

I have had decent luck with a very thin clj-kafka wrapper for the basics plus raw interop whenever I need a non-default option, YMMV

dpsutton20:10:47

PSA: don't shadow core functions with variable names. especially meta

noisesmith20:10:18

haha, those bugs are fun

bja20:10:07

still bitter about using a library whose api was implemented in terms of proxy and thus shadowed my this in method definitions

Alex Miller (Clojure team)22:10:23

I think that is the only anaphoric macro in core :)