#clojure log - Apr 11 2012

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

0:00 amalloy: but i recently overdid it, i think, in trying to make a mutable database "look" immutable from the clojure POV. it's not a clear line to draw

0:01 ppppaul: wkmanire, datomic DB

0:01 lol

0:02 couchdb is immutable too

0:02 sorta

0:02 wkmanire: I've never heard of either of those.

0:02 But I'm pretty sure that couchdb is mutable.

0:02 ppppaul: nope

0:02 unless you tell it to be

0:02 you have to tell it when to mutate

0:02 which could be never

0:03 muhoo: mutate or gc?

0:03 ppppaul: i've been working with it for about a year

0:03 well, gc

0:03 but you can see all the garbage/revisions up until then

0:03 muhoo: i'm trying to wrap my brain around couchdb atm

0:04 ppppaul: couchapps are pretty cool

0:04 muhoo: after decades of sql, i feel a bit lost in how to structure data to make it nosql-idiomatic

0:04 bbloom: speaking of datomic, i asked over in #datomic yesterday, but the room is pretty quiet… are there IRC logs?

0:04 i'm curious to see the recent discussions over there

0:04 muhoo: i.e. i have a compulsion for 3rd normal form i'm trying to recover from :-)

0:05 wkmanire: ouch

0:05 ppppaul: lol

0:05 do your dbs even work?

0:05 muhoo: hehe

0:05 they're not "web scale", but yes they waork

0:05 wkmanire: muhoo: I'm tired of databases doing anything other than storing and returning data.

0:05 ppppaul: couch is neat in that you can make your tables when you need them

0:05 and when you make a table it gets mega indexed/cached

0:06 muhoo: oh, i'm so irritated with orm's and activerecord, i'm eager to learn a better way, believe me

0:06 wkmanire: muhoo: Microsoft had a brilliant idea and interfaced .Net with SQL Server so you can now write .Net libraries that run CLR code directly against database structures before they are returned by your Stored procedures, queries etc...

0:06 bbloom: muhoo: tell me about it. active record is *killing* me :-/

0:06 muhoo: wkmanire: isn't that kind of like couchdb views?

0:06 amalloy: bbloom: Raynes offered to have lazybot log for them, and i think the response was "gosh that sounds interesting, we should file a jira issue for discussing whether we want that"

0:07 ppppaul: i think couchdb views are like stored procedures

0:07 muhoo: bbloom: square peg, round hole, indeed.

0:07 wkmanire: muhoo: I've only read about couchdb in passing. I've not actually used it.

0:07 muhoo: i've played with it. i have to admit the idea of running views in clojure has me salivating

0:07 bbloom: amalloy: i see being built on the JVM isn't without problems… the enterprise mind poison is strong :-P

0:07 ppppaul: you prob want your views in the db

0:07 muhoo: but, if i use a hosting server, i have to write them in js. or maybe cljs (experimental)

0:08 wkmanire: muhoo: In imperative land there is a huge push to unit test all of the behaviors of your application. Any logic that gets moved into a sproc gets a lot harder to test and isn't encapsulated by your business classes.

0:08 ppppaul: oh, those views

0:08 wkmanire: I've been burnt by that over and over again.

0:08 ppppaul: clojurescript views would be nice

0:08 it's not so hard to test views in couchdb

0:08 bbloom: while trying to contribute to CLJS, my limit experience with JIRA has quite unpleasant

0:09 to the point that I kinda don't want to contribute….

0:09 ppppaul: you can write curl unit tests

0:09 bbloom: GitHub has just spoiled me so much

0:09 amalloy: bbloom: cljs is so much easier to contribute to than jvm-clojure

0:09 bbloom: yup, i've got a few patches that dnolen merged for me

0:09 amalloy: dnolen is like a hero straight out of some greek myth

0:10 muhoo: indeed. cljs, core.logic....

0:10 there are so many heroes in clj land actually

0:10 amalloy: every clj patch i've filed has been dropped on the floor; every cljs patch has been merged in under 24 hours

0:10 muhoo: these guys are immensely smarter than me. it's scary and inspirational and depressing all at the same time.

0:11 bbloom: my latest cljs patch has a pretty big impact on the compiler

0:11 muhoo: amalloy: i have a feeling that rhickey really didn't want to be linus torvalds

0:11 bbloom: so i don't blame dnolen for taking his time to review it :-)

0:11 wkmanire: muhoo: Smarter is a function of time and effort.

0:11 ppppaul: is there going to be a clojure 1.4?

0:12 muhoo: i.e. he wasn't trying to start a huge community, he was trying to write something cool, then to make some money, not to be a leader of an opensource community

0:12 wkmanire: that is a very positive way to look at it.

0:12 ppppaul: you can fork clojure

0:12 amalloy: ppppaul: they're at like beta 84 now, should be out Real Soon Now

0:12 ppppaul: lead the revolution

0:12 what's the new dirt on 1.4? i haven't used it since 1.2

0:12 1.3 wouldn't work for me :(

0:13 muhoo: ppppaul: wat?

0:13 amalloy: well, it fixes a lot of the breaking changes 1.3 introduced for no reason

0:13 ppppaul: well, it broke my 1.2 projects to upgrade to 1.3

0:13 amalloy: while leaving in the ones it introduced for a reason

0:13 ppppaul: oh cool

0:13 alexbaranosky: lol

0:13 arohner_: amalloy: what breaking changes did 1.3 introduce, aside from contrib?

0:13 amalloy: &(class (int 1))

0:13 lazybot: ⇒ java.lang.Long

0:13 arohner_: oh right

0:13 bbloom: lol.

0:13 alexbaranosky: added the reader stuff

0:13 wkmanire: muhoo: Thats one of the reasons I'm here actually. Its nice that everything I see looks alien for a change.

0:13 amalloy: (= \a \a) causes a reflection warning

0:14 ppppaul: ...

0:14 wkmanire: muhoo: I'm going to get a lot more bang for my buck (smarter for my time) here for a little while.

0:14 amalloy: exceptions get wrapped in N layers of RuntimeException, where N is unpredictable

0:14 muhoo: wkmanire: i had a pretty severe anxiety attack recently. luckily cemerick's book saved me from self-destructino

0:14 wkmanire: muhoo: Cemerick's book? Sorry to hear that.

0:14 muhoo: wkmanire: why sorry? the book is fantastic.

0:15 wkmanire: muhoo: Condolences for the anxiety attack.

0:15 I've never heard of Cemerick or his book.

0:15 muhoo: wkmanire: clojurebook.com

0:15 wkmanire: Ah, I lied.

0:15 I was recently recommended to buy this.

0:15 But I didn't know th ename of the author.

0:16 bbloom: http://www.4clojure.com/ has been extremely helpful for learning the std lib

0:16 once i followed some smart folks, it was really nice to learn new tricks by looking at other's solutions

0:17 muhoo: so much of the clojure stuff was utterly impenetrable to me. his book is very practical, and i'm really a sysadmin/webmonkey kind of guy, so it was a huge relief to see examples i could relate to.

0:17 wkmanire: muhoo: Thanks for the advice. Did you start off in CS with imperative languages too?

0:17 muhoo: yep, bash, c, python, ruby, js, etc. some scheme.

0:18 wkmanire: muhoo: Trust me, I understand exactly what you mean.

0:20 muhoo: good to know. it was pretty funny on here for a while, lots of serious heavyweight devs talking about things that made my head spin trying to read.

0:21 budu: does anyone know how to get cljsc to pack everything inside a single file, i'm getting "cljs is not defined"

0:22 ppppaul: i'm not really sure how in datomic queries happen in the app code...

0:24 bbloom: ppppaul: if I understand it correctly, it happens by fetching database segments directly from block storage and loading them into an embedded database w/ query engine

0:24 budu: cljs is in clojurescript's bin

0:24 it's just a simple script that wraps the closure/build function

0:25 budu: bbloom: i mean the js namespace, not the script

0:25 bbloom: sorry, my brain parsed that as cljsc

0:26 :-P

0:26 budu: i'm trying to compile some files that could get run by a browser and nodejs at the same time

0:26 bbloom: when do you get cljs is not defined?

0:27 budu: if i'm compiling with this command:

0:27 cljsc test.cljs '{:optimizations :simple :pretty-print true}' > test.js

0:27 there's no cljs namespace defined anywhere

0:27 but with:

0:27 cljsc test.cljs '{:optimizations :simple :pretty-print true :target :nodejs}' > test.js

0:27 there is

0:28 ppppaul: so if i'm using datomic and i have a 1PB db... what happens?

0:28 bbloom: pppaul: presumably a lot of garbage collection due to cache invalidation :-)

0:29 ppppaul: haha

0:29 is datomic meant to be a local db? like couchdb?

0:29 bbloom: but more seriously, i read that datomic can join multiple data sources

0:29 so if your memory set is huuuuge

0:29 you could set up a funnel of peers

0:29 each operating on a segment

0:30 and map/reducing to a smaller set of data

0:30 which could act as a data source for down the stream

0:30 the same way you handle 1PB of data w/ any thing really :-)

0:30 ppppaul: datomic has a java shell?

0:30 lol

0:31 bbloom: budu: what do you mean "no cljs namespace defined anywhere"? you grepped the output?

0:33 wkmanire: whoever wrote this trycjl.com tutorial needs to be evaluated.

0:33 "Clojure has a great set of immutable and persistent data structures. Vectors, lists, maps, sets, I get chills."

0:33 amalloy: Raynes: hey look, someone's talking about you!

0:34 * wkmanire was hoping that "whoever wrote this" is here.

0:36 wkmanire: Raynes: Your tutorial is fun, I hope you finish it.

0:36 Raynes: Is this project on github? I'd like to follow it if it is.

0:38 xeqi: https://github.com/Raynes/tryclojure ?

0:39 wkmanire: muhoo: That book is available for kindle so I went ahead and bought it just now.

0:39 muhoo: great!

0:39 wkmanire: whoever gets kick backs for advertising it in the IRC should go claim their credits.

0:39 :D

0:39 muhoo: the only person here who does is, IIRC, the author

0:40 yoklov: heh, muhoo convinced me to get it too

0:40 muhoo: i'm just grateful it exists. full disclojure: i have no connection with the book or its authors.

0:41 amalloy: i've SEEN you palling around with cemerick in here! shill!

0:41 wkmanire: muhoo: You should establish one.

0:41 muhoo: You might be able to mutate the state of your bank account at this rate.

0:42 muhoo: amalloy: he convinced ME to buy it :-)

0:42 i spent the full $35 before it went on sale too :-/

0:42 bbloom: (reset! @account-bbloom 10000000000000000)

0:42 if only it were that easy

0:43 whoops no @

0:43 whatever :-P

0:43 muhoo: i do have an interest in more people using clojure who come to it from a similar place as i do

0:44 ,(reset! @account-bbloom 10000000000000000)

0:44 amalloy: (swap! bloom-account (comp last (partial iterate inc))) is more reflective of the real process

0:44 wkmanire: muhoo: I'm unfortunately not going to get to leave the windows world any time soon. And if I felt so compelled, would still not be able to leave the imperative world for some time after that.

0:44 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: account-bbloom in this context, compiling:(NO_SOURCE_PATH:0)>

0:44 wkmanire: muhoo: I'm hoping to learn a lot of new stuff I can take back to the imperative world to make my 9 to 5 more interesting.

0:44 muhoo: you do clr stuff?

0:44 wkmanire: yep.

0:44 Every day.

0:44 including today.

0:44 muhoo: well, there is clojure-clr, i'm told.

0:44 wkmanire: I don't even want to look at it.

0:45 muhoo: hahha

0:45 wkmanire: .Net already has F# for FP.

0:45 muhoo: like a starving man looking through the plate-glass window at the people eating chocolat cake, eh?

0:45 wkmanire: not tsay that clojure-clr shouldn't exist

0:45 Just saying, I'm looking to move out of windows and CLR developement all together.

0:45 amalloy: well, F# doesn't have macros

0:45 wkmanire: not to*

0:46 bbloom: amalloy: they are working on some interesting things for type-safe code generation

0:46 http://msdn.microsoft.com/en-us/library/hh156509(v=vs.110).aspx

0:46 amalloy: i wonder which .NET language i would pick, if someone told me i had to work on the CLR but could pick my language

0:46 brehaut: amalloy: it does have a syntax quotation thing though i think

0:46 muhoo: amalloy: it wouldn't be clojure-clr?

0:46 amalloy: too bleeding-edge for me

0:47 cemerick: muhoo: if it makes you feel any better, I have zero control over O'Reilly's pricing, etc.

0:47 wkmanire: I'm going to enjoy 4clojure.com

0:47 muhoo: wkmanire: i'm making a similar transition.

0:47 amalloy: and likely to have many confusing *almost*-the-same moments

0:47 muhoo: cemerick: it's ok, i wanted the pdf, and the only place to get it was oreilly at the time.

0:47 wkmanire: amalloy: I'm doing web dev with VB.Net

0:48 amalloy: okay, that's not the one i would pick

0:48 ibdknox: C# is a fantastic language

0:48 ppppaul: so to use datomic i need to have something running on amazon :(

0:48 c# is fantastic?

0:48 brehaut: amalloy: its not macros but http://msdn.microsoft.com/en-us/library/dd233212.aspx

0:48 pppaul: monads!

0:48 ahem. sorry. LINQ!

0:48 wkmanire: cemerick: I just bought your e-book. Would you mind signing it for me?

0:49 ppppaul: e-sign

0:49 technomancy: Clojure%20Programming.pdf.asc

0:49 muhoo: i've heardquite a few people commenting on how msft has started-- surprisingly-- getting stuff right lately. i noticed it correlated strongly with the retirement of billg, interestingly.

0:49 ibdknox: lol

0:49 wkmanire: It is getting better

0:49 I've just had my fill.

0:49 ibdknox: eh, they have a long way to go

0:49 and I'd be surprised if they get there

0:49 wkmanire: They don't provide interfaces anywhere

0:49 ibdknox: not for lack of trying

0:49 ppppaul: MS-lisp is going to be a show-stopper

0:49 wkmanire: You have to abstract away their code constantly to enable unit testing.

0:50 Or mock the hell out of i t.

0:50 brehaut: muhoo: its more to do with people like erik meijer and don syme having been there long enough for their work to have made it out of the lab

0:50 amalloy: i remember finding C# 1.0 distasteful, but i was impassioned with java at the time. since then it does seem to keep getting better

0:50 wkmanire: I can go on and on with my complaints.

0:50 bbloom: muhoo: I used to work at msft (now I run a startup and use zero msft tech). It has nothing to do with lately: the managed languages group has been doing great work for a long time

0:50 ibdknox: amalloy: C# is nothing like C# 1.0

0:50 brehaut: amalloy: C#1 is a distasteful Java ;)

0:50 amalloy: *chuckle*

0:51 bbloom: C# 3's Linq was my gateway drug to FP

0:51 wkmanire: A lot of the classes that you might want to inherit from are not inheritable or do not expose overridable members

0:51 So you end up wrapping them

0:51 or dealing with it.

0:51 ibdknox: the platform is one thing

0:51 amalloy: but see, F# would also tempt me, and i might want to use C++ just to leverage my C experience

0:51 ibdknox: but the language is excellent

0:52 cemerick: wkmanire: Come find me at a conf sometime, and I'll sign whatever you like. :-)

0:52 amalloy: i suspect if i were under pressure to actually get something done, i would learn C#

0:52 bbloom: if you know java, there isn't much to learn

0:52 wkmanire: cemerick: I might just take you up on that.

0:53 ppppaul: C is not C++

0:53 bbloom: …unless you need to do win32 interop

0:53 then you're opening pandora's box

0:53 ibdknox: I'm not sure that's true

0:53 brehaut: amalloy: F# has a full OO sub syntax that you can use pretty much anywhere where C# would be used

0:53 wkmanire: cemerick: I bought your book because your cohort recommended it by the way.

0:53 ibdknox: java doesn't even have first class functions

0:53 wkmanire: He's admitted to at least 2 sales since I've /joined this channel.

0:54 but still proclaims his innocence.

0:54 bbloom: ibdknox: sure it does, they are just absurdly verbose & called anonymous classes

0:54 ppppaul: java has first class ints

0:54 and strings

0:54 what more do you need?

0:54 xeqi: but functors

0:54 ibdknox: bbloom: that's a bit of a stretch

0:54 cemerick: wkmanire: sadly, I've not built my own affiliate network yet :-P

0:54 ibdknox: delegates then

0:54 and and and

0:54 bbloom: i worked on C# & VS integration for xbox — I'm quite familiar with C#

0:55 ppppaul: i really like how i can put exception handling everywhere in my java apps

0:55 ibdknox: bbloom: I was PM for C# and VB

0:55 :)

0:55 bbloom: it's heads and shoulders above java for day to day use

0:55 wkmanire: I wish I could have spent my .Net time with C# instead of VB.

0:55 bbloom: ibdknox: awesome. we may even know each other already haha

0:55 wkmanire: Not because I prefer the syntax, but because C# was the favorite son.

0:56 It got all of the new features first, and more third party open source guys latched onto it.

0:56 brehaut: wkmanire, really? you dont like having to type FUNCTION all over the place?

0:56 wkmanire: brehaut: Visual Studio types most of that crap for you.

0:56 brehaut: but its still there, in all caps, yelling at you

0:56 wkmanire: I type P space F space myFunction ....

0:56 amalloy: calling you Dim

0:57 brehaut: (inc amalloy)

0:57 its still broken isnt it

0:57 amalloy: i dunno, man. it's a myster

0:57 y

0:57 $login

0:57 lazybot: You've been logged in.

0:57 amalloy: $loaded?

0:57 lazybot: :autoreply :brainfuck :clojure :debug :dictionary :eball :embedded :fortune :github :google :haskell :help :internal :javadoc :karma :knowledge :leet :lmgtfy :load :log :logger :login :macro :mail :max :mute :operator :ping :rotten-tomatoes :rss :sed :seen :shorturl :timer :title :translate :utils :weather :whatis :yesno

0:57 amalloy: well, it alleges to be active. god knows

0:57 $logout

0:57 lazybot: You've been logged out.

0:58 muhoo: in tools.logging and log4j is there a way to get it to stop printing "sun.reflect.NativeMethodAccessorImpl invoke0" every time it logs something?

0:58 wkmanire: I once toyed with the idea of working with Mono before I started learning Python as a good footstep into developing from a linux box. But the Vb support for Mono and VB in Sharp develop was laughable.

0:58 VB is definitely the bastard child.

0:59 amalloy: $dec lazybot

1:00 muhoo: wkmanire: could be worse.. you could be using..... PHP

1:00 wkmanire: muhoo: At least with PHP 5+ you can pretend like it doesn't suck.

1:01 brehaut: thats a hell of a lot of playing pretend

1:01 muhoo: oh it still sucks.

1:02 but it has features that you can use to make it smell like javascript, or java, or whatever

1:02 amalloy: 5.3 has closures!

1:03 muhoo: anonymous functions, and closures, yes.

1:03 and eval, well it's had eval for a long time

1:03 amalloy: every time you use them it feels like one more needle in your eye, but they're there

1:03 muhoo: i'll never forget the first time i learned scheme, then went back to doing PHP. my code was an unreadable disaster

1:03 amalloy: i learned clojure while doing PHP at my day job

1:04 wkmanire: I don't hate working with PHP. At the risk of sound like egotistical, I hate working on PHP that I didn't write. Because I never know what the hell is in my scope.

1:04 It seems like every side job I get to work on a PHP site has been copy and pasted together by a bunch of script kiddies hired from sites like ODesk.

1:05 amalloy: i definitely remember a decision i made to use a closure in PHP when really any sensible person would have used an interface

1:05 wkmanire: No offense to odesk, I know there is a lot of talent floating around there.

1:05 amalloy: wkmanire: your PHP looks like that to everyone else, btw

1:05 wkmanire: amalloy: More than likely.

1:06 amalloy: the PHP i wrote looks like that to me, probably

1:06 wkmanire: I'm gonna go get a beer and start reading my shiny new e-book.

1:06 My english are starting to badder.

1:06 amalloy: just add beer, that'll fix it

1:10 ppppaul: javascript can smell nice

1:11 wkmanire: Too bad cemerick parted.

1:11 I wanted to thank him for targeting python guys.

1:12 ppppaul: JS is one of my favorite languages.

1:12 ppppaul: glad to hear that... you'll like clojure even more

1:17 amalloy: wkmanire: you can tweet him, or use lazybot's $mail

1:17 wkmanire: amalloy: I'm not much of a twit.

1:18 But I'll be frequenting this channel.

1:18 I'm sure I'll get an opportunity to thank him properly.

1:18 amalloy: $mail amalloy check it out, a mail message for myself

1:18 lazybot: Message saved.

1:18 jaen: Incidentally, what did a :haskell keyword did in lazybot's module list? ;d

1:18 wkmanire: $mail lazybot Message saved.

1:18 lazybot: You can't message the unmessageable.

1:18 wkmanire: $mail unmessageable wanna bet?

1:18 lazybot: Message saved.

1:18 amalloy: $heval map succ [1,3..9]

1:19 hm, i guess my haskell is bad? i know he evals it

1:19 $heval [1,2]

1:19 jaen: now, that's proper haskell you wrote there I think

1:19 amalloy: maybe that's broken

1:20 last time i tried to eval haskell it worked; not sure if he's sick today or what

1:20 jaen: Maybe he's just lazy ; d

1:20 * wkmanire just choked on his beer.

1:24 amalloy: $mail Raynes can you check out the haskell plugin? $heval isn't working; maybe he just needs a restart

1:24 lazybot: Message saved.

1:25 amalloy: where's that polyglot bot? rublets or something?

1:26 wkmanire: oh man

1:26 I must be living under a rock.

1:26 When did Oracle acquire Java?

1:26 I thought Sun owned Java.

1:26 brehaut: haha

1:26 a few years ago now wasnt that?

1:26 oracle bought all of sun

1:26 wkmanire: Wow

1:27 That must have been a big ticket.

1:27 Sun had some huge enterprise clients didn't they?

1:27 brehaut: 2009 they were aquired

1:27 wkmanire: The last time I worked with Java was 2004ish.

1:28 amalloy: as long ago as 2009? the wound feels fresher

1:29 brehaut: everything is slower in the land of oracle

1:31 amalloy: speaking of which, did you hear oracle has plans for all the way up to JDK 12?

1:31 brehaut: haha really?

1:31 wont that be due in 2083

1:32 wkmanire: :D

1:32 amalloy: 2021

1:32 http://www.infoworld.com/d/application-development/oracle-lays-out-long-range-java-intentions-188739

1:32 (but seriously, who thinks they can release 5 versions in just 9 years)

1:33 muhoo: nice, clojure.tools.logging totally ignores any log4j.properties files

1:33 and sends everything to the console :-/

1:33 brehaut: amalloy: i struggle to believe they can release 2 versions in 9 years

1:33 muhoo: amalloy: that's fud.

1:34 an old ibm/at&t trick

1:34 amalloy: i, uh, i'm pretty sure FUD means something else

1:34 muhoo: you lay out your roadmap, and enterprise CTOs can pooh-pooh any competitor's bright idea by saying "Oh, well $bigcorp has got that on their roadmap, no need to switch."

1:35 amalloy: i guess i can see how you might make them feel similar

1:36 arohner_: muhoo: c.tools.logging does zero configuration of log4j

1:36 muhoo: arohner_: does it read it?

1:36 arohner_: muhoo: no. it only sends messages to log4j/ whatever logging lib you have on classpath

1:36 it's log4j's responsibility to read log4j.properties

1:37 muhoo: oh. so if i don't explicitly add log4j to project.clj deps, then tools.logging just sends stuff out stdout?

1:37 arohner_: oh, yeah. It's probably going to java's built-in logger

1:37 amalloy: java's logging ecosystem is incredible

1:38 muhoo: incredible in what sense of the word?

1:38 amalloy: like, it is impossible to believe that things are the way they are

1:38 muhoo: oh like "inconceivable"? http://www.youtube.com/watch?v=Z3sLhnDJJn0

1:39 arohner_: thanks

1:39 arohner_: muhoo: and if you're doing new development, you should probably look at logback

1:40 muhoo: yes, i am, and i will, thank you

1:40 * muhoo shudders at log4j

1:43 wkmanire: Whew

1:43 Beer #2, the final of the night.

1:43 Is there a preferred emacs major mode for Clojure?

1:44 muhoo: wkmanire: i've been using clojure-mode

1:44 wkmanire: http://github.com/technomancy/clojure-mode

1:45 wkmanire: technomancy is a busy feller isn't he.

1:45 I'm already downloading leiningen

1:45 muhoo: indeed.

1:45 wkmanire: now I'll be downloading clojure-mode from him too.

1:45 muhoo: there are a bunch of guys here who are pretty amazing.

1:48 as for logging, i'm hoping longbottom gets released soon

1:48 laurus: Could someone help me understand what is wrong with this simple function? http://paste.lisp.org/display/128887

1:49 bbloom: what's it supposed to do?

1:49 johnwayner: Hi. I've got a program which calls interate with a step function to create sucessive versions of the hashmap. I'm trying to process these iterations as quickly as possible. I'm using visualvm to try to find any obvious hotspots. The one that always sticks out at 88% is clojure.lang.Keyword.hashCode(). I'm reusing a very limited set of hashcodes as keys in my maps, so I would expect these to be cached and not rehashed every time

1:49 Any ideas what I'm doing wrong? (the code is quite complicated otherwise I'd provide some of it)

1:49 amalloy: well, you passed a one-argument function to reduce, which calls its function with two args

1:49 laurus: bbloom, it's supposed to calculate that expression for each number in the sequence numbers, and add them all up.

1:50 amalloy: laurus: you want (reduce + (map #(...) numbers))

1:50 bbloom: can also (apply + ...

1:51 amalloy: *shrug*

1:51 laurus: amalloy, why does reduce call a function with two arguments?

1:51 bbloom: 6 of one :-)

1:51 `(doc reduce)

1:51 laurus: Oh, wait, I see.

1:51 amalloy: but then you can't call yourself a map/reduce expert, bbloom

1:51 bbloom: ,(doc reduce)

1:51 johnwayner: Jeez, I should have re-read that before hitting enter. I'm obviously using a limited set of KEYWORDS as keys in my maps...

1:51 clojurebot: "([f coll] [f val coll]); f should be a function of 2 arguments. If val is not supplied, returns the result of applying f to the first 2 items in coll, then applying f to that result and the 3rd item, etc. If coll contains no items, f must accept no arguments as well, and reduce returns the result of calling f with no arguments. If coll has only 1 item, it is returned and f is not called. If val i...

1:52 wkmanire: muhoo: Ok, got clojure-mode byte-compiled and installed.

1:52 Now its time to install leiningen

1:52 laurus: amalloy, it worked, and I understand why. Thank you!

1:53 muhoo: wkmanire: have you been an emacs user before?

1:53 wkmanire: muhoo: I'm rabid.

1:53 does clojure-mode integrate a REPL?

1:53 amalloy: wkmanire: swank/slime

1:54 (lein includes a swank server)

1:54 johnwayner: ... interesting, Keyword.hashCode just returns the cached hash...

1:54 wkmanire: amalloy: I'm sticking this on my windows box so I have something fun to help distract me during my work day.

1:55 amalloy: Can you link me to a tut on how to set this up?

1:56 amalloy: wkmanire: if you have lein and clojure-mode installed, there is no setup

1:56 wkmanire: Ok.

1:56 I'll finish installing lein

1:56 amalloy: just visit a buffer inside of a project created by lein new (it will have a project.clj somewhere), and M-x clojure-jack-in

1:56 wkmanire: I saw that function!

1:57 amalloy: emacs fine lein on your path, fire it up, negotiate a swank port/version, and you're in a slime repl

1:57 wkmanire: I try C-H F clojure-jack-in

1:57 not documented

1:57 tried*

1:57 Also, I'm not familiar with swank

1:59 muhoo: wkmanire: docs here https://github.com/technomancy/swank-clojure

1:59 amalloy: well, that's something to get used to. but for a while at least, you can treat it as a repl with easy copy/paste from your source files, within emacs

1:59 wkmanire: thanks

1:59 amalloy: ~swank

1:59 clojurebot: swank is trust the readme and the readme only. all others will lead you astray.

2:00 muhoo: it's true

2:00 amalloy: i don't trust clojurebot when he talks about swank, even, just in case

2:01 * wkmanire is starting to think he shouldn't be drinking beer while doing this.

2:01 wkmanire: At 2am

2:01 muhoo: nah, it's more fun that way

2:01 amalloy: you should just move to a better timezone

2:01 so it's not so late all the time

2:01 wkmanire: I hate windows.

2:01 It makes this so much harder than it should be.

2:01 muhoo: amen

2:02 you're an emacs user stuck doing vb on windows?

2:02 * wkmanire nods remorsefully.

2:02 muhoo: that explains the beers

2:03 wkmanire: I spend almost all of my off hours in linux land

2:03 But, tomorrow, bright and early at around noon.

2:04 I'm going to log back into my windows machine and start trying to track internet traffic through other companys' websites using vb.net.

2:04 :(

2:05 muhoo: sorry to hear it man

2:05 wkmanire: muhoo: Thats ok.

2:05 Here in a few months I'm going to try to make a switch.

2:05 muhoo: well, if it makes you feel any better, i've been making a living doing PHP for a while

2:05 wkmanire: Hopefully it will go well.

2:06 muhoo: At least I could do PHP from my linux box and from Emacs.

2:06 there isn't a good VB.Net mod

2:06 mode*

2:06 muhoo: that's why i was doing it, actually.

2:06 wkmanire: and I don't know ELisp well enough to mak one.

2:06 make*

2:06 (nor have I the desire to learn ELisp)

2:06 not that desperate yet.

2:06 I'll learn it eventually though.

2:07 muhoo: the weirdest thing about elisp is its scoping, but if you're used to java and php, it's not new.

2:07 wkmanire: closures don't scare me.

2:07 muhoo: sorry javascript

2:07 wkmanire: I like 'em.

2:08 I like Python closures a bit more than Javascript closures.

2:08 muhoo: no i mean no modules org-mode-some-long-function-name-because-no-namespaces-thats-why

2:08 wkmanire: I shouldn't be able to mutate things in a long distance parent scope 6 calls up the stack.

2:08 distant*

2:09 Python at least makes you work for it if you want that.

2:09 muhoo: so you got that lein installed yet? :-)

2:09 wkmanire: I just finished running the self installer batch file.

2:09 muhoo: it's a 20-second process, walked a customer through it today, that was fun.

2:09 wkmanire: I had to install 64bit curl and add it to my path.

2:09 the batch file took care of the rest

2:10 Ok, so amalloy mentioned setting up a project?

2:10 wat dat mean?

2:10 muhoo: yep, "lein new projectname"

2:10 then "cd projectname", "lein repl", and you are in business

2:10 wkmanire: well, lein installer did not put lein on my path.

2:10 where did it install it?

2:11 muhoo: on linux, ~/.lein

2:11 amalloy: wkmanire: python doesn't really have closures. i mean, it has named inner functions, which are closures, but you can't have lambdas

2:11 wkmanire: python has lambdas

2:11 what do you mean?

2:11 muhoo: python *used* to have lambdas

2:12 they got moved to a library, IIRC, in like 2.4 or so

2:12 wkmanire: square = lambda x: x * x

2:12 amalloy: it has limited lambdas. the "feature set" allowed in named functions is larger than the one for lambdas

2:12 wkmanire: Well that is certainly true.

2:12 amalloy: you can't just "build a function anywhere", which is the whole point of lambdas. some lambdas you're required to give a name to

2:13 http://symbo1ics.com/blog/?p=1292 is a recent blog post about the ramifications of that distinction

2:13 wkmanire: added to my "to read" bookmarks.

2:14 that list is getting longer than I can stomach.

2:15 something weird happened.

2:15 It installed leiningen to the equivelant of ~/.lein

2:15 ~\.lein\self-installs\leiningen-1.7.1-standalone.jaf

2:15 clojurebot: Gabh mo leithscéal?

2:15 wkmanire: ~wat

2:15 clojurebot: It's greek to me.

2:15 wkmanire: ~same

2:15 clojurebot: Gabh mo leithscéal?

2:16 wkmanire: .jar*

2:16 muhoo: jav?

2:16 wkmanire: but I can't seem to run the jar file.

2:16 muhoo: wait,

2:16 wkmanire: it has no main.

2:16 muhoo: no you run lein

2:16 put lein in your path

2:16 make it executable

2:16 then run "lein"

2:16 wkmanire: I don't know where it is.

2:16 muhoo: it sets up the cp and runs the jar

2:17 did you wget it?

2:17 wkmanire: muhoo: In case you missed it, I'm setting this up on a windows machine

2:17 So I can play with it during brain farts while I'm working.

2:17 amalloy: wkmanire: the executable is the .bat, not the .jar

2:17 muhoo: oh fun

2:17 wkmanire: ah!

2:17 I see

2:17 amalloy: it does the work of opening up the jar for you

2:17 wkmanire: ok

2:17 one sec

2:18 ok ready to rock.

2:18 muhoo: yay!

2:18 wkmanire: I thought that was just an installer.

2:18 amalloy: it installs itself if necessary

2:18 muhoo: could you imagine an InstallSheild lein?

2:18 amalloy: you can blow away the jar and keep using the .bat - it just gets another copy

2:19 muhoo: lein has a lot of funny recursive stuff like that.

2:19 wkmanire: Understood.

2:19 Ok, I started up my project

2:19 going to try to hijack it with emacs now.

2:19 jack-in

2:19 whatever the terminology is.

2:20 amalloy: i think jack-in is supposed to evoke memories of the matrix, plugging clojure into your skull

2:20 wkmanire: ahhh, fond memories.

2:21 amalloy: Unless you're not talking about shadowrun

2:22 laurus: When moving through a list in Clojure inside a function such as map, is there a way to get the current position of the list?

2:23 wkmanire: amalloy: "Could not start swank server: That's not a task. Use \"lein help\" to list all tasks."

2:23 any ideas?

2:23 amalloy: oh, you need to install the swank plugin

2:23 it should be in the swank readme, how to do that

2:23 wkmanire: looking

2:23 amalloy: &(doc map-indexed)

2:23 lazybot: ⇒ "([f coll]); Returns a lazy sequence consisting of the result of applying f to 0 and the first item of coll, followed by applying f to 1 and the second item in coll, etc, until coll is exhausted. Thus function f should accept 2 arguments, index and item."

2:27 wkmanire: crap

2:27 the installer shit all over the place.

2:28 muhoo: there's an easier way, just run the repl in a comint-mode buffer

2:28 i haven't messed with swank yet, i'm sure i will though at some point.

2:29 wkmanire: http://pastebin.com/VSNqg2tF

2:29 I'm going to try again as admin.

2:29 muhoo: wkmanire: https://refheap.com/paste/1992

2:30 wkmanire: where does this go?

2:30 muhoo: granted, i'm on linux, and i know sweet FA about windows, so ymmv

2:30 that's in my .emacs

2:30 my cheap way of running repls without swank

2:30 wkmanire: I'm not going to give up just yet.

2:31 muhoo: "couldn't delete" does smell like a permissions issue though.

2:31 wkmanire: I was running as admin.

2:31 hmm

2:32 muhoo: well, what is C:\Users\wkmanire\AppData\Local\

2:32 Temp\lein-2d8b965f-63b9-4cb4-9ab0-033ea5588228\lib\cdt-1.2.6.2.jar

2:32 laurus: amalloy, I'm not sure that's the one I need

2:32 I am trying to loop through a list of 50 items and output this to a text file: "1 firstvalue\n2 secondvalue..."

2:33 amalloy: if you don't think map-indexed is the solution to that problem you are missing something fairly fundamental, but i'm not sure what

2:33 muhoo: cdt is some eclipse thing, eh?

2:33 amalloy: &(map-indexed vector '[a b c d e])

2:34 lazybot: ⇒ ([0 a] [1 b] [2 c] [3 d] [4 e])

2:34 laurus: amalloy: I don't need to apply "f to 0", I just need it to literally print 0.

2:35 amalloy: so write a function g that prints 0 and then calls f, whatever makes you happy

2:35 laurus: amalloy, ah, I see, I didn't get that

2:35 I didn't realize you can just plug in "vector" there

2:36 muhoo: amalloy: you are right. i'm stunned by what a monstrous right royal PITA logging is on java, even using logback

2:36 it's like dealing with the italian bureaucracy.

2:38 "simple" logging framework: http://www.slf4j.org/images/concrete-bindings.png

2:39 wkmanire: well crap

2:39 I can't get lein to work

2:39 amalloy: wkmanire: does stuff other than lein swank work? like, can you lein new? lein repl?

2:40 wkmanire: lein new worked.

2:40 amalloy: (not that i know how to help you either way)

2:40 muhoo: wkmanire: cd into your project

2:40 wkmanire: lein repl worked as well

2:40 muhoo: oh

2:40 so lein is working, clojure is working, swank is not working?

2:40 wkmanire: I think that is correct.

2:40 amalloy: it sounds like he can't install the swank plugin

2:40 wkmanire: the installer is downloading the jar file and putting it into the plugin directory.

2:40 But the installer is bombing out before it finishes

2:41 because of some kind of permissions issue in a temp directory.

2:41 muhoo: manually clear out the temp directory and try again?

2:42 wkmanire: did that

2:42 I'll give the stack trace

2:42 just a sec

2:42 muhoo: you might have to ping technomancy on this one, i dunno.

2:43 wkmanire: http://pastebin.com/kVLGAB32

2:44 muhoo: Yeah, I think so.

2:44 muhoo: or, submit it as an issue on github maybe

2:44 laurus: Here is a short program I just wrote, I haven't finished it yet since I think I am doing something fundamentally wrong. http://paste.lisp.org/display/128888

2:44 I feel like every time I want to map over something, I can't "get inside" far enough

2:45 For example, for a list of lists, is there any way to map over those inner lists without making an anonymous function?

2:45 muhoo: wkmanire: but, like i said, i've been using clojure for months now with no swank, haven't missed it.

2:45 wkmanire: muhoo: There is a similar issue already submitted but I can't seem to get the same results as that user.

2:45 It's 2:40, gonna have to hit the sack.

2:45 muhoo: aaare

2:45 wkmanire: I'll start reading the book and bug you guys some more tomorrow.

2:46 Nice to meet you all.

2:46 Good night.

2:46 muhoo: have fun, and welcome!

2:46 andyfingerhut: laurus: You can map over an inner list with a named function, if you prefer.

2:46 laurus: andyfingerhut, what is the best way?

2:46 I couldn't finish the program yet because I didn't want to create yet another confusing function

2:47 I feel like I am creating a big mess.

2:47 andyfingerhut: I'll just toss out a couple of possibilities. I'd almost recommend trying to write it in each way, and see if you have a preference.

2:47 laurus: OK!

2:47 andyfingerhut: Another is for, which you can nest calls to.

2:48 I don't recall off the top of my head, but you might be able to do a nested map using a single for with multiple bindings.

2:48 laurus: Am I on the right track, by the way?

2:48 I mean, does that program look like a normal Clojure program or is it "wrong"?

2:49 When I run the program, I suppose I will call it like this: (writedata (createlist (100))

2:50 andyfingerhut: Still aborbing some of it.

2:54 laurus: I'm tempted to use loop in an imperative style.

2:55 andyfingerhut: I just commented with an alternate version of createlist that I think is equivalent, but not sure.

2:56 laurus: andyfingerhut, thanks I'll look now

2:57 andyfingerhut, yes, equivalent :)

2:57 andyfingerhut, that's fantastic!

2:57 Ah, I see what you're doing

2:58 By using the ->> macro you can avoid creating all these anonymous functions and calls within calls

2:58 andyfingerhut: I prefer -> and ->> when they are used in a chain with an initial value and at least two expressions that operate on them afterwards, but that is more of a personal preference of mine.

2:58 laurus: I think it looks good! I suppose the whole program could somehow be composed that way?

2:58 andyfingerhut: I didn't remove any anonymous functions. I did remove some intermediate named things that were only named to be used once.

2:59 laurus: Ah ok I see.

2:59 Do you see what I'm trying to do?

2:59 andyfingerhut: not yet. I'm a little slow on the uptake tonight :)

2:59 amalloy: laurus: i strongly recommend ##(doc for) for iterating over nested lists

2:59 lazybot: ⇒ "Macro ([seq-exprs body-expr]); List comprehension. Takes a vector of one or more binding-form/collection-expr pairs, each followed by zero or more modifiers, and yields a lazy sequence of evaluations of expr. Collections are iterated in a nested fashion, rightmost ... https://refheap.com/paste/1993

2:59 laurus: amalloy, ok

3:00 amalloy: &(let [inputs '[[a b c] [d e f]]], (for [xs inputs, x xs] (keyword x)))

3:00 lazybot: ⇒ (:a :b :c :d :e :f)

3:01 amalloy: tbh i recommend `for` even for simple lists; it's usually prettier than (map #(...) xs)

3:01 laurus: amalloy, how would you fix this program?

3:03 amalloy: what is it you're trying to do? right now it doesn't even compile

3:03 laurus: I know, I couldn't finish it

3:03 I want to print out "1 calcresult1\n2 calcresult2..."

3:03 The createlist function is the one that creates calcresult1, calcresult2, etc.

3:03 amalloy: and calcresult is (ichiban 1)?

3:04 laurus: Yes :P Sorry for the stupid names

3:04 amalloy: so what is with the PI/4 and - stuff?

3:05 laurus: Basically, the function called ichiban creates a result

3:05 And createlist creates a result out of that result.

3:05 The one that should be printed to the file.

3:06 Basically I feel like continuing in this style for any calculation-oriented program will create a giant mess of unreadable nested maps

3:06 andyfingerhut: laurus: Take a look at paste 3. I messed up paste 2.

3:06 amalloy: i agree, to the point that i can't figure out what you're doing enough to fix it

3:07 laurus: amalloy, yeah. I'm totally confused now too.

3:07 Is there some kind of guide for people doing math or science using Clojure?

3:08 This sounds stupid, but "this is really easy to do in Python".

3:08 amalloy: it's easy in clojure too

3:09 but so far i don't think anyone understands the goal

3:10 andyfingerhut: laurus: It can be confusing when accustomed to writing imperative style code to write functional style code. It can feel "unnatural", because you know how to crank it out in a few seconds in imperative style from long practice, and feel like a fish out of water in a different style.

3:10 amalloy: do you have a link describing in some mathematical notation what you want? the clojure you've written doesn't lend itself to reading

3:10 laurus: I want to print out "absolute value of pi/4 minus delta(n)" where delta(n) is "sum (-1)^k / (2k + 1) from k = 0 to n".

3:10 amalloy: ah, cool

3:10 andyfingerhut: laurus: Did you look at annotation 3? See if it looks interesting.

3:10 laurus: andyfingerhut, yes, that's great, thanks!

3:11 andyfingerhut: Except I think I've reversed the subtraction between Pi/4 and delta(n).

3:14 amalloy: laurus: do you have expected outputs somewhere to verify my solution is correct?

3:16 laurus: amalloy, let me check it one sec :)

3:16 Oh, it's not pasted

3:16 amalloy: https://gist.github.com/237543a6327f100512ad is definitely not the fastest solution

3:16 laurus: Um, I don't. But it declines roughly linearly

3:16 :)

3:16 There shouldn't be negative numbers, for sure

3:17 Oh, amalloy, it's 2k + 1.

3:18 amalloy: yes, that's what (inc (* 2 k)) is

3:19 oh, i left out the abs that you had in your original but not in the problem statement just now

3:19 oh. no, you included it, i'm just dumb

3:20 laurus: Ah, thanks

3:20 amalloy: anyway, you can add a Math/abs right before the -, and then it does what you described

3:20 laurus: Yes, I did that thanks :)

3:20 So to write the data to a file, what should I do?

3:21 andyfingerhut: And if you want a little speed optimization, you could replace (apply * (repeat k -1)) with (if (even? k) 1 -1), but that is perhaps less clear, too.

3:21 amalloy: andyfingerhut: i think there are bigger targets here, like the whole apply + thing can be memoized and/or simplified

3:22 Lajla: &(symbol? (symbol "I worship His Shadow")))

3:22 lazybot: ⇒ true

3:22 andyfingerhut: I like printf if you want the output to be text.

3:23 Oh, except if you want the output to go to a file, you would have to wrap it in something like (binding [*out* wrtr] <code that does printf here> )

3:23 amalloy: laurus: (spit "somefile.out" (clojure.string/join \newline (for [[idx delta] (deltas n)] (str idx " " delta))))?

3:24 yeah, that works

3:24 wei_: what's the best way to read from a config file and but still have defaults? (binding [config/config (merge defaults-map (parse-file "test.cfg")) (run!)) ?

3:24 andyfingerhut: Yeah, slurp and spit are cool for things that you know will easily fit in memory all at once.

3:25 amalloy: agreed, if you want to run this on a million numbers at once, don't use spit or join

3:25 wei_: er, (binding [config/config (merge defaults-map (parse-file "test.cfg"))] (run!))

3:26 laurus: amalloy, thanks. This is a very nice learning process for me!

3:27 andyfingerhut: wei_: Looks good to me. Merge is nice for such things.

3:31 chrisr: laurus: try stick it out, for the first few months heavy math/numerics was massive pain point in clojure for me, but after you figure it out having access to the clojure+java ecosystem is (IMO) vastly superior to python/sage, matlab, octave et al

3:32 wei_: andyfingerhut: thanks. as a followup, say I have test1/run and test2/run. how would I write (call-run "test1") so that it calls the right run function?

3:35 andyfingerhut: wei_: You want call-run to take a string that is the name of a namespace?

3:35 wei_: yup

3:37 andyfingerhut: Someone else probably knows something cleaner, but I think (apply (resolve (symbol "test1" "run"))) works

3:39 Or even leave out the "apply"

3:40 laurus: amalloy, thanks a million

3:40 chrisr, that's good to hear :)

3:41 I will stick it out!

3:50 fliebel: I remember reading someone claiming continuations are worse than goto, but I forgot why. Anyone know?

3:53 rahcola: well continuations aren't exactly the easiest concept to grok

3:54 atleast if they are first-class values, and can be stored

3:56 jaen: I never got people saying that goto sucks ; d

3:57 twhume: Potential noob-question: I have a function which takes a map, and in some circumstances has trouble getting values from the map. Given the code:

3:57 (println m)

3:57 (println (clojure.string/join ", " (keys m)))

3:57 (println (first (keys m)))

3:57 (println (get m (first (keys m))))

3:57 I get the output:

3:57 {Google Inc 14.399999999999997, Clearleft Ltd 12.000000000000002, Future Platforms 4.8}

3:57 Google Inc, Clearleft Ltd, Future Platforms

3:57 Google Inc

3:57 nil

3:57 I don't understand why I'm getting that last "nil". Surely the fact that the map contains they key and a value associated with that key, means it should return 14.399999999999997 ?

3:58 Any ideas? I'm v new to Clojure so suspect it's something deeply obvious I'm missing.

4:00 andyfingerhut: twhume: Is "Google Inc" a string?

4:01 twhume: Yes. Would that make a difference though? I'm never referring to it as a string in the line (println (get m (first (keys m)))) ?

4:01 hoeck: twhume: its the result of the call to println (if you're on a repl)

4:01 wei_: andyfingerhut: thanks! that works except I had to use deref instead of apply

4:01 andyfingerhut: I was only concerned if it was a symbol, since some chars aren't 100% supported in symbols, although they sometimes work.

4:02 hoeck: twhume: sorry, ignore me

4:02 twhume: hoeck: no, this isn't on the repl. This is cut and pasted from code. The reason I've got this level of debugging in is that my code was throwing a NullPointerException further in when trying to get the value for one of those keys.

4:03 hoeck: twhume: I was too fast in recognizing that specific pattern :)

4:03 twhume: andyfingerhut: Hmm; shouldn't be a symbol, but could I have inadvertently converted it to one, I wonder. This same code works for a unit-tested map with single-word keys...

4:03 jaen: thume: Weird, this seems to work for me allright.

4:03 fliebel: &(let [m {:foo 3}] (println (get m (first (keys m)))))

4:03 lazybot: ⇒ 3 nil

4:04 twhume: jaen: yeah, I have some unit tests which seem to work just fine with it too. Must be something about the map itself, I guess; in my unit tests it's constructed manually, in my "real" code it's created by another function. Any pointers for things to look for?

4:05 andyfingerhut: Try printing (class (first (keys m))) ?

4:05 It shouldn't make any difference that I can think of -- just grasping for straws.

4:05 Are the keys a mutable data type?

4:06 hoeck: or use prn instead of println (this will print strings with their quotes)

4:06 twhume: andyfingerhut: returns java.lang.String both in my unit tested code, and the real stuff.

4:06 andyfingerhut: Those are immutable, so no clues there.

4:06 rahcola: twhume: could you make a gist?

4:07 with the constructing function also included

4:07 twhume: One difference I can see: my working code passes in a clojure.lang.PersistentArrayMap, my not-working code passes in a clojure.lang.PersistentTreeMap ...?

4:08 rahcola: will do

4:10 fliebel: huh, where did you get the treemap from?

4:10 I only get ara and hash maps

4:10 *array

4:10 twhume: rahcola: https://gist.github.com/2b7b99137ce4e9ee2474

4:11 andyfingerhut: fliebel: It is possible to make one by calling sorted-map

4:11 fliebel: andyfingerhut: Thanks

4:12 twhume: andyfingerhut: yeah, that's what I'm doing.

4:12 andyfingerhut: Could your comparator function be bad?

4:12 i.e. not satisfy the properties a comparator function should, like transitivity?

4:13 twhume: andyfingerhut: are you looking at the gist now? Which comparator function do you mean?

4:14 andyfingerhut: twhume: Your sort-map-by-value calls sort-map-by. The first arg is a comparator fn

4:15 twhume: How would that result in th

4:15 

4:15 urk

4:15 How would that result in a get on that map returning nil, when the key I'm "get"ting is there tho? I can see how an iffy comparator might result in problems sorting or constructing the map, but not its subsequent behaviour.

4:15 andyfingerhut: I'm not sure yet. Still thinking. But a bad comparator function can make sorts go wrong, and sorted data structures give bad answers.

4:16 The comparator function I think is used in looking up keys in the map.

4:16 rahcola: sort-map-by-values looks funny in anycase

4:16 twhume: rahcola: this is my first proper clojure code so I expect big chunks to be iffy :-(

4:16 rahcola: atleast with sort and sort-by, the comparator fn should satisfy the java.util.Comparator

4:17 twhume: andyfingerhut: I think you've nailed it. I changed the "<=" to "<" in the comparator, and suddenly my gets are working.

4:17 rahcola: (into (sorted-map-by (fn [key2 key1] (<= (m key1) (m key2)))) m)

4:18 twhume: (and I can see that <= might not be transitive)

4:18 Would you concur that this is a reasonable fix? I'm not sure I get what's happening behind the scenes to account for this behaviour.

4:19 andyfingerhut: http://stackoverflow.com/questions/1528632/how-do-you-use-sorted-map-by-in-clojure

4:19 You might want compare instead of < or <=

4:20 twhume: Hah, that's where I got the code that was broken, I think (see Rafael's comment about using <= instead of compare)

4:21 compare works fine too tho (just checked).

4:21 rahcola: < nor <= should work

4:21 because the comparator should return -1,0,1

4:21 not boolean values

4:21 twhume: andyfingerhut: any idea what's caused this problem? I get that the comparator was wrong, but how did that make the subsequent get return nil?

4:22 (I suspect my mental model for how this is working behind the scenes - map is created, then consumed - is wrong)

4:23 amalloy: a broken comparator breaks everything about a sorted collection, period. once you get to "the comparator is wrong", no other questions are useful

4:23 andyfingerhut: I don't know for sure, but I believe sorted-map's are implemented by binary search trees, where when a search is done, the given search key is compared against stored keys, and the results tell the search routine whether to go down to the left or right child. If that comparison routine is bad, it is possible to store a key in the tree, but never find it again.

4:24 rahcola: twhume: it seems place-tuples is just set to (ref {}) and then never updated

4:24 amalloy: andyfingerhut: correct, sorted-map uses a red-black binary search tree

4:24 twhume: ok andy - thanks very much for your help (and rahcola, amalloy!)

9:05 Raynes: It's a Wednesday, people. Activate and complain about your jobs and such.

9:05 Iceland_jack: Damn jobs.

9:05 lstoll: It's almost thursday.

9:05 jkdufair: Damn objective c. Why can't clojure run on iOS?

9:05 Raynes: It's barely Wednesday.

9:06 I'm surprised nobody is working on a clj->objc compiler.

9:06 Once you start compiling to PHP, things are going downhill.

9:06 rodnaph: haha https://github.com/rodnaph/clj-php

9:06 :D

9:07 Raynes: :p

9:07 oakwise: jkdufair: try clj->gambit->c?

9:07 jkdufair: I understood that eval is verboten on iOS. Then I find out that the framework we are using at work - Rhodes - is running an entire ruby stack on the device. Not sure how that flies

9:07 rodnaph: Raynes: it's just an exercise. not a real thing.

9:08 Raynes: I read some Objective-C code a few days ago.

9:08 I had to have prescription eyedrops to get it out of my eyes.

9:08 rodnaph: the inline parameter syntax is kinda nice in obj-c - that's about it tho.

9:14 jkdufair: i'm a big smalltalk fan, so i thought i'd be more of an objc fan, but it seems to be the bastard stepchild of smalltalk and a rusty 1957 nash rambler

9:15 clj -> gambit? how's that work?

9:17 Raynes: https://github.com/takeoutweight/clojure-scheme

9:18 jkdufair: hey that's pretty cool.

9:19 do i see that rich and stuart h are working on this?

9:21 TEttinger: Clojure on the CLR -> Mono -> MonoTouch = iPhone Clojure

9:22 just costs... money

9:23 jkdufair: clj -> objc would be cool

9:23 S11001001: via gambit sounds less insane

9:23 pjstadig: jkdufair: clojure-scheme? no, it's a fork of clojurescript so it has commits from rich and stu

9:23 cemerick: jkdufair: doesn't look like it.

9:27 jkdufair: ah cool

10:31 dnolen: CLJS users please try master when you get a chance

10:31 I made quite a few changes to address direct invocation, shouldn't really make any difference to most folks - but issues sensible warnings for the edge cases.

10:33 wkmanire: Good morning.

10:43 cemerick: For your consideration: Friend, an extensible authentication and authorization library for Clojure Ring webapps and services http://wp.me/p10OJi-d6

10:51 fdaoud: cemerick: excellent!

11:02 weavejester: cemerick: I like the use of derive and keywords for the roles in Friend

11:02 cemerick: weavejester: yeah, I'm *way* too happy about that :-)

11:02 Raynes: weavejester: What is your real first name?

11:03 If you don't mind me asking.

11:03 cemerick: Of course, the values in :roles can be anything, of course.

11:03 weavejester: Raynes: James

11:03 Raynes: Oh yes. I knew that. I'm not sure why I thought I didn't.

11:05 weavejester: cemerick: I'm a little uncertain about the workflow… when it comes to authentication/authorization, too many overly-complex libraries have left me suspicious of such things

11:06 cemerick: weavejester: I mostly share your reluctance. It's the thinnest thing I could come up with and still retain the sort of development experience I wanted.

11:07 I'm certain things will need to be rejiggered a bit. e.g. this is a good indication that something's not quite right: https://github.com/cemerick/friend/blob/master/src/cemerick/friend/openid.clj#L82

11:07 wkmanire: I cannot get Technomany's swank-clojure plugin installed.

11:07 :/

11:08 Raynes: cemerick: Add BrowserID and I'm in.

11:08 cemerick: Raynes: Add BrowserID and you're in. :-)

11:08 Raynes: I totally didn't know you were going to say that.

11:08 cemerick: hah

11:08 wkmanire: lein keeps trying to delete temp files it doesn't have rights to delete

11:08 weavejester: cemerick: I'm not sure I entirely understand the workflows. I mean, I can understand their purpose, but not how they work

11:09 cemerick: Raynes: You've already done the hard work. Bridging it to a Friend workflow should be cake.

11:09 weavejester: The docs are far from comprehensive. Pepper me with questions at your convenience.

11:10 I sent an ANN to ring-clojure, but I think it was auto-moderated. That might be the best forum for a proper discussion once you're ready.

11:11 weavejester: cemerick: Looks like there are 2 pending messages

11:12 cemerick: Shall I remove one? They look like they're duplicates.

11:12 cemerick: weavejester: yes, please. I was worried I fat-fingered a second.

11:13 Raynes: Man, I do that so often.

11:13 I don't even use google groups because of that crap.

11:13 weavejester: cemerick: Okay, done.

11:14 fdaoud: ring-clojure?

11:14 weavejester: fdaoud: The google group

11:15 fdaoud: weavejester: oic. thanks.

11:16 weavejester: cemerick: I think I understand workflows now, after reading through more carefully. I'll ask some questions on the Ring group, as I'm curious as to your reasoning on some things. There are likely scenarios I haven't thought about.

11:17 jsabeaudry: Which profiler do people use with clojure? (I'm using VisualVM however I find it very rudimentary)

11:17 wkmanire: Well, I added a comment to the existing issue for the problem I'm having on technomancy's github account.

11:17 Guess I'll just have to wait on this one for a bit.

11:17 cemerick: weavejester: well, same here :-)

11:18 jtoy: is there a more idiomatic way to write this? (let [ json (json/parse-string line)] (if (nil? json) [] (vector ( map json ["name" "description" "id" "count"]))))

11:19 jsabeaudry: jtoy, if-let would help

11:19 weavejester: cemerick: I like :identity and :roles. But… hm… I'd have been tempted to make the workflow middleware, and add those keys to the request.

11:20 jtoy: jsabeaudry: ok, ill look into if-let, I've never used it

11:20 cemerick: weavejester: the identity is added to the request

11:21 fliebel: jtoy: Would select-keys help?

11:21 weavejester: cemerick: Oh, so… what's the reasoning for workflows not being middleware? Or are they?

11:21 jtoy: ah cool, i was wondering if this existed in clojure

11:22 mefesto: hey everyone

11:22 Raynes: mefesto: Long time no see.

11:22 jtoy: fliebel: would that replace the vector/map piece? I am still ltotally confused with sequence/vectors , i only got that to work from testing on the repl,

11:22 mefesto: Raynes: yeah work is killing me :)

11:22 Raynes: We'll always have Raleigh/Durham. <3

11:23 mefesto: true true

11:23 i missed the last conj but plan to be at the next one

11:23 fliebel: jtoy: dunno, I think it would return a map, so it's just an alternative...

11:24 weavejester: jtoy: Why do you need the vector part anyway? Usually a seq will do, unless you need fast indexing.

11:24 Raynes: (if-let [json (json/parse-string line)] (select-keys json ["name" "description" "id" "count"]) [])

11:24 jtoy: weavejester: I need to return the data in a vector, the other functions that use it need a vector

11:24 Raynes: jtoy: ^ Untested.

11:24 weavejester: jtoy: Also, (vector '(1 2)) => [(1 2)]. You might want (vec '(1 2)] => [1 2]

11:25 jtoy: Are you sure they need it as a vector?

11:25 cemerick: weavejester: I didn't think middleware was right for authentication processing. Too much power and responsibility for the middleware author, and configuration and ordering complexity for the user.

11:26 jtoy: weavejester: yes, also you are right, i think i need vec

11:27 weavejester: cemerick: That's true… I think I'll need to look into Friend further and come back with a more thoughtful response.

11:32 cemerick: weavejester: That is to say, there's plenty of auth middleware about already. I don't think anyone is being particularly well-served by it. Part of my response is to take away some of the rope, build a box (one as shallow as possible), and make the rules therein very clear.

11:33 (not that I've made anything as clear as it needs to be w.r.t. docs :-)

11:34 weavejester: cemerick: I agree with the reasoning. I'm just not completely certain about the interface yet. The idea that workflows can return responses *or* authentication maps seems a little… untyped, so to speak.

11:35 jtoy: nm i wnt vector and not vec

11:35 cemerick: weavejester: my kingdom for an Option ;-)

11:36 jkkramer: cemerick: nice work so far, appreciate the effort. I have an app with three roles: anonymous user, anonymous user with implicit account, registered user, and admin. going from anon to anon-with-account requires action but no "credentialing". Friend is flexible enough to handle that with a custom workflow, yes?

11:37 cemerick: weavejester: but yes, you're absolutely right. I'm not thrilled with that aspect of things, either. I've been contemplating requiring them to return a ring response with an optional authentication map therein. Still thinking.

11:37 gfredericks: okay so if I just have a single cljs file that I'm compiling to a single js file without any closure/cljs deps included, can goog/cljs be included as static unchanging files? and where would I get that?

11:37 weavejester: cemerick: Admittedly I don't have a better solution, either ;)

11:38 cemerick: jkkramer: Certainly. That workflow would be a function that creates the placeholder account and returns the corresponding authentication map.

11:39 jkkramer: That's actually exactly how most anyone would use the openid workflow, since logging in for the first time generally registers you with the app at the same time. With openid, it's the credential function that would do the work.

11:39 jkkramer: ok, cool

11:40 gfredericks: Currently using this to compile from maven: https://refheap.com/paste/2004

11:40 jkkramer: cemerick: any plans to make password reset flows easier? that's another thing i've re-invented several times for different apps -- generate reset token, email user with special url, expire the token after a while, etc.

11:40 Raynes: Yay! Over 2000 pastes

11:41 Been getting a lot of pastes from rubeque lately.

11:42 cemerick: jkkramer: Not at present. Sounds like a good companion library though, for someone that knows how that sort of thing should work :-)

11:45 antares_: I am trying to implement clojure.core.cache for Monger and getting "CacheProtocol" is not a protocol from the compiler. What am I doing wrong? https://gist.github.com/48422a63cbbec00a1e0e

11:45 java.lang.IllegalArgumentException: interface clojure.core.cache.CacheProtocol is not a protocol

11:46 Na-Fiann: hi, I'm trying to learn clojure by doing the 4clojure.com exercises. However, at exercise 21, I get an error message from the website, where it works fine for me. the Error is "You tripped the alarm! nth is bad!". However, I'm not using nth (the objective is to implement that function). Any idea why the following might trip the alarm? http://pastebin.com/fFrDy9j8

11:47 Raynes: 4clojure macroexpands its input. I'm guessing letfn expands into code that uses nth.

11:47 Hrm, or not.

11:48 Oh, destructuring.

11:48 Yeah, that's probably what is causing it.

11:48 ngw: hi *

11:48 Na-Fiann: ahh

11:48 hm

11:49 ngw: I'm using korma for my SQL, does the library give a way to validate data?

11:49 Na-Fiann: dammit, that was my favorite bit here -_-

11:49 Raynes: Sometimes this happens for the silliest of reasons, but there aren't easy ways to prevent form happening. The usual recommendation is to try writing it in a slightly different way.

11:50 jkkramer: antares_: you need to import CacheProtocol -- (:import [clojure.core.cache CacheProtocol])

11:50 ngw: what I'm not able to understand is where does Korma sits: does it only generates the SQL or is it, to say, "for models"?

11:50 because I can as well build functions to validate for example an email format

11:51 but I don't know if that's the right idiomatic way

11:52 Na-Fiann: Raynes, yeah that was the problem. Thanks

11:52 Raynes: Na-Fiann: Sorry it had to happen in the first place. :|

11:52 antares_: jkkramer: I did and it does not help. Updated gist: https://gist.github.com/48422a63cbbec00a1e0e

11:53 ngw: I believe there's noir.validation. And https://github.com/michaelklishin/validateur/, a standalone library.

11:54 jkkramer: antares_: does changing clojure.core.cache.CacheProtocol to just CacheProtocol in your extend-protocol call help?

11:55 antares_: jkkramer: I tried imported value initially, I believe it does not

11:55 ngw: oh nice

11:55 thank you antares_

11:58 wow, it's pretty cool

11:59 searching for validation at the db layer was probably some rails brain damage, thank you *

11:59 jkkramer: antares_: how about cache/CacheProtocol (and remove the :import line)? I believe clojure creates an interface with the same name as the protocol. interfaces are imported, but protocols can be got via :require/:use…I think

12:00 antares_: ngw: there's nothing wrong with validation at the db layer. Validateur is mostly used in that setting. noir.validation maybe be different.

12:00 jkkramer: sigh, you are right

12:01 jkkramer: clojure.core.cache.CacheProtocol = interface, clojure.core.cache/CacheProtocol = protocol

12:01 antares_: jkkramer: right

12:08 jkkramer: thank you very much, several tests already pass.

12:25 fliebel: What would be a neat way to organize a lot of parameters from a gui into one function? I started adding a few, and the if statements are already getting out of hand. I think I need some higher order magic.

12:28 I'm reading data from an oscilloscope, but with 2 channels and a lot of modes, the acquisition gets a little out of hand.

12:32 hiredman: fliebel: rules engine

12:32 fliebel: $google rules engine

12:32 lazybot: [Business rules engine - Wikipedia, the free encyclopedia] http://en.wikipedia.org/wiki/Business_rules_engine

12:35 fliebel: hiredman: Anything particular? It seems swats of if statements is also a rules engine.

12:36 RickInGA: dnolen: I just saw on twitter that you have heard that a cljs book is in the works... have any more info?

12:36 dnolen: RickInGA: nope heard that from cemerick

12:37 hiredman: fliebel: really, what makes you say that?

12:37 cemerick: RickInGA: it's a well-known secret at this point, I think.

12:37 fliebel: hiredman: The above link "The first class processes so-called production/inference rules. These types of rules are used to represent behaviors of the type IF condition THEN action"

12:38 RickInGA: dnolen: ok, thanks. Is there a good way to start with CLJS for people that need a bit of hand holding? I have peeked at cljs a few times, and just not known where to start

12:39 dnolen: RickInGA: ClojureScript is just Clojure sans concurrency stuff - I recommend using lein-cljsbuild.

12:42 RickInGA: dnolen: cemerick: thanks

13:06 autodidakto: technomancy: Do both lein 1.x and lein 2.x project.clj files use the same syntax for dev dependencies?

13:07 That is, ":profiles {:dev {:plugins [" ?

13:09 dnolen: JS-centric but still interesting w/ respect to CLJS - http://www.meteor.com/main

13:10 autodidakto: er. i'm trying to straighten out the use of dev-dependencies/plugins on a project basis

13:13 RickInGA: dnolen: that is pretty cool

13:14 dnolen: RickInGA: yeah, caching DB data on clients and supporting queries is the future. I'd rather use Datomic Datalog queries over MongoDB tho.

13:14 jaen: I see reactive interface is pretty big nowadays ; d

13:15 dnolen: Meteor client packages are neat, but we already have that with lein

13:16 RickInGA: ibdknox has a cljs template that recompiles when you save a file, noir does the same.

13:16 don't know about wiring into the database

13:17 dnolen: RickInGA: it's not the direct wiring into the database that is interesting - just caching + queries.

13:17 clearly any real solution needs to deal with privileges

13:21 RickInGA: dnolen was your talk at jsconf recorded?

13:23 dnolen: RickInGA: yes

13:27 technomancy: autodidakto: plugins don't need to go in profiles

13:27 they can just be at the top-level of defproject since they aren't transitive

13:27 autodidakto: rephrase: Should lein plug... err

13:27 hmm

13:27 technomancy: :dependencies inside the :dev profile are just for things that need to run inside the project

13:28 autodidakto: Ok. So I have a plugin that I want for my project, i open up my project.clj..

13:28 and do I use -> :dev-depencies, or {:dev {:plugins ?

13:28 or :profile {:dev {:plugins ?

13:29 technomancy: :plugins [[lein-whatevs "0.1.0"]]

13:29 autodidakto: lein 1.x and 2.x, same?

13:30 technomancy: yes, unless you need 1.6 or older

13:30 :plugins is new in 1.7

13:30 autodidakto: gotcha...

13:30 working on the lein-ritz README... i think they confused the instructions

13:30 2.x, they use "{:dev {:plugins" and 1.x they use ":dev-dependencies"

13:31 technomancy: boo

13:32 autodidakto: heh. Both should be (defproject ... :plugins [[...]] then..

13:32 technomancy: yeah, that's basically why 1.7 was released =)

13:32 to get :plugins support into the 1.x branch

13:33 autodidakto: perfect. Thanks :)

13:33 Btw, do you have any opinion about lein-ritz (swank-clojure replacement that adds debugging, i think) ?

13:33 technomancy: I haven't tried it myself, but I like the idea.

13:34 autodidakto: Was talking to the author. He said that it has come a long way. I offered to help cleanup the readme

13:35 technomancy: in the long run I would like to see a shift towards nrepl

13:35 autodidakto: does nrepl do debugging?

13:36 wkmanire: technomancy: Hey, I added a comment to an issue a windows user reported for your clojure-swank plugin.

13:36 I've been trying to install it on a windows box.

13:37 technomancy: autodidakto: not yet, but I think it's more productive to focus on a single backend

13:37 hugod: autodidakto: the instructions for 2.x refer to the .lein/profiles.clj file, that provides a cross project way of using lein-ritz

13:37 wkmanire: That user was able to re-run the install command for the plugin after the first time it failed, and the second time it worked. I haven't had the same success.

13:37 technomancy: autodidakto: oh yeah, for something like lein-ritz you shouldn't put it in project.clj anyway; my bad

13:37 cpinera: Hi there! Newbie question: anyone has experience configuring emacs/slime for CL & Clojure? I'm interested in learning Clojure, but I'm afraid I'll have to re-install slime and re-configure my emacs setup from the ground up.

13:38 hugod: autodidakto: adding lein-ritz, a development tool, to your project.clj is perhaps not the nicest thing to do

13:38 technomancy: wkmanire: hmm... I don't really know much about Windows, but it sounds like you have permissions issues; maybe you were using Leiningen as another user?

13:38 yoklov: technomancy: a shift to nrepl over slime?

13:38 technomancy: yoklov: some day

13:38 wkmanire: technomancy: I'm runing it as administrator from the console.

13:38 Windows attempt at a terminal emulator.

13:39 Windows'*

13:39 running*, wow, I need to focus.

13:39 yoklov: i wasn't aware nrepl could offer that level of interactivity

13:39 technomancy: wkmanire: I don't understand, shouldn't administrator have permissions to do anything?

13:39 wkmanire: Yeah, it should.

13:39 technomancy: yoklov: it doesn't yet; it's got a long way to go

13:39 yoklov: i see.

13:40 wkmanire: technomancy: Is there a way I can manually complete the installation process from where it died?

13:40 I really want to get the REPL running in an emacs buffer.

13:40 technomancy: wkmanire: you could check out swank-clojure 1.4.4, run "lein uberjar", and copy the uberjar into your plugins dir

13:41 wkmanire: technomancy: Already cloned swank-clojure, I'll give uberjar a shot.

13:41 technomancy: wkmanire: or you could use inferior-lisp

13:42 M-x run-lisp in a clojure-mode buffer

13:42 wkmanire: technomancy: Would that be the same thing?

13:43 technomancy: no, it's a simplified version

13:43 but if all you want is a repl in an emacs buffer, that's it

13:43 autodidakto: hugod: Nonetheless, the readme does offer those (broken) instructions to add it to your project.clj ... but since you both agree, I will remove those instructions from the readme entirely

13:44 wkmanire: technomancy: I bought cemerick's book and am trying to get my tooling set up the way most folks do it for wokring out of emacs.

13:44 I'll give the uberjar approach a try first.

13:44 working*

13:44 technomancy: unfortunately windows is pretty different from the way most folks work

13:45 wkmanire: technomancy: Trust me, I'd much rather be doing this from my Linux box.

13:46 autodidakto: sorry, disconnect... wkmanire: don't let tooling slow you down for now. you'll figure it out as you go along. make progress in the book :)

13:47 technomancy: M-x run-lisp is definitely the simplest way to go

13:47 wkmanire: ok.

13:48 Well, I think I build from the master branch because it created swank-clojure-1.5.0-SNAPSHOT.jar

13:48 I'll try to run-lisp approach now.

13:49 autodidakt: hugod: I'll remove the project.clj instructions, then?

13:50 wkmanire: Yeah, instant success.

13:50 technomancy: If you would like me to do anything to help you troubleshoot this installation issue on windows feel free to contact me on github.

13:51 hugod: autodidakt: makes sense to me

13:51 wkmanire: I would eventually prefer to do this the "right" way.

13:51 technomancy: wkmanire: sorry, I wouldn't know where to start

13:52 twhume: I'm having trouble with max-key, probably betraying a fundamental misunderstanding. If I do

13:52 (def fl (list (magicInk.Global.feedback. "A" 2), (magicInk.Global.feedback. "B" 1)))

13:53 (max-key :modifier fl)

13:53 … why do I get (#magicInk.Global.feedback{:objname "A", :modifier 2} #magicInk.Global.feedback{:objname "B", :modifier 1}) returned and not a single item (#magicInk.Global.feedback{:objname "A", :modifier 2}) ?

13:55 Is it something to do with passing a list of records into max-key…?

13:55 ibdknox: dnolen: RickInGA: meteor is relatively straightforward to build in clj/cljs

13:56 RickInGA: ibdknox: I was thinking after some of the stuff you had built, it couldn't be that far away

13:56 ibdknox: dnolen: I built some of the basics of it already, though didn't continue with it. The problem with such a system is that the code has to exist in both contexts, and that usually has very real consequences.

13:56 I also don't really understand the value of having an api to the database directly

13:56 seems like a disaster waiting to happen

13:57 RickInGA: ibdknox: yeah, probably. Still looked cool :)

13:57 ibdknox: the coolest part for me was their reactivity implementation

13:57 which is also the easiest to reimplement

13:57 :)

13:58 RickInGA: reactivity = pushing changes to the clients?

13:58 ibdknox: the code automatically knowing what things might cause a fragment to change

13:59 no meta data needed to explain the bindings

13:59 it just happens

13:59 RickInGA: ah, yeah, that is neat

14:01 ibdknox: I have a little library that haven't pushed anywhere

14:02 called bridge that is the first part of their dev experience: a pluggable way to send random assets/messages to the client as soon as they're available

14:02 I was using it for auto CSS loading on save

14:02 Raynes: ibdknox: You have a little library for everything.

14:02 * ibdknox looks around innocently

14:03 ibdknox: Raynes: maybe. :p

14:03 autodidakt: hugod: I've spent the last hour or two pouring over the install instructions, fighting with words, struggling for clarity... Check it out and confirm that I'm on the right path

14:03 https://github.com/autodidakto/ritz/blob/develop/README.md

14:03 RickInGA: jcrossley: I want to get a user group started. any ideas for good meeting places?

14:03 fdaoud: go fetch a crate, then do a waltz, jayq! you'll have better korma and won't be left in the noir.

14:03 ibdknox: lol

14:04 autodidakt: RickInGA: lady's night at chippendales

14:05 RickInGA: jcrossley3: just saw I typed your name wrong...

14:05 jcrossley3: RickInGA: ?

14:05 mk: jcrossley3: it was missing a 3

14:06 (and so might not have triggered your irc notify)

14:06 jcrossley3: ah, i c now

14:06 RickInGA: jcrossley3: I said that I wanted to start a user group and wondered if you had any ideas where we could host it. Then it occured to me that you might not have been alerted

14:07 jcrossley3: RickInGA: i don't know of a place offhand, but i can ask around

14:09 RickInGA: jcrossley3: thinking about finding a coffee shop easy access from interstates, and make finding a better space an agenda item

14:10 jcrossley3: RickInGA: good idea

14:12 18WAARKKY: Agg. sorry for the nick change spam. I hate freenode.. or maybe it's my client. oh well

14:16 troessner: guys, my current company is hosting a party for some bright, young, err, programming talents. i am trying to come up with a task they can use to hack on. since i'd also like to learn something, i am thinking of something practical in clojure

14:16 is there anything that comes to your mind that you are missing in clojure?

14:16 some small libraries maybe that you love from other languages?

14:16 should be something that's doable in 2 - 3 days

14:17 jsabeaudry: troessner, what I'd like is to be able to call ioctl from clojure

14:17 Iceland_jack: “A type system”

14:17 * Iceland_jack ducks

14:17 ibdknox: lol

14:17 18WAARKKY: Iceland_jack: turing complete?

14:17 troessner: :-)

14:17 Iceland_jack: 18WAARKKY: I would insist

14:17 * Iceland_jack goes back to Qi/Shen

14:17 mk: troessner: merely providing bindings to an existing java lib might not be too fun

14:18 S11001001: troessner: bug tracker for dogfooding, good enough for dogfood

14:18 jsabeaudry: I just found out that (mod i 8) won't be optimized as (bit-and i 7) :(

14:18 mk: troessner: this is probably not something many people will use at all, but I've been curious about how opengl might be used with clojure

14:18 troessner: jsabeaudry, i think that's way to complex for some 19 years old with no experience in clojure

14:19 S11001001, should be something that they feel is valued by the community.....

14:19 S11001001: troessner: community of programmers, or who?

14:19 ibdknox: mk: ztellman has a lib for opengl https://github.com/ztellman/penumbra

14:20 troessner: S11001001, the clojure community

14:20 S11001001, i come from ruby / python - my first thought was something along "fix some bugs in rails"

14:20 mk: troessner: you might look at the gsoc proposals for some ideas

14:20 troessner: but i want to learn something too

14:21 and i don't know much about clojure or lisp for that matter

14:21 mk: ibdknox: interesting, thanks

14:21 ibdknox: troessner: if you're new, I wouldn't worry about building something useful - just build something fun :)

14:22 troessner: ibdknox, true, but i don't want them to do something like the x-th draft for a web framework

14:23 something that requires you to grasp basic languae concepts

14:23 and is usefull at the same time

14:23 would be perfect

14:23 jsabeaudry: troessner, do your young programming talents have experience with something in particular?

14:23 troessner: jsabeaudry, unfortunately that varies - the first one in java, the second one in haskell, the third one in JS and python

14:24 mk: troessner: the last few mini-projects I saw linked in here included a roguelike game, and a game-of-life like simulation. Seeing people do fun things in clojure is good publicity

14:24 * technomancy definitely recommends a game

14:24 technomancy: "something useful" is probably too ambitious for getting started.

14:25 gtoast: Is there a function to lazily join to sequences together, so after seq A is exhausted elements come from seq B?

14:25 troessner: technomancy, hmm, good point

14:25 yoklov: clojure's surprisingly great for making games

14:25 mk: it can also be boring, unless you yourself feel the frustration caused by not having this useful thing

14:25 yoklov: something which is usually a pain in functional languages

14:25 raek: gtoast: concat and lazy-cat

14:25 gtoast: raek: thanks

14:25 18WAARKKY: raek: if i ever make a podcast/book/website for clojure, it's so going to be called "lazy-cat"

14:25 troessner: mk, yoklov, technomancy hmmm, i like the idea of a game

14:26 mk: both of those examples I mentioned were written by yoklov

14:26 18WAARKKY: yoklov: text based? swing?

14:26 raek: gtoast: concat calls seq on its arguments though (allows you to pass seqable things like arrays and vectors)

14:26 ibdknox: there's some source code for pong on my github

14:26 raek: lazy-cat is fully lazy

14:26 yoklov: 18WAARKKY, swing, as text based ends up being being a hassle with java

14:26 18WAARKKY: ibdknox: i'm there

14:26 mk: yoklov: can you link the demo of the roguelike, and the hex thing?

14:26 ibdknox: it's not finished

14:26 18WAARKKY: yoklov: I've been toying with the idea of a text game... hassle in java? do explain

14:27 ibdknox: and probably sucks compared to what I would do now... but it does work :)

14:27 yoklov: roguelike game: http://thomcc.github.com/dunjeon/ cellular automata: http://thomcc.github.com/hex/

14:28 18WAARKKY, i just mean console output can be weird, you have to use lein trampoline to get stdin to work right, i don't know. swing's cleaner

14:28 (hex is in clojurescript)

14:29 ibdknox: the code I mentioned: https://github.com/ibdknox/clojure-pong

14:29 mk: yoklov: I see you ported the roguelike to cljs. No diagonal movement keys?

14:29 yoklov: mk: nah. I don't really have a good reason for why not, to be honest.

14:30 ibdknox: troessner: oh right, I also built the live game editor... lol

14:30 forgot about that

14:30 that has all the code needed for something mario-esque

14:30 mk: yoklov: I think I just saw two monsters merge into one

14:31 yoklov: mk: you did. that can happen if they have the same health and occupy the same position. its a fairly rough-around-the-edges game.

14:31 ibdknox: troessner: which might also help if you want to just get people started quickly - no setup required. http://www.chris-granger.com/2012/02/26/connecting-to-your-creation/

14:31 18WAARKKY: yoklov: how is it that fp is good for games? summarize!

14:32 ibdknox: Build a functioning game in your editor? heh. And i thought it was jsut a demo..

14:32 ibdknox: oh no

14:33 it's not vaporware

14:33 that actually works

14:33 lol

14:33 yoklov: 18WAARKKY, fp usually isn't, but clojure makes it nice. immutability is a boon because you don't have to worry about getting into an inconsistent state and stuff, i don't know.

14:33 mk: 18WAARKKY: clojure isn't so strict with fp that it lacks the various state-changing things that make things difficult

14:33 ibdknox: I definitely wouldn't say it's easier to write it in Clojure though

14:33 having done both a few times now

14:33 with the same games

14:34 18WAARKKY: mk: ahh. was about to mention "functional reactive programming"

14:34 yoklov: 18WAARKKY, look at the source for dunjeon and see if things like that appeal to you: https://github.com/thomcc/dunjeon/blob/master/src/dunjeon/core.clj

14:34 FRP is, in my experience, too slow to be useful.

14:34 18WAARKKY: yoklov: Thanks, I'll check it out

14:35 ibdknox: not easier? explain :)

14:36 yoklov: it's short. essentially being able to structure your code as a bunch of transformations over data structures is neat. tick is essentially: (-> game-state (tick-player input) autoheal tick-monsters update-vision)

14:37 ibdknox: things like update are complicated a bit by not being able to update in place

14:37 doing it *did* affect the way I write games in other languages now though

14:37 mk: ibdknox: update in place?

14:37 troessner: ibdknox, that looks interesting, thanks! i'll look into that

14:37 ibdknox: I think much more about behaviors

14:39 mk: yeah, if (-> ...) is your only real way to chain a series of mutations, you can't do relatively simple things like (if x (cool x) (zomg x)) without reworking things a bit, or constantly evaluating the conditionals in different places

14:40 in most programs you can get away with that because truly not that many things are mutable

14:40 but in a game..

14:40 everything is mustable

14:40 mutable*

14:40 otherwise you have a very boring game :)

14:40 fdaoud: troessner: other ideas for games: http://landoflisp.com/source.html

14:41 mk: ibdknox: how do you end up reworking things?

14:41 ibdknox: hiding conditionals in functions is what I ended up doing

14:42 Chousuke: I don't think there's anything inherently mutable about a game

14:42 yoklov: ibdknox: yeah, the fact that (->) is a macro is sometimes annoying, as it means it doesnt work well with ifs and whatnot

14:42 Chousuke: but it's hard to make efficient without mutation

14:42 ibdknox: fwiw, the last time I wrote a little example game for someone, I did it in JS directly and found it much easier

14:42 Chousuke: sure, I went down that route too and it was disgusting to write any real game logic :(

14:43 Chousuke: you'd probably need logic programming to go with it :P

14:43 yoklov: Chousuke, have you written many games? they are sort of inherently stateful

14:43 Chousuke: yoklov: in practice I guess. :P

14:43 technomancy: yoklov: state can be tracked on the stack without mutable state

14:44 out of the tarpit, etc

14:44 yoklov: technomancy, yeah, and thats what i've ended up doing when making games in clojure

14:44 but its a bit

14:44 awkward. much better in clojure than in, say, haskell

14:45 where it just ends in cursing

14:46 Chousuke: what was that proof of concept where you could alter parameters of the game engine and replay your actions? that was cool

14:46 but it's probably too slow to be of much use in a real game :(

14:48 yoklov: Chousuke, are you talking about http://www.chris-granger.com/2012/02/26/connecting-to-your-creation/ ?

14:48 Chousuke: yeah, that one

14:49 yoklov: it's extremely neat

14:49 its a little slow but very fast for clojurescript code

14:50 Chousuke: that would be awesome in a roguelike :

14:50 you could do time travel

14:50 and then cause all sorts of weird things to happen

14:51 yoklov: something like time travel is probably a good example of something which would be easier to implement in a functional language than in an imperative one

14:51 nlew: best selling point for functional programming I've ever heard

14:52 Chousuke: or you could recover from game engine crashes by just rolling back to the previous state (while preparing a bug raport from the faulty state)

14:52 aperiodic: it would be cool to see a braid clone written in clojure

14:52 Chousuke: report*

14:52 aperiodic: i imagine that doing all the time manipulation in that game would be easier than in an imperative language

14:54 yoklov: but slower, and braid had it work so smoothly

14:54 ibdknox: the latest versions of CLJS should dramatically improve the speed there

14:58 yoklov: yeah, maps are still slow though :(

14:58 ibdknox: not too much longer :)

14:58 yoklov: no?

14:58 clojurebot: no is tufflax: there was a question somewhere in there, the answer

14:58 ibdknox: someone has a persistentHashMap impl somewhere

14:59 yoklov: oh, the javascript one?

14:59 or in cljs

14:59 ibdknox: CLJS

14:59 persistent vectors made it in

15:00 and I remember a tweet saying hashmaps weren't far behind

15:01 cpinera: What is the difference between defn and defn- ?

15:01 mefesto: cpinera: defn- is private to the namespace

15:02 cpinera: mefesto: got it. Thanks!

15:03 yoklov: ibdknox: neat. then all thats left are chunked seqs and transients

15:06 cpinera: sorry for these very basic questions. What does the @ symbol mean when it's prepended to a variable that is being passed to a function?

15:07 S11001001: cpinera: @anything = (deref anything)

15:07 cpinera: S11001001: perfect. Thanks!

15:07 S11001001: deref is a function

15:09 cpinera: S11001001: Am I ok to assume that I'll need to deref most anything I send to java methods, since they can most surely have side-effects?

15:09 S11001001: deref is a function that operates on IDerefs, and has little to do with purity

15:10 incidentally, you can look for sugar using quotes

15:10 &'@anything

15:10 lazybot: ⇒ (clojure.core/deref anything)

15:10 S11001001: &'`(list ~a ~b ~c)

15:10 lazybot: ⇒ (clojure.core/seq (clojure.core/concat (clojure.core/list (quote clojure.core/list)) (clojure.core/list a) (clojure.core/list b) (clojure.core/list c)))

15:11 yoklov: and then once you know the name of the function

15:11 (doc deref) can help you lots

15:11 (in your repl)

15:11 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.NoClassDefFoundError: Could not initialize class clojure.lang.RT>

15:12 cpinera: Got it. Thanks for the explanation and the link!

15:40 Cr8: gah, maybe my attempts to learn emacs would be going better if I didn't have a keyboard with blank keys.

15:42 18WAARKKY: Cr8: we put a hardware Qwerty->Dvorak adapter on your keyboard cable as a joke

15:42 Cr8: if they make those, i am buying one, and doing that to somebody

15:42 18WAARKKY: hehe they do

15:43 Cr8: they do

15:43 alright

15:43 fff

15:43 expensive

15:43 18WAARKKY: the joke would be priceless.... or at least, if you do it enough times it will be worth it

15:48 ahh yes. perfect

15:48 fliebel: I hope neotyk read that... hm, he isn't even on.

15:49 18WAARKKY: spread the news

15:56 * Cr8 uses vim to edit init.el again

15:57 18WAARKKY: We'll all done it from time to time.... to time...to time...

15:57 *We've

16:06 RickInGA: samaaron: I am using your live config, but it doesn't give me paredit or syntax highlighting when I am editing a cljs file. Is that normal?

16:09 mrb_bk: dnolen: have you checked out "lisp in small pieces"

16:10 dnolen: mrb_bk: I have a copy but only read the first few pages - looks amazing. I want to finished Dan Friedman et al's Essentials of Programming Languages first.

16:11 mrb_bk: dnolen: ah yeah, that's on my list too

16:11 been specifically curious about a book about implementing lisps in a non-lisp

16:12 rads: dnolen: I saw your tweet: "I'd be more excited about Meteor if I hadn't seen most of that stuff working in ClojureScript already." what stuff are you talking about exactly? running code in the browser?

16:14 ibdknox: rads: it wouldn't take much to make the best parts of meteor in clj/cljs

16:14 dnolen: rads: there wasn't anything significant in the demo that you can't do in Clojure/ClojureScript or Clojure/ClojureScript libraries etc.

16:15 wei_: is there such thing as "map" with a state threaded through?

16:15 rads: I see. it sounded like there was something already out there I could take a look at

16:16 ibdknox: rads: if I get antsy enough, maybe there will be ;)

16:17 Bronsa: wei_: reduce+atom?

16:17 ibdknox: wei_: I'm not sure I understand the question

16:20 wei_: hm, let me try to rephrase

16:20 amalloy: reductions or reduce are both sufficient. using an atom as part of a reduce is probably a crime

16:21 ibdknox: yeah that's scary lol

16:21 wei_: yeah, I probably don't need an atom since the state is localized to the map

16:22 emezeske: Bronsa: ,(reduce (fn [[state result] item] [(inc state) (conj result (+ state item))]) [0 []] [1 2 3 4 5])

16:22 ibdknox: just reduce then

16:22 Bronsa: oic

16:22 rads: ibdknox: I'll be watching. the reactive part of the API confuses me right now

16:22 amalloy: Bronsa: ##(reduce (fn [[state result] item] [(inc state) (conj result (+ state item))]) [0 []] [1 2 3 4 5])

16:22 lazybot: ⇒ [5 [1 3 5 7 9]]

16:22 ibdknox: rads: oh, why? I thought that was the most interesting part lol

16:22 * emezeske didn't know about ##!

16:22 amalloy: personally i prefer (map second (reductions ...))

16:23 rads: ibdknox: I just dont' understand how it works behind the scenes very well

16:23 ibdknox: rads: it's pretty clever

16:23 rads: it's very interesting

16:23 emezeske: Ooh, reductions, veery interesting

16:23 wei_: ok. i think that'll do what I want- thanks!

16:23 for completeness, why is reduce + atom scary

16:24 emezeske: wei_: That introduces mutability where it's not required.

16:24 amalloy: &(map first (reductions (fn [[prev state] item] [(+ state item) (inc state)]) [nil 0] [1 2 3 4 5]))

16:24 rads: I've tried to read up on functional reactive programming before but the literature was a bit over my head at the time

16:24 Bronsa: because now that i notice, it'd be useless.

16:24 lazybot: ⇒ (nil 1 3 5 7 9)

16:24 rads: it seems there aren't a lot of solid implementations around

16:25 ibdknox: rads: their implementation is actually only like 50 lines I think, fwiw

16:25 rads: I saw the link from the documentation. I'll have to read it more closely

16:26 amalloy: or really, just write it by hand: ##((fn step [[x & xs] state] (lazy-seq (when x (cons (+ x state) (step xs (inc state)))))) [1 2 3 4 5] 0)

16:26 lazybot: ⇒ (1 3 5 7 9)

16:27 ibdknox: I don't use lazy seqs enough

16:27 amalloy: ibdknox: i <3 lazy-loop (from useful) as a nicer way to write a lot of lazy-seqs

16:28 * ibdknox goes to look

16:28 amalloy: (lazy-loop [[x & xs] [1 2 3 4 5], state 0] (when x (cons (+ state x) (lazy-recur xs (inc state)))))

16:28 Bronsa: https://github.com/flatland/useful/blob/develop/src/useful/seq.clj#L105-119

16:28 amalloy: macroexpands to the above lazy-seq

16:28 wei_: wow, there's so many ways to do this

16:29 i think I like the reductions version best since it's more succinct

16:29 ibdknox: very cool

16:38 yoklov: wow, there are some uh, pretty useful functions there

16:38 Raynes: Damn it.

16:38 yoklov: i'd have a million uses for take-shuffled

16:38 Raynes: amalloy: I concede. I'm just going to like useful from now on and not complain about it.

16:38 amalloy: haha i'm glad someone wants take-shuffled. i wrote it because it was an interesting function to write; i'm not sure i've ever needed it

16:39 yoklov: i usually just do (take n (shuffle coll))

16:39 aperiodic: samaaron: tried my kinect thing with the quil 1.0.0 release this morning... no luck :(

16:39 yoklov: but the laziness could definitely be beneficial

17:01 RickInGA: I am trying to use an html canvas from clojurescript. I am trying to copy a piece of this example: http://nakkaya.com/2012/01/31/clojurescript-canvas-a-simple-breakout-implementation/

17:02 My code is this, and it doesn't seem to do anything: https://refheap.com/paste/2012

17:03 yoklov: RickInGA, any errors on the page?

17:03 RickInGA: yoklov none that I am aware of, not sure how to check

17:03 I am using Chrome, not sure how to open console

17:04 yoklov: in chrome, right click -> inspect element

17:04 then the console tab

17:04 also, dom/getElement means you need an ns form with (:require [goog.dom :as dom])

17:05 RickInGA: ah, I have an uncaught error, no protocol mehtod iSequable.seq defined

17:05 yoklov: hm

17:06 go to your scripts tab, click the little stop sign at the bottom until it turns purple, and refresh the page (without closing the inspector)

17:06 RickInGA: yoklov I was concerned about that, because the cljs github page had get-element, which I do have working appending to "content"… but I have not found a combination of capitalization and dashes to work for my canvas

17:06 yoklov: does your canvas have <canvas id="surface"></canvas>

17:06 err look like

17:07 and try (.getElementById js/document "surface")

17:07 RickInGA: <canvas height="500" id="surface" width="500">

17:07 yoklov: okay, thats good

17:08 RickInGA: yoklov: change (dom/getElement to (.getElementByID ?

17:08 yoklov: yes

17:08 RickInGA: lose the dom/ ?

17:09 yoklov: mhm, (.getElementById js/document "surface")

17:09 RickInGA: Uncaught Error: No protocol method ISeqable.-seq defined for type function: function () {

17:09 var a = "surface".getElementByID();

17:09 yoklov: thats what (dom/getElement) does, in all likelihod

17:09 RickInGA: return cljs.core.Vector.fromArray([a.getContext("2d"), a.width, a.height])

17:09 }

17:09 yoklov: okay, look in the right hand side

17:09 under locals

17:09 see what "a" is

17:09 err scope variables > locals

17:10 it should be a canvas element type of some sort

17:11 RickInGA: in scope variables it just says not paused

17:11 yoklov: oh actually

17:11 no i see whats wrong

17:11 RickInGA: ah, found pause… progress :)

17:11 yoklov: you're doing (.getElementById "surface")

17:11 you want

17:11 (.getElementById js/document "surface")

17:13 RickInGA: yoklov same error

17:13 yoklov: hm

17:13 oh

17:13 haha

17:13 (fill-rect surface [0 0 10 10] [255 255 255]) should be (fill-rect (surface) [0 0 10 10] [255 255 255])

17:14 RickInGA: duh, yeah, thanks

17:14 yoklov: and then everything else you had before should work.

17:18 kjellski: is there anything I can do about the emacs elpa install of swank-clojure is failing in emacs with the output of "File exists: /Users/me/.emacs.d/elpa/clojure-mode-1.7.1/clojure-mode.el

17:18 RickInGA: yoklov: not yet, but thanks for the help

17:19 yoklov: RickInGA, what's wrong now?

17:19 * yoklov has been debugging cljs canvas crap for the past week or so

17:20 RickInGA: yoklov: same error.

17:20 yoklov: kjellski, i don't think you need swank-clojure anymore

17:21 RickInGA: yoklov ok, new error :)

17:21 yoklov: oh?

17:21 senthil: are Vectors equivalent to Array in Ruby?

17:21 RickInGA: cannot call method 'call' of undefined

17:21 yoklov: something is nil which you're using as a function

17:21 senthil, more or less, but vectors are immutable

17:22 jtoy: so does clojure have libraries that allow for async program?

17:22 senthil: yoklov: like most other data types right?

17:22 yoklov: yeah, all of clojures datatypes are immutable

17:22 kjellski: yoklov, I was just following the instructions on dev.clojure.org ...

17:22 jtoy: i mean evented programming, sorry

17:22 senthil: yoklov: nice, thx!

17:23 yoklov: kjellski, you should only need clojure-mode

17:23 and then

17:23 jtoy: i want to write a small daemon to do url unrolling, and i want to use one small daemon to do it

17:23 yoklov: clojure-jack-in

17:23 technomancy: kjellski: where are these instructions? they are really out of date

17:23 kjellski: yoklov, I tried that, but somehow emacs doesn't know anything about the jack-in stuff....

17:24 technomancy, http://dev.clojure.org/display/doc/Getting+Started+with+Emacs

17:24 technomancy: kjellski: the version of clojure-mode you have is from 2010

17:24 jtoy: or does clojure have a green threads library?

17:24 kjellski: technomancy, so what would you suggest? try to reinstall it through elpa?

17:24 yoklov: jtoy: you probably want to look into agents

17:24 technomancy: kjellski: no, get rid of elpa entirely

17:24 senthil: "user=> (vector 1 2 3) == [1 2 3]" => "#<core$_EQ__EQ_ clojure.core$_EQ__EQ_@73325573>"

17:25 technomancy: elpa is deprecated; it has an ancient version of clojure-mode

17:25 senthil: i thought "==" would return true/false

17:25 kjellski: technomancy, whohoooo ^^ and how do I get started then?

17:25 technomancy: kjellski: you can get clojure-mode either from git or marmalade

17:25 RickInGA: yoklov I think the example I am using just has too many moving parts. can you point me to an example that draws anything at all onto a canvas. I just want to know how to address it

17:25 yoklov: senthil, you want (== (vector 1 2 3) [1 2 3])

17:25 but

17:25 that will still be wrong

17:25 because == is for numbers

17:25 senthil: yoklov: err, right

17:26 yoklov: ,(= (vector 1 2 3) [1 2 3])

17:26 clojurebot: true

17:26 kjellski: technomancy, thanks!

17:26 technomancy: kjellski: where did you see elpa mentioned?

17:26 yoklov: RickInGA, not really, do you have any experience with javascript?

17:26 technomancy: it shouldn't be in any of the official docs

17:26 senthil: ,(== 1 1)

17:26 clojurebot: true

17:26 jtoy: agents look like its for aysnc state change, can i use it for async io ? ALA node.js ?

17:26 kjellski: technomancy, nowhere… just tried it the "easy way..."

17:26 technomancy: oh, ok; cool

17:27 yoklov: jtoy: i don't know, sorry

17:27 technomancy: I've asked the elpa maintainer many times to put up a deprecation notice; no dice so far =(

17:27 RickInGA: yoklov some, but none with canvas. I am trying to read a book about canvas but executing in cljs.

17:29 are there any guidelines for translating from js to cljs?

17:29 senthil: yoklov: the diff. between = and == being latter only cares if values (not type) are the same?

17:30 yoklov: senthil, == is for numbers

17:30 ,[(= 3 3.0) (== 3 3.0)]

17:30 clojurebot: [false true]

17:30 senthil: yoklov: ah

17:31 mk: == has nothing to do with the java == or the js ===

17:31 autodidakto: mk: what about the ruby <=>

17:31 all your base are belong to the spaceship operator!

17:31 senthil: yoklov: got it, thx again

17:33 mk: autodidakto: that's (compare)

17:33 ,(compare 9 3)

17:33 clojurebot: 1

17:33 jtoy: ,(1)

17:33 clojurebot: #<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn>

17:33 autodidakto: ,1

17:33 clojurebot: 1

17:33 autodidakto: ,'(1)

17:33 clojurebot: (1)

17:33 mk: ,(int 1)

17:33 clojurebot: 1

17:34 RickInGA: yoklov: thanks for the extensive help… I have to go

17:34 autodidakto: jtoy: though shalt quote they list when used as data

17:34 *thy list

17:34 ,(+ 0 #_(+ 1 1))

17:34 clojurebot: 0

17:35 mk: jtoy: 1 is not a function that evaluates to itself

17:35 jtoy: yeah, oops

17:35 autodidakto: ,[1]

17:35 clojurebot: [1]

17:36 autodidakto: mk: common mishap in lisp, and i think it would be even easier to make in clojure because you get use to not having to quote [] and {}

17:36 mk: hmm, vectors complect efficiency/implementation with ... executability

17:38 autodidakto: executability? i thought lists were that

17:38 mk: autodidakto: they are

17:38 autodidakto: then you mean lists, not vectors. correct?

17:38 mk: there is no real issue with treating [1] as if it were (1) (both would be an error)

17:39 autodidakto: no, I guess I mean that they complect efficiency and non-executability

17:39 yoklov: that would suck

17:39 kjellski: technomancy, I'm having a hard time to get this all going… I've already installed Emacs.app because I failed with Aquamacs… is it really that hard all the time? now clojure-mode.el tells me lein is not installed but I can run it in the shell...

17:39 autodidakto: kjellski: got the swank clojure plugin installed?

17:39 mk: yoklov: in what sense? (I probably agree)

17:40 yoklov: if [1] were an error

17:40 and i needed to do '[1]

17:40 kjellski: autodidakto, how? I've already removed all the elpa stuff...

17:40 autodidakto: kjellski: there are two parts. Emacs and Lein. Emacs needs clojure-mode, Lein needs swank plugin

17:41 kjellski: autodidakto, AHA! ^^ now, how do I get the clojure-mode back in action?

17:41 yoklov: kjellski, you want Emacs.app anyway

17:41 jtoy: is there a way to have nested #'s ?

17:42 autodidakto: kjellski: you mean how to you install the package?

17:42 mk: yoklov: right. But when you use [], it's not always clear whether you want an efficient list, or a non-executing list

17:42 aperiodic: jtoy: nested anonymous function literals -- #(...) -- are not allowed

17:42 yoklov: jtoy no. use (fn [arg etc] …)

17:42 bradwright: kjellski: you probably have PATH fail, that happens on OSX

17:42 autodidakto: kjellski: are you familiar with package management? M-x install-package, elpa, etc?

17:42 technomancy: kjellski: that's a common problem with Macs

17:42 kjellski: autodidakto, yes, I'm completely new to emacs...

17:42 technomancy: nothing to do with lein or Clojure specifically; it's just that OS X doesn't propagate your environment variables

17:42 autodidakto: kjellski: technomancy: oh! did you isntall it via homebrew?

17:42 mk: jtoy: you might clean your nested #s up with ->

17:42 bradwright: kjellski: https://gist.github.com/2046593 might help

17:42 autodidakto: lemme pastebin you the code i use..

17:43 jtoy: mk: nice, I should try with -> I've never used that

17:43 kjellski: bradwright, where should this go?

17:43 autodidakto: bradwright: and you call that in your init.el after that defun?

17:43 bradwright: In your Emacs config

17:43 autodidakto: yeah

17:43 clojurebot: I don't understand.

17:43 bradwright: Something like that anyway

17:44 technomancy: neither do I, clojurebot.

17:44 neither do I

17:44 bradwright: I've refined it since - that function is pretty ugly

17:44 yoklov: mk: i'm unsure of what you mean by that

17:44 re: efficient vs non-executing

17:45 autodidakto: yoklov: vectors are more effecient than lists, that's why we use them

17:45 yoklov: it's just a data structure literal. when eval sees a list it evaluates it, when it sees a vector it's a literal

17:45 autodidakto: yoklov: but if we just want efficiency, fine, but why change the function-in-caller spot syntax?

17:45 mk: yoklov: yeah. Technically, you could have 4 things: executable lists, exec vectors, nonexec lists, nonexec vectors

17:46 gfredericks: I'm about to initiate a small library wrapper around aleph for defining http proxies -- am I ooverlooking something that already exists?

17:46 yoklov: what would the benefit of having executable vectors

17:46 autodidakto: kjellski: with that gist, you'd have to past "(set-exec-path-from-shell-PATH)" after it

17:46 kjellski: bradwright, do I need to do a (require path) in my .emacs file or should i paste it directly in there? I've now put it into .emacs.d/path.el

17:46 aperiodic: why would you want executable vectors? vectors and lists are equally good (asymptotically) at iterating; vectors are just better at random access

17:47 bradwright: kjellski: reload that Gist

17:47 aperiodic: when you execute a form, you're not accessing the elements randomly

17:47 kjellski: bradwright, and now?

17:47 bradwright: kjellski: copy the entire thing into your scratch buffer

17:47 kjellski: bradwright, okay

17:47 bradwright: kjellski: then run M-x eval-buffer

17:48 i.e pretty Meta and X, then type "eval-buffer" and hit RETURN

17:48 Press, not pretty

17:48 Ugh, Liox

17:48 mk: yoklov: unsure, it might make certain apply-forms more efficient? (though seqs probably take care of that). The point is that we can use lists to represent execution, or not (by quoting)

17:48 yoklov: mk: it would make use of the literals more of a pain

17:49 for what would be at best a minimal benefit

17:49 kjellski: bradwright, now I've evaded that scratch...

17:49 jtoy: what way do yo guys recommend to see if 2 lists have any of the same elements?

17:49 bradwright: kjellski: your Emacs exec-path should now be the same as your shell path

17:49 kjellski: so leon etc. should work

17:49 Lein

17:49 autodidakto: yoklov: you'd have to quote them everytime, yeah. but it is a ideological compromise, i think

17:49 bradwright: FFS Lion auto correct

17:49 kjellski: bradwright, okay...

17:49 mk: yoklov: yeah. My thought was just that vectors were complected, because they represent both non-executablity and efficiency, two concepts that are fully distinct

17:50 autodidakto: bradwright: setenv persists across reboots?

17:50 mk: jtoy: what do you mean? in your code?

17:50 yoklov: jtoy: i would probably do (empty? (clojure.set/intersection (set list1) (set list2))) or something like that

17:50 bradwright: autodidakto: no, you need to put that in your emacs.d somewhere

17:51 autodidakto: bradwright: plus he needs to call the function in his emacs.d, correct?

17:51 jtoy: yoklov: what if they are large though? it will go through every element

17:51 yoklov: well, intersections gonna need to do that anyway

17:51 bradwright: autodidakto: I updated my Gist to the full snippet required

17:51 Including calling the function

17:51 mk: jtoy: err, make an intersection seq, and then do isempty? I think that might be lazy

17:52 jtoy: yoklov: i wanted to have it stop if there was an intersection

17:52 offby1: jtoy: if they happen to be sorted, you can do better

17:52 bradwright: autodidakto: https://gist.github.com/2046593

17:52 jtoy: i mean on the first match

17:52 but i don't even care about the match

17:52 autodidakto: bradwright: thanks :) sorry to be pedantic about it. i understand your comments, but i have a feeling that kjellski wasn't fully

17:52 understanding

17:52 bradwright: autodidakto: sure, no worries :)

17:53 yoklov: jtoy: (some (set l1) l2)

17:53 ibdknox: jtoy: is there something wrong with the set comparison?

17:54 jtoy: ibdknox: no, i didn't know about it, the 2 lists i compare are always about 150 elements, wasn't sure if its bad to convert them constantly like that

17:54 yoklov: mk: i don't think that vectors represent efficiency.

17:54 ibdknox: 150 elements is tiny ;)

17:54 yoklov: they represent a data structure.

17:54 mk: yoklov: the same data structure as a '(list), just more efficient

17:54 aperiodic: no

17:54 yoklov: they certainly don't represent non-execution. it's lists that represent execution.

17:54 ibdknox: jtoy: in general, it's best to just roll with it. If it ends up being too slow, then try and make it faster

17:55 otherwise you're optimizing for no reason

17:55 yoklov: mk: lists aren't less efficient than vectors.

17:55 they just support different operations.

17:55 ibdknox: mk: huh?

17:55 it's nothing like a list

17:55 aperiodic: mk: vectors have efficient random access. they are way less efficient than lists for things like concatenation/subrange removal

17:55 jtoy: ibdknox: true, i am running this inside hadoop, so is a little hard to optimize

17:56 kjellski: autodidakto, it keeps telling me this: "Could not start swank server: /bin/bash: line 1: lein: command not found\n"

17:56 mk: aperiodic: yes, right. Mostly. Our vectors are implemented with the log32 tries, aren't they?

17:56 yoklov: yeah

17:57 autodidakto: kjellski: you added the code from the (updated) gist and restarted?

17:57 mk: on the other hand, our lists are not implemented in a way that makes getting the last element anything short of O(n) - right?

17:58 yoklov: yeah, but getting the first element is O(1)

17:58 kjellski: autodidakto, yes

17:58 gfredericks: let's invent reverse linked lists!

17:58 ibdknox: gfredericks: it will change *everything*.

17:58 kjellski: autodidakto, I've put the gist into .emacs.d/path.el and have a (require 'path) in my .emacs

17:59 mk: yoklov: which is effectively equivalent to the vector's O(log32n) - I guess that's why I'm thinking of vectors as efficient over lists

18:00 autodidakto: kjellski: M-S-; (getenv "PATH")

18:00 mk: gfredericks: yeah, but the middle elements! what we really need are skiplists. Or like... tries

18:00 gfredericks: hmmmmm

18:00 okay, so decide which middle element you're interested in, and use a regular linked list for the right side and a reverse linked list for the left side!

18:01 mk: actually, why aren't our lists just implemented in the same way as vectors?

18:01 yoklov: mk: at the end of the day the performance of each data structure is an implementation detail

18:01 mk: because its a different API.

18:02 if you want a vector use a vector. if you want a list use a list. you seem to have the idea that lists are inherently worse than vectors, but they address different needs.

18:02 mk: yoklov: how's that? Do you mean conj? Because conj is terrible.

18:02 gfredericks: vectors don't have O(1) add-time

18:02 yoklov: mk: why is conj terrible

18:03 technomancy: clojurebot: recite the litany against cons

18:03 clojurebot: excusez-moi

18:03 technomancy: clojurebot: litany against cons?

18:03 clojurebot: litany against cons is "I must not cons. Cons is the perf-killer. Cons is the little death that brings total obliteration. I will face my cons and permit it to pass over me and through me, and when it has gone past I will turn my GC to see its path. And where it has gone there will be nothing; only I will remain."

18:03 ibdknox: lol

18:03 mk: yoklov: some needs (like access time of O(1) in favor of the equally-fast Olog32n) just don't matter

18:03 yoklov: -_-

18:03 ibdknox: haha

18:05 gfredericks: mk: if we're gonna use all one thing why not something more generic that can add/remove in all positions?

18:05 mk: why is cons evil?

18:05 gfredericks: certainly any advantage of vectors over finger trees are needs that just don't matter

18:05 technomancy: allocation/GC is the most common cause of perf issues

18:06 mk: gfredericks: perhaps I erroneously think that our vectors have fast middle insertion/removal. If not, then let's use finger trees for everything

18:06 technomancy: finger trees are really slow

18:06 mk: nevermind then!

18:06 gfredericks: mk: by insert I mean not update, but actual insert

18:07 mk: gfredericks: right, so do I

18:07 gfredericks: technomancy: you mean in principle or just the particular clojure impls? what makes them inherently slower?

18:07 mk: no inserting/removing in the middle of a vector is O(n) I'm 97% sure

18:07 dnolen: mk: someone needs to implement the datastructure that Phil Bagwell talked about at the Clojure/conj

18:07 technomancy: gfredericks: part of what makes vectors fast is the fact that they can be implemented in terms of arrays

18:08 there are optimizations all the way down the stack to make arrays fast

18:08 gfredericks: I guess that makes sense

18:08 technomancy: but I dunno; I'm just parrotting what I've heard from chouser and rich

18:08 mk: gfredericks: I'm not sure why that would be... I was imagining that the nodes in the tree were ...replicated? from top to bottom on insertion into our vectors (I'm not describing this well)

18:09 dnolen: gfredericks: PersistentVectors work better in terms of modern hardware. Finger Trees only sound good on paper.

18:09 yoklov: what data structure did phil bagwell talk about at clojure/conj?

18:10 dnolen: yoklov: get the slides here, http://github.com/relevance/clojure-conj/tree/master/2011-slides

18:10 gfredericks: mk: it's hard for me to describe simply, but I believe due to the vector impl all efficient operations preserve the position of each element within its length-32 array

18:10 dnolen: yoklov: would be a big deal if someone did them. I wouldn't be surprised if ClojureScript gets fast insertion and concatenation first!

18:10 gfredericks: so deleting in the middle requires shifting every element to the right one position to the left in its array

18:11 mk: gfredericks: I see. I didn't think that was the case, but you may be right

18:11 aperiodic: mk: i think you're making assumptions about the performance characteristics of vectors solely based on the fact that vectors are implemented as tries, which might (IMO, probably) not be true, since vectors only have to support an array-like API. i would urge you to look at the implementation of vectors, and do some performance testing, before declaring arrays the be-all and end-all of data structure performance

18:11 s/arrays/vectors/ in the last sentence there

18:12 gfredericks: mk: as high-level evidence I would point out that I don't believe there are any core functions for doing such things to vectors

18:12 dnolen: aperiodic: vectors in Clojure are implemented as tries.

18:12 yoklov: dnolen: uh, that… file has no extension and isn't text, pdf, gzip, svg, or anything i can determine.

18:12 any clue?

18:12 dnolen: yoklov: pdf likely.

18:13 mk: aperiodic: I'm not saying they are (and true arrays definitely are not). I'm just saying that we can give up some of the minor performance differences (if the differences really are all minor) for conceptual simplicity

18:13 dnolen: yoklov: here's the paper http://infoscience.epfl.ch/record/169879/files/RMTrees.pdf

18:13 yoklov: dnolen: yeah, tried that and the other ones in there

18:13 ah, thanks

18:14 dnolen: mk: "minor performance" difference? what between vectors and lists?

18:14 aperiodic: dnolen: the assumptions of performance characteristics might not be true, not the implementation of vectors. that was ambiguous, oops.

18:15 gfredericks: dnolen: he's suggesting that lists are only slightly better than vectors at anything

18:15 mk: dnolen: I'm thinking of, for example, O(1) on head insertion vs O(log32n) - that sort of difference might not matter

18:15 gfredericks: at least if you ignore the beginning vs end difference

18:16 dnolen: mk: lists and vectors are useful for very different things. happy I can take advantage of that.

18:16 mk: gfredericks: I am not. I'm saying that if they are indeed only slightly better, then we might think of doing away with the two distinct structures

18:16 dnolen: mk: they aren't slightly better. they're insanely great.

18:16 gfredericks: mk: is that not a superset of what I said?

18:17 mk: gfredericks: I state the conditional, you say that I state the antecedent of the conditional

18:17 aperiodic: i can insert an arbitrary amount of things into any point in a list in O(1) time. i will be at your door with pitchforks and torches if that's not the case

18:17 mk: dnolen: what's the best example of that?

18:17 yoklov: mk: lists don't sound like much, but really they hit an algorithmic sweet spot, which is why lisps have gotten on with them for so long

18:17 gfredericks: mk: I'm going to go give the kid a bath; I'll grant you any claim you make about what I just said.

18:18 aperiodic: O(1) is not O(log32 n). please stop trying to handwave away the difference.

18:18 mk: gfredericks: :)

18:18 amalloy: aperiodic: when log32 n is at most 5, it's the same as 1

18:19 mk: aperiodic: not handwaving, just appealing to "programmer time is more important". If I really need that O1, I'd probably just write it in java

18:19 I mean C

18:19 dnolen: mk: to each his own.

18:21 aperiodic: mk: i'm not convinced that taking away vectors saves me time

18:21 ibdknox: quite the opposite

18:21 mk: for the record, I agree that certain implementations of lists are a much better idea for some operations. But if we could implement a structure that is effectively as fast as both linked lists and vectors, we might consider using that

18:21 aperiodic: and i really don't want to write C if i'm concerned about programmer time, that seems totally bacwkards

18:21 ibdknox: having vectors and lists is very useful just from a visual stand point

18:22 mk: aperiodic: I mean the opposite - if you're worried about O(1) on list insertions, you might not care about how much time and complexity it takes to get the efficiency you need

18:22 yoklov: and from a "porting existing lisp code/not horrifying lisp programmers by entirely doing away with lists" point of view

18:23 mk: ibdknox: yeah, I agree with the visual aspect, and the part about lists being executable and vectors not

18:23 ibdknox: that alone makes it worthwhile

18:24 having done numerous user test on code readability

18:24 you can't overestimate the value that has

18:24 lo

18:24 l

18:25 yoklov: haha, yeah, without lists it would be a sea of square brackets, as opposed to a sea of various matched delimeters :p

18:25 mk: ibdknox: yeah, totally agreed - I have nothing against () and [], just the underlying performance (and the behaviour of e.g. conj)

18:25 dnolen: mk: we're patiently waiting for you to implement RBB-Trees for us.

18:25 ibdknox: haha :)

18:25 mk: dnolen: :)

18:25 yoklov: mk: how do you think conj should work?

18:26 mk: yoklov: it shouldn't ;)

18:26 * yoklov likes conj

18:27 aperiodic: mk: sure, if you can hand me a data structure that has O(1) random access and O(1) concatenation, or close enough that I can't construct an example where I can see the difference, I'll take it. w

18:27 mk: ,[(conj [1] 2) (conj '(1) 2)]

18:28 clojurebot: [[1 2] (2 1)]

18:28 yoklov: conj gives you performance guarantees, not order guarantees

18:29 when you don't care about the order of your items, its nice to be able to swap out a [] with a () or a #{}.

18:30 and then if you use conj you know that it will be inserted in the fastest way possible,.

18:31 mk: seems like it'd be a good idea to just implement an efficient bag

18:31 yoklov: thats what sets are.

18:32 jtoy: why does the reply get garbled up sometimes?

18:33 mk: yoklov: sets aren't quite bags - but sure, use sets, avoid conj

18:33 jtoy: i can't use commmandline history

18:33 mk: jtoy: which reply?

18:33 jtoy: repl

18:33 mk: jtoy: which repl?

18:33 jtoy: lein repl

18:33 technomancy: jtoy: lein1 or lein2?

18:33 jtoy: technomancy: I'm on lein1 now

18:34 yoklov: mk: you seem to have a problem with having more than one data structure

18:34 technomancy: oh. hmm... lein1's repl is ... not very good, I guess.

18:34 jtoy: are you using rlwrap?

18:35 jtoy: technomancy: i didn't do anything to add it, so if its not default then no

18:35 technomancy: try installing rlwrap; lein repl will use it if it's installed, and it's way better than the built-in stuff

18:36 jtoy: ok, thx

18:36 mk: yoklov: only when the differences are trivial in nearly all cases

18:37 jtoy: what is the right way to do this? (clojure.set/intersection (set (.split "this is a test" "\\s+")) (set ("this" "you")))

18:37 mk: who was it who was looking for something to assign to some students for a several-day coding exercise?

18:38 yoklov: *shrug* i don't think th edifferences are trivial, but whatever.

18:38 emezeske: jtoy: ("this" "you") is trying to call "this" as a function

18:38 jtoy: emezeske: doh

18:38 mk: yoklov: they aren't - I didn't realize that insertion time was O n

18:38 emezeske: jtoy: You could use a vector, or quote the list

18:39 jtoy: Or even better, use the set literal #{"this" "you"}

18:40 mk: jtoy: have you learned the difference between vectors and lists?

18:40 jtoy: somewhat, the part i get more confused on is with maps and seq and lazy

18:41 mk: jtoy: what do you think the difference is?

18:41 jtoy: the difference is they are all confusing :)

18:42 mk: jtoy: :) lists are for executing, while [] are usually for representing data-stuff

18:42 gfredericks: or bindings

18:42 jtoy: mk: yeah, i got that, I use [] so far for binding and arugments

18:43 mk: jtoy: arguments usually belong in a list

18:43 gfredericks: wut

18:43 (fn [a b c] b)?

18:43 ibdknox: haha

18:43 mk: ,(+ 1 2 3 4 5 6) -- the numbers being arguments

18:43 clojurebot: 21

18:44 gfredericks: clearly we're both wrong

18:44 mk: perhaps

18:44 gfredericks: let's make this an argument

18:44 yoklov: probably he means the arguments list of a function?

18:44 gfredericks: the first of a finger tree of arguments

18:45 mk: yeah I'm attempting to unsuccessfully point out that lists are for functions and their arguments, while vectors are for data-stuff

18:45 gfredericks: and locals

18:45 locals is maybe more accurate than "bindings"

18:45 ibdknox: http://i.imgur.com/04937.png

18:46 mk: arguments and bindings are "data stuff"

18:46 gfredericks: they don't have anything to do with runtime data...

18:46 (fn [a b] [a b]) ;; <-- two totally different uses of vectors

18:46 emezeske: I think the main point to make is that vectors evalutate to themselves, whereas lists evaluate by trying to call their first element as a function

18:46 ,[list 5]

18:46 clojurebot: [#< clojure.lang.PersistentList$1@1ae5cd8> 5]

18:46 emezeske: ,(list 5)

18:46 clojurebot: (5)

18:47 mk: gfredericks: neither gets executed

18:47 gfredericks: they're still distinct things though

18:47 conceptually they're quite different

18:47 yoklov: i agree with emezeske

18:47 gfredericks: the fn macro could just as well be a list

18:47 mk: I agree with emezeske too

18:48 gfredericks: (fn (a b) [a b]) is unambiguous

18:48 it's just not as readable

18:48 it has nothing to do with the list/vector data structures

18:48 I must be trolling if nobody agrees with me

18:48 mk: gfredericks: don't you need to quote that inner list?

18:48 gfredericks: mk: not if the macro supports it

18:49 e.g., the ns macro lets you use unquoted lists almost everywhere

18:49 (ns foo.bar (:require baz)) does not call the :require function

18:49 emezeske: Well, macros are a special case, because macros can do whatever the heck they want with their arguments

18:50 gfredericks: sure but MOST of the vectors you see in source code are there for macros, not because they represent runtime data structures

18:50 mk: ,((fn '(x) x) 1)

18:50 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol>

18:50 gfredericks: let, loop, binding, fn, defn, etc...

18:50 emezeske: gfredericks: That's true, but it's a convention rather than any intrinsic property of vectors vs lists

18:51 gfredericks: emezeske: it is, but it seems silly to ignore when telling a beginner that vectors are used for data-y things

18:52 mk: gfredericks: bindings are data-y things

18:52 you don't execute a binding

18:52 gfredericks: okay; I guess if that makes sense to everyone else that's all that's important

18:56 emezeske: gfredericks: Your points are valid. I don't profess to know how to teach Clojure ^_^

18:58 offby1: "Your points are valid. I wish to subscribe to your newsletter"

18:59 * emezeske thinks maybe he missed an inside joke.

18:59 AimHere: Simpsons reference

19:00 So whether that's 'inside' I don't know

19:00 emezeske: ^_^

19:01 gfredericks: emezeske: clearly the key to learning clojure is whatever I have most recently had an insight about

19:01 offby1: also ancient, also not really that funny (except to me)

19:02 gfredericks: offby1: I for one welcome your new robot overlord references

19:02 emezeske: Hey, I get that one!

19:02 offby1: ayup

19:43 tacoman: what's the best way to restart a running Clojure program I'm testing in SLIME?

19:46 bobzhang: can anyone tell me why nothing happened for this piece of code ?'(.start (Thread. #(/ 3 0)))'

19:48 offby1: I suspect the thread ran, but the repl didn't print the resulting value

19:48 or the exception doesn't get raised in the repl thread

19:48 bobzhang: offby1: you can join the thread, stil nothing happend

19:49 offby1: *shrug*

19:49 just guessing

19:50 emezeske: bobzhang: Futures can be nice for that: ##@(future (/ 3 0))

19:50 lazybot: java.lang.SecurityException: You tripped the alarm! future-call is bad!

19:50 emezeske: bobzhang: When you dereference the future, if there was an exception, it will be thrown

19:51 bobzhang: emezeske: thanks. But why the code above does not propogate the exception?

19:53 emezeske: bobzhang: I don't understand what you mean

19:53 bobzhang: When I paste that in my REPL, I see a divide by zero exception

19:58 bobzhang: emezeske: future works, I mean the original code

20:02 gfredericks: does core.match require clojure 1.3?

20:03 emezeske: bobzhang: Yep, I was referring to the original code. I paste (.start (Thread. #(/ 3 0))) into my REPL, and I see a DBZ exception.

20:04 yoklov: can anybody think of a more elegant way to do this? https://refheap.com/paste/2018 (specifically the (concat (mapcat …) (mapcat …)) part, but the reduction/function in general?

20:05 bobzhang: emezeske: weird. I tested in repl, it raised exception, in slime, not, though

20:11 emezeske: bobzhang: Note that the future way is probably better; the exception gets propagated to the caller instead of just being raised mysteriously in the background

20:12 bobzhang: Which probably has something to do with why slime noticed the future error but not the thread one

20:19 pickles: is there a core or contrib function that will both filter on a predicate and apply a function to the filtered items?

20:19 a sort of filter-map

20:19 google hasn't yielded anything thus far

20:20 technomancy: ,(for [n (range 10) :when (even? n)] (inc n))

20:20 clojurebot: (1 3 5 7 9)

20:20 technomancy: pickles: ^

20:20 pickles: hm

20:21 looks like it should work!

20:21 thanks technomancy

20:21 (nice screenname, btw)

20:22 technomancy: np

20:24 pickles: I seem to overlook for loops in functional languages

20:24 gfredericks: it's more "list comprehensions" than "for loops"

20:24 it is called "for" probably to be confusing

20:24 and "for" is short

20:25 pickles: true

20:33 yoklov: weird.

20:34 i think the google closure compiler just crashed.

20:35 ran out of memory while compiling cljs output. thats… not really the part of the toolchain that i'd expect to crash.

20:37 Frozenlock: How can one change the header in Noir?

20:38 gfredericks: somebody told me that scala lets you flag function arguments so that the forms given become the body of a function -- i.e., the function is passed, letting you delay evaluation

20:38 essentially a special case of what you can do with macros

20:39 most of the macros I write just do that :/

20:45 I wonder if flatland/useful has a def-with-macro macro

20:49 emezeske: yoklov: here's my attempt: https://refheap.com/paste/2019

20:49 yoklov: it doesn't produce vectors, though

20:49 yoklov: hm

20:50 thats interesting

20:50 emezeske: yoklov: I went for pure readability, no idea how efficient it would be

20:52 yoklov: One problem I see is that it passes over the top and bottom vectors twice

21:00 yoklov: hm, yours seems to be faster than mine

21:00 Lajla: yoklov, behold

21:01 emezeske: yoklov: interesting

21:01 Lajla: &(symbol? (symbol "I worship His Shadow"))

21:01 lazybot: ⇒ true

21:01 Lajla: YES

21:01 I broke your stuff

21:02 yoklov: emezeske: yeah, but when i make the vector bigger yours stays around the same but mine actually gets faster, so i don't think i can trust my benchmarks.

21:02 emezeske: yoklov: ^_^

21:03 nodename: I need some help building a library in lein with both Java and clj source. I've tried and tried but when I use this lib from a small clojure program I get a Class Not Found when my clj lib code imports the class

21:03 yoklov: 100ms for 1000x1000, 40ms for 4000x4000. go figure (yours was cleanly under 20ms for both)

21:04 nodename: I may have a classpath issue

21:05 anyone?

21:05 clojurebot: Just 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 ..."

21:05 emezeske: yoklov: heh

21:06 nodename: clojurebot: thanks, I already did that

21:06 clojurebot: Huh?

21:10 emezeske: nodename: If you haven't tried it yet, "lein classpath" will show you were it's looking

21:13 nodename: emezeske: hmmm

21:17 emezeske: lein classpath shows the library jar on the classpath for my app; do the Java classes have to be in any particular package? They're separate from my clj src in the lib...

21:20 gtoast: In the documentation for doall there's a 2 arity version

21:20 Its not really documented. Does anyone know what it does? (doall n coll)

21:20 gfredericks: ,(doc doall)

21:21 clojurebot: "([coll] [n coll]); When lazy sequences are produced via functions that have side effects, any effects other than those needed to produce the first element in the seq do not occur until the seq is consumed. doall can be used to force any effects. Walks through the successive nexts of the seq, retains the head and returns it, thus causing the entire seq to reside in memory at one time."

21:21 emezeske: nodename: You could do something like "jar tf my-library.jar" to see if it contains the files you think it does

21:21 gfredericks: ,(source doall)

21:21 clojurebot: Source not found

21:21 gfredericks: $source doall

21:21 lazybot: doall is http://is.gd/ubI870

21:21 emezeske: nodename: I don't know much about packaging java libraries with lein, so I probably can't help much more than that

21:21 gfredericks: gtoast: my guess is only walks n items

21:22 gtoast: gfredericks: Yea thats what I thought. just wanted to confirm.

21:22 gfredericks: gtoast: glancing at the source confirms it

21:22 Frozenlock: Using Noir, I want to generate a file and let the user download it without writing it on disk. I should probably start with an easier task: How can I let the user downlad a file already on my disk? With my first goal in mind, I suppose I _should not_ use the ring's wrap-file-info. Any suggestions on how to do that?

21:22 brehaut: Frozenlock: the :body of a ring response may be a file

21:23 weavejester: Frozenlock: In the body of your response, return an input stream

21:24 Frozenlock: Thanks! Isn't there a part where I should put the content-type "application/octet-stream", or something like that?

21:24 nodename: emezeske: the .class files are where I expect them to be in the jar. I think I'm going to put the java and clj src in the same tree and see if that helps. Thanks

21:24 weavejester: Frozenlock: "application/octet-stream" is kinda a catch-all content-type. There might be something more specific.

21:25 emezeske: nodename: Good luck!

21:25 weavejester: Frozenlock: You can use the ring.util.response namespace to easily add content types etc. to a response.

21:32 Frozenlock: weavejester: gotcha! I'm looking at your source right now, it might inspire me, especially guess-mime-type ^^

21:42 nodename: Now I have my java-source-path the same as my source-path, and "lein jar" fails with a ZipException duplicate entry of my core.clj. I'm sure I've seen a working example of a lein project with both clj and java somewhere on github... this is very frustrating

21:48 amalloy: nodename: https://github.com/flatland/clojure-protobuf is one such example, if you want to compare/contrast

21:48 nodename: amalloy: thanks!

21:48 amalloy: it currently runs under lein1; it depends on some plugins that don't exist yet on lein2, or something

21:55 xumingmingv: what's the effect when we add a hyphen at the beginning of a function? e.g. defn -test

21:57 gfredericks: xumingmingv: that's the default prefix that gen-class looks for

21:58 also I think has meaning in clojurescript; so depends what you're looking at

21:59 xumingmingv: i mean just clojure

21:59 so def -test means define a instance method named test in the generated class?

22:03 yoklov: anybody know what the following error means: https://refheap.com/paste/2023 (cljs macro weirdness)

22:05 (or just my own noobishness)

22:08 nodename: FYI: My ZipException duplicate entry problem was fixed by Raynes a while ago. I just needed to update lein to 1.7.1

22:10 amalloy: nothing leaps out at me, yoklov. looks correct, and i don't know anything about cljs's special macro environment

22:10 yoklov: it macroexpands right :/

22:10 or at least doesnt mess with the doseq

22:10 cljs needs macros in a separate file

22:10 thats all

22:11 ah

22:11 the compiler needed to be restarted i guess.

22:11 or rather, it ran out of memory shortly after and stopped complaining after i restarted it

22:12 (well, google closure compiler ran out of memory)

22:34 RickInGA: yoklov: thanks again for the help earlier. I managed to reduce the complexity from the example and get something working

22:35 yoklov: oh? thats good, i was going to gist in a few functions i'd been using to manipulate the canvas so you could sort of see how it translated

22:36 RickInGA: the example had a lot going on, it was tough for me to see what was cljs, what was js interop and what was html properties

22:38 it aint fancy, but it does draw a square, which is a great first step! https://refheap.com/paste/2024

22:40 yoklov: oh, you can do (set! context.fillStyle "#ffffaa")

22:40 if you want to, i mean.

22:40 * cduffy tries to figure out what to make of a "java.lang.NoSuchMethodError: clojure.lang.IFn$OOLO.invokePrim(Ljava/lang/Object;Ljava/lang/Object;J)Ljava/lang/String;"

22:42 RickInGA: yoklov: yes, that worked. does that work because it was a set! or can I change the next line too?

22:43 yoklov: hm, try it?

22:43 i actually havent been able to it documented anywhere.

22:43 or at least, not where it works

22:43 RickInGA: yoklov: nope, replacing second line doesnt work

22:43 yoklov: yeah, i think its just in set then.

22:44 which is a bummer

22:45 RickInGA: .fillrect context x y w h somehow looks better anyway

22:45 yoklov: oh, for method calls yeah

22:45 but

22:46 (.-width canvas) would be nice as canvas.width

22:47 RickInGA: and now that it is working, I am going to call it a night.

23:23 wkmanire: Good evening.

Logging service provided by n01se.net