#clojure logs

2016-03-01

02:54Kneiva_sdsd
05:07umu-erikHello, 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?
05:10qsys... in an environment that's not open for 'non-Java' ;)
05:12tdammersumu-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
05:12TEttingeranything where lines of code written are a metric of work done
05:12tdammersTEttinger: that's a subset of my last point ;)
05:13TEttingerhehe
05:13tdammersor rather the one before that
05:14tdammersthe 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
05:15TEttingeralso 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
05:15tdammersyes
05:15TEttingerAda is hideously verbose, but that's in part due to copious safety checks
05:15tdammersAda also has a strong static type system right?
05:15TEttingervery
05:16TEttingerstronger than C or C++, weaker than Haskell
05:16tdammersthen not "very" :D
05:16tdammersbut "fairly" or "reasonably" :D
05:16TEttingernot much weaker than haskell
05:16tdammersI was under the impression that in terms of static guarantees it was about on par with Haskell, but less expressive and more verbose
05:17tdammerswhich, in a high-security / high-stakes environment, might arguably be a benefit even
05:17TEttingerit does have some neat features designed to ensure imperative code doesn't have a lot of the bugs it often has
05:17mokusowow, a language can have stronger static type than C? Interesting !
05:17tdammersmokuso: C's static type system is so weak that it's hardly worth mentioning
05:17tdammersint i = "Hello, world!"; printf("%s", i); // ouch
05:17mokusoso, one could say that Haskell is the language with the hardest static type system ?
05:18TEttingerlike 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
05:18tdammersTEttinger: that's something Haskell is painfully lacking
05:18mokusotdammers: how would you write the same thing in Haskell? I can google, but hey, since we're talking .. :)
05:18TEttingerif you assign 100 to the 0-99 range, you loop around to 0 instead of erroring
05:19tdammersmokuso: you wouldn't, that's the point. It'd be something like: do { let i = "Hello, world!" :: Int; putStr i }
05:19TEttingermokuso: if you want the strongest type system I'd guess Agda? there's likely something newer
05:19tdammersbut it wouldn't compile, because the types don't match up
05:19mokusotdammers: aha, thanks
05:20tdammers(btw, if you'd remove the :: Int type hint, it *would* compile, but i would be inferred as String
05:20umu-erikThanks 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.
05:20TEttingerclojure doesn't have bytecode itself
05:20tdammersumu-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
05:20mokusothanks TEttinger , I'm just being curious. I'll have a look tho
05:21umu-erikDoesn't AOT compilation of clojure create JVM-bytecode?
05:21TEttingerit can produce JVM bytecode that is essentially the same as what Java produces, though it may use the clojure libs (java can too)
05:21tdammersumu-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
05:21tdammersunless they were designed to be backend-agnostic
05:22tdammerspractical clojure projects can be assumed to require a working JVM
05:22clojurebotTitim gan éirí ort.
05:22TEttingerand clojurescript is pretty much a separate language, but is extremely similar
05:22TEttingerIIRC the macros in clojurescript use clojure to produce their final output
05:22tdammersTEttinger: arguably, yes. I'd call it the same language but with an incompatible standard library
05:23TEttingerthat sounds fair, yeah
05:23tdammersthe macro thing is kind of annoying IMO
05:23tdammerspart of the beauty of clojure, IMO, is that macros are written in the exact same language as the code they produce
05:23TEttingeryeah
05:23tdammersso you can have a function that is used both in macro space and in code space
05:23TEttingermost lisps have that, right?
05:23TEttingeror at least schemes
05:24tdammersyes, that's kind of the unique selling point
05:24tdammers"homoiconic" being the fancy word
05:24TEttingeroh that's what you mean
05:24tdammersbut in clojurescript it feels a bit second-class, because it's not 100% the same language, and there's a noticable barrier
05:24TEttingerI thought the "macro space/code space" thing was referring to the differences between scheme and CL
05:24J_Arcanehopefully that can be fixed now that CLJS is self-hosting.
05:25mokusotdammers: 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
05:25TEttingerhomoiconic is homo- "same" iconic "representation", to mangle the greek
05:25mokusoI know
05:26mokusoI'm Greek :)
05:26TEttingerhehe
05:26tdammersTEttinger: you mean lisp-1 vs. lisp-2
05:26TEttingerI can never remember what iso is in greek
05:26TEttingeryes
05:26mokusoiso stands for equal
05:26tdammersTEttinger: clojure/scheme, where functions are lambdas bound to variables, vs. CL, where functions live in a namespace of their own
05:26TEttingeroh that makes sense :)
05:27mokusothat's why in Greek the equation is called "isotita" :>
05:27TEttingerisometric is equal distance measurement, which makes total sense
05:27mokusoyeh :)
05:27mokusoisosceles , etc
05:28mokusosceles stands for legs, more or less
05:28TEttingerI think if isomorphism is related to the term polymorphism, then homoiconic refers to something else DESPITE being made of synonyms
05:29TEttingerequal shape and same representation I think in this case refer to different "levels" of the language's design
05:29tdammersisomorphism means the same shape; homoiconic means the same symbols
05:29mokusoI'm not sure how 'isomorphism' is used in functional languages. I've seen it only in Graph theory, so far
05:30tdammerstwo 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
05:30mokusobetween two graphs that are the same, if you change the name of the nodes and the vertices
05:30TEttingerhomoiconic in lisps refers to the same syntax being used for data and code
05:30tdammersfor example, a structured text document and a file system are isomorphic, because they're both tree-shaped
05:31tdammersby contrast, homoiconic means that two things are expressed in the same symbolic representation, despite having different meanings or referring to different domains
05:31mokusonice
05:31TEttingerthat 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
05:31TEttingerI think Io is homoiconic
05:32tdammersfor 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
05:32tdammersand to some degree, the term "homoiconic" is completely meaningless, because on some level, *all* programming languages are homoiconic
05:33tdammersC programs are represented as byte sequences, and they can operate on byte sequences
05:33tdammerswhich means that C is homoiconic, the symbols being bytes
05:33tdammers(interpreted as source code, or as byte sequences, or as 8-bit encoded strings)
05:34TEttingerlisp-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]
05:34TEttingerthe use of it in destructuring has no parallel though, that I can think of
05:34tdammerscorrect, but it doesn't really change clojure's homoiconicity
05:35TEttingeryes, it's just a difference from how lisp does it
05:35tdammersyes
05:35TEttingeror common lisp or scheme, I guess is more accurate
05:35tdammerson a side note, in Scheme you can use [] and () interchangeably
05:35TEttingerI've been told that by people who use [] for unusual purposes in scheme
05:36tdammerswell, "unusual"...
05:36tdammersusually in the context of minilanguages or certain macros
05:36TEttingernot usual for the scheme community in his case
05:37TEttingerthis guy used [] around... was it macro calls? and () for anything else
05:37TEttingerwhich does kinda make sense
05:38tdammersI'd use [] for things that are important macrostructures (pun intended), vs. () for the nuts-and-bolts code
05:38TEttingeralso makes sense
05:39TEttingerit's nice to see C# 7's proposed features being mostly FP stuff https://github.com/dotnet/roslyn/issues/2136
05:39clojurebotHuh?
05:40tdammersC# has been drifting this way for a long while now
05:40TEttingeryeah, it's nice and seems to be pushing java in the same direction, slowly
05:41TEttingervery slowly now that Java 9 is delayed another year
05:41tdammersgod, the thought that I may have to sign up for a Java job in the near future fills me with dread
05:42TEttingerhttp://www.java9countdown.xyz/
05:42TEttingeronly 418 days!
05:42TEttingerONLY
05:42tdammers418 days
05:42tdammersI could probably design and implement a working programming language in 418 days
05:42hyPiRiontdammers: It's alright to use Java if you can use the library named Clojure :)
05:42tdammershyPiRion: that's not the kind of job I'm talking about ;)
05:43hyPiRionIt's not too bad if you start from scratch and doesn't need old libraries either, but that rarely happens
05:43tdammerswell, the problem isn't so much Java the language, or the JVM; it's the kind of organisation that tends to go with it
05:44hyPiRionyep
05:44TEttingeragreed
05:44tdammersthe 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
05:45TEttingerif 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 :)
05:48prohoboTEttinger: is that a surfboard?
05:49TEttingerprohobo: the black and white A-shaped thing with a red dot in the middle is Duke, the decrepit java mascot
05:49prohoboah
05:50prohobobut, he's a surfboard right?
05:51TEttingerI 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
05:51prohobowhy not a cup of spanish coffee
05:51prohobowith a fedora
05:52TEttingeri mean a surfboard makes sense because the island of java has good surf
05:52TEttingernot sure what he is supposed to be
05:52prohobowhat
05:52prohobothere's an island called Java?
05:53TEttingeryes, are you a product of the american public school system by any chance?
05:53prohobocanadian actually
05:53TEttingeraw
05:53prohobohow is it a burn that i dont know irrelevant geographical information
05:53TEttingeri was absolutely awed by how few districts teach any geography at all here
05:54prohoboJava looks like a nice place
05:54prohoboin fact, it looks like the island they used to film Jurassic Park at
05:54TEttingerjava the island is IIRC where the kind of coffee gets its name
05:54TEttingerthat was kauai in hawaii
05:54TEttingerbeen there
05:54prohobosimilar landscape
05:54TEttingersumatran coffee refers to sumatra in indonesia
05:55TEttingerwhere they have some funky and cool wildlife
05:55prohobolemurs?
05:55TEttingerrhinos with red hair sticking out from under their thick hides
05:55TEttingerno, a bit far for lemurs
05:55prohobomy lack of geographical knowledge showing through again
05:55prohoboas far as im concerned, lemurs can be anywhere
05:56TEttingerlemurs 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
05:56prohoboi look for them
05:56TEttingerlorises 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
05:57TEttingerslow lorises look like cartoon teddy bears. venomous itch-causing saliva, can kill bugs
05:57shadow6ram420How high am i?
05:57TEttingerslender lorises look like slenderman mixed with some kind of bear
05:58TEttingershadow6ram420: not enough. I haven't even gotten to the ocean fauna in the java area :P
05:58TEttingermantis shrimp that can punch through aquarium glass with the force of a 9mm handgun
05:59TEttingermimic octopuses that can change shape to imitate the silhouette of a fish
05:59TEttingerplus prohobo is right, it looks beautiful and tropical
05:59shadow6ram420so lost, or maybe for the first time... truth.
06:00TEttingerhaha. doritos shall set you free, or something
06:00TEttingerI could be asleep right now for all I know, I took a sleeping pill 30 minutes ago
06:02shadow6ram420itchy saliva and mimicing octopie. this is the internet huh? eh.
06:02TEttingerhaha
06:02TEttingerthis is the one that isn't venomous, it just moves spider-like http://dharing.zenfolio.com/img/s/v-3/p587617820-3.jpg
06:02tdammers"relax, this one just looks like a huge spider, nothing to worry about"
06:03shadow6ram420omg a f-ing link i smiled inside and out.
06:03TEttingerthis is the poisonous one, believe it or not http://www.acuteaday.com/blog/wp-content/uploads/2011/04/cute-slow-loris.jpg
06:04shadow6ram420i was told not to click links. or was that 4chan? idk gave someone im ip adress for tech support.
06:05TEttingeryou can do a google image search for: slow loris
06:05TEttingerand see tons of em. sad stuff is when they get smuggled as pets, they usually remove teeth so they can't bite
06:06shadow6ram420now 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
06:06TEttingerhaha
06:07TEttinger30 seconds later "awwwww so cute"
06:08shadow6ram420so its kinda like if some kittiens were vemnous some arnt?
06:08shadow6ram420that thing would kill me no problem.
06:08TEttingerlol exactly
06:08shadow6ram420cuz id pick that thing up in a heartbeart.
06:09shadow6ram420think i like it more knowing it may be deadly(to somthing?)
06:09TEttingerthere'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.
06:10TEttingerit won't KILL you. but it will make you go into a coma from pain for a month
06:10TEttingerand it's specifically meant to stab predators who pick it up from above, like big eagles
06:11shadow6ram420platypus are deadly when mating, good to know. you need a show on animal planet
06:11TEttingerit 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
06:11TEttingertotally
06:12shadow6ram420you should watch VHF staring weird al
06:12TEttingerI should, it's been recommended before
06:13shadow6ram420badgers i didnt order any stinking badgers!
06:14shadow6ram420damn dual screen. now i have 25 pairs of big cute eyes looking at me.
06:15TEttingerand my cat https://dl.dropboxusercontent.com/u/11914692/Satchmo_Portrait.png
06:15shadow6ram420was tempted to check out platypus but i feel the moment has passed.
06:15TEttingeri'm typing at an awkward angle because my cat stole my chair
06:16shadow6ram420oroin's belt?
06:17shadow6ram420MIB reference nm
06:17TEttingeri wish. it does jingle though
06:18TEttingerbest 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
06:18shadow6ram420still looking at the same 25 img's
06:20prohoboseriously?
06:20prohoboa platypus can put me in a coma for a month?
06:20prohoboahahahhaha
06:21prohobothat makes them so much better
06:33TEttingerprohobo: 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
06:33TEttingeror screaming all the patients away
06:33prohobodude, thank god i haven't met a platypus up to now
06:33prohoboi'd try to hug it or something
06:33TEttingerthey're cuddly yes
06:34TEttingerfemales never have the spurs
06:35prohobomore painful than a bullet ant?
06:35prohobodoubtful
06:37TEttingermuch more. the poison's only effect is pain
06:37TEttingerit targets pain transmitters directly, bypassing the receptors
06:38TEttingerso morphine targets receptors
06:38TEttingerbig whoop to platypus venom!
06:39prohobothat's insane
06:39prohobowe should build an army of platypuses
06:40TEttingerhaha
06:40TEttingerit's being researched as a way to treat people who are also experiencing pain but strong painkillers don't help
06:41TEttingerif you can figure out how platypus venom bypasses receptors and CAUSES pain in transmitters, you could do the opposite and STOP pain in transmitters
07:31aurelianneed to host a small ring/compojure app (no db required yet) is heroku the best free option? are there any alternatives?
07:40justin_smithaurelian: you can use beanstalk on aws free tier, iirc. And it's easy to deploy an uberwar on beanstalk.
08:13solatisokay, so i have two sequences, and i want to iterate over both of them, in nested loops
08:13solatiswhat is the function i would be looking for for this?
08:13solatisis it zip?
08:14justin_smithsolatis: for
08:14justin_smithor doseq, depends if you want a return value or side effects
08:14justin_smith,(for [a [1 2 3] b [4 5 6]] [a b])
08:14clojurebot([1 4] [1 5] [1 6] [2 4] [2 5] ...)
08:15solatisyes 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
08:15justin_smiththat's for
08:15solatisawesome
08:15justin_smith,(for [a [1 2 3] b [4 5 6]] (* a b))
08:15clojurebot(4 5 6 8 10 ...)
08:17justin_smith,(for [a [1 3] b [5 7]] (* a b))
08:17clojurebot(5 7 15 21)
08:28aurelianthanks justin_smith... my connection dropped :\
08:28aurelianwill check that beanstalk out
08:29aurelianwhere do you get aws free tier?
08:31Kneivaaurelian: https://aws.amazon.com/free
08:31aureliancheers! 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
08:33Kneivaaurelian: 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.
08:34KneivaReading from their forums a Clojure application should work as well.
08:34aureliancool, I'll check it out
08:34codefingeraurelian: are you have problems with heroku?
08:35aureliannope, just asking for alternatives
08:35aurelianas far as I remember heroku didn't keep my app warm, so usually first request was taking foreever
08:36Empperithat isn't actually a heroku problem
08:36Empperithat happens with normal virtual servers too
08:37aurelianthat's depends on the provider I guess
08:37Empperioperating system kernels tend to move idle applications to virtual memory so that more active applications have more physical memory available
08:37aurelianI see
08:38Empperiit happens with actual physical servers too
08:38Empperiso if your app does nothing and you wait long enough it'll end up in virtual memory
08:38Empperiand when it receives activity then it'll be moved back to physical memory if there's enough space left
08:38codefingeraurelian: heroku puts free apps to sleep if it's not being used (i.e. receiving requests)
08:38aurelianthat :)
08:39Empperithat should cause even longer pauses
08:39Empperibut anyway, that "first request takes forever" is a more general problem
08:39EmpperiI've had some funny talks with some guys who have been banging their heads to the wall because of that problem
08:40Empperiand the problem goes away with a simple monitoring script which one should have in place anyway :)
08:41codefingeryea, general warm-up is a java thing. many java shops spend several minutes warming up a process before bring it online
08:42codefingeri'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
08:42Empperiit's a thing in any JIT
08:42Empperibut that is a different problem
08:43Empperithat is about JIT optimizations which can be done only when the application is actually ran
08:44EmpperiClojure actually benefits hugely from JIT, it might hit it's default inlining values pretty quickly
09:06AdmiralBumbleBeeSo what is the preferred non-emacs environment for clojure these days?
09:07ridcullycursive or vim-fireplace ?
09:07aurelianI have great success with vim, but that's because I'm using vim since 2006
09:08aurelianatom with proton looked also nice
09:08AdmiralBumbleBeeI'm currently trying an experiment to not use emacs for a month, as I really overrely on it
09:08aurelianand cursive they say is's awesome
09:08AdmiralBumbleBeeand I need to get my clojure environment back up
09:08ridcullyhttp://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
09:08schmirAdmiralBumbleBee: I've heard good things about spacemacs :)
09:09qsystux-vum here
09:09AdmiralBumbleBeeschmir: I'm trying to avoid the whole emacs at all thing.
09:09ridcullyi use vim too
09:09qsys*tux-fim
09:09qsys*tux-vim - damn'd, typing is hard today :p
09:09EmpperiCursive is great but it has one big drawback: macros
09:10EmpperiI love Cursive but if your clojure programming style is heavily relying on macros then you are pretty much screwed with Cursive
09:10AdmiralBumbleBeeEmpperi: Why? because I am..
09:10Empperihowever I hear it'll have some improvements in the near future
09:11EmpperiAdmiralBumbleBee: 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
09:11Empperiit uses static analysis
09:11AdmiralBumbleBeeEmpperi: that sounds not very good.
09:11Empperiboth approaches have their benefits
09:13AdmiralBumbleBeeI suppose I'll try Cursive and encounter any issues on my own
09:14AdmiralBumbleBeeIt looks to be the type of program I'm looking to experience by avoiding emacs for a while
09:14qsysonce I crossed euh... lighttable
09:15qsysyou might like that one, I don't know.
09:56phorsehow are file downloads typically handled in a SPA? Ajax is giving me a bunch of guff.
10:01justin_smithphorse: so you are trying to get files via Ajax?
10:05amoeis there any predicate for datetimes returned from clj-time? or should I just test with 'instance?'
10:12phorsejustin_smith: that's right - a simple crud setup - fetch from database, write to csv/xlsx, allow clients to download file
10:13phorseI'm using re-frame, but I feel like I'm really fighting when it comes to file uploads and downloads
10:14justin_smithphorse: why does the file have to exist on your server, why not send the bytes to the client?
10:14phorsejustin_smith: I haven't explored that, where can I look to learn more?
10:14justin_smithphorse: in my cljs / reagent app we generate a "file download" 100% in frontend code, by crunching the data in the app state
10:15justin_smithphorse: one moment, let me see if I can find a good example or summarize what we do in our (closed source) code
10:16phorseThanks! Some of these downloads are pretty big, though - up to 1 MB
10:16justin_smithphorse: 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:17renlhi when i see a #+clj in the source code what does it mean?
10:17justin_smithrenl: it's a cljx file, which is deprecated
10:17renldoes #+ mean anything in clojure syntax?
10:17renloh mmm
10:17justin_smithno, it's a special cljx directive, the cljx preprocessor will take that file and generate a clj file and a cljs file
10:18justin_smithbut since cljc is in clojure.core, cljx is pretty much over
10:19renlokie thanks
10:20phorsejustin_smith: that would simplify a lot. Do you use something like data.csv to order things on the frontend?
10:20justin_smithphorse: basically you end up with something like [:a {:href (str "data:attachment/" filetype "," encoded)} :target "_blank" :download (str filename "." extension)} "Download"]
10:21justin_smithphorse: we use testdouble.cljs.csv
10:21justin_smithin the above "encoded" is the actual csv data shoved into the URL
10:21justin_smiththere's other ways to do that, but that worked out OK for our CSV (~1000 rows usually)
10:21justin_smithoh, and we used (js/encodeURIComponent data) to make encoded
10:22justin_smithand data was the outptu of the csv/write-csv call
10:23phorsejustin_smith: thanks for walking me through that - I'll experiment with that this morning.
10:24justin_smithphorse: here's some docs on dataurls http://dataurl.net/#about
10:26justin_smithphorse: 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:27justin_smithI just had a random editor movement idea that probably isn't unique and might even exist
11:28justin_smitha keypress to move "forward by forms at this level"
11:28justin_smithwhich 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:30justin_smithso 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:25cortexmananyone using emacs/cider ? the stack traces could use some work...
13:37amalloyjustin_smith: you mean C-M-f?
13:38amalloy(bound to forward-sexp)
13:38justin_smithamalloy: oh, does it actually do that? I guess I don't use it
13:38amalloyit's probably my most-used sexp movement command
13:44amalloythe ones that i much more rarely remember to use are paredit-forward-down, paredit-backwards-up, and so on
13:45amalloyi mostly only use those for defining keyboard macros
13:59cortexmanis there a way to get the repl to respond to interrupt signals faster
13:59cortexmani don't care if it comes at a performance cost during debugging
13:59cortexmanwhen i do C-c C-c, i need it to stop.
15:40justin_smithcortexman: 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:53Shayanjmjustin_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:53cortexmanjustin_smith, i will try that
15:53ShayanjmI 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:54Shayanjmbut I guess also intuitively that causes my REPL to hang and be generally useless
15:54Shayanjmhow do you handle this?
15:55j-pbfuture
15:55cortexmanjustin_smith - do you use emacs / know how to make a second repl connection?
15:55j-pbShayanjm: (future (something that blocks
15:55j-pbstarts it in a new thread
15:55j-pbdon't deref that future though otherwise you'll block again
15:55Shayanjmj-pb: the above was wrapped in a (future)
15:56justin_smithShayanjm: the way I ended up doing it was using create-message stream, getting an iterator from that, and looping on .message calls
15:56justin_smitherr, looping .next, and calling .message on each result
15:57justin_smithso pretty much not using the higher level clj-kafka stuff
15:57Shayanjmah gotcha
15:57justin_smithiirc 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:57justin_smithsomething about push vs. pull semantics and plugged up messages
15:58Shayanjmyeah, and I'm not sure how to pull from that lazy seq in a 'nice' way that won't hang
15:58Shayanjmhttps://gist.github.com/shayanjm/6301cad1d64191b8ecad
15:58Shayanjmthis is currently crashing my repl
15:58justin_smithwell, .next hangs too
15:58justin_smiththat's the point, it hangs until you get another result from the other end
15:58cortexmanhmm, @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:59justin_smithcortexman: are you sure you were in the same namespace? because that contradicts everything I know about clojure namespaces
15:59j-pbShayanjm: I don't she how that should hang except for overloading the repl process as long as that future isn't referenced
16:00justin_smithj-pb: it will block until there's a message to read
16:00j-pbjustin_smith: yeah but it shouldn't block general repl execution
16:00justin_smithj-pb: these are two conversations
16:01justin_smithbrb, interviewing a potential hire
16:01j-pbjustin_smith: I think "this is currently crashing my repl" was in reference to that code though
16:02j-pbShayanjm: btw the same could proably be achieved by doing (future (doall (map #(swap! message-log conj %)) msgs)))
16:02Shayanjmj-pb ah you're right
16:03j-pbShayanjm: what do you mean with "crash repl" btw?
16:03ShayanjmI'm currently in emacs cider so I haven't tried this in the proper terminal repl yet
16:03Shayanjmbut
16:03Shayanjmwhen I create that future, the repl slows down until I simply can't run anything anymore
16:03j-pbloool
16:04Shayanjm(println "hi") simply doesn't execute after creating that future
16:04j-pbahem how many messages do you have in there?
16:04Shayanjmnot even that many
16:04Shayanjmprobably like 500-1k stacked up so far?
16:04j-pbmaybe the GC is going crazy?
16:04Shayanjmcould be
16:05Shayanjmmaybe I need to be running this on a heftier host...
16:05cortexman justin_smith i just confirmed that's the behavior i'm getting
16:05Shayanjmoh yeah
16:06Shayanjmj-pb: OutOfMemoryError GC overhead limit exceeded
16:06Shayanjmrekt
16:09j-pbShayanjm: I think the best way to go right now is using the new kafka 9 consumer direclty
16:09j-pbit has some really nice improvements
16:09ShayanjmI don't even know how I'd go about doing that in Clojure honestly
16:09j-pbjava interop
16:09j-pbworks super easiy
16:10j-pbobject.method(foo, bar)
16:10j-pb(.method object foo bar
16:10j-pb)
16:14Shayanjmah right
16:14Shayanjmokay sweet, i'll check it out
16:15j-pbShayanjm: it makes it possible to access offsets manually more easily
16:21cortexmanwhat's this thing APersistentMap$ValSeq
16:21cortexmanand how can i get the val:)
16:21TEttingercortexman: looks like the return of vals
16:22TEttinger,(vals {:a 1 :b 2})
16:22clojurebot(1 2)
16:22TEttinger,(class (vals {:a 1 :b 2}))
16:22clojurebotclojure.lang.APersistentMap$ValSeq
16:22cortexmani see. thanks
16:22TEttingerit is as you would expect a sequence of possibly more than one va;
16:22TEttingerval
16:23TEttingerbut you can go through it with map or filter, etc.
16:23TEttinger,(map inc (vals {:a 1 :b 2}))
16:23clojurebot(2 3)
16:24TEttinger,(filter zero? (vals {:a 1 :b 0}))
16:24clojurebot(0)
17:29WorldsEndlessI 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:36cortexmani'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:38cortexmanmy final dictionary gets converted into vectors
17:43justin_smithcortexman: that's because you are calling concat on a hash map
17:43justin_smithcortexman: perhaps you want (concat (for ...) [{}])
17:44justin_smith,(concat [:a :b :c] {:a 0})
17:45clojurebot(:a :b :c [:a 0])
17:45justin_smith,(concat [:a :b :c] [{:a 0}])
17:45clojurebot(:a :b :c {:a 0})
17:45justin_smithI think you want the latter
17:47cortexmanthanks:)
17:48justin_smithcortexman: 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:48justin_smithit could be that ns user is handled differently though
17:53cortexmani tried ns user, but i also tried another namespace
18:37tolstoyWorldsEndless: You can use an alias: :aliases {"uwar" ["do" "clean" "uberwar"]} or something like that.
18:43justin_smithtolstoy: WorldsEndless: oh, I didn't see that question. What you want is :prep-tasks
18:43justin_smiththses are run in order when doing an uberjar
18:44justin_smithwell, if you add :prep-tasks to the :uberwar task, etc.
18:44justin_smitheach profile can have its own prep-tasks definition
18:46justin_smithmy prep-tasks for uberjar are basically ["clean" ["shell" "compile-less-files"] ["shell" "get-git-tag"] ["cljsbuild" "once" "app"] "compile"]
18:47tolstoyAh, cool. I sure hope I remember :prep-tasks a year from now when I need it! ;)
18:48justin_smithhaha
18:49justin_smithit's in lein help sample
18:49tolstoyYes, but if you don't even know to look for it, you'll never see it.
18:49justin_smithtolstoy: "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:51tolstoyJust 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:52justin_smithit'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:52tolstoyYeah, it might just be an uberwar thing, or perhaps he has other generated artifacts.
18:53tolstoyTalk 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:53tolstoyI feel like one of those TV actors who says at the beginning of every episode: It's never easy.
18:54justin_smithit just means you are important
18:55tolstoyNot Very Ignorant Peon?
19:10tolstoyAh. Vehicle Inspection Station.
19:11tolstoyI bet the conversation over on Slack isn't this scintillating and off topic.
19:12rhg135~slack
19:12clojurebotExcuse me?
19:13rhg135I forget the syntax
19:43GuthurI recently updated my cider and it now seems to be font locked on clojure functions
19:43Guthurany ideas how to turn this off?
19:48Guthurthankfully this only seems to be the case in the REPL
19:54cortexmanany 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:56justin_smithcortexman: is this a datascript error, maybe datomic?
20:00cortexmandatomic yes
20:00cortexmani am trying to transact a vector of maps
20:01tolstoycortexman: I've gotten that a lot. It's something simple, I think, like not passing the DB param or something.
20:06cortexmanhmm.
20:08tolstoyIf 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:08tolstoyIn other words, it's not the data, but something at issue with passing it in (at least when I get that error).
20:08tolstoyOr misspelling transact as tramsact. ;)
20:17cortexmani think the prob is i have to specify :db/add
21:00celwellHello, 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:00celwell(defmacro time-it [& body] ('do (println body) `(time ~@body)))
21:02hiredman,((fn [& body] (prn body)) 1 2 3 4)
21:02clojurebot(1 2 3 4)\n
21:04celwellhmmm, that's not quite the same behavior. I'm trying to print out the sexp as is (before evaluation). I.e., the code.
21:05celwellHere's a use case: (time-it (+ 100 (rand-int 100)))
21:06celwellCurrent macro gives: ((+ 100 (rand-int 100)))\n"Elapsed time: 0.083534 msecs"
21:06hiredman,((fn [& body] (prn body)) '(foo))
21:06clojurebot((foo))\n
21:08celwellthen 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:09hiredmanlook, I think you are missing my point
21:09hiredman[& foo] in function arg lists in varargs syntax, it is all the arguments collected in a sequence
21:09hiredmanso in your macro body, is all the arguments collected in to a sequence
21:10hiredmanyou pass it one thing, so body is a sequence containing that one thing
21:11celwelloh yeah... thanks. so maybe: (defmacro time-it [& body] ('do (apply println body) `(time ~@body)))
21:15hiredmanyou are printing the body at macro expand time, not run time
21:15hiredmanand your macro expands to something like ('do nil (time ...))
21:16hiredmanerr
21:16hiredman(time ...)
21:16hiredmanbecause at macro expand time you are looking up the symbol 'do in the result of the println (which is nil)
21:16hiredmanand returning `(time ~@body) if no result is found