#clojure logs

2012-04-04

00:00muhoocheckouts dir, IIRC
00:19muhoook it is NOT me, i don't think
00:19muhooi tried to do "lein jar" in this directory: https://github.com/clojurebook/ClojureProgramming/tree/master/ch08-lein-mixed-source
00:20muhooand it exploded all over my face, Exception in thread "main" java.lang.reflect.InvocationTargetExceptio
00:20muhooCaused by: java.lang.NullPointerException (NO_SOURCE_FILE:0)
00:26muhoooh.... i see
00:26muhoono main
00:26muhoomaybe
00:28muhoonaw, that can't be it.
00:55xeqimuhoo: did you get ch08-lein-mixed-source working?
01:17muhooxeqi: no, it seems to have a bug, or i'm doing something very wrong
01:17muhooit compiles, but won't jar
01:19muhooi'm having another interesting issue. i've been asked to deliver javadoc, but i'm writing in clojure and delivering an aot, gen-class'ed jar
01:19muhooso i'm thinking of writing some kind of tool or lein plugin that'll generate javadoc. but i'd need some serious macro-fu that i don't have yet
01:20xeqihttps://refheap.com/paste/1735
01:20muhoobut having ^doc metatada might make it almost unpainful
01:21muhooxeqi: if zero?
01:21muhoohmm, must try
01:21xeqizero happens on clojure compile success
01:23xeqihmm, that really should be a when
01:23muhoowhy, should it not return the result?
01:24xeqiresult should always be returned
01:24xeqithe if only has one branch
01:25muhoooh i see, that result wasn't the else of the if
01:26muhooworks!
01:26muhooas https://refheap.com/paste/1736
01:27muhooxeqi: why does it work?
01:27muhooit's only going to compile the java if the clj compiliation succeeds?
01:28muhoobut why was the clj compilation failing?
01:28xeqithe lein jar task wants a result from compile
01:28xeqithe robert.hooke call replaced compile with the fn
01:28muhooaha! no return value
01:28xeqithe fn returned the result of javac, which was nil
01:29xeqinow it keeps the result of the clojure compile
01:29xeqiand compiles java on success
01:29muhoohow in the world did you find that? if yyou don't mind me asking
01:29muhooi looked at that stacktrace and couldn't make sense of it
01:30RaynesCheck it out guys, my Elixir build tool works as a Clojure build tool too: https://refheap.com/paste/1737
01:31xeqiI've been working on lein2 for a while, so had a general sense of lein's structure
01:32xeqihttps://refheap.com/paste/1738
01:32xeqiso thats the failure stack trace
01:32xeqithe bottom "Caused by: ..." is the main exception
01:33muhoonumbers!
01:33muhooit wanted an integer, got null. wow.
01:36muhooxeqi: thanks!
01:41xeqiRaynes: Mix.External.run_async_cmd(':(){ :|:& };:') ; can it be a fork bomb too?
01:42Raynesxeqi: It runs an external program, so a random shell command wont work. :p
01:58amalloywell, 'bash -c ":(){ :|:& };:"' might
02:24nedis there a defacto method of using socket.io with clojure/clojurescript/rack
04:02kralmorning
04:04andyfingerhutgood morning. (1am here)
04:04Iceland_jackgood morning (8am here) :)
04:26muhoois there anything special i'd need to do in order to integrate a clojure project with jenkins?
04:30LajlaLEEEEROOOOOOOOOOOOOOOOOOOOOOOOOY
04:30LajlaJEEEEEEEEEEEEEEEENKINS
04:30muhoohahaha
04:31muhoothat's a meme i haven't heard in a while
04:32Fossi\o/
04:32Fossistill diggin it though :D
05:44BorkdudeI have this Eclipse project: http://dl.dropbox.com/u/3914693/practicum5.zip
05:44Borkdudeit is a webnoir website, but the resources folder doesn't seem to be recognized
05:44Borkdudehow do I fix this?
06:10clgvBorkdude: "doesn't seem to be recognized" means resources that are in it are not loaded?
06:10clgvBorkdude: if so, then it might not be on the classpath
06:10Borkdudeclgv: I mean I get a 404 when I request http://localhost:8080/css/tictactoe.css
06:17clgvBorkdude: I dont know the details of static resources in noir. but is it on the classpath when you start the server?
06:17Borkdudeclgv: no, I didn't expect these static resources to be on the classpath...
06:21Borkdudeclgv: I will try...
06:21clgvBorkdude: I just created a new noir project and I can access http://localhost:8080/css/reset.css without a problem
06:22Borkdudeclgv: in Eclipse?
06:22clgvBorkdude: no, I started it via "lein run"
06:22clgvI can try eclipse now
06:22Borkdudeclgv: try it in Eclipse and try to add you own css file
06:22katratxoBorkdude: i tested it, you need to add the resources folder to your project's build path
06:23Borkdudeclgv: the weird thing is, I can request reset.css succesfully, while there isn't such a file in my project...
06:23Borkdudekatratxo: ah... will try now
06:23katratxoBorkdude: under libraries tab, add class folder, and pick the resources one
06:23clgvkatratxo: thats what I thought. I think leiningen does it as default
06:24katratxoclgv: yes, you were right
06:25Borkdudekatratxo: clgv: works!
06:26Borkdudekatratxo: clgv I added it as source folder, but that also works
06:26Borkdudekatratxo: clgv it feels a bit weird though, to add static resources as a "class" or "src" folder
06:27Borkdudekatratxo: clgv What's the deal with reset.css? My browser can find it, while it isn't even there in the projects resources
06:27clgvBorkdude: you just need it in the classpath so that it can be loaded via classloaders
06:28Borkdudeclgv: right, changed it
06:28clgvBorkdude: in a project created from lein-noir it is in resources/public/css/reset.css
06:29Borkdudeclgv: yes, but I only copied the src folder into an Eclipse project
06:29Borkdudeclgv: not the resources folde
06:29Borkdudeclgv: although Chrome pretends the reset.css is just there
06:30clgvBorkdude: you dont have to copy. just create the eclipse project in the folder created from lein-noir
06:30Borkdudeclgv: that's probably the easier way.. ;)
06:31Borkdudeclgv: anyway, tnx for helping me out
06:31clgvBorkdude: I think the reset.css is part of the welcome page that is shipped with noir. so it is probably included in the jar
06:31Borkdudeclgv: aah.... you're right
07:38gregoriusanybody plans an interactive school fo clojure like codeacademy.com ?
07:45wmealingi'm browsing the misaki source code to see how others do things , and i see things like *template-dir* is there anything special about the asterisks around words ?
07:46danlarkinjust convention
07:46danlarkinit's usually used to indicate that var will by dynamically bound
07:47wmealingok.
07:48wmealingthat is something that I don't really know enough about, so i guess there is some reading for me to do, thanks danlarkin
07:51wmealingok, that didnt look too hard.
08:21beenetoIs there a document that gives a primer in clojure coding conventions, indenation and names etc?
08:21beenetoEverywhere points at http://dev.clojure.org/display/design/Library+Coding+Standards but that is pretty specific to writing frameworks
08:22wmealing-ahah :use
08:22wmealingok, i thought there was some macro trickery magic going on, but no.. its just namespace importing trickery.
08:22wmealingof which i'm much more comfortable
08:23kzarJust reading an Android book and it's recommending I upgrade java from 1.6 to 1.7, is that likely to mess up Clojure on my computer?
08:23wmealingdoubt it
08:24gregoriuskzar: nope
08:24kzarphew OK
08:24wmealingi'm doing all my stuff on 1.7, things seem to work
08:24wmealingjava-1.7.0-openjdk-1.7.0.3-2.1.fc16.1.x86_64
08:25kzarActually is there an easy way to do the upgrade on Mac?
08:26gregoriuswmealing: open-jdk is not the same as oracle jdk
08:27wmealingi'm aware. i'm sure there are shiny proprietary bits that make it more server grade.
08:28wmealinghowever if stuff works in this, but not in oracles jvm, maybe its not as enterprisey as they think.
08:33wmealingsorry, had a bad day, debugging oracle issues.
08:36kzarI'm having to learn Java, Eclipse and Android dev :( - Guess which two I'm not enjoying. At least the Java knowledge will be useful for Clojure hacking
08:38wmealingyou can still do android in vim, if thats your game.. you dont need to use the gui.
08:38wmealingi found it much easier not to
08:39kzarWell I use Emacs usually but I found that it was too much trying to learn Java + Android when all the documentation seems to be geared to Eclipse so I eventually gave in. I'll defo look into avoiding it later when I've got my head around some of it
08:40ChironHi Clojurians!
08:41ChironWhat is the idiomatic way to code an iteration inside another? for example (doseq [foo (fooz-generator)] (doseq [baz (baz-generator foo))
08:42wmealingkzar, the sample project are useful to have, if you get random "R" errors, just clean your project and build again.
08:42kzarwmealing: Yea, R.java is generated from the XML right? That confused me initially
08:43wmealingyeah.
08:44hoeckChiron: for, see http://stackoverflow.com/questions/9137660/how-do-you-replace-java-nested-for-loops-in-clojure
08:45hoeckChiron: the first (dnolens) answer is very idiomatic clojure
08:47Chironsomehow, not following it
08:50Chiron(for [foo (foo-generator) baz (baz-generator foo)] ;;; code to operate on baz ) this works?
08:51kzarChiron: Just remember it's lazy so you might need a doall or similar
08:55augustlwant to use clojure to generate a static HTML website, any suggestion?
08:55augustlsomething like Ruby's middleman and jekyll
09:01wmealingaugustl, misaki ?
09:03augustlwmealing: thanks!
09:06wmealingaugustl, i'm using it as a learning tool thats the only reason i know :)
09:06wmealingbut it seems to work okay.
09:06augustlhmm, it seems to enforce a certain path structure
09:07wmealingyou have the source, go at it
09:07hoeckChiron: yes, it works like this
09:08hoeck,(for [foo (range 5 0 -1) baz (range foo)] baz)
09:08clojurebot(0 1 2 3 4 ...)
09:33wmealingcan you reflect on a java object to get a list of its methods in clojure ?
09:34joegalloyes. for starters, you can always just use the java interop stuff for doing it straight up.
09:34wmealingthere is probably some base java function i can call for this.
09:34wmealingok
09:34fdaoudwmealing, for example
09:35joegallobut if you more, there's http://clojure.github.com/clojure/#clojure.reflect
09:35joegallos/you more/you want more/
09:35fdaoud,(map #(.getName %) (.. "42" getClass getMethods))
09:35clojurebot("hashCode" "compareTo" "compareTo" "indexOf" "indexOf" ...)
09:35wmealingboth are very helpful, thankyou
09:50heowAnyone make a namespace explorer? Like if I'm in ns foo.bar.baz and want to go to foo,bar I can type somethnig like (cd "..")
09:58jorendorffExtremely stupid question: why does (get '(1 2 3) 1) evaluate to nil?
09:58jkkramerjorendorff: get is for associative data structures, and a list is not associative
09:59gtrak`vector should work though
09:59jkkramer,(some #{1} '(1 2 3)) ;linear search
09:59jorendorffI guess I would've expected it to throw, though.
09:59clojurebot1
09:59jorendorffYeah, I just switched to vectors, it's fine.
09:59gtrak`,(get [1 2 3] 1)
09:59clojurebot2
09:59jkkramerget is very forgiving. you can pass it pretty much anything
10:00jkkramer,(nth '(1 2 3) 1) ;also
10:00clojurebot2
10:00jorendorffthanks
10:04jtoycan someone point me to what is wrong with this:
10:04jtoy(defn mygrep [id] (with-open [is (clojure.java.io/reader "/mnt/results")] (first (filter (some (fn [x] (re-find (re-pattern (str "^" id "\\s")) x)) (partition-by identity (line-seq is)) )))))
10:04jtoy I get the error: ClassCastException clojure.lang.Cons cannot be cast to java.lang.CharSequence clojure.core/re-matcher (core.clj:4262) when calling like (mygrep 149)
10:06jkkramer,(partition-by identity "aabbcc")
10:06clojurebot((\a \a) (\b \b) (\c \c))
10:06clgvheow: try 'in-ns
10:08jtoyjkkramer: hmmm, it seems my logic is all backwards
10:09jkkramerjtoy: i would break things down step by step. add each transformation incrementally (e.g., using the repl), making sure you get the expected output from each
10:25krlany guides on how to get cljs evaluation from emacs buffers working swank-style?
10:26krlusing lcjs template
10:26krl*cljs-template
10:30jtoyi thought this would be lazy and not store everything in ram: but it dies with out of memory issues: (defn mygrep [id] (with-open [is (clojure.java.io/reader "/mnt/results")] (second ( partition-by #(re-find (re-pattern (str "^" id "\\s")) %) (line-seq is))) ))
10:34rhcjtoy: seems like it would, unless your pattern is matching lots of lines..
10:38jtoyat max 500 lines, that is not a lot
10:39rhcoh wow
10:44edwIs there a built-in that is equiv to (fn [a b] b)?
10:51S11001001jtoy: this function isn't really a grep; are you sure you don't want something using filter instead? If you are sure, I suggest grabbing the partition-by source and removing the `seq' call on the last line.
10:51jtoyS11001001: yeah, grep was a bad name ,but filter and grep are pretty similar?
10:51S11001001yes
10:52S11001001grep is actually (filter #(re-find whatever %) (line-seq r))
10:53S11001001as TimMc was saying yesterday, partition-by is only oddly lazy (lazy in the rest, not in the first). So you hold onto the head of the first group while trying to retrieve the second
10:53jtoyS11001001: I'm just changing it to a grep now and go through the whole file ,i don't understand enough of clojure to write that other smarter version
10:53S11001001(dropping that seq makes it evenly lazy)
10:53jtoyah, i wasn't sure what oddly.evenly meant yseterday
10:53S11001001if you're doing that, then you might as well use filter
10:54jtoyyeah, still something wrong, but I'm closer: (defn mygrep [id] (with-open [is (clojure.java.io/reader "/mnt/results")] (filter #(re-find (re-pattern (str "^" id "\\s")) %) (line-seq is)) ))
10:55lynaghkIs there a way I can adjust the Clojure printer so that all numbers will be printed as floats? E.g., (prn 32M) will print as 32.0
10:57weavejesterlynaghk: I believe you can use format
10:57weavejester&(format "%f" 32)
10:57lazybotjava.util.IllegalFormatConversionException: f != java.lang.Long
10:58weavejester&(format "%0.2d" 32)
10:58lazybotjava.util.MissingFormatWidthException: 0.2d
10:58weavejesterIf I could remember the syntax :)
10:58lynaghkweavejester: I need to alter the global printing function---whatever is used by "pr"
10:59weavejesterlynaghk: Why do you need to alter an already-existing function?
10:59lynaghk(context: I'm using ibdknox's fetch library to send DB results to a ClojureScript app. JavaScript doesn't appreciate numbers like "32M")
10:59weavejesterIsn't that a bug in fetch?
11:00lynaghkweavejester: you could think of it that way. You think the best thing to do is add a codepath in fetch that coereces all numbers to floats?
11:01weavejesterlynaghk: Does fetch communicate via Clojure forms or JSON?
11:01lynaghkweavejester: fetch uses pr-str internally, so injecting the behavior into pr makes the most sense to me
11:01lynaghkclojure forms
11:02weavejesterAh… Hm… I think ultimately I'd say it's an issue with fetch.
11:02lynaghkweavejester: I still want to fix it =)
11:02weavejesterA workaround where all numbers are converted to floats would work until fetch is patched
11:03fdaoud&format "%d" 32)
11:03lazybot⇒ #<core$format clojure.core$format@b82d00>
11:03weavejesterOr you could fix fetch and send a pull request to ibdknox
11:03fdaoud&(format "%d" 32)
11:03lazybot⇒ "32"
11:03TimMcjtoy: Work on understanding the individual tools (filter, line-seq, partition-by...) before trying to debug the results of gluing them all together.
11:04lynaghkweavejester: yep, that's what I'm going to do. I'm digging into clojure.core print. Looks like I should be able to redef some methods.
11:05fdaoud&(format "010%d" 32)
11:05lazybot⇒ "01032"
11:05fdaoudhuh. it has me beat too.
11:06clgv&(format "%,2.1d" 32)
11:06lazybotjava.util.IllegalFormatPrecisionException: 1
11:06clgv&(format "%,4d" 32)
11:06lazybot⇒ " 32"
11:06clgv&(format "%,04d" 32)
11:06lazybot⇒ "0032"
11:08lynaghkweavejester: yep, that worked. Clojure is so awesome.
11:09weavejesterlynaghk: This is just a workaround, right? redefing core functions as a long term solution is a little… iffy :)
11:10lynaghkweavejester: This seems fine to me. Isn't the whole idea of multimethods to be an open, extensible system?
11:11weavejesterlynaghk: Multimethods allow polymorphism, but I thought you said you had to redef
11:11rexim&(+ 1 2)
11:11lazybot⇒ 3
11:11lynaghkweavejester: the alternative is to try and walk all possible datastructures and manually coerce numeric types into something that clojure.core/print-method prints without prefixes, which seems like much more of a hack
11:12weavejesterlynaghk: True, but the best solution would probably be to fix fetch :)
11:12lynaghkyeah, I defined a method in the fetch namespace to handle java.math.BigDecimal. Within the fetch namespace, it'll be called instead of what's in clojure.core.
11:12rexim&3
11:12lazybot⇒ 3
11:12lynaghkweavejester: I feel like that's what I just did. What would be an alternative fix?
11:13weavejesterlynaghk: Ohh, I see. So you just extended a multimethod with custom behavior for BigDecimal? That seems fine, TBH.
11:13rexim&\o_
11:13lazybotjava.lang.IllegalArgumentException: Invalid digit: ï¿¿
11:13weavejesterI thought you were redef-ing
11:13lynaghkweavejester: yep. Sorry if my language was unclear.
11:14lynaghkphew. you had me worried for a sec there = )
11:14jtoyTimMc: I've tested out the parts of this individually (defn mygrep [id] (with-open [is (clojure.java.io/reader "/mnt/results")] (filter #(re-find (re-pattern (str "^" id "\\s")) %) (line-seq is))) ) , but when i put it together I get: (IOException Stream closed java.io.BufferedReader.ensureOpen (BufferedReader.java:97) I don't understand why my code is not in the context of the with-open
11:15llasramLazy sequences
11:15TimMcjtoy: Ah, now that's a legitimate pitfall.
11:15weavejesterlynaghk: Your solution sounds good. My only reservation would be that print-method isn't a documented function.
11:15TimMcjtoy: You're running into the problem of lazy evaluation + dynamic binding.
11:16weavejesterlynaghk: But if it works well in practise, I can't think of a neater solution.
11:16lynaghkweavejester: sweet.
11:16TimMcjtoy: Put a doall around the filter call, but inside the with-open.
11:16lynaghkweavejester: oh, while you're here there's something I wanted to ask you about ring
11:16weavejesterlynaghk: Shoot
11:16lynaghkweavejester: are you still open to a patch that would allow the file middleware to serve unsafe paths (e.g. symlinks)
11:17lynaghkweavejester: I saw a discussion you had on the mailing list last summer that said you'd be open to it, but the original guy found some other solution and never submitted the patch
11:17weavejesterlynaghk: Oh, hm, yes, I'd be open to it, if it was an option.
11:17weavejesterlynaghk: And not the default :)
11:18lynaghkweavejester: okay, cool. I'll get a pull to you in the next day or so. Preference on the name? The keyword :allow-symlinks? is informative, but :allow-unsafe-paths? might be safer.
11:19weavejesterlynaghk: If you can, it might make the 1.1 release. I'm planning on releasing an RC this weekend.
11:20lynaghkweavejester: yeah, I'll definitely get it to you by this weekend.
11:32heyduckhi all - i have a question concerning a future that never gets run. just wondering if somebody would be willing to take a look.
11:32heyduckhttps://gist.github.com/2302478
11:32heyduckThe comment on the bottom briefly explains what's going on. thanks in advance to anybody for their time
11:36clgvheyduck: future around future in that gist doesnt get you anywhere.
11:37clgvheyduck: maybe your timeout is too short. have you tried to deref without a timeout?
11:39heyduckclgv: thanks for helping - the timeout is only for the deref - my issue is when removing line 23 - that future is never run
11:46clgvheyduck: I strongly doubt that. 'vec in line 6 forces the evaluation of the 'for which causes all the futures to be created and thus their content expressions to be submitted to the executor
11:47clgvheyduck: you might check the thread activity with jvisualvm or htop
11:51heyduckclgv: i will do that, thanks. the reason i say it's not executing is that i'm not seeing writes into our datastore when removing that deref line, but keeping it does result in writes.
11:54clgvheyduck: what does exec-query look like?
11:54heyduckclgv: i'll add to the gist
11:57S11001001&'#(list % % % %)
11:57lazybot⇒ (fn* [p1__24780#] (list p1__24780# p1__24780# p1__24780# p1__24780#))
11:59heyduckclgv: i've added an example of all the functions that would be used in one call, for example to mongodb
12:04clgvheyduck: queryblock: contains a lazy 'for - that's the reason. change it to a doseq and you get your isnerts
12:06heyduckclgv: that's exactly it. thanks so much for your time
12:12achinweavejester: I just pushed the web-xml change to the PR, but I just saw that I missed the 0.6.3 release. Any idea when 0.6.4 might go out?
12:14weavejesterachin: As soon as I merge in your change. Pre-1.0 releases can be thrown out any time.
12:23achinweavejester: Oh. Great. Thanks.
12:24achinweavejester: It'll definitely make things easier on our end.
12:43eggsbyibdknox: weavejester: have you ever seen noir dropping routes when uberjarring for production? More information here (including project.clj) here: https://refheap.com/paste/1776:
12:43samaaronhow can I see runtime errors in javascript?
12:43samaaronfor example, I tried (int 3.5) in a form
12:43samaaronwhich cljs doesn't seem to handle
12:43samaaronbut i didn't see any errors anywhere
12:43samaaronthe cljs compiler seemed to compile it with no problem
12:44oakwisesamaaron: where is the code actually running? browser?
12:44samaaronoakwise: yup
12:45samaaronoakwise: it's been compiled to js, and is running in the browser
12:45mfexsamaaron: did you compile with advanced optimizations?
12:45samaaronnope
12:45oakwisesamaaron: if you're using chrome, open up the developer tools and go to the console tab. You should shee the errors.
12:45samaaronoakwise: i have that open
12:45samaaronno errors
12:47oakwisesamaaron: but things like (.log js/console 1) do show up?
12:47mfexsamaaron: I think advanced compilation will catch it
12:48samaaronmfex: but if I use advanced compilation, then I'm assuming debugging will be harder because the code will be obfuscated
12:48samaaronoakwise: yup, the log thing works great
12:49samaaronoakwise: that's what alerted me to the error. (let [x (int 7.7)] (.log js/console x)) doesn't even print anything
12:49mfexsamaaron: true but just running the compiler will show the warning, you can still use simple or no optimisations and just just the advanced compilation as a sanity check
12:50samaaronmfex: I've got cljsbuild to run in auto mode with no optimisations
12:50samaaroni guess i'd have to turn that off
12:50samaaronrun a manual advanced mode compile
12:50samaaronthen turn it back on again
12:50samaaronhuge hassle
12:51mfexsamaaron: true, I would like a lein cljsbuild auto for simple/dev mode and lein cljsbuild once for advanced
12:52mfexI have the two compile tasks as two as lein run files because I use a different clojurescript version than cljsbuild
12:52samaaronsounds tricksy
12:53samaaroni still haven't got the in-browser repls stuff working yet
12:53samaaroni really miss being able to eval forms arbitrarily
12:55samaaronso the subquestion is how I force a number into an integer in cljs
12:55oakwisesamaaron: I just put (int 3.5) in a keypress callback and got the error properly in my chrome console when the callback was triggered
12:55samaaronweird
12:56mfexjavascript does not have integers
12:56samaaronwhat about whole numbers?
12:56samaaronwhat is 1 in js?
12:56oakwise1.0 :\
12:57mfex1 = float
12:57oakwiseyou can (js/parseInt "3")
12:57samaaronok, so does js have a floor operation?
12:57TimMcyep
12:57samaaronis that just floor?
12:57samaaronand how would I know if it was?
12:57TimMcMath.floor(3.5) => 3
12:58samaaronMath.floor rather than Math/floor?
12:58TimMcwell, that was the JS version
12:58samaaronoh yeah
12:58samaaronso where do people go to find these lib fns?
12:58samaaroni'm just stabbing around in the dark
12:59oakwisehttps://developer.mozilla.org/en/JavaScript/Reference is pretty great
12:59TimMcsamaaron: Math.floor is a JS built-in, so it's not CLJS-specific knowledge.
13:00samaaronoakwise: awesome, thanks
13:00oakwisesamaaron: np. I'm just confused by why your error isn't showing up. How is the code getting triggered?
13:00samaaronoakwise: I'd love to solve that problem
13:01samaaronI'm probably doing something horribly wrong
13:01samaaronok, so i'm using cljsbuild
13:01samaaronmy project.clj looks as follows: I
13:01samaaronI
13:01samaaronhmm
13:01samaaronhttps://gist.github.com/2303832
13:02samaaronthere
13:03oakwise(first step would be lein-cljsbuild 0.1.6)
13:03samaaronooh
13:03samaarongood plan
13:04oakwiseand then what does your cljs look like?
13:05samaaronoh, it's a horrible mess
13:05samaaroni've just added it to the gist
13:05oakwiseheh fair
13:06samaaroni was calling int within the draw fn
13:07oakwiseanother small item: the <script> tag doesn't like being in the <head> for some reason. Maybe that's fixed in the current cljs but I had trouble getting the repl working unless the script is in <body>
13:07samaaronoakwise: awesome, thanks
13:07samaaroni thought the script tag shoudl go in the head
13:08oakwisein theory that's what head is for
13:08samaaronso, i'm also seeing this error in the chrome console: GET file:///Users/sam/scratch/game-of-life/resources/public/deps.js
13:08samaaronwhich when expanded says:
13:08oakwisebut scripts in the head will block loading of everything after them until they finish loading. Maybe that's the issue... the repl connect never "finishes" (just guessing)
13:09samaarongoog.writeScriptTag_ goog.importScript_ (anonymous function)
13:09oakwiseyou can just `touch resources/public/deps.js`
13:09oakwiseit's a google closure thing that shouldn't matter for what you're doing
13:10samaaronwhat is the deps.js all about?
13:11mfexsamaaron: add <script>var CLOJURE_NO_DEPS = true;</script> to the html to prevent the deps loading
13:11mfexoops
13:11mfexthat's CLOSURE_NO_DEPS
13:11samaaronmfex: what are the deps?
13:11samaaronhaha, clojure/closure are so annoyingly similar
13:12mfexit's something from goog closure, I'm not sure what it is for. I never needed it for my cljs projects
13:12oakwisesamaaron: so in your draw fn, you are actually seeing the result of that log call right? and if you put a "(log (int 3.5))" right after it, things blow up but you don't see the error?
13:13eggsbyso can noir just not be used in a jar for deployment :(
13:13eggsbykind of a deal breaker
13:14muhooeggsby: i'd find that very surprising
13:14samaaronoakwise: exactly - although now I'm seeing a compiler WARNING about my use of int
13:14oakwisehttps://developers.google.com/closure/library/docs/depswriter
13:14muhooeggsby: i'm also surprised that ibdknox and weavejester aren't around. they usually are. maybe Raynes would know too.
13:15oakwisesamaaron: okay dumb question: you've made sure "All" is clicked at the bottom of the developer tools window, and not just "Logs", right?
13:15eggsbyya muhoo, same problem from last night, you ever get your issue sorted?
13:15samaaronoakwise: yep, but only out of luck, I hadn't seen that before ;-)
13:15muhooeggsby: i did! thanks to some expert help from some of the folks here
13:16eggsbynice :)
13:16muhooeggsby: like i said, ibdknox is very, very helpful, and usually around
13:16oakwisesamaaron: what happens when you enter regular js errors into the dev console? null()
13:16samaaronoakwise: this is what i see: http://imgur.com/wDSM6
13:16muhooeggsby: if you can distill it down to some sample code you can post on the gist, then mayeb submit it as an issue to noir or lein-ring on github?
13:17eggsbyya, creating a demo project to recreate the bug is probably the best path
13:17muhooeggsby: the way i got my problem fixed, is i found an example in the clojurebook.com which failed in exactly the same way. then they knew the problem wasn't just me being ign't
13:17eggsbyI'm thinking about just dropping down to compojure/ring/hiccup tho and ditching noir
13:18eggsbythe worst is that it compiles and runs fine from the jar, but just drops all routes
13:18muhooeggsby: not a bad plan, but maybe better if you can to distill the problem to something simple within noir
13:18oakwisesamaaron: ?! nothing shows up when you `null()`?
13:19muhooeggsby: it is, of course, possible that pilot error is involved. it's rare i find a problem that *isn't* caused by me, for example :-)
13:19mfexeggsby: are you deploying with tomcat?
13:19samaaronoakwise: i see the error: TypeError: object is not a function
13:19dgrnbrgIs it possible to have the reader attach line-number information to all symbols read?
13:20samaaronoakwise: the screenshot I linked to is what I see when I run the code in https://gist.github.com/2303832
13:20oakwisesamaaron: oh okay that is good
13:20technomancydgrnbrg: doesn't that happen when you use a LineNumberingPushbackReader?
13:20eggsbymfex: I'm just trying to get this passed off to another team member, but I can't create a standalone jar for the life of me - a la https://refheap.com/paste/1776
13:23dgrnbrgtechnomancy: only for s-exprs, not literals
13:23mfexeggby: when running through lein do you use lein run or lein ring?
13:23technomancydgrnbrg: oh, sure. literals can't have metadata.
13:23technomancyerr
13:23technomancythat is, strings, numbers, and keywords can't
13:23dgrnbrgtechnomancy: is there a way to get line number information from a let form's variables?
13:23technomancynot sure about that
13:24bhenrydo korma entities create the table in the db? or do i have to create the table and then make the entity match?
13:24eggsbymfex: 'lein run'
13:24oakwisesamaaron: samaaron: open up the "Scripts" tab, browse to your main.js, and see if you can find your draw function. Do you see something like gol.int$.call(null, 3.5)?
13:26samaaronoakwise: gol.log.call(null, cljs.core.str.call(null, x__5096, ", ", gol.int$.call(null, y__5097)));
13:26eggsbyhmm, ya even the default project created with 'lein run' cant be uberjar'd
13:26eggsbyoops, I mean with 'lein noir new myproject'
13:29samaaronoakwise: what does the $ represent?
13:29oakwisesamaaron: that should definitely bomb out. Try something simplier like `(log "before") (int 3.5) (log "after")` in your setup fn and see what happens
13:30samaaronok, now it prints "before" then nothing
13:30samaarongol.int$.call(null, 3.5);
13:30oakwisesamaaron: not sure exactly
13:30oakwise?!
13:30eggsby:(
13:30samaaronthat's what got compiled...
13:30oakwisesomeone is squashing your errors
13:30samaaronswine!
13:31samaaronI shall have them!
13:31oakwisea witch hunt is definitely in order
13:31samaaronso what does the $ signify in the compiled symbol?
13:32oakwiseI don't know actually. Good question.
13:32oakwisewhat about trying a different error? (.nope "foo")
13:34oakwisesamaaron: also, try going to the "script" tab and clicking the little pause button to enable breaking on exceptions
13:35eggsbyhttps://refheap.com/paste/1778
13:36oakwise(and then reloading)
13:36eggsbyso the standalone jar works fine when you leave it in the project dir but breaks when you move it, sounds like its secretly reading files off disk?
13:37samaaronoakwise: no error reported
13:38mfexeggsby: that's really weird
13:39eggsbyeasy to reproduce, however
13:39oakwisesamaaron: I'm at a loss. Have you tried FF?
13:39samaaronoakwise: i just tried it in safari, and I see the error
13:39@rhickeynaming poll: I have a new reduce at hand that takes a function of [result key value], with internal-reduce-like implementations for all the associative collections, so much faster than (reduce (fn [ret [k v]] ...) init amap)
13:39samaaroni'm using Chrome: 17.0.963.56
13:39@rhickeyoptions are: reduce-kv, kv-reduce, ???
13:39lazybotrhickey: Yes, 100% for sure.
13:40samaaronrhickey: I'd prefer it starting similarly
13:40samaaronthat way my auto-complete can help me find it...
13:40@rhickeyit will also work for vectors, passing indexes for k
13:41@rhickeyindices
13:41oakwisesamaaron: sounds like your chrome is funkified? Switch to the dev channel (mine is 18.0.1025.142)?
13:41dgrnbrgrhickey: i agree with samaaron's logic
13:41@rhickeymy pref also, what about the kv part?
13:42apwalkrhickey: reduce-indexed ?
13:42jkkramerrhickey: reduce-pair?
13:42@rhickeyreduce-associative is a mouthful
13:42dgrnbrgrhickey: reduce-assoc
13:42samaaronreduce-ass
13:42TimMcapwalk: "indexed" indicates an integer counter
13:42samaaron;-)
13:42bhalbertreduce-entry
13:42@rhickeyjkkramer: not taking pairs, that's part of the point
13:43technomancyI think -kv is short and unambiguous
13:43@rhickeybhalbert: also not entries is part of the point
13:43jkkrameroh i get it. reduce-kv sounds reasonable
13:43replacait's a bummer that "map" is overloaded, cause reduce-map would be nice
13:43dgrnbrgrhickey: could you give a sample of what it looks like to use? is it like (reduce-assoc (fn [x] [(keyword x) x]) {} '[a b c d]) ?
13:43replacarhickey: I think I'd go with reduce-assoc or reduce-kv
13:44technomancyreduce-assoc makes me think assoc is meant as a verb
13:44@rhickey(reduce-kv (fn [ret k v] ...) init amap)
13:44dgrnbrghow do you use the ret parameter?
13:44mfexreduce-kv wins for me over reduce-associative for brevity
13:44samaarondgrnbrg: ret is just the thing you're building up
13:44TimMcdgrnbrg: Just like regular reduce on a map, except the entry is "destructured" for you.
13:44dgrnbrgoh, i see
13:44@rhickeythe idea being people can take existing (reduce (fn [ret [k v]] ...) ... code and :add -kv, lift the vector arounf k v i nthe args, and go
13:45TimMcThe usecase for vector is pretty great.
13:45dgrnbrg(brainfart)
13:46@rhickeyok, reduce-kv seems uncontroversial, thanks all, should be showing up soon
13:46dgrnbrgcould it be done as (reduce :assoc (fn [ret k v] ..) init amap…)?
13:46samaaronI think I'd prefer brevity with such a potentially used fn name
13:46dgrnbrgor even by inspecting the arity of the reduction fn, defaulting to the 2 arg form if both 2 and 3 arg arities are avaialble?
13:47technomancydgrnbrg: fn literals don't have :arglists metadata, unfortunately
13:47technomancy(not that I think that's the right solution anyway, I just wish fns had metadata)
13:48pjstadigwe have mapv
13:49pjstadigwhat about reducea
13:49apwalkIf for is lazy and doseq returns nil, how can you realize a comprehension and return the result, idiomatically? I'm about to resort to loop/recur.
13:49@rhickeypjstadig: that's another option, we don't use 'a' otherwise for that, but do for 'array'
13:50pjstadigtrue 'a' may get confused for 'array'
13:50mfextechnomancy: does the "Note on disconnections on Heroku" from https://github.com/thegeez/clj-browserchannel-demo ring a bell with you?
13:50dgrnbrgapwalk: doall?
13:50S11001001apwalk: use for and use vec, into, or doall on the result
13:51apwalkS11001001: ah, right, that'll work, thank you.
13:51technomancymfex: not off the top of my head, but I can ask the routing team if you like
13:51apwalkdgrnbrg: hmm, doall works too
13:52mfextechnomancy: I can submit a long form question somewhere with background, what is the place for that?
13:53technomancymfex: probably support.heroku.com; unfortunately our IRC channel is useless =(
13:53@rhickeyreplaca: reduce-map would hide the fact it works on vectors too
13:55dgrnbrgapwalk: doall realizes the seq and returns the head. into will put them into a new collection, and vec will put them into a new vector. you probably want doall unless you really want a different kind of collection, since doall will generate less garbage
13:55TimMcrhickey: And this will work on any Associative?
13:56dgrnbrgsince 1.4 isn't released yet, perhaps a new hungarian notation could be devised, to allow for denoting fns on arrays, vectors, and associatives
13:56replacarhickey: yeah, but we're treating them as a map (in the braod sense of key -> value) in that instance. Still, I don't think it's a good name cause of the confusion with the fn "map", map-reduce, etc.
13:56@rhickeyTimMc: persistent hash/array/tree/map and persistentvector to start
13:56@rhickeybut will be a protocol to extend
13:56TimMcAh, I see.
13:56apwalkdgrnbrg: very appreciated, I was just trying to think through exactly that.
13:56replacadgrnbrg: you'll need to go stand in the corner for 5 minutes for that suggestion :)
13:57dgrnbrgreplaca: why? I think that there's already a hungarian notation, just done in a semi-ad-hoc way, and perhaps it's time to reconsider it
13:57MrKottercoalesce
13:58replacadgrnbrg: that never ends happily
13:58mfextechnomancy: is there a heroku forum or something? I have more of a question rather than a ticket/request about a running app
13:58dgrnbrgreplaca: mapv, assoca
13:59technomancymfex: sure, you might try https://groups.google.com/group/heroku
14:00TimMcrhickey: Will this be an internal reduce, then?
14:00@rhickeyTimMc: yes, smoking fast
14:00@rhickeyno allocation
14:00TimMcI see, hence the specificity.
14:03replacadgrnbrg: assoca?
14:04dgrnbrgreplaca: you caught me :)
14:04dgrnbrgWhat about the possibility of using a keyword flag in the function?
14:04dgrnbrglike (reduce :assoc (fn [r k v] …) …)
14:08TimMcIs that even unambiguous?
14:09@rhickeydgrnbrg: that is not a possibility
14:09@rhickey:)
14:11dgrnbrgI think that you could get the order s.t. the fn would go into the initializer slot…ehh…I like modal functions
14:11dgrnbrg(binding [*associate-reduce* true] (reduce (fn [dynamic lulz here] …) …))
14:12TimMcwtf
14:13dgrnbrgI am concerned that adding all the performance-oriented variations of map & reduce (just pmap, mapv, reduce, reduce-assoc) makes the language harder to understand
14:14TimMcdgrnbrg: And dynamic binding is supposed to help?
14:14dgrnbrgWell, then you learn about the options later
14:14dgrnbrgwhen you look at the docstring for reduce
14:15dgrnbrgThe idea being that if I present many coworkers w/ clojure, they'll flail around w/ the choices because they're obsessed with "performance", and then they'll decide it's "too many choices" and go back to doing it in java w/ for loops :(
14:18technomancyif they're obsessed with performance they'll flail regardless
14:30technomancyjust don't show them http://meshy.org/2009/12/13/widefinder-2-with-clojure.html or they'll explode
14:32technomancyclojurebot: ludicrous speed is great for when light speed is too slow: http://meshy.org/2009/12/13/widefinder-2-with-clojure.html
14:32clojurebotYou don't have to tell me twice.
14:33jorge_anyone here familiar with clj-facebook-graph? I am a little confused as to how the callback works
14:33jorge_or doesn't work, in my case.
14:39autodidaktoIf anyone wants to submit examples to clojuredoc for "amap", it would be much appreciated :) http://clojuredocs.org/clojure_core/clojure.core/amap
14:48autodidaktois clojure.walk/walk syntactic sugar for two maps? is it a different use case?
14:49S11001001autodidakto: it's an unbounded number of maps and intos
14:49S11001001and utterly eager
14:49S11001001so, in short, the latter
14:49autodidaktoS11001001: thanks
14:51S11001001on the other hand, it *is* fmap (the functor map operation), but clojure's map is not functor map
14:51S11001001hmm, that is not quite right, never mind
14:53autodidaktohehe, alright. I'm studying the documentation for walk/into/fmap right now
14:54S11001001autodidakto: I'm afraid the best way to understand map (and its numerous weird consequences) is to read the source
14:55S11001001uh, I mean walk :)
14:55autodidaktoS11001001: will do.
15:01llasramI think that 2009 "widefinder" blog post has a concurrency bug in its atom-using code.
15:02llasramI'm very glad I finally embraced refs
15:03samaaronllasram: I see it as embracing the immutability first and foremost :-)
15:03llasramOk, that is probably more fundamental :-)
15:04samaaronthen you should embrace the Overtone sine waves ;-)
15:06autodidaktosamaaron: sounds like you're preaching a new religion
15:06samaaronautodidakto: haha - I'm hardly the relgious type
15:07samaaronbut I guess if I were to preach anything it would be the value of seeing programming as an art and to perceive the artistry in programming
15:07samaaronand the artist in the programmer
15:07autodidaktoAll hail Immutability, the first and foremost. His name is Overtone. Let his sine waves overcome you.... at least that's my understanding
15:07autodidaktooh that works too :)
15:13autodidaktosamaaron: btw, I appreciate your talks on overtone and how you compare the layout of the guitar fretboard and fingerings as an outdated, arbitrary constraint
15:16gregoriusnewbe question: anybody using clooj?
15:19autodidaktogo ahead and ask your question, gregorius
15:20mk~anybody
15:20clojurebotPardon?
15:20gregoriusalready asked: anybody using clooj? because i don't know the difference between clooj-0.2.8-standalone.jar and clooj-0.2.8.jar
15:20mk~anyone
15:20clojurebotJust a heads up, you're more likely to get some help if you ask the question you really want the answer to, instead of "does anyone ..."
15:21autodidaktoget standalone
15:21gregoriusautodidakto: thnx
15:21mkgregorius: I'm guessing that with standalone, you won't need to find all the other jars yourself
15:21autodidakto"runs as a standalone application or as a clojure editor embedded in another java or clojure application. The standalone version (containing the clojure core, currently version 1.3.0) is a single jar file that can be launched by double-clicking
15:21gregoriussilly me, should read the readme
15:22mkgregorius: np, and welcome to the channel :)
15:22autodidaktohehe I almost missed it too.
15:23autodidaktoGregorius: I once misread a README, filed issues, etc. I felt so dumb I made myself fork the project and work improving the documentation to make up for not reading the README
15:23gregoriusas a totaly newbre (also a programming newbe) :is there any need of type conversion in clojure?
15:24autodidaktoGregorius: don't worry about types for now
15:24AimHereWhat autodidakto, but the answer is yes.
15:24AimHere*said
15:25samaaronautodidakto: yup - the exciting question is what might musical interfaces look like in the future - now they're free from arbitrary constraints...
15:27mkgregorius: powerful languages like the various lisps might be a bit harder to learn at first, so if you get stuck or confused that's normal - feel free to ask in here if that happens
15:28gregoriusautodidakto: ok, but this functional thing is weird
15:28gregoriusautodidakto: i mean clojure... wanted to do a simple thing but I"m stuck
15:28autodidaktosamaaron: I also think about the physical-handicap angle... it's tough for me to practice certain intruments because of a shoulder condition.. Other people have much worse problems..
15:28gregoriusmk: I'm stuck already on a simple problem
15:28autodidaktoGregorius: there are some good books just coming out :)
15:29gregoriusautodidakto: books are expensive, especially if you ern little
15:30gregoriusautodidakto: or u mean i should start with some lisp ebooks that are free?
15:30mkgregorius: there are ways to get books without paying - such as the local library, or university library
15:30autodidaktoGregorius: it's worth it. PM me and I'll give you recommendations
15:30gregoriusmk: not here
15:30sattvikgregorius: what sort of problem have you run into?
15:32gregoriussattvik: oh just wanted to create a sum from the ciphers of a given number an i have no idea how to start it with clojure
15:32samaaronautodidakto: that's a very important and interesting angle too :-)
15:32autodidaktosattvik: he said he's just beginning to program. everything is a roadblock at those stages. I'll recommend him some good resources
15:33mkgregorius: you've got a repl set up and running, yes?
15:33gregoriusmk: positive
15:33AimHereautodidakto, thing is, there's good free Lisp resources that are non-Clojure, like SICP; a total programming newbie will have pain converting between the languages
15:34mkgregorius: what's the cipher of a number?
15:34gregoriusSICP is scheme based?
15:34AimHereYes
15:34autodidaktoAimHere: yeah. I dont recommend trying to translate.
15:34AimHereLearn enough clojure to be dangerous; then translate ;)
15:34autodidaktoSICP is mit scheme, though someone has just begun translating the examples. Either way, I'd recommend more hand holding for a first book..
15:36gregoriusmk: a number usually includes ciphers
15:36gregoriusmk: sorry was meaning a digit
15:37gregoriusmy bad english
15:37mkgregorius: so when we represent 112, we use 2 digits
15:37mkI follow so far
15:38gregorius112 are 3 digits
15:39gregoriusmk: okey i know the algorithm, i have to read the number and do a mod operation (number mod 10)
15:39edwHow can I create an unqualified name?)
15:40AimHereThe way I'd be inclined to do that would be using a recursive function using the mod and the quotient
15:40samaaronedw: in which context?
15:40edwSo I can (eval `(let [foo 42] foo)) for example.
15:40mkgregorius: convert to string, take the length of that string. Done?
15:40AimHereIs he not summing the digits rather than counting them?
15:41samaaronedw: `(let [~'foo 42] ~'foo)
15:41edwAh. Thank you.
15:41samaaronnp
15:42edwI had a brain fart and was typing the uglier ~(symbol 'foo)
15:42gregoriusmk: convert to string? wait have to look in docs
15:43AimHeregregorius > That's one way of doing it, though if you're summing the digits rather than counting them, it might be a funky way of getting the answer
15:43mkgregorius: what are the answers to the following: 1, 111, 222, 1234?
15:43mkAimHere: (also, negatives)
15:44gregoriusAimHere: the problem is how to get digits out from the number. tokenize?
15:45gregoriusmk: (1, + 1 1 1) etc
15:45AimHeregregorius (- (int %) (int \0)) perhaps; as I say, funky
15:45mkgregorius: I'm still not sure what you need to do :) - how do you solve 1, 111, 222, 1234? What are the final answers?
15:46gregoriusAimHere: % ? not mod ?
15:46gregoriusmk: for example you have a number 1234. ok?
15:46AimHeregregorius > This is using a rather silly way of taking the string of the number; ignore it for the time being
15:46mk1 3 6 and 10? or 1 3 3 and 4?
15:46gregoriusmk: then the sum of digits is: 1 + 2 + 3+4
15:47yoklovAnybody want to give me some feedback on my GSOC proposal? http://www.google-melange.com/gsoc/proposal/review/google/gsoc2012/thomcc/1
15:47mkor 1 1 1 and 4?
15:47AimHereRight, probably the mod way is better
15:47gregoriusmk: what do u mean?
15:47goodieboywhat's the main difference between an atom and a ref?
15:48samaarongoodieboy: an atom provides no coordination guarantees
15:48mkgregorius: there are many, many things you could be talking about
15:48AimHeregregorius > He wasn't sure what your problem was; he didn't know whether you were summing or counting digits
15:48samaarona ref can be updated in a transaction
15:48mk but you're just talking about getting the sum of every digit?
15:48goodieboysamaaron: ahh ok
15:49samaarongoodieboy: in fact, refs may *only* be updated in transactions, and therefore use the STM
15:49AimHeregregorius > Do you know about recursion? Making a function call itself?
15:49gregoriusmk: I'm summing the digits not counting
15:49samaaronatoms just provide atomic updates
15:49goodieboysamaaron: very good to know. OK so when working with multiple threads, refs are definitely the right choice.
15:49gregoriusAimHere: positive. have a knowledge what is a recursion
15:50samaarongoodieboy: it's not as simple as that
15:50samaaronboth are useful with multiple threads
15:50samaaronthe question is whether or not you want to coordinate updates of multiple references
15:50mkyoklov: I'll have a look - I'll message you?
15:50yoklovk
15:50AimHereGood. Then can you see how the problem could be done as a recursive function? if f(n) is the sum of the digits of n, then f(1234) is 1+f(234) which is 1+2 + f(34) and so on?
15:51AimHereOr in this case, f(1234) is f(123)+4 which is f(12) + 3+4 ...
15:51gregoriusAimHere: recursion is nice but the performance is not so good if u r using recursion, i think
15:51goodieboysamaaron: i see
15:51gregoriusAimHere : but i got your idea
15:52AimHeregregorius> In lisps, including clojure, there's a clever trick called tail recursion which makes the performance better
15:52mkgregorius: don't worry about performance
15:52gregoriusAimhere: f(n) = 1+ f(n-1) right?
15:52AimHereNot in this case
15:52samaaronAimHere: Clojure doesn't have real tail recursion as the JVM doesn't support it
15:52AimHereHere, f(n)=mod(n,10) + f(int (n/10))
15:53gregoriusAimHere: sorry, i was simplyfing
15:53AimHeresamaaron, there is a hack though, which does the job
15:53gregoriuswhat is ttail recursion??? (silly me)
15:54yoklovtail recursion is where the recursion is turned into a loop
15:54AimHeregregorius > Don't worry about it at the moment; it's a way of improving performance and not having stack overflows when you recurse
15:54fliebelgregorius: basically a function that ends by calling itself.
15:54gregoriusAimHere: okey the algorithm is clear, but have no ide how to start the implementation in clojure
15:55gregoriusBTW, do you know any pastebin alernative with clojure highlightning?
15:55AimHerepastebin.com has clojure highlighting, I've not needed any others yet
15:55fliebelgregorius: refheap
15:55yoklovgregorious: also, recursion is more expensive than a procedure call in most languages
15:56fliebelhttps://refheap.com/paste
15:56autodidaktoahh, first types, now tail recursion... you're too worried about optimization for now :)
15:56AimHereI think talk of tail recursion and procedure call cost is perhaps 'premature optimization' here
15:56gregoriusyolkov: this is the point why i was meaning it's a performance bottleneck
15:56gregoriusfiebel: thnx
15:56autodidaktobtw, this is the first i've heard of clooj. playing with it now. pretty cool. Like Dr Racket but for clojure
15:57weavejesterDoes anyone know of a good Leiningen method to hook into if you want to run every time
15:57weavejesterI want to write a file to the project root before a command
15:57gregoriusautodidakto: i got it from: http://dev.clojure.org/display/doc/Getting+Started
15:58Raynesweavejester: Before *every* command?
15:58RaynesOr just before a certain command?
15:58weavejesterRaynes: Any command that potentially executes code in a project
15:59weavejesterSo maybe… eval-in-project?
15:59weavejesterExcept there's trampolining
15:59weavejesterBut every command would work as well, as all it's doing is writing a hidden file.
16:01weavejesterHm… I suspect I'll have to have two different hooks for Lein 1 and 2.
16:01weavejesterBut I guess it's only relevant in Lein2 anyway...
16:05gregoriusAimHere: so my first problem is: how to proove that the input is a number?
16:05mabesin clojure 1.2 land I used slurp* to read a jetty request body.. in clojure 1.3 what is the preferred way of doing that now that slurp* is gone?
16:06weavejestermabes: Use slurp
16:06weavejestermabes: Without the *
16:06weavejestermabes: In Clojure 1.2 slurp is the same as the old slurp*
16:06AimHeregregorius, I'm not sure why you need to do that; the 'number?' function should do though
16:07gregoriusAimHere: as a said, i'm totlly newbe
16:07gregoriusthnx for hint of number?
16:07AimHereWell you'd only have to check for a number if this function was going to be fed things that weren't numbers by accident
16:11mabesweavejester: cool, thanks
16:22gregoriusAimHere: hmm, just started and:
16:23gregoriusAimHere: (println (read-line)))
16:23gregoriusAimHere : sorry wrong.
16:24sattvikgregorius: Clojure is a dyanmic language, so you generally don't have to worry about types. You can (for now) just assume that whatever your function gets is a valid input.
16:24gregoriusAimHere : (let [yayinput (read-line)])
16:24gregoriusbut after (println (yayinput)) throws an exception
16:25amalloytoo many parens
16:25amalloy(println yayinput)
16:25AimHereThere's an extra paren after the (let [] too
16:25gregoriusamalloy :a also an CompilerException thrown by REPL
16:26amalloyAimHere: well. there are the right parens, just in the (possibly) wrong place - it should go after the println
16:26AimHereIndeed
16:26N8DawgI had a question to the room, I was thinking about writing a filesystem library
16:27N8Dawgwhich would return a directory as a tree of maps,
16:27N8Dawgthe content of files would also be accessible as an attribute of the map
16:28amalloy(let [input (read-line)] (println input))
16:28AimHeregregorius > (let [yin (read-line)] (println yin))
16:28N8Dawgis there a library which does this already?
16:31N8Dawgis it even a good idea/useful?
16:32sattvikN8Dawg: I think it sounds interesting, especially if it could be made to be relatively platform-agnostic.
16:32sattvikNo idea if there is anything like it, though.
16:33N8Dawgbasically the idea is to transform a filesystem into clojure data so it can be filtered mapped etc
16:39gregoriusN8Dawg: somethink like NoSQL ?
16:40N8Dawggregorious: how do you mean?
16:43gregoriusN8Dawg: a kind of mapping that is used in NoSQL
16:46N8Dawggregorius: like hadoop? hadoop runs on a distributed filesystem. I'm thinking a really simple abstraction, something you'd point at a local directory
16:48gregoriusN8Dawg: not hadoob, more like MongoDB, or CouchDB, or something JSON
16:49unlinkHow do I specify system properties values on the command line when using lein run?
16:50unlinke.g. java -Dsome.property=value clojure.main script.clj
16:52technomancyunlink: JVM_OPTS=-Dsome.property=value
16:52technomancyas an environment variable
16:52technomancyor :jvm-opts ["-Dsome.property=value"] in project.clj if you want it always on
16:53unlinktechnomancy: I see in the lein source that JVM_OPTS is marked as being for backwards compatibility...do you intend to remove it?
16:53technomancyunlink: no, JAVA_OPTS is for backwards compat
17:06goodieboyi'm curious about when you should use defonce?
17:07goodieboywouldn't it only be useful when you reload a namespace?
17:18unlinkWhat is the recommended logging stack for clojure applications? Do I need tools.logging, slf4j and log4j?
17:20TimMc[1;5D[1;5D[1;5D[1;5D[1;5D
17:21TimMcwtf
17:22cjfriszTimMc: Did you just try to lay some terminal colors on the IRC?
17:22TimMcNo, I think it's a connection issue.
17:23cjfriszAhh
17:23TimMcSuper laggy connection on my laptop, and I think either my local terminal or irssi got confused.
17:23llasramunlink: I'm curious about that as well. Java logging in general is still pretty murky to me.
17:24unlinkllasram: I have logging working with tools.logging and log4j with a 5-line log4j arcane property file incantation on my classpath.
17:25unlinkllasram: I read on the internets that slf4j is the new hotness, plus it lets me configure jetty logging at the same time. It seems that it's turtles all the way down with Java logging; everything seems to be a facade.
17:25unlinkin Python, my "logging" is sys.stderr.write("%s\tDEBUG\tsomething happened\n" % datetime.datetime.utcnow())
17:27llasramIn Python and Ruby I've been getting some serious mileage out of the standard-library logging classes, just because the consist format makes it easy to add log-based alerting.
17:27llasramJava logging's format flexibility seems like a bit of a negative there, although being able to redirect to syslog with a config file change is pretty nice :-)
17:29unlinkllasram: yeah. I don't want to configure logging in my application, though. http://www.12factor.net/logs
17:32llasramOoh, that looks like an interesting manifesto. Thanks for the link!
17:32llasramAnd that is what I'm doing in practice, actually. In reality even the Java and Clojure stuff I've got going is writing to stdout and just redirecting to syslog via `logger`.
17:32llasramThe idea of a config-file change to send to syslog sounded nice, but on reflection maybe it isn't :-)
17:35unlinkllasram: well, the config file change should be to pipe your application to logger(1).
17:39unlinktechnomancy: under what circumstances does leiningen delete and re-download the whole lib/ directory?
17:41unlinkllasram: using slf4j + logback + tools.logging seems to work well, too.
17:42unlinkllasram: as an added bonus, it has fairly sensible default configuration
17:54y3diah the headline of the rich hickey info q video on hackernews tricked me into thinking that some clojurewest vids were starting to go up
18:02devny3di: you weren't the only one :)
18:23autodidaktoyah, those vids are taking a minute to be uploaded. What the dilly-yo?
18:24aperiodicthey're being edited by a production company before being uploaded, which I guess takes some time.
18:25aperiodicat least, that's what I heard
18:27autodidaktoahh. Thanks for the info. Good audio and slide management is worth a wait.
18:32offby1Ahoy -- I just ran "lein test" on an old project, and got a big stack trace that contained this baffling line:
18:32offby1Exception in thread "main" java.lang.Exception: No such var: clojure.core/spit (NO_SOURCE_FILE:1)
18:32offby1any idea what that means?
18:33amalloyspit didn't exist until clojure 1.2 (1.1?). so you're running new code on an old clojure
18:34offby1aha!
18:34offby1thanks.
18:36TimMcrepeatability, bro
18:37autodidaktorepeatability, bro
18:37offby1repeatability, bro
18:37offby1do I win something?
18:38offby1gaah, once again hosed by my inability to run "strace" on OS X.
18:38offby1grr
18:40offby1this is probably laughably ignorant, but: short of strace, how can I tell which clojure I'm using?
18:42Bronsa,(clojure-version)
18:42clojurebot"1.4.0-master-SNAPSHOT"
18:43offby1that would require that I have a repl running :)
18:43offby1I guess I could "lein repl".
18:44offby1user=> (clojure-version) => "1.2.1"
18:44offby1hmm
18:44autodidaktohow are you using clojure?
18:44offby1I nuked ~/.m2 an ~/.lein, and re-ran "lein test", and it downloaded some stuff ... and then failed the same way.
18:45offby1autodidakto: just running "lein test" at the moment
18:45ldopaoffby1: pgrep -lf clojure. should be able to see the version of the jar on the cp
18:45offby1hmm, clever
18:45offby1zip nada bupkis -- pgrep gave no output.
18:45offby1probably help if I actually had a java process running though :)
18:45offby1let's try again
18:46offby1http://ix.io/2h6 <-- 1.2.1 clear as day
18:47offby1I guess I gotta see if this problem repros on *nix, where I can actually run strace.
18:55amalloyoffby1: that's just the lein jvm, though - it's running on 1.2, but it launches another jvm for your app to run in, and that might be some other version
18:55offby1amalloy: hence my desire to repro this on linux -- I have no idea what files are being loaded by what processes
18:56amalloyi never mastered strace. i hear it's awesome, and a few times i've tried, but i've just had a terrible time learning anything
18:56offby1any suggestions for which Java package I should install on Ubuntu 11? The choices are overwhelming :-p
18:56offby1odd, I'm an strace whiz
18:58offby1I think the secrets are 1) knowing which system calls to trace (the default of "all" can be overwhelming); 2) putting the output into a file that you can then browse with your favorite editor
18:58autodidaktooffby1: why you keep hosing it, then?
18:58offby1autodidakto: why do I keep hosing what?
18:59amalloyoffby1: i think i installed openjdk-6-jdk, but on 10.10, not 11
18:59autodidakto"gaah, once again hosed by my inability to run "strace" on OS X."
18:59offby1autodidakto: I'm still not understanding your question
18:59offby1I simply meant that, because I don't know how to run strace on OS X (the program is Linux-specific), I can't investigate my problem
18:59amalloyer, that's a total lie. i'm on 11.10
18:59amalloyi just forgot what year it is now
19:00amalloyso, openjdk-6-jdk is probably a reasonable choice for you
19:00offby1*sigh* my Ubuntu laptop has chosen _now_ to do an unattended dist-upgrade
19:01autodidaktooffby1: ahh. thought you tweaked a config and broke it something. not a question anyway, just teasing
19:01offby1autodidakto: I think OS X has some equivalent ("dtrace" maybe) but I've never learned it
19:02aperiodici've never had luck with dtrace
19:02offby1kinda smells all enterprise-y
19:02aperiodicdisktop uses it, and it just spews error messages
19:16offby1w00t, repros on *nix; now for "strace" wizardry
19:19offby1grr
19:19offby1time to grovel some git repositories, I guess
19:23offby1well, this is probably a clue: after cleaning thoroughly with "git clean -dxf", then running "lein test" again, I see the message "Copying 2 files to /usr/local/src/anagrams/clojure/lib". Looking in that directory, I see: clojure-1.1.0jar and clojure-contrib-1.1.0.jar
19:23offby1why would lein copy an old version of clojure, and then expect a newer one?
19:29dnolen`all CLJS IPrintable types have JS toString methods now - fixes behavior of the IPrintable CLJS types w/ str
19:32amalloyoffby1: i suspect if you could link to your project.clj (and source files if possible; they might or might not be necessary) it would be the work of a couple minutes to tell you the problem
19:35offby1technomancy: "lein test" is failing; the problem seems to involve it downloading and using clojure 1.1. See http://ix.io/2ha for a bit of a transcript
19:35offby1amalloy: ok, hold on
19:36offby1amalloy: https://github.com/offby1/anagrams/commit/5e7a2bd029ce73932355658529a0909bbf55e72e
19:37offby1I wonder if it's because the project.clj file asks for that old version
19:37amalloyoffby1: https://github.com/offby1/anagrams/blob/master/clojure/project.clj
19:37amalloyyes
19:37amalloyyou ask for an old version, and by god you get an old version
19:38devnI saw some discussion not too long ago about corelibs using type hinting to avoid reflection warnings
19:38devnsay I (:import [com.foo.bar.baz BazThing])
19:38offby1amalloy: the nerve!!
19:38amalloyi would say: depend on 1.3, don't depend on contrib at all, and write your own version of lower-case
19:38devnis it sufficient to hint like (defn foo [^BazThing baz-arg] ...)
19:39amalloyor use one from a different lib, like apache commons
19:39offby1amalloy: huh
19:39offby1why?
19:39clojurebotwhy is the ram gone is <reply>I blame UTF-16. http://www.tumblr.com/tagged/but-why-is-the-ram-gone
19:39xeqi&(clojure.string/lower-case "ASDF")
19:39lazybot⇒ "asdf"
19:39amalloyoh, it's in clojure.string. use that, then
19:39offby1hm, OK
19:39amalloyit's *also* in java.lang.String/toLowerCase, which i hadn't noticed
19:40devn,(.toLowerCase "ABCD")
19:40clojurebot"abcd"
19:41amalloybtw, just browsing through this code, combine could be a lot simpler: (defn combine [words anagrams] (for [word words, anagram anagrams] (cons wod anagram)))
19:52unlink(binding [*warn-on-reflection* true] (letfn [(lower [s] (.toLowerCase s))] (lower "ABCD")))
19:53unlink,(binding [*warn-on-reflection* true] (letfn [(lower [s] (.toLowerCase s))] (lower "ABCD")))
19:53clojurebot"abcd"
19:53unlinkoh, it's not dynamic.
19:55brehaut,(do (set! *warn-on-reflection* true) (let [lower (fn [s] (.toLowerCase s))] (lower "ABCD")))
19:55clojurebot#<IllegalStateException java.lang.IllegalStateException: Can't change/establish root binding of: *warn-on-reflection* with set>
19:56amalloyunlink: indeed, that will cause reflection
19:56devnreflection is a bummer
19:57devnjust got rid of a bunch of warnings -- word to the wise: dont wait until you've written a bunch of code to tackle your reflection warnings
19:57devnjust had to traverse a bunch of javadoc to remember what happened where
19:58devnNode => NamedNodeMap => DomAttr
20:02offby1nuts. for some reason I thought integers in Clojure were infinite-precision, like in some Schemes ... I don't suppose they are.
20:03amalloyoffby1: wellllll
20:03offby1with the M suffix
20:03offby1I guess they are
20:03amalloyin versions before 1.3 they were infinite-precision by default
20:04amalloystarting with 1.3, you can get infinite precision either by using the M suffix or by using promoting operators like +' instead of + and *' instead of *
20:04offby1ah
20:04offby1thanks; my code dates from before 1.3 so it assumed infinite-precision
20:05amalloybut integer literals are 64 bits, which is practically infinite anyway. i find it a little surprising you'd use that up without noticing
20:06beffbernardamalloy: Do you know the reasons why they moved away from infinate-precision? Other than performance reasons/
20:07amalloywhy would there be any other reason?
20:07amalloylike, if performance didn't matter, there would be no benefit at all to moving away from infinite precision
20:07beffbernardI guess there could be political reasons
20:08offby1is there a deftest macro that's specialized for testing equality? (is (= this that)) works, but if the test fails, I don't get a nice message saying "this was 27 but that was 19".
20:08beffbernardI suppose checking for overflow/boxing/primitives would be costly
20:08dnolen`beffbernard: it was for perf reasons.
20:08dnolen`beffbernard: checking for overflow is not that costly - boxing primitives is.
20:08TimMcThe decision was made over several dead bodies.
20:09beffbernardTimMc: lol
20:10amalloyoffby1: doesn't it say something like "expected: (= this that); actual (not (= 27 19))"?
20:11offby1oh, lemme look again
20:11offby1gonna get a callous on that forehead pretty soon :)
20:11offby1thanks
20:12devncan you remove a reflection warning, but have another spring up in its place? As in: If I hint an arg or two, but then that function is generic enough to work in another context, do I wind up with a new reflection warning for that type?
20:12devnor can i rest easy knowing that all hints are as they should be once reflection warnings subside?
20:14S11001001devn: actually, you end up with a classcastexception at runtime
20:14S11001001consider (defn close-thing [it] (.close it))
20:15S11001001if you lock down it to a particular interface or class, it won't pick up other no-arg methods named "close", and you'll get a ClassCastException for trying to use them
20:16devnso then the question becomes (in my mind) -- do I err on the side of being specific, or err on the side of reflection
20:16S11001001choose reflection
20:16devnit seems like historically the answer has been the former
20:16devnreally?
20:16FrozenlockI find myself doing (first (filter ...)) quite often. Is there a function for that?
20:16S11001001I disagree; historically, the answer I have heard, from Rich et al, has been leave reflection alone until you need to fix it for performance
20:17devnFrozenlock: I must be mis-remembering -- I've seen discussion on the clojure mailing list which discuss whether or not hints should be required for new "contrib" libraries
20:17devni write "contrib" because...well, clojure.contrib is no more
20:17devnmaybe it was for core libs
20:18S11001001Frozenlock: there was, but it was dropped because it was kind of pointless when you can just first filter
20:18FrozenlockOk, at least I know I'm the only one :)
20:18Frozenlock*not
20:18FrozenlockThanks!
20:19TimMcS11001001: ffilter?
20:19S11001001find-first
20:19devnwrite one! :)
20:19devn(defn ffilter [pred coll] ...)
20:20S11001001in all seriousness simple juxtapositions of two functions don't really deserve librification
20:20brehaut(def first-where (comp first filter))
20:20S11001001I'm also against not=, if-not, & such
20:20Frozenlockdevn: Sure, was just wondering I there was already something for it (example if; when).
20:20devnFrozenlock: there might be, but it not might be the path you're staring down
20:20devnFrozenlock: phrase your question in terms of data in, data out
20:21FrozenlockMultiple maps in, single maps out
20:21devnuse data
20:22aperiodicdevn: my impression is that requiring hints for libraries is just so there's no performance issues from the library, which would be inconvenient for library users to fix. in your own code, i'd say forget about reflection unless it's in an inner loop
20:25devnaperiodic: it feels like a nice exercise, though
20:25devnaperiodic: if i'm writing a library for public consumption, why not do it?
20:25amalloyS11001001: well, not= is sorta in a different category, because there's a jvm bytecode instruction for it; (not (= x y)) would be much less performant. it's also often a more-clear way to write what you mean
20:26aperiodicdevn: oh, yeah, for a public library, not having reflection is definitely a benefit.
20:29offby1*sigh* Why am I getting ``Could not start swank server: That's not a task''? Lein is as far as I know up to date; so is clojure-mode
20:30yoklovyou need lein-swank
20:30yoklovhttps://github.com/technomancy/swank-clojure
20:31offby1odd, I've never had to install that manually before
20:32yoklovweird, i think i always have
20:32devnoffby1: how do you try to start it?
20:32aperiodicit could've been a dependency or dev dependency of the other projects you ran `lein swank` in
20:32devnclojure-jack-in, slime-connect, etc
20:34offby1devn: M-x clojure-jack-in
20:34Frozenlocklein plugin install swank-clojure 1.4.0
20:34offby1Frozenlock: aha, that sounds good
20:34devnyeah, do that
20:34devni was living in the olden days until recently
20:34devnM-x slime-connect
20:34FrozenlockNo dependency needed after that P)
20:34Frozenlock:)
20:34devnyeah, much nicer
20:35yoklovi thought that was deprecated (though it's what i do too)
20:35FrozenlockPerhaps... I'm still rocking lein 1.
20:35offby1Frozenlock: success! Thanks
20:35FrozenlockMessing with clojure made me a new man: If it ain't broken, don't fix it!
20:36Frozenlockoffby1: np
20:36yoklovyeah, lein version 2 crapped out on me once so i installed it as lein2 and i never remember to use it
20:36devni feel like part of the clojure motto is to absolutely fix it if it's fundamentally broken
20:36devnthat's sort of the obligation
20:40wei_speaking of lein, what's the best way to include a java project as a dependency?
20:41ocmvn is a sure bet
20:44oc(release the java project as a jar/war/ear-packaged mvn artifact, then depend on it using lein)
20:45wei_oc: could you point me to instructions on how to do that?
20:47ocif you are unfamiliar with maven, I suggest you start with sonatype's guide for how to release jars (i.e. to nexus) using mvn deploy:deploy-file
20:47FrozenlockI think you can also put them on clojars- but I really don't know how.
20:50aperiodicyeah, i usually just throw em up on clojars under my username group
20:51ocmaven is an entire ecosystem for handling the complexities of dependencies, releasing, versioning and distribution... (love it or hate it, it does that part quite nice) explaining how it works is kinda out of scope. There are however two things you can do easily given that the java project is not itself built with maven; 1) if you are the sole developer, you can always locally release it using mvn install:install-file, 2) release it to a mvn repository using mvn d
20:51aperiodicwei_: can you get produce the jar you want lein to be able to grab?
20:51wei_yup. it's this project https://github.com/gvsumasl/jacc
20:52wei_i've been putting the jar in lib/ -- and that works until i call "lein deps" which clears the lib directory
20:53amalloy~repeatability
20:53clojurebotrepeatability is crucial for builds, see https://github.com/technomancy/leiningen/wiki/Repeatability
20:54wei_thanks, I had a feeling it wasn't the right way to do things
20:54oci guess you can also use a local store such as libs, just remember to datestamp the jar for future developers ;)
20:55offby1hmm, (= 1 1M) => false .... surprising
20:56ocsurprising?
20:56oc(type 1M)
20:57amalloy&(== 1 1M)
20:57lazybot⇒ true
20:58wei_if I don't want to set up private maven repo, is it appropriate to upload a pure-java project to clojars?
20:58aperiodicwei_: i'm guilty of that
20:58wei_cool :)
20:58muhoonow i'm usin glein to build java projects too. i ain't going back ant unless someone drags me kicking and screaming.
20:58muhoolein, not glein
20:58occlojars is just a m2-repo isn't it? :)
20:59offby1oc: I guess I figured = was "numerical equality".
20:59offby1as opposed to (say) "identity" -- analogous to scheme's "eq"
21:00amalloyyeah, the distinction between = and == is a little weird to me
21:00offby1in scheme you have (at least) three kinds of equality, and you need to know which one is which :-|
21:00amalloy== is a special numbers-only comparator, which i guess is faster and more...type-ambivalent?
21:00offby1I've made my peace with that
21:00ocoffby1: = sadly equals Java' equals() ;)
21:01offby1and I'm 100% ignorant of Java
21:01oc(fortunate when dealing with java)
21:01offby1so is that basically a pointer comparison?
21:01ocumm when i think of it, it also considers nil
21:02amalloyno, identity? is a pointer comparison
21:02ochumm, i just read the doc. wtf.
21:02oc&(doc =)
21:02lazybot⇒ "([x] [x y] [x y & more]); Equality. Returns true if x equals y, false if not. Same as Java x.equals(y) except it also works for nil, and compares numbers and collections in a type-independent manner. Clojure's immutable data structures define equals() (and thus =) ... https://refheap.com/paste/1794
21:02amalloy= is the general-purpose "are these the same thing", and == is some weird wart that you occasinoally see used for numbers
21:03oclazybot cut this part: " Clojure's immutable data
21:03oc structures define equals() (and thus =) as a value, not an identity, comparison,"
21:04offby1ask the bot if 1 equals 1M.
21:04oc&(= 1 1M)
21:04lazybot⇒ false
21:04oc&(== 1 1M)
21:04lazybot⇒ true
21:05amalloyoc: ...he linked to a paste of the part he cut off. i don't know why you would paste that back into the channel; anyone who wants to read it all can follow it
21:05offby1works for me!
21:05offby1oc: thanks
21:06ocamalloy: well, the last sentence was the crux :)
21:06fhilHi, all. Quick question. I'm considering picking up Clojure. Slowly. Is this the right place to be as a newbie?
21:06offby1fhil: absoloosely
21:06offby1fhil: they haven't kicked me out yet :)
21:07fhilSounds good.
21:08amalloydon't listen to him, he just wants someone else to get picked on when he's not the most junior anymore
21:09fhilJoy of Clojure. Will start next week.
21:09muhoofhil: i recommend clojurebook.com
21:10fhilYou're good offby1. I can take the low punches... instead. You can relax now.
21:11ocjoy of clojure is imho somewhat more advanced than i.e. clojure in action. Though absolutely a great book
21:11fhiljava/groovy background
21:11RickInGAI really liked the 2nd edition of programming clojure by stuart halloway and aaron bedra
21:11oci usually recommend CiA first for java devs
21:12ochaven't read programming clj
21:13RickInGAthe last chapter walks through creating a web app with noir and deploying it on heroku
21:13RickInGAwas the reason I bought it, but the whole book is good
21:13oci.e. the webnoir.org tutorial? ;)
21:13yoklovisn't there a new clojure book?
21:14RickInGAoc: good point, the tutorails for noir are fantastic
21:14RickInGAyoklov: yes, Clojure Programming by Chaz Emerick. What I have read of it has been very good.
21:14fhilIs Noir the faved web framework?
21:14cemerickyoklov: You may be thinking about http://clojurebook.com, which muhoo mentioned abobve
21:14fhilArguably...
21:14ocring is my fav web framework ;)
21:17ocnoir builds defpage and some middleware (and a lot of other nice stuff) onto ring
21:18fhilthe smaller the better.
21:20offby1I notice that it takes about ten seconds from when I type "lein test", to when I see ``Testing anagrams.test.core''. (This is a not-terribly-slow Macbook Air). Is that typical? If not, is there something simple I can do to reduce that delay?
21:22yokloverr, so what's the deal with the new clojure book?
21:23offby1It's new. It's about Clojure. And it's a book.
21:23yoklovwell what's the target audience?
21:23cemerickyoklov: Did you go to http://clojurebook.com? ;-)
21:23yoklov / is it a good reference?
21:24offby1no idea.
21:24yoklovI mean, it suggests that I am its target audience, but… is that _really_ true?
21:24offby1haven't read it.
21:25yoklovOkay, so targetted at java/ruby/python devs?
21:25fhilcemerick: cheers. Thanks for the work on the book.
21:25RickInGAyoklov: I have donly dipped in and out of it, but what I have read has been very well written.
21:26RickInGAyoklov: the ns macro with use and require was a mystery to me until I read that part of the book.
21:26cemerickyoklov: well, I *hope* we're not lying to you :-)
21:27cemerickfhil: Sure, I hope you're enjoying it.
21:27muhooi found it the clearest and easiest to digest so far, though the noir docs are also exemplary, imho
21:27fhilNot yet. Just learned about it.
21:29muhooin fact, i treat it as docs, and find myself blitzing around it as a reference, instead of hittting google. or here :-)
21:32mkwhich new book is this?
21:33RickInGAmk: Clojure Programming by cemerick, et al. from O'Reilly
21:33brehautmk: http://www.clojurebook.com/
21:38mkthanks. What's the animal on the cover?
21:40brehaut“The animal on the cover of FILL IN TITLE is FILL IN DESCRIPTION.”
21:40brehautthats from the colophon
21:40brehautalthough i probably have an old pdf
21:44alex_baranoskyjust curious: do a lot of you guys use core.match?
21:55devnalex_baranosky: i think it's a mixed bag
21:55alex_baranoskydevn: funky syntax?
21:55alex_baranoskyI pretty much have only ever used it to flatten nested conditionals
21:55devni have a hard time saying I "use" it. I use it, but it's not an automatic requirement.
21:56alex_baranoskyI use it alla carte I guess
21:56devnI find myself wanting for very general, specific reasons
21:56devnmuch like your example of flattening nested conditionals
21:58yoklovclojure already has destructuring so i don't need it as often as i did when i wrote in racket
22:005EXAAM9RUalex_baranosky: What part of the syntax do you think is funky? the (match indentation part? or?
22:01alex_baranosky5EXAAM9RU, I don't per se. Just thought devn might have been thinking that
22:30dnolenCLJS now warns on redef and the various shadowing issues around redef fixed
22:35autodidaktoAhhh. Nothing like rainbow parenthesis to show my pride.... in lisp.
22:36eggsby:)
22:36eggsbycould someone speak on cljs v. something like coffeescript?
22:36eggsbyI've been using coffeescript for a few months to my great enjoyment, why might I want to switch to cljs?
22:36autodidaktoeggsby: specify good sir!
22:37autodidaktoeggsby: what do you do with coffee/js?
22:37autodidaktocljs is more than a cleaner way to write js
22:37yokloveggsby: with coffeescript you still have most of JS's problems, they're just hidden from you
22:37eggsbyWell, I enjoy coffeescript because it simplifies scoping and provides shorthand notation for best practices. I (and some of my coworkers) are wondering what we could gain by using cljs
22:38yoklovclojurescript attempts to actually tackle the flaws
22:38eggsbyWe all like clojure so it seems like a good road to go down, but we're all having trouble envisioning what we'd gain from it
22:38eggsbyyoklov: what is the generated js like?
22:38autodidaktocoffeescript is easier js. cljs can be a replacement for js
22:38yokloveggsby: very tough to read.
22:38yoklovyou get surprisingly used to it
22:38yoklovbut its rough.
22:39autodidaktoyou dont do cljs to generate js. you do it for client-side, in browser clojure
22:39yoklovwell you still need to look at the generated code a lot.
22:39yoklovi do at least
22:40yoklovdebugging and such
22:40dnoleneggsby: it depends on whether JS semantics work well enough for you.
22:40dnoleneggsby: I prefer CLJS semantics. And I don't think I'd use anything where I don't have access to core.match / core.logic - but I'm clearly biased.
22:41autodidaktoit's pattern matching
22:41dnoleneggsby: one thing I definitely think is superious is managing front end dependencies - lein cljsbuild is turning to be great for that.
22:41dnoleneggsby: when I use JS and CoffeeScript managing deps is pretty ad-hoc.
22:42eggsbyIt is, there's no beaten path as far as asset management goes
22:42eggsbyThough there are a lot of options
22:43dnoleneggsby: and lein is pretty darn good compared to what's out there :) stuff like bundler, rvm which I use at work is oh so bad.
22:43eggsbyWhat about interoperability with js libs? Is it easy enough to do fluid interfaces? (with the .. macro for instance?)
22:44dnoleneggsby: the js interop story is OK, but to be honest there's very few JS libs that I think are any good.
22:44eggsbyI know in jQuery for example fluid interfaces are extremely popular, they were always kind of a hassle (not very idiomatic) in coffeescript
22:44dnoleneggsby: we use underscore.js, no need for that in Clojure.
22:44eggsbyHm, fair point. I use underscore and backbone quite a bit, but so long as I could access the vars and js keywords (i.e. "new") I needed i'd be fine
22:44hhutcheggsby: i've written a fair amount of demo code using Google Closure APIs and Clojurescript
22:45dnoleneggsby: I don't really have an opinion one way or the other about jQuery, it's useful but I'm ready for something better.
22:45eggsbyAt the end of the day I won't know whether its right for me until I try it out :)
22:45hhutchthe interop, to me at least, is the same as with java
22:45eggsbydnolen: agreed
22:45devndnolen: what's your take on bundler?
22:45dnolendevn: bunlder rake exec wtf
22:45eggsbyjQuery is bloated is my issue, which is tied to another interest about cljs generated js, if its unreadable to me that sounds like it may be generated unnecessary code to support the syntax, which slows things down, broadly speaking
22:46eggsbyIs this a 'real issue' or just a red herring?
22:46eggsbys/generated/generating
22:46dnoleneggsby: I think with source maps the tables are going to dramatically change around front end dev.
22:46dnoleneggsby: GClosure dead code elimination is too good.
22:46dnolenwhy should I use your 150k library when I only need 5k of it.
22:47devndnolen: because it might mean you need to give your client a CD instead of a floppy
22:47devn??
22:47lazybotdevn: Uh, no. Why would you even ask?
22:47dnolenthis whole movement around tiny JS libs is very short sighted - just use better tools IMO.
22:48devnagreed.
22:49dnolenJSConf went well - definitely got some folks interested in the idea of ClojureScript and hopefully less afraid of Lisp in general.
22:49devnthat's a trend
22:49eggsbyhhutch: where could I find that demo code?
22:50eggsbydnolen: you have any idea whether yr talk will be publicly available? If so any idea when? :D
22:50devndnolen: i see a lot of people who have been cutely critical of lisp and fp starting to "get it"
22:51dnoleneggsby: I don't know actually.
22:51eggsby:(
22:51dnoleneggsby: but probably not too long.
22:51eggsbyontwik got some from last year, but they kind of slowly trickled out
22:52dnolendevn: yep
22:53FrozenlockIn Noir, is there a way to export a bunch of page as html, but with the folders at the same time (in order to keep the same paths)? I would like to make an offline backup of static pages.
22:53eggsbyheh, making jeckyll in noir?
22:54eggsby-c
22:54FrozenlockJeckyll does that?
22:54devnFrozenlock: just use wget?
22:54Frozenlockdevn: of course!
22:54FrozenlockThanks!
22:54FrozenlockHowever, as I'm mostly trying to learn clojure.. is there an in-clojure way? :P
22:55xeqiFrozenlock: clj-http ?
22:56yoklovFrozenlock, maybe some way of messing with the routes table? That was actually one of the proposals for google summer of code this year (so i don't think anybody did it).
22:56devnFrozenlock: you could shell out. wget just does so much for you that it seems sort of crazy to not use it
22:56yokloverr, has already done it*
22:56devnthere is, im sure, a wget for java
22:57Frozenlockdevn: indeed, found one in half a second http://www.devdaily.com/blog/post/java/jget-something-like-wget
22:58FrozenlockI might take your advice and just relax on this one.
22:58devnFrozenlock: i mean, you *caN*
22:58devn*can*
22:58devnbut it's just probably not worth it if you just want to run it over your site
23:01johnkpaulis there anything special about the default user namespace?
23:01devnjohnkpaul: no, not really
23:01johnkpaulusing clojurescript, I can easily def a symbol in cljs.user
23:01johnkpaulbut when I'm in any other namespace, it errors out
23:02devnjohnkpaul: script/repljs?
23:03johnkpaullein trampoline cljsbuild repl-listen
23:03devni have no idea what that means :X
23:03johnkpaul:/ that's the command I ran to get the repl
23:04johnkpaulbasically, after running that, (def hello "world") works fine
23:04dnolenjohnkpaul: hullo!
23:04johnkpauland I can run (identity hello) and I get "world"
23:04johnkpaul:D hey dnolen
23:04johnkpaulfigured you'd be swanodette in here too
23:05johnkpaulI'm working on something dear to your heart actually
23:05dnolenjohnkpaul: hmm, I haven't run into that problem. how are you switching namespaces?
23:05dnolenjohnkpaul: !
23:06johnkpaul(in-ns 'cljs-demo.core)
23:06dnolenjohnkpaul: yeah that should just work.
23:06johnkpaulso that works fine
23:06johnkpauland from there, I can run (identity cljs.user/hello)
23:06johnkpauland that works as well
23:06johnkpauland from there, I can run alerts or console logs
23:06johnkpaulbut I can't def
23:07johnkpaul(def test "hello") gives me ...
23:07johnkpaul"Error evaluating:" (def test "test") :as ".test = \"test\";\n"
23:07johnkpaul#<SyntaxError: syntax error>
23:08dnolenjohnkpaul: yeah, there's a bug in JIRA. I think using in-ns without first evaluating the ns form doesn't work right now.
23:09johnkpauloh! ok, let me try that
23:09eggsbyhmm, 56kb hello world :(
23:10dnoleneggsby: heh, yeah CLJS doesn't compete against hello world in JS or CS
23:10johnkpaulso that works dnolen, it takes > 30 seconds to load it all into the browser
23:10dnoleneggsby: only if you already use something like jQuery + Underscore.js, then the size is competitive
23:10johnkpaul"it all" meaning all of the macros and modules in cljs-demo.core
23:11eggsbydnolen: so you use cljs in leiu of jquery? how do you handle dom selection/event delegation?
23:11dnolenjohnkpaul: huh, that seems odd - it never takes more than 2-3 seconds for me.
23:11eggsbyor ajax, etc
23:11johnkpauleggsby: cljs includes the google closure toolkit
23:11dnoleneggsby: domina is getting good and GClosure is actually fine for the basics.
23:11johnkpauleggsby: http://closure-library.googlecode.com/svn/docs/closure_goog_dom_dom.js.html
23:12dnoleneggsby: one my favorite things to show is that a project that uses GClosure, domina, core.logic generates 650k of code
23:12dnoleneggsby: but after advanced opts and gzip - 34k
23:13johnkpauldnolen: so that load time might be FF, I haven't tried in chrome
23:13johnkpaulbut what I'm looking for now is how to run code after the repl starts up
23:13johnkpaulsomething like python's -i
23:13dnolenjohnkpaul: remember there's no load time that's browser related when you eval ns form
23:13dnolenjohnkpaul: that's all in the browser REPL (which is not in the browser)
23:14johnkpauloh, I didn't have to run all of the other parameters to ns
23:15johnkpaulI passed :use-macros and require-macros and all of that
23:15johnkpaulmaybe that's what took so long?
23:15dnolenjohnkpaul: it's a bit weird to realize but eval'ing ns form doesn't trigger anything in the browser.
23:15johnkpauloh, really? But I saw tons of ajax requests
23:15dnolenjohnkpaul: w/ browser REPL you have to sometimes deal w/ browser REPL sync issues, sometimse just refresh.
23:15dnolenjohnkpaul: definitely unrelated
23:16johnkpaulhm, they were actually all almost the same line
23:16johnkpaulif(goog.getObjectByName('clojure.browser.event')){true}else{false};
23:16johnkpaulit was just different object's by name
23:16johnkpaul~ 20 of them
23:16clojurebotCool story bro.
23:18johnkpaulanyway, that's something I can figure out
23:18johnkpaulbut do you know if I can run a script in the repl before it ends up with the user
23:18johnkpaulI want to preload that namespace
23:18johnkpaulso the user can just start playing with the repl with everything loaded
23:19jonasendnolen: do you have time for a core.logic question?
23:19dnolenjohnkpaul: if you build the file once, everything is compiled, so the browser has it all.
23:20dnolenjohnkpaul: only trick is to start the repl and eval the ns expression, to save them one step.
23:20johnkpauloh I see, yeah, that's what I want, if they can start with the repl in the right namespace
23:20dnolenjohnkpaul: yes
23:20dnolenjonasen: what's up?
23:21johnkpaulok thanks, I need to get dinner, I'll continue working on it afterwards but I'll be back
23:21jonasenI'm trying to make a version of appendo which would take an arbitrary number of args, called `concato`
23:21dnolenjohnkpaul: I would recommend making a custom lein task - might want to pick some brains in here that have done that more than I have.
23:22dnolenjonasen: sure
23:22jonasendnolen: but I dont't know how to do the recursion (because of https://gist.github.com/2236019)
23:23dnolenjonasen: what does you attempt at concato look like?
23:24jonasendnolen something like https://refheap.com/paste/1795
23:25dnolenjonasen: looking
23:30Frozenlock(.mkdirs (file "asdf")) Creates a directory called "asdf". (make-parents (file "asdf")) does apparently nothing. How is this function supposed to be used?
23:31dnolenjonasen: https://gist.github.com/2307725
23:31jonasendnolen: thanks, I'll take a look
23:33dnolenjonasen: only slightly different from yours
23:36bowskiHello clojure friends. I'm learning this language for a project I just got. I've never written in clojure, but I defined 8 nodes as lists with things in them. Right now I just want to go through each node and display the first thing (car, right?). Can someone help me learn the right way to go about it?
23:36Frozenlockbowski: not car, first
23:37bowskioh, ok. I've done a little scheme before and they look very similar
23:37FrozenlockCar would have been right for other lisps.
23:37brehaut,(map first [[:a :b] [:c :d]])
23:37wei_(map #(println (first %)) nodes)
23:37jonasendnolen: I commented on your gist
23:38dnolenjonasen: it's easy to run into non-termination with concato
23:39bowskiI labeled them node0 - node7. how could I access all of these? It looks like map is the way to go. I'm reading up on the clojure doc for map
23:39dnolenjonasen: you absolutely cannot call appendo w/ all fresh vars.
23:39jonasendnolen: ah, I see
23:43jonasendnolen: Do you think there's a different approach? A different way to implement `concato` with stronger termination guarantees?
23:44dnolenjonasen: pondering it a bit right now :)
23:44jonasendnolen: :)
23:45jonasendnolen: Also, is this a restriction in miniKanren or does (for example) prolog behave the same way?
23:45dnolenjonasen: pretty sure Prolog has the same problems.
23:46jonasendnolen: Good! Then it should be possible to find something in Prolog literature!
23:47dnolenjonasen: yes or ask on StackOverflow with the equivalent Prolog
23:47dnolenjonasen: I've gotten very nice insights there that way.
23:51bowskisay I wanted to (println node1 - node7). How could I append a string for the range of 1-7 to be executed? Also, thanks for taking the time to read/help me guys.
23:54bowskijwpalmer: Haha, my professor I believe
23:54unlinkDo people typically deploy with OpenJDK nowadays?
23:59eggsbyunlink: I think everyone still uses oracle, openjdk still has some bugs for a lot of libs :/