New Functional Programming Job Opportunities

2015-08-10 Thread Functional Jobs
Here are some functional programming job opportunities that were posted

recently:



Senior Software Engineer / Clojure at goCatch

http://functionaljobs.com/jobs/8855-senior-software-engineer-clojure-at-gocatch



Cheers,

Sean Murphy

FunctionalJobs.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
--- 
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: some guidance sought

2015-08-10 Thread William la Forge
Oh! The Java collection methods! For interop with Java, I'm guessing. Not a 
personal priority, though I see that data.int-map does exactly that.

The Clojure interfaces are much more reasonable. And really I want to focus 
on the extensions to AA trees that I've developed, like virtual AA trees 
that can be used in place of a B-tree.

Many thanks for the links. Plenty here for me to dig through. And as a 
newbie I've got to do a lot of reading if I ever want to write readable 
code.

On Monday, August 10, 2015 at 7:29:26 AM UTC-4, Linus Ericsson wrote:

 The clojure core datastructures PersistentHashMap and PersistentVector are 
 based on Philip Bagwells Ideal Hash Trees: 
 http://lampwww.epfl.ch/papers/idealhashtrees.pdf

 Several of Chris Okasakis Purely Functional Datastructures are implemented 
 already. http://www.cs.cmu.edu/~rwh/theses/okasaki.pdf

 Clojure Toolbox http://www.clojure-toolbox.com/ mentions


- Merkle https://github.com/aphyr/merkle
- clj-tuple https://github.com/ztellman/clj-tuple
- core.rrb-vector https://github.com/clojure/core.rrb-vector
- data.finger-tree https://github.com/clojure/data.finger-tree
- data.int-map https://github.com/clojure/data.int-map
- data.priority-map https://github.com/clojure/data.priority-map
- data.union-find https://github.com/jordanlewis/data.union-find
- fast-zip https://github.com/akhudek/fast-zip
- immutable-bitset https://github.com/ztellman/immutable-bitset
- ordered https://github.com/flatland/ordered
- ring-buffer https://github.com/amalloy/ring-buffer

 under Datastructures.


 Monads has been implemented many times, check 
 https://github.com/clojure/algo.monads for one example.


 Mary Rose Cook wrote an impressive as well as entertaining article on 
 implementing Fibonacci Heaps in Clojure 
 http://maryrosecook.com/blog/post/the-fibonacci-heap-ruins-my-life


 Sketchy datastructures exists, https://github.com/bigmlcom/sketchy 
 (bloom, hyperloglog, min-distance hashing etc). Another Bloom Filter: 
 https://github.com/kyleburton/clj-bloom


 It is said that splay trees aren't very suitable for implementing as an 
 immutable structure because they mutate on read.


 I guess you'll get quite exact guidelines in the various core libraries on 
 how to implement the Java collection methods (in general, all mutating 
 methods throw methodNotImplementedExceptions).


 Good luck!


 /Linus


 On Monday, August 10, 2015 at 12:31:25 AM UTC+2, William la Forge wrote:

 I've done a lot with AA trees in the past, creating variations that are 
 immutable, durable (replacing b-trees) and versioned of vectors, maps and 
 sets.

 I would like to migrate these ideas from Java to Clojure, while 
 implementing the interfaces appropriate for Clojure.

 Still being very much a newbie, I'd appreciate some pointers, relevant 
 docs and/or examples.

 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 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: My first Clojure program (and blog post about it)

2015-08-10 Thread kirby urner
 Your way works because basically you are building two extra vectors
 which are implicitly getting destructured, but that's syntactically noisy
 and also a lot of extra computational work that is unneeded.

 --


Thanks!

I cleaned it up a bunch:

https://github.com/4dsolutions/synmods/blob/master/qrays.clj

Kirby

-- 
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: some guidance sought

2015-08-10 Thread Andy Fingerhut
I had not heard of AA trees before, but according to Wikipedia they sound
like a variant of red-black trees.  Clojure's built-in sorted-map and
sorted-set implementations are called by the class name PersistentTreeMap
in its Java implementation [1], and it implements a persistent version of a
red-black tree.  The source code won't give you lots of hand-holding, but
it is there to see if you are interested.

Andy

[1]
https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/PersistentTreeMap.java

On Mon, Aug 10, 2015 at 11:56 AM, William la Forge laforg...@gmail.com
wrote:

 Oh! The Java collection methods! For interop with Java, I'm guessing. Not
 a personal priority, though I see that data.int-map does exactly that.

 The Clojure interfaces are much more reasonable. And really I want to
 focus on the extensions to AA trees that I've developed, like virtual AA
 trees that can be used in place of a B-tree.

 Many thanks for the links. Plenty here for me to dig through. And as a
 newbie I've got to do a lot of reading if I ever want to write readable
 code.


 On Monday, August 10, 2015 at 7:29:26 AM UTC-4, Linus Ericsson wrote:

 The clojure core datastructures PersistentHashMap and PersistentVector
 are based on Philip Bagwells Ideal Hash Trees:
 http://lampwww.epfl.ch/papers/idealhashtrees.pdf

 Several of Chris Okasakis Purely Functional Datastructures are
 implemented already. http://www.cs.cmu.edu/~rwh/theses/okasaki.pdf

 Clojure Toolbox http://www.clojure-toolbox.com/ mentions


- Merkle https://github.com/aphyr/merkle
- clj-tuple https://github.com/ztellman/clj-tuple
- core.rrb-vector https://github.com/clojure/core.rrb-vector
- data.finger-tree https://github.com/clojure/data.finger-tree
- data.int-map https://github.com/clojure/data.int-map
- data.priority-map https://github.com/clojure/data.priority-map
- data.union-find https://github.com/jordanlewis/data.union-find
- fast-zip https://github.com/akhudek/fast-zip
- immutable-bitset https://github.com/ztellman/immutable-bitset
- ordered https://github.com/flatland/ordered
- ring-buffer https://github.com/amalloy/ring-buffer

 under Datastructures.


 Monads has been implemented many times, check
 https://github.com/clojure/algo.monads for one example.


 Mary Rose Cook wrote an impressive as well as entertaining article on
 implementing Fibonacci Heaps in Clojure
 http://maryrosecook.com/blog/post/the-fibonacci-heap-ruins-my-life


 Sketchy datastructures exists, https://github.com/bigmlcom/sketchy
 (bloom, hyperloglog, min-distance hashing etc). Another Bloom Filter:
 https://github.com/kyleburton/clj-bloom


 It is said that splay trees aren't very suitable for implementing as an
 immutable structure because they mutate on read.


 I guess you'll get quite exact guidelines in the various core libraries
 on how to implement the Java collection methods (in general, all mutating
 methods throw methodNotImplementedExceptions).


 Good luck!


 /Linus


 On Monday, August 10, 2015 at 12:31:25 AM UTC+2, William la Forge wrote:

 I've done a lot with AA trees in the past, creating variations that are
 immutable, durable (replacing b-trees) and versioned of vectors, maps and
 sets.

 I would like to migrate these ideas from Java to Clojure, while
 implementing the interfaces appropriate for Clojure.

 Still being very much a newbie, I'd appreciate some pointers, relevant
 docs and/or examples.

 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 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: My first Clojure program (and blog post about it)

2015-08-10 Thread Mark Engelberg
On Sat, Aug 8, 2015 at 12:39 PM, kirby urner kirby.ur...@gmail.com wrote:


 (defrecord XYZray [OX OY OZ]
VectorOps
(norm [this] (this))


Should be (norm [this] this) not (norm [this] (this)), because the latter
will try to invoke `this` as a function.

(defn qray-to-xyzray
  [qray]
  (let [[a] [(:OA qray)]
[b] [(:OB qray)]
[c] [(:OC qray)]
[d] [(:OD qray)]
[x] [(* (/ 1 (Math/sqrt 2))(+ (- (- a b) c) d))]
[y] [(* (/ 1 (Math/sqrt 2))(- (+ (- a b) c) d))]
[z] [(* (/ 1 (Math/sqrt 2))(- (- (+ a b) c) d))]]
(XYZray. x y z)))


You have excessive, unnecessary brackets in your let clause.  Should look
like this:

(defn qray-to-xyzray
  [qray]
  (let [a (:OA qray)
b (:OB qray)
etc

Your way works because basically you are building two extra vectors which
are implicitly getting destructured, but that's syntactically noisy and
also a lot of extra computational work that is unneeded.

-- 
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: Hashing With Consistent Results

2015-08-10 Thread Christian Weilbach
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi,

I am the author of https://github.com/whilo/hasch

Would calling hasch.core/edn-hash satisfy your performance
requirements? I tried hard to make the recursion of the protocol
performant, but hashing a value is slower than the time needed to
write the data to disk for big collections. You should pick a faster
message-digest like you suggested, e.g. MD5:

(defn ^MessageDigest md5-message-digest []
  (MessageDigest/getInstance md5))

(edn-hash {:foo Bar :baz 5} md5-message-digest)

You can use the criterium benchmarking snippets in platform.clj to do
benchmarks. Object.hashCode() is a lot faster still and caches the
result, I am not sure how much overhead the protocol dispatch causes.

Note that if some collisions are ok for you, you might find a better
tradeoff, since atm. commutative collections like maps and sets are
hashed key-value wise and then XOR'd for safety. I am interested in
your findings and decision, especially if you pick something else.

Christian

On 10.08.2015 09:00, Atamert Ölçgen wrote:
 Hi,
 
 I need a way to reduce a compound value, say {:foo bar}, into a
 number (like 693d9a0698aff95c in hex). I don't necessarily need a
 very large hash space, 7 hex digits is good enough for my purposes.
 But I need this hash to be consistent between runs and JVM versions
 etc. So I guess that rules out standard object hashes.
 
 I would like to find a sufficiently fast way to do this. I can live
 with MD5, but are there faster alternatives (but produce smaller
 hashes)? ( clj-digest https://github.com/tebeka/clj-digest
 provides a nice interface to what Java provides but there are only
 usual suspects AFAICS 
 http://docs.oracle.com/javase/7/docs/technotes/guides/security/StandardNames.html#MessageDigest

 
)
 
 I will be dealing with unordered collections, but it seems hashing
 is consistent when the input order is changed:
 
 user= (.hashCode {:foo Bar :baz 5}) 2040536238 user= (.hashCode
 {:baz 5 :foo Bar}) 2040536238
 
 
 (It even gave the same hash code in different runs.)
 
 I will use these hashes to build index tables. My data, that
 contains these things I hash is a set. I will store this as an
 ordered set and keep an index pointing to where records from this
 hash to that hash lives. This is all Clojure, but I can't keep all
 my data in memory. (So Clojure's persistent data structures is out
 of the picture. life would've been much simpler if I could.)
 
 Thanks for reading. Any insight is appreciated.
 


-BEGIN PGP SIGNATURE-
Version: GnuPG v1

iQEcBAEBAgAGBQJVyJ3vAAoJEKel+aujRZMkbhMIAJ61DGUWM9JoN/JcIxvh2Jph
VohlWbr1yw69D+x4guGOk5AXUh7HMAkmlbuc+YRRnYqGhZtc3r/6C/d/aa5faBAh
NdIeDa8yNHTAuYERDktfviy+q5a/blJRdvIIe7ntyjpDZyd2gD1AwUGYOKctXipS
wMPan7v7yPfPlFfnl+VVXfP8yx/LWyZbwfu0Ugv2B2NhvqPMu8joyondOz7GPcLd
P7EgpIrvfQAElA4c4+UB0BEeJkn+fnpYF3QLJIy5oQny5QwbVtxgVuUNES8EolYl
HkpFY1ECV/M65fvP6wrcYPihuphSYQoPkfY4ZQfzWCq9mo+3Aj1Jq2u7QfG9HxM=
=1UE6
-END PGP SIGNATURE-

-- 
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: why does this file watcher keep triggering?

2015-08-10 Thread Colin Yates
I'm glad that sort of thing doesn't just happen to me :)

Sent from my iPhone

 On 10 Aug 2015, at 00:44, Lawrence Krubner lawre...@rollioforce.com wrote:
 
 
 Okay, I am an idiot. I had the directory watch setup to watch the directory 
 where the uberjar was built, so of course it was triggered thousands of time 
 while the uberjar was built, since I guess every new byte added to the 
 uberjar triggers the change event. 
 
 So I set my app to listen on the final directory, where the final uberjar is 
 moved, just once, when the uberjar is complete, and now the app behaves the 
 way I was expecting it to. 
 
 
 On Sunday, August 9, 2015 at 1:13:56 PM UTC-4, Lawrence Krubner wrote:
 
 Let's assume for a moment that, for some strange reason, the directory 
 watching strategy won't work here. Does anyone have any other suggestions? 
 I am thinking there must be a simple way to setup Jenkins and Supervisord to 
 run these apps, but what I'm doing keeps getting more and more complex, 
 which is typically a warning sign that I'm on the wrong track.
 
 
 
 
 On Saturday, August 8, 2015 at 5:24:28 PM UTC-4, Lawrence Krubner wrote:
 I feel stupid, but I have not been able to track this down. 
 
 The background is that I have Jenkins running on the server, and when 
 triggered it pulls code from Github, compiles it, and then moves the final 
 uberjar to the directory where I keep all the uberjars that run on this 
 server. Then I have an app that should kill all currently running 
 instances. Then Supervisord should step in and restart the instances, using 
 the new uberjars for the new instances. 
 
 All of this works, but I have been doing one bit by hand: kill all 
 currently running instances. I log in as root and run a script that kills 
 the old instances. But just today I wrote a quick Clojure app to automate 
 this for me (the whole app is 50 lines of code, so this is a very small 
 app). 
 
 To trigger the main action, I thought the app should set a watcher on the 
 final directory where Jenkins moves the uberjars to. When Jenkins moves a 
 new uberjar to the directory, the watch would be triggered and then it 
 could run the kill all currently running instances script. However, I 
 assumed that the kill all currently running instances script would be 
 triggered once each time the uberjar was updated, but instead it seems to 
 be triggered infinitely. Does a JVM app, or a Clojure app, change the dir 
 its in, on launch? Or is the problem in my own code? I'm using Chris 
 Zheng's excellent Hara library for the Watch. This is the main function of 
 my app, which is called on startup: 
 
 (defn establish-watchers []
   The config contains a hashmap which has a 'watchers' key, which contains 
 a vector that holds hashmaps with 2 keys, one pointing to the directory 
 that should be watched and the other pointing to the command that should be 
 run when the watch is triggered.
   (let [config (read-string (slurp /etc/fiit.edn))
 watchers (:watchers config)]
   (doseq [w watchers]
  (common-watch/add (clojure.java.io/file (:dir-to-watch w)) (keyword  
 (:dir-to-watch w))
(fn [f k _ [cmd file]]
  (pprint/pprint (:out (sh/sh (:action-to-do w)
{:types #{:create :modify}
 :recursive false
 :async false}
 
 So if I log in as root and start the app like this:
 
 /usr/bin/java -jar /home/jenkins/fiit/fiit-1-standalone.jar
 
 Then at the terminal I see this, which I expect: 
 
 [/home/jenkins/sarr]
 [/home/jenkins/food_for_all]
 
 Those are the 2 directories that it is watching. 
 
 Then if I trigger Jenkins for the sarr app, Jenkins will pull the sarr code 
 from Github, rebuild the sarr uberjar, and move the uberjar to 
 /home/jenkins/sarr. 
 
 All of that works just great. And then my app sees there has been a change 
 in /home/jenkins/sarr, and so it calls the command to kill all existing 
 instances of the sarr app. However, instead of doing this once, it starts 
 doing so an infinite number of times. At the terminal I see: 
 
 (sarr is a Java app, not a Clojure app)
 
 We will kill these processes: \n
 We will kill these processes: \n
 We will kill these processes: \n
 We will kill these processes: \n
 We will kill these processes: \n
 We will kill these processes: \n
 We will kill these processes: \n
 We will kill these processes: \nroot 25593  0.0  0.1 5813460 19452 ?   
 Sl   20:28   0:00 /usr/bin/java -cp /home/jenkins/sarr/sarr.jar 
 com.candle.sarr.Main\nroot 25595  0.0  0.1 5813460 19564 ?   Sl   
 20:28   0:00 /usr/bin/java -cp /home/jenkins/sarr/sarr.jar 
 com.candle.sarr.Main\n25593\n25595\n
 We will kill these processes: \n
 We will kill these processes: \n
 We will kill these processes: \n25694\n
 We will kill these processes: \n
 We will kill these processes: \n
 We will kill these processes: \n
 We will kill these processes: \n
 We will kill these processes: \n
 We will kill these processes: \n
 We will 

Hashing With Consistent Results

2015-08-10 Thread Atamert Ölçgen
Hi,

I need a way to reduce a compound value, say {:foo bar}, into a number
(like 693d9a0698aff95c in hex). I don't necessarily need a very large hash
space, 7 hex digits is good enough for my purposes. But I need
this hash to be consistent between runs and JVM versions etc. So I guess
that rules out standard object hashes.

I would like to find a sufficiently fast way to do this. I can live with
MD5, but are there faster alternatives (but produce smaller hashes)? (
clj-digest https://github.com/tebeka/clj-digest provides a nice interface
to what Java provides but there are only usual suspects AFAICS
http://docs.oracle.com/javase/7/docs/technotes/guides/security/StandardNames.html#MessageDigest
)

I will be dealing with unordered collections, but it seems hashing is
consistent when the input order is changed:

user= (.hashCode {:foo Bar :baz 5})
2040536238
user= (.hashCode {:baz 5 :foo Bar})
2040536238


(It even gave the same hash code in different runs.)

I will use these hashes to build index tables. My data, that contains these
things I hash is a set. I will store this as an ordered set and keep an
index pointing to where records from this hash to that hash lives. This is
all Clojure, but I can't keep all my data in memory. (So Clojure's
persistent data structures is out of the picture. life would've been much
simpler if I could.)

Thanks for reading. Any insight is appreciated.

-- 
Kind Regards,
Atamert Ölçgen

◻◼◻
◻◻◼
◼◼◼

www.muhuk.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
--- 
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: Manifold streams/deferreds raising errors downstream of a sink

2015-08-10 Thread Atamert Ölçgen
Hi Andy,

I would provide a function that wraps put!. It would still return a
deferred, but not the result of put!. It would create a deferred,
representing the result of the computation and pass it down the stream
together with the input. Consumers would set its value once the computation
is done.

I am actually using this technique in a couple of projects and very happy
with it.


On Mon, Aug 10, 2015 at 7:13 AM, Andy Chambers achambers.h...@gmail.com
wrote:

 Hey All,

 I'm trying to build a library that exposes manifold streams for data
 producing applications. The intention
 would be for these apps to s/put! to a sink stream returned by the
 producer function. However, I need to
 take the value that is put in and pipe it into some other function before
 I know whether there is an error
 and if there is an error, I'd like to propagate it back to the caller.

 I understand that the value returned by put! is a deferred, and how to set
 the error state of a deferred but I
 don't understand how I can arrange for the deferred to be manipulated
 downstream of where it has been
 taken off the stream.

 (defn producer []
   (let [in (s/stream)]

 (s/consume (fn [msg]
  (d/future
(prn oops, going to error now)
(throw (Exception. (str msg) in)

 in))

 @(s/put! (producer) 42)

 As written, you get a success response even though an exception was
 triggered by the function that consumes
 the in stream. Is it possible to re-write this so that the exception
 bubbles up to where the put! is deref'd?

 Cheers,
 Andy

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




-- 
Kind Regards,
Atamert Ölçgen

◻◼◻
◻◻◼
◼◼◼

www.muhuk.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
--- 
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: Anotating functions for pre-processing

2015-08-10 Thread Georgi Danov
thanks for all the useful replies. I underwent some pc migration so could 
not answer.

to all that suggest that I rethink the use case — I am fully aware of 
libraries like tools.trace and this approach (with-xyz ...). I am also 
aware of function composition and I enjoy it in many places, but not in 
function definitions. 
It is just that to me this looks way too invasive to my work habits. Yes, 
it's explicit, but to a java dev an annotation (or meta) is equally 
explicit while being less invasive. 

let me explain:
 - while I am developing I am used to quickly annotate methods so that they 
are instrumented to be traced, performance measured, so on
 - this means I am used to put an annotation, do some work, then comment 
it, and keep it around for when I revisit this code so that I uncomment it. 
If it's tracing with some extra config, this is worth it
 - in the final version, when I am releasing it, many, if not all of these 
annotations are gone
 - often some annotations remain in the code, but the facilities that 
process them are switched off on prod, while I switch them on locally on 
demand.
Guess using @Transactional in my example was not the best choice of 
annotation.

doing that with wrapping forms just feels too heavy. Secondary concern gets 
very prominent place and I don't think that's justified. 

How to mark certain blocks for some instrumenting seems to be matter of 
taste to big extent. However, see how the type hints are implemented as 
meta, and that's right and this is comparable to what I want.

As you properly notice the pre-processing approach might bite sometimes, 
but it's the same when using sprig, so that's something I am used to.

Thanks,
Georgi

On Friday, August 7, 2015 at 12:24:51 PM UTC+2, Shantanu Kumar wrote:

 Hi Georgi,

 Have you seen this thread?
 https://groups.google.com/forum/#!topic/clojure/0hKOFQXAwRc

 Shantanu

 On Wednesday, 5 August 2015 17:28:42 UTC+5:30, Georgi Danov wrote:

 Hi,
  I have had good 6 months of fun with Clojure and have big appreciation 
 for it's way of doing things. Coming from the Java/Spring world however, I 
 still have this nagging desire to be able to annotate functions and have 
 some preprocessor pick up these annotations and decorate the code 
 accordingly. Let me illustrate it:

 In Java + Spring
 @Transactional
 public void someFunction(){...}

 the Spring core container has excellent support for preprocessors to 
 instrument this function with some advice.

 -

 I wish I could do that in Clojure:

 (defn ^:transactional someFunction [...] ...)

 and then have somehow means to decorate someFunction (yes, I am aware 
 there is no container)

 I have read some blog posts (about dependency injection in the context of 
 testing clojure) that discuss *alter-var-root,* but that looks like very 
 brutal approach.

 What would be the advice on that? I am even happy to go with solution 
 that involves some micro-container spring-like approach.

 Cheers



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