Re: Any data about just how much loc Clojure shaves off java?

2017-11-19 Thread Ravindra Jaju
Not an apples-and-oranges comparison here. But I was involved in a rewrite
of an existing system exceeding 100K lines of Java code.

When you rewrite, there's a lot more insight and clarity about the purpose,
and the rewrite done in Clojure had the benefit of skipping the useless
bits, while bettering the core parts and extending for missed requirements
(which were very hard to do with the Java code which turned out to be
highly unstable and understand - the whole reason for the rewrite)

We achieved our goal in about 5K lines of Clojure code.

Best,
jaju

On Mon, Nov 20, 2017 at 3:31 AM, Didier  wrote:

> Hi there,
>
> Out of pure curiosity, I was wondering if there was any rewrite or
> equivalent code out there between Java and Clojure that showed exactly how
> many LOC you save from switching to Clojure. Especially for larger
> endeavour.
>
> 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: [ANN] Ring Jetty servlet adapter

2017-11-19 Thread Jiacai Liu
Glad I can help.
If you have any questions, open a issue
 on
github, I will look into it ASAP.

On Sun, Nov 19, 2017 at 11:55 PM, Michael Blume 
wrote:

> I was just about to start figuring out how to do this, for pretty much
> exactly the same reason (the Hystrix metrics stream). Thanks for this, I'm
> looking forward to trying it out.
>
> On Thu, Nov 16, 2017 at 5:23 AM Jiacai Liu  wrote:
>
>> Fork of official jetty adapter
>>  
>> enhanced
>> with servlet-mapping support.
>>
>>
>> Why
>> another adapter
>>
>> Some Java libraries, such as hystrix-metrics-event-stream
>> ,
>> come with util servlets for exposing statistic infomation. But in a purely
>> Ring-based app we can't use those directly, you must convert the servlet
>> into a Ring handler function for use. This is cumbersome, and servlet
>> support should be supported out of box.
>>
>>
>> The codebase stays in step with the official, with version number
>> unchanged. So you can replace the official adapter with this in the least
>> amount of effort.
>>
>>
>>
>> https://github.com/jiacai2050/ring-jetty-servlet-adapter
>>
>>
>>
>> Let me know if you have any suggestions :-)
>>
>> --
>> 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.
>

-- 
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: Any data about just how much loc Clojure shaves off java?

2017-11-19 Thread Alex Miller
I agree that 5-10x is probably a good estimate not knowing anything else. 
Typically the “information objects” are a huge savings and then another large 
savings in data transformation and glue code. Algorithmic code is probably 
smaller. 

Depending on what you’re doing, if there is a lot of repetitive boiler plate 
that can be macroed then 100x is possible.

-- 
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: Any data about just how much loc Clojure shaves off java?

2017-11-19 Thread Rangel Spasov
Very hard to give any sort of scientifically or statistically accurate 
answer to this question but I'll go for it nevertheless ;).

I would say 5-10x (half to one order of magnitude). 

On Sunday, November 19, 2017 at 2:01:12 PM UTC-8, Didier wrote:
>
> Hi there,
>
> Out of pure curiosity, I was wondering if there was any rewrite or 
> equivalent code out there between Java and Clojure that showed exactly how 
> many LOC you save from switching to Clojure. Especially for larger 
> endeavour. 
>
> 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: Map Keywords are functions, why not vector elements?

2017-11-19 Thread Stephen Feyrer
Hi,

A quick thank you to both Gary and Sean and everyone!  I will come back to
this once I have achieved a deeper understanding.

Apologies for the delayed response.


--
Kind regards

Stephen.

On 14 November 2017 at 09:59, Gary Verhaegen 
wrote:

> If you're going to call that for multiple elements of the same vector,
> it's worth thinking about doing some work upfront so that each look-up is
> faster:
>
> (defn indices [vect]
>   (->> vect
>(map-indexed vector)
>(reduce (fn [acc [idx el]]
>  (update acc el (fnil conj []) idx))
>{})))
> (indices [1 "is" 1 :same]){1 [0 2], "is" [1], :same [3]}
>
>
> would walk through the vector only once and create a map of value -> list
> of indices.
>
> On 14 November 2017 at 05:49, Sean Corfield  wrote:
>
>> I don’t think anyone addressed your question about finding all the
>> indices in a vector where the element matches a given search value?
>>
>>
>>
>> There are a number of ways to tackle that (given it’s going to be a
>> linear search). Since you want the indices, you are either going to need to
>> track them directly or use map-indexed to produce them automatically.
>>
>>
>>
>> (defn indices [x l] ; produces a vector
>>
>>   (loop [i 0 l l r []]
>>
>> (if (seq l)
>>
>>   (recur (inc i) (rest l) (if (= x (first l)) (conj r i) r))
>>
>>   r)))
>>
>>
>>
>> (defn indices [x l] ; produces a lazy sequence
>>
>>   (keep identity (map-indexed (fn [i v] (when (= x v) i)) l)))
>>
>>
>>
>> (defn indices [x l] ; produces a vector
>>
>>   (transduce (comp (map-indexed vector)
>>
>>(filter (comp (partial = x) second))
>>
>>(map first))
>>
>>  conj
>>
>>  []
>>
>>  l))
>>
>>
>>
>> Hopefully that’ll give you some options to think about…
>>
>>
>>
>> Sean Corfield -- (970) FOR-SEAN -- (904) 302-SEAN
>> An Architect's View -- http://corfield.org/
>>
>> "If you're not annoying somebody, you're not really alive."
>> -- Margaret Atwood
>>
>>
>> --
>> *From:* clojure@googlegroups.com  on behalf of
>> Stephen Feyrer 
>> *Sent:* Monday, November 13, 2017 5:19:32 PM
>> *To:* clojure@googlegroups.com
>> *Subject:* Re: Map Keywords are functions, why not vector elements?
>>
>> Hi Alex, Didier,
>>
>> Thanks for your patience.
>>
>> That covers everything which I can think of and a fair bit more :)  I
>> have a bit of reading and thinking to do now.
>>
>> Again, thank you.
>>
>>
>> --
>> Rule of thumb simple question, complicated answer
>>
>> Stephen.
>>
>> On 13 November 2017 at 22:09, Didier  wrote:
>>
>>> Yo are looking for indexOf (.indexOf vector value).
>>>
>>> (.indexOf ["a" "b"] "b")
>>> => 1
>>>
>>> (.indexOf ["a" "b" "b"] "b")
>>> => 1
>>>
>>> Note how indexOf searches for the index of the first value which matches
>>> value.
>>>
>>> To do what you ask, is a query over a vector, which requires a search on
>>> each element. This will take O(N) time. For a small list like in your
>>> example its probably good enough and not an issue.
>>>
>>> If you want the name of the horse in a given position, that's a key
>>> lookup, which is ~O(1) time. You can use get:
>>>
>>> (get ["a" "b"] 1)
>>> => "b"
>>>
>>> If you really needed performance, you would need to combine a LinkedList
>>> and a map. Some datastructures do it for you under the hood, like Apache
>>> LinkedMap, amalloy ordered, java LinkedHashMap, etc.
>>>
>>> Its possible to also just use sorted-map-by in a closure. But this only
>>> works if you're not going to add/update things to the datastructure after
>>> first creation.
>>>
>>> See the example on clojuredocs: https://clojuredocs.org/clojur
>>> e.core/sorted-map-by#example-542692d5c026201cdc327094
>>>
>>> --
>>> 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 

Any data about just how much loc Clojure shaves off java?

2017-11-19 Thread Didier
Hi there,

Out of pure curiosity, I was wondering if there was any rewrite or equivalent 
code out there between Java and Clojure that showed exactly how many LOC you 
save from switching to Clojure. Especially for larger endeavour. 

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: [ANN] Ring Jetty servlet adapter

2017-11-19 Thread Michael Blume
I was just about to start figuring out how to do this, for pretty much
exactly the same reason (the Hystrix metrics stream). Thanks for this, I'm
looking forward to trying it out.

On Thu, Nov 16, 2017 at 5:23 AM Jiacai Liu  wrote:

> Fork of official jetty adapter
>  enhanced
> with servlet-mapping support.
>
>
> Why
> another adapter
>
> Some Java libraries, such as hystrix-metrics-event-stream
> ,
> come with util servlets for exposing statistic infomation. But in a purely
> Ring-based app we can't use those directly, you must convert the servlet
> into a Ring handler function for use. This is cumbersome, and servlet
> support should be supported out of box.
>
>
> The codebase stays in step with the official, with version number
> unchanged. So you can replace the official adapter with this in the least
> amount of effort.
>
>
>
> https://github.com/jiacai2050/ring-jetty-servlet-adapter
>
>
>
> Let me know if you have any suggestions :-)
>
> --
> 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.