Re: can I force the JIT to be called immediately for certain pieces of code after it starts executing with out waiting for the JVM realize it is necessary....

2011-01-02 Thread Konrad Hinsen

On 2 Jan 2011, at 03:29, Sunil S Nandihalli wrote:

 can I force the JIT to be called immediately for certain pieces of  
code after it starts executing with out waiting for the JVM realize  
it is necessary? I would not mind jitting the whole code ..  
Actually I don't mind waiting a few extra seconds at the start since  
actual run-time for the program could be a couple of hundred  
minutes...


 Is startup time the only reason why the whole code is not jitted  
immediately.. ?


No. JIT compilation is based on run-time profiles of the code, so it  
requires information that is not available before starting the  
program. To given an example, if a method is called frequently with a  
specific argument type, a specialized version can be compiled.


In terms of total runtime there wouldn't be much to gain anyway from  
compiling upfront. All you'd gain is a more uniform cost of function  
calls. But why care unless you need real-time performance - and then  
you shouldn't be using a JVM language anyway.


Konrad.

--
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: ANN: Gloss, a byte-format DSL

2011-01-02 Thread pepijn (aka fliebel)
Hi,

Thanks for helping out. After using codecs rather than frames, I get
even weirder errors.

My code now gives me: java.lang.Exception: Cannot evenly divide bytes
into sequence of frames.

Hard coding the header followed by a terminating :byte works as it
should:

(decode (compile-frame [tag tstring (header tag (memoize #(compile-
frame [(name %) tstring (get-tag %)])) (comp symbol first)) :byte])
data)
[:compound "hello world" ["string" "name" "Bananrama"] 0]

So the problem seems to be with the repeated. Investigating that, I
copied an example from the introduction page, and this is the result:
(defcodec t (repeated (string :utf-8 :delimiters ["\n"]) :delimiters
["\0"]))
(encode t ["foo" "bar" "baz"])
java.lang.IllegalArgumentException: Don't know how to create ISeq
from: java.nio.HeapByteBuffer
((#
#)
(#
#)

But on the other hand:
(decode t (.getBytes "blabla\nhihi\ng\n\0"))
["blabla" "hihi" "g"]

This gives me the same error as my code, but since the header in my
code seems correct, I don't see why it has leftover bytes.
(decode t (.getBytes "blabla\nhihi\ng\0"))
java.lang.Exception: Cannot evenly divide bytes into sequence of
frames.

By the way, is there an easy way to get something readable out of
encode? Like Unix hexdump, or even just a seq of integers. Debugging
is a weak point in Gloss so far, if you ask me.

Thanks!

Pepijn de Vos

On Jan 1, 10:47 pm, Zach Tellman  wrote:
> The header->body function in (header ...) must return a codec, so you
> need to call compile-frame on the vector you're generating.  Since you
> don't want to call compile-frame every time you decode a frame, you
> can memoize the function.  A version that does both can be found 
> athttps://gist.github.com/762031.
>
> I agree that the way the enumeration and types are blurred in your
> code is a little confusing.  You could create a stronger distinction
> by calling your enumerated types :tag-byte, :tag-int32, etc, and then
> defining a map from those tags onto :byte, :int32, and so on.
>
> Zach
>
> On Jan 1, 1:01 pm, "pepijn (aka fliebel)" 
> wrote:
>
>
>
>
>
>
>
> > Hey,
>
> > I am trying Gloss for reading NBT [1] files.
>
> > First thing I did like is that it seems to make things real easy.
> > First thing I did not like is the weak separation between types
> > like :byte and extra data like :foo.
>
> > I think I'm nearly done with the NBT reader [2], but I ran into a
> > problem. Whatever I put in the header form, I get exceptions like
> > this:
>
> > java.lang.IllegalArgumentException: No implementation of
> > method: :sizeof of protocol: #'gloss.core.protocols/Writer found for
> > class: clojure.lang.PersistentVector
>
> > Only thing it mentions in the stacktrace [3] is methods on a reify,
> > which calls the same method again, or in the most recent case, just
> > return nil.
>
> > [1]http://www.minecraft.net/docs/NBT.txt
> > [2]https://gist.github.com/761997
> > [3]http://pastebin.com/AqrsbjuS
>
> > On Nov 28 2010, 8:14 pm, Zach Tellman  wrote:
>
> > > You're right, that's an omission from the frame syntax.  I'll add the
> > > ability for all or part of the frame to be scoped as (little-
> > > endian ...) and (big-endian ...), with big-endian as the default.
>
> > > Just as a side-note, though, Calx [1] is already handling little-
> > > endian data by using encode-to-buffer, where it's writing to a buffer
> > > whose endianness has been preset.   This obviously isn't a general
> > > solution, but just thought I'd point it out.
>
> > > Zach
>
> > > [1]https://github.com/ztellman/calx
>
> > > On Nov 28, 8:50 am, zoka  wrote:
>
> > > > If Gloss is to decode incoming packet (byte array) in little-endian
> > > > format it is straightforward:
> > > > Wrap byte array into ByteBuffer b, invoke b.order(LITTLE_ENDIAN) and
> > > > pass b to decode function that will return Clojure map of decoded
> > > > values.
>
> > > > However, when outgoing packet byte array is to be produced from map of
> > > > values, encode function will always return ByteBuffer in default big-
> > > > endian format, so resulting byte array extracted form ByteBuffer using
> > > > get() method will be incorrect.
>
> > > > If Gloss is to support little-endian frames, it seems that endianness
> > > > needs to be part of frame definition. In that case Gloss decode fun
> > > > would refuse to accept ByteBuffers with wrong order() and encode fun
> > > > will always generate the correct result.
>
> > > > Zoka
>
> > > > On Nov 25, 3:00 am, Zach Tellman  wrote:
>
> > > > > ByteBuffers have an order() method which allows you to toggle the
> > > > > endianness.  I haven't tested this, but since everything is built on
> > > > > top of Java's ByteBuffer functionality it should be fine as long as
> > > > > the ByteBuffers are correctly set and correctly ordered with respect
> > > > > to each other.
>
> > > > > Zach
>
> > > > > On Nov 23, 2:52 pm, zoka  wrote:
>
> > > > > > JVM stores numbers in in big endian format - is there a way to 
> > > > > > proces

Re: ANN: Gloss, a byte-format DSL

2011-01-02 Thread pepijn (aka fliebel)
Okay, clicked send to early. The header also contains 0-bytes, so the
repeated stops 'mid-sentence' and tries to balance things. Is there
any way Gloss can handle nested structures like this?

On Jan 2, 12:20 pm, "pepijn (aka fliebel)" 
wrote:
> Hi,
>
> Thanks for helping out. After using codecs rather than frames, I get
> even weirder errors.
>
> My code now gives me: java.lang.Exception: Cannot evenly divide bytes
> into sequence of frames.
>
> Hard coding the header followed by a terminating :byte works as it
> should:
>
> (decode (compile-frame [tag tstring (header tag (memoize #(compile-
> frame [(name %) tstring (get-tag %)])) (comp symbol first)) :byte])
> data)
> [:compound "hello world" ["string" "name" "Bananrama"] 0]
>
> So the problem seems to be with the repeated. Investigating that, I
> copied an example from the introduction page, and this is the result:
> (defcodec t (repeated (string :utf-8 :delimiters ["\n"]) :delimiters
> ["\0"]))
> (encode t ["foo" "bar" "baz"])
> java.lang.IllegalArgumentException: Don't know how to create ISeq
> from: java.nio.HeapByteBuffer
> ((#
> #)
> (#
> #)
>
> But on the other hand:
> (decode t (.getBytes "blabla\nhihi\ng\n\0"))
> ["blabla" "hihi" "g"]
>
> This gives me the same error as my code, but since the header in my
> code seems correct, I don't see why it has leftover bytes.
> (decode t (.getBytes "blabla\nhihi\ng\0"))
> java.lang.Exception: Cannot evenly divide bytes into sequence of
> frames.
>
> By the way, is there an easy way to get something readable out of
> encode? Like Unix hexdump, or even just a seq of integers. Debugging
> is a weak point in Gloss so far, if you ask me.
>
> Thanks!
>
> Pepijn de Vos
>
> On Jan 1, 10:47 pm, Zach Tellman  wrote:
>
>
>
>
>
>
>
> > The header->body function in (header ...) must return a codec, so you
> > need to call compile-frame on the vector you're generating.  Since you
> > don't want to call compile-frame every time you decode a frame, you
> > can memoize the function.  A version that does both can be found 
> > athttps://gist.github.com/762031.
>
> > I agree that the way the enumeration and types are blurred in your
> > code is a little confusing.  You could create a stronger distinction
> > by calling your enumerated types :tag-byte, :tag-int32, etc, and then
> > defining a map from those tags onto :byte, :int32, and so on.
>
> > Zach
>
> > On Jan 1, 1:01 pm, "pepijn (aka fliebel)" 
> > wrote:
>
> > > Hey,
>
> > > I am trying Gloss for reading NBT [1] files.
>
> > > First thing I did like is that it seems to make things real easy.
> > > First thing I did not like is the weak separation between types
> > > like :byte and extra data like :foo.
>
> > > I think I'm nearly done with the NBT reader [2], but I ran into a
> > > problem. Whatever I put in the header form, I get exceptions like
> > > this:
>
> > > java.lang.IllegalArgumentException: No implementation of
> > > method: :sizeof of protocol: #'gloss.core.protocols/Writer found for
> > > class: clojure.lang.PersistentVector
>
> > > Only thing it mentions in the stacktrace [3] is methods on a reify,
> > > which calls the same method again, or in the most recent case, just
> > > return nil.
>
> > > [1]http://www.minecraft.net/docs/NBT.txt
> > > [2]https://gist.github.com/761997
> > > [3]http://pastebin.com/AqrsbjuS
>
> > > On Nov 28 2010, 8:14 pm, Zach Tellman  wrote:
>
> > > > You're right, that's an omission from the frame syntax.  I'll add the
> > > > ability for all or part of the frame to be scoped as (little-
> > > > endian ...) and (big-endian ...), with big-endian as the default.
>
> > > > Just as a side-note, though, Calx [1] is already handling little-
> > > > endian data by using encode-to-buffer, where it's writing to a buffer
> > > > whose endianness has been preset.   This obviously isn't a general
> > > > solution, but just thought I'd point it out.
>
> > > > Zach
>
> > > > [1]https://github.com/ztellman/calx
>
> > > > On Nov 28, 8:50 am, zoka  wrote:
>
> > > > > If Gloss is to decode incoming packet (byte array) in little-endian
> > > > > format it is straightforward:
> > > > > Wrap byte array into ByteBuffer b, invoke b.order(LITTLE_ENDIAN) and
> > > > > pass b to decode function that will return Clojure map of decoded
> > > > > values.
>
> > > > > However, when outgoing packet byte array is to be produced from map of
> > > > > values, encode function will always return ByteBuffer in default big-
> > > > > endian format, so resulting byte array extracted form ByteBuffer using
> > > > > get() method will be incorrect.
>
> > > > > If Gloss is to support little-endian frames, it seems that endianness
> > > > > needs to be part of frame definition. In that case Gloss decode fun
> > > > > would refuse to accept ByteBuffers with wrong order() and encode fun
> > > > > will always generate the correct result.
>
> > > > > Zoka
>
> > > > > On Nov 25, 3:00 am, Zach Tellman  wrote:
>
> > > > > > ByteBuffers have an order() method which all

Re: can I force the JIT to be called immediately for certain pieces of code after it starts executing with out waiting for the JVM realize it is necessary....

2011-01-02 Thread Sunil S Nandihalli
thanks you all for your feedback .. but I had implemented something in
clojure which I knew would be much faster in say c++ .. and now was
regretting it .. and was really looking at all weird locations in
desperation.. but now I realized I was doing something in a very wrong
inefficient (algorithmically )  way .. now things seem better..
Sunil.

On Sun, Jan 2, 2011 at 4:31 PM, Konrad Hinsen wrote:

> On 2 Jan 2011, at 03:29, Sunil S Nandihalli wrote:
>
>   can I force the JIT to be called immediately for certain pieces of code
>> after it starts executing with out waiting for the JVM realize it is
>> necessary? I would not mind jitting the whole code .. Actually I don't
>> mind waiting a few extra seconds at the start since actual run-time for the
>> program could be a couple of hundred minutes...
>>
>>  Is startup time the only reason why the whole code is not jitted
>> immediately.. ?
>>
>
> No. JIT compilation is based on run-time profiles of the code, so it
> requires information that is not available before starting the program. To
> given an example, if a method is called frequently with a specific argument
> type, a specialized version can be compiled.
>
> In terms of total runtime there wouldn't be much to gain anyway from
> compiling upfront. All you'd gain is a more uniform cost of function calls.
> But why care unless you need real-time performance - and then you shouldn't
> be using a JVM language anyway.
>
> Konrad.
>
>
> --
> 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: can I force the JIT to be called immediately for certain pieces of code after it starts executing with out waiting for the JVM realize it is necessary....

2011-01-02 Thread ajuc
On 2 Sty, 12:01, Konrad Hinsen  wrote:
> On 2 Jan 2011, at 03:29, Sunil S Nandihalli wrote:
>
> >  can I force the JIT to be called immediately for certain pieces of  
> > code after it starts executing with out waiting for the JVM realize  
> > it is necessary? I would not mind jitting the whole code ..  
> > Actually I don't mind waiting a few extra seconds at the start since  
> > actual run-time for the program could be a couple of hundred  
> > minutes...
>
> >  Is startup time the only reason why the whole code is not jitted  
> > immediately.. ?
>
> No. JIT compilation is based on run-time profiles of the code, so it  
> requires information that is not available before starting the  
> program. To given an example, if a method is called frequently with a  
> specific argument type, a specialized version can be compiled.

But in theory it could be posible to collect run-time data in one run,
then JIT code at startup, using that collected data and current
procesor architecture.

-- 
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 non-Enclojure Clojure plugin homepages are all rather hard to find.

2011-01-02 Thread Chas Emerick

On Jan 1, 2011, at 2:20 AM, Ken Wesson wrote:

> I use Enclojure/NetBeans myself, but it occurred to me to check out
> the current state of its Eclipse counterpart.
> 
> But I can't find it anywhere. Google returns tons of results, of
> course, but they're all third-party results except the first, which is
> a code.google.com repository. *None* of the top ten results are the
> home page of the plugin; if you're just looking to download the binary
> and use it, or read about it in plain English, you're going to ignore
> the Google Code link, and if you want to get your information from the
> horse's mouth, you'll ignore all of the other hits and then give up.
> 
> This is a problem for Counterclockwise, which really should have its
> own web site in the top ten (and preferably at the very top) of a
> Google search for "counterclockwise clojure" (no quotation marks in
> the actual search).

The Google Code site *is* the ccw site (though the code is on github: 
http://github.com/laurentpetit/ccw).  I'd think that, for a relatively young 
IDE plugin, that wouldn't be a "problem", especially since the project's wiki 
has a plethora of information that is prominently linked.  FWIW, the latest 
release of ccw is also available through the in-IDE Eclipse Marketplace.

There's also the "Getting Started" pages in assembla, which is listed highly 
for nearly any "clojure " search you might run: 
http://www.assembla.com/wiki/show/clojure/Getting_Started

The Enclojure site is definitely very nice.  Laurent may have plans to build 
something similar for ccw -- I don't know.  If you'd like to help with building 
one, by all means send a message to the dev ML @ 
.

- 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: can I force the JIT to be called immediately for certain pieces of code after it starts executing with out waiting for the JVM realize it is necessary....

2011-01-02 Thread Marek Kubica
On Sun, 2 Jan 2011 05:41:08 -0800 (PST)
ajuc  wrote:

> But in theory it could be posible to collect run-time data in one run,
> then JIT code at startup, using that collected data and current
> procesor architecture.

Something like this is already used in practice, it is called
Profile-Guided Optimization (PGO) and available in GCC (but that uses
AOT, which sounds to me like equivalent to "JIT at startup"). The
OpenJDK-JVM does not support this and I doubt that it will. Maybe GCJ
at some time, but as far as I saw, GCJ does not work with Clojure yet.

regards,
Marek

-- 
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


My first clojure web app

2011-01-02 Thread Sean Allen
I finally moved on from messing around with stuff in the repl and trying to
get a firm grasp on all things clojure and dove into doing a little web
development with it. I hadn't used ring, compojure or enlive before so I
kept that functionality in the app really minimal. I'd appreciate feedback
on:

ways my clojure code could be improved/made more idiomatic.
things i did wrong with ring, compojure and enlive
code organization etc.

Thanks in advance to anyone who takes a look and gives me so feedback.
Code is on github at: https://github.com/SeanTAllen/Simple-Compojure-To-Do

-Sean-

-- 
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: a loop gives boxing warning when it shouldn't

2011-01-02 Thread Allen Johnson
Here is my attempt. I changed the divide to use unchecked-divide-int
and explicitly cast recur values to long.

http://clojure.pastebin.com/xs79ruw1

Allen

On Sat, Jan 1, 2011 at 5:47 PM, Albert Cardona  wrote:
> Hi all,
>
> I'd apreciate help on figuring out why a loop gets number boxing
> warnings, when it shouldn't:
>
> http://clojure.pastebin.com/9uLZqGhy
>
> I'm using clojure from:
>
> commit f30995c86056959abca53d0ca35dcb9cfa73e6e6
> Author: Stuart Halloway 
> Date:   Fri Dec 17 15:17:20 2010 -0500
>
> Thanks.
>
> Albert
>
> --
> http://albert.rierol.net
>
> --
> 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: ANN: Gloss, a byte-format DSL

2011-01-02 Thread Zach Tellman
There was a bug in repeated, which is fixed now.  Pull the latest from
github or clojars and let me know how it goes.

Zach

On Jan 2, 3:29 am, "pepijn (aka fliebel)" 
wrote:
> Okay, clicked send to early. The header also contains 0-bytes, so the
> repeated stops 'mid-sentence' and tries to balance things. Is there
> any way Gloss can handle nested structures like this?
>
> On Jan 2, 12:20 pm, "pepijn (aka fliebel)" 
> wrote:
>
>
>
>
>
>
>
> > Hi,
>
> > Thanks for helping out. After using codecs rather than frames, I get
> > even weirder errors.
>
> > My code now gives me: java.lang.Exception: Cannot evenly divide bytes
> > into sequence of frames.
>
> > Hard coding the header followed by a terminating :byte works as it
> > should:
>
> > (decode (compile-frame [tag tstring (header tag (memoize #(compile-
> > frame [(name %) tstring (get-tag %)])) (comp symbol first)) :byte])
> > data)
> > [:compound "hello world" ["string" "name" "Bananrama"] 0]
>
> > So the problem seems to be with the repeated. Investigating that, I
> > copied an example from the introduction page, and this is the result:
> > (defcodec t (repeated (string :utf-8 :delimiters ["\n"]) :delimiters
> > ["\0"]))
> > (encode t ["foo" "bar" "baz"])
> > java.lang.IllegalArgumentException: Don't know how to create ISeq
> > from: java.nio.HeapByteBuffer
> > ((#
> > #)
> > (#
> > #)
>
> > But on the other hand:
> > (decode t (.getBytes "blabla\nhihi\ng\n\0"))
> > ["blabla" "hihi" "g"]
>
> > This gives me the same error as my code, but since the header in my
> > code seems correct, I don't see why it has leftover bytes.
> > (decode t (.getBytes "blabla\nhihi\ng\0"))
> > java.lang.Exception: Cannot evenly divide bytes into sequence of
> > frames.
>
> > By the way, is there an easy way to get something readable out of
> > encode? Like Unix hexdump, or even just a seq of integers. Debugging
> > is a weak point in Gloss so far, if you ask me.
>
> > Thanks!
>
> > Pepijn de Vos
>
> > On Jan 1, 10:47 pm, Zach Tellman  wrote:
>
> > > The header->body function in (header ...) must return a codec, so you
> > > need to call compile-frame on the vector you're generating.  Since you
> > > don't want to call compile-frame every time you decode a frame, you
> > > can memoize the function.  A version that does both can be found 
> > > athttps://gist.github.com/762031.
>
> > > I agree that the way the enumeration and types are blurred in your
> > > code is a little confusing.  You could create a stronger distinction
> > > by calling your enumerated types :tag-byte, :tag-int32, etc, and then
> > > defining a map from those tags onto :byte, :int32, and so on.
>
> > > Zach
>
> > > On Jan 1, 1:01 pm, "pepijn (aka fliebel)" 
> > > wrote:
>
> > > > Hey,
>
> > > > I am trying Gloss for reading NBT [1] files.
>
> > > > First thing I did like is that it seems to make things real easy.
> > > > First thing I did not like is the weak separation between types
> > > > like :byte and extra data like :foo.
>
> > > > I think I'm nearly done with the NBT reader [2], but I ran into a
> > > > problem. Whatever I put in the header form, I get exceptions like
> > > > this:
>
> > > > java.lang.IllegalArgumentException: No implementation of
> > > > method: :sizeof of protocol: #'gloss.core.protocols/Writer found for
> > > > class: clojure.lang.PersistentVector
>
> > > > Only thing it mentions in the stacktrace [3] is methods on a reify,
> > > > which calls the same method again, or in the most recent case, just
> > > > return nil.
>
> > > > [1]http://www.minecraft.net/docs/NBT.txt
> > > > [2]https://gist.github.com/761997
> > > > [3]http://pastebin.com/AqrsbjuS
>
> > > > On Nov 28 2010, 8:14 pm, Zach Tellman  wrote:
>
> > > > > You're right, that's an omission from the frame syntax.  I'll add the
> > > > > ability for all or part of the frame to be scoped as (little-
> > > > > endian ...) and (big-endian ...), with big-endian as the default.
>
> > > > > Just as a side-note, though, Calx [1] is already handling little-
> > > > > endian data by using encode-to-buffer, where it's writing to a buffer
> > > > > whose endianness has been preset.   This obviously isn't a general
> > > > > solution, but just thought I'd point it out.
>
> > > > > Zach
>
> > > > > [1]https://github.com/ztellman/calx
>
> > > > > On Nov 28, 8:50 am, zoka  wrote:
>
> > > > > > If Gloss is to decode incoming packet (byte array) in little-endian
> > > > > > format it is straightforward:
> > > > > > Wrap byte array into ByteBuffer b, invoke b.order(LITTLE_ENDIAN) and
> > > > > > pass b to decode function that will return Clojure map of decoded
> > > > > > values.
>
> > > > > > However, when outgoing packet byte array is to be produced from map 
> > > > > > of
> > > > > > values, encode function will always return ByteBuffer in default 
> > > > > > big-
> > > > > > endian format, so resulting byte array extracted form ByteBuffer 
> > > > > > using
> > > > > > get() method will be incorrect.
>
> > > > > > If Glos

feedback on first compojure app: Sportello

2011-01-02 Thread Alex Baranosky
Hello everyone,

Sean Allen inspired me to share the web app I've been playing with to learn
Compojure.  It's codenamed Sportello and is a simple app that uses the
Google Maps API to calculate an estimated amount of miles you'll have to
travel from a certain place depending on where you live and how frequently
you visit a list of other places.

https://github.com/AlexBaranosky/Sportello/tree/master/src

I used StringTemplate for my templating, and Midje for testing.  One thing I
could see doing is using some form of caching on my requests to google, so
that the same request isn't sent to google over and over (they have a
request limit).  When I get inspired to, I want to add users and sessions,
and save a user's data.  Any direction here would be appreciated.

To get it to run on your machine, in template.clj change the (def
template-dir "C:\\dev\\sportellos\\templates") line to match the location of
the templates folder in your clone of the project.  Then just lein repl
src/server.clj and go to localhost:8080

Any comments on style, technique or just anythings I missed would be greatly
appreciated.  I'm really trying to expand my horizons and perfect the app as
a kind of kata.

Best,
Alex

-- 
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

ANN: syntax-rules

2011-01-02 Thread Brian Goslinga
I have released version 1.0.0-alpha1 of my syntax-rules library:
http://clojars.org/org.clojars.qbg/syntax-rules. This library is also
on Github: https://github.com/qbg/syntax-rules

This library seeks to address two sources of incidental complexity
when writing macros in Clojure using defmacro: parsing the macro form
and checking for syntax errors.  The library provides powerful tools
for parsing macros with complex syntax (see the wiki for an example of
parsing deftype). In addition, this library will generate reasonable
syntax error messages almost for free.

The wiki for this library is located at 
https://github.com/qbg/syntax-rules/wiki.
On the wiki are some simple examples comparing the implementation of
simple macros from Clojure using defmacro and defsyntax-rules. An
implementation of defn is provided using defsyntax-rules. As mentioned
above, there is also an example of parsing deftype using defsyntax-
rules.

I hope people find this library useful.

Brian

-- 
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 non-Enclojure Clojure plugin homepages are all rather hard to find.

2011-01-02 Thread Ken Wesson
On Sun, Jan 2, 2011 at 9:10 AM, Chas Emerick  wrote:
> The Google Code site *is* the ccw site

Really? That is ... non-obvious.

> I'd think that, for a relatively young IDE plugin, that wouldn't be a 
>"problem"

I'd think the opposite -- that's when it most needs growth in its
user-base, and users not being able to quickly find via Google an
*obvious* home site will hamper adoption.

> especially since the project's wiki has a plethora of information that is
> prominently linked.

It's too bad, then, that the project's wiki is not prominently and
*obviously* one of the google results.

>  FWIW, the latest release of ccw is also available through the in-IDE
> Eclipse Marketplace.

"Marketplace"? That doesn't sound good. Are they actually charging
money for it? I very much doubt that would be viable. For La Clojure
it could be; users of that have already proven willing and able to
part with money over the 'net for their development tools. Eclipse
users on the other hand have already made one choice of free over paid
in that area.

> There's also the "Getting Started" pages in assembla, which is listed
> highly for nearly any "clojure " search you might run:
> http://www.assembla.com/wiki/show/clojure/Getting_Started

I noticed Assembla results in all my google searches, but pretty much
ignored them; my readings here and elsewhere have "taught" me that
Assembla is an issue tracker and maybe another code repository site,
and therefore unlikely to be of interest except to developers of the
things you find there and those who wish to report bugs. And for bug
reporting, you apparently have to register and get some kind of a
login there. "Members-only site mainly for the developers of
Clojure/CCW/Enclojure/whatever" is thus how it "smells" to someone
searching for information on any of those, so few users are likely to
surf there. Also, "third-party/repository" vs. "the home page I'm
looking for".

> The Enclojure site is definitely very nice.  Laurent may have plans to
> build something similar for ccw -- I don't know.

I'd recommend that course of action.

-- 
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 non-Enclojure Clojure plugin homepages are all rather hard to find.

2011-01-02 Thread Sean Corfield
On Sun, Jan 2, 2011 at 12:01 PM, Ken Wesson  wrote:
> On Sun, Jan 2, 2011 at 9:10 AM, Chas Emerick  wrote:
>> The Google Code site *is* the ccw site
> Really? That is ... non-obvious.

I'm genuinely curious: why do you think that isn't obvious?

The Project Home page there has the overview, videos, announcements,
quick links and roadmap and the wiki has all the documentation.

> I'd think the opposite -- that's when it most needs growth in its
> user-base, and users not being able to quickly find via Google an
> *obvious* home site will hamper adoption.

The CounterClockWise project home page is the #1 result for Googling
clojure plugin eclipse (which seems the most obvious phrase to me). In
fact, clojure plugin {IDE} leads to the project home page for each of
Eclipse, Netbeans, IDEA so I'd say all three are easy to find. For
TextMate, the Clojure bundle is the second result (ironically, it's
the third result for the more obvious clojure bundle textmate search).

> "Marketplace"? That doesn't sound good. Are they actually charging
> money for it?

Interesting that you would assume that. I know of several technologies
that have a "marketplace" for free add-ons / applications. Presumably,
you're not familiar with Eclipse? It's just a centralized distribution
channel for plugins. Unfortunately, the search engine is offline right
now so I can't tell what the phrase clojure returns...
-- 
Sean A Corfield -- (904) 302-SEAN
Railo Technologies, Inc. -- http://getrailo.com/
An Architect's View -- http://corfield.org/

"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood

-- 
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: can I force the JIT to be called immediately for certain pieces of code after it starts executing with out waiting for the JVM realize it is necessary....

2011-01-02 Thread Alex Miller
You can change the number of times code must be run before it is
compiled with this flag:

-XX:CompileThreshold=1

The default is 1500 in the client hotspot and 1 in server
hotspot.

Of course, you should probably not muck with this unless you are
feeling kinda wild and crazy.


On Jan 1, 8:29 pm, Sunil S Nandihalli 
wrote:
> Hello Everybody,
>  can I force the JIT to be called immediately for certain pieces of code
> after it starts executing with out waiting for the JVM realize it is
> necessary? I would not mind jitting the whole code .. Actually I don't
> mind waiting a few extra seconds at the start since actual run-time for the
> program could be a couple of hundred minutes...
>
>  Is startup time the only reason why the whole code is not jitted
> immediately.. ?
>
>  Is there a way to find out which piece of code is getting jitted .. and
> when?
>
> thanks,
> Sunil.

-- 
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: Boston meetup Jan 11?

2011-01-02 Thread Mark C
Btw, I notice there are 10 people near Boston waiting for a Clojure
meetup.
http://clojure.meetup.com/members/us/ma/boston/  It might be worth
creating a meetup to let them know this is happening.

M.

On Dec 30 2010, 1:52 pm, dysinger  wrote:
> 10 of us from Sonian are going to converge on Boston the week of Jan
> 9.  It's always awesome to meet other Clojure hackers. I propose we
> meet up somewhere central(ish) Jan 11 @ 7-9pm-ish.  We have room at
> our company headquarters in Dedham but that might be a hike for some
> people.  Any other places we could meet/greet & hack for an hour or
> two central to Boston?

-- 
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 non-Enclojure Clojure plugin homepages are all rather hard to find.

2011-01-02 Thread Ken Wesson
On Sun, Jan 2, 2011 at 4:31 PM, Sean Corfield  wrote:
> On Sun, Jan 2, 2011 at 12:01 PM, Ken Wesson  wrote:
>> On Sun, Jan 2, 2011 at 9:10 AM, Chas Emerick  wrote:
>>> The Google Code site *is* the ccw site
>> Really? That is ... non-obvious.
>
> I'm genuinely curious: why do you think that isn't obvious?

Because from its url it looks like it'll just be the code repository.
It doesn't *seem* any more promising as the home page link than the
github.com results you tend to get when you search for other
Clojure-related material.

Lots of people expect a project to have a sourceforge, github, Google
Code, or similar page that isn't very end-user friendly because it's
targeted at the developers and not the users, plus its own .com or
whatever site (e.g., clojure.org) that serves as the home page for the
generally interested public (often linking to sourceforge or wherever
from the big friendly DOWNLOAD WINDOWS INSTALLER button, though).

>> I'd think the opposite -- that's when it most needs growth in its
>> user-base, and users not being able to quickly find via Google an
>> *obvious* home site will hamper adoption.
>
> The CounterClockWise project home page is the #1 result for Googling
> clojure plugin eclipse (which seems the most obvious phrase to me). In
> fact, clojure plugin {IDE} leads to the project home page for each of
> Eclipse, Netbeans, IDEA so I'd say all three are easy to find. For
> TextMate, the Clojure bundle is the second result (ironically, it's
> the third result for the more obvious clojure bundle textmate search).

If it is the Google Code page, then we're both right. It is easy to
find; it's just not quite as easy to recognize. Lots of people will
think "code.google.com -- that'll be the repository. But I'm not
looking to dive into its source code; I just want the page that links
to the end-user documentation and links to SETUP.EXE and tells me in
plain English all about the darn thing". Which, if it's at
code.google.com, they will therefore not find because it's in the last
place they'd look.

>> "Marketplace"? That doesn't sound good. Are they actually charging
>> money for it?
>
> Interesting that you would assume that.

That something calling itself an "app store" or a "plugin marketplace"
or some similar phrase is not giving everything away for free? It's
not exactly the world's strangest assumption to make. :)

> I know of several technologies that have a "marketplace" for free
> add-ons / applications. Presumably, you're not familiar with Eclipse?

No; as I mentioned in my earlier post, I use NetBeans but thought I'd
see if there was an alternative out there that equaled or beat that
yet.

> It's just a centralized distribution channel for plugins. Unfortunately,
> the search engine is offline right now

Not a very good sign. You expect that kind of thing from penny-ante
operators with cheap Dreamhost plans, not big-name open source
projects or big commercial outfits (and didn't Eclipse at one time
have heavy backing from Big Blue?).

In the meantime I'd suggest using a site-scoped Google search. Besides
the fact that Google's search engine is *never* "offline right now", I
find that its site-scoped search frequently gives superior results to
the built-in search even on some big-name professional sites (all of
Microsoft's multifarious sites, for starters).

-- 
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: a loop gives boxing warning when it shouldn't

2011-01-02 Thread Albert Cardona
2011/1/2 Allen Johnson :
> Here is my attempt. I changed the divide to use unchecked-divide-int
> and explicitly cast recur values to long.
>
> http://clojure.pastebin.com/xs79ruw1
>
> Allen


Hi Allen,

Thanks for the effort.

What I don't understand is why one should cast to int or long at all
if the variables "l" and "r" of the loop are ints, and will remain
ints throughout. And k is an int since both r and l are ints, and i
and j will be ints too.

I can't see where the variables are boxed into objects. Both the loop
and the let declare them as primitives if they are given primitives.
Perhaps they are already objects before they reach the inc and dec
function calls in the recur, but if so, it's a mystery to me why.

Albert

-- 
http://albert.rierol.net

-- 
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: a loop gives boxing warning when it shouldn't

2011-01-02 Thread Allen Johnson
> I can't see where the variables are boxed into objects. Both the loop
> and the let declare them as primitives if they are given primitives.
> Perhaps they are already objects before they reach the inc and dec
> function calls in the recur, but if so, it's a mystery to me why.

Yeah that is interesting. I'm not sure the _why_ of it but I attempted
to narrow it down and it looks like it has something to do with nested
loops and recur. The code below is basically the same thing except the
first one generates auto-boxing warnings while the latter does not.
I'd also like to know why this is.

(set! *warn-on-reflection* true)

;; generates auto-boxing warnings
(defn example [^long x]
  (loop [a x]
(let [i (loop [k a] k)]
  (if false (recur i) i

;; no warnings
(defn example [^long x]
  (loop [a x]
(let [i (let [k a] k)]
  (if false (recur i) i

Also, I couldn't resist giving qsort another attempt. I got a new
laptop and need to break it in somehow :) So here is a rewritten
version based on an example in "Introduction to Algorithms" without
casts.

https://gist.github.com/763139

Allen

-- 
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: ANN: syntax-rules

2011-01-02 Thread Sunil S Nandihalli
really nice .. I used to wonder why nobody had already written something
like this for clojure.. after I found out that scheme had all this.. Will
definitely check it out.. :)
Sunil.

On Mon, Jan 3, 2011 at 1:27 AM, Brian Goslinga wrote:

> I have released version 1.0.0-alpha1 of my syntax-rules library:
> http://clojars.org/org.clojars.qbg/syntax-rules. This library is also
> on Github: https://github.com/qbg/syntax-rules
>
> This library seeks to address two sources of incidental complexity
> when writing macros in Clojure using defmacro: parsing the macro form
> and checking for syntax errors.  The library provides powerful tools
> for parsing macros with complex syntax (see the wiki for an example of
> parsing deftype). In addition, this library will generate reasonable
> syntax error messages almost for free.
>
> The wiki for this library is located at
> https://github.com/qbg/syntax-rules/wiki.
> On the wiki are some simple examples comparing the implementation of
> simple macros from Clojure using defmacro and defsyntax-rules. An
> implementation of defn is provided using defsyntax-rules. As mentioned
> above, there is also an example of parsing deftype using defsyntax-
> rules.
>
> I hope people find this library useful.
>
> Brian
>
> --
> 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: The non-Enclojure Clojure plugin homepages are all rather hard to find.

2011-01-02 Thread Sean Corfield
On Sun, Jan 2, 2011 at 7:41 PM, Ken Wesson  wrote:
> Because from its url it looks like it'll just be the code repository.
> It doesn't *seem* any more promising as the home page link than the
> github.com results you tend to get when you search for other
> Clojure-related material.

Good feedback. Thanx. I guess I'm used to reading wikis on github as
being the official project home pages but I can see your p.o.v.

I'm a developer so I think it's reasonable to read about developer
tools on developer sites but I'm getting the sense that a lot of
people coming to Clojure are not coming from what might be called a
'traditional developer' background?

> Lots of people expect a project to have a sourceforge, github, Google
> Code, or similar page that isn't very end-user friendly because it's
> targeted at the developers and not the users, plus its own .com or
> whatever site (e.g., clojure.org) that serves as the home page for the
> generally interested public (often linking to sourceforge or wherever
> from the big friendly DOWNLOAD WINDOWS INSTALLER button, though).

Point taken but I find it an interesting distinction given that the
users of developer tools like CCW are developers :)

However, as someone involved with an free open source CFML engine who
is faced with a large number of Windows developers who expect simple
click-click-done installers, I think I can understand where you're
coming from...

So if CounterClockWise had its own domain website that pointed to the
Google repo and the wiki and the Assembla wiki (where all the other
IDE plugins are documented), you'd be mollified?
-- 
Sean A Corfield -- (904) 302-SEAN
Railo Technologies, Inc. -- http://getrailo.com/
An Architect's View -- http://corfield.org/

"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood

-- 
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: ANN: syntax-rules

2011-01-02 Thread Konrad Hinsen

On 2 Jan 2011, at 20:57, Brian Goslinga wrote:


I have released version 1.0.0-alpha1 of my syntax-rules library:
http://clojars.org/org.clojars.qbg/syntax-rules. This library is also
on Github: https://github.com/qbg/syntax-rules


Excellent, thanks! Ever since I saw a paper on syntax-rules in Scheme  
I have wanted this for Clojure.


Konrad.

--
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