Macro for quickly switching libraries

2016-04-05 Thread Will Bridewell
I'm working on some code where I want to evaluate different implementations 
of the same functionality. Each implementation of a function lives in its 
own namespace. For example, suppose that I have the following simplified 
code.

(ns tst1)
(defn foo [x] (+ x 1))

(ns tst2)
(defn foo [x] (+ x 2))

(ns tst3)
(defn foo [x] (+ x 3))

(in-ns 'user)

What I'd like to do is call a macro that binds the function name in user to 
the function in one of the libraries. The call would look like one of 
these. 

(switch-library! 'tst1 'foo)

(switch-foo-library! 'tst1)

The closest that I got was to do 

(defmacro switch-foo-library! [x]
  `(defn foo [y#] ((resolve (symbol (str ~x "/foo"))) y#)))

That's kind of embarrassing, but I think it does what I want. However, 
suppose I do

(ns-unmap 'user 'juxt)
(defmacro switch-juxt-library! [x]
  `(defn juxt [y#] ((resolve (symbol (str ~x "/juxt"))) y#)))

Now I get 

CompilerException java.lang.RuntimeException: Can't create defs outside of 
current ns, compiling:

Well, gosh. I can't play around with symbols in clojure.core? What's 
happening here?


-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Advice getting started with concurrency and parallelism in Clojure

2016-04-05 Thread Timothy Baldridge
If it all seems confusing, do not despair, there's two things that will
handle the vast majority of the use cases you may have:

1) `future` - spawns a thread that runs the body of the future (
https://clojuredocs.org/clojure.core/future)
2) `atom` and `swap!` - Used to store data that needs to be shared between
threads and updated concurrently (https://clojuredocs.org/clojure.core/atom)
these are built on top of CAS, which itself is foundation upon which most
of concurrent programming is built. (
https://en.wikipedia.org/wiki/Compare-and-swap)

Those two primitives alone will handle 90% of the use cases you will run
into as a new clojure developer. The rest of the stuff (agents, thread
pools, refs, vars, cps/core.async) can all come in time, but you will use
them much less often than threads and atoms. So read up on those two and
feel free to come back with any questions you may have.

Timothy


On Tue, Apr 5, 2016 at 7:24 PM, Chris White  wrote:

> I was doing some reading of code recently to help me get up to speed with
> Clojure. One of the libraries I randomly came across dealt with parallelism
> and I had a hard time following along with it. To try and wrap my head
> around things I did a quick search and found this article:
>
>
> http://www.thattommyhall.com/2014/02/24/concurrency-and-parallelism-in-clojure/
>
> I'm not sure how authoritative this is based on my current experience, but
> needless to say I was a bit overwhelmed. That said is there any sort of
> introductory material that list members have used to help get them into how
> Clojure deals with concurrency and parallelism? I also don't mind anything
> that's not specifically using Clojure but will at least help me understand
> the concepts behind how Clojure does it. Thanks again for any and all help!
>
> - Chris White (@cwgem)
>
> --
> 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 unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
“One of the main causes of the fall of the Roman Empire was that–lacking
zero–they had no way to indicate successful termination of their C
programs.”
(Robert Firth)

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Advice getting started with concurrency and parallelism in Clojure

2016-04-05 Thread Chris White
I was doing some reading of code recently to help me get up to speed with 
Clojure. One of the libraries I randomly came across dealt with parallelism 
and I had a hard time following along with it. To try and wrap my head 
around things I did a quick search and found this article:

http://www.thattommyhall.com/2014/02/24/concurrency-and-parallelism-in-clojure/

I'm not sure how authoritative this is based on my current experience, but 
needless to say I was a bit overwhelmed. That said is there any sort of 
introductory material that list members have used to help get them into how 
Clojure deals with concurrency and parallelism? I also don't mind anything 
that's not specifically using Clojure but will at least help me understand 
the concepts behind how Clojure does it. Thanks again for any and all help!

- Chris White (@cwgem)

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ANN] components.md

2016-04-05 Thread Timothy Baldridge
The thing that this doc also advocates (and I am against) is manual
dependency management, your app start function must call start on its
dependencies. This not only hardcodes the dependency, but also requires the
user to think about the startup order of components on every usage.

In addition this approach doesn't support substituting alternate
implementations. During testing I often want to use a in-memory queue vs
RabbitMQ. Or perhaps I want to wire an entire system up with in-memory
queues to perform limited integration testing. Hardcoding dependencies
limits the flexibility of the app.


And this part of the doc:

"A: You see, this all idea of reusable libraries of components never worked
and it gets complicated pretty fast. See the past 20 years of OO
frameworks. Do you really want a Spring/J2EE in your beautiful Clojure app?"

Is just wrong. Perhaps across multiple projects and multiple companies
component re-use isn't as common as some would think. but within the same
company/project components are re-used a lot. Not only does this quote it
present a false dichotomy (either you have a nice Clojure app or you have
reusable components). But it is also little more than an ad-homiem attack:
"This looks like OOP, OOP is bad, therefore doing this is bad!"



On Tue, Apr 5, 2016 at 11:31 AM, James Reeves  wrote:

> On 5 April 2016 at 17:23,  wrote:
>
>> Not sure it's worth to depend on a library for a defprotocol with two
>> functions. Also, still need to double check, but I think I can get rid of
>> that defprotocol.
>>
>
> Well, the advantage with using the Lifecycle protocol from Component is
> that you can make use of existing libraries.
>
> - James
>
> --
> 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 unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
“One of the main causes of the fall of the Roman Empire was that–lacking
zero–they had no way to indicate successful termination of their C
programs.”
(Robert Firth)

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ANN] components.md

2016-04-05 Thread James Reeves
On 5 April 2016 at 17:23,  wrote:

> Not sure it's worth to depend on a library for a defprotocol with two
> functions. Also, still need to double check, but I think I can get rid of
> that defprotocol.
>

Well, the advantage with using the Lifecycle protocol from Component is
that you can make use of existing libraries.

- James

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ANN] components.md

2016-04-05 Thread reborgml
Not sure it's worth to depend on a library for a defprotocol with two 
functions. Also, still need to double check, but I think I can get rid of 
that defprotocol.

Renzo

On Tuesday, 5 April 2016 16:12:42 UTC+1, James Reeves wrote:
>
> Why implement your own Lifecycle protocol, rather than using the one from 
> the Component library?
>
> - James
>
> On 5 April 2016 at 09:28, Renzo Borgatti > 
> wrote:
>
>> Hello clj,
>>
>> kinda late into that discussion of a while ago about “how I use 
>> components”, I finally wrote-up about it:
>>
>> https://github.com/reborg/scccw/blob/master/COMPONENTS.md
>>
>> The result is a markdown document that is meant to be used by 
>> copy-pasting. So no libraries, no frameworks. The reason is that I’m mainly 
>> introducing an architectural convention to handle stateful parts of a 
>> Clojure application and I believe your app should bootstrap from these 
>> general principles and extend on them, evolutionary. It’s not different 
>> from saying that you should isolate impure functions in your code: you 
>> wouldn’t create a library out of it.
>>
>> Let me know what you think. Between this organization for components and 
>> Fluorine for config (https://github.com/reborg/fluorine/), I’m a happier 
>> Clojure dev these days :)
>>
>> Renzo
>> @reborg
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clo...@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+u...@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 unsubscribe from this group and stop receiving emails from it, send an 
>> email to clojure+u...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ANN] components.md

2016-04-05 Thread James Reeves
Why implement your own Lifecycle protocol, rather than using the one from
the Component library?

- James

On 5 April 2016 at 09:28, Renzo Borgatti  wrote:

> Hello clj,
>
> kinda late into that discussion of a while ago about “how I use
> components”, I finally wrote-up about it:
>
> https://github.com/reborg/scccw/blob/master/COMPONENTS.md
>
> The result is a markdown document that is meant to be used by
> copy-pasting. So no libraries, no frameworks. The reason is that I’m mainly
> introducing an architectural convention to handle stateful parts of a
> Clojure application and I believe your app should bootstrap from these
> general principles and extend on them, evolutionary. It’s not different
> from saying that you should isolate impure functions in your code: you
> wouldn’t create a library out of it.
>
> Let me know what you think. Between this organization for components and
> Fluorine for config (https://github.com/reborg/fluorine/), I’m a happier
> Clojure dev these days :)
>
> Renzo
> @reborg
>
> --
> 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 unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ANN] dali SVG library 0.7.0

2016-04-05 Thread Pierre Allix
Wow very nice work.

It's very close to what I did on github.com/pallix/lacij and 
https://github.com/pallix/tikkba and I'm wondering if some part could be 
put in common.

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Clojure library

2016-04-05 Thread Fernando Abrao
Yes, thats I wanted.

Thanks a lot
Regards

Em domingo, 3 de abril de 2016 07:10:01 UTC-3, Ashish Negi escreveu:
>
> By default build tool : lein would not do AOT i.e. create .class files. 
> So, your jar with `lein uberjar` would have .clj files. You can verify with 
> un-tar the jar.
>
> If you have a `-main` then you can use :skip-aot for not doing aot.. 
> see 
> https://github.com/technomancy/leiningen/blob/master/sample.project.clj#L189
>
>

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ANN] kithara 0.1.0 - Reliable RabbitMQ Consumers for Clojure

2016-04-05 Thread Łukasz Korecki
This is great - we're planning to open source our tiny consumer lib - there 
might be no need after all :-)


Looking at the source and the readme it's **very** similar to our solution.


Łukasz

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ANN] Aleph 0.4.1

2016-04-05 Thread Rangel Spasov
Zach - thank you for all the work you do on Aleph, I use it every day!

On Saturday, April 2, 2016 at 11:44:53 PM UTC-7, Zach Tellman wrote:
>
> This release represents a number of incremental improvements to 0.4.0, 
> which has been handling billions of daily requests for close to a year.  
>
> * Documentation can be found at http://aleph.io/
> * Literate examples of usage can be found at 
> http://aleph.io/aleph/literate.html
> * Comparative benchmarks can be found at 
> https://www.techempower.com/benchmarks/#section=data-r12&hw=peak&test=plaintext&l=4,
>  
> which may or may not be relevant to your particular use case
>
> If anyone has questions, I'm happy to answer them.
>

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ANN] components.md

2016-04-05 Thread Renzo Borgatti
Hello clj,

kinda late into that discussion of a while ago about “how I use components”, I 
finally wrote-up about it:

https://github.com/reborg/scccw/blob/master/COMPONENTS.md

The result is a markdown document that is meant to be used by copy-pasting. So 
no libraries, no frameworks. The reason is that I’m mainly introducing an 
architectural convention to handle stateful parts of a Clojure application and 
I believe your app should bootstrap from these general principles and extend on 
them, evolutionary. It’s not different from saying that you should isolate 
impure functions in your code: you wouldn’t create a library out of it.

Let me know what you think. Between this organization for components and 
Fluorine for config (https://github.com/reborg/fluorine/), I’m a happier 
Clojure dev these days :)

Renzo
@reborg

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.