2010-02-01
| 00:14 | abrooks | Next question: I see I can use :as with alias and require but I'd like to rename on an import. Can I do that? |
| 00:18 | kmurph79 | what's the advised way of installing clojure (os x)? i have no intent of using emacs |
| 00:19 | Raynes | :> |
| 00:20 | abrooks | kmurph79: I think this is though I haven't tried it. http://github.com/citizen428/ClojureX |
| 00:22 | kmurph79 | abrooks: thanks, ill give that a shot |
| 00:22 | abrooks | I suspect there's a prebuilt one here but the site is tooo slooooo and I'm not going to wait for it: http://citizen428.net/archives/390-Easy-setup-for-Clojure-on-Mac-OS-X-Leopard.html |
| 00:22 | abrooks | That's linked off of the github project page for ClojureX at the top. |
| 00:30 | konr | Isn't it cool? http://55chan.org/prog/src/126500183321.jpg |
| 00:48 | DeusExPikachu | what is the difference between (load-file "pathname") and (load ["pathname"])? |
| 01:01 | Raynes | (doc load) |
| 01:01 | clojurebot | "([& paths]); Loads Clojure code from resources in classpath. A path is interpreted as classpath-relative if it begins with a slash or relative to the root directory for the current namespace otherwise." |
| 01:01 | Raynes | (doc load-file) |
| 01:01 | clojurebot | "([name]); Sequentially read and evaluate the set of forms contained in the file." |
| 02:57 | Raynes | "procedural programming is also known as "Functional Programming."" |
| 02:58 | Raynes | The guy who wrote that then proceeded to argue about how similar the paradigms are. I assume he actually had no clue what functional programming is. |
| 02:59 | tomoj | heh |
| 02:59 | tomoj | I see you left a comment |
| 03:00 | tomoj | I could see how he could be correct, maybe |
| 03:01 | tomoj | as in, saying "X is also know as 'Y'" isn't the same as saying "X and Y are the same" |
| 03:02 | tomoj | since one thing might be known by a name which typically refers to something else |
| 03:02 | tomoj | but I don't think that's what he was going for |
| 03:09 | Raynes | tomoj: I know the guy. |
| 03:09 | Raynes | tomoj: You must be a l33t google searcher, by the way. |
| 03:12 | Raynes | tomoj: Scratch that. It's the first (and near only) result. |
| 03:33 | tomoj | yup :) |
| 03:34 | tomoj | only result I found for "procedural programming is also known as" |
| 04:43 | LauJensen | I just got K-Lined? |
| 04:43 | eevar2 | that or you got creative with your quit message ;) |
| 04:44 | LauJensen | == You are banned from this server- Temporary K-line 1440 min. - Joining #pines (2010/2/1 09.37) |
| 04:47 | cypher23 | LauJensen, ask in #freenode? |
| 04:49 | LauJensen | What good would that do ? |
| 04:53 | cypher23 | so the staff can tell you why you got klined? |
| 04:55 | LauJensen | But according to this webinterface, #freenode looks quite empty |
| 04:57 | cypher23 | LauJensen, 563 nicks when I join it |
| 04:57 | LauJensen | Ok - Might be webchat.freenode.net thats messing with me |
| 04:57 | cypher23 | maybe |
| 04:57 | cypher23 | I'm using irssi |
| 04:58 | hiredman | could be the webchat all got klined |
| 04:59 | hiredman | clojurebot: the most horrible thing? |
| 04:59 | clojurebot | I don't understand. |
| 04:59 | hiredman | clojurebot: the most terrible thing? |
| 04:59 | clojurebot | Huh? |
| 04:59 | hiredman | gah |
| 05:03 | fnuction | Hello |
| 05:04 | fnuction | Anyone able to help with failing clojure-test-mode installs? |
| 05:05 | esj | nope, tried it myself over the w/e and failed |
| 05:06 | fnuction | Well, means I'm not alone which helps my self esteem I guess. |
| 05:15 | zaphyr | How do I coax clojure into creating a class vec3f with float fields x, y, z? |
| 05:16 | zaphyr | must i use :gen-class? |
| 05:18 | Chousuke | on 1.1.0, yes |
| 05:18 | zaphyr | ah, okay. thanks |
| 05:18 | Chousuke | on 1.2.0-master you could use deftype. |
| 05:18 | zaphyr | goodie :) |
| 05:18 | hoeck | zaphyr: with the newest clojure build you can use (deftype vec3f [#^float x, #^float y, #^float z]) |
| 05:19 | zaphyr | that's much nicer. i've only just started and spent ages seeing if i could somehow type defstruct for similar behaviour |
| 05:21 | hoeck | zaphyr: deftype creates a class with public final fields under the hood, so it is way more efficient than defstruct |
| 05:21 | Chousuke | before deftype the most idiomatic form of a three-float vector was [1.0 2.0 3.0] :P |
| 05:21 | hoeck | and prettier than gen-class :) |
| 05:21 | Chousuke | but that doesn't support primitives |
| 05:21 | Chousuke | which I suppose is one of the reasons behind creating deftype |
| 05:22 | zaphyr | hehehe, yeah. plus i'm porting from java, and already ran benchmarks on different representations, public field access is considerably faster than array references, which is why I have to take this route. |
| 05:22 | Chousuke | but hm, doesn't java already have a vector3d class somewhere? |
| 05:23 | hoeck | I have a small spacewar like game with clojure+jbox2d+processing laying around here, as soon as I have some time for it, I will port it to use deftyped vectors |
| 05:24 | zaphyr | Chousuke: I think Java3D might have, but i rolled my own library for jogl a few years back, and now want to do it over in clojure to see if I can implement it in a nice language |
| 05:24 | Chousuke | http://java.sun.com/javase/technologies/desktop/java3d/forDevelopers/J3D_1_3_API/j3dapi/javax/vecmath/Vector3d.html indeed |
| 05:24 | Chousuke | it's mutable though :-( |
| 05:24 | zaphyr | boo! |
| 05:26 | zaphyr | on an unrelated note- bizarrely creating a GLCanvas within the SLIME repl seems to cause the AWT to hang when it draws |
| 05:26 | zaphyr | that is- prior to registering anything such as a GLEventListener on it |
| 05:27 | Chousuke | you probably need to tell awt to do drawing in some special thread |
| 05:28 | zaphyr | I thought it was happening on the EDT? maybe not. I'll fight that battle another day |
| 09:02 | avarus | hi! |
| 09:03 | ohpauleez | hi avarus |
| 09:04 | avarus | I just tried the clojure-json lib from danlarkin |
| 09:04 | avarus | hi ohpauleez :) |
| 09:04 | avarus | it seems to work but I have no idea how to get the values :) |
| 09:04 | avarus | the decoder returns something like this: {:domainrequest {:targetemail foo@bar.com}, :email {:pass myscrecretpass, :user websend@foobar.com}, :database {:name domains, :pass mysecretpass, :user postgres, :host 127.0.0.1}} |
| 09:04 | avarus | so how can I get the value of :host e.g.? :) |
| 09:05 | chouser | avarus: (-> rtn :database :host) |
| 09:05 | Raynes | Hey... I bet I could clean up my code using that pattern. |
| 09:06 | Raynes | Yep. I totally can. |
| 09:07 | avarus | chouser: thanks. what's rtn in this context? :) |
| 09:07 | chouser | :-) ...the thing that the decoder returns |
| 09:08 | Raynes | I'm guessing the map. |
| 09:08 | avarus | ah lol :) |
| 09:08 | avarus | thanks :) |
| 09:08 | Raynes | He telepathically says "You're welcome." |
| 09:13 | avarus | indeed, that works :) |
| 09:14 | avarus | it looked similar before but I didn't have that -> |
| 09:14 | avarus | I also had a variant where :database and :host were in front of the json/decode-from-str function |
| 09:14 | Raynes | It could have been done like so: (:host (:database rtn)) |
| 09:14 | Raynes | But -> makes it prettier. |
| 09:15 | avarus | oh, that makes even sense to me |
| 09:16 | Raynes | chouser: I'm buying your book today. :> |
| 09:16 | avarus | me, too :> |
| 09:16 | avarus | 40% discount is too good to be true though :P |
| 09:16 | Raynes | hi5 |
| 09:17 | Raynes | Indeed. |
| 09:19 | avarus | ah I do it now before I get lazy and fall asleep |
| 09:20 | avarus | so if I got it right I get the full ebook/book when it's done? :) |
| 09:21 | rsynnott | is this the pragmatic programmers book? |
| 09:21 | avarus | no |
| 09:21 | avarus | http://joyofclojure.com/ |
| 09:22 | avarus | perhaps will be finished in fall 2010 if I read it right |
| 09:22 | rsynnott | ah :) |
| 09:22 | avarus | the programming clojure book from pragmatic* is already available |
| 09:22 | rsynnott | the front cover is deranged... |
| 09:22 | rsynnott | avarus: yep, I've got it |
| 09:23 | rsynnott | was wondering was there another one |
| 09:23 | avarus | yes, me, too :) |
| 09:23 | Chousuke | I already bought that but the discount was mostly obliterated by shipping costs ;P |
| 09:23 | tomoj | yeah, what the heck is that on the cover? |
| 09:24 | avarus | the book is ok...sometimes it makes me think "what?!" .. I think it's because I never did any lisp programming at all |
| 09:25 | avarus | yes, it's a good idea |
| 09:29 | esj | is there a magic incantation to make jline work under swank- |
| 09:29 | esj | the default repl is 'orrrrrrible. |
| 09:31 | avarus | chouser: just curious. what if there is an update to the ebook; do I get an email to download the newer pdf? :) |
| 09:35 | avarus | lol, the pdf says licensed to andreas schipplock (my name actually :P) |
| 09:35 | Raynes | avarus: Do you know what sucks? |
| 09:36 | avarus | no |
| 09:36 | avarus | what? |
| 09:36 | clojurebot | what is wrong with you |
| 09:36 | Raynes | When I bought Programming Clojure, I signed up on pragprog and accidentally used an incorrect name. Now I have to stare at that fail everytime I read that book. :| |
| 09:36 | avarus | hehe |
| 09:37 | Raynes | clojurebot: Be quiet. |
| 09:37 | clojurebot | Gabh mo leithscéal? |
| 09:37 | Raynes | That's what she said. |
| 10:04 | chouser | avarus: I'm not sure, actually. I think you get email, but we'll tweet and/or blog about updates as well. |
| 10:07 | _fogus_ | avarus: I believe you will receive update emails directly from Manning when they are available |
| 10:11 | avarus | k, thx |
| 10:29 | avarus | bye:) |
| 11:24 | freddy_d | clojure + compojure + enlive = excellent |
| 11:24 | freddy_d | what are people using for database access? clojure.contrib.sql or something else? |
| 11:25 | esj | clojureQL and congomongo here, |
| 11:30 | freddy_d | esj: never heard of MongoDB, looks interesting |
| 11:30 | esj | yeah, I'm still in the initial explorations too |
| 11:31 | freddy_d | what is your back-end db? |
| 11:31 | esj | mysql, not exciting |
| 11:31 | freddy_d | that's fine :) |
| 11:31 | freddy_d | everything is key-value in my app, so MongoDB looks like it'll fit right in |
| 11:33 | fholm | MongoDB <3 |
| 11:36 | esj | its be much faster if you do |
| 11:36 | esj | ok, i say that, i think it should be much faster.... |
| 11:39 | freddy_d | thing is, i already have ddl and sql queries, so i'm just running them through clojure.contrib.sql, not sure value of adding more layers |
| 11:39 | freddy_d | maybe for another project that i start from scratch, will be easier to get started |
| 11:41 | esj | yeah, for sure. |
| 11:54 | cemerick | freddy_d: cluch, given a couchdb backend |
| 13:20 | stuartsierra | Just pushed the Big Contrib Lib Rename. |
| 13:21 | freddy_d | ? |
| 13:21 | stuartsierra | see my announcement on the list |
| 13:21 | freddy_d | ok |
| 13:22 | freddy_d | aw, no more ducks? |
| 13:26 | stuartsierra | no more ducks |
| 13:26 | stuartsierra | it was a silly name; I never would have chosen it if I though it would get used so much |
| 13:26 | freddy_d | :) |
| 13:27 | freddy_d | stuartsierra: thank you (and rhickey et. al.) for Clojure and libraries |
| 13:27 | stuartsierra | you're welcome |
| 13:28 | freddy_d | I haven't been this excited about a new language since 1996 |
| 13:28 | stuartsierra | me neither, give or take a few years |
| 13:28 | freddy_d | I've always loved FP but Haskell, Scala just don't do it for me |
| 13:34 | freddy_d | there's something about the rhythm of Clojure.... when I write code, it's almost like a melodious drum beat |
| 13:47 | qed | melodious drum beats! |
| 13:51 | jcromartie | melodious drum beats? |
| 13:51 | jcromartie | it's starting to sound like a Rails dev channel in here |
| 13:51 | qed | heh jcromartie: 12:34:19 < freddy_d> there's something about the rhythm of Clojure.... when I write code, it's almost like a melodious drum beat |
| 13:51 | jcromartie | yeah |
| 13:56 | qed | jcromartie: i just thought that was funny -- im not making fun or anything, i just thought that particular way of phrasing it was, well, you know, sort of funny |
| 13:56 | jcromartie | yes I know :) |
| 13:57 | qed | "the heavens split apart before my very eyes upon the writing of mine first function! melodious drum beats filled the air as angels rocked me gently to sleep in a carriage made of gold as I ascended toward the heavens." |
| 13:58 | qed | (okay, now i'm making fun) |
| 14:05 | stuartsierra | This calls for http://xkcd.com/224/ |
| 14:06 | qed | stuartsierra: hahahahaha |
| 14:13 | technomancy | stuartsierra: For my clojure.io proposal I also moved a few things from java-utils as well... file, delete-file, and delete-file-recursively |
| 14:13 | technomancy | dunno if you want to make clojure.contrib.io match that or not, but just thought I'd mention it |
| 14:17 | stuartsierra | technomancy: yes, I like the idea |
| 14:17 | stuartsierra | Can't decide if I like having file-related stuff in c.c..io or creating a new c.c.file |
| 14:20 | technomancy | a file-related namespace might be a little bare |
| 14:22 | stuartsierra | true |
| 14:22 | stuartsierra | Actually, it'd be nice if we could drop c.c.java altogether, since the name isn't exactly informative. |
| 14:23 | stuartsierra | Move the file stuff to c.c.io, the string-related stuff to c.c.string. What else is there? |
| 14:23 | technomancy | yeah, I only use it for file and delete-file, and occasionally as-str |
| 14:23 | technomancy | clojure.io will probably land in clojure.lib soon, so it probably doesn't matter a great deal what contrib does |
| 14:23 | stuartsierra | ok |
| 14:24 | technomancy | c.c.java also has properties-related stuff, but that's easy to do in straight java too |
| 14:24 | technomancy | *straight java interop |
| 14:24 | stuartsierra | My intent with my recent work on contrib was to clean it up for clojure.lib. |
| 14:24 | technomancy | gotcha |
| 14:25 | stuartsierra | So if you have a patch for moving file stuff to .io, go for it. |
| 14:26 | stuartsierra | back in a bit |
| 14:49 | technomancy | src/main/clojure/clojure/contrib/io.clj <= eww; that is a mouthful |
| 14:51 | hiredman | verging on java levels of directory nesting |
| 14:51 | technomancy | hiredman: it's great if you're paid by the directory. for open source though... not so much. |
| 14:52 | cemerick | what would the alternative be? |
| 14:52 | technomancy | cemerick: the way it used to be was much nicer. |
| 14:52 | technomancy | with the one change of moving the tests to a top-level test/ directory. |
| 14:53 | cemerick | isn't that only a diff of 2 directory segments? |
| 14:54 | stuartsierra | directories are not a crime |
| 14:54 | technomancy | it's just more busy work |
| 14:54 | cemerick | where's the work, though? |
| 14:54 | technomancy | anyway, you can ignore me; I'm not hacking on contrib these days |
| 14:55 | stuartsierra | It's a small price to pay for a simpler build process. |
| 14:55 | technomancy | stuartsierra: it's like three lines to use src/ in the maven build; clojure-pom works that way |
| 14:56 | technomancy | but go with whatever works for you |
| 14:58 | technomancy | sorry, shouldn't be so negative. it's certainly better than the old build.xml; thanks for cleaning it up. |
| 14:59 | stuartsierra | I kind of want to encourage following the Maven defaults. I know it could be fewer dirs, but then there's more non-standard configuration. |
| 15:00 | cemerick | it's an absolute no-brainer IMO |
| 15:00 | cemerick | that much less cognitive overhead for newcomers |
| 15:01 | technomancy | stuartsierra: in that case, it must come to a duel |
| 15:02 | technomancy | if you're encouraging that kind of stuff outside contrib, that is |
| 15:02 | technomancy | =) |
| 15:03 | cemerick | technomancy: where do you stand vis á vis clojure polyglot maven? |
| 15:03 | stuartsierra | technomancy: I used to be a rated competitive fencer. :) |
| 15:03 | technomancy | cemerick: I think it's a terrible idea to develop something like that in secret. |
| 15:03 | technomancy | because of that I haven't been following it much |
| 15:03 | cemerick | secret? |
| 15:05 | technomancy | cemerick: maybe it's opened up more recently, but as of a while ago the repositories for maven 3 weren't public |
| 15:05 | cemerick | ah |
| 15:05 | technomancy | there's so much wrong with that... I don't even know where to start |
| 15:06 | cemerick | it's a software business, so I can't fault them for doing what they need to |
| 15:06 | stuartsierra | They've got alpha snapshots up: http://maven.apache.org/download.html |
| 15:06 | technomancy | that's an improvement |
| 15:06 | stuartsierra | and public SVN: http://maven.apache.org/source-repository.html |
| 15:08 | technomancy | the fact that they'd ever consider it reasonable to have it closed in the first place makes me want to avoid the whole scene |
| 15:08 | technomancy | though I am glad they've opened up |
| 15:10 | cemerick | They'd never actually close it up, maven's ubiquity is what drives interest in their tools/servers. |
| 15:12 | technomancy | they'd never close up an actual release, but the fact that the public wasn't involved in the early transition from 2 to 3 signals something's very wrong with the community |
| 15:13 | stuartsierra | Doesn't Apache own Maven now anyway? |
| 15:14 | cemerick | it's certainly an apache project. Sonatype could take their newest toys home with them if they so chose, though. |
| 15:16 | AWizzArd | btw, does Leiningen also use Maven? |
| 15:16 | technomancy | AWizzArd: it uses maven-ant-tasks, which provides access to Maven's dependency management (the good part) via the ant API |
| 15:17 | technomancy | which means you can use it without a dependency injection (!) framework |
| 15:17 | AWizzArd | technomancy: from Maven I saw so far that it tries to download stuff from the internet when one uses it. |
| 15:17 | AWizzArd | Is this also true for Leiningen, or would it work also behind a firewall, for corporate users? |
| 15:18 | AWizzArd | (who don't have access to the net) |
| 15:18 | technomancy | AWizzArd: you can configure both Leiningen and Maven to pull from private repositories |
| 15:18 | AWizzArd | What would it like to pull? |
| 15:18 | technomancy | but if you don't have access to the Internet, your build system is the least of your worries |
| 15:18 | AWizzArd | No :) |
| 15:18 | stuartsierra | AWizzArd: does this help: http://www.aviransplace.com/2006/08/20/tip-installing-maven-2-behind-a-proxy/ |
| 15:19 | AWizzArd | I don't understand why a build system would need to have access to the net, if the dependencies are already present on the local disk. |
| 15:19 | technomancy | AWizzArd: oh, if you've got the deps on disk it doesn't |
| 15:19 | AWizzArd | ok, sounds good then |
| 15:19 | technomancy | AWizzArd: maven will still try to connect to the Internet every time you do something if you have a "-SNAPSHOT" version in your deps |
| 15:19 | chouser | but they aren't. when you install maven, you apparently only get a maven stub. each time I try a new command it fetch a half-dozen jars |
| 15:19 | technomancy | but Leiningen will only do it when you explicitly ask for it |
| 15:19 | stuartsierra | Unless you add the "-o" option |
| 15:20 | technomancy | right |
| 15:20 | AWizzArd | o an in 'omit'? |
| 15:20 | stuartsierra | short for --offline |
| 15:20 | AWizzArd | good |
| 15:21 | cemerick | chouser: maven is really only a stub -- everything it does is implemented as plugins, which are pulled on demand |
| 15:21 | cemerick | e.g. if there's a 3rd-party plugin that has a goal you want to run, you can invoke it, and maven will go find the necessary artifact without any pom config, etc. |
| 15:22 | chouser | it feels much more like a distro tool than a build tool to me. |
| 15:22 | AWizzArd | In principle it's okay, our harddisks are big enough, we have enough ram and most users do have an internet connection. But still, seeing that Maven eats so very many resources sounds strange when I just want to compile a project and get a .jar file :) |
| 15:22 | AWizzArd | chouser: a resource hungry distro ;) |
| 15:22 | cemerick | chouser: yup, build + release + project mgmt/description + .... |
| 15:22 | stuartsierra | Maven's really aiming at larger projects with 100s of dependencies. |
| 15:23 | AWizzArd | I am sure it is useful and it went through some years of development. |
| 15:23 | stuartsierra | But putting contrib in a Maven build will make it easier (hopefully) for people with those kinds of large projects to use it. |
| 15:23 | AWizzArd | I am just not used to the idea of needing 100 MB for such a build tool. |
| 15:24 | stuartsierra | Think of autoconf/automake. |
| 15:24 | cemerick | stuartsierra: now that I'm well past my former experiences/prejudices, I think using it if you have zero dependencies is worthwhile. The dependency mgmt is useful, but hardly the majority of its appeal, IMO. |
| 15:25 | stuartsierra | cemerick: yes, once you get over the lack of control, it's valuable to be forced into certain conventions |
| 15:25 | AWizzArd | managing complex software is a complex task itself, and I guess the maven devs did not write all that code to eat specifically my resources. It's just the psychological effect I think. |
| 15:25 | chouser | ah, yes. once you learn to live without liberty, there are benefits to a communist state. ;-) |
| 15:25 | cemerick | stuartsierra: aside from that, there's piles of plugins that are immensely useful and make all sorts of build processes trivial to use. |
| 15:26 | cemerick | And the release automation has been a godsend for us. |
| 15:27 | AWizzArd | technomancy: i have a big code base, all rooted in a src/ folder. In that I find several components that can be combined with each other. What I would like to know is if I can use Leiningen to define several combinations of components out of which it can produce one .jar file. |
| 15:27 | stuartsierra | yeah, that's the biggest reason I wanted to switch contrib. Doing the releases with Ant was a pain. |
| 15:28 | AWizzArd | technomancy: lein jar Project1 ==> compiles and jars the right files |
| 15:28 | AWizzArd | lein jar all ==> compiles all sources, something like that I mean |
| 15:32 | stuartsierra | AWizzArd: in the Maven model that would be accomplished with sub-modules. |
| 15:32 | AWizzArd | I see. |
| 15:33 | AWizzArd | We just did not want to have 18 different repositories from which we have to pull. So most code sits in one repo. With a bigger portion of reusable code and some projects that are using that + specific code. |
| 15:35 | stuartsierra | In Maven, that would be one "parent" project with dirs like ./modules/foo. Still one source code repository. |
| 15:36 | stuartsierra | Look at the examples from the Sonatype guys - they're big on this. |
| 15:36 | AWizzArd | yes, such a thing would be interesting |
| 15:36 | AWizzArd | This could be emulated with lein maybe by having a shell script that manages several project.clj files and renames them ;) |
| 16:21 | technomancy | AWizzArd: flightcaster added multiple module support for leiningen, but I haven't had a chance to review it yet |
| 16:21 | technomancy | check the mailing list |
| 16:22 | technomancy | AWizzArd: what I've done in the past with Ruby is just treat independent subcomponents as independent projects, and that works really well too. |
| 16:47 | cschep | I have a file named foo.clj if I run a repl from the directory that it is in, should I be able to do (use 'foo) and run the function defined in the file? Or does it have to be on the class path? My java understanding is lacking here I think.. |
| 16:49 | reify | OH at lunch today: clojure sucks because it doesn't support OOP and defaults to immutable data structures |
| 16:49 | the-kenny | lol |
| 16:50 | reify | i was thankful they didn't mention the JVM :) |
| 16:50 | technomancy | programmaring is hard |
| 16:55 | cschep | Hey guys, I'm trying to write a clj script so that I can say something like "clj foo.clj" and end up at a repl with foo.clj already ran/imported into the environment...the wiki's example seems outdated..does anyone have something like this setup? |
| 16:58 | dnolen | cschep: this doesn't work for you? http://clojure.org/repl_and_main |
| 17:04 | cschep | dnolen: ack, sorry, I went straight to the wiki which looks a little different, that is definitely right. thank you. |
| 17:05 | dnolen | cschep: np |
| 17:06 | hiredman | the wiki is old, and whoever started it seems to have moved on to other things |
| 17:08 | cschep | hiredman: ah, that makes sense. |
| 18:01 | AWizzArd | What is fsync(2) or fsync(3) in Java? |
| 18:01 | hiredman | a jni call |
| 18:03 | AWizzArd | hiredman: just calling .flush on my output stream won’t make sure that the writing action will block until the disk reports that my data was saved? |
| 18:04 | hiredman | AWizzArd: I would not rely on it |
| 18:07 | AWizzArd | hiredman: Do you think http://java.sun.com/javase/6/docs/api/java/nio/channels/FileChannel.html#force%28boolean%29 is the right thing? Or also not trustworthy? |
| 18:12 | hiredman | I just asked in ##java |
| 18:12 | hiredman | no replies yet, but nio seems like a more promising place to get that kind of thing |
| 18:12 | AWizzArd | hiredman: thank you! |
| 18:13 | hiredman | oh |
| 18:13 | hiredman | ~jdoc java.io.FileDescriptor |
| 18:13 | hiredman | has a sync method |
| 18:15 | AWizzArd | okay, that looks also good |
| 18:16 | arohner_ | AWizzArd: even if java promises that it has called write() and sync(), your OS and raid controller can still lie to you |
| 18:17 | AWizzArd | arohner: could this also happen to the Oracle DB? |
| 18:17 | AWizzArd | Or do they use other tricks to be sure that their transactional data indeed was written? |
| 18:18 | AWizzArd | or take a DB written in Java (i think one such db ships with the jdk) |
| 18:18 | hiredman | derby |
| 18:18 | arohner | they *might* use tricks to say "I know that on linux versions x.y.z and above, calling sync();sync(); will really flush to disk" |
| 18:18 | arohner | of course, your raid controller can still lie |
| 18:18 | AWizzArd | hmm ok |
| 18:19 | AWizzArd | interesting problem will be how/when to write transactional data to disk. In principle it should happen during a dosync |
| 18:19 | hiredman | which is what you want to be able to plugin into the stm for |
| 18:20 | AWizzArd | first making a change to a snapshot in memory, then writing out to disk that the modification happened and then ref-setting everything |
| 18:21 | AWizzArd | hiredman: is there already such a mechanism in place in Clojure? |
| 18:22 | AWizzArd | One other potential problem could be if many threads try to insert data, then maybe none of them could ever finish because they all compete with each other and no thread can win (because this syncing to disk just takes so long). |
| 18:22 | hiredman | AWizzArd: nope |
| 18:23 | arohner | is there a cleaner way to make a map from a for loop than (into {} (for []...))? |
| 18:26 | Kruppe | Clojure noob here, if i want some kind of global state variable should I be doing something like this: (def count 0) (defn update [] (def count (+ count 1))) or should I be doing something else? I'm looking for something analogous to defvar in cl. |
| 18:26 | arohner | Kruppe: typically refs are used for that |
| 18:26 | arohner | ,(doc ref) |
| 18:26 | clojurebot | "([x] [x & options]); Creates and returns a Ref with an initial value of x and zero or more options (in any order): :meta metadata-map :validator validate-fn :min-history (default 0) :max-history (default 10) If metadata-map is supplied, it will be come the metadata on the ref. validate-fn must be nil or a side-effect-free fn of one argument, which will be passed the intended new state on any state change. If the new state |
| 18:26 | Kruppe | arohner: ah ok, ill look into that |
| 18:27 | arohner | (def count (ref 0)) |
| 18:27 | AWizzArd | arohner: this into is good. You only may consider reduce for some cases, maybe. |
| 18:29 | hiredman | Kruppe: don't re-def |
| 18:29 | Kruppe | hiredman: yeah I noticed clojure.core/count |
| 18:30 | Kruppe | hiredman: thanks for the warning though :) |
| 18:30 | AWizzArd | maybe hiredman meant that you said (def count 0) ... a bit later ... (def count something-else) |
| 18:31 | Kruppe | AWizzArd: ah, I actually couldn't find any other way to update the def |
| 18:31 | Kruppe | AWizzArd: what SHOULD be there instead? |
| 18:32 | Kruppe | AWizzArd: or should I just not use it like that? |
| 18:32 | AWizzArd | you can use atoms for counter |
| 18:33 | AWizzArd | ,(let [my-counter (atom 100)] (println @my-counter) (swap! my-counter inc) (println @my-counter)) |
| 18:33 | clojurebot | 100 101 |
| 18:33 | AWizzArd | the “swap!” is the function which will update the contents of your counter |
| 18:34 | arohner | Kruppe: if you use a ref, you change it using dosync, alter, commute, ref-set. If you use an atom, you change it using swap! |
| 18:34 | arohner | Kruppe: one thing that helped me when learning clojure: coming from CL, you're familiar with boxes pointing to values |
| 18:34 | Kruppe | arohner: yup |
| 18:35 | AWizzArd | Kruppe: note that using Refs and Atoms are concurrency-ready. |
| 18:35 | arohner | in Clojure, def creates a box, called a var. refs and atoms are additional kinds of boxes |
| 18:35 | arohner | vars, refs, and atoms each have different concurrency semantics |
| 18:36 | arohner | if you want a global value to something that can change, typically you use a var pointing at an atom or ref |
| 18:37 | arohner | a var has a root value, that all threads see by default. You can also set a thread local value on the var, using binding |
| 18:37 | arohner | it's possible to re-set the root value (i.e. by re-defing), but this is considered bad style |
| 18:37 | Kruppe | arohner: yeah it seemed clumsy |
| 18:38 | Kruppe | arohner: I knew there had to be another way |
| 18:46 | Kruppe | arohner: AWizzArd: thanks for clearing that up, I think I get it now! |
| 18:47 | AWizzArd | enjoy |
| 18:47 | maxhodak | i keep getting a java.lang.ClassNotFoundException trying to access a java class and have just hit a wall |
| 18:48 | maxhodak | i'm trying to use the thrift (incubator.apache.org/thrift) java libs and it's generating a series of classes |
| 18:48 | maxhodak | and clojure can't seem to find one of the nested classes |
| 18:48 | AWizzArd | maxhodak: (System/getProperty "java.class.path") |
| 18:48 | hiredman | maxhodak: you have to use the desugared name |
| 18:48 | hiredman | with $ |
| 18:49 | maxhodak | hmm |
| 18:49 | maxhodak | so it can find the class file; it's on the classpath. i'm using lein and that's all fine |
| 18:49 | maxhodak | like, i have class foo { class bar { } } |
| 18:49 | maxhodak | and i can basically see foo , but not foo.bar |
| 18:49 | hiredman | some.package.someClass$innerClass |
| 18:50 | maxhodak | hiredman: sugared name? |
| 18:50 | maxhodak | oh |
| 18:51 | maxhodak | hiredman: that didn't fix it, either quoted or unquoted |
| 18:52 | hiredman | not quote |
| 18:52 | hiredman | some.package.someClass$innerClass instead of some.package.someClass.innerClass |
| 18:53 | maxhodak | nope |
| 18:53 | hiredman | are you sure? |
| 18:54 | maxhodak | my path basically looks like |
| 18:54 | maxhodak | /src/clj/file.clj, /src/java/foo/bar.java |
| 18:54 | maxhodak | inside file.clj i'm trying (new myproject.foo.bar$quuz) |
| 18:55 | maxhodak | (er, add a myproject into those paths as appropriate) |
| 18:55 | maxhodak | and i'm getting either unable to resolve class name or class not found |
| 18:56 | hiredman | how are you starting the repl |
| 18:56 | maxhodak | i'm getting the error on lein compile; i dont have a repl up |
| 18:58 | hiredman | where are the class files? |
| 18:59 | maxhodak | src/java/myproject/foo/* |
| 18:59 | hiredman | maxhodak: uh, and how do you know that is on the class path |
| 19:00 | maxhodak | because :import (myproject.foo) doesn't generate an error |
| 19:01 | hiredman | maxhodak: it wouldn't, you are telling it to import nothing from a nonexistant package |
| 19:01 | hiredman | (:import (myproject foo)) is what you want |
| 19:03 | maxhodak | is (:import (myproject.foo *)) valid in clojure? |
| 19:03 | hiredman | nope |
| 19:03 | maxhodak | hmm ok |
| 19:05 | hiredman | I think you will find your classes are not on your classpath |
| 19:05 | maxhodak | yeah, now it's dying on the import |
| 19:05 | maxhodak | readreadread lein doc |
| 19:05 | maxhodak | thaanks |
| 19:06 | hiredman | I would recommend, if this is your first project, to skip lein |
| 19:06 | maxhodak | it's not my first in clojure, just the first trying to get it to play along really nicely with java |
| 19:07 | maxhodak | and lein is *amazing* with dependencies |
| 19:08 | hiredman | ok |
| 19:08 | cschep | is there a "best place" to get SLIME on github? |
| 19:09 | Chousuke | cschep: I think you should install slime using ELPA to ensure it works with clojure-mode |
| 19:09 | Chousuke | cschep: There's some incompatibility issue with the latest CVS/git/whatever versions :/ |
| 19:09 | dnolen | cschep: I would get it from ELPA, but if you want to interoperate with other Lisps (SBCL, CMUCL, ClozureCL, MzScheme, etc) you should get technomancy's fork on github. |
| 19:10 | cschep | Chousuke: ahh.. I've been trying to avoid ELPA so I can learn better how everything fits together.. but if it's not going to work.. |
| 19:11 | dnolen | maxhodak: based on your description of your project dir layout your import statement will not work. |
| 19:11 | cschep | so get ELAP, install clojure-mode, then do clojure-install ? |
| 19:11 | cschep | ELPA* |
| 19:11 | hiredman | there is a lein java plugin somewhere |
| 19:11 | hiredman | ~google lein-java |
| 19:11 | clojurebot | First, out of 163000 results is: |
| 19:11 | clojurebot | Building Clojure Projects with Leiningen « I am Zef |
| 19:11 | clojurebot | http://zef.me/2470/building-clojure-projects-with-leiningen |
| 19:11 | hiredman | :/ |
| 19:12 | technomancy | cschep: clojure-install is deprecated. if you install swank-clojure through elpa it will get the jars for you |
| 19:12 | AWizzArd | hiredman: about this in-memory transaction via dosync with additional persistence to disk: I would think that a (locking ...) around the dosync could help. In that case all threads that try to make a modification that requires disk-persistence would sit in the lock and won’t destroy each others transaction?! |
| 19:13 | maxhodak | hmm. now im getting tons of ZipExceptions on lein |
| 19:13 | cschep | this feels so fragmented, is there one place with a "right way"? |
| 19:13 | hiredman | AWizzArd: no |
| 19:13 | hiredman | AWizzArd: don't do that |
| 19:13 | technomancy | cschep: there's a lot of outdated info on the web... that's how blogs work unfortunately. the swank-clojure readme is your best bet |
| 19:13 | raek | have anyone seen this something like this function before? http://gist.github.com/292210 |
| 19:13 | raek | I don't want to reinvent what's already in clojure... |
| 19:14 | AWizzArd | hiredman: what is the problem with that approach? |
| 19:14 | hiredman | AWizzArd: the tie in with the stm would mean you could have database transactions, for example, that rollback if the transaction is retried |
| 19:14 | hiredman | not some kind of constant writing or something |
| 19:14 | hiredman | don't throw your own locks in with the stm |
| 19:15 | AWizzArd | yeah, but you also said that there is no mechanism in Clojure which would support my "plugins".. |
| 19:15 | hiredman | there is no stm support for this |
| 19:16 | hiredman | you just need to come up with a mechanism, possibly sending side-effect stuff to an agent to be executed once the transaction completes |
| 19:17 | AWizzArd | The challenge is that the order of the steps must be: writing data to the persistent data structure. This shows if there are contsraints or not. Then write to disk that the change happened. Then ref-set the ref to the new state. |
| 19:17 | Chousuke | raek: hm, remember that maps are unordered. the behaviour of that function is not well-defined. |
| 19:18 | Chousuke | array-maps happen to be ordered but I don't think that's guaranteed. :/ |
| 19:18 | raek | I know... but the assumption is that only one of the predicates will return true |
| 19:18 | AWizzArd | Step 1 and 3 must be in the same dosync, so that I will know that I can ref-set the new state later. But that also implies that step 2 must be in the same transaction. |
| 19:18 | raek | at least that's the case in my application |
| 19:19 | hiredman | erm, why are you using ref-set? |
| 19:19 | raek | maybe "mutually exclusive predicates" needs more explanation in the docstring |
| 19:20 | Chousuke | raek: ah, well, in that case I don't think there's anything like that in clojure |
| 19:20 | AWizzArd | hiredman: because i have a pointer to a snapshot that already has the correct state that i want |
| 19:20 | hiredman | why? |
| 19:20 | clojurebot | http://clojure.org/rationale |
| 19:20 | Chousuke | :P |
| 19:21 | hiredman | why aren't you just using alter? |
| 19:22 | AWizzArd | hiredman: I could also use alter |
| 19:23 | hiredman | ~alter |
| 19:23 | clojurebot | alter is always correct |
| 19:23 | AWizzArd | :-) |
| 19:24 | AWizzArd | ~seen kotarak |
| 19:24 | clojurebot | kotarak was last seen quiting IRC, 3557 minutes ago |
| 19:26 | AWizzArd | n8 all, and thanks hiredman for finding FileDescriptor’s .sync |
| 19:32 | cschep | Why doesn't swank-clojure just grab the latest clojure/clojure-contrib from github? |
| 19:33 | dnolen | cschep: because they aren't always stable, not very a good user-experience :) |
| 19:34 | cschep | dnolen: ha, cool. |
| 19:34 | cschep | dnolen: is there a command to see if there is an update? must be.. |
| 19:35 | dnolen | cschep: if you want to work from the latest, clone them from github, build the jars, and symlink to them from your .swank-clojure dir |
| 19:36 | dnolen | that's what I do. |
| 19:38 | cschep | oh, cool. |
| 19:42 | dnolen | cschep: supposedly there's way to configure swank-clojure from your .emacs file but I couldn't figure it out :) |
| 19:43 | cschep | dnolen: ha, yeah I was just reading about that, but i'm just learning clojure so i doubt that i'll even notice any difference in 1.1.0 and 1.2.0 |
| 19:43 | cschep | dnolne: learning clojure as well as emacs, as well as being a bit newer to the java side of things has been a real hassle |
| 19:44 | dnolen | it's a lot to handle. Did you look into Enclojure? |
| 19:44 | cschep | dnolen: I didn't really, I'm hoping to start using emacs more and more for other code too, so I decided to just bite the bullet..maybe I should retreat for a bit though.. :) I dunno. |
| 19:46 | dnolen | well you're already on your merry way. If you stop now you'll just forget everything ;) |
| 19:50 | cschep | ha, truth. |
| 20:05 | zaphyr | Heh, I've been losing all day so I've been forced to ask this newbie question- I need to create a java class called 'vec3f', containing three public static final float fields x,y, and z, with a constructor taking those arguments (in clojure 1.1). Can anyone give a brief paste to demonstrate how I would go about this? Thanks in advance. |
| 20:08 | zaphyr | oops, s/public static final/public final/ (duh) |
| 20:10 | dnolen | zaphyr: I don't think that you can really do that in Clojure 1.1, you can use deftype in clojure 1.2. |
| 20:11 | zaphyr | ahh, that's probably why i couldn't find it. :) |
| 20:11 | zaphyr | all i found was :state, which was close, but no cigar |
| 20:11 | zaphyr | thanks! |
| 20:11 | krumholt_ | zaphyr, do you need that class to feed it to a java function? |
| 20:12 | zaphyr | actually it's a performance thing- i need to be able to read unboxed floats from members as it's the quickest way to do it under the sun jvm |
| 20:13 | zaphyr | java doesn't really need to see it, but since it's going to be used heavily a defstruct probably won't cut it |
| 20:13 | zaphyr | (and float[] will be significantly slower according to my benchmarks) |
| 20:14 | krumholt_ | zaphyr, (deftype vec3f #^float x1 #^float x2 #^float x3) |
| 20:14 | zaphyr | want :), is 1.2 stable enough given I'm still starting out do you think? |
| 20:15 | krumholt_ | i don't know anything about 1.2 sorry. but deftype should be pretty fast |
| 20:16 | dnolen | zaphyr: pretty stable, tho it means you need to build your .jars of course. Though that isn't so hard. |
| 20:16 | zaphyr | krumholt: oh, i was under the impression deftype was 1.2 only, so maybe i've just completely overlooked that |
| 20:17 | krumholt_ | no protocols and deftype is usable in 1.1 |
| 20:17 | cschep | is there a good way to parse HTML in clojure? |
| 20:17 | cschep | I'm looking at http://htmlparser.sourceforge.net/ .. |
| 20:17 | krumholt_ | it says in the docs that it is alpha and subject to change if thats not a problem for you |
| 20:18 | zaphyr | ah, well, not really at this stage, i'm happy to change as required. |
| 20:18 | somnium | krumholt_: that's 1.2 (previously 1.1-new) |
| 20:18 | dnolen | cschep: Enlive is good for HTML parsing |
| 20:19 | ohpauleez | enlive is awesome |
| 20:19 | krumholt_ | somnium, oh ok. thanks for the info |
| 20:20 | zaphyr | hmm (deftype vec #^float x #^float y #^float z) gives me Exception in thread "main" java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol? |
| 20:20 | zaphyr | using clojure 1.1.0-new-snapshot |
| 20:20 | zaphyr | (downloaded a couple of days ago) |
| 20:21 | cschep | dnolen: ok cool i'll check it out |
| 20:21 | dnolen | ,deftype |
| 20:21 | clojurebot | java.lang.Exception: Unable to resolve symbol: deftype in this context |
| 20:21 | dnolen | ,+ |
| 20:21 | clojurebot | #<core$_PLUS___4518 clojure.core$_PLUS___4518@1b38815> |
| 20:22 | dnolen | (deftype vec3f [#^float x #^float y #^float z]) |
| 20:24 | zaphyr | yay! it worked! thanks everyone :) |
| 20:42 | zaphyr | final stupid question of the night- can i implement multimethods for my new vec3f type to handle the numerical operators? looking at the source to clojure.lang.Numbers it seems i might win more if I just do this part in Java... |
| 20:45 | arohner | {:pre [(disjoint? (set (keys A)) (set (keys B)))]} |
| 20:46 | arohner | I'd like to see the haskell type for that... |
| 20:50 | zaphyr | ah, nm i just found clojure.contrib.generic.arithmetic :) |
| 21:01 | arohner | are there any library functions for generating selections / permutations? |
| 21:04 | dnolen | arohner: clojure.contrib.combinatorics |
| 21:05 | arohner | looks like I need to become familiar with incanter |
| 21:05 | somnium | arohner: a few things in clojure.set too |
| 21:26 | arohner | is there any way to easily make maven/lein build against the clojure checkout in my directory? |
| 21:26 | arohner | I dislike it that I have my own git branch, and then I download some library, and I run mvn install and then it goes and downloads some other clojure version than the one I'm using |
| 21:48 | vu3rdd | did anyone try the latest clojure-contrib from the master branch? |
| 21:48 | vu3rdd | I am having trouble giving locally built clojure.jar to the -contrib build |
| 21:48 | dnolen | vu3rdd: you're using maven right? |
| 21:48 | vu3rdd | I do mvn -Dclojure.jar=<absolute path to clojure.jar> package |
| 21:49 | vu3rdd | but it still downloads clojure-1.2.0-XXX.jar from the web |
| 21:49 | vu3rdd | I tried passing the -o flag to mvn (offline mode), but it fails because it can't find the jar |
| 21:50 | vu3rdd | is anyone else also facing this? |
| 21:50 | dnolen | vu3rdd: hmm, it seemed to work for me this morning, but I'm not on machine with that setup at the moment. |
| 21:52 | vu3rdd | would you mind trying by deleting the copy of clojure-XXX.jar from the ~/.m2 directory and try again? |
| 21:52 | vu3rdd | when you get to the machine, I mean |
| 21:52 | vu3rdd | dnolen: thanks a lot. |
| 23:06 | qed | forgive me if this is dense, but: When that finishes, symlink bin/lein from your checkout to your path. This will make "lein" run from your checkout while "lein-stable" uses the jar self-installed in ~/.m2. |
| 23:06 | qed | So I I make a symlink from where to where? I have lein-stable in my ~/bin/ which is on my path |
| 23:06 | dnolen | qed: yes |
| 23:07 | dnolen | from path/to/lein-checkout/bin/lein to /usr/bin/local or whatever is appropiate for your system. |
| 23:07 | dnolen | /usr/bin/local/lein i mean |
| 23:07 | dnolen | in your case |
| 23:07 | dnolen | ~/bin/lein then |
| 23:07 | clojurebot | I don't understand. |
| 23:08 | dnolen | ln -s ~/bin/lein path/to/checkout/bin/lein |
| 23:08 | dnolen | er |
| 23:08 | dnolen | sorry |
| 23:08 | qed | is it reversed? |
| 23:08 | dnolen | yes |
| 23:08 | qed | yeah i always make that mistake |
| 23:08 | qed | okay that makes sense, i kept reading that link i should overwrite the lein binary in my checkout |
| 23:08 | qed | like* |
| 23:09 | qed | ln would make so much sense if there was a [to] somewhere in there |
| 23:09 | dnolen | heh well it does follow the convention of cp and mv: source -> target |
| 23:36 | qed | dnolen-rec_: re: heh well it does follow the convention of cp and mv: source -> target --- Yes, but in a way the source is the target and vice versa |