Fork me on GitHub
#clojure
<
2016-01-21
>
danielcompton00:01:04

@bradford: could you just run with different threads for the different ‘JARs’?

bradford00:01:44

@danielcompton: Possibly? They still need to communicate with each other (one-way) through Queues of some type.

danielcompton00:01:57

Oh yeah, core.async for your queues is probably a good idea

danielcompton00:01:13

or just a juc queue maybe

danielcompton00:01:26

but core.async will probably be easier

bradford00:01:37

Although you're right, I don't need shared access to anything mutable, so maybe Agents are overkill.

bradford00:01:15

I think -- unless the core.asyncs are "something mutable".

danielcompton00:01:47

Depending on how complex your JARs are, you could just put them in go blocks

bradford00:01:09

It's pretty simple, they boil down to f(x)->y

bradford00:01:28

with some crufitness with @AutoLoader and other java-y classpath-y things.

bradford00:01:34

That I think I can hide.

danielcompton00:01:40

How do they know where to take from and deliver to?

bradford00:01:36

I've got a DAG. In production, edges in the graph are Queues, and nodes are workers.

bradford00:01:46

I build it with loom 🙏:skin-tone-2:

bradford00:01:12

(It's a lot more complex than that, the DAG actually compiles to a Terraform file that spins up all the resources in the cloud)

danielcompton00:01:22

nice. Sounds like it should be pretty easy to substitute core.async for queue and maybe go blocks for workers

bradford00:01:19

That does sound nice, I'll have to read up on core.async. This'll be super cool when it's done though -- a developer can use the same config file to create a 100-node topology in the cloud, or just test the same topology on local.

bradford00:01:04

And hey, I prefer clojure 'easy' to java 'easy' (maps of lists of maps of objects of maps to strings, forever)

bradford01:01:16

Hrmm...another Q. I don't think I'm getting destructuring quite right:

(defn tst [a [w x] b] (str a w x))
=> #'sossity.core/tst
(tst "a" ["w" "x"])
ArityException Wrong number of args (2) passed to: core/tst  clojure.lang.AFn.throwArity (AFn.java:429)
(apply tst "a" ["w" "x"])
=> "aw"
1. Why am I getting a wrong arity? I thought w and x were being destructured from b? expected output is "awx" 2. Why am I not getting an arity error?

slester01:01:32

@bradford did you mean (defn tst [a [w x]] (str a w x))?

bradford01:01:55

@slester: ohhh. I use the position, not the symbol, to destructure.

slester01:01:56

you're going from (defn tst [a b]) to (defn tst [a [w x]]) because you're trying to get the pieces from b, which you know is a vector of 2 items

bradford01:01:56

Makes sense, thx ^_^

jethroksy02:01:34

@alexmiller: yup its there, I'm reading it and it's great! simple_smile

jarodzz07:01:11

guys. can i say transducer is reducer with a different sequence of args?

seancorfield08:01:12

So @crocket why do you think it's ironic that Clojure performs well?

crocket08:01:06

But, haskell programs are shorter in benchmarks.

seancorfield08:01:42

Yup, and some benchmarks are faster in Haskell and some are faster in Clojure.

seancorfield08:01:56

I don't know why that is surprising?

crocket08:01:03

Usually, statically typed languages are a lot faster than dynamically typed languages.

seancorfield08:01:30

Nothing to do with types. More to do with compilation.

seancorfield08:01:44

Clojure is compiled (and strongly typed, just at runtime).

lucasbradstreet08:01:54

Unfortunately, the alioth clojure implementations are usually pretty ugly

crocket08:01:24

Type reflection also affects performance.

lucasbradstreet08:01:36

Maybe this will improve as they’re rewritten with transducers

seancorfield08:01:09

Most Clojure programs avoid type reflection.

lucasbradstreet08:01:02

Clojure + Flight Recorder + targeted optimisations will pretty much always get you where you need to be

crocket08:01:23

What is Flight Recorder?

lucasbradstreet08:01:56

Java8 feature that is super awesome for profiling

crocket08:01:39

Does openjdk have flight recorder?

lucasbradstreet08:01:48

Unfortunately not

lucasbradstreet08:01:49

Its a commercial feature in Java8. You’re also supposed to pay for it if you run it in prod

crocket08:01:04

Does openjdk offer a decent profiler for free?

lucasbradstreet08:01:16

It includes one but it’s really not comparable. This might be worth a look though https://github.com/RichardWarburton/honest-profiler

crocket08:01:33

I was referring to type hint. Type hint increases performance by suppressing reflection.

crocket08:01:40

I don't know whether clojure compiler tries to suppress reflection without type hint.

hans08:01:57

If there are no type hints, the compiler resorts to reflection if it needs to.

hans08:01:25

And even though type hints are often ugly, they are well worth it when you care about performance. Reflection is really really slow.

hans08:01:05

Like in 70x slower with reflection than without.

hans08:01:26

Note that I used "when", not "if" above. I do not think that one should use type hints everywhere "because performance". simple_smile

jarodzz08:01:31

@hans, if it will be 70x faster, why the doc says we should avoid it only when there's a performance issue

danielr09:01:16

@dm3 The reason I got the "cannot find symbol" error, was because there was a class slack.slackapi.class. My protocol interface was slack.slackapi.SlackActions. Just in case you're interested. simple_smile

dm309:01:08

interesting

jimmy10:01:52

hi guys is this file *.abnf the "next level" of file format for parsing @@ https://github.com/sfx/schema-contrib/blob/master/resources/email.abnf . I find it's much greater more detailed than any simple regex out there and it sure works correctly in many cases.

hans10:01:31

@jarodzz: Because 70x faster does not have a meaning if not seen in context. If you're calling a method a few times, then 70x faster will make no difference. If you're calling it a million times, 70x faster can be a deal maker.

nberger12:01:50

@nxqd abnf is the format used by instaparse, which is used in that library to implement some of the validators. Turns out it's a standard format. https://github.com/Engelberg/instaparse/blob/master/README.md

Alex Miller (Clojure team)13:01:12

@lucasbradstreet: most of the alioth programs would not benefit from transducers as they primarily involve tight mathematical loops using primitives. Transducers and seq fns can't retain or manipulate primitives (currently) - that's something Rich and I have talked about changing (but it's non-trivial).

lucasbradstreet14:01:32

@alexmiller: That's too bad, though it's good to know that. Thanks.

meow14:01:27

@alexmiller: you seem to know a lot about Clojure. Ever thought about writing a book? 😼

meow14:01:54

@stuartsierra: you will quickly learn my particular sickness for sarcasm and obscure emoji, not to mention reactji performance art

Lambda/Sierra14:01:33

I think I'm emoji-illiterate

meow14:01:18

I have mad respect and 💌 for @alexmiller

meow14:01:35

reactji performance art inspired by clj and Stuart Sierra

slotkenov15:01:26

Would you use gradle to have one tool for building/dependency management/deployment, or both gradle and lein/boot to be able to use a build tool specific for clojure?

slotkenov15:01:34

Using gradle for clojure doesn’t seem too attractive, but gradle is used for deployment which means duplication if lein/boot would be used for clojure

martinklepsch16:01:30

@slotkenov: if you just do a clojure server and get a proper repl running nicely with gradle gradle might be just fine

bja16:01:47

alternately, if all you need gradle for is deployment, make gradle invoke lein uberjar (or whatever your clojure build process is)

dmitrig0118:01:41

sorry to repeat myself - I have a clojure project that provides an http server, but as part of that project I've also written some scripts that do db schema migrations and such (on postgres). right now I'm just triggering those scripts in the repl, but it would be great if I could make some kind of standalone command (either through lein or outside it) that would run those. how might I go about doing that?

jack_liang18:01:12

hi, i am new to clojure and trying to learn the language

jack_liang18:01:21

thing is i dont know if im being too syntax oriented

jack_liang18:01:04

i cant seem to find much resources regarding how the loops work or conditionals work

jack_liang18:01:13

perhaps im looking in the wrong place

shaun-mahood18:01:21

@jack_liang: There's a beginners channel, if you post any specifics to your problem in there you can usually get help pretty quick.

shaun-mahood18:01:42

Do you have a specific question about loops and conditionals or are you just after the basics?

immo18:01:07

@dmitrig01: try lein help run

dmitrig0118:01:37

@immoh: oh woah, didn't realize you could run other functions than the main one. sweet, thanks!

jack_liang18:01:39

may i ask whats the name of the beginners channel?

meow19:01:14

@dmitrig01: no need to apologize when your question doesn't get answered - that's the challenge with a large group on Slack. Nobody should feel hurt if they get ignored. It happens to all of us. And in addition to lein run you might find boot conducive to your needs. Lots of great help on the #C053K90BR channel.

bfabry19:01:43

speaking of questions that didn't get answered... simple_smile anyone got a solution to referring to the class your generating in a gen-class ns today? ie type hinting the this param https://groups.google.com/forum/#!searchin/clojure/gen-class/clojure/A9Si6Ow581U/sstYR15uBgAJ

markmandel19:01:59

If I just load things in my REPL without tools.namespace, everything is fine. Okay, I'm confused now.

pguillebert19:01:25

markmandel: stating the obvious here but did you lein clean ?

markmandel19:01:27

I thought I had, but willing to give it another shot

markmandel19:01:57

....this looks promising...

markmandel19:01:37

@pgambling: excuse me while I go scream into a corner for a while. That was exactly it.

pguillebert19:01:16

you’re welcome simple_smile

slester20:01:33

Is there a way to speed up lein repl?

slester20:01:57

or lein in general? I heard somewhere it's not really JVM startup that's the bulk of the time

bja20:01:56

a lot of people I know try to avoid restarting their repls using something like tools.namespace to reload the namespaces as necessary

Lambda/Sierra21:01:46

@markmandel: Do you have anything AOT-compiled? That will often cause errors like that. Never mix AOT-compilation with reloading.

bja21:01:17

slester: there is also https://github.com/technomancy/grenchman which tries to automate long-lived repls a little

markmandel21:01:15

@stuartsierra heh... I may have a little bit.

prasincs21:01:29

has anyone run jitpack for private repos using leiningen? The documentation is sparse on where to provide the authentication token

prasincs21:01:45

google wasn’t helpful either 😞

timgilbert21:01:19

@slester: there's also this page on the lein wiki if you haven't seen it: https://github.com/technomancy/leiningen/wiki/Faster

timgilbert21:01:37

...and there's a #C0AB48493 channel which might be helpful

honzabrecka21:01:14

Hi, I have the following issue: I'm using org.httpkit.client for tousands file uploads (doseq [file (files dir)] (upload ... callback)) and in callback I'm updating an atom an checking whether it's done. When I run my function from REPL, it waits correctly, but when I compile and run from command line, then it end almost immediatelly. Can someone help, please?

Slackbot21:01:14

Yo it's clojurian, whats up ?

bfabry21:01:07

@honzabrecka: in a repl, the main jvm thread is being kept open by the user input wait, if you don't have that then you need to find a way to manually tell the main thread to wait. either loop and check that atom and thread/sleep or some other mechanism

arohner21:01:46

I have a fun unicode problem. My app has an API that sends transit data, containing unicode strings. When I connect to the app on my laptop, everything works fine. When I connect in production ,going through AWS ELB, unicode gets corrupted, like ""Bras��lia, Brazil”. Does that ring any bells?

arohner21:01:06

the API returns data with content-type "application/transit+json; charset=UTF-8"

arohner21:01:19

arg. server’s default charset is US-ASCII because it wasn’t explicitly configured

pguillebert22:01:09

7 bits should be enough for everybody

lvh22:01:10

I have a thing that produces a manifold stream (think core.async chan but different) to connect to syslog. metadata seemed like a useful place to store the internal client so it’s available for inspection. However, some types don’t implement IReference (which lead me to learn how meta even works internally). What’s the best way to solve this problem? Add metadata support to some types? Is there a way to implement IReference for existing types? (I guess there is)

lvh22:01:19

one way would be to change the return type so it returns a map of things I guess?

bfabry22:01:48

@lvh I'd go with wrapping your data in a map or something over trying to play wack a mole with adding metadata to things that don't normally have it

lvh23:01:14

bfabry: Yep, makes sense. That’s what I ended up going with. Thanks simple_smile

lvh23:01:32

ztellman: When using transform on a stream, are the transducers supposed to see deferreds? That seems like it would kind of defeat the point; but I’m seeing in a function being (map f) ‘d

lvh23:01:48

oh, wait, I see why that is. Never mind simple_smile

lvh23:01:58

ztellman: (I was calling periodically with a fn that returns a deferred; and for some reason I was expecting it to give me a stream of realized values, so I’m missing a realize-each)

bensu23:01:23

I'll be in san francisco until the 31st. if anybody wants to meet and talk clojure send me a private message.