Re: Macro tutorials?

2011-10-06 Thread Stefan Kamphausen
Hi.

You might consider reading Peter Seibel's excellent Practical Common Lisp 
which has some nice macro-work in it. If after that you're still hungry for 
more, consider Let Over Lambda by Doug Hoyte.  

Admitted, both cover Common Lisp, but the differences will not keep you from 
getting a deeper understanding of how macros work and where and how they can 
be used.

(This is more an answer to the subject of this thread, less to the question 
in your body :)

Regards,
Stefan

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Reuse of generic Clojure/ClojureScript code?

2011-10-06 Thread Laurent PETIT
Hmm, I think the maven convention will start to make sense, somehow :

src/main/java/

-

src/main/java/
src/main/clojure/ ; clojure only code (jvm that is)
src/main/clojurescript/ ; clojurescript only code
src/main/clojurescript/ ; shared by clojure or clojurescript : no
bounty, but better name than clojurescript welcome

2011/10/6 Dave Sann daves...@gmail.com:
 If anyone is interested, this is the strategy that I am currently using.
 It's a bit messy with linking but it saves me maintaining multiple versions
 and has worked so far. I expect that the linking could be removed with some
 work upstream. This is a workaround for me until a more standard solution
 comes out.
 I have started to separate code that I believe to be generic form code that
 I believe to be platform specific. It is not always possible to tell due to
 included dependencies, so there may be some trial and error.
 If I am making a project - say 'utils' that I think can be used across clj
 and cljs, I use the following structure:
 I put generic code in src.
 I put jvm specific code in src/utlis/x (namespace utils.x and below)
 I put cljs/js specific code in src_cljs/utils/x (namespace utils.x and
 below)
 Generic code is developed under src and sym-linked into src_cljs - with a
 change in extension to .cljs
 All platform dependent code is in or under the namespace utils.x (I use x
 because it's short and easy to see). This is not crosslinked (obviously).
 I do not use 'cljs' or 'jvm' as the name space for platform specific code.
 Using the same prefix 'x' allows generic code to freely use platform
 specific code provided that it is explicitly implemented to the same API in
 both clj and cljs. This may not always be a reasonable thing to do, but
 where it is it seems effective.
 Nothing special is required beyond this. I use cljs-watch to compile the
 clojurescript by pointing it at the src_cljs directory.
 Cheers
 Dave

 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with your
 first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: goog.net.cookies with clojurescript?

2011-10-06 Thread Jonathan Fischer Friberg
I managed to do it.
The problem is that we need to use the function set in a goog.net.Cookies
object.
There is already such an object, which is called goog.net.cookies, see the
bottom of the source file:

/**
 * A static default instance.
 * @type {goog.net.Cookies}
 */
goog.net.cookies = new goog.net.Cookies(document);

Therefore we need to do

(ns cookies
  (:require [goog.net.cookies :as cks]))

(defn ^:export setcookie []
  (.set goog.net.cookies name content -1))

Which will properly set the cookie (see attachment)


On Wed, Oct 5, 2011 at 11:24 PM, Eric Harris-Braun
zippy.314@gmail.comwrote:

 Has anybody successfully used cookies in clojurescript with
 goog.net.cookies?

 I keep getting this error: 'this.isValidName' [undefined] is not a
 function (Safari) or Uncaught TypeError: Object [object DOMWindow]
 has no method 'isValidName' (Chrome) when I try to set a cookie via
 goog.net.cookies.set.

 Thanks

 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=enattachment: cookie_small.png

Re: Macro tutorials?

2011-10-06 Thread Michael Jaaka
Thanks to all! You have helped a lot!
Also I will consider reading Practical Common Lisp.

On Oct 6, 9:42 am, Stefan Kamphausen ska2...@googlemail.com wrote:
 Hi.

 You might consider reading Peter Seibel's excellent Practical Common Lisp
 which has some nice macro-work in it. If after that you're still hungry for
 more, consider Let Over Lambda by Doug Hoyte.  

 Admitted, both cover Common Lisp, but the differences will not keep you from
 getting a deeper understanding of how macros work and where and how they can
 be used.

 (This is more an answer to the subject of this thread, less to the question
 in your body :)

 Regards,
 Stefan

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


clojure.contrib.base64

2011-10-06 Thread Rok Lenarcic
I use Base64 encoding a lot and the slow implementation is hurting a
lot. It's slower than Sun misc encoder/decoder
and that one is very very slow. I was using Sun's implementation a bit
and it took 80 seconds to encode a 56 MB file.
Then I found this: http://migbase64.sourceforge.net/
It loaded from a disk drive and encoded the same file in 0.3 seconds!
Would it be possible to have Clojure contrib use an implementation
like this and thus enable all Clojure developers to have lightning
fast Base64 encoding/decoding? I know having everything implemented in
clojure is a big thing around here but in case of Base64 encoding and
regular expressions I think the language would benefit greatly by
having implementations which are orders of magnitude faster than
default implementations in java. Did I say regular expressions?
http://www.tusker.org/regex/regex_benchmark.html
Like Rich Hickey said: why should we reinvent file streams and sockets
in each language?
I think the same principle applies to Base64 and regular expressions,
especially when in Clojure we have an opportunity to replace standard
java implementations with ones that are orders of magnitude faster.
What are your views on this?

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Exception handling changes in Clojure 1.3.0

2011-10-06 Thread Rok Lenarcic

On Oct 3, 9:27 pm, Stuart Halloway stuart.hallo...@gmail.com wrote:

 Catching checked exceptions seems to work fine. Try e.g.

 (try (throw (java.io.IOException.)) (catch java.io.IOException _ caught!))

 I suspect something else is going wrong in the GAE example. Can you narrow 
 the code down to a block you can quote in full here?

 Stu

 Stuart Halloway
 Clojure/corehttp://clojure.com

Does this work across function boundaries?
(try (exception-throwing-fn 1 2 3) (catch java.io.IOException _
caught!))

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Exception handling changes in Clojure 1.3.0

2011-10-06 Thread Meikel Brandmeyer (kotarak)
It does.

user= (defn f [] (Class/forName nonexistant))
#'user/f
user= (try (f) (catch ClassNotFoundException e caught!))
caught!

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: clojure.contrib.base64

2011-10-06 Thread Jonathan Fischer Friberg

 thus enable all Clojure developers to have lightning
 fast Base64 encoding/decoding?


This is already possible, if you're using leiningen:
put the file in src/util/ and compile, you can now call it as usual.

On Thu, Oct 6, 2011 at 11:16 AM, Rok Lenarcic rok.lenar...@gmail.comwrote:

 I use Base64 encoding a lot and the slow implementation is hurting a
 lot. It's slower than Sun misc encoder/decoder
 and that one is very very slow. I was using Sun's implementation a bit
 and it took 80 seconds to encode a 56 MB file.
 Then I found this: http://migbase64.sourceforge.net/
 It loaded from a disk drive and encoded the same file in 0.3 seconds!
 Would it be possible to have Clojure contrib use an implementation
 like this and thus enable all Clojure developers to have lightning
 fast Base64 encoding/decoding? I know having everything implemented in
 clojure is a big thing around here but in case of Base64 encoding and
 regular expressions I think the language would benefit greatly by
 having implementations which are orders of magnitude faster than
 default implementations in java. Did I say regular expressions?
 http://www.tusker.org/regex/regex_benchmark.html
 Like Rich Hickey said: why should we reinvent file streams and sockets
 in each language?
 I think the same principle applies to Base64 and regular expressions,
 especially when in Clojure we have an opportunity to replace standard
 java implementations with ones that are orders of magnitude faster.
 What are your views on this?

 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: clojure.contrib.base64

2011-10-06 Thread Meikel Brandmeyer (kotarak)
Hi,

may I ask an heretic question?

When there is a fast migbase64... why not just use that one?

It was always promoted to use existing Java libraries where it made sense. 
Or is clojurescript now changing this stance?

Sincerely
Meikel


-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: clojure.contrib.base64

2011-10-06 Thread Stuart Halloway
 I use Base64 encoding a lot and the slow implementation is hurting a
 lot. It's slower than Sun misc encoder/decoder
 and that one is very very slow. I was using Sun's implementation a bit
 and it took 80 seconds to encode a 56 MB file.
 Then I found this: http://migbase64.sourceforge.net/
 It loaded from a disk drive and encoded the same file in 0.3 seconds!
 Would it be possible to have Clojure contrib use an implementation
 like this and thus enable all Clojure developers to have lightning
 fast Base64 encoding/decoding? I know having everything implemented in
 clojure is a big thing around here but in case of Base64 encoding and
 regular expressions I think the language would benefit greatly by
 having implementations which are orders of magnitude faster than
 default implementations in java. Did I say regular expressions?
 http://www.tusker.org/regex/regex_benchmark.html
 Like Rich Hickey said: why should we reinvent file streams and sockets
 in each language?
 I think the same principle applies to Base64 and regular expressions,
 especially when in Clojure we have an opportunity to replace standard
 java implementations with ones that are orders of magnitude faster.
 What are your views on this?

I too would like a fast base64. There are a few different things we could do:

1. Vet the best Java one and link it from contrib.base64 (and possibly 
deprecate the contrib as well).

2. Approve a base64 lib for inclusion by reference in contribs.

3. Write a fast clojure one (possibly a direct port of the project you link, if 
it is the best).

I have several Clojure projects that ship with no binary dependencies. This is 
a maintenance virtue, which is why I think #3 is important. 

If somebody writes a good one I will fast track getting it into contrib.

Stu


-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: clojure.contrib.base64

2011-10-06 Thread Chas Emerick

On Oct 6, 2011, at 4:44 AM, Jonathan Fischer Friberg wrote:

 thus enable all Clojure developers to have lightning
 fast Base64 encoding/decoding?
 
 This is already possible, if you're using leiningen:
 put the file in src/util/ and compile, you can now call it as usual.

I've used the sun.misc implementations as a matter of course, and just pulled 
migbase64 into my project when performance was a consideration (in a different 
package!).  It is licensed under BSD, so doing so is unambiguously reasonable 
IMO.

I'm not sure I see the (practical) utility of a Clojure reimplementation in 
this case, especially since the API and semantics of any Java implementation 
will be sane (hard to botch a referentially-transparent byte[] = String spec).

- Chas

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: goog.net.cookies with clojurescript?

2011-10-06 Thread Eric Harris-Braun
Thanks Jonathan!  That's it exactly.  I had seen goog.net.cookies
(lowercase) and didn't realize it was an object on which to make the
set call.  I thought in was another namespace in which to make the
function call, thus I had been writing:

.. (:use [goog.net.cookies :as cookie]) ...

and was calling:

(cookie/set name content)

which is what was failing!

Thanks again.

-e

On Oct 6, 6:38 am, Jonathan Fischer Friberg odysso...@gmail.com
wrote:
 I managed to do it.
 The problem is that we need to use the function set in a goog.net.Cookies
 object.
 There is already such an object, which is called goog.net.cookies, see the
 bottom of the source file:

 /**
  * A static default instance.
  * @type {goog.net.Cookies}
  */
 goog.net.cookies = new goog.net.Cookies(document);

 Therefore we need to do

 (ns cookies
   (:require [goog.net.cookies :as cks]))

 (defn ^:export setcookie []
   (.set goog.net.cookies name content -1))

 Which will properly set the cookie (see attachment)

 On Wed, Oct 5, 2011 at 11:24 PM, Eric Harris-Braun
 zippy.314@gmail.comwrote:



  Has anybody successfully used cookies in clojurescript with
  goog.net.cookies?

  I keep getting this error: 'this.isValidName' [undefined] is not a
  function (Safari) or Uncaught TypeError: Object [object DOMWindow]
  has no method 'isValidName' (Chrome) when I try to set a cookie via
  goog.net.cookies.set.

  Thanks

  --
  You received this message because you are subscribed to the Google
  Groups Clojure group.
  To post to this group, send email to clojure@googlegroups.com
  Note that posts from new members are moderated - please be patient with
  your first post.
  To unsubscribe from this group, send email to
  clojure+unsubscr...@googlegroups.com
  For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en



  cookie_small.png
 39KViewDownload

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: clojure.contrib.base64

2011-10-06 Thread Aaron Bedra
This actually introduces an opportunity for a much larger set of utilities.

clojure.data.crypto

base64 is part of this idea anyways, and putting it in place along with
nice wrappers around the messy java crypto bits I think could provide a
significant win.  I have had to do this several times now and it would
be great to have in the future. The thing that always pushed me away was
relying on sun.misc when all of the jdks don't have it. 

Cheers,

Aaron Bedra
--
Clojure/core
http://clojure.com

On 10/06/2011 08:07 AM, Stuart Halloway wrote:
 I use Base64 encoding a lot and the slow implementation is hurting a
 lot. It's slower than Sun misc encoder/decoder
 and that one is very very slow. I was using Sun's implementation a bit
 and it took 80 seconds to encode a 56 MB file.
 Then I found this: http://migbase64.sourceforge.net/
 It loaded from a disk drive and encoded the same file in 0.3 seconds!
 Would it be possible to have Clojure contrib use an implementation
 like this and thus enable all Clojure developers to have lightning
 fast Base64 encoding/decoding? I know having everything implemented in
 clojure is a big thing around here but in case of Base64 encoding and
 regular expressions I think the language would benefit greatly by
 having implementations which are orders of magnitude faster than
 default implementations in java. Did I say regular expressions?
 http://www.tusker.org/regex/regex_benchmark.html
 Like Rich Hickey said: why should we reinvent file streams and sockets
 in each language?
 I think the same principle applies to Base64 and regular expressions,
 especially when in Clojure we have an opportunity to replace standard
 java implementations with ones that are orders of magnitude faster.
 What are your views on this?
 I too would like a fast base64. There are a few different things we could do:

 1. Vet the best Java one and link it from contrib.base64 (and possibly 
 deprecate the contrib as well).

 2. Approve a base64 lib for inclusion by reference in contribs.

 3. Write a fast clojure one (possibly a direct port of the project you link, 
 if it is the best).

 I have several Clojure projects that ship with no binary dependencies. This 
 is a maintenance virtue, which is why I think #3 is important. 

 If somebody writes a good one I will fast track getting it into contrib.

 Stu



-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


how to use record as a value

2011-10-06 Thread Razvan Rotaru
Hi,

I want to instantiate a record, but having the record type as value at
runtime.

Example:
(defrecord car [year manufacturere])
(defrecord bike [year manufacturere])
(defrecord boat [year manufacturer])

I want to do (new stuff 1982 Mercedes), but having the record type
kept in the variable stuff. Something like:

(let [stuff car]
  (new stuff 1982 Mercedes))

(let [stuff bike]
  (new stuff 1990 Harley Davidson))

Obviously new does not work. I'm gratefull for suggestions of how to
do it best.

Thanks,
Razvan

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: how to use record as a value

2011-10-06 Thread Aaron Bedra
Assuming you want to do things with the record later, why not just
create it in the let binding

(let [foo (-car 1982 Mercedes)]
  ...)

or

(let [foo (car. 1982 Mercedes)]
  ...)

or even

(let [foo (map-car {:year 1982 :manufacturer Mercedes})]
  ...)

or if you must

(let [foo #user.car{:year 1982 :manufacturer Mercedes}]
  ...)

Cheers,

Aaron Bedra
--
Clojure/core
http://clojure.com

On 10/06/2011 01:27 PM, Razvan Rotaru wrote:
 Hi,

 I want to instantiate a record, but having the record type as value at
 runtime.

 Example:
 (defrecord car [year manufacturere])
 (defrecord bike [year manufacturere])
 (defrecord boat [year manufacturer])

 I want to do (new stuff 1982 Mercedes), but having the record type
 kept in the variable stuff. Something like:

 (let [stuff car]
   (new stuff 1982 Mercedes))

 (let [stuff bike]
   (new stuff 1990 Harley Davidson))

 Obviously new does not work. I'm gratefull for suggestions of how to
 do it best.

 Thanks,
 Razvan


-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: how to use record as a value

2011-10-06 Thread Bronsa
is it -record just a shortrand for record.?

2011/10/6 Aaron Bedra aaron.be...@gmail.com

 Assuming you want to do things with the record later, why not just
 create it in the let binding

 (let [foo (-car 1982 Mercedes)]
  ...)

 or

 (let [foo (car. 1982 Mercedes)]
  ...)

 or even

 (let [foo (map-car {:year 1982 :manufacturer Mercedes})]
  ...)

 or if you must

 (let [foo #user.car{:year 1982 :manufacturer Mercedes}]
  ...)

 Cheers,

 Aaron Bedra
 --
 Clojure/core
 http://clojure.com

 On 10/06/2011 01:27 PM, Razvan Rotaru wrote:
  Hi,
 
  I want to instantiate a record, but having the record type as value at
  runtime.
 
  Example:
  (defrecord car [year manufacturere])
  (defrecord bike [year manufacturere])
  (defrecord boat [year manufacturer])
 
  I want to do (new stuff 1982 Mercedes), but having the record type
  kept in the variable stuff. Something like:
 
  (let [stuff car]
(new stuff 1982 Mercedes))
 
  (let [stuff bike]
(new stuff 1990 Harley Davidson))
 
  Obviously new does not work. I'm gratefull for suggestions of how to
  do it best.
 
  Thanks,
  Razvan
 

 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en


-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: how to use record as a value

2011-10-06 Thread Razvan Rotaru
Wow, that was fast. Thanks.

This could work but only partially.

(let [stuff car]
  (new stuff 1982 Mercedes)
  (new stuff 2001 Seat)
  ...)

I could take advantage of the fact that records are maps:
(let [stuff (car. 1982 Mercedes)]
   ... use Mercedes...
   (assoc stuff :year 2001 :manufacturer Seat))

But this will work only if all my types have the same parameters. If
bike would be:

(defrecord bike [manufacturer year type])

then i'm stuck again.

Razvan

On Oct 6, 8:32 pm, Aaron Bedra aaron.be...@gmail.com wrote:
 Assuming you want to do things with the record later, why not just
 create it in the let binding

 (let [foo (-car 1982 Mercedes)]
   ...)

 or

 (let [foo (car. 1982 Mercedes)]
   ...)

 or even

 (let [foo (map-car {:year 1982 :manufacturer Mercedes})]
   ...)

 or if you must

 (let [foo #user.car{:year 1982 :manufacturer Mercedes}]
   ...)

 Cheers,

 Aaron Bedra
 --
 Clojure/corehttp://clojure.com

 On 10/06/2011 01:27 PM, Razvan Rotaru wrote:







  Hi,

  I want to instantiate a record, but having the record type as value at
  runtime.

  Example:
  (defrecord car [year manufacturere])
  (defrecord bike [year manufacturere])
  (defrecord boat [year manufacturer])

  I want to do (new stuff 1982 Mercedes), but having the record type
  kept in the variable stuff. Something like:

  (let [stuff car]
    (new stuff 1982 Mercedes))

  (let [stuff bike]
    (new stuff 1990 Harley Davidson))

  Obviously new does not work. I'm gratefull for suggestions of how to
  do it best.

  Thanks,
  Razvan

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: clojure.contrib.base64

2011-10-06 Thread Allen Johnson
Just wanted to add the Apache commons codec has a base64
encoder/decoder. With a quick test I was able to encode a ~100MB file
in 2.3sec. Example code below:

In leiningen: [commons-codec 1.4]

(require '[clojure.java.io :as io])
(import '[org.apache.commons.codec.binary Base64OutputStream])

(defn encode [src dest]
  (with-open [in (io/input-stream src)
   out (- dest (io/output-stream) (Base64OutputStream.)))]
(io/copy in out :buffer-size 8192)))

(.length (io/file /tmp/blob))
= 99667238

(time (encode /tmp/blob /tmp/output))
= Elapsed time: 2254.521259 msecs

org.apache.commons.codec.binary.Base64 has helper methods as well.

Allen

On Thu, Oct 6, 2011 at 1:27 PM, Aaron Bedra aaron.be...@gmail.com wrote:
 This actually introduces an opportunity for a much larger set of utilities.

 clojure.data.crypto

 base64 is part of this idea anyways, and putting it in place along with
 nice wrappers around the messy java crypto bits I think could provide a
 significant win.  I have had to do this several times now and it would
 be great to have in the future. The thing that always pushed me away was
 relying on sun.misc when all of the jdks don't have it.

 Cheers,

 Aaron Bedra
 --
 Clojure/core
 http://clojure.com

 On 10/06/2011 08:07 AM, Stuart Halloway wrote:
 I use Base64 encoding a lot and the slow implementation is hurting a
 lot. It's slower than Sun misc encoder/decoder
 and that one is very very slow. I was using Sun's implementation a bit
 and it took 80 seconds to encode a 56 MB file.
 Then I found this: http://migbase64.sourceforge.net/
 It loaded from a disk drive and encoded the same file in 0.3 seconds!
 Would it be possible to have Clojure contrib use an implementation
 like this and thus enable all Clojure developers to have lightning
 fast Base64 encoding/decoding? I know having everything implemented in
 clojure is a big thing around here but in case of Base64 encoding and
 regular expressions I think the language would benefit greatly by
 having implementations which are orders of magnitude faster than
 default implementations in java. Did I say regular expressions?
 http://www.tusker.org/regex/regex_benchmark.html
 Like Rich Hickey said: why should we reinvent file streams and sockets
 in each language?
 I think the same principle applies to Base64 and regular expressions,
 especially when in Clojure we have an opportunity to replace standard
 java implementations with ones that are orders of magnitude faster.
 What are your views on this?
 I too would like a fast base64. There are a few different things we could do:

 1. Vet the best Java one and link it from contrib.base64 (and possibly 
 deprecate the contrib as well).

 2. Approve a base64 lib for inclusion by reference in contribs.

 3. Write a fast clojure one (possibly a direct port of the project you link, 
 if it is the best).

 I have several Clojure projects that ship with no binary dependencies. This 
 is a maintenance virtue, which is why I think #3 is important.

 If somebody writes a good one I will fast track getting it into contrib.

 Stu



 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with your 
 first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: how to use record as a value

2011-10-06 Thread Meikel Brandmeyer
Hi,

use the factory function.

Clojure 1.3.0
user= (defrecord car [year manufacturer])
user.car
user= (defn create [stuff] (stuff 1982 Mercedes Benz))
#'user/create
user= (create -car)
#user.car{:year 1982, :manufacturer Mercedes Benz}

You can't pass car. around at runtime because it is a class. And instantiating 
a class is hard-wired in the byte code. Hence the actual class must be known at 
compile time. -car however is a normal clojure function. So you can pass it 
around as you like.

Sincerely
Meikel

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Faster JSON library

2011-10-06 Thread Lars Nilsson
The clojure.contrib.base64 discussion has inspired me (sorry!) to
write this.. I would very much like to see a faster JSON parser be in
contrib. clj-json can beat clojure.data.json by up to a factor of 140x
when reading/parsing and 5x when creating a JSON string.

clojure.data.json reading:

(dotimes [_ 5] (time (read-json (slurp foo.json
Elapsed time: 105137.039484 msecs
Elapsed time: 109517.590644 msecs
Elapsed time: 114940.018075 msecs
Elapsed time: 107612.194846 msecs
Elapsed time: 104434.230607 msecs
nil

clj-json reading:

(dotimes [_ 5] (time (parse-string (slurp foo.json) true)))
Elapsed time: 851.541746 msecs
Elapsed time: 716.894466 msecs
Elapsed time: 713.257132 msecs
Elapsed time: 710.379671 msecs
Elapsed time: 709.358592 msecs
nil

clojure.data.json create string:

(def foo (read-json (slurp foo.json)))
(dotimes [_ 5] (time (json-str foo)))
Elapsed time: 1546.511918 msecs
Elapsed time: 1533.056017 msecs
Elapsed time: 1534.136322 msecs
Elapsed time: 1537.893503 msecs
Elapsed time: 1555.343765 msecs
nil

clj-json create string:

(def foo (parse-string (slurp foo.json)))
(dotimes [_ 5] (time (generate-string foo)))
Elapsed time: 375.415311 msecs
Elapsed time: 298.440444 msecs
Elapsed time: 272.829368 msecs
Elapsed time: 271.800466 msecs
Elapsed time: 273.67808 msecs
nil

The JSON file is about 217KB, with vectors containing a couple of
thousand JSON objects with nested vector objects between 2-6 levels
deep.

Granted, clj-json uses a (presumably heavily optimized) Java library
as the work horse, while clojure.data.json is pure Clojure. However, I
feel the speed penalty is too big of a price to pay in this case. Now,
I can use clj-json for my own parsing needs. However, something like
clutch (couchdb library) that uses c.d.json behind the scenes may be
paying a price in performance that I cannot easily overcome without
hacking around inside it in order to swap JSON implementation, rather
than tweaking my own code (although, in this case it may be limited to
just the JSON string creation).

Perhaps there are benefits (of which I'm not aware) to c.d.json that
are not available in clj-json, but I'd be hard-pressed to come up with
a scenario where I wouldn't pick the significant speed boost of
clj-json.

Lars Nilsson

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: how to use record as a value

2011-10-06 Thread Razvan Rotaru
This is what I'm looking for. Thanks. I have not seen this kind of
expression before: -foo. Is is created by defrecord or is it
implemented at reader level?

I realize now that I can also keep a generating function in the
variable stuff:

(let [stuff #(car. %1 %2)]
  (stuff 1982 Mercedes)
  (stuff 2011 Seat))

But keeping the actual constructor is of course better.

RR


On Oct 6, 8:56 pm, Meikel Brandmeyer m...@kotka.de wrote:
 Hi,

 use the factory function.

 Clojure 1.3.0
 user= (defrecord car [year manufacturer])
 user.car
 user= (defn create [stuff] (stuff 1982 Mercedes Benz))
 #'user/create
 user= (create -car)
 #user.car{:year 1982, :manufacturer Mercedes Benz}

 You can't pass car. around at runtime because it is a class. And 
 instantiating a class is hard-wired in the byte code. Hence the actual class 
 must be known at compile time. -car however is a normal clojure function. So 
 you can pass it around as you like.

 Sincerely
 Meikel

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: clojure.contrib.base64

2011-10-06 Thread Rok Lenarcic
Sure, I can use that file. This DIY attitude doesn't benefit the
beginners. I can add and use that java, but 90% of clojure users will
use the clojure contrib function and 9% will use faster sun encoder,
because people don't know that Sun's implementations are slow and that
better ones are available. I see little reason for not making these
implementations default, rather than requiring the user to know about
existence of obscure libraries, in java no less.

On Oct 6, 1:50 pm, Meikel Brandmeyer (kotarak) m...@kotka.de
wrote:
 Hi,

 may I ask an heretic question?

 When there is a fast migbase64... why not just use that one?

 It was always promoted to use existing Java libraries where it made sense.
 Or is clojurescript now changing this stance?

 Sincerely
 Meikel

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


The Website / Wikispaces

2011-10-06 Thread Simon Morgan
When using clojure.org does anybody else quite frequently get the
Wikispaces homepage instead? This seems to happen most often when I
start Firefox because I always have a clojure.org tab open. Any idea
what's causing this?

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: clojure.contrib.base64

2011-10-06 Thread Alexander Taggart
I threw a base64 encoder together a while ago when playing with the new 
primitive stuff.  Interesting to note that it is faster than the one in 
Apache commons-codec.

https://github.com/ataggart/codec/blob/master/src/codec/base64.clj

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: clojure.contrib.base64

2011-10-06 Thread Ray Miller
On 6 October 2011 18:27, Aaron Bedra aaron.be...@gmail.com wrote:
 This actually introduces an opportunity for a much larger set of utilities.

 clojure.data.crypto

 base64 is part of this idea anyways, and putting it in place along with
 nice wrappers around the messy java crypto bits I think could provide a
 significant win.

I wrote a little wrapper around java.security.MessageDigest a few weeks ago:

  https://github.com/ray1729/clj-message-digest

(also available on Clojars). This was inspired by Perl's Digest::MD5
module and  provides md5, md5-hex, md5-base64 etc. functions.

Incidentally, I used the Apache Commons Base64 encoder, as the one in
contrib was producing different results from the Apache Commons and
Perl implementations. Perhaps a bug?

Ray.

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: clojure.contrib.base64

2011-10-06 Thread Stuart Halloway
 I threw a base64 encoder together a while ago when playing with the new 
 primitive stuff.  Interesting to note that it is faster than the one in 
 Apache commons-codec.
 
 https://github.com/ataggart/codec/blob/master/src/codec/base64.clj

Do you want to make this the basis for an improved contrib?

One thing I would like to see is a call that takes bytes,offset,length. When I 
care about fast I also care about not being forced to do an arraycopy.

Stu


Stuart Halloway
Clojure/core
http://clojure.com

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Exception handling changes in Clojure 1.3.0

2011-10-06 Thread Kevin Downey
On Thu, Oct 6, 2011 at 4:39 AM, Meikel Brandmeyer (kotarak) m...@kotka.de 
wrote:
 It does.

 user= (defn f [] (Class/forName nonexistant))
 #'user/f
 user= (try (f) (catch ClassNotFoundException e caught!))
 caught!

the problem is in Reflector.java and the call to Class/forName is
non-reflective, so of course it doesn't expose the problem.


 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with your
 first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en



-- 
And what is good, Phaedrus,
And what is not good—
Need we ask anyone to tell us these things?

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: clojure.contrib.base64

2011-10-06 Thread Alexander Taggart
Sure, I'll start working on it.  Do you want it to be worked on in a contrib 
project or just submit it once it's functional?  Also, I assume you'd want 
this to work with 1.2, right?

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: The Website / Wikispaces

2011-10-06 Thread Jonathan Fischer Friberg
I do

On Thu, Oct 6, 2011 at 2:32 PM, Simon Morgan s...@spamcop.net wrote:

 When using clojure.org does anybody else quite frequently get the
 Wikispaces homepage instead? This seems to happen most often when I
 start Firefox because I always have a clojure.org tab open. Any idea
 what's causing this?

 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en


-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: how to use record as a value

2011-10-06 Thread Alan Malloy
-foo is new in 1.3. I'm surprised so many people are recommending it
without mentioning that. -foo is like foo., except that it's a real
clojure function and as such can be passed as a function; you can call
apply on it; and so forth.

On Oct 6, 11:05 am, Razvan Rotaru razvan.rot...@gmail.com wrote:
 This is what I'm looking for. Thanks. I have not seen this kind of
 expression before: -foo. Is is created by defrecord or is it
 implemented at reader level?

 I realize now that I can also keep a generating function in the
 variable stuff:

 (let [stuff #(car. %1 %2)]
   (stuff 1982 Mercedes)
   (stuff 2011 Seat))

 But keeping the actual constructor is of course better.

 RR

 On Oct 6, 8:56 pm, Meikel Brandmeyer m...@kotka.de wrote:







  Hi,

  use the factory function.

  Clojure 1.3.0
  user= (defrecord car [year manufacturer])
  user.car
  user= (defn create [stuff] (stuff 1982 Mercedes Benz))
  #'user/create
  user= (create -car)
  #user.car{:year 1982, :manufacturer Mercedes Benz}

  You can't pass car. around at runtime because it is a class. And 
  instantiating a class is hard-wired in the byte code. Hence the actual 
  class must be known at compile time. -car however is a normal clojure 
  function. So you can pass it around as you like.

  Sincerely
  Meikel

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: clojure.contrib.base64

2011-10-06 Thread Stuart Halloway
 Sure, I'll start working on it.  Do you want it to be worked on in a contrib 
 project or just submit it once it's functional?  

Whatever works best for you.

 Also, I assume you'd want this to work with 1.2, right?

I won't personally need that. Plus, this is the kind of lib where the code 
would differ substantially. Your call, though.

Thanks,
Stu

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Problem Running ClojureScript on OpenJDK

2011-10-06 Thread Volker Schlecht
Master works like  a charm now - Thanks!!

On Oct 4, 5:44 am, db donald.bl...@gmail.com wrote:
 Works for me.  Thanks.

 On Oct 3, 10:15 am, Brenton bashw...@gmail.com wrote:







  If you have been having problems the ClojureScript andOpenJDK, please
  try the current master branch of ClojureScript.

  I would be interested to know what problems still remain, if any,
  after these changes.

  On Oct 2, 11:07 pm, db donald.bl...@gmail.com wrote:

   Here's what the patch looks like foropenjdk-6 with the latest master,
   where the mozilla-specific lines have moved to the rhino.js file:

   diff --git a/src/clj/cljs/repl/rhino.clj b/src/clj/cljs/repl/rhino.clj
   index cbe4f2a..15c5bf1 100644
   --- a/src/clj/cljs/repl/rhino.clj
   +++ b/src/clj/cljs/repl/rhino.clj
   @@ -27,6 +27,7 @@ goog.require = function(rule)
   {Packages.clojure.lang.RT[\var\
              linenum (or line Integer/MIN_VALUE)
              ctx (sun.org.mozilla.javascript.Context/enter)]
          (try
   +        (.setOptimizationLevel ctx -1)
            {:status :success
             :value (.evaluateString ctx (:global repl-env) js filename
   linenum nil
            (finally

   This works for me on openjdk6, but will not work on openjdk7 because
   it doesn't ship with Rhino.  For openjdk7, it looks like a separate
   version of Rhino needs to be downloaded.

   On Oct 2, 4:36 pm, Stefan Kamphausen ska2...@googlemail.com wrote:

Hi,

I hope, people are aware that Oracle considersOpenJDKto be the standard
choice for Linux users now and removed the special distributor's 
license.  
Seehttp://robilad.livejournal.com/90792.html

Kind regards,
Stefan

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Reuse of generic Clojure/ClojureScript code?

2011-10-06 Thread pmbauer
Do you know if that solution will extend to sharing clojure core libraries 
where that makes sense (a lot of copy-n-pasted code in 
[core|set|string|walk|zip].cljs)?

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Leiningen Local Repositories

2011-10-06 Thread Michał Marczyk
Hi!

Issue #287 [1] seems related to this.

I've posted a description of a possible use of unquote in defproject
for doing things like

(defproject ...
  ;; private-repo-info comes from ~/.lein/init.clj
  :repositories ~(user/private-repo-info))

as a comment on the issue.

Sincerely,
Michał


[1] https://github.com/technomancy/leiningen/issues/287

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Faster JSON library

2011-10-06 Thread Tal Liron
An excellent JVM library to use as base is Jackson:

http://jackson.codehaus.org/

It would be wonderful to see a Clojure-friendly version of it: having it 
create Clojure-specific structures from JSON, and also recognizing Clojure 
deftypes for serialization. The streaming API is friendly enough that I can 
see it being relatively easy.

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Faster JSON library

2011-10-06 Thread David Nolen
clj-json uses Jackson and so does https://github.com/dakrone/cheshire

On Thu, Oct 6, 2011 at 8:07 PM, Tal Liron tal.li...@gmail.com wrote:

 An excellent JVM library to use as base is Jackson:

 http://jackson.codehaus.org/

 It would be wonderful to see a Clojure-friendly version of it: having it
 create Clojure-specific structures from JSON, and also recognizing Clojure
 deftypes for serialization. The streaming API is friendly enough that I can
 see it being relatively easy.

  --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en


-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Faster JSON library

2011-10-06 Thread Phil Hagelberg
On Thu, Oct 6, 2011 at 5:07 PM, Tal Liron tal.li...@gmail.com wrote:
 An excellent JVM library to use as base is Jackson:

 http://jackson.codehaus.org/

 It would be wonderful to see a Clojure-friendly version of it

Both clj-json and cheshire (https://github.com/dakrone/cheshire) are
actually already based on Jackson.

 I can use clj-json for my own parsing needs. However, something like
 clutch (couchdb library) that uses c.d.json behind the scenes may be
 paying a price in performance

Seems a bit silly if someone's just choosing a slower implementation
just because it's in contrib. I suspect the author of Cheshire may
have plenty of good reasons for not wanting to put his library in
contrib, including the fact that its deps might not line up with
contrib policy, wanting to accept patches without making contributors
mail in paperwork, and wanting to use a better bug tracker than Jira.

-Phil

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Faster JSON library

2011-10-06 Thread Tal Liron
Cheshire looks great, thanks for the tip!

I wonder, then, what's the OP's problem? I think it's good to have a 
lightweight, 100% Clojure version of JSON in contrib. A lighter weight is 
often a higher priority than performance. I think both approaches have their 
place.

In the Java world, too, there's the option of using the slower, simpler 
reference implementation of JSON.

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Faster JSON library

2011-10-06 Thread Lars Nilsson
As I mentioned in my previous email, my problem isn't really picking a
JSON implementation for my own needs, but rather when I use a library
that uses a slower implementation. If I wanted to use clutch for
couchdb access and didn't pay too much attention as to what leiningen
pulls in, I wouldn't know from looking at its API that c.d.json is
used, only if I checked what was stuffed in lib, or started looking at
its source. I could go ahead and use clj-json all day long within my
own code, but whenever I call a clutch function that involves reading
or writing JSON I would not have any say in the matter (unless I dig
into its code and make changes, rather than work on my own..) I cloned
clutch in github with the intent of playing around with swapping in
clj-json to see what difference it makes in practice, but it's not
what I'd like to work on at the moment, ideally.

Lars Nilsson

On Thu, Oct 6, 2011 at 8:20 PM, Tal Liron tal.li...@gmail.com wrote:
 Cheshire looks great, thanks for the tip!

 I wonder, then, what's the OP's problem? I think it's good to have a
 lightweight, 100% Clojure version of JSON in contrib. A lighter weight is
 often a higher priority than performance. I think both approaches have their
 place.

 In the Java world, too, there's the option of using the slower, simpler
 reference implementation of JSON.

 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with your
 first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Reuse of generic Clojure/ClojureScript code?

2011-10-06 Thread Dave Sann
fair enough.

Is there any support for this at the moment?

My only comment would be that it is quite handy to know that you have 
imported code that might be platform specific.

It also seems reasonable that pure clojure code might be used by the .net 
version.


Cheers

Dave

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Reuse of generic Clojure/ClojureScript code?

2011-10-06 Thread Dave Sann
I don't see why not, in principle. 

However, from my perspective when compiling at the moment, these are already 
taken care of. 
So I have not looked into this side of things.

I think that it would need some thought to get the best solution.

Cheers

D

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Faster JSON library

2011-10-06 Thread Dave Sann
In my opinion, the situation is not clear cut:
  I might want a slower but more portable library if porting clutch to 
clojurescript. 
  (I read that someone has this working...)
  I might just want a lib that works if moving to .net in the short term but 
optimise with a faster library later. 
  Or, I might want a fast JVM specific library

Json parsing and writing has a relatively simple API/interface so different 
implementations of the same api are not unexpected.

So I have two thoughts:

1. Assuming a standard API. How can you practically choose between different 
implementations that trade off different characteristics depending on your 
need. For example: performance vs portability; or performance on certain 
problem types vs others.

2. How many libraries might have a standard API with different 
implementations. (is it worth expending time to address this?)

In general, this is a potentially tricky question in respect of dependency 
management.

Cheers

Dave

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Faster JSON library

2011-10-06 Thread Meikel Brandmeyer (kotarak)
Hi,

slf4j comes to mind. Have a standard API which is provided by the different 
libraries. If you were targeting clojurescript you'd specify the portable 
library. For a server application running on the JVM you'd specify a fast 
Jackson-based implementation. This leaves the choice to the user of the 
library. What she specifies in her project dependencies is used.

Welcome to the paradox of choice.

Sincerely
Meikel

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en