#clojure log - Mar 01 2016

The Joy of Clojure
Main Clojure site
Google Group
List of all logged dates

2:54 Kneiva_: sdsd

5:07 umu-erik: Hello, I'm writing a discussion on Clojure in my beginner's level project. I've found many discussions on the advantages of Clojure but now I'm trying to find the other side of the argument. What would an example of a use case where Clojure is not suitable be?

5:10 qsys: ... in an environment that's not open for 'non-Java' ;)

5:12 tdammers: umu-erik: anything where type-driven development is a serious advantage, anything hard-realtime, anything where running on JVM is out of the question, anything where you need to hire dirt-cheap developers and can afford atrocious quality, anything that needs to start up from scratch in a matter of milliseconds

5:12 TEttinger: anything where lines of code written are a metric of work done

5:12 tdammers: TEttinger: that's a subset of my last point ;)

5:13 TEttinger: hehe

5:13 tdammers: or rather the one before that

5:14 the alternative choices in those cases, btw., would be Haskell, C or C++ or maybe Rust, Scheme or Common Lisp, PHP, and Scheme or Common Lisp again

5:15 TEttinger: also the stuff Ada is used for is a good example of what Clojure should not be used for. Ada has a lot of use in avionics (planes and military computer stuff), in part because if someone dies as a result of coding error, and that person was not INTENDED to die (an important distinction in the department of defense's fav lang), you can figure out what code did that

5:15 tdammers: yes

5:15 TEttinger: Ada is hideously verbose, but that's in part due to copious safety checks

5:15 tdammers: Ada also has a strong static type system right?

5:15 TEttinger: very

5:16 stronger than C or C++, weaker than Haskell

5:16 tdammers: then not "very" :D

5:16 but "fairly" or "reasonably" :D

5:16 TEttinger: not much weaker than haskell

5:16 tdammers: I was under the impression that in terms of static guarantees it was about on par with Haskell, but less expressive and more verbose

5:17 which, in a high-security / high-stakes environment, might arguably be a benefit even

5:17 TEttinger: it does have some neat features designed to ensure imperative code doesn't have a lot of the bugs it often has

5:17 mokuso: wow, a language can have stronger static type than C? Interesting !

5:17 tdammers: mokuso: C's static type system is so weak that it's hardly worth mentioning

5:17 int i = "Hello, world!"; printf("%s", i); // ouch

5:17 mokuso: so, one could say that Haskell is the language with the hardest static type system ?

5:18 TEttinger: like you can have enumerated integers, that are limited to (for instance) between 1 and 100. or 0 and 99, if you want an array index

5:18 tdammers: TEttinger: that's something Haskell is painfully lacking

5:18 mokuso: tdammers: how would you write the same thing in Haskell? I can google, but hey, since we're talking .. :)

5:18 TEttinger: if you assign 100 to the 0-99 range, you loop around to 0 instead of erroring

5:19 tdammers: mokuso: you wouldn't, that's the point. It'd be something like: do { let i = "Hello, world!" :: Int; putStr i }

5:19 TEttinger: mokuso: if you want the strongest type system I'd guess Agda? there's likely something newer

5:19 tdammers: but it wouldn't compile, because the types don't match up

5:19 mokuso: tdammers: aha, thanks

5:20 tdammers: (btw, if you'd remove the :: Int type hint, it *would* compile, but i would be inferred as String

5:20 umu-erik: Thanks for the responses, would I be correct to assume that Clojure needs a virtual machine to interpet its bytecode. This is a strength but could also be a big weakness.

5:20 TEttinger: clojure doesn't have bytecode itself

5:20 tdammers: umu-erik: in theory, clojure could run on other backends; there's clojurescript, which compiles to JavaScript, and I believe there an implementation that targets the .NET CLR

5:20 mokuso: thanks TEttinger , I'm just being curious. I'll have a look tho

5:21 umu-erik: Doesn't AOT compilation of clojure create JVM-bytecode?

5:21 TEttinger: it can produce JVM bytecode that is essentially the same as what Java produces, though it may use the clojure libs (java can too)

5:21 tdammers: umu-erik: but in practice, most clojure projects are somehow tied into Java's library ecosystem, so while you're still using the same core language, most libraries won't transfer as-is

5:21 unless they were designed to be backend-agnostic

5:22 practical clojure projects can be assumed to require a working JVM

5:22 clojurebot: Titim gan éirí ort.

5:22 TEttinger: and clojurescript is pretty much a separate language, but is extremely similar

5:22 IIRC the macros in clojurescript use clojure to produce their final output

5:22 tdammers: TEttinger: arguably, yes. I'd call it the same language but with an incompatible standard library

5:23 TEttinger: that sounds fair, yeah

5:23 tdammers: the macro thing is kind of annoying IMO

5:23 part of the beauty of clojure, IMO, is that macros are written in the exact same language as the code they produce

5:23 TEttinger: yeah

5:23 tdammers: so you can have a function that is used both in macro space and in code space

5:23 TEttinger: most lisps have that, right?

5:23 or at least schemes

5:24 tdammers: yes, that's kind of the unique selling point

5:24 "homoiconic" being the fancy word

5:24 TEttinger: oh that's what you mean

5:24 tdammers: but in clojurescript it feels a bit second-class, because it's not 100% the same language, and there's a noticable barrier

5:24 TEttinger: I thought the "macro space/code space" thing was referring to the differences between scheme and CL

5:24 J_Arcane: hopefully that can be fixed now that CLJS is self-hosting.

5:25 mokuso: tdammers: I've seen this term before. I think in a clojure book. It's similar to the notion of isomorphism if I got it right

5:25 TEttinger: homoiconic is homo- "same" iconic "representation", to mangle the greek

5:25 mokuso: I know

5:26 I'm Greek :)

5:26 TEttinger: hehe

5:26 tdammers: TEttinger: you mean lisp-1 vs. lisp-2

5:26 TEttinger: I can never remember what iso is in greek

5:26 yes

5:26 mokuso: iso stands for equal

5:26 tdammers: TEttinger: clojure/scheme, where functions are lambdas bound to variables, vs. CL, where functions live in a namespace of their own

5:26 TEttinger: oh that makes sense :)

5:27 mokuso: that's why in Greek the equation is called "isotita" :>

5:27 TEttinger: isometric is equal distance measurement, which makes total sense

5:27 mokuso: yeh :)

5:27 isosceles , etc

5:28 sceles stands for legs, more or less

5:28 TEttinger: I think if isomorphism is related to the term polymorphism, then homoiconic refers to something else DESPITE being made of synonyms

5:29 equal shape and same representation I think in this case refer to different "levels" of the language's design

5:29 tdammers: isomorphism means the same shape; homoiconic means the same symbols

5:29 mokuso: I'm not sure how 'isomorphism' is used in functional languages. I've seen it only in Graph theory, so far

5:30 tdammers: two things that are isomorphic have the same shape, despite that shape being implemented using a different set of symbols, and being filled with different content

5:30 mokuso: between two graphs that are the same, if you change the name of the nodes and the vertices

5:30 TEttinger: homoiconic in lisps refers to the same syntax being used for data and code

5:30 tdammers: for example, a structured text document and a file system are isomorphic, because they're both tree-shaped

5:31 by contrast, homoiconic means that two things are expressed in the same symbolic representation, despite having different meanings or referring to different domains

5:31 mokuso: nice

5:31 TEttinger: that is, one uniform syntax for everything. it doesn't have to be lisp-like to be homoiconic though. APL, REBOL, a few others of note

5:31 I think Io is homoiconic

5:32 tdammers: for example, the form (pr 1) and the form '(1 2) are homoiconic; they use the same symbolic language (s-expressions), but one is interpreted as a function call, and the other is a list containing two numbers

5:32 and to some degree, the term "homoiconic" is completely meaningless, because on some level, *all* programming languages are homoiconic

5:33 C programs are represented as byte sequences, and they can operate on byte sequences

5:33 which means that C is homoiconic, the symbols being bytes

5:33 (interpreted as source code, or as byte sequences, or as 8-bit encoded strings)

5:34 TEttinger: lisp-like syntax is one of the things that clojure diverges from its roots on somewhat. using non-parenthesis punctuation like {} and [] for some data is definitely different, and it's purely for programmer benefits; there's IIRC no difference between (vector 1 2 3) and [1 2 3]

5:34 the use of it in destructuring has no parallel though, that I can think of

5:34 tdammers: correct, but it doesn't really change clojure's homoiconicity

5:35 TEttinger: yes, it's just a difference from how lisp does it

5:35 tdammers: yes

5:35 TEttinger: or common lisp or scheme, I guess is more accurate

5:35 tdammers: on a side note, in Scheme you can use [] and () interchangeably

5:35 TEttinger: I've been told that by people who use [] for unusual purposes in scheme

5:36 tdammers: well, "unusual"...

5:36 usually in the context of minilanguages or certain macros

5:36 TEttinger: not usual for the scheme community in his case

5:37 this guy used [] around... was it macro calls? and () for anything else

5:37 which does kinda make sense

5:38 tdammers: I'd use [] for things that are important macrostructures (pun intended), vs. () for the nuts-and-bolts code

5:38 TEttinger: also makes sense

5:39 it's nice to see C# 7's proposed features being mostly FP stuff https://github.com/dotnet/roslyn/issues/2136

5:39 clojurebot: Huh?

5:40 tdammers: C# has been drifting this way for a long while now

5:40 TEttinger: yeah, it's nice and seems to be pushing java in the same direction, slowly

5:41 very slowly now that Java 9 is delayed another year

5:41 tdammers: god, the thought that I may have to sign up for a Java job in the near future fills me with dread

5:42 TEttinger: http://www.java9countdown.xyz/

5:42 only 418 days!

5:42 ONLY

5:42 tdammers: 418 days

5:42 I could probably design and implement a working programming language in 418 days

5:42 hyPiRion: tdammers: It's alright to use Java if you can use the library named Clojure :)

5:42 tdammers: hyPiRion: that's not the kind of job I'm talking about ;)

5:43 hyPiRion: It's not too bad if you start from scratch and doesn't need old libraries either, but that rarely happens

5:43 tdammers: well, the problem isn't so much Java the language, or the JVM; it's the kind of organisation that tends to go with it

5:44 hyPiRion: yep

5:44 TEttinger: agreed

5:44 tdammers: the kind where they've been doing straight up waterfall until 2013, then heard about this Agile thing and now they're doing Scrum wrong and in a situation that it's not suitable for in the first place, and they're still running Ubuntu 12, and getting a test server takes 3 months

5:45 TEttinger: if you use Java to code what is essentially C, it actually isn't bad at all. I've ported C code to Java and somehow managed to reduce the line count in a few cases :)

5:48 prohobo: TEttinger: is that a surfboard?

5:49 TEttinger: prohobo: the black and white A-shaped thing with a red dot in the middle is Duke, the decrepit java mascot

5:49 prohobo: ah

5:50 but, he's a surfboard right?

5:51 TEttinger: I would have gone with a trained monkey myself. which is suitable in a number of ways, especially since java coders can often be outsourced to India, where you have a lot of wild monkeys that could potentially be writing your outsourced cheap-as-can-be code

5:51 prohobo: why not a cup of spanish coffee

5:51 with a fedora

5:52 TEttinger: i mean a surfboard makes sense because the island of java has good surf

5:52 not sure what he is supposed to be

5:52 prohobo: what

5:52 there's an island called Java?

5:53 TEttinger: yes, are you a product of the american public school system by any chance?

5:53 prohobo: canadian actually

5:53 TEttinger: aw

5:53 * tdammers fetches burn ointment

5:53 prohobo: how is it a burn that i dont know irrelevant geographical information

5:53 TEttinger: i was absolutely awed by how few districts teach any geography at all here

5:54 prohobo: Java looks like a nice place

5:54 in fact, it looks like the island they used to film Jurassic Park at

5:54 TEttinger: java the island is IIRC where the kind of coffee gets its name

5:54 that was kauai in hawaii

5:54 been there

5:54 prohobo: similar landscape

5:54 TEttinger: sumatran coffee refers to sumatra in indonesia

5:55 where they have some funky and cool wildlife

5:55 prohobo: lemurs?

5:55 TEttinger: rhinos with red hair sticking out from under their thick hides

5:55 no, a bit far for lemurs

5:55 prohobo: my lack of geographical knowledge showing through again

5:55 as far as im concerned, lemurs can be anywhere

5:56 TEttinger: lemurs are mostly found in madagascar, on the other side of the indian ocean. some can be found rarely on the african mainland. there are close relatives though, other prosimians like lorises

5:56 prohobo: i look for them

5:56 TEttinger: lorises range from cuddly looking but, I am not making this up, mildly venomous, to looking like something out of a horror movie, but not actually dangerous to pet

5:57 slow lorises look like cartoon teddy bears. venomous itch-causing saliva, can kill bugs

5:57 shadow6ram420: How high am i?

5:57 TEttinger: slender lorises look like slenderman mixed with some kind of bear

5:58 shadow6ram420: not enough. I haven't even gotten to the ocean fauna in the java area :P

5:58 mantis shrimp that can punch through aquarium glass with the force of a 9mm handgun

5:59 mimic octopuses that can change shape to imitate the silhouette of a fish

5:59 plus prohobo is right, it looks beautiful and tropical

5:59 shadow6ram420: so lost, or maybe for the first time... truth.

6:00 TEttinger: haha. doritos shall set you free, or something

6:00 I could be asleep right now for all I know, I took a sleeping pill 30 minutes ago

6:02 shadow6ram420: itchy saliva and mimicing octopie. this is the internet huh? eh.

6:02 TEttinger: haha

6:02 this is the one that isn't venomous, it just moves spider-like http://dharing.zenfolio.com/img/s/v-3/p587617820-3.jpg

6:02 tdammers: "relax, this one just looks like a huge spider, nothing to worry about"

6:03 shadow6ram420: omg a f-ing link i smiled inside and out.

6:03 TEttinger: this is the poisonous one, believe it or not http://www.acuteaday.com/blog/wp-content/uploads/2011/04/cute-slow-loris.jpg

6:04 shadow6ram420: i was told not to click links. or was that 4chan? idk gave someone im ip adress for tech support.

6:05 TEttinger: you can do a google image search for: slow loris

6:05 and see tons of em. sad stuff is when they get smuggled as pets, they usually remove teeth so they can't bite

6:06 shadow6ram420: now you want me to open another tab click a text feild input aformentioned text. kindda putting me out here arnt you? fuk it ill do it. brb

6:06 TEttinger: haha

6:07 30 seconds later "awwwww so cute"

6:08 shadow6ram420: so its kinda like if some kittiens were vemnous some arnt?

6:08 that thing would kill me no problem.

6:08 TEttinger: lol exactly

6:08 shadow6ram420: cuz id pick that thing up in a heartbeart.

6:09 think i like it more knowing it may be deadly(to somthing?)

6:09 TEttinger: there's only a handful of venomous mammals. one is the platypus, sometimes called the duck-billed platypus, which has a "non-lethal, wink" stabby thing on its hind legs, but only the males have it and only during some of the year.

6:10 it won't KILL you. but it will make you go into a coma from pain for a month

6:10 and it's specifically meant to stab predators who pick it up from above, like big eagles

6:11 shadow6ram420: platypus are deadly when mating, good to know. you need a show on animal planet

6:11 TEttinger: it can kill dogs, they know that from when they would shoot a platypus and send a dog to fetch its fur, find out platypus isn't dead, now your dog is

6:11 totally

6:12 shadow6ram420: you should watch VHF staring weird al

6:12 TEttinger: I should, it's been recommended before

6:13 shadow6ram420: badgers i didnt order any stinking badgers!

6:14 damn dual screen. now i have 25 pairs of big cute eyes looking at me.

6:15 TEttinger: and my cat https://dl.dropboxusercontent.com/u/11914692/Satchmo_Portrait.png

6:15 shadow6ram420: was tempted to check out platypus but i feel the moment has passed.

6:15 TEttinger: i'm typing at an awkward angle because my cat stole my chair

6:16 shadow6ram420: oroin's belt?

6:17 MIB reference nm

6:17 TEttinger: i wish. it does jingle though

6:18 best picture I have of him I think, at least recently. he was entranced by the dangling headphone cables that I knocked partway off the table, that's why his eyes are so wide

6:18 shadow6ram420: still looking at the same 25 img's

6:20 prohobo: seriously?

6:20 a platypus can put me in a coma for a month?

6:20 ahahahhaha

6:21 that makes them so much better

6:33 TEttinger: prohobo: it isn't the poison that puts you in the coma though. when you get to a hospital with a platypus sting, you're screaming from the most intense pain imaginable. so they inject morphine, does NOTHING. they could give you all the morphine they have, won't change the pain. they put you in a coma to prevent you from going crazy from pain

6:33 or screaming all the patients away

6:33 prohobo: dude, thank god i haven't met a platypus up to now

6:33 i'd try to hug it or something

6:33 TEttinger: they're cuddly yes

6:34 females never have the spurs

6:35 prohobo: more painful than a bullet ant?

6:35 doubtful

6:37 TEttinger: much more. the poison's only effect is pain

6:37 it targets pain transmitters directly, bypassing the receptors

6:38 so morphine targets receptors

6:38 big whoop to platypus venom!

6:39 prohobo: that's insane

6:39 we should build an army of platypuses

6:40 TEttinger: haha

6:40 it's being researched as a way to treat people who are also experiencing pain but strong painkillers don't help

6:41 if you can figure out how platypus venom bypasses receptors and CAUSES pain in transmitters, you could do the opposite and STOP pain in transmitters

7:31 aurelian: need to host a small ring/compojure app (no db required yet) is heroku the best free option? are there any alternatives?

7:40 justin_smith: aurelian: you can use beanstalk on aws free tier, iirc. And it's easy to deploy an uberwar on beanstalk.

8:13 solatis: okay, so i have two sequences, and i want to iterate over both of them, in nested loops

8:13 what is the function i would be looking for for this?

8:13 is it zip?

8:14 justin_smith: solatis: for

8:14 or doseq, depends if you want a return value or side effects

8:14 ,(for [a [1 2 3] b [4 5 6]] [a b])

8:14 clojurebot: ([1 4] [1 5] [1 6] [2 4] [2 5] ...)

8:15 solatis: yes i want a return value -- basically, i want to iterate over both sequences, call a function, and get a one-dimensional sequence back with the results

8:15 justin_smith: that's for

8:15 solatis: awesome

8:15 justin_smith: ,(for [a [1 2 3] b [4 5 6]] (* a b))

8:15 clojurebot: (4 5 6 8 10 ...)

8:17 justin_smith: ,(for [a [1 3] b [5 7]] (* a b))

8:17 clojurebot: (5 7 15 21)

8:28 aurelian: thanks justin_smith... my connection dropped :\

8:28 will check that beanstalk out

8:29 where do you get aws free tier?

8:31 Kneiva: aurelian: https://aws.amazon.com/free

8:31 aurelian: cheers! I already have an aws account and paying for some s3 stuff afair, I guess I'll need to signup with another email or something

8:33 Kneiva: aurelian: I'm using https://www.openshift.com for a small python site. The free part does not expire after a year and you don't even need a credit card.

8:34 Reading from their forums a Clojure application should work as well.

8:34 aurelian: cool, I'll check it out

8:34 codefinger: aurelian: are you have problems with heroku?

8:35 aurelian: nope, just asking for alternatives

8:35 as far as I remember heroku didn't keep my app warm, so usually first request was taking foreever

8:36 Empperi: that isn't actually a heroku problem

8:36 that happens with normal virtual servers too

8:37 aurelian: that's depends on the provider I guess

8:37 Empperi: operating system kernels tend to move idle applications to virtual memory so that more active applications have more physical memory available

8:37 aurelian: I see

8:38 Empperi: it happens with actual physical servers too

8:38 so if your app does nothing and you wait long enough it'll end up in virtual memory

8:38 and when it receives activity then it'll be moved back to physical memory if there's enough space left

8:38 codefinger: aurelian: heroku puts free apps to sleep if it's not being used (i.e. receiving requests)

8:38 aurelian: that :)

8:39 Empperi: that should cause even longer pauses

8:39 but anyway, that "first request takes forever" is a more general problem

8:39 I've had some funny talks with some guys who have been banging their heads to the wall because of that problem

8:40 and the problem goes away with a simple monitoring script which one should have in place anyway :)

8:41 codefinger: yea, general warm-up is a java thing. many java shops spend several minutes warming up a process before bring it online

8:42 i've heard of financial firms that execute bogus stock trades in the morning before the markets open, knowing they'll fail, but they warmup all the right parts of the app that way

8:42 Empperi: it's a thing in any JIT

8:42 but that is a different problem

8:43 that is about JIT optimizations which can be done only when the application is actually ran

8:44 Clojure actually benefits hugely from JIT, it might hit it's default inlining values pretty quickly

9:06 AdmiralBumbleBee: So what is the preferred non-emacs environment for clojure these days?

9:07 ridcully: cursive or vim-fireplace ?

9:07 aurelian: I have great success with vim, but that's because I'm using vim since 2006

9:08 atom with proton looked also nice

9:08 AdmiralBumbleBee: I'm currently trying an experiment to not use emacs for a month, as I really overrely on it

9:08 aurelian: and cursive they say is's awesome

9:08 AdmiralBumbleBee: and I need to get my clojure environment back up

9:08 ridcully: http://blog.cognitect.com/blog/2016/1/28/state-of-clojure-2015-survey-results look for "primary development environment" if you want to go with popular vote

9:08 schmir: AdmiralBumbleBee: I've heard good things about spacemacs :)

9:09 qsys: tux-vum here

9:09 AdmiralBumbleBee: schmir: I'm trying to avoid the whole emacs at all thing.

9:09 ridcully: i use vim too

9:09 qsys: *tux-fim

9:09 *tux-vim - damn'd, typing is hard today :p

9:09 Empperi: Cursive is great but it has one big drawback: macros

9:10 I love Cursive but if your clojure programming style is heavily relying on macros then you are pretty much screwed with Cursive

9:10 AdmiralBumbleBee: Empperi: Why? because I am..

9:10 Empperi: however I hear it'll have some improvements in the near future

9:11 AdmiralBumbleBee: Cursive doesn't use REPL for syntax evaluation thus it doesn't understand macros which need to be executed to make any sense out of them

9:11 it uses static analysis

9:11 AdmiralBumbleBee: Empperi: that sounds not very good.

9:11 Empperi: both approaches have their benefits

9:13 AdmiralBumbleBee: I suppose I'll try Cursive and encounter any issues on my own

9:14 It looks to be the type of program I'm looking to experience by avoiding emacs for a while

9:14 qsys: once I crossed euh... lighttable

9:15 you might like that one, I don't know.

9:56 phorse: how are file downloads typically handled in a SPA? Ajax is giving me a bunch of guff.

10:01 justin_smith: phorse: so you are trying to get files via Ajax?

10:05 amoe: is there any predicate for datetimes returned from clj-time? or should I just test with 'instance?'

10:12 phorse: justin_smith: that's right - a simple crud setup - fetch from database, write to csv/xlsx, allow clients to download file

10:13 I'm using re-frame, but I feel like I'm really fighting when it comes to file uploads and downloads

10:14 justin_smith: phorse: why does the file have to exist on your server, why not send the bytes to the client?

10:14 phorse: justin_smith: I haven't explored that, where can I look to learn more?

10:14 justin_smith: phorse: in my cljs / reagent app we generate a "file download" 100% in frontend code, by crunching the data in the app state

10:15 phorse: one moment, let me see if I can find a good example or summarize what we do in our (closed source) code

10:16 phorse: Thanks! Some of these downloads are pretty big, though - up to 1 MB

10:16 justin_smith: phorse: but the high level version is that the file doesn't have to exist as a "file" anywhere in order to be a download, all you need is to generate the right bytes and then offer it to the user and label it as a download

10:17 renl: hi when i see a #+clj in the source code what does it mean?

10:17 justin_smith: renl: it's a cljx file, which is deprecated

10:17 renl: does #+ mean anything in clojure syntax?

10:17 oh mmm

10:17 justin_smith: no, it's a special cljx directive, the cljx preprocessor will take that file and generate a clj file and a cljs file

10:18 but since cljc is in clojure.core, cljx is pretty much over

10:19 renl: okie thanks

10:20 phorse: justin_smith: that would simplify a lot. Do you use something like data.csv to order things on the frontend?

10:20 justin_smith: phorse: basically you end up with something like [:a {:href (str "data:attachment/" filetype "," encoded)} :target "_blank" :download (str filename "." extension)} "Download"]

10:21 phorse: we use testdouble.cljs.csv

10:21 in the above "encoded" is the actual csv data shoved into the URL

10:21 there's other ways to do that, but that worked out OK for our CSV (~1000 rows usually)

10:21 oh, and we used (js/encodeURIComponent data) to make encoded

10:22 and data was the outptu of the csv/write-csv call

10:23 phorse: justin_smith: thanks for walking me through that - I'll experiment with that this morning.

10:24 justin_smith: phorse: here's some docs on dataurls http://dataurl.net/#about

10:26 phorse: instead of data urls of course you can generate the data on the backend in a request handler, but the same concept applies - you tell the client it's a file, and just generate the content when they need it

11:27 I just had a random editor movement idea that probably isn't unique and might even exist

11:28 a keypress to move "forward by forms at this level"

11:28 which would mean not jumping down into lower nestings, and alwas leaving your cursor in a place so it would continue moving forward by forms of that level (if possible)

11:30 so if you have (defn ^f [] (x) (y) (z (+ 1 1))) moving forward would give you (defn f ^[] (x) (y) (z (+ 1 1))) then (defn f [] ^(x) (y) (z (+ 1 1)) then (defn f [] (x) ^(y) (z (+ 1 1))) etc.

13:25 cortexman: anyone using emacs/cider ? the stack traces could use some work...

13:37 amalloy: justin_smith: you mean C-M-f?

13:38 (bound to forward-sexp)

13:38 justin_smith: amalloy: oh, does it actually do that? I guess I don't use it

13:38 amalloy: it's probably my most-used sexp movement command

13:44 the ones that i much more rarely remember to use are paredit-forward-down, paredit-backwards-up, and so on

13:45 i mostly only use those for defining keyboard macros

13:59 cortexman: is there a way to get the repl to respond to interrupt signals faster

13:59 i don't care if it comes at a performance cost during debugging

13:59 when i do C-c C-c, i need it to stop.

15:40 justin_smith: cortexman: is this because it's crucial that the process stop? because if it is about being able to access the prompt again you can just make another repl connection, since C-c C-c can only interrupt the top level process in a particular repl

15:53 Shayanjm: justin_smith: sorry for bugging you about this again - the looping process to consume messages from kafka using clj-kafka... how does that work precisely?

15:53 cortexman: justin_smith, i will try that

15:53 Shayanjm: I create a consumer c outside of the looping process, and (def msgs (messages c "test")). Intuitively I would think I could just throw (take 1 msgs) into a (while true) and append the output to some atom

15:54 but I guess also intuitively that causes my REPL to hang and be generally useless

15:54 how do you handle this?

15:55 j-pb: future

15:55 cortexman: justin_smith - do you use emacs / know how to make a second repl connection?

15:55 j-pb: Shayanjm: (future (something that blocks

15:55 starts it in a new thread

15:55 don't deref that future though otherwise you'll block again

15:55 Shayanjm: j-pb: the above was wrapped in a (future)

15:56 justin_smith: Shayanjm: the way I ended up doing it was using create-message stream, getting an iterator from that, and looping on .message calls

15:56 err, looping .next, and calling .message on each result

15:57 so pretty much not using the higher level clj-kafka stuff

15:57 Shayanjm: ah gotcha

15:57 justin_smith: iirc I made this choice because clj-kafka was providing a lazy-seq and I wanted something more explicitly stateful to connect to core.async

15:57 something about push vs. pull semantics and plugged up messages

15:58 Shayanjm: yeah, and I'm not sure how to pull from that lazy seq in a 'nice' way that won't hang

15:58 https://gist.github.com/shayanjm/6301cad1d64191b8ecad

15:58 this is currently crashing my repl

15:58 justin_smith: well, .next hangs too

15:58 that's the point, it hangs until you get another result from the other end

15:58 cortexman: hmm, @justin_smith, i used M-x cider-connect to connect to the existing repl server, went into the same namespace as my other repl connection, and i could not access the variables i had defined there

15:59 justin_smith: cortexman: are you sure you were in the same namespace? because that contradicts everything I know about clojure namespaces

15:59 j-pb: Shayanjm: I don't she how that should hang except for overloading the repl process as long as that future isn't referenced

16:00 justin_smith: j-pb: it will block until there's a message to read

16:00 j-pb: justin_smith: yeah but it shouldn't block general repl execution

16:00 justin_smith: j-pb: these are two conversations

16:01 brb, interviewing a potential hire

16:01 j-pb: justin_smith: I think "this is currently crashing my repl" was in reference to that code though

16:02 Shayanjm: btw the same could proably be achieved by doing (future (doall (map #(swap! message-log conj %)) msgs)))

16:02 Shayanjm: j-pb ah you're right

16:03 j-pb: Shayanjm: what do you mean with "crash repl" btw?

16:03 Shayanjm: I'm currently in emacs cider so I haven't tried this in the proper terminal repl yet

16:03 but

16:03 when I create that future, the repl slows down until I simply can't run anything anymore

16:03 j-pb: loool

16:04 Shayanjm: (println "hi") simply doesn't execute after creating that future

16:04 j-pb: ahem how many messages do you have in there?

16:04 Shayanjm: not even that many

16:04 probably like 500-1k stacked up so far?

16:04 j-pb: maybe the GC is going crazy?

16:04 Shayanjm: could be

16:05 maybe I need to be running this on a heftier host...

16:05 cortexman: justin_smith i just confirmed that's the behavior i'm getting

16:05 Shayanjm: oh yeah

16:06 j-pb: OutOfMemoryError GC overhead limit exceeded

16:06 rekt

16:09 j-pb: Shayanjm: I think the best way to go right now is using the new kafka 9 consumer direclty

16:09 it has some really nice improvements

16:09 Shayanjm: I don't even know how I'd go about doing that in Clojure honestly

16:09 j-pb: java interop

16:09 works super easiy

16:10 object.method(foo, bar)

16:10 (.method object foo bar

16:10 )

16:14 Shayanjm: ah right

16:14 okay sweet, i'll check it out

16:15 j-pb: Shayanjm: it makes it possible to access offsets manually more easily

16:21 cortexman: what's this thing APersistentMap$ValSeq

16:21 and how can i get the val:)

16:21 TEttinger: cortexman: looks like the return of vals

16:22 ,(vals {:a 1 :b 2})

16:22 clojurebot: (1 2)

16:22 TEttinger: ,(class (vals {:a 1 :b 2}))

16:22 clojurebot: clojure.lang.APersistentMap$ValSeq

16:22 cortexman: i see. thanks

16:22 TEttinger: it is as you would expect a sequence of possibly more than one va;

16:22 val

16:23 but you can go through it with map or filter, etc.

16:23 ,(map inc (vals {:a 1 :b 2}))

16:23 clojurebot: (2 3)

16:24 TEttinger: ,(filter zero? (vals {:a 1 :b 0}))

16:24 clojurebot: (0)

17:29 WorldsEndless: I need leiningen to perform a "lein clean" every time before "lein uberwar". Is there something I can put in my project.clj for this?

17:36 cortexman: i'm trying to do (vec (concat (for [...] {}) {})) resulting in a vector of dictionaries where most were generated by the for loop, but the final one was not

17:38 my final dictionary gets converted into vectors

17:43 justin_smith: cortexman: that's because you are calling concat on a hash map

17:43 cortexman: perhaps you want (concat (for ...) [{}])

17:44 ,(concat [:a :b :c] {:a 0})

17:45 clojurebot: (:a :b :c [:a 0])

17:45 justin_smith: ,(concat [:a :b :c] [{:a 0}])

17:45 clojurebot: (:a :b :c {:a 0})

17:45 justin_smith: I think you want the latter

17:47 cortexman: thanks:)

17:48 justin_smith: cortexman: also if you can prove that two connections to the same nrepl server see different namespaces (other than user I guess?) that would be a big bug in clojure.core

17:48 it could be that ns user is handled differently though

17:53 cortexman: i tried ns user, but i also tried another namespace

18:37 tolstoy: WorldsEndless: You can use an alias: :aliases {"uwar" ["do" "clean" "uberwar"]} or something like that.

18:43 justin_smith: tolstoy: WorldsEndless: oh, I didn't see that question. What you want is :prep-tasks

18:43 thses are run in order when doing an uberjar

18:44 well, if you add :prep-tasks to the :uberwar task, etc.

18:44 each profile can have its own prep-tasks definition

18:46 my prep-tasks for uberjar are basically ["clean" ["shell" "compile-less-files"] ["shell" "get-git-tag"] ["cljsbuild" "once" "app"] "compile"]

18:47 tolstoy: Ah, cool. I sure hope I remember :prep-tasks a year from now when I need it! ;)

18:48 justin_smith: haha

18:49 it's in lein help sample

18:49 tolstoy: Yes, but if you don't even know to look for it, you'll never see it.

18:49 justin_smith: tolstoy: "I need to do something when compiling" "there's an example in lein help sample" are sufficient to find the info in a minute or two

18:51 tolstoy: Just looked at it, and the examples "compile protobuf" or whatever (coffeescript, say) seems clear, but it never occurred to me to put a clean there.

18:52 justin_smith: it's almost a bug that it doesn't clean when doing an uberjar anyway, but it's easy enough to work around with a prep task

18:52 tolstoy: Yeah, it might just be an uberwar thing, or perhaps he has other generated artifacts.

18:53 Talk about "confusing": There's this DEQ cert you have to get for DMV in Portland, so you go to the site, type in your address, and it says I'm "inside the VIP boundary". Does that mean I need it, or not?

18:53 I feel like one of those TV actors who says at the beginning of every episode: It's never easy.

18:54 justin_smith: it just means you are important

18:55 tolstoy: Not Very Ignorant Peon?

19:10 Ah. Vehicle Inspection Station.

19:11 I bet the conversation over on Slack isn't this scintillating and off topic.

19:12 rhg135: ~slack

19:12 clojurebot: Excuse me?

19:13 rhg135: I forget the syntax

19:43 Guthur: I recently updated my cider and it now seems to be font locked on clojure functions

19:43 any ideas how to turn this off?

19:48 thankfully this only seems to be the case in the REPL

19:54 cortexman: any idea on this? Caused by: java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: :db.error/not-a-data-function Unable to resolve data function: {:blah/blerg .....}

19:56 justin_smith: cortexman: is this a datascript error, maybe datomic?

20:00 cortexman: datomic yes

20:00 i am trying to transact a vector of maps

20:01 tolstoy: cortexman: I've gotten that a lot. It's something simple, I think, like not passing the DB param or something.

20:06 cortexman: hmm.

20:08 tolstoy: If d/transact, it might be something like (d/tramsact conn [{:db/id 23 :other/attr "blah"}]) ;; missing the "conn" param, or not putting the values in a vector.

20:08 In other words, it's not the data, but something at issue with passing it in (at least when I get that error).

20:08 Or misspelling transact as tramsact. ;)

20:17 cortexman: i think the prob is i have to specify :db/add

21:00 celwell: Hello, I have a macro printing out a sexp an then the time it takes to eval (think: simple profiler). But for some reason it always wraps the sexp in an extra () when printed. Also, any advice on the macro in general?

21:00 (defmacro time-it [& body] ('do (println body) `(time ~@body)))

21:02 hiredman: ,((fn [& body] (prn body)) 1 2 3 4)

21:02 clojurebot: (1 2 3 4)\n

21:04 celwell: hmmm, that's not quite the same behavior. I'm trying to print out the sexp as is (before evaluation). I.e., the code.

21:05 Here's a use case: (time-it (+ 100 (rand-int 100)))

21:06 Current macro gives: ((+ 100 (rand-int 100)))\n"Elapsed time: 0.083534 msecs"

21:06 hiredman: ,((fn [& body] (prn body)) '(foo))

21:06 clojurebot: ((foo))\n

21:08 celwell: then I would have to prepend a single quote every time I use it. also it doesn't call (time) on the body, which might be harder to do without a macro

21:09 hiredman: look, I think you are missing my point

21:09 [& foo] in function arg lists in varargs syntax, it is all the arguments collected in a sequence

21:09 so in your macro body, is all the arguments collected in to a sequence

21:10 you pass it one thing, so body is a sequence containing that one thing

21:11 celwell: oh yeah... thanks. so maybe: (defmacro time-it [& body] ('do (apply println body) `(time ~@body)))

21:15 hiredman: you are printing the body at macro expand time, not run time

21:15 and your macro expands to something like ('do nil (time ...))

21:16 err

21:16 (time ...)

21:16 because at macro expand time you are looking up the symbol 'do in the result of the println (which is nil)

21:16 and returning `(time ~@body) if no result is found

Logging service provided by n01se.net