faster json extraction?

2010-06-23 Thread braver
While writing JSON is fast, reading it back into a Clojure map is slow; even with clj-json, based on Jackson. Here's an idea: use Jackson's ObjectMapper. The following line extracts a Java Map: Map userData = mapper.readValue(new File("user.json"), Map.class) (from http://wiki.fasterxml.com/Jac

Re: State of Clojure web development

2010-06-23 Thread Meikel Brandmeyer
Hi, On Jun 23, 11:23 pm, James Reeves wrote: > 1. Have you written, or are you writing, a web application that uses > Clojure? What does it do? I'm guerilla coding a small web app to do some very non-standard statistical analysis of customer returns (ABS/ESC systems for cars). The whole thing i

Re: classpath problem with emacs and slime

2010-06-23 Thread Phil Hagelberg
On Wed, Jun 23, 2010 at 8:36 AM, Manuel wrote: > I created a new project using leinigen; told it to download and > install clojure-contrib (along with some other things), which it does, > and everything works fine except that I can't use > clojure.contrib.math. > > If I try (:use clojure.contrib.m

Re: slow raw io

2010-06-23 Thread cageface
Interesting. Here are the times I get: LINUX: slurp, *in* 18.8 seconds slurp, System/in 18.2 seconds slurp2, *in* 6.7 seconds slurp2, System/in 5.7 seconds I have an intel iMac here too, running 10.6.4: slurp, *in* 20.4 seconds slurp, System.in 19.0 seconds slurp2, *in* 7.2 seconds slurp2, System

Re: compiling clojure for a servlet container (tomcat)

2010-06-23 Thread Todd
Adrian/Alex - Thank you for both of your responses. As I'm new to clojure (and lisp in general), it'll take me a bit to puzzle through your code and links. However, I'll use it as an example to study the language. Thanks again! -Todd -- You received this message because you are subscribed to

Re: STM style disk persistance

2010-06-23 Thread meb
You might also want to check out Redis, which is supposed to act like disk persistent data structures in memory. The author just added a virtual memory module, so now Redis can handle datasets larger than the memory you assign it. Mark On Jun 22, 10:57 am, Timothy Baldridge wrote: > Greetings,

Re: STM style disk persistance

2010-06-23 Thread Timothy Baldridge
I'm wondering if we're going about this slightly the wrong way. Let's take a look at CouchDB. CouchDB prefers to keep all data on the disk at all times. As docs (or items) are added to a database they extend that database, but never overwrite it. In addition all changes are written instantly to dis

classpath problem with emacs and slime

2010-06-23 Thread Manuel
Hello there, I'm new to Clojure and encountered a problem which I couldn't solve on my own. I created a new project using leinigen; told it to download and install clojure-contrib (along with some other things), which it does, and everything works fine except that I can't use clojure.contrib.math

Re: clojure.xml/parse cannot handle filenames containing #

2010-06-23 Thread Stuart Halloway
clojure.xml/parse is not documented to handle filenames-as-strings at all. It treats strings as URIs, deferring to the host (JVM) notion of URI as implemented in the underlying API. I can certainly see why this would be confusing! Is there a way to make it better without violating the expectati

Re: slow raw io

2010-06-23 Thread Stuart Halloway
On my laptop (Mac) the biggest difference here has nothing to do with buffering in slurp. It is whether you use System/in (fast) or *in* (slow). The latter is a LineNumberingPushbackReader. Can you check and confirm? When I slurp System/in it is more than twice as fast as slurping *in*. I beli

Re: clojure.xml/parse cannot handle filenames containing #

2010-06-23 Thread cageface
It looks like it's having trouble figuring out if "test#1.log" is a file path or a URI. Not sure what a real solution is but this seems to work as a workaround: (clojure.xml/parse (java.io.File. "test#1.log")) On Jun 23, 12:30 pm, Zak Wilson wrote: > (clojure.xml/parse "test1.log") >  works cor

Re: slow raw io

2010-06-23 Thread cageface
Another example. I'm running this on a Ubuntu 10.04 laptop with this java: java version "1.6.0_18" OpenJDK Runtime Environment (IcedTea6 1.8) (6b18-1.8-0ubuntu1) OpenJDK 64-Bit Server VM (build 14.0-b16, mixed mode) and this command line: java -Xmx3G -server clojure.main cat2.clj (require '[clo

Re: slow raw io

2010-06-23 Thread cageface
Sure. Here's my clj script: #!/bin/sh if [ -z "$1" ]; then exec java -server jline.ConsoleRunner clojure.main else SCRIPT=$(dirname $1) export CLASSPATH=$SCRIPT/*:$SCRIPT:$CLASSPATH exec java -Xmx3G -server clojure.main "$1" "$@" fi (Usually I don't have the -Xmx flag there. I add

Re: slow raw io

2010-06-23 Thread Stuart Halloway
I am seeing more like 1.8 seconds for the raw version, vs. 2.8 seconds for slurp (master branch). Can you post a complete example (including the clj script you use, and what version of Clojure), so we can be apples-to-apples? Stu > For the record, this program runs in 3.3 seconds so I guess tha

Re: State of Clojure web development

2010-06-23 Thread Hugo Duncan
On Wed, 23 Jun 2010 17:23:16 -0400, James Reeves wrote: 1. Have you written, or are you writing, a web application that uses Clojure? What does it do? I'm writing cloudhoist.com, a cross cloud management console and api, that lets you start and stop nodes on Amazon, Rackspace, etc, config

Re: State of Clojure web development

2010-06-23 Thread Brian Carper
On Jun 23, 2:23 pm, James Reeves wrote: > 1. Have you written, or are you writing, a web application that uses > Clojure? What does it do? My blog and a couple of other blog-like hobby sites. I also wrote a small standalone data-collection app at work. It collects survey data for psych research

Re: State of Clojure web development

2010-06-23 Thread Chas Emerick
James, First, thank you for all of your work in this area. It is greatly appreciated. My answers follow: 1. DocuHarvest ( https://docuharvest.com ), which I've already talked about here. Broadly speaking, it extracts data from documents, and it's just getting started. 2. Relevant to

Re: State of Clojure web development

2010-06-23 Thread Joost
On Jun 24, 1:55 am, Joost wrote: > compojure in whatever was the last release version - with a few lines > of patches. This may be interesting to anyone in the US or Japan: All the patches I made were to fix UTF-8 handling. I live in Europe. We use characters like Ø and ß and you'd better get us

Re: State of Clojure web development

2010-06-23 Thread Joost
On Jun 23, 11:23 pm, James Reeves wrote: > Hello there! Hi James! :) > 1. Have you written, or are you writing, a web application that uses > Clojure? What does it do? I've written one very simple "internal organsiation" site in clojure that's finished except for a few little bugs. Should be

Re: Requesting Feedback on new Relational Mapping lib for Clojure

2010-06-23 Thread Brenton
Thank you for your ideas, feedback and criticisms. rb and Jeff Future versions of Carte will not force you to list the column names but will retrieve them from the database. Jeff The model macro produces a map which may then be merged with other model maps so you could define the model in vario

Re: slow raw io

2010-06-23 Thread cageface
For the record, this program runs in 3.3 seconds so I guess that points to the implementation of slurp: (import '[java.io BufferedReader InputStreamReader]) (let [reader (BufferedReader. (InputStreamReader. System/in)) file-data (StringBuffer.) buffer (char-array 4096)] (loop [total

Re: State of Clojure web development

2010-06-23 Thread Sean Corfield
On Wed, Jun 23, 2010 at 2:23 PM, James Reeves wrote: > 1. Have you written, or are you writing, a web application that uses > Clojure? What does it do? I don't know that I'll be writing entire web applications in Clojure any time soon but I expect to be using Clojure in some form from (essentiall

slow raw io

2010-06-23 Thread cageface
Not sure if this is a clojure issue or a something else but I'm seeing surprisingly slow I/O on large text files. For example, on a unix machine try this: 1. create a large file rm -f words; for x in $(seq 300); do cat /usr/share/dict/words >> words; done 2. create a clj file that just slurps it

State of Clojure web development

2010-06-23 Thread James Reeves
Hello there! Chas Emerick's recent "State of Clojure" survey [http://bit.ly/dtdAwb] indicated that a significant proportion of Clojure users are beginning to use Clojure for web development. A recent Hacker News posting [http://bit.ly/91Bu5J] seems to corroborate these results, with several Clojur

Re: STM style disk persistance

2010-06-23 Thread Daniel Werner
On Jun 22, 7:57 pm, Timothy Baldridge wrote: > system it uses. Has anyone tried marrying the two system systems to > create a truly persistent data primitive where any "updates" to a map > is written to the disk? There has been an attempt at integrating STM transactions with DB transactions, even

Re: clojure.contrib.logging in "side-effect free" functions?

2010-06-23 Thread John Williams
When the docs say not to use side-effects in a function or block of code, they're not saying you can't use side-effects at all; it's just a reminder that using side-effects can cause nasty surprises for one or more of these reasons: 1. The code may be evaluated later than you expect. 2. It might no

clojure.xml/parse cannot handle filenames containing #

2010-06-23 Thread Zak Wilson
(clojure.xml/parse "test1.log") works correctly, output omitted (clojure.xml/parse "test#1.log") Premature end of file. [Thrown class org.xml.sax.SAXParseException] $ mv test\#1.log test2.log (clojure.xml/parse "test2.log") works correctly, output omitted test#1.log is a copy of test1.l

Re: Clojure Futures Docs and Functionality

2010-06-23 Thread Daniel Werner
Hello Ryan, On Jun 21, 7:34 am, Ryan Senior wrote: > 1 - I think a good improvement would be updating the docs for the future > related functions to indicate what kind of objects are passed in and > returned.  Users would then not have to go through the source to see what's > being returned.  Thi

Re: Hiring again - need 3 devs before fall 2010

2010-06-23 Thread Tim Dysinger
Sorry I didn't provide enough detail on that last post. Please send your interest to jobs on sonian.net with "clojure" in the subject. On Wed, Jun 23, 2010 at 8:24 AM, Tim Dysinger wrote: > Hello, > > It's that time again.  I need to hire some more full-time > work-from-home pair-programming ema

Re: Enhanced Primitive Support

2010-06-23 Thread John Williams
On Sat, Jun 19, 2010 at 5:41 AM, Heinz N. Gies wrote: > Lets get away from the argument already cast and bring a new one. It is an > impossible situation that the literal 1 in one place has a different meaning > and behavior then in another place. This is in fact a show stopper, I'm > serious, th

ops' macro to tidy +', -', *', /' operations?

2010-06-23 Thread Aaron Brooks
I'm afraid I have nothing to contribute to the on-going discussions of what the default numerical behavior should be and what the prime version operations should do. I did, however, notice that the prime ops tend to be clustered together in the examples given and seem likely to be clustered in real

Re: Clojure / Common Lisp Question

2010-06-23 Thread evins.mi...@gmail.com
On Jun 18, 9:52 am, rob levy wrote: > As an informal survey of people who use both Clojure and Common Lisp for > different projects, what do you see as the main determining factors behind > your choice to use either Clojure or Common Lisp for a project, given the > present state of Clojure.  Let

Can't send from agent error handler?

2010-06-23 Thread Shawn Hoover
My first thought for an agent error handler was to send the exception to another agent. user=> (let [handler (agent nil) a (agent 42 :error-handler (fn [_ ex] (send handler (fn [_] (println ex)]

Hiring again - need 3 devs before fall 2010

2010-06-23 Thread Tim Dysinger
Hello, It's that time again. I need to hire some more full-time work-from-home pair-programming emacs/unix/math-loving clojure devs. Join our team of 7 devs who write clojure full time. We will be bringing on a dev a month over the summer. The ideal candidate has some unix, jvm & coljure/lisp/f

Re: Reflection warnings in defrecord (missing hint in core_deftype.clj?)

2010-06-23 Thread David Nolen
I've been seeing this as well. On Wed, Jun 23, 2010 at 11:17 AM, Michał Marczyk wrote: > Hi, > > just noticed that > > (defprotocol Foo (foo [self])) > (defrecord Bar [x] Foo (foo [self] x)) > > gives a reflection warning -- "call to contains can't be resolved". > > My initial guess is that this

Reflection warnings in defrecord (missing hint in core_deftype.clj?)

2010-06-23 Thread Michał Marczyk
Hi, just noticed that (defprotocol Foo (foo [self])) (defrecord Bar [x] Foo (foo [self] x)) gives a reflection warning -- "call to contains can't be resolved". My initial guess is that this is due to a missing hint on line 215 in core_deftype.clj. Sincerely, Michał -- You received this messa

Re: STM style disk persistance

2010-06-23 Thread evins.mi...@gmail.com
On Jun 22, 12:57 pm, Timothy Baldridge wrote: > Greetings, > > I've recently started learning Clojure. For the past year or so I've > been using CouchDB, and am very happy with the MVCC disk storage > system it uses. Has anyone tried marrying the two system systems to > create a truly persistent

Re: Slides for short (45 minutes) presentation of clojure for java devs

2010-06-23 Thread Robert Campbell
I'd like to resurrect this thread, because I have the exact same requirement Laurent had and I'm hoping there's been some additional progress in this area. I'm set to give a Clojure presentation to our company's Java developers, and I'm looking for a way to excite the audience about FP concepts in

Re: lazy-xml defect (?)

2010-06-23 Thread Chouser
On Wed, Jun 23, 2010 at 7:17 AM, Stuart Halloway wrote: > I am trying to track down and solve the issues Phil Hazelden > reported on Hacker News [1]. I suspect that the XML issue was > this one: > > It appears that the code has moved on since this report-- the > emit-element fn mentions a :pad opt

Re: Enhanced Primitive Support

2010-06-23 Thread Heinz N. Gies
Hmm yesterday Rick said that the new changes give clojure a chance to put down the 'scala is faster then clojure' argument. So I figured I give it a try and implemented some of the shootouts: fannkucken-redux and the regexdna example. I found some interesting things especially once I got carried

Re: Compiling a namespace causes subsequent uses of it to fail.

2010-06-23 Thread Stuart Halloway
I think the behavior you are seeing here is reasonable. When you mix compilation and dynamic access to vars, you need to reason carefully about the order in which things will happen. More usefully: you can write a test in your var-get expression that will make it do what you want in all scenari

lazy-xml defect (?)

2010-06-23 Thread Stuart Halloway
I am trying to track down and solve the issues Phil Hazelden reported on Hacker News [1]. I suspect that the XML issue was this one: It appears that the code has moved on since this report-- the emit-element fn mentions a :pad option but I don't see it being used anywhere. Is there an issue her

Re: Question about "every?"

2010-06-23 Thread Stuart Halloway
Hi Michele, Pass a sequence of maps, not just a map: (every? #(:x %) [{:x "s"}]) -> true Cheers, Stu > In the book "Programming Clojure" (p2_0, pdf, page 185) "Adding > Validation to Refs" there is this code: > > (def validate-message-list (partial every? #(and (:sender %) (:text > % > >

Question about "every?"

2010-06-23 Thread michele
In the book "Programming Clojure" (p2_0, pdf, page 185) "Adding Validation to Refs" there is this code: (def validate-message-list (partial every? #(and (:sender %) (:text % This works fine as a validator, but when I try the code directly - not as a validator - it returns false. I also tested

Re: Need help getting Snow Leopard, Aquamacs, Clojure, and Slime to work

2010-06-23 Thread Larry Travis
Thanks again. I have to be away from home and my iMac for the next ten days so it will be some time before I can work through your suggestions, but I will certainly give them a try. I'll let you know what kind of success I have. I very much appreciate your help. --Larry Travis Joost wrote:

Re: Name change proposal for "extend-protocol"

2010-06-23 Thread Travis Hoffman
Thanks for the clarification Stuart! I think I see how to think about protocols ... and not as an interface, in the java sense. I think it makes sense to me now. Love your book, btw! -Travis On Jun 21, 12:31 pm, Stuart Halloway wrote: > Hi Travis, > > The choice of "extend" follows from this r

Re: I am unclear on how I can call an Ifn stored in a map usefully

2010-06-23 Thread Tim Robinson
Perfect! And Thanks! Tim On Jun 22, 7:00 pm, Michał Marczyk wrote: > Firstly, consider using Delays rather than IFn. See (doc delay) and > (doc delay?). In Clojure, many sorts of things are IFns, including > (among others) sets, vectors and maps, and you probably don't want to > call those. > > (d

Re: Transform columnar data into a tree?

2010-06-23 Thread ka
How about this (using only map, reduce) - user=> (def data1 [[:a1 :b1 :c1] [:a1 :b1 :c2] [:a1 :b2 :c3] [:a1 :b2 :c4] [:a2 :b3 :c5] [:a2 :b3 :c6] [:a2 :b4 :c7] [:a2 :b4 :c8]]) user=> (pprint (reduce (fn f [tree r

Re: Enhanced Primitive Support

2010-06-23 Thread Heinz N. Gies
Other math functions as max, min and so on should behave the same as +, - I think it is kind of confusing if you've a loop with a max and have to cast it to long by hand :) Regards, heinz. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to

Re: STM style disk persistance

2010-06-23 Thread Heinz N. Gies
Not really tried that, but something that goes somewhat in the direction, stupiddb - (see on github or explanations on my blog http://blog.licenser.net ). It is not guaranteed persistent sadly since it's not easy to couple IO and Memory transactions and it might be a bit too heavy for a stupid d