#clojure logs

2008-07-21

07:42abrooksColin, of Project Euler just emailed me to say that he added Clojure to the list of available languages. If you've been solving your PE problems with Clojure you can now show that to the public. :)
11:01Chouserabrooks: that probably warrants a post to the list
11:32Chouserdrewr: daily atom?
11:33Chouserhourly rss?
11:33ChouserI guess every IRC post could be its own feed entry...
11:44drewrI couldn't come up with a good solution.
11:44drewrEvery post shouldn't be an entry. That could get out of control.
11:45drewrMaybe hourly would work.
11:45drewrNo entry if there wasn't activity.
11:46Chouserhourly would fit in with the current design pretty well.
15:06rhickey_note, latest svn has new namespaces for set et al -> clojure.set etc. aliases coming...
15:40Chousercan static functions not be called using (classname/methodname arg) syntax?
15:41Chouserstatic methods I mean.
15:42cemerickChouser: should work -- I've been using that for a while
15:43cemericker, no, just for fields
15:43cemericksorry -- there's a contrib lib for that -- import-static, I think
15:43rhickey_user=> (Boolean/valueOf "true")
15:43rhickey_true
15:44Chouseryep, sorry -- it's non-static method. I'm trying to run some old code and wasn't paying close enough attention.
16:20mebaran151is there a linter for clojure that I can call from emacs?
16:21Chousermebaran151: to check for syntax error or something?
16:21mebaran151just to prettify the code
16:21mebaran151and fix nasty indentation
16:21mebaran151I still haven't gotten down a good LISP indentation style yet
16:22Chouserah. I think there's a clojure-mode, but I have no idea if it helps with indentation or not. I don't use emacs.
16:23toyvomebaran151: tell me if you find one :) I have been sitting in scheme-mode, which indents OK except some parts that are idiomatic to Clojure
16:23rhickey_http://clojure.codestuffs.com/
16:23mebaran151Chouser, what editor do you use?
16:24mebaran151I have the clojure mode, but I don't think it contains a linter
16:24Chouservim
16:24toyvorhcickey_: thanks Rich, looks good.
16:25Chouserthe plugin I use for indentation is imperfect -- perhaps similar to what toyvo described.
20:25toyvoI also have Clojure in inferior-lisp, for what it's worth for now. But must check out that Clojure mode.. Anyone tried running a long-standing Clojure with detachtty? Any issues with that? That would be fun - a dynamic JVM in production.
20:25rhickey_mebaran151: still not quite sure what you mean by linter, but if you select a region and do C-M-\ clojure mode will re-indent the region
20:26mebaran151you sure it's C-m-\? That just seems to add a new line to the top of my buffer.
20:27rhickey_mebaran151: did you have a region selected?
20:28mebaran151yeah
20:28mebaran151that's ctrl-m backslash right?
20:29rhickey_mebaran151: ctrl-meta-\
20:29rhickey_all together
20:30mebaran151that doesn't seem to change anything
20:30rhickey_may be ctrl-alt-\ depending on os
20:30mebaran151just put it on a nasty bit of clojure I'm working on it and it slightly forgot to do anything
20:31rhickey_if you go down the code and type Tab on each line does it indent?
20:34toyvomebaran151: maybe you are in text mode and not in scheme/lisp/clojure mode? I go to scheme mode by pressing escape, then x, then typing scheme-mode (enter). Should be similar for other modes.
20:34mebaran151it's seems to be syntax highlighting properly
20:36mebaran151how do I reindent in scheme mode
20:36mebaran151just switched to it
20:37toyvoM-x mark-whole-buffer and then M-x escape-region. M-x - emacs jargon for Esc then x, or Alt+x, or Meta+x
20:38toyvosorry, indent-region, not escape-region
20:38toyvothese commands should be the same in any mode
20:43rhickey_namespace aliases are up, via Graham Fawcett (alias 'set 'clojure.set)
20:44Chousernice
20:46Chousernow give scgilardi a few minutes to integrate that into lib...
20:46toyvoDo you guys plan to go for Clojure code repo like CPAN or Scala Bazaars? Are those 12 or so files in SVN I've seen (under User Contributions) the repository as of today? Or is the preferred way of distributing Clojure code is in jars?
20:50Chousertoyvo: I'm sure someone else can answer better than I, but my understanding is that the relationship between directory structure namespaces is currently in flux.
20:50Chouseronce that has settled down and lib (or something like it?) has been rolled into stock clojure releases, we'll have sufficient framework to think about the next stage.
20:51Chouserfor now there's clojure-contrib and various bits of .cljs and .jars here and there on the web.
20:53ChouserThe fact that Java has nothing like CPAN (that I know of?) and "hasn't needed it" may mean Clojure never gets something like it either. Dunno.
20:53mebaran151what do other lisps do for pkg management?
20:53toyvoChouser: Thanks - that's how the situation looks to me. Hmm...
20:54toyvoI know PLT Scheme has a pretty innovative PlaneT repository. It allows you to do something equivalent to Java's code loading over HTTP.
20:54toyvoTHat is, you just write (require (planet ...)) and the system downloads and installs the correct version of the package and its dependencies for you.
20:54leadnosecommon lisp has asdf and cl-build
20:54Chousermebaran151: gentoo seems to actively package and distribute common lisp libs via their standard OS distro system.
20:54mebaran151without something like CPAN, the biggest problem is that most libraries won't reuse the utils in the others
20:55mebaran151because dependency management would be too much of a pain
20:56mebaran151btw, I'm maintaining a clojure pkg for archlinux
20:57toyvomebaran151: great!
20:57mebaran151I wish you guys would just include the jline jar inside clojure
20:58ChouserI don't use JLine.
20:58ChouserI like rlwrap. :-)
20:58mebaran151I was thinking of making everyone just use rlwrap, but I wondered if there were any downsides
20:58toyvoAh that's what it is! I'm on rlwrap too :)
20:59toyvoI've not written much java before this week - but supposedly something like JLine is NOT included, can you load it over HTTP? Is that something URLClassLoader is about?
21:00mebaran151I don't like the idea of loading remote code: seems like a huge security risk
21:00Chousertoyvo: I think so, but I don't think it caches it anywhere.
21:01toyvoThen we could mash-up a clojure library that loads it and caches in /tmp.. Yes, it's a huge security risk. But on the other hand, loading Linux packages - isn't that a risk? I wonder.
21:01Chousersince clojure source can have Java dependencies, it seems like a CPAN-for-clojure would actually have to be a pretty complete Java/jar/clj fetching, dependency resolving, caching thing.
21:02mebaran151toyvo, it's a very explicit risk though
21:02mebaran151when I install package, I have to explicit run it before evil stuff happens
21:02mebaran151in a remote URL loading scheme, someone could just mangle the byte code to point to their evil botnet maker
21:03toyvoAh yes... Perhaps certificates can help?
21:03toyvoChouser: I've heard Maven does something like that? Or no? Sorry, my Java is rudimentary.
21:04mebaran151yes, maven does automatically pull dependency
21:04mebaran151there actually really isn't any reason its infrastructure couldn't be exploited: scala does something
21:04mebaran151the only problem is that maven is very much wedded to a compile cycle, which may or may not be appropriate for a lsip
21:05toyvoLooks like... So that may be a good start... If it has classes we can take out and reuse.
21:05Chouserif we think of "compiling" clojure as being more of "fetch and compile java dependencies, fetch .clj and run any gen-class stuff" it maps ok, right?
21:06mebaran151maybe, though compiling is a very external process in Java Scala land
21:06toyvoThere's another related question I spent some time thinking about: can you load new versions of classes into a JVM without restarting it? Erlang VM guarantees such hot uploads, for JVM I was a bit confused..
21:07mebaran151JVM has a security model that interferes with this, but it's currently a JSR
21:07mebaran151you could try something like java rebel, but it's proprietary and I don't see how it maintains bytecode security
21:08ChouserClojure works hard to allow dynamic code changes without actually having to replace Java classes.
21:08mebaran151you can also try class loader hacks, but those are always very memory leaky
21:09toyvoAh... Right! Hm.. But in Clojure, if I load new proxies, these are different classes, right? So the old ones can get recycled.
21:11toyvoBut then, it looks like distributing Clojure as compiled bytecodes is out, because new versions cannot be hot-updated in the JVM as easily, having static class names.
21:11mebaran151for a servlet, is there any real downside to using a proxy: I know their slower to instantiate, but aren't servlets only loaded once at server boot?
21:11mebaran151toyvo, I think the ASM library might support some name mangling
21:12cemericktoyvo: I understand that Rich is contemplating a FASL-esque distributable path, rather than compiling to bytecode
21:13rhickey_right now the story is, dynamic code means load new source
21:13toyvoI'm googling for "FASL"... :)
21:14cemericktoyvo: you won't find much -- there's no spec or anything -- it appears to be implemented differently in every lisp
21:14toyvooh, but what IS it? I'm los
21:15toyvoAh, got it
21:16mebaran151can Java call clojure?
21:17toyvomebaran151: that was a good question. I'm interested too if proxy servlets are in any way inferior. They seem superior in being easily reloaded - modified from a REPL.
21:17mebaran151well I've read that proxy's instantiate much slower
21:17mebaran151but for a server, I think that a servlet only needs to be loaded once
21:18rhickey_The best recipe for servlets is to use gen-and-save-class, this gives you a static class stub, with all of the real logic in Clojure, and thus re-loadable
21:18mebaran151but right now, I'd prefer not create trash class files as develop the servlet
21:18rhickey_?
21:19mebaran151well doesn't it write a class file
21:19mebaran151or is this class file static as I change it's internal logic
21:19rhickey_yes, and the same one will be useful for the entire lifecycle of development
21:19rhickey_it doesn't need to be regenerated
21:21rhickey_note: new in svn - all of the .cljs have moved out of the root! and now follow classpath rules
21:22toyvogen-and-save-class - is it only in SVN? My system seems not to find it.
21:22toyvoLet me upgrade
21:22mebaran151rhickey, what do you mean by moved out of root?
21:24rhickey_boot.clj et al were all in the root of the jar, now in classpath-compliant subdirectories corresponding to the packages of the classes of the generated functions
21:24rhickey_user=> map
21:24rhickey_clojure.map__571
21:24rhickey_user=> clojure.set/union
21:24rhickey_clojure.set.union__1962
21:26rhickey_in /clojure/boot.clj and /clojure/set/set.clj respectively
21:30toyvoHas anyone thought of writing a Clojure bot to sit in the IRC? Like Haskell's Lambda bot?
21:31Chouserit's been mentioned several times. Nobody's quite bothered to do it yet though.
21:32toyvoI'll give it an hour.. Seems to be a fun thing to do.
21:32mebaran151ah, so this is more of an internal thing, the classpath edits?
21:34rhickey_well, some of the libraries need to be manually loaded, so people might need to edit the paths. Otherwise, it is for tooling, lots of Java support for finding things in classpaths, so now Clojure is more compliant. It also provides a known schema for file layout that can be leveraged by the lib/require framework.
21:35drewr,test
21:35clojurebotI don't yet know what "test" means.
21:35drewrclojurebot: Learn then!
21:35Chouser,(println "hello everyone")
21:35clojurebotI don't yet know what "(println "hello everyone")" means.
21:35Chouserawww
21:35drewr:-)
21:36drewrHaven't decided yet what to hook into it. Probably the DOC function for starters.
21:36toyvoAh
21:36toyvoNeat
21:36ChouserDoing any Java sandbox stuff? Any logging?
21:37drewrNope, basically an echo service currently.
21:38toyvo,(doc gen-and-save-class)
21:38clojurebotI don't yet know what "(doc gen-and-save-class)" means.
21:38drewrI didn't do logging because I didn't have a dedicated box for it. I'm going to switch my VPS to a vendor whose network allows IRC and then I'll fire it up.
21:39toyvo,(doc int)
21:39Chouserdrewr: ok. When that's done, if you're interested we can look at rolling clojure-log into it.
21:39clojurebotI don't yet know what "(doc int)" means.
21:40toyvo,(def id #(%))
21:40clojurebotI don't yet know what "(def id #(%))" means.
21:40rhickey_drewr: doc is easy, just echo (doc x) => http://clojure.org/api#x
21:40Chouserdrewr: right now clojure-log is connected from my aging linux workstation over residential DSL. Anything would be more robust, I'm sure.
21:41drewrChouser: Yup. I didn't want to bother unless it was going to improve on what you've done.
21:42toyvodrewr: so clojurebot is just an echo? man, i'm confused :) I kept thinking it's an interpreter with an unknown limited set of commands.
21:43toyvoOr is there something it does right now?
21:43toyvo,(+ 1 2 3)
21:43clojurebotI don't yet know what "(+ 1 2 3)" means.
21:43drewrtoyvo: It's unlikely I'll allow readable expressions.
21:43drewrI would think it's too hard to do it securely, so I haven't given it much thought.
21:43toyvodrewr: what does/will it allow then?
21:44drewrtoyvo: Print docstrings and google results perhaps.
21:45toyvodrewr: Well... Are you sure security is such a big big issue?
21:45rhickey_drewr: http://calumleslie.blogspot.com/2008/06/simple-jvm-sandboxing.html
21:45toyvoRich: thanks for the link!
22:18fyuryuis it normal, that stuff gets printed twice? http://paste.lisp.org/display/64026
22:28Chouserwhat's swing-frame?
22:28fyuryuin other words: do methods contained in proxy are somehow executed twice?
22:29fyuryuChouser: oh, just a function that creates a swing-frame and packs the applet into into it
22:31Chouserthe body of your "setup" method shouldn't be called at all when it's defined
22:32Chouseryou're sure swing-frame isn't somehow causing your setup method to be called twice?
22:34fyuryuChouser: no, applets require (according to javadoc) that a "init" call when inserted into a swing frame, but I don't call "setup" myself
22:36fyuryuChouser: maybe it's a Processing thing
22:41fyuryuChouser: ok, I got it. I created the frame in a try catch block