Entwined STM V1.0

2013-08-18 Thread Ivan Koblik
Hi All, Almost 4 years ago I developed STM with semantic concurrency control for my project at CERN. Main feature of this STM is the TransactionalMap that lets you merge concurrent changes. Library is heavily tested and is very stable. It has been used in production for the past 2 years.

Re: Entwined STM V1.0

2013-08-18 Thread Hussein B.
Great ! Congratulations! How it does compare with Clojure's builtin STM? Thanks. On Sunday, August 18, 2013 10:24:48 AM UTC+2, Ivan Koblik wrote: Hi All, Almost 4 years ago I developed STM with semantic concurrency control for my project at CERN. Main feature of this STM is the

Re: Model validation - exceptions as side-effects?

2013-08-18 Thread Leonardo Borges
On 18/08/2013 2:00 PM, Alexandr Kurilin a...@kurilin.net wrote: I'd love to know your expert opinion on this, since you wrote Bouncer: say you're in the situation I listed above, where you don't care about nice error handling, you just want to give the caller a 400 if the input is incorrect.

Re: Entwined STM V1.0

2013-08-18 Thread dennis zhuang
That's really cool. Do you have any performance benchmark between TransactionalMap and java.util.concurrent.ConcurrentHashMap? When should i use these collections instead of java.util.concurrent.* collections? 2013/8/18 Ivan Koblik ivankob...@gmail.com Hi All, Almost 4 years ago I

Re: vec to map with consolidated vals

2013-08-18 Thread Timo Mihaljov
On 17.08.2013 08:40, David Chelimsky wrote: Which led me to this: (defn to-consolidated-map [parts] (apply merge-with + (map (partial apply hash-map) parts))) This is exactly what I came up with after reading your first message. Apparently Jay Fields took the same approach. I think it's

Re: core.async - handling nils

2013-08-18 Thread Mikera
If you use a singleton sentinel value that is generated privately within the core.async implementation, then the sentinel isn't really a regular value in the sense that it can be created by regular user code. nil, on the other hand, gets used very frequently as a value in regular Clojure code.

Re: Entwined STM V1.0

2013-08-18 Thread Ivan Koblik
Thank you! Great question. I couldn't devise a way to merge concurrent changes in a HashMap using Clojure's STM. A while ago I discussed it with Christophe Grand and he had his own idea about how to fix it: [1] and [2]. IIRC Christophe's solution may see a conflict even if there's no real

Re: Entwined STM V1.0

2013-08-18 Thread Ivan Koblik
I'll come back to you with the benchmarks, so far I haven't done any. I have an impression that ConcurrentHashMap will outperform TransactionalMap in most cases, but there may be cases when different keys end up in the same bucket in the ConcurrentHashMap and that is where TransactionalMap may

Help to morph this imperative snippet into a functional one

2013-08-18 Thread Hussein B.
Hi! Would you please help me transforming this imperative code into functional one? The code is a typical snippet in imperative style. A lot of mutations that I don't even know how to start morphing it to Clojure. class Container { MapString, Container children; String letter;

Re: Current state of the art in Web deployment?

2013-08-18 Thread Norman Richards
On Sat, Aug 17, 2013 at 3:52 PM, John Jacobsen eigenhom...@gmail.comwrote: So, what do all y'all do? What is a good lightweight but robust way to get a fairly simple Compojure/Ring app backed by Datomic facing the outside world? Not too worried about massive scalability at this point;

Re: Help to morph this imperative snippet into a functional one

2013-08-18 Thread Chris Ford
Can you explain what the code is supposed to do in English? Java is a little hard to read. :-) Are you doing Huffman coding or similar? On 18 August 2013 16:51, Hussein B. hubaghd...@gmail.com wrote: Hi! Would you please help me transforming this imperative code into functional one? The

Re: Help to morph this imperative snippet into a functional one

2013-08-18 Thread Hussein B.
It might be Huffman coding but I don't know Hoffman coding in depth, so I can't be precise. :) But any way, it is a snippet written in an imperative style that I'm trying to transfer into a functional one. The amount of mutation and the if statements are blocking me from doing it in Clojure.

Re: Help to morph this imperative snippet into a functional one

2013-08-18 Thread Chris Ford
This is close, though it only permits values at leaves and stores the values in the reverse order. Depending on what you need, this might be sufficient: (defn insert [container letters value] (update-in container letters #(conj % value))) e.g. (- {} (insert foo 3) (insert foo 4) (insert bar

Re: Help to morph this imperative snippet into a functional one

2013-08-18 Thread Chris Ford
Here's a version that allows values to be anywhere in the tree: (defn insert [[container values] [letter letters] value] (if letter [(update-in container [letter] #(insert % letters value)) values] [container (conj values value)])) e.g. (- [{} []] (insert foo 4) (insert f 5) (insert

Re: Current state of the art in Web deployment?

2013-08-18 Thread John Jacobsen
Many thanks to everyone who replied about deploying a Web server to production. Specific replies: On Aug 17, 2013, at 6:51 PM, Mark Mandel mark.man...@gmail.com wrote: On Sun, Aug 18, 2013 at 6:52 AM, John Jacobsen eigenhom...@gmail.com wrote: After some prototyping and development, we are

Comparing of 2 words

2013-08-18 Thread Christian Sperandio
Hi, I wrote a set of functions to compare 2 words managing the keyboard mistakes. The common mistakes are insertion, deletion, substitution or inversion. It can be useful for searching name, product reference, city For example, if you want to let 2 errors in an input, you can do: ;; a

Re: Current state of the art in Web deployment?

2013-08-18 Thread Steven Degutis
I don't think there is a such thing as a real server. Any process that listens on a TCP port and talks HTTP is a legitimate server, regardless of when or how it's started up. Upstart is a fine way to run your server and make sure it's restarted if it dies. It's not hacky or unconventional, in

ANN Langohr documentation updates

2013-08-18 Thread Michael Klishin
I'm happy to announce that Langohr [1] documentation is being actively worked on again. There's already one full new guide available [2], that covers RabbitMQ extensions and how to use them from Clojure. At least two more guides (TLS/SSL support and Durability) are in the works and will be

Re: Current state of the art in Web deployment?

2013-08-18 Thread Sean Corfield
On Sun, Aug 18, 2013 at 9:21 AM, John Jacobsen eigenhom...@gmail.com wrote: My main concern was just the need to ssh into the server and run leiningen in the background, as opposed to setting up a real server which starts at boot time. I'm OK w/ wrapping 'lein ring server-headless' with

Revisiting forward-chaining rules in Clojure

2013-08-18 Thread Ryan Brush
Perhaps the best aspect of Clojure is how it can adopt the best ideas from other domains to concisely solve problems, as we've seen with core.logic, core.async and other libraries. I recently came across a problem domain that is easily expressed in forward-chaining rules, and found Clojure to

Re: Current state of the art in Web deployment?

2013-08-18 Thread Ray Miller
On 18 August 2013 17:21, John Jacobsen eigenhom...@gmail.com wrote: On Aug 17, 2013, at 4:52 PM, Ray Miller r...@1729.org.uk wrote: One option is simply to write an upstart script that invokes 'lein ring server-headless' and sit an apache or nginx proxy in front of it. That's how my website

Re: vec to map with consolidated vals

2013-08-18 Thread Ray Miller
On 18 August 2013 12:31, Timo Mihaljov t...@mihaljov.info wrote: On 17.08.2013 08:40, David Chelimsky wrote: Which led me to this: (defn to-consolidated-map [parts] (apply merge-with + (map (partial apply hash-map) parts))) This is exactly what I came up with after reading your first

Re: Current state of the art in Web deployment?

2013-08-18 Thread James Henderson
Hi John, Building on Ray's answer to use Upstart, I've recently started using a Git-based deployment method that essentially uses a Git post-receive hook to re-deploy the application with a simple git push. To set-up, create a bare repo and a working tree on the deploy host, and the relevant

Re: Revisiting forward-chaining rules in Clojure

2013-08-18 Thread Shantanu Kumar
Thanks for posting. I will certainly explore this. Did you look at Mimir? https://github.com/hraberg/mimir Could you outline how is Clara's approach different from Mimir? Shantanu On Sunday, 18 August 2013 23:46:14 UTC+5:30, Ryan Brush wrote: Perhaps the best aspect of Clojure is how it can

Re: Revisiting forward-chaining rules in Clojure

2013-08-18 Thread Ryan Brush
Shantanu, I appreciate it. I did look at Mimir, but had some different objectives, and therefore tradeoffs, and didn't see a straightforward way to reconcile them. First, I wanted to use existing data models in the rules as is -- be it Clojure records, Java Beans, or other structures. Drools

lein-undertow-adapter

2013-08-18 Thread Alexander Solovyov
I was looking at techempower benchmarks [1] and noticed that fastest (by their measurements) Java HTTP server - Undertow - had no Ring adapter. I felt like it and wrote one just for fun: https://github.com/piranha/ring-undertow-adapter Installation and usage is pretty standard, put

[ANN] clj-time 0.6.0 released - some API deprecations

2013-08-18 Thread Sean Corfield
What: A Clojure wrapper for Joda Time Where: https://github.com/clj-time/clj-time Details: An API cleanup that deprecates several inconsistent / abbreviated names and introduces preferred replacements. Deprecated API will remain under 0.7.0 so you will have plenty of time to update

Re: What's your preference, partial or closures?

2013-08-18 Thread Mikera
I prefer to use closures / higher order functions that return a function. Reasons: - You typically get much better performance by returning a closure. partial uses apply, which adds a lot of overhead - It can result in cleaner user code (partials require a bit of mental decoding, and you can

Re: What's your preference, partial or closures?

2013-08-18 Thread Chris Allen
Am I crazy or does this scream macro? On Saturday, August 17, 2013 6:02:03 PM UTC-7, Sean Corfield wrote: On Sat, Aug 17, 2013 at 5:43 PM, yair yair...@gmail.com javascript: wrote: What do you mean by currying in this context? Is there a way to do this in clojure apart from using

Re: What's your preference, partial or closures?

2013-08-18 Thread Sean Corfield
You're crazy :) On Sun, Aug 18, 2013 at 9:04 PM, Chris Allen callen.2...@gmail.com wrote: Am I crazy or does this scream macro? On Saturday, August 17, 2013 6:02:03 PM UTC-7, Sean Corfield wrote: On Sat, Aug 17, 2013 at 5:43 PM, yair yair...@gmail.com wrote: What do you mean by currying in

Re: Revisiting forward-chaining rules in Clojure

2013-08-18 Thread Alan Moore
On Sunday, August 18, 2013 1:41:56 PM UTC-7, Ryan Brush wrote: Shantanu, I appreciate it. I did look at Mimir, but had some different objectives, and therefore tradeoffs, and didn't see a straightforward way to reconcile them. First, I wanted to use existing data models in the rules as

Re: Revisiting forward-chaining rules in Clojure

2013-08-18 Thread Ryan Brush
The idea of Datomic as an approach to scalable working memory is interesting. I haven't looked at the mechanics of doing this, but it seems possible since Clara aims to separate the working memory system from the rule logic and Rete network. Also, the approach I've taken here aligns with