#clojure logs

2015-04-10

03:12magnarsTurning on source-maps in my clojurescript profile, makes it basically just hang there for several minutes now - could it be taking so long? (I am including core.async) Any idea what could make it hang otherwise?
03:34Guest72028is the excuse , we have too many change requests valid for not using unit tests and version control?
03:35magnarsthere is no excuse to not use version control
03:35Guest72028:-), ok and the unit tests?
03:35Guest72028the project is very big btw
03:35Guest72028a payroll application
03:38magnarsautomated testing is a huge advantage when done right, but it might be prohibitively expensive to shoehorn into an existing huge codebase
03:39magnarsbut too many change requests sounds to me like a rather weak argument
03:39Guest72028oh, ok, i see
03:39Guest72028what if they implement unit tests gradually?
03:41magnarsone good way of introducing unit tests is to write tests when reproducing bugs, and them keeping them around to avoid those known bugs to creep up again - that is probably easiest done with some sort of feature tests tho.
03:43Guest72028thanks, that seems like a clever idea
03:43sveriAnd adding tests for new features obv.
03:45TEttingergfredericks made a pretty amazing regex tester for use in clojure tests
03:46TEttingerhttps://github.com/gfredericks/test.chuck/blob/master/src/com/gfredericks/test/chuck/regexes.clj#L501
03:46Guest72028part of the frustration i guess is that management want a feature and they want it like yesterday
03:47TEttingerif you want to make sure your input validation actually only lets in valid input, that tester util may be especially handy
03:48oddcullyGuest72028: test are written to make change/refactoring easy. if every little change breaks half your testbase, then there are problems with the architecture
03:48magnarsGuest72028: the only way to go fast is to go clean
03:49Guest72028ah, ok, so you have to tell the requester be reasonable, you can't build a house in 1 day
03:49oddcullyGuest72028: you can't have a kid in 1 month with 9 wifes
03:49Guest72028:-)
03:50magnarssoftware development is a marathon, not a sprint
03:50Guest72028i guess im the only one here, using git with feature branches running unit tests after new feature then merging back to develop branch
03:51Guest72028i mean only one in my company
03:51oddcullyalso i bet the most expensive part of testing right now are the poor sods that test the app before release by hand (hopefully be protocol); start with automated tests there. granted it can be hard, but at least it tests the stuff that faces customer
03:51slipsetoddcully: wouln't mind trying though
03:52oddcullyhaha
03:52Guest72028oddcully: they're the typical cowboy coder, the users tests the features ,hehe
03:52magnarsslipset: sounds exhausting ;)
03:52magnarsif your users are doing all the testing, and they are still your customers, that might be a deliberate strategy that is currently working ;-)
03:53Guest72028the users have no choice, the software is enforced by the company
03:53oddcullysure. and management likes it because the devs can bring up new stuff every minute
03:54Guest72028yip
03:54Guest72028oh, looky here i have this button when i press it features magically appear
03:55oddcullyand unless they are eastwook-level cowboys this pile of next-age-spaghetti will explode in at least a year
03:55oddcullywook... s/wook/wood/
03:55Guest72028strange enough, i got a hold of the source code, they don't do oop in c++, theyre using c structs.. etc (atoi), software been running for 10 years
03:56Guest72028no inheretance, they use if statements for that
03:56oddcullyinheritance is the root of all evil anyway
03:56Guest72028ok, so composition better?
03:57magnarsseparating data and functions is better :)
03:57oddcully(inc magnars)
03:57lazybot⇒ 4
03:58Guest72028magnars: do you have an example?
04:01magnarsGuest72028: wish I could come up with a brilliant example, but it is one of the core tenets of Clojure, in that "It is better to have 100 functions operate on one data structure than to have 10 functions operate on 10 data structures." - Alan J. Perlis
04:02Guest72028maybe i'm strange but i prefer the functional style of code
04:03TEttingerclojure is rather strongly opposed to defining new data structures when existing ones can be used, it's interesting
04:04TEttingerone of the few data structures that you do sorta need an external lib for are insertion-ordered collections.
04:04TEttinger$google clojure ordered collections
04:04lazybot[Data Structures - Clojure] http://clojure.org/data_structures
04:04TEttingerhm
04:04TEttinger$google clojure ordered collections flatland
04:04lazybot[amalloy/ordered · GitHub] https://github.com/amalloy/ordered
04:04TEttingerthere we go
04:04Guest72028recently got interested with data science, incanter seems to be great tool for this
04:05Guest72028sorry for the bad grammar, my english can improve (2nd language)
04:06TEttingerI wouldn't have guessed, your grammar seems fine
04:08Guest72028ok, cool. feel free to correct if needed , hehe
04:09Guest72028i think i'd enjoy doing clojure programming as a job, don't see a market for it in our country at the moment
04:22Guest72028magnars: why is inheritence evil, just curious
04:23Guest72028ok, i see overcomplication of things
04:24Guest72028http://learnpythonthehardway.org/book/ex44.html
04:25Guest72028if clojure uses the jvm, is the limits of concurrency due to underlaying jvm, could it be as highly concurrent as say erlang?
04:27slipsetGuest72028:what
04:27slipsetis your country?
04:27Guest72028south africa
04:28slipsetso, no clojure in south africa either :(
04:31Guest72028i found 3 jobs on a job searching app
04:31dstocktonslipset: there's clojure in ZA
04:32dstocktonhttps://github.com/ptaoussanis wrote a load of popular libraries, is South African
04:34oddcullyGuest72028: if inheritance is used to save you typing (as a cheap macro system) and not for reflecting the domain, this builds up bad code
04:34oddcullyGuest72028: the quote was from http://channel9.msdn.com/Events/GoingNative/2013/Inheritance-Is-The-Base-Class-of-Evil
04:34oddcully(and i quoted wrong ;p)
04:35jonathanjoh hey, more saffers ;P
04:40Guest72028dstockton: interesting
04:40dstocktoni don't know about jobs, but there's definitely a community/interest
05:17acron^in David's enlive tutorial, he uses the following syntax: (def ^:dynamic *story-selector*
05:17acron^a) what is the "dynamic" metadata?
05:18acron^b) idiomatically, what do the asterisk' indicate?
05:20kungiacron^: dynamic means you can change *story-selector* through with-redefs (for example) by using clojures dynamic scoping.
05:21kungiacron^: the asterisk' or earmuffs are a remnant of lisp inidcating a "special variable" that's not lexically scoped.
05:22kungiacron^: Have a look here: https://stackoverflow.com/questions/1986961/how-is-the-var-name-naming-convention-used-in-clojure
05:22acron^Thanks kungi
05:22acron^(inc kungi)
05:22lazybot⇒ 2
05:22acron^;)
05:22magnarskungi acron^ - the idiomatic way to bind dynamic vars is with `binding`
05:24kungimagnars: I dont't see the difference between `binding` and `with-redefs` (just had a look at the docs)
05:26magnarskungi: `with-redefs` is global, `binding` is thread-local
05:26kungimagnars: I see thank you
05:27kungiWhy are new bindings made in parallel? This introduced a bug in my code lately and I had to nest binding forms.
05:33dysfuni can't say i'm terribly impressed with cljs compile times. it's just taken 18 seconds with no optimisations to build effectively "hello, world"
05:34Empperiyou have an issue in your compilation settings
05:34dysfunhowso?
05:34EmpperiI have compilation times of 0.1-0.8 secs here and this is definetly way more complex than "hello world"
05:34Empperia real reagent based webapp
05:35dysfuni'm generating a source-map. is that somehow mega slow?
05:35Empperino if you have your settings correct
05:35Empperiyou're using cljsbuild plugin for leiningen I assume?
05:35dysfunmy settings are source map, no opts
05:35dysfunno, i'm using the boot cljs plugin
05:35Empperiok
05:35Empperido you get one big "main.js" or gazillion smaller files?
05:36Empperiif you get one main.js then you do have simple optimizations on which will slow down compilation considerably
05:36Empperiwith no optimizations clojurescript compilation will generate one .js file per .cljs
05:36dysfuni have optimisations disabled
05:37Empperiso you get tons of js files as on output?
05:37dysfunand yes, i have one js file per cljs
05:37Empperithen you do *not* have optimizations disabled
05:37Empperibut you may think you have
05:37Empperiah fuck
05:37Empperisorry
05:37Empperimisread
05:37Empperimy bad
05:37Empperishit, need more coffee
05:38dysfuni'm looking at the generated js file
05:38Empperianyway, sourcemap generation will slow it down somewhat, but those numbers I'm seeing is with sourcemaps on
05:38dysfunthere are 4 lines of code that actually do something
05:38dysfunit's all very human readable
05:38Empperithe main.js file should pretty much contain very little
05:38Empperiwith no optimizations
05:39Empperihere we have 4 lines with fourth line being empty
05:39Empperiit just inserts some stuff to DOM to allow google closure dependency management to kick in
05:39Empperiand then it'll dynamically load all required js files one by one
05:40dysfunhttps://www.refheap.com/99457
05:40Empperiso that's your core.js I take it
05:40dysfunyes
05:40Empperiis that your output target file?
05:41Empperifor cljs compiler
05:41EmpperiI'm guessing not
05:41dysfuni haven't explicitly specified one
05:42dysfun(cljs :source-map true :optimisations :none) ;; my boot config
05:42Empperithis is leiningen config but... https://www.refheap.com/4e6ee2a346dfbe075c35c7417
05:42Empperiyou might want to enable :compiler-stats true and :verbose true to see what's really happening under the hood
05:43Empperiyou'll most likely end up seeing some kind of optimization happening even if you say you shouldn't have any optimizations
05:43Empperiand oh
05:43Empperidysfun: optimiZations, not optimiSations
05:43dysfunaha
05:43Emppericlojurescript compiler reads :optimizations keyword
05:44EmpperiI'd guess boot plugin passes the parameters as-is to the cljs compiler like leiningen plugin does
05:44dysfunthe one major benefit i've found of type systems is that it prevents locale-related spelling errors
05:44Empperithere are several others
05:44dysfunwhich is pretty niche i'll grant :)
05:44Empperibut then again dynamic typing gives you other perks
05:44Empperithere is no silver bullet :)
05:45dysfunof course
05:45Empperibut I'm guessing you'll see a dramatic speedup in compile times if you change that 's' to 'z'
05:45dysfunit's theoretically possible to get the benefits of both, and yet it's sufficiently difficult we haven't done it yet
05:45Empperiof course we have
05:45dysfunah, my fans are going full pelt. i must have started a jvm...
05:45Emppericheck Google's Dart for instance
05:45Empperiit has optional typing
05:46Empperipretty nice implementation of static typing on top of dynamic typing
05:46dysfuncore.typed is a bit like that i suppose
05:46dysfunElapsed time: 24.063 sec
05:46Empperidysfun: make a change to your file
05:47Empperiit had to compile everything from scratch since you changed optimization level
05:47dysfunah, 3.187, that's better
05:47Empperiwhich means clojure.core etc
05:47Empperistill really slow
05:47Empperibut better
05:47Empperi"Successfully compiled "resources/private/generated/main.js" in 0.643 seconds."
05:47dysfunyeah, but it's fast enough to not make me want to give up clojurescript :)
05:47Empperispeed I'm seeing here
05:47dysfunthis laptop is a bit slow
05:47Empperiwe have something like 2k lines of clojurescript in this app
05:47dysfunand i have firefox running with $many tabs
05:48dysfunit takes on a good day about 15 seconds to get to a boot repl
05:49Empperigeesh, you have something seriously funky going on there :D
05:49Empperibut anyway, with this ~3 year old windows desktop I'm seeing compilation times like that
05:49dysfunthis is a three year old macbook air
05:50dysfunit flies when i kill firefox
05:50Empperimy ~year old mbp gives me similar compilation times as this desktop
05:50Empperikill the firefox and try to change a file then
05:50Empperiwhat's the compilation time then?
05:51dysfunyes, of course firefox has just hung when i tried to quit it from within itself
05:51Empperijust kill it :)
05:51dysfuni did
05:51Empperiand if it kills your performance that bad then I'd change to Chrome
05:51dysfun2.805
05:51Empperinot much of a difference there
05:51Empperistrangely slow
05:52dysfunyes, kernel_task has spun up now
05:52Empperioh well, might be air's slow I/O
05:52dysfuni'll wait for it to die down and report back
05:52Empperibut anyway, the speed I'm getting is what you're supposed to see too
05:52Empperiand you definetly shouldn't think that kind of compilation times are normal
05:52dysfunand i've killed my VM too
05:52Empperiand dump cljs due to that
05:53Empperiyou'd regret it, I postponed getting familiar with cljs for quite some time
05:53dysfunoh great, spotlight is running an index too. it's not my day to actually try and compile stuff fast
05:53Empperiand now I've been using it for over a month
05:53Empperiand shit I feel so stupid not going for it earlier
05:53dysfunwell i've played with om a bit before
05:53dysfunit's just that clojure is really fun and compiling isn't
05:54dysfun0.992
05:54dysfunhooray
05:54Empperiwell, these days if you do frontend stuff you'll have some kind of compilation phase anyway
05:54Empperiwell that looks more like it :)
05:54clojurebotExcuse me?
05:54dysfuni try not to do frontend stuff for the most part
05:54Emppericlojurebot: you're excused
05:54clojurebotCool story bro.
05:55dysfunand when i was doing it last, i didn't precompile css or js actually
05:55Empperiyou can do that these days too but that's stupid way to do things :)
05:55Empperiif you're writing raw javascript then you'll most likely have something like browserify or similar
05:55dysfunit's less stupid than you might think
05:55Empperiand css is written via less or sass
05:56Empperisure, if you're app is small then it's not a problem
05:56dysfunfor example i checked out a competitor's app last year (it's open source!) and got fed up when the build process broke
05:56Empperibut with 10kloc and larger it gets really hairy
05:56EmpperiI've written a javascript frontend which had nearly 40kloc of javascript code
05:56dysfunyes, i *like* sass. i just don't care enough about the reduced code size enough
05:57Empperiwithout any kind of compilation
05:57EmpperiI tell you, that was pain :)
05:57dysfunhowever, now that boot seems to be doing a good enough job, it should be fairly easy for me to set it up and have it all managed by boot
05:57dysfunwhich means no build tool hell
05:57Empperihappy to help
05:57Empperigotta do some work now :)
05:57dysfunfrankly maintaining 40klo javascript is anybody's idea of hell
05:57sobelonce i understood google's js closure compiler and why it's necessary, i realized the hand-written web is over
05:58dunderprotohave any of you read Paul Graham's On Lisp?
05:58dysfunthe hand written web has been dead for a while, but the corpse is still twitching
05:58dunderprotothe book really piqued my interest but I wasn't sure how much of it would be applicable to clojure
05:58sobelsure, but let's not confuse the throes of death with viability ;)
05:59dysfun:)
05:59Empperijavascript is the new assembly
05:59Empperiyou see ppl writing raw assembly code too
05:59Empperi:)
05:59dysfundunderproto: it's been a long time since i read it. i'm happy to help you with specific questions
05:59sobelEmpperi: yup, and there will always be people getting in deep to tweak things. i mean, someone implemented the logic gates that execute the machine code, right?
06:00sobelsomeone had to smelt the silicon and actually touch pre-hardware
06:00dunderprotodysfun: do you think it'd be worth reading? I was looking for a book that would teach me how to write macros for clojure. I saw some folks recommend On Lisp
06:00sobel(yuck!)
06:00dysfundunderproto: frankly i'm a bit down on paul graham these days. and i really wouldn't recommend reading how to write macros in the wrong lisp in order to learn them in clojure
06:01dysfunreading *about* macros in lisps, sure, but if you want to learn how to write macros, no, i wouldn't say it's a good idea
06:02sobelis there a koans chapter just on macros? :)
06:02dunderprotodysfun: ah. I appreciate the advice. Maybe I will keep looking.
06:02dysfuni forget which lisp graham favours. clojure macros are a bit like hygienic macros in scheme
06:02dysfunwe have different (imo better) syntax
06:03sobeli'm also useless at macros so far and figure i should eventually get introduced
06:03dunderprotoGraham used common lisp I think
06:03dysfunyeah, common lisp macros are a bit special imo
06:04dunderprotodysfun: what book would you recommend for clojure?
06:04dysfunbut hey, they look like function definitions. except your arguments are all the code between the parens instead of the values they represent
06:05dysfunand you return some code.
06:05dysfunbook choice is highly personal. do you want a practical book or a theoretical one?
06:05dunderprotopractical :)
06:05dysfunhow quickly do you need to feel you've done something to keep going?
06:05kris_In Clojure(Script) how do I dereference an atom which is a different namespace?
06:06dysfunkris_: the same way? @other-ns/atom ?
06:06dunderprotoI have a lot of patience
06:07slipsetdunderproto: why do you want to learn how to write macros?
06:07dysfunin that case, have a look at one of the o'reilly's. i think there's a roughly 50/50 split on preference. read up about them both
06:07slipsetIt seems to me that the clojure community favors data over functions over macros
06:07dunderprotodysfun: thanks, will check it out
06:08dunderprotoI was mostly drawn to lisps because of PG's essay about "beating the averages"
06:08dysfunslipset: well it's more about not using a hammer to crack a nut
06:08dysfunslipset: the further down the chain you go, the more you lose in terms of composability
06:08dysfunso "if you can do without a macro, do" is a good guideline
06:08dunderprotobut yeah, I do understand that some of the techniques may not be as ideal or idiomatic for clojure
06:08slipsetdunderproto: same thing for me, but I've yet to figure out the macros are great thingy
06:09dysfunmacros are pretty great
06:09oddcullydysfun: that's how i usually do it. well last time i used a big skrewdriver for the chestnuts
06:09Empperi"the first rule of macro-club is that you don't write macros"
06:09slipsetBut I can see that in 1995, when there was little support for web programming, you could probably do a lot with macros to help that situation
06:10dysfunfor example, how many times have you been tidying up code and thought "i wish i could generate the try/catch" ?
06:10Empperi"the second rule of macro-club is you'll still avoid writing that macro"
06:10ddellacostadunderproto, if you're not familiar with macros and want to learn how to write them in Clojure, take a look at the chapters in Clojure Programming and Joy of Clojure
06:10Empperi"the third rule of macro-club is you should write that macro since you got this far in the rules"
06:10kris_@dysfun thanks, I was doing other-ns/atom (no @)
06:10slipsetEmpperi: sounds like Knuths optimization rules.
06:10dysfuni see macros largely as "the last stage of boilerplate removal"
06:10Empperipretty much
06:10Empperimacros give you insane power but they come with a cost
06:10dunderprotothanks dysfun and everyone else
06:11dysfunbut you know what the real thing is?
06:11slipsetdunderproto also remember, you cannot pass macros around
06:11dysfunit's that you're writing programs that read and write programs. and it's not that hard
06:11slipset(map some-macro myvec) will not work
06:11dysfuni can write a macro without a second thought to do what i need because it's easy when you've done it for a while
06:11Empperithere are some clojure.core macros which are macros for a good reason and still they bite me in my arse time to time
06:12Empperimy favourite two are 'and' and 'or' macros
06:12dysfunanyone who's ever written macros for a non-lisp will know what i mean here
06:12Empperiwish I could sometimes do: (apply and list-of-predicates)
06:13Empperibut you can't
06:13Empperinot with 'and'
06:13dysfunhowever, every-pred does that
06:13Empperiyes
06:13Empperithere are other cases too though
06:14Empperibut anyway, a good example of one of the prices to be paid when you go the macro-way
06:14dysfunyou should go read up about f-expressions. slightly different than macros, but pretty equivalent
06:14dysfunand yes, not being able to use macros in higher order stuff is a bit of a pain
06:15slipsetBut back to Graham, I still fail to see how my writing macros make my life so much easier.
06:16slipsetI can see the value of eg the go-macro, but it would not be for me to write.
06:17slipsetAnd so, to me the go-macro could just as well be a feature of the compiler
06:17slipsetI can also see that as a designer of libraries, macros can be nice, but I'm just a lowly consumer of such.
06:19dysfunwell for example, i've got a simple macro 'safely' that wraps something in a try/catch
06:19dysfunit's just a nice little touch to tidy it up
06:20EmpperiI use macros especially with tests
06:20Empperi(with-clear-database ....) etc
06:23dysfunright, now to see how well boot-reload works with a custom ring handler
06:23sobelso, how long until i'm one learning all the basic functions like every-pred?
06:24dysfunnever?
06:24sobelone=done
06:24dysfunkeep https://clojure.org/cheatsheet/ open in a tab
06:24sobelfair
06:24sobelit's already up
06:24sobelhadda ask
06:24dysfun:)
06:25dysfunit's quite pleasing when you realise you have a useful working set of them in memory
06:36sobeli'm close but i still write more code than i have to, just because i don't always have the right ones yet
06:37stianit's a lisp, there will always exist a shorter way of expressing your forms - no matter your level ;)
06:40TEttingeryep
06:41TEttingerI can still probably code-golf some of my one-liners further
06:41TEttingerbut clojure is an amazingly good language for code golf
06:47dysfunyes, except that unlike golfing e.g. perl, your code tends to become cleaner because golfing is more about figuring out how to do the same thing with better use of builtins
06:52TEttingerdysfun, excuse me, but my golf game must be on another level, since my clojure golf code starts out getting more readable and then gets much, much less readable once I start treating strings as sequences of chars and other useful but confusing tricks
06:52TEttinger:)
06:56TEttinger,(map partition [1 2 3] (repeat "The Quick Brown Fox"))
06:56clojurebot(((\T) (\h) (\e) (\space) (\Q) ...) ((\T \h) (\e \space) (\Q \u) (\i \c) (\k \space) ...) ((\T \h \e) (\space \Q \u) (\i \c \k) (\space \B \r) (\o \w \n) ...))
06:56dysfunyour output is unreadable, but that's a different thing :)
06:56TEttingerheehee
06:57TEttingerstill, clojure is loaded with really handy features for golf that turn out to be useful in many more cases
06:57dysfunheh
06:57Foxborono20aføsldkfjsadx20
06:57Foxboronwops
06:57TEttingerthough I doubt myself that golf is an intended goal, some other lisp users have suggested that
06:58dysfunFoxboron: you might want to change that ;)
06:58TEttingerFoxboron, especially since this channel is publically logged
06:58FoxboronNot a password actually
06:58Foxboronme typing randomly as irssi hung up a few sec
06:59TEttingerhaha
06:59stianor just golfing :)
07:00dysfuni think he missed if that was golf :)
07:00oddcullyi find codegolfing a good way to actually learn about all that fancy functions
07:15borkdudeI have a problem that I would like to discuss. I have a form with a rich text editing field in which users can upload pictures. I want to use a uuid to keep track of which form post the pictures belong to. The pictures are posted before the form. Is this a good approach?
07:15dysfunit's not an unreasonable approach. why uuids though?
07:16borkdudedysfun because I need some identifier
07:16dysfunyou can create one of those by obtaining the next sequence id for the post
07:16dysfunor by inserting a partial record with some flag
07:18borkdudedysfun the first option: this can pose a race condition. the second option seems ok to me, but more complex than using a uuid, because I won't have to clean up records if users decide not to finish their submission
07:18dysfunactually, you're going to have to clean out the images table
07:19borkdudedysfun true
07:20dysfunthere are merits to both approaches
07:20dysfuni'm not going to pretend to know more about your code than you :)
07:21borkdudedysfun well, I bet I'm not the first dealing with this specific problem :) Maybe other just upload the pictures and leave them lingering without even touching upon this problem?
07:21dysfuni expect in most cases they insert a partial record and then never clean up
07:22borkdudeok
07:25mavbozoborkdude, that's a good idea. btw, what db do you use?
07:25borkdudemavbozo mysql (legacy choice)
07:26mavbozoborkdude, and the uuid is just a standard uuid without indexing on the table?
07:26borkdudemavbozo yeah
07:27mavbozoborkdude, don't you a little a bit worried about the query performance?
07:27zoti'm trying to use a cljx-based project and run lein install to test the jar locally with another package, but the actual source files never make it into the jar. project file is here: https://github.com/benfleis/datascript/blob/feature/clojure-port-v2/project.clj . anybody see where i'm going wrong?
07:28borkdudemavbozo well, the uuid is just to prevent garbage. For example I could check if there are pictures with an unknown uuid on S3 and clean then. in the database I use an integer id also.
07:28borkdudemavbozo in other words, there won't be a query using the uuid
07:29zotand at the moment, i don't even care whether the cljs makes it in, just the clj would be enough
07:30acron^I have an atom set, which holds hashmaps. Is there any way for me to alter a single hashmap in the set without swap! disj, swap! conj combo ?
07:32zotacron^: you mean you have sth like (atom #{ { … } { … } })? if so, how do you match elements of the set? (or is it a sorted set and you do some range matching or sth?)
07:32acron^zot: each hm has an :id
07:33mavbozoborkdude, well, for once then, i thought you use uuid as primary key, or index on the table.
07:33acron^(atom #{ { :id 4 … } { :id 6 … } etc })
07:33acron^it's not sorted, the ids are uids
07:33zotacron^: in your shoes i would mod it to be hm -> hm, with the id being the key, and do swap! update-in … (or assoc-in …)
07:34borkdudemavbozo well no. I would generate a uuid client side. Upload pictures in the rich text editor with the uuid as an extra parameter to keep track. The pictures would end up on S3. Then the user submits the form. The uuid is just an extra field, so I know which picture belongs to which form post.
07:34zotunreferrable data inside the atom just sounds needlessly tricky to me
07:34borkdudeAnother option is just to analyse the html and generate a list of used and unused pictures.
07:34zoterr, un-path-map-able
07:34acron^so you mean i shouldn't use a set?
07:35zotmeaning that there's no obvious sequence of keys that tells you what's what. even a vector would be an improvement, where you could do update-in with the vector index.
07:35zotacron^: imho
07:35zotif you're updating those things, are you expecting it to keep uniqueness for you as you make changes? that would be the only reason i can imagine, but that sounds unlikely to me
07:37acron^ok, i am a novice clojure users so my motive for using a set is flaky
07:37acron^lets say I change it to vec
07:38dysfunborkdude: there's another option. you could embed the image directly in the html with src="data://"
07:38acron^is there still no better way than removing and re-adding an element to the atom? (swap! disj, swap! conj)
07:38dysfunthen when the user posts it, strip them out and save them properly
07:39oddcullyswap! #(conj (disj %)) ish
07:40acron^:o
07:41zotacron^: if your structure looks like [ {:k1 1, :k2 2}, {:k3 3, :k4 4} ], (swap! <thing> assoc-in [0 k3] 1000) will work
07:41zotoops, s/0/1/
07:41zotfor the array index
07:41zotalthough in my example k3 would be added to the 0th element with a new val of 1000
07:42zotusing 1 would update k3 in the second
07:42acron^zot
07:42acron^that's perfect, thank you
07:43acron^(inc zot)
07:43lazybot⇒ 1
07:43zotyw
07:43oddcully,(doc replace) maybe then
07:43clojurebot"([smap] [smap coll]); Given a map of replacement pairs and a vector/collection, returns a vector/seq with any elements = a key in smap replaced with the corresponding val in smap. Returns a transducer when no collection is provided."
07:46oddcully,(into #{} (replace {{:id 1} {:id 42}} #{{:id 1}}))
07:46clojurebot#{{:id 42}}
08:06hellofunkanyone have first-hand experience with the first and second editions of Joy of Clojure and can comment on the significance of their differences?
08:33nicferrierif I use a gensym in a macro it's compiled to the evaled name right?
08:33nicferrierit won't gensym in the byte code... it'll be the name.
08:33nicferrierI've written a macro to wrap a function in a child process
08:34nicferrierso it starts the process and then calls the function that you specify in the child process.
08:34justin_smithnicferrier: like future but in a new vm?
08:34nicferrierit does that by calling the same clojure program you are running ... but with an argument.
08:34nicferrieryeah. similar.
08:34nicferrierit's just to protect code that crashes.
08:35nicferrieryou could use a bash while loop... but trust me... there are reasons why not.
08:35nicferrierit's just the basic supervisor pattern
08:35justin_smithI'm all too familiar with craziness from bash while loops
08:35nicferrieranyway, I'm using a gensym for this arg
08:35nicferrierjustin_smith: well, it's more the organization I'm in. but anyway.
08:36nicferrierand it appears the gensym is different on either side of the child process.
08:36justin_smithgensym is not deterministic
08:36blashyrkhi! is there a way to do something like a "case-let" ? in terms of regular java it would be some thing like int x; if(something) x = someFunction() else x = someOtherFunction();
08:36justin_smith,(gensym "hello")
08:36clojurebothello27
08:36justin_smith,(gensym "hello")
08:36clojurebothello52
08:36justin_smith,(gensym "hello")
08:36clojurebothello77
08:37nicferrierjustin_smith: yeah. but surely if I make a macro with the gensym it'll be gen'd at compile time and the gen'd value will be used in the bytecode?
08:37justin_smithblashyrk: ##(let [a (if (> (rand) 0.49) 42 :else)] a)
08:37lazybot⇒ :else
08:39justin_smithnicferrier: I'm less sure of that
08:39blashyrk@justin_smith I know I could do it that way I was just checking if there was a shorter way, macro or something. thanks :)
08:39nicferrierjustin_smith: yy. it's tricky enough at the best of times.
08:39justin_smithblashyrk: I can't think of anything that would be more concise than if
08:40blashyrksomething like
08:40blashyrk(case-let [foo condition set-if-true set-if-false])
08:41blashyrkit's not that big of a deal really, I am just constantly trying to learn the tricks and was wondering if something like this was implemented
08:41justin_smith(let [foo (if condition set-if-true set-if-false)]) has exactly the same character count
08:41justin_smithit's literally the same number of symbols
08:42justin_smithblashyrk: but if you really want that syntax, it would be a relatively easy macro to write
09:44hellofunk anyone have first-hand experience with the first and second editions of Joy of Clojure and can comment on the significance of their differences?
09:49not-much-ioHas anyone had indentation problems with Clojure in the graphical variant of emacs? (24.4.1) It *displays* that the indentation is off although opening in emacs in the terminal or another text editors shows the indentation is correct.
09:51f3ewnot-much-io: tabs vs spaces?
09:53borkdudenice that this works: (assoc nil :foo "bar") ;;=> {:foo "bar"}
09:53borkdudeclojure is so forgiving
09:54mavbozo,(get get get get)
09:54clojurebot#object[clojure.core$get "clojure.core$get@bb699c8"]
09:54not-much-iof3ew: I've never understood the tabs vs. spaces debate, I've used tabs. In the recent Stackoverflow survey there was a almost 50/50 split... What's the deal? Some press tab others click space multiple times?? :D
09:55nicferriernot-much-io: no. their editors press space multiple times.
09:55justin_smithnot-much-io: sounds like you have a bad default font (maybe not a fixed width)
09:55nicferriernot-much-io: tabs are "bad" because you can vary what the tab is and that might change how the file looks.
09:56not-much-iojustin_smith: the font is the same in both the terminal and GUI
09:56mavbozo,(get get nil get)
09:56clojurebot#object[clojure.core$get "clojure.core$get@bb699c8"]
09:56justin_smith,(get (gensym) (gensym) 42)
09:56clojurebot42
09:56not-much-ionicferrier: If their editors press space for them, then how many times it presses can also vary right?
09:57justin_smithnot-much-io: the difference is varying on creation vs. varying on display
09:57justin_smithwhen it varies on creation, the author can fix any errors
09:57justin_smithwhen it varies on display, the author just looks like they are incompetent because the indentation is broken
09:58mavbozo,(get nil nil 42)
09:58clojurebot42
09:58nicferrierbut some people say "but then I can adjust the indentation"
09:58justin_smithclearly we need code editors with css support
09:58not-much-iojustin_smith: Ahso, okei, well that makes sense. I have to re-evaluate my life now. Spaces it should be then?
09:58mavbozowait til you see clojure's java source code
09:58nicferrier not-much-io it really should, yes.
09:59not-much-ioIs there some easy step to switch from tab to space in emacs or should I just start googling?
09:59tomjackhttps://books.google.com/books?id=n8AOBwAAQBAJ
09:59tomjackkind of frightening
09:59justin_smithnot-much-io: untabify-region
10:00justin_smithtomjack: yuck
10:00justin_smithtomjack: that look-inside is so terrible
10:01oddcullyis it me not allowing google executing javascript or is this just MD-ish code printed as book?
10:01justin_smithtomjack: and the authors who make crap books like that do review spam too
10:01justin_smithto make the books look popular
10:02tomjack:(
10:02justin_smithoddcully: MD-ish?
10:02tomjackmaybe before long the books will actually be valuable
10:02justin_smithoddcully: it's a terribe book, probably written by a crappy mail-merge macro in microsoft word
10:02oddcullysection 3 -> `* Groovy (programming language)|Groovy`
10:02justin_smithyeah
10:03justin_smithmacro-generated
10:03justin_smithput on the store in the hopes they can trick someone into buying it
10:03justin_smithI bet every single book they publish uses the same stupid template
10:03oddcullyshould have used TeX ;P
10:03borkdudeis this an autogenerated bok?
10:03borkdude*book
10:03justin_smithyeah - it's a whole genre of crap
10:03not-much-iojustin_smith: I think it might have fixed it but, configuring the space to indent like tab did?
10:03oddcullysection 4 -> headline on page end
10:03borkdudeit indeed looks like crap
10:04oddcullythat looks like what my firefox generates when i generate a pdf
10:04justin_smiththey generate books, make it look like something that might be valuable, and hope someone buys it. They use sockpuppet accounts to make fake reviews to make the books look popular.
10:04justin_smithhuge scam
10:04justin_smithI mean, if it was just a formatting issue, you would find some content in the book
10:05justin_smithbut no, it's not just badly formatted, it has no useful information
10:05justin_smiththere are literally people who generate books with markov chains, then combine randomized keywords to generate a title
10:06justin_smiththere's no cost to publishing the stuff, and if anyone is stupid enough to buy, jackpot
10:06tomjacksorry, hope I didn't ruin your morning :)
10:06justin_smithhaha no, I'm sorry for the rant
10:06justin_smithI just really hate people that do that
10:06oddcullyrant away
10:07oddcullyclears the system
10:10tomjackI found the book in my search for a solution to this hilarious problem: https://www.refheap.com/2ab934158d7df2615f7bdf6fb
10:10oddcullydid it help?
10:11tomjack(org.eclipse.jdt.core)
10:11justin_smithtomjack: wait, is that a thing that actually works?
10:11tomjackwhy on earth would someone make a .java -> AST library where the AST nodes print _as .java source_??
10:11lazybottomjack: Uh, no. Why would you even ask?
10:11justin_smithoh yeah, eclipse basically has its own java parser, huh
10:11tomjackjava brain poisoning I guess
10:11justin_smithhaha
10:12justin_smithbut you can still access the ast data, right?
10:12tomjackyeah, but I have to apparently write a library which converts their AST into data, which just makes me "ugh"
10:14justin_smithtomjack: just because the printed form is java source doesn't neccessarily make the data harder to access though does it?
10:14tomjackAFAICT it means you have to go to the javadoc or inspector to see what's available, instead of just printing
10:15justin_smithtomjack: but most printed forms for java objects are totally useless
10:15tomjackyes, I guess I should not be surprised :(
10:29not-much-ioI am confused with how to switch from using tabs to using spaces in Emacs. From here -> http://emacsblog.org/2007/09/30/quick-tip-spaces-instead-of-tabs/ It says just use '(setq-default indent-tabs-mode nil) but for me tabs keeps working and space is still a single space. Is there no easy way to pretty much keep using space just let it use spaces?
10:29not-much-iokeep using the tab button *
10:30dysfunis there a clojurescript equivalent of http://www.clojure-toolbox.com/ yet?
10:35justin_smithnot-much-io: after you do that, the tab key should insert multiple spaces
10:35justin_smithas apropriate for your mode's indentation
10:36justin_smithnot-much-io: something very helpful is M-x whitespace-mode
10:37not-much-iojustin_smith: That is very helpful, I now see that thespaces in the GUI emacs are shorter than the spacen in the CLI
10:38justin_smithyeah, like I was saying, proportional font
10:38justin_smitheven in a terminal, a proportional font will display as fixed-width, it's a limitation of the CLI
10:40not-much-iojustin_smith: If I look really close, they might really be different, but really similar. Alright thanks, I'll experiment with the font.
10:40not-much-ioHave I understood correctly that if someone helps you out you '(inc that-user) for clojurebot? :)
10:41justin_smithwithout the quote, and it's lazybot that does it
10:41justin_smithbut yeah
10:41not-much-ioI quoted to not trigger the inc :D
10:41not-much-io(inc justin_smith)
10:41lazybot⇒ 237
11:34tomjack,(:foo #{:foo}) ; whoa
11:34clojurebot:foo
11:38calvinfroedgeCan anyone tell me if something like this is possible? (defn foo [a & [b c :as args & d]](prn d))
11:39calvinfroedgeI want to bind b and c to :args, but also have d
11:45mavbozo,(defn foo [a & [b c :as args & d]](prn d))
11:45clojurebot#error{:cause "Unable to resolve symbol: d in this context", :via [{:type clojure.lang.Compiler$CompilerException, :message "java.lang.RuntimeException: Unable to resolve symbol: d in this context, compiling:(NO_SOURCE_PATH:0:0)", :at [clojure.lang.Compiler analyze "Compiler.java" 6535]} {:type java.lang.RuntimeException, :message "Unable to resolve symbol: d in this context", :at [clojure.lang.Ut...
11:47calvinfroedgemavbozo: See = ) Great mystery.
11:49justin_smith,(defn foo [a & rst] (let [[a b & d] rst args [a b]] d)
11:49clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
11:50justin_smith,(defn foo [a & rst] (let [[b c & d] rst args [b c]] {:a a :b b :c c :args args :rst rst}))
11:50clojurebot#'sandbox/foo
11:50justin_smith,(foo (range 10))
11:50clojurebot{:a (0 1 2 3 4 ...), :b nil, :c nil, :args [nil nil], :rst nil}
11:50justin_smith,(apply foo (range 10))
11:50clojurebot{:a 0, :b 1, :c 2, :args [1 2], :rst (1 2 3 4 5 ...)}
11:52calvinfroedgejustin_smith: Nice work! Thanks a lot.
12:17borkdudeordnungswidrig I'm using :handle-request-entity-too-large (fn [ctx] {:error "My error"}) and I get this error: No method in multimethod 'render-map-generic' for dispatch value: null. What could it be?
12:19borkdudeordnungswidrig I'm reading this https://github.com/clojure-liberator/liberator/issues/94
12:40favetelinguiswhat am i not understanding with features: http://lpaste.net/130495 why is this code not printing anything 4sec?
12:40favetelinguisfutures that is :)
12:48justin_smithfavetelinguis: "I will print after 4 sec" is not a function
12:48justin_smithfavetelinguis: if you deref the future, you'll see the exception thrown
12:48favetelinguishehe i saw it now, thanks
13:27favetelinguisdoes core.reducers support trancducers? if not will they in the future?
13:48zanesIs there any reason why `(go (<! (async/timeout 1000)))` should behave differently than merely `(async/timeout 1000)`?
13:53whodidthisnot sure if im using splice correctly but if i run #?@(:clj [(def a 1) (def b 2)]) how come only a gets defined
13:54Bruce_Waynedoes anyone know how to render a link in reagent?
13:56Bronsawhodidthis: wrap it in a (do)
14:00dnolenzanes: those those don't mean the same things
14:01zanesdnolen: Sorry, (<!! (async/timeout 1000)) and (<!! (go (<! (async/timeout 1000))).
14:02dnolenzanes: what do you mean by "behave differently" then?
14:03zanesYeah, let me get you a more complete example.
14:07zanesdnolen: False alarm.
14:08zanesI’m writing a test and one of the go blocks was using Thread/sleep.
14:16zanesI thought the test was deadlocking with `(<!! (go (timeout…` and not with `(<!! (timeout`, but I was wrong.
14:19ncthom91hi all. When I use a `go` block in the middle of my function body, does the go block execute in a separate thread while the execution of the remainder of my function continues?
14:19ncthom91or does the remainder of my function wait for that go-block to finish
14:19ncthom91I think it's probably the former, yea? Cause the go block immediately returns a channel
14:22zanesncthom91: The former.
14:22ncthom91zanes cool, thanks
14:22zanesIf you want to block until it’s finished you can call `<!!` on the channel returned by `go`.
14:23ncthom91zanes i took a slightly similar, but essentially equivalent (i think?), approach by removing the (go) block and changing my >! call inside the go block to a >!!
14:23zanesYeah, that works!
14:24saik0having some trouble improrting clojure.data.priority-map https://gist.github.com/anonymous/cc6ffaa0c58442890f95
14:24ncthom91sweet. zanes my other question is, this function itself actually runs inside a go block from the calling function, so all of this happens in a separate thread right?
14:25zanesncthom91: So, like, `(f (go ((fn [] (>!! c :thing)))))`?
14:25zanesSomething like that?
14:25ncthom91Well I have a function `update` and inside update I make my >!! call
14:26ncthom91But `update` gets called from a different function with (go (update x y))
14:26zanesBut regardless: Yes. If a function calls another function inside a go block the called function is executing in one of the go threads.
14:26zanesYes, totally. That’s happening in one of the go threads.
14:26ncthom91sweet.
14:26ncthom91What happens if my `update` function does IO?
14:27ncthom91in terms of what code runs in what threads?
14:35mavbozosaik0, priority-map function call should've been (clojure.data.priority-map/priority-map :a 1 :b 2)
14:36saik0mavbozo ah, got it. thanks
14:38mavbozosaik0, because the namespace is too long, you might want to alias it (:require [clojure.data.priority-map :as pm])
14:38mavbozosaik0, might help the eye spotting what's wrong
15:09lemonodorif you’re into gorilla (or planespotting), this has been a fun worksheet I’ve been working on: http://viewer.gorilla-repl.org/view.html?source=github&amp;user=wiseman&amp;repo=orbital-detector&amp;path=stats.cljw
15:17kwladykawhat is the right architecture in functional language like clojure? i am talking about things like MVC, Enitity, Boundary, Interactor etc. What is the right way to separate UI, use cases and DB? How to do that right in Clojure?
15:19kwladykaIt will be greate if somebody can give some real example of project like web app where the UI is undepended code, and the core is the core, and DB is independed, easy to change.
15:19pbxkwladyka, what do you mean by "undepended" and "independed"?
15:20pbx(not that i have an example handy)
15:20eceliskwladyka: check luminus
15:21ecelishttp://www.luminusweb.net/
15:21ecelisthere is no such thing as "right way"
15:22aaelonyhow does luminus facilitate transfer of dat structures from clojure to clojurescript?
15:22kwladykapbx, sorry, it should be "independent"
15:24mavbozokwladyka, see http://modularity.org/index.html. malcolm sparks is in the process of writing a book which i think would be a good answer to your question. It's still a draft for now but there are some ready-made leiningen templates.
15:24kwladykaecelis hmm so another quesion is: should use web framework in Clojure or just ring+compojure? What more gives thing like luminus? I am sorry about that question but i am learning Clojure and it is my first functional language, so i am confuse sometimes.
15:26kwladykamavbozo thx
15:27mavbozokwladyka, you wrote Interactor, that's interesting choice of term. Where did you know about that term?
15:27mavbozokwladyka, i only heard it from uncle bob videos
15:27kwladykamavbozo clean code, episode 07 about architecture
15:27kwladyka:)
15:29kwladykai feel how i am doing this now it is bad... and i am looking solution everywhere... and the worst thing i don't understand how to write in functional language yet. but i am pretty sure how i did this in OOP it was bad and i never liked that :)
15:29kwladykai feel myself all should be divded as much as possible
15:29mavbozokwladyka, ah, so you have previous experience building webapps. If that's the case, then I recommend you to dive straight in making website in clojure.
15:30kwladykathe on thing is use for example AngularJS, Clojure to write backend, and DB. It is good step. But... how to do that without AngularJS? I am not sure how to do right architecture then.
15:30mavbozokwladyka, yogthos's book Web Development in clojure will guide you https://pragprog.com/book/dswdcloj/web-development-with-clojure
15:33kwladykaAdding things liek AngularJS makes this easier, because i have separated UI in natural way and i can communicate by JSON. But how to do that if i will use static pages?
15:33kwladykathis book will answer for that question?
15:34kwladykaand even if i use AngularJS or static pages... details about core are important too.... is there any conception like MVC, but for functional language?
15:35mavbozokwladyka, the book will help you get real experience creating websites in clojure. besides, the book starts with a familiar MVC pattern.
15:36kwladykammm but i feel MVC is really bad way to do projects. I need solution for architecture now, not how to use tools in Clojure.
15:36mavbozokwladyka, i think it helps having some practical coding with clojure first before continuing on with answering your question
15:37kwladykai will start do some web app anyway to learn, this process of learning is obviously. But i am not sure how to learn creating of good architecture.
15:38kwladykamy main think is: architecture should be true image of business model, easy to read, easy to write, extermly elastic - it has to be done in some way.
15:38kwladykaespecially with Clojure :)
15:41mavbozokwladyka, there are good books-- https://leanpub.com/building-a-system-in-clojure and this https://pragprog.com/book/vmclojeco/clojure-applied, and video presentations to help you answer your question about architecture in clojure application such as
15:41mavbozoweb application
15:41bacon1989I've been meaning to grab that book
15:41kwladykathx, added to read :)
15:41mavbozoor business model
15:41bacon1989but I like physical books :(
15:41mavbozobut i don't think it's not for clojure beginners
15:42bacon1989do you know if it's coming out to paperback anytime soon?
15:42bacon1989mavbozo double negative
15:42mavbozocorrection, i think it's not for clojure beginners
15:42bacon1989;)
15:44kwladykamavbozo there is only one way to not be beginner, i has to read things like that and try to understand :)
15:44mavbozokwladyka, i still think you learn creating good architecture by studying -> doing -> review -> discuss
15:44bacon1989ah, the paperback release is at the end of the year
15:44mavbozokwladyka, you discuss it here
15:44bacon1989I might get it
15:45kwladykamavbozo yes but i don't want research whole wheel again.
15:47eceliskwladyka: luminus includes bootstrap for the front end, but its my guess it can be easily changed to use angular
15:47ecelisor any other front end framework for that matter
15:48ecelisbut you can also choose to use bare compojure or ring, it depends on your needs really
15:48kwladykaok so another question is: what should use for web apps? In the Internet it is a lof of informations but out of date. Use rings+compojure? Or lumius or something else? Mayby right question should looks: when use which one? Example if i want write e-store app as independent core and connect with that web intefrace or mayby later even mobile phone interface. Which tools should i use?
15:48eceliskwladyka: try yourself, there is no absolute answer of what tools to use
15:49bacon1989kwladyka: most people use compojure+ring
15:49ecelisit depends on programmers needs, taste, background, etc
15:49weavejes_kwladyka: Luminus is a project template, rather than a framework in the same sense of Rails or Django.
15:50saik0i have a collection of infite seqs, I'd like to "make" str print something like '((first seq) "LazySeq@xxxxxx"), it would be handy for experimenting.
15:50kwladykaweavejes_ what do you mean "project template"? I should understand that like get other libraries as dependency but zero lumius code?
15:51mavbozokwladyka, starts with instructions from yogthos's book web development with clojure. It makes you focus building your web app quickly without overwhelmed by various ways and toolings in clojure.
15:51mavbozokwladyka, and then you can review it based on your previous knowledge about building good architecture.
15:51kwladykamavbozo but tools are very important, i don't really want miss that
15:51weavejes_kwladyka: If you run "lein new luminus foo", then Luminus will generate a new project for you called "foo". It'll include a number of dependencies, such as Compojure and Ring.
15:52kwladykai want do this in 80% or something like that and later finish that research :)
15:52mavbozokwladyka, we can not hope to understand everything in this world.
15:52mavbozokwladyka, if you want to learn good architecture, then focus on that.
15:54kwladykajust i have to start with something, so i am doing quick research about tools and architecture to decide which tools i will use first and in what way :)
15:54weavejes_kwladyka: Luminus is essentially a way of getting started. It's not really a framework, since it doesn't include its own code in the template, as far as I'm aware.
15:54mavbozokwladyka, agree with weavejes_
15:55mavbozokwladyka, luminus is a good way to start
15:56kwladykai did lein new luminus foo and looking on code now :)
15:56mavbozokwladyka, great!
15:56kwladykais ther more tool wich i should be interested in?
15:57ecelisbesides leiningen and your text editor, I don't think you need any other tool :)
15:57mavbozokwladyka, git as scm and heroku to deploy your webapp
15:59kwladykaDo you think Light Table is good? Or is it not ready yet?
15:59mavbozokwladyka, Light Table is good for clojure beginners
16:00kwladykamavbozo but not for clojure pro?
16:00justin_smithkwladyka: it has some cool features that can definitely help you figure out clojure, but eventually most people move to a more normal editor or ide
16:00justin_smithkwladyka: no reason not to try it
16:01mavbozokwladyka, Light Table is used as editor in yogthos's instructions in web development with clojure
16:02mavbozokwladyka, i dont' want you get distracted from your architecture focus
16:03kwladykamavbozo yes, anyway i think i will use light table for a while, becuase too many things too learn
16:04bacon1989kwladyka: no no no, you should jump right into emacs
16:04mavbozoand ends up studying emacs architecture instead
16:04arohnerbwhaha! leinception! https://github.com/arohner/lein-docker#lein
16:05kwladykaok, i checked how luminus build start architecture but still i don't have answer about how to build architecture to be image of business model, not technical separation. I think it is really hard issue :)
16:05mavbozokwladyka, try put all your business model code in separate namespaces first.
16:06kwladykamavbozo i will try but... it will be glad to see how sombody did this
16:06kwladykafrom my live experience it is always better to first look how other did things :)
16:15kwladykaok, i am tired today, its time to a little rest and play bloodborne game :) thank you for your time and see you later! :)
16:17dfinningerGah, 2 hours left until I can get back to Bloodborne!
16:21bacon1989is bloodborne like dark souls?
16:21bacon1989I don't know anything about that franchise
16:29bacon1989already i'm enjoying this applied clojure book
16:29bacon1989I didn't know about the map->record function
16:30bacon1989it was kind of why I shyed away from using records that were more than 3-4 parameters
16:57brainproxyany examples of a (relatively) simple transducer stack that terminates early via (reduced ...)
17:00dfinningerbacon1989: yup, basically a more action-heavy dark souls
17:12sidharthaanyone have a nice clojure based web user registration and cookie system they'd like to share knowledge about ?
17:17sidharthaya know.. i'm looking at mozillas' persona ...
18:11danielglauserIn Emacs I have a handy piece that highlights an expr when I'm on the open or close of it. Works for (, [, {, etc. Is there anything similar in Intellij/Cursive land?
18:13cflemingdanielglauser: You mean it highlights the whole expr?
18:13danielglauserYes
18:14cflemingdanielglauser: Cursive will highlight the matching paren, and show the extent in the left gutter, but I don't think there's anything that will highlight the expr. Could you file an issue for that?
18:15cflemingdanielglauser: I've actually been considering something similar for if forms, that would highlight the then and else clauses slightly differently, perhaps in subtle green/red
18:16danielglausercfleming: Funny you mention that, this question was born out of that complaint, folks would like an easier way to see the else part of an if
18:16cflemingdanielglauser: Which I'm hoping will catch some of my stupid "used when instead of if" bugs
18:16cflemingdanielglauser: Oh nice
18:16danielglausercfleming: Link to place to file an issue? Google is not my friend.
18:17cflemingdanielglauser: https://github.com/cursiveclojure/cursive/issues
18:17danielglauserOh cool, it's on Github. Sweet.
18:17cflemingdanielglauser: Just the issues, not the source, sorry
18:17danielglauserGot it
18:19cflemingSome of the source will be up there sometime soon when I get the extension API out there
18:28cflemingdanielglauser: Thanks
18:29danielglausercfleming: np
18:29cflemingdanielglauser: Nice github profile pic too :)
18:30danielglauserThanks! Back when California still had water in it.
18:30cflemingHehe
18:31cflemingI'm in New Zealand, kayaking is pretty huge here - I did some white water stuff a long time ago, but nothing like that
18:33danielglausercfleming: Well, it has been a while since I've done drops like that. New Zealand is awesome for paddling, I've seem some great footage from there.
18:38cflemingdanielglauser: Yeah, lots of nice spots. Lots of sea kayaking around where I am.
18:39danielglausercfleming: Nice! I'm sure hiredman would enjoy that too.
18:55weiwhat’s an idiomatic way to update one element in a vector into two elements? e.g. [1 2 3 4 5] => [1 2 :a :b 4 5]
18:55wei(flatten (assoc-in [1 2 3 4 5] [2] [:a :b])) is one solution, but I’d rather not use flatten
18:58TimMcI think a general-purpose splice fn (as in JS) is called-for.
19:07rukorhi, pls how can one disable source maps for advanced compilation
19:14dnolenrukor: source maps are not enabled by default for advance compilation, also there is a :clojurescript channel
19:14dnolener #clojurescript channel
19:16justin_smithwei: ##(mapcat (fn [[i x]] (if (= i 2) [:a :b] [x])) (map-indexed list [1 2 3 4 5]))
19:16lazybot⇒ (1 2 :a :b 4 5)
19:16justin_smithwei: with a helper function or maybe a macro that can be made a bit more comprehensible, of course
19:17justin_smithmaybe this is better ## (mapcat (fn [i x] (if (= i 2) [:a :b] [x])) (range) [1 2 3 4 5])
19:17lazybot⇒ (1 2 :a :b 4 5)
19:19rukordnolen: thanks, i actually thought i was typing in #clojurescript
19:20wei##((fn [i x coll] (concat (take i coll) x (drop (inc i) coll))) 2 [:a :b] [1 2 3 4 5])
19:20lazybot⇒ (1 2 :a :b 4 5)
21:30Lewixwhats the meaning of seq can be infinite?
21:32justin_smithLewix: a lazy-seq is represented so that you don't realize all the items, you just have a function that you know will get the next item
21:32justin_smithso for example iterate returns a seq that doesn't end
21:32justin_smithor cycle
21:33justin_smith,(nth (cycle [1 2 3]) 1000000)
21:33clojurebot2
21:33Lewixjustin_smith: If I understand correctly seq that are operations such as map, filter, reduce, some , replace are lazy and infinite
21:34justin_smithLewix: iterate is always infinite, cycle is always infinite, map filter and replace are all as long as their input, or shorter
21:34justin_smithreduce is not infinite except in very special circumstances
21:35justin_smithI've yet to use an indefinite return value from a reduce
21:36Lewixjustin_smith: Are sequence backed by functions infinite?
21:36justin_smiththey can be
21:36justin_smithlazy-seqs are backed by functions, they are not always infinite
21:36justin_smithreduce is not lazy, the others you mentioned are
21:36Lewixwhy is (def a-range (range 1 4)) considered infinite?
21:36justin_smithit isn't
21:36justin_smithbut (range) is
21:37Lewixwhy is reduce not lazy while the others are?
21:37justin_smithbecause the point of reduce is to get a single value from a collection
21:38justin_smithif you put your mind to it, you could ensure that single value is actually an infinite sequence, but I haven't seen that in practice, and it wouldn't be derived 1->1 from the inputs like the other higher level transforming functions are
21:39Lewix(def a-range (range 1 4)) as opposed to (range 1 4) doesn't get created until it's called
21:39justin_smiththat's false
21:39justin_smithboth are equally lazy
21:39justin_smithneither are realized until the values are accessed
21:39justin_smithin the repl, def returns nil so you don't access the value at first
21:40Lewix,(range 1 4)
21:40clojurebot(1 2 3)
21:40justin_smiththe side effect of printing is why that gets realized
21:40justin_smith,(do (range 1 4) nil)
21:40clojurebotnil
21:40Lewix,(def a-range (range 1 4))
21:40clojurebot#'sandbox/a-range
21:40justin_smiththat sequence cannot ever get realized ^
21:40justin_smiththe one in the do that is
21:41Lewixok
21:41justin_smithbetter example: ##(do (map println (range)) nil)
21:41lazybot⇒ nil
21:41Lewix(second (range 1 4)) is different from (second a-range) - the former is invoked once while the other twice
21:41justin_smithno
21:41justin_smiththat's wrong
21:42LewixHow?
21:42justin_smithlazy-seqs store their realized values
21:42justin_smithand def does not invoke any of the values
21:42justin_smithnor does using seq directly
21:43justin_smithit's only consuming values (eg with second, nth, print, count) that anything is realized
21:43justin_smithand the values are guaranteed to be realized exactly once
21:43justin_smith,(def foo (map println (range)))
21:43clojurebot#'sandbox/foo
21:43justin_smith,foo
21:43clojurebot(0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\nnil nil nil nil nil ...)
21:43justin_smith,foo
21:43clojurebot(nil nil nil nil nil ...)
21:44justin_smithsee, the println only happens once
21:44justin_smithit's only invoked once
21:44Lewixjustin_smith: so Alan Dipert got it wrong
21:44justin_smithI'd more likely believe you are misreading
21:44justin_smithbut possibly
21:45Lewixjustin_smith: thanks I'll go over it again
21:47Lewixjustin_smith: so you're arguing that (second a-range) is invoked once
21:48Lewixjust like (range 1 4)
21:48Lewixjust like (second (range 1 4) )
21:49Lewix*
21:49justin_smithwait, what exactly do you mean by "invoked" here?
21:49justin_smithas in the thunks being realized? yes, in both cases invoked exactly once
21:50Lewixok thanks
22:09Lewixjustin_smith:
22:10Lewixjustin_smith: "instead of being backed by data like linked lists are clojure sequences are backed by functions so they can be lazy and infinite" - this is a verbatim copy of what I heard
22:11justin_smithright
22:11justin_smithbut the results of those functions are cached
22:11justin_smithso it's true, but perhaps incomplete
22:13justin_smithand they can be lazy and they can be infinite, but some seqs are neither
22:23Lewixjustin_smith: that means that sequences are invoked twice
22:23Lewixjustin_smith: (second (range 1 4))
22:23justin_smithI literally have no idea what you are talking about
22:23justin_smithwhere is the second invocation you are talking about here?
22:24Lewixin linked list you have to pass through the first item to get to the second
22:24justin_smithyes
22:24justin_smithso calling second realizes two elements
22:24Lewixinvoked once for first the a second time for the second item
22:25justin_smithrange is chunked, you would need to consume at least 33 items iirc for two distinc invocations to happen
22:25LewixI meant that it's invoked twice in that specific case
22:25justin_smithno
22:25justin_smithit isn't
22:25justin_smithbecause range realizes 32 items at a time
22:25Lewixit what the same guy is saying ^^
22:25Lewixit got me thinking
22:25justin_smithit's an implementation detail
22:25justin_smithOK
22:25justin_smith,(first (map print (range)))
22:25clojurebot012345678910111213141516171819202122232425262728293031
22:26justin_smithnote that it gave us the first item, but it realized 32 items
22:26tomjackwhew. looks like I was a bit unfair to eclipse jdt: https://www.refheap.com/29f0551b9dab5c11bd8299f2f
22:26Lewix,(set! *print-length* 1000000000000)
22:26clojurebot1000000000000
22:26Lewix,(first (map print (range)))
22:26clojurebot012345678910111213141516171819202122232425262728293031
22:26justin_smithit's going to be 32 every time
22:27justin_smithlike I said, it's an implementation detail, but unless you use anything beyond the 32nd item, there is exactly one invocation that happens
22:27justin_smithbut if you rely on stuff like that you're doing it wrong anyway
22:27Lewixright justin_smith - i care about details though , so you're sayin gthat the 32 items are cached
22:28justin_smithright, there's exactly 1 invocation that realizes 32 items, in that case
22:28Lewixbuok thanks
22:28Lewixfor clarifying
22:28justin_smithwhich is one reason why laziness and side effects don't mix, and if your code relies on a specific number of items from some lazy-seq being realized, it's going to be buggy code
22:29tomjackuser> (first (map print (range)))
22:29tomjack0
22:30tomjackuser> *clojure-version*
22:30tomjack{:major 1, :minor 7, :incremental 0, :qualifier "beta1"}
22:30tomjack
22:30justin_smithtomjack: yeah, I was careful to say "implementation detail" for a reason :)
22:30justin_smithtomjack: this was merely a counterexample to the assertion that you invoked a lazy-seq twice if you get the second item
22:31justin_smithif clojurebot was using beta1, I would pick a different example :)
22:31tomjackmy point was, 'if you rely on it, your code may break' is not just a warning now
22:31tomjackit just broke! :)
22:31justin_smithoh, yeah
22:31justin_smithhaha
22:31justin_smithtrue!~
22:31tomjack(also, I didn't know what the result was going to be..)
22:31justin_smithheh
22:32justin_smithtomjack: now try ##(first (map print [:a :b :c :d :e :f :g]))
22:32lazybot⇒ :a:b:c:d:e:f:gnil
22:33justin_smithgnil
22:33justin_smithgnil is a new nil that takes extra arguments including the standard --help command line flag
22:35tomjacksame result
22:35justin_smithinteresting
22:35justin_smiththe purge of chunks
22:35tomjackno, I mean, same result as before 1.7
22:35justin_smithahh
22:40fitzNormal Java interop can't see private fields, can it?
22:40justin_smithfitz: you can see them via reflection
22:42fitzjustin_smith: that's different than just Classname/staticField, right?
22:42justin_smithright
22:42justin_smithit's trickier (and you can do the same thing in java too)
22:43Lewixjuancate: tomjack ;i guess previous versions didn't have that constrain if I may call it so
22:45Lewix,*clojure-version*
22:45clojurebot{:major 1, :minor 7, :incremental 0, :qualifier "master", :interim true}
22:45tomjackah, interesting
22:46tomjackuser> (first (map print (range 100)))
22:46tomjack012345678910111213141516171819202122232425262728293031
22:46tomjack
22:46tomjack(still 1.7.0-beta1)
22:46justin_smithoh, so (range) is special cased, but (range 100) is not
22:46tomjack(range) is now (iterate inc' 0)
22:47justin_smithaha
22:47justin_smiththat explains it
22:49Lewixuser=> (first (map print (range)))
22:49Lewix012345678910111213141516171819202122232425262728293031nil
22:49Lewix{:major 1, :minor 6, :incremental 0, :qualifier nil}
22:57Lewixjustin_smith: what if i want to print 44 items with range
22:58justin_smiththen it would realize 64 of them
22:58justin_smithwell, depending on clojure version etc. of course
22:59Lewixjustin_smith: I mean how do i do that since it's set to 32 and (set! *print-length* 1000000000000) wouldnt work
22:59justin_smithLewix: clojurebot has weird settings
22:59LewixI see
22:59TEttinger&(doseq [n (range 44)] (print n " "))
22:59lazybot⇒ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 nil
23:00TEttingerlazybot has no print length
23:00TEttinger&(doseq [n (range 444)] (print n " "))
23:00lazybot⇒ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 6... https://www.refheap.com/99487
23:00TEttingerlazybot also has no def, a tradeoff
23:12tomjack(inc cgrand)
23:12lazybot⇒ 2
23:13tomjackhttp://stackoverflow.com/questions/15013458/clojure-zipper-of-nested-maps-repressing-a-trie/15020649#15020649
23:53LewixI'm looking for a benchmark of programming languages - slowest to fastest
23:54Lewixand any advantages/disadvantage of each programming languages. i would have thought that in 2015 we could easily find such a study ^^
23:55justin_smiththere's the alioth.debian.org benchmarks game