Re: Clojure as a first programming language?

2016-12-01 Thread Ryan Waters
It's a question simply stated with an answer that depends on a lot of
things. And, as is often the case with the person giving an answer, without
asking other people I can only relate it to my own experiences with clojure
and programming in general.

The fun and freeing thing about clojure is the flexible ways it allows you
to program and think about programming challenges.  There's a number of
reasons that make this true.  Languages I've used in the past at times felt
like their design was limiting, usually in the form of making easy things
easy and hard things harder than necessary.  Maybe they provided too much
"help" and turned inner workings into a difficult-to-know black box, or
they provided concurrency building blocks without providing a safe
framework to prevent a novice programmer from shooting themselves in the
foot, or they were designed in such a way that locking in developer
mindshare was a primary motivator.  I don't think clojure has these
problems.

Diving into a new language requires good learning resources, particularly
in the ways you find most natural to use.  Are you self-sufficient?  Is
documentation enough or would it be faster and more useful to be able to
ask someone questions?  Do you have any higher education in programming?
Buy some clojure books and spend time with them.  The mailing list, IRC and
slack, et. al. can all be resources for specific questions but more general
questions (even this one) can be more difficult to answer.

Pick something you want to make and explore what different languages have
to offer and you'll naturally find one that resonates with you.  I love
clojure.  It's not perfect but it's still smarter than I am, which I
appreciate.  It rarely gets in my way.



On Thu, Dec 1, 2016 at 12:22 PM, Nur Azhar  wrote:

> Hi,
>
> it's almost 8 years later and I am going to ask these same question since
> it wasn't really answered
>
> Thanks for taking the time to read. I’m interested in trying out Clojure
>> for my first programming language--at least, the first programming language
>> in which I intend to commit myself to becoming proficient.
>> http://stackoverflow.com/questions/10509283/clojure-as-
>> a-first-programming-language
>>
> I hope someone replies
>
> On Tuesday, December 1, 2009 at 1:38:58 PM UTC+8, Towle wrote:
>>
>> Hi all,
>>
>> Thanks for taking the time to read my post. I'm interested to get some
>> opinions from experienced Clojure programmers on whether the language
>> would be a good first language to learn, or rather to learn in-depth.
>> I have minimal experienced with more common languages like Java, HTML,
>> and C++, but having the personality I do, felt compelled to shop
>> around a bit before choosing a first language to learn seriously on a
>> deep and intuitive level-- perhaps my odd notion of there being a
>> connection between a programmer and the first language s/he
>> understands on that high of a level. So after shopping around
>> thoroughly and picking up bits about on theoretical computer science
>> and the history of programming languages, I decided to pick up a Lisp;
>> I'm intrigued by the greater concept/idea behind the Lisp family of
>> languages.
>>
>> After a long while trying to figure out which of the Lisps would be a
>> good first choice, I stumbled across Clojure and immediately thought
>> it a brilliant idea, conceding of course that at my current level of
>> knowledge, I likely have no idea what a brilliant idea in computer
>> programming looks like. Regardless, it still feels brilliant.
>>
>> As I see it, among other features of the language, the idea of a Lisp
>> designed to be a capable choice for "real-world" code applications,
>> that is a Lisp which embodies the spirit of that family of languages
>> yet one which resolves many of the "practicality" complaints which
>> stand as hurdles on a Lisp's path to real-world use. For my situation,
>> that of a student who wants both a) to learn a first language I can
>> have a real, intellectual appreciation for and b) to begin the journey
>> to "expertise" in a language it would be practical to code web
>> applications in.
>>
>> So, Clojure programmers, am I wrong? Should I pass on Clojure in favor
>> of another langauge? Or learn Common Lisp or Scheme first, then try my
>> hand at Clojure? Am I mistaken for a different reason? Or perhaps
>> there are some criteria I should consider before diving in?
>>
>> Thanks in advance, and again for taking the time to read.
>> --Towle
>>
> --
> 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 

clojure / H2 interop problem

2015-12-08 Thread Ryan Waters
I'm probably making a dumb mistake but I've been unable to import the
necessary classes to do transactions in H2 (MVMap interface).

I receive the following error at the repl:
---
user=> (in-ns 'asdf.core)
#object[clojure.lang.Namespace 0x46d3c2c8 "asdf.core"]
asdf.core=> (clojure.core/load-file "src/asdf/core.clj")

CompilerException java.lang.ClassNotFoundException:
org.h2.mvstore.db.TransactionStore.Transaction,
compiling:(/home/rwaters/asdf/src/asdf/core.clj:1:1)
asdf.core=>
---

Here's my project.clj:
(defproject asdf "0.1.0-SNAPSHOT"
  :dependencies [[org.clojure/clojure "1.7.0"]
 [com.h2database/h2 "1.4.189"]])

And here's core.clj:
(ns asdf.core
  (:import [org.h2.mvstore MVMap MVStore]
   [org.h2.mvstore.db TransactionStore]
   [org.h2.mvstore.db.TransactionStore Transaction]))


Notice how the imports before 'Transaction' are successful.  I can't seem
to import any class defined in org.h2.mvstore.db.TransactionStore:
https://github.com/h2database/h2database/blob/master/h2/src/main/org/h2/mvstore/db/TransactionStore.java

I was using the following test code as a point of reference:
https://github.com/h2database/h2database/blob/master/h2/src/test/org/h2/test/store/TestTransactionStore.java

Thank you,
Ryan

-- 
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 / H2 interop problem

2015-12-08 Thread Ryan Waters
That works!  I guess I haven't had to import an inner class before.

Thanks.

On Tue, Dec 8, 2015 at 9:09 AM, Alex Miller <a...@puredanger.com> wrote:

> You probably want TransactionStore$Transaction - that's how the jvm refers
> to inner classes.
>
>
> On Tuesday, December 8, 2015 at 9:06:08 AM UTC-6, Ryan Waters wrote:
>>
>> I'm probably making a dumb mistake but I've been unable to import the
>> necessary classes to do transactions in H2 (MVMap interface).
>>
>> I receive the following error at the repl:
>> ---
>> user=> (in-ns 'asdf.core)
>> #object[clojure.lang.Namespace 0x46d3c2c8 "asdf.core"]
>> asdf.core=> (clojure.core/load-file "src/asdf/core.clj")
>>
>> CompilerException java.lang.ClassNotFoundException:
>> org.h2.mvstore.db.TransactionStore.Transaction,
>> compiling:(/home/rwaters/asdf/src/asdf/core.clj:1:1)
>> asdf.core=>
>> ---
>>
>> Here's my project.clj:
>> (defproject asdf "0.1.0-SNAPSHOT"
>>   :dependencies [[org.clojure/clojure "1.7.0"]
>>  [com.h2database/h2 "1.4.189"]])
>>
>> And here's core.clj:
>> (ns asdf.core
>>   (:import [org.h2.mvstore MVMap MVStore]
>>[org.h2.mvstore.db TransactionStore]
>>[org.h2.mvstore.db.TransactionStore Transaction]))
>>
>>
>> Notice how the imports before 'Transaction' are successful.  I can't seem
>> to import any class defined in org.h2.mvstore.db.TransactionStore:
>>
>> https://github.com/h2database/h2database/blob/master/h2/src/main/org/h2/mvstore/db/TransactionStore.java
>> <https://www.google.com/url?q=https%3A%2F%2Fgithub.com%2Fh2database%2Fh2database%2Fblob%2Fmaster%2Fh2%2Fsrc%2Fmain%2Forg%2Fh2%2Fmvstore%2Fdb%2FTransactionStore.java=D=1=AFQjCNGYr8ZgI5CvN_pau3GmKi_GAgI8Zg>
>>
>> I was using the following test code as a point of reference:
>>
>> https://github.com/h2database/h2database/blob/master/h2/src/test/org/h2/test/store/TestTransactionStore.java
>>
>> Thank you,
>> Ryan
>>
>> --
> 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: easy clojure.core.cache interaction

2015-06-11 Thread Ryan Waters
Also worth mentioning is that the implementation is many-thread friendly,
so using a cache:
1) won't be a single thread bottleneck (as in the case of using an
unadorned agent)
2) work is done on the calling threads

Granted, there's a race condition where two threads trying to find the same
thing at the exact same time will result in one thread doing the work and
the other thread waiting (and therefore you don't know which thread would
be doing the work) but this should be exceedingly rare and the work-or-wait
is happening where it should be anyway.

A previous version of the function had the work being done within the agent
which would have killed parallelized I/O for me (in a separate project).


On Thu, Jun 11, 2015 at 9:32 PM, Ryan Waters ryan.or...@gmail.com wrote:

 https://gist.github.com/rwat/4abcebcb4cfae956f382

 I've enjoyed using clojure.core.cache for caching results from time
 expensive operations involving I/O, etc. and feel like this is the sort of
 function that makes c.c.cache as simple to use as possible.  e.g. all it
 becomes is:

 (cache-interact c f k xs)

 where c is the cache (agent), f is the function that generates the value
 you're looking for if it isn't already cached, k is the key to search for
 and xs is optional extra arguments that are apply'ed to f.

 I could have used an agent or atom to store the cache but I don't know how
 much is 'too much' to perform within an atom reset!/swap!.  The operations
 performed within the critical section are all fast but there's a handful of
 them so I decided to err on the side of using an agent.

 Also, I apologize for some of the symbol names.  I don't make it a habit
 to name things in that style.

 I would appreciate any feedback / recommendations for improvement.

 Thank you,
 Ryan


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


easy clojure.core.cache interaction

2015-06-11 Thread Ryan Waters
https://gist.github.com/rwat/4abcebcb4cfae956f382

I've enjoyed using clojure.core.cache for caching results from time
expensive operations involving I/O, etc. and feel like this is the sort of
function that makes c.c.cache as simple to use as possible.  e.g. all it
becomes is:

(cache-interact c f k xs)

where c is the cache (agent), f is the function that generates the value
you're looking for if it isn't already cached, k is the key to search for
and xs is optional extra arguments that are apply'ed to f.

I could have used an agent or atom to store the cache but I don't know how
much is 'too much' to perform within an atom reset!/swap!.  The operations
performed within the critical section are all fast but there's a handful of
them so I decided to err on the side of using an agent.

Also, I apologize for some of the symbol names.  I don't make it a habit to
name things in that style.

I would appreciate any feedback / recommendations for improvement.

Thank you,
Ryan

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


problems using leiningen on Ubuntu 14.10 (and solved)

2015-03-14 Thread Ryan Waters
What follows is an issue I was having with leiningen on a couple new linux
installations.

This writeup is only tangentially related to Clojure but I wanted to email
it out there for others who may run into this same issue.  The following is
relevant for Debian (Jessie) and Ubuntu Server 14.10 as of today.  I forget
which openjdk I was using on debian but on ubuntu it's openjdk-8-jdk.  I'm
also using Leiningen 2.5.1 which I installed via the lein bash script
method.

PROBLEM:

I would get the following when running 'lein deps' within one of my project
directories:
---
Could not transfer artifact lein-cljsbuild:lein-cljsbuild:pom:1.0.3 from/to
central (https://repo1.maven.org/maven2/): java.lang.RuntimeException:
Unexpected error: java.security.InvalidAlgorithmParameterException: the
trustAnchors parameter must be non-empty
This could be due to a typo in :dependencies or network issues.
If you are behind a proxy, try setting the 'http_proxy' environment
variable.
---

Some searches suggested I might have an empty java keystore which turned
out to be the case:
---
keytool -list -keystore
/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/lib/security/cacerts -v
Enter keystore password:

...

Keystore type: JKS
Keystore provider: SUN

Your keystore contains 0 entries
---

SOLUTION:

An explanation of the root problem with a resolution can be found here:
https://justus.berlin/2015/01/connection-problems-with-ssltls-peers-in-java-on-ubuntu-server-14-12-with-fix/

In short, it appears the keystore generation script that should run after a
jdk ubuntu+debian package is installed doesn't end up running when it needs
to, so one must:

---
root@gl:~# rm /etc/ssl/certs/java/cacerts
root@gl:~# /var/lib/dpkg/info/ca-certificates-java.postinst configure
---

Again, all credit to 'justus.berlin' for this fix.

- - -

Sidenote - I had an unrelated problem with wget and curl connecting to
/any/ SSL website under Debian Jessie, even with 'ca-certificates' package
installed.  That's just lame.

Anyway, I hope this helps save somebody some time and/or bumps up google
search results for the link above.

Thanks,
Ryan

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


vertigo question

2015-01-27 Thread Ryan Waters
In working with vertigo I've found the need to parameterize the struct
field I wish to examine.  Unfortunately vertigo doesn't seem to like vars
in its macros.  For example:

- - - -
;; vs is 'vertigo.structs and vc is 'vertigo.core

(vs/def-typed-struct mystruct :ints (vs/array vs/uint32 10))
(def ^:mystruct vert (vc/marshal-seq mystruct [{:ints (range 10)}]))

(vc/get-in vert [0 :ints 1])
1  ;; works, returns 1

(let [^clojure.lang.Keyword x :ints] (vc/get-in vert [0 x 1]))
CompilerException java.lang.IllegalArgumentException: 'x' is assumed to be
numeric, which isn't accepted by mystruct,
compiling:(form-init1370835477311955482.clj:1:38)


- - - -
I originally ran into this when using vc/over within vc/doreduce.  I'm
using vertigo 0.1.3.

Thanks!
Ryan

-- 
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] async-sockets - work with sockets using core.async channels

2014-10-12 Thread Ryan Waters
I was just starting to use Sente [1] (which relies on httpkit [2]) and this
conversation is a real eye opener.  Unless a person uses a library that
supports backpressure, as mentioned earlier, your
transport-concern-made-opaque-because-of-core-async must become an
application-level concern.  The far-side of the communication would have to
respond with an application level acknowledgement for local sends and the
local side would need to not send data unless acks were received for
previously sent data.

E.g. this could be implemented with core.async by using a pair of channels
(instead of a single channel) for all 'sends' where one channel is used for
data while the other channel waits for acknowledgement of put data (a
'control' channel).  This would have the unfortunate side effect of hurting
throughput.  A better system would be to allow for a certain number of
unacknowledged sends before backing off.  Of course, now a person is
implementing what was created for TCP at the level of their application.

Christophe's approach means you at least wouldn't have to do the above,
replacing it instead with a per backend implementation.  I hope somebody
else is able to explain it better.

Looking forward to an Aleph rewrite!!

- - -
[1] https://github.com/ptaoussanis/sente
[2] https://github.com/http-kit/http-kit

On Sat, Oct 11, 2014 at 8:01 PM, Julian juliangam...@gmail.com wrote:

 Hi Zach,

 Thanks for the clarity of thought that went into this post.

 Perhaps it is obvious to everyone but me, but I saw this post by
 Christophe Grande yesterday that appears to address these concerns:
 Back-pressurized interop for core.async
 https://twitter.com/cgrand/status/520566182194450432
 https://gist.github.com/cgrand/767673242b7f7c27f35a

 I'm interested to hear if this solves your problem or is about something
 else.

 Cheers
 Julian


 On Wednesday, 8 October 2014 17:00:02 UTC+11, Zach Tellman wrote:

 The reason the thread-per-connection approach is nice is because it
 correctly propagates backpressure.  If we're copying data from a source to
 a sink (let's say reading it in from the network and writing to a file),
 it's possible that the production of data may outstrip the consumption.  If
 this happens, we need to make sure the producer slows down, or we risk
 running out of memory.  In Java, the producer is typically connected to the
 consumer via a blocking queue, and if the queue fills up the producer can't
 send anything more to the consumer.  A Java socket is one such queue, and
 if it fills up it will exert backpressure via TCP.  This will work no
 matter how many queues or other mechanisms separate the producer and
 consumer.

 However, every attempt I've seen to marry core.async to an async network
 stack has been fundamentally broken, in that it doesn't do this.  Often,
 they'll just use 'put!', which works fine until the channel's queue fills
 up, and 1024 pending puts are accumulated, and finally the channel throws
 an exception.  Alternately, they'll use a blocking put on the channel,
 which means that any backpressure will also extend to whatever other
 connections are sharing that thread or the thread pool.  Note that the
 software that uses core.async in this way may work flawlessly in a wide
 variety of cases, but there's still an intractable failure mode lying in
 wait.

 In some cases, such as http-kit's websocket mechanism, there's no way to
 even exert backpressure (you register a callback, and have no way to
 indicate in your callback that you can't handle more messages).  This means
 that any attempt to use http-kit in conjunction with core.async will be
 subtly but fundamentally broken.  Arguably, even without core.async in the
 equation it's broken.  This is not a good state of affairs.  I'll admit
 that it took me a few failures in production to realize how important
 correct handling of backpressure is, but this isn't something that our
 ecosystem can afford to ignore, especially as Clojure is used for
 larger-scale projects.

 I will note that I am working on a solution to this, in the form of the
 upcoming Aleph release [1].  This will model every network connection via
 streams that can trivially be converted into core.async channels [2], and
 which exert backpressure over TCP wherever necessary without requiring a
 thread per connection.  A formal beta should be available in the near
 future (it's already handling billions of requests a day in production
 without issue).

 Zach

 [1] https://github.com/ztellman/aleph/tree/0.4.0
 [2] https://github.com/ztellman/manifold



 On Tuesday, October 7, 2014 1:36:16 PM UTC-7, adrian...@mail.yu.edu
 wrote:

 It's not about 'safety' (depending on what that means in this context),
 but as Zach pointed out, if you aren't careful about backpressure you can
 run into performance bottlenecks with unrestrained async IO operations
 because although they let you code as if you could handle an unlimited
 amount of connections, obviously that isn't true. 

probably a noobie question: apparent memory leak

2014-03-29 Thread Ryan Waters
I have some code that blows up the heap and I'm not sure why.  I've reduced
it down to the following.

I've tried to make sure the atom doesn't have boundless growth and I didn't
think 'while' hangs on to the head of sequences so I'm embarrassed to say
I'm stumped.


(defn leaks-memory
  []
  (let [mem (atom [])
chunksize 1000
threshold 2000]
  (while true
(swap! mem conj (rand-int 100))

; every 'chunksize' item past 'threshold'
(when (and (= 0 (mod (count @mem) chunksize))
   ( (count @mem) threshold))
  (swap! mem subvec chunksize)

-- 
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: probably a noobie question: apparent memory leak

2014-03-29 Thread Ryan Waters
If you do a (count @mem) it reports the length of the atom's vector isn't
growing without bounds.  It seems counterintuitive that the parts of the
old vector wouldn't get garbage collected because the atom no longer points
to them.  But I guess I need to rtfd.

Thank you.


On Sat, Mar 29, 2014 at 10:07 AM, Aaron Cohen aa...@assonance.org wrote:



 On Sat, Mar 29, 2014 at 10:09 AM, Ryan Waters ryan.or...@gmail.comwrote:

 I have some code that blows up the heap and I'm not sure why.  I've
 reduced it down to the following.

 I've tried to make sure the atom doesn't have boundless growth and I
 didn't think 'while' hangs on to the head of sequences so I'm embarrassed
 to say I'm stumped.


 (defn leaks-memory
   []
   (let [mem (atom [])
 chunksize 1000
 threshold 2000]
   (while true
 (swap! mem conj (rand-int 100))

 ; every 'chunksize' item past 'threshold'
 (when (and (= 0 (mod (count @mem) chunksize))
( (count @mem) threshold))
   (swap! mem subvec chunksize)

 (doc subvec)

 Returns a persistent vector of the items in vector from
 start (inclusive) to end (exclusive). If end is not supplied,
 defaults to (count vector). This operation is O(1) and very fast, as
 the resulting vector shares structure with the original and no
 trimming is done.

 subvec is fast, but it's not saving you any memory.

 --
 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: probably a noobie question: apparent memory leak

2014-03-29 Thread Ryan Waters
Nice!  I hadn't seen that before.

Thank you both.


On Sat, Mar 29, 2014 at 3:29 PM, Jonas jonas.enl...@gmail.com wrote:

 You could give core.rrb-vector[1]. From the docs:

 The main API entry points are clojure.core.rrb-vector/catvec,
 performing vector concatenation, and clojure.core.rrb-vector/subvec, which
 produces a new vector containing the appropriate subrange of the input
 vector (in contrast to clojure.core/subvec, which returns a view on the
 input vector).

 [1] https://github.com/clojure/core.rrb-vector


 On Saturday, March 29, 2014 8:42:25 PM UTC+2, Ryan Waters wrote:

 If you do a (count @mem) it reports the length of the atom's vector isn't
 growing without bounds.  It seems counterintuitive that the parts of the
 old vector wouldn't get garbage collected because the atom no longer points
 to them.  But I guess I need to rtfd.

 Thank you.


 On Sat, Mar 29, 2014 at 10:07 AM, Aaron Cohen aa...@assonance.orgwrote:



 On Sat, Mar 29, 2014 at 10:09 AM, Ryan Waters ryan@gmail.comwrote:

 I have some code that blows up the heap and I'm not sure why.  I've
 reduced it down to the following.

 I've tried to make sure the atom doesn't have boundless growth and I
 didn't think 'while' hangs on to the head of sequences so I'm embarrassed
 to say I'm stumped.


 (defn leaks-memory
   []
   (let [mem (atom [])
 chunksize 1000
 threshold 2000]
   (while true
 (swap! mem conj (rand-int 100))

 ; every 'chunksize' item past 'threshold'
 (when (and (= 0 (mod (count @mem) chunksize))
( (count @mem) threshold))
   (swap! mem subvec chunksize)

 (doc subvec)

 Returns a persistent vector of the items in vector from
 start (inclusive) to end (exclusive). If end is not supplied,
 defaults to (count vector). This operation is O(1) and very fast, as
 the resulting vector shares structure with the original and no
 trimming is done.

 subvec is fast, but it's not saving you any memory.

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


-- 
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: Does Pedestal have a future in the long run

2013-11-10 Thread Ryan Waters
Thank you Saravana.  I'm finding a number of the posts David Nolen [1] has
written on his blog to be invaluable.  Once I figure out what mix of
libraries I'll be using I can let you know!

[1] http://swannodette.github.io/


On Sat, Nov 9, 2013 at 12:33 PM, Ryan Neufeld r...@cognitect.com wrote:

 Stuart Halloway is doing a presentation and we’ll be dumping a lot more
 new stuff into the repository. I made a mistake in saying we had an
 announcement, it’s more just that we’ll be talking more publicly about what
 we’re working on following next week.

 -Ryan


 On November 8, 2013 at 5:39:34 PM, Andreas Liljeqvist 
 (bon...@gmail.com//bon...@gmail.com)
 wrote:

  Will there by any presentation on Pedestal, or just announcements?


 On Fri, Nov 8, 2013 at 1:38 AM, Ryan Neufeld r...@thinkrelevance.comwrote:

 Speaking as a core Pedestal team member and engineer at Cognitect I can
 say we are *very* serious about continuing to grow and support Pedestal.
 It may be quiet, but we're using the entirety of Pedestal with a number of
 client and are fervently preparing a number of new features and
 improvements we plan to announce at the Conj next week. Further, we've even
 begun selling commercial support that includes Pedestal[1].

 ClojureScript One was a huge influence on pedestal-app, but you're
 completely right that we've abandoned it and should probably wind things
 down there.

 Are there any other questions I can field while I'm here?

  -Ryan

 [1]: http://cognitect.com/Cognitect-Support-Services.pdf


 On Thursday, November 7, 2013 5:30:59 PM UTC-5, Marko Kocić wrote:

 Hi all,

 I'd like to hear opinions about Pedestal from the people that have been
 playing more with it. Right now I started looking at it, and like some of
 the things, but not sure should I invest more time learning it. While I do
 like some concepts, I'm not sure is it going to became abandonware like
 Clojurescript One (does anyone reemembers it anymore).

 So far, after initial splash, I haven't seen large community interest in
 it. The number of aproachable getting started guides and hands on tutorials
 is missing. That might change over time, but I'm afraid that next year this
 time we'll get another Clojurescript one page application framework not
 much related with Pedestal. How serious Cognitect/Relevance is about it?

 Best regards,
 Marko

 --
 --
 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/groups/opt_out.


 --
 --
 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 a topic in the
 Google Groups Clojure group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/clojure/XQ4wuUc0bCk/unsubscribe.
 To unsubscribe from this group and all its topics, send an email to
 clojure+unsubscr...@googlegroups.com.

 For more options, visit https://groups.google.com/groups/opt_out.

  --
 --
 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/groups/opt_out.


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

Re: Does Pedestal have a future in the long run

2013-11-08 Thread Ryan Waters
Pedestal-app and pedestal-service seem like they have a lot of solid design
behind them and there's quite a few bright people that have put time into
development and documentation.  I don't doubt Cognitect's dedication to the
project or their ability to derive productivity from it.

I program in clojure on a part-time basis and when I first learned about
pedestal (specifically pedestal-app) it was very promising.  I wanted to
see if the next website I made (using clojurescript in the browser and
clojure on the server) would be a good match for pedestal and I've spent
the past couple months reading (and re-reading ... and re-reading ...) the
available pedestal-app documentation, pedestal sample apps and especially
the app-tutorial.

After many hours I've decided to move away from pedestal-app, at least for
the time being.  Earlier I had done some proof-of-concept UI stuff with C2
(think moving an array of images a la google maps) which went pretty well.
 It was my first time learning and using clojurescript and C2; cljsbuild
was a delight.  I decided the next step was to try to take what I had and
translate that into pedestal-app.  The message oriented communication
between different parts of the app, the ability to build client-server
communication without a server, the ability to step through recordings of
app interactions for testing, shared clojure / clojurescript code, etc.
were all very appealing.  Especially compared to plain javascript in a
browser, there's the ability to use clojurescript (a win), the ability to
avoid callback mess (which can also be avoided through FRP stuff like
javelin), and a message oriented architecture (which seems superior to
FRP?) which all made pedestal very compelling.

Each time I worked with pedestal-app I would make some progress but
progress was slow.  I was wading through a swamp of maybe strange
convention and overcomplication.  app-tutorial was at times illuminating
and cryptic; each read through would teach me something that I thought
could have been, perhaps, better explained than it was.  I wanted to
re-write the whole of app-tutorial and offer it up as supplemental
documentation but I wanted to work on my website more.

Another aspect to my story is that I don't know of anyone else that uses
any of this stuff so outlets for questions are limited to mailings lists
and IRC and I try to keep myself from asking bad or 'obvious' questions to
that helpful crowd  ; )

I've since moved on to looking at using a collection of libraries like
hiccup/domina/dommy/whatever for DOM stuff (I don't care - they would all
work for my needs) and - *crucially* - using core.async as the glue that
will facilitate the interactions between all the pieces of the UI stuff.  I
have renewed excitement for the project that I'm working on because I'm no
longer stuck in slow motion.  Again, I only essentially have hobby time
to work on this but in one week of learning core.async, with special thanks
to David Nolen's tutorials and example code, I know how to proceed.  I'll
have to write some additional stuff that pedestal-app would have provided
out of the gate but it's nothing daunting.  And it's exciting.

Pedestal-app was too cumbersome for me, overly complicated and/or not the
kind of documentation I wanted but there's still a lot of great ideas
behind it.  I'm interested to see what pedestal-app's rate of adoption and
new developments will be, too, and it might be something I would return to
in the future.




On Fri, Nov 8, 2013 at 4:39 PM, Andreas Liljeqvist bon...@gmail.com wrote:

 Will there by any presentation on Pedestal, or just announcements?


 On Fri, Nov 8, 2013 at 1:38 AM, Ryan Neufeld r...@thinkrelevance.comwrote:

 Speaking as a core Pedestal team member and engineer at Cognitect I can
 say we are *very* serious about continuing to grow and support Pedestal.
 It may be quiet, but we're using the entirety of Pedestal with a number of
 client and are fervently preparing a number of new features and
 improvements we plan to announce at the Conj next week. Further, we've even
 begun selling commercial support that includes Pedestal[1].

 ClojureScript One was a huge influence on pedestal-app, but you're
 completely right that we've abandoned it and should probably wind things
 down there.

 Are there any other questions I can field while I'm here?

 -Ryan

 [1]: http://cognitect.com/Cognitect-Support-Services.pdf


 On Thursday, November 7, 2013 5:30:59 PM UTC-5, Marko Kocić wrote:

 Hi all,

 I'd like to hear opinions about Pedestal from the people that have been
 playing more with it. Right now I started looking at it, and like some of
 the things, but not sure should I invest more time learning it. While I do
 like some concepts, I'm not sure is it going to became abandonware like
 Clojurescript One (does anyone reemembers it anymore).

 So far, after initial splash, I haven't seen large community interest in
 it. The number of aproachable getting started guides and hands 

cond-let

2013-10-05 Thread Ryan Waters
Is cond-let not part of modular contrib?  If it is, where is it?  All the
github sources I've seen either:
a) define it themselves
b) use a non-contrib library
c) grab it from monolithic (old) contrib

clojure.org is no help, nor is dev.clojure.org.  clojuredocs.org is out of
date and clojure-doc.org doesn't have it.  At least clojure.org has the
clojure cheetsheet - perhaps the one URL I use off that site.  If anyone
can also enlighten my ignorance on better ways to find the functions
provided by contrib, short of reading each one in turn, that would be cool
too.

No one I know uses clojure and I don't live in an area with clojure meetups
or conjs so I apologize in advance for what may be silly questions and
rantings.

Thank you!
Ryan

-- 
-- 
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/groups/opt_out.


Re: cond-let

2013-10-05 Thread Ryan Waters
I'm glad I didn't miss anything too obvious!  Sometimes it's hard to know
when to continue to look on my own vs. calling out for help (but
potentially wasting other people's time).  Thank you for your time and good
suggestions.


On Sat, Oct 5, 2013 at 12:07 PM, Andy Fingerhut andy.finger...@gmail.comwrote:

 And given your locale, I would highly recommend the #clojure IRC channel.


 On Sat, Oct 5, 2013 at 8:45 AM, Ryan Waters ryan.or...@gmail.com wrote:

 Is cond-let not part of modular contrib?  If it is, where is it?  All the
 github sources I've seen either:
 a) define it themselves
 b) use a non-contrib library
 c) grab it from monolithic (old) contrib

 clojure.org is no help, nor is dev.clojure.org.  clojuredocs.org is out
 of date and clojure-doc.org doesn't have it.  At least clojure.org has
 the clojure cheetsheet - perhaps the one URL I use off that site.  If
 anyone can also enlighten my ignorance on better ways to find the functions
 provided by contrib, short of reading each one in turn, that would be cool
 too.

 No one I know uses clojure and I don't live in an area with clojure
 meetups or conjs so I apologize in advance for what may be silly questions
 and rantings.

 Thank you!
 Ryan



  --
 --
 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/groups/opt_out.


  --
 --
 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/groups/opt_out.


-- 
-- 
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/groups/opt_out.


Re: [ANN] New Version of ClojureScript One

2012-01-25 Thread Ryan Waters
On Wed, Jan 25, 2012 at 2:40 PM, Brenton bashw...@gmail.com wrote:
 We have released a new version of ClojureScript One.

 ...

 No more scripts! Everything now works through Leiningen. We have added
 support for retrieveing git dependencies via Leiningen.


It's nice that leiningen can handle the classpath issues and repl now.
 I bet clojure-jack-in works too.  Thank you!

- Ryan

-- 
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: Best IDE

2012-01-18 Thread Ryan Waters
On Wed, Jan 18, 2012 at 1:35 PM, Jeb Beich jebbe...@gmail.com wrote:
 Any suggestions for a vim man?


Jeb -

I'd recommend either vimclojure or emacs + Evil.  I recently switched
from the former to the latter and the transition hasn't been too bad.
I wanted the abilities of emacs + slime + swank, leiningen
integration, a large community of clojure users, etc. with vim
keybindings.

I tried vimclojure for a while but it helps if you really know vim.  I
figured if I was going to put that much time into an editor then I
might as well give an earnest try with what most clojure programmers
use.  That said, you can get vimclojure basics (no integrated repl,
etc.) running in no time with little expertise.

- Ryan

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


ClojureScript One and remote development

2012-01-12 Thread Ryan Waters
I ran into an issue with remote development and ClojureScript One and
thought I'd share with others who potentially will run into the same
issue.

If I want to access ClojureScript One on ComputerA from ComputerB then
I have to tunnel or port forward my request to ComputerA's
localhost:8080.  That's pretty self-evident.  However, I couldn't get
(cljs-repl) stuff to live update.  Instead the repl prompt would hang
and I nothing would change in my browser.  It turns out the long poll
XHR request runs over port 9000 so you need to forward or tunnel both
8080 and 9000 for everything to be happy.

This can be accomplished, e.g, with the following from ComputerB:

ssh -N -L localhost:8080:localhost:8080 -L
localhost:9000:localhost:9000 user@computera


- Ryan

-- 
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] ClojureScript One - Getting Started with ClojureScript

2012-01-11 Thread Ryan Waters
On Wed, Jan 11, 2012 at 1:27 PM, Brenton bashw...@gmail.com wrote:
 Today we are releasing ClojureScript One. A project to help you get
 started writing single-page applications in ClojureScript.


Can we quote Rich as saying This is Awesome?  This looks so thorough
and well-executed - very exciting.  Thank you.

- Ryan

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


goog.debug.Logger from clojurescript or how to hide mutability with a functional approach

2012-01-10 Thread Ryan Waters
I'd like to use clojurescript to set up a gclosure logger
(goog.debug.Logger) similar to the closure demo [1].  The slightly
modified javascript for this is below.  How should clojurescript
insulate the programmer from the mutability issues?
1) log level mutates a LogManager object
2) a logconsole object is created that will receive logger messages
3) a logger object is created

I know I can get this to work but I want to do it the best way
possible and minimize cringing on the part of clojure programmers who
know the language and functional programming better than I do.

How about a single logging function that has a defonce for an atom
which sets up 1), 2), and 3) and then uses the atom (the logger
object) to reference the relevant logging method?  (e.g. info)  Also,
it's my understanding that clojurescript doesn't support private
declarations so defonce- is not possible.  My reservation is a def (or
defonce) shouldn't be nested in a defn.

There's got to be a better way and thank you for the feedback.

- Ryan

-

(defn g-log
  [msg]
  (defonce g-logger (atom (let blah blah ...
  (.info g-logger msg))

-

//
// javascript based on google closure demo
//

// Set log level
goog.debug.LogManager.getRoot().setLevel(goog.debug.Logger.Level.ALL);

// enable logger to receive logging messages
var logconsole = new goog.debug.DivConsole(goog.dom.getElement('log'));
logconsole.setCapturing(true);

// create logging object
var logger = goog.debug.Logger.getLogger('demo');

// now we can log stuff
logger.info(This is a log message);


-
[1] 
http://closure-library.googlecode.com/svn/trunk/closure/goog/demos/button.html

-- 
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: Struggling in making a sub-process work in an interactive way

2012-01-10 Thread Ryan Waters
On Mon, Jan 9, 2012 at 11:20 PM, jaime xiejianm...@gmail.com wrote:

 now it works fine for NON-interactive command such as dir or help,
 but it will hang when I send the shell commands that require user
 input, such as time. I think the reason is that my code doesn't
 detect any input requirement so the shell keep waiting for an input
 infinitely.


You could get around the blocking I/O problem with
java.nio.channels.Selector and the like.  Wrapping or duplicating what
expect4j does would do the trick.

http://code.google.com/p/expect4j/

- Ryan

-- 
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: ClojureScript DOM-manipulation library?

2012-01-07 Thread Ryan Waters
On Fri, Jan 6, 2012 at 2:02 PM, kovas boguta kovas.bog...@gmail.com wrote:
 I think what matters is the design. Jquery is an accessible
 implementation target, but if someone wants to retarget the design to
 gclosure, thats fine too (just more work than is need to get started)


Chris and Kovas -

By going with jquery how well does your clojurescript compile-time
check and minify?  Have you written anything that sufficiently tests
compatibility with the gclosure compiler?

- Ryan

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


basic exception handling

2011-01-24 Thread Ryan Waters
The following code doesn't catch the exception thrown like I think it
should.  Any recommendations appreciated.

https://gist.github.com/793340

Thank you,
Ryan

- - - -

(ns my-ns
  (:use [clj-time.core :only [date-time]]))

(defn my-date-time
  same as clj-time.core date-time but returns nil on improper input
  [ args]
  (try
(apply date-time (map #(Integer/parseInt %) args))
(catch NumberFormatException e hi)))

; works
(println (my-date-time 2011 01 01))

; errors out but should be caught in try/catch
(println (my-date-time 2011 asdf 01))


- - - - output


#DateTime 2011-01-01T00:00:00.000Z
Exception in thread main java.lang.RuntimeException:
java.lang.NumberFormatException: For input string: asdf (temp.clj:0)
at clojure.lang.Compiler.eval(Compiler.java:5440)
at clojure.lang.Compiler.load(Compiler.java:5857)
at clojure.lang.Compiler.loadFile(Compiler.java:5820)
at clojure.main$load_script.invoke(main.clj:221)
at clojure.main$script_opt.invoke(main.clj:273)
at clojure.main$main.doInvoke(main.clj:354)
at clojure.lang.RestFn.invoke(RestFn.java:437)
at clojure.lang.Var.invoke(Var.java:373)
at clojure.lang.AFn.applyToHelper(AFn.java:169)
at clojure.lang.Var.applyTo(Var.java:482)
at clojure.main.main(main.java:37)
Caused by: java.lang.RuntimeException:
java.lang.NumberFormatException: For input string: asdf
at clojure.lang.LazySeq.sval(LazySeq.java:47)
at clojure.lang.LazySeq.seq(LazySeq.java:56)
at clojure.lang.Cons.next(Cons.java:39)
at clojure.lang.RT.boundedLength(RT.java:1186)
at clojure.lang.AFn.applyToHelper(AFn.java:155)
at clojure.lang.AFn.applyTo(AFn.java:151)
at clojure.core$apply.invoke(core.clj:540)
at my_ns$my_date_time.doInvoke(temp.clj:8)
at clojure.lang.RestFn.invoke(RestFn.java:437)
at my_ns$eval64.invoke(temp.clj:13)
at clojure.lang.Compiler.eval(Compiler.java:5424)
... 10 more
Caused by: java.lang.NumberFormatException: For input string: asdf
at 
java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
at java.lang.Integer.parseInt(Integer.java:449)
at java.lang.Integer.parseInt(Integer.java:499)
at my_ns$my_date_time$fn__59.invoke(temp.clj:8)
at clojure.core$map$fn__3695.invoke(core.clj:2096)
at clojure.lang.LazySeq.sval(LazySeq.java:42)
... 20 more

-- 
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: basic exception handling

2011-01-24 Thread Ryan Waters
Thank you Ken - I should have checked for Exception; not sure why I
didn't.  Your other explanations were helpful too.

-- 
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: Collapse some functions? (was Re: clojure.core function decision tree)

2010-11-10 Thread Ryan Waters
Not to veer a hijack, but a 'popular' or common functions group could
be useful for people learning clojure. It could be assembled by taking
the number of occurrences in a set of code or by being hand-picked by
people-who-should-know.  Everyone who uses clojure should have an idea
of everything that's available but nobody waits to write a program
until they've memorized the language libraries.

Giving people the hints on what to prioritize in their clojure
learning and what tools (functions, etc.) to pick from in their
clojure use would both help them to write their first programs and
maybe speed learning overall due to more efficient use of time.

- Ryan


On Wed, Nov 10, 2010 at 10:37 AM, Gary Poster gary.pos...@gmail.com wrote:

 On Nov 10, 2010, at 11:16 AM, Meikel Brandmeyer wrote:

 Hi,

 On 10 Nov., 17:09, Gary Poster gary.pos...@gmail.com wrote:

 I believe that the cost of having developers remember both rseq and reverse 
 (why can't reverse just DTRT if it is given a vector?), last and peek 
 (same), butlast and pop (same), and nth and get (same) is unnecessarily 
 high.

 Ehm. No.

 rseq O(1), reverse O(n).
 peek O(1), last O(n).
 pop O(1), butlast O(n).
 get O(1), nth O(n).

 (Where O(1) might sometimes mean O(log32 n))

 The different functions are there under different names, because they
 have different performance promises.

 But that's exactly my point.  Why should developers have to remember to use 
 rseq on a vector, as the first example?  Why can't reverse simply be part of 
 a protocol, so that it gives O(1) when it can?  Is there *any* practical 
 value to having reverse have O(n) performance on a vector?  Clojure is 
 advertised as a practical language (I remember reading it early in JoC, for 
 instance), and I don't see it here.

 Then peek is not equivalent to
 last. For lists it is equivalent to first.

 OK, thank you.  As I said initially, the email could have been researched 
 better, but the larger thought is still valid, with other reasonable examples.

 Gary


-- 
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: Images in autodoc?

2010-10-30 Thread Ryan Waters
+1 on the side of enhancing clojure's core documentation


On Thu, Oct 28, 2010 at 1:08 PM, Chris Maier
christopher.ma...@gmail.com wrote:
 My interest is general improvement of Clojure documentation.  At the
 conj, I spoke with Zack Kim about helping to improve the state of the
 documentation.  My goal was to contribute additional documentation for
 vars that are lacking, as well as clarifying some of the more
 confusing doc strings (actually as a result of our talk, Zack is
 adding some community features to ClojureDocs where we can all comment
 and discuss doc string and submit possible revisions).  As I started
 looking over the docs, it occurred to me that it would be nice to be
 able to format the strings (code formatting, bold, italics, lists,
 links, etc.), as well as add images where appropriate (I thought it
 might be helpful to have some images for describing how zippers work,
 for example).

 I wouldn't mind having these features for my own projects, but I think
 that Clojure as a whole could benefit from these improvements;
 anything to make it easier for newcomers to get up to speed.

 Chris


-- 
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: Conj arrivals and Thursday night...

2010-10-18 Thread Ryan Waters
I probably wouldn't be able to show up until 8:00pm but I'd be
interested in getting on the 'list' for said group.

Thanks,
Ryan


On Mon, Oct 18, 2010 at 11:32 AM, Andrew Gwozdziewycz apg...@gmail.com wrote:
 Hey Conj goers,

 I'm scheduled to arrive around 6:30, and after I check in am planning
 to spend the rest of the night writing code. Anyone want to help
 commandeer a random lobby to join in on the fun?

 Andrew
 --
 http://www.apgwoz.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 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: Learning clojure? Here's a practical example using clojure and nmap.

2010-07-26 Thread Ryan Waters
I don't have a website I maintain right now so I thought I'd post this
to the mailing list.

I have a need to scan a list of IP addresses and I wanted the scan
order to be random.  Nmap can do this.  However, I also want the scan
order to be consistent so I can do handy things like diff output logs
for changes.  The following program generates a list of IPs,
randomizes their order, and outputs to a file.

The program ends up being very small but expressive; I developed
against Clojure 1.1.  Because this was one of my first clojure
programs, it took a long time to write and I'd like the thank everyone
that answered my questions in IRC and the mailing list.

For completeness' sake, you can use the list of IPs with e.g. the
following nmap command:
nmap -iL ips.txt -sP -oG scanned_results.txt

http://gist.github.com/484747

- - - -

; Generate a list of random IPs to be fed into nmap so that nmap may scan
; aggressively but not swamp any given subnet within the 172.16.0.0/12 range.
;
; Licensed under the EPL (fwiw  ;)

(use '[clojure.contrib.seq-utils :only (shuffle)]
 '[clojure.contrib.duck-streams :only (write-lines)])

(write-lines
  ./ips.txt
  (shuffle
(for [octet1 [172]
  octet2 (range 16 33)
  octet3 (range 256)
  octet4 (range 256)]
  (str octet1 \. octet2 \. octet3 \. octet4

- - - -

- Ryan (arkh)

-- 
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: Feedback on Clojure web development post

2010-07-24 Thread Ryan Waters
Thank you, Mark.  It's awesome when someone has the patience, time and
interest in putting something like this together so others may learn
faster.  I know I'll benefit from it.

- Ryan
(irc nick arkh)


On Sat, Jul 24, 2010 at 2:30 AM, Mark McGranaghan mmcgr...@gmail.com wrote:
 Hi All,

 I recently posted to my blog on the process of developing and
 deploying a simple Clojure web application:

 http://mmcgrana.github.com/2010/07/develop-deploy-clojure-web-applications.html

 (more in previous post)

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


randomizing a vector

2010-07-21 Thread Ryan Waters
http://gist.github.com/484747

- - -

My sad little program has a number of issues and I would welcome
suggestions on any aspect of it.  I come from an imperative
programming background and clojure is my first experience with a
functional or lisp language.

I'd like to take a list of things (really, a vector) and randomly add
items of that list to another list.  I chose to work with vectors
because clojure is efficient at adding things their ends and because I
can address their consistent ordering with an index.

Issues:

1) Idiomatic: please point out anything that looks generally awkward
or otherwise less than ideal for clojure (and suggest an alternative)
: )  For example, in my loop I rebind symbols to themselves and have
received mixed advice on IRC as to whether it's appropriate to do
that.

2) Transients: For speed and because I don't care about the
intermediate values of the vectors, I'd like to use them.  I was able
to easily work with the transient vector 'random-ips' but receive an
error when trying to wrap the vector 'ordered-ips' in a transient:
Exception in thread main java.lang.ClassCastException:
clojure.lang.PersistentVector$TransientVector cannot be cast to
clojure.lang.IPersistentVector (gen_ips.clj:36)

3) Overall speed: it's abysmal but I don't blame Clojure.  It's either
because I'm Doing It Wrong or what I'm doing is simply expensive in a
big O notation sort of way.  I'm trying to randomly order 1.1 million
strings.

4) Clojure side-gripe: I wish it were easier to mix clojure's
different 'types': vectors, lazy sequences, etc.  It's probably an
ignorance thing on my part but, for what I know right now, I find
using different macros with all the different return types
problematic.

- - -

Thanks in advance to addressing one or more of these issues!

- Ryan

-- 
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: randomizing a vector

2010-07-21 Thread Ryan Waters
I'm currently using clojure 1.1 and wasn't aware of shuffle in the
contrib libraries.

It felt like a wheel reinvention ... I should have looked harder!

Thank you.


On Wed, Jul 21, 2010 at 12:51 PM, Randy Hudson randy_hud...@mac.com wrote:
 Clojure 1.2 has a shuffle function. If you're using 1.1, you can just
 cop the 1.2 implementation.

 On Jul 21, 1:18 pm, Ryan Waters ryan.or...@gmail.com wrote:
 http://gist.github.com/484747

 - - -

 My sad little program has a number of issues and I would welcome
 suggestions on any aspect of it.  I come from an imperative
 programming background and clojure is my first experience with a
 functional or lisp language.

 I'd like to take a list of things (really, a vector) and randomly add
 items of that list to another list.  I chose to work with vectors
 because clojure is efficient at adding things their ends and because I
 can address their consistent ordering with an index.

 Issues:

 1) Idiomatic: please point out anything that looks generally awkward
 or otherwise less than ideal for clojure (and suggest an alternative)
 : )  For example, in my loop I rebind symbols to themselves and have
 received mixed advice on IRC as to whether it's appropriate to do
 that.

 2) Transients: For speed and because I don't care about the
 intermediate values of the vectors, I'd like to use them.  I was able
 to easily work with the transient vector 'random-ips' but receive an
 error when trying to wrap the vector 'ordered-ips' in a transient:
 Exception in thread main java.lang.ClassCastException:
 clojure.lang.PersistentVector$TransientVector cannot be cast to
 clojure.lang.IPersistentVector (gen_ips.clj:36)

 3) Overall speed: it's abysmal but I don't blame Clojure.  It's either
 because I'm Doing It Wrong or what I'm doing is simply expensive in a
 big O notation sort of way.  I'm trying to randomly order 1.1 million
 strings.

 4) Clojure side-gripe: I wish it were easier to mix clojure's
 different 'types': vectors, lazy sequences, etc.  It's probably an
 ignorance thing on my part but, for what I know right now, I find
 using different macros with all the different return types
 problematic.

 - - -

 Thanks in advance to addressing one or more of these issues!

 - Ryan

 --
 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: Ordering of messages to agents

2010-07-07 Thread Ryan Waters
On Wed, Jul 7, 2010 at 3:46 PM, Brian Hurt bhur...@gmail.com wrote:
 I'm wondering if the following pattern is safe or not.  I'm in a
 transaction, and I want to create an agent and then send it an initializing
 message (the message function isn't transaction-safe, so I don't want to run
 it in the transaction).  So I want to do something like:

 (def my-ref (ref nil))

 (defn example [ f ]
     (dosync
     (if (nil? @my-ref)
     (let [ a (agent nil) ]
     (ref-set my-ref a)
     (send a init-function)
     (send a f))
     (send @my-ref f

 (actually, what I want to do is rather more complicated than this, but this
 demonstrates the problem).  So, my question is: is it guaranteed that
 init-function will be received by the agent before any f functions are
 received?

 Brian

 --

It's not guaranteed the init-function will complete before f.

At the end of the Concurrency (Chapter 6) of Programming Clojure,
Stuart Halloway outlines a rationale and a way to create functions
that only run once.  Related code can be found here - see 'runonce':

http://github.com/stuarthalloway/lancet/blob/master/lancet.clj

I hope that helps with what you're trying to do!

Ryan

-- 
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: Ordering of messages to agents

2010-07-07 Thread Ryan Waters
On Wed, Jul 7, 2010 at 4:32 PM, Meikel Brandmeyer m...@kotka.de wrote:
 Hi,

 Am 07.07.2010 um 23:11 schrieb Ryan Waters:

                 (send a init-function)
                 (send a f))

 It's not guaranteed the init-function will complete before f.

 I doubt that. Since only one action can be active at a time and the ordering 
 is preserved, init-function will be complete before f by definition: f is not 
 started until init-function is complete. (And btw: no other g can happen 
 between init-function and f, because the agent is not yet known to the 
 outside world)

 Sincerely
 Meikel


My apologies - I read the code wrong and should explain more of what I
see.  When the if is true, the ordering of init-function and f is
guaranteed so init-function will complete before f.  However, on any
subsequent calls to example, there are no language guarantees that
keep the if from evaluating to false, calling (send @my-ref f), but
only after the previous call to (send a init-function).

Stated another way, it's technically possible the agent calls won't
complete before a subsequent call to example.

-- 
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: usage examples in clojure api docs

2010-07-02 Thread Ryan Waters
+1

I like it, Justin.  I was looking at making something myself but your
efforts are farther along.  I'd be happy to help with any aspect of
this.

Ryan


On Fri, Jul 2, 2010 at 2:46 AM, Justin Kramer jkkra...@gmail.com wrote:
 Partly in response to this issue and partly to get my feet wet with
 Ring and friends, I spent the last few nights writing a proof-of-
 concept Wiki to collect structured Clojure usage examples:

 http://clojure-examples.appspot.com/

 Here's a sample function page:

 http://clojure-examples.appspot.com/clojure.core/contains%3F

 I tried to come up with something that encourages a many-hands
 approach while maintaining structure and quality. There are plenty of
 missing features, but it should be easy for anyone interested to jump
 in and write some examples. It uses a modified version of Markdown for
 syntax. Content could be exported/parsed en masse relatively easily.

 The source is on GitHub: http://github.com/jkk/clj-wiki

 Does this seem like a worthwhile approach?

 Justin

 On Jun 29, 9:35 pm, Mike Meyer mwm-keyword-googlegroups.
 620...@mired.org wrote:
 On Tue, 29 Jun 2010 17:01:10 -0700 (PDT)





 Mark Fredrickson mark.m.fredrick...@gmail.com wrote:
  On Jun 29, 5:43 pm, nickikt nick...@gmail.com wrote:
   We could make it possible to add some metadata to a function
   like :example or something. Then add a function called (example
   function name) to print the example.

   Everybody could send patches. It would be a good way to learn and a
   good extra doku.

  I was considering doing this for a while. This thread prompted me to
  put it into action:

 http://github.com/markmfredrickson/postdoc

  Here is an example of it in action:

    (defn foo
      Adds two numbers
      [a b]
      (+ a b))

    (defn bar
      Subtracts two numbers
      [a b]
      (- a b))

    (postdoc #'foo
             {:references [http://foo.com; http://bar.com;]
              :examples ['(foo 1 2) '(foo 3 4)]
              :see-also [#'bar]
              :categories [:bar :baz :other]})

   user (doc foo)
  -
  user/foo
  ([a b])
    Adds two numbers
  === Categories ===

  :bar, :baz, :other

  === See Also ===

  * #'user/bar

  === Examples ===

   (foo 1 2)
  3
   (foo 3 4)
  7

  === References ===

  *http://foo.com
  *http://bar.com

  There is also a (run-examples foo) function that evaluates the
  examples.

 It's a great start. However, examples are much more useful if you know
 what they should produce. run-examples might provide that, but having
 them in the metadata would be even better - along with an explanation.

 Doing that would allow the examples to be used as a set of unit tests
 as well. Nuts, the things you want to test - corner cases and edge
 conditions - are among the more useful things to document about a
 function.

         mike
 --
 Mike Meyer m...@mired.org          http://www.mired.org/consulting.html
 Independent Network/Unix/Perforce consultant, email for more information.

 O ascii ribbon campaign - stop html mail -www.asciiribbon.org

 --
 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: Documentation and examples (and where is the documentation on reduce)?

2010-07-02 Thread Ryan Waters
n00b question: Why is [1 2 3] idiomatic and not '(1 2 3) ?  Is it a
vectors vs. lists thing, notation thing, or something else?

I don't have a lisp background so there's a truckload of lisp reading
I still want to do which may answer questions like these for me.  If
there's a particular text on what would help a person discern
idiomatic vs. not, in clojure, I'd be happy to put that on my list
'(ha ha).  :P

Ryan

On Fri, Jul 2, 2010 at 9:50 AM, Meikel Brandmeyer m...@kotka.de wrote:
 Hi,

 On Jul 2, 12:18 pm, Walter van der Laan waltervanderl...@gmail.com
 wrote:

 For example you can point your browser 
 athttp://getclojure.org:8080/examples/reduce
 for reduce examples.

 Is it necessary to have 250 examples for a function which has
 effectively five variations?

 (reduce + [])
 (reduce + [1])
 (reduce + [1 2 3])
 (reduce + 0 [])
 (reduce + 0 [1 2 3])

 Then there are examples like this one:
 (reduce '* '(1 2 3))

 Someone who is new to Clojure and tries to understand reduce... Does
 he understand why the result is 3? A result which relies on a not very
 well-known fact, that you can actually call symbols like keywords for
 map lookup with up to two arguments. (I bet there quite a few of
 seasoned clojurians who didn't know that) I - if I was a newbie to
 the language - would mainly think: wtf? Additionally the particular
 example above doesn't even make sense.

 I'm all for examples, but please: clear examples focusing on the thing
 being demonstrated. Symbol calling or showing that [1 2 3] and (list 1
 2 3) can be interchanged in the example above are nice to know, but
 don't help to understand reduce itself. They should go to their own
 sections in a tutorial.

 The 0.02€ of a guy who has not put effort in creating examples for the
 core API.

 Sincerely
 Meikel

 PS: I also think the examples should demonstrate idiomatic clojure. [1
 2 3] is idiomatic while '(1 2 3) is not. Whatever we put in examples
 will show up in code. So be it [] vs. '() or (.java interop) vs. (.
 interop (java)) - we should pay attention!

 --
 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: Conjure / Compojure Docs etc

2010-06-29 Thread Ryan Waters
An excellent post regarding compojure documentation was made by James
Reeves on the compojure group June 26, 2010:

http://groups.google.com/group/compojure/msg/da0de026bbbfbec1

In it, he discusses a strong desire to update the docs and provides
links a person would want to use in the mean time.


On Mon, Jun 28, 2010 at 1:46 PM, Oleg oleg.richa...@gmail.com wrote:
 Dear John!

 I think that a lot of interesting about Compojure most used clojure
 web development library you can find there: 
 http://weavejester.github.com/compojure/

 See also http://github.com/briancarper/cow-blog this beautiful project
 from Brian Carper, which shows many interesting clojure and compojure
 development tricks.

 - Oleg

 On 28 июн, 00:56, john.holland jbholl...@gmail.com wrote:
 I've seen a lot of mentions of Compojure on the group. I found the
 documentation a little lacking. Am I missing something obvious?

 Also, Conjure (sort of Rails done in Clojure) seems very nice, is well
 documented, etc. But I don't see any mention of it. Is there any
 reason for it not to be popular?

 --
 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: usage examples in clojure api docs

2010-06-29 Thread Ryan Waters
I've wanted to work on expanded documentation for Clojure, too, both
as a way to contribute something I think is needed and as a way to
learn Clojure.  To illustrate what I have in mind, I put together an
example of new documentation for 'conj' located here (a read-only
google doc, for now):

http://bit.ly/9YOvgP

Try to imagine the information tastefully laid out with a lot of
hyperlinking, category cross-referencing and additional organization à
la the Clojure Cheat Sheet.  Not only would it be a way to see example
code, both toy examples and real-world examples, but also a way to tie
together related functions/macros, explanations and/or outside linking
for some of the larger concepts (like clojure.org sidebar topics,
links to relevant videos, books?, etc.)

The target audience I had in mind would be people who want to learn
clojure and want to have an available reference more expository than
the current API docs.

Please note that I'm still learning Clojure and one or more bits of
information at the above link may be incorrect!  And it's still very
unfinished; I know at least one of the terms used is incorrect
(items? I whipped it together ...).  I would welcome corrections and
explanations, even if what I've produced so far is just a simple
example of what could be.

- Ryan Waters


On Tue, Jun 29, 2010 at 9:34 AM, Angel Java Lopez ajlopez2...@gmail.com wrote:
 Hi people!

 I love PHP documentation

 http://www.php.net/manual/en/

 and its function reference:
 http://www.php.net/manual/en/funcref.php

 Each function has a dedicated page, with detailed description, initial
 examples. And visitors can add new examples or limit cases. Example:

 http://www.php.net/manual/en/function.array-combine.php

 And the documentation can be built in .pdf and other formats. I never need
 an irc channel or send an email in a list to understand a function. Maybe
 for other topics, but not to understand a function.

 That's the level of function documentation to match, I guess. And it's
 pretty good in the non-function part: good explanation of language and its
 usage.

 Angel Java Lopez
 http://www.ajlopez.com
 http://twitter.com/ajlopez

 On Tue, Jun 29, 2010 at 1:06 AM, cageface milese...@gmail.com wrote:

 Several people have suggested that usage examples in the docs would be
 helpful and this is something I often find myself wishing for. Are
 patches introducing examples welcomed by the core team?

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

-- 
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: working with agents and atoms - a beginner question

2010-06-17 Thread Ryan Waters
After reading your posts and thinking wouldn't it be nice to just
kick off a thread and not care about the return value I recall Rich
using/liking [1] the Java Executor framework [2].   I looked at
clojure.lang.Agent and saw it used there, too.  It's tricky because I
wouldn't want to lean on Java too much for something this fundamental
or go too far without expecting to have to code something as
complicated as what's found in core.clj (with possible java mechanics
as found in RT.java).

I picture wanting a system that can kick off workers (Executor
framework) that only needs start() and join() semantics.  I haven't
gone through all the Executor and related stuff yet so I still need to
read about everything that's available.

- - -

[1] http://clojure.org/concurrent_programming
[2] http://www.ibm.com/developerworks/java/library/j-jtp1126.html




On Wed, Jun 16, 2010 at 3:51 PM, Meikel Brandmeyer m...@kotka.de wrote:
 Hi,

 Am 16.06.2010 um 22:34 schrieb Christophe Grand:

 I agree, it still feels a little dirty to use a future without caring
 about the return value but on the positive said you get an easy way to
 block and wait for the tread to finish (deref) and you also get
 future-done?, future-cancel and future-cancelled which can prove
 useful.

 True. This infrastructure is an incentive to use future. Maybe one can wash 
 away the dirty feeling by believing, that deref'ing is actually a 
 syncronisation point of sorts and the return value just a side-effect.

 Sincerely
 Meikel

 --
 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: working with agents and atoms - a beginner question

2010-06-16 Thread Ryan Waters
On Tue, Jun 15, 2010 at 12:23 PM, Shawn Hoover shawn.hoo...@gmail.com wrote:

 On Tue, Jun 15, 2010 at 12:01 PM, Ryan Waters ryan.or...@gmail.com wrote:

 I'm working with the code at the following gist and also pasted below:

 http://gist.github.com/421550

 I'd like to have execution of a separate thread (agent) continue
 running until it sees the atom 'running' change to false.

 Unfortunately, the program doesn't return from the send-off but
 to my understanding it should.  Why won't it return?  I'm using
 clojure 1.1.

 TIA

 

 (ns nmanage)

 (def running (atom true))

 (defn process
  []
  (when @running
    (prn hi)
    (Thread/sleep 1000))
  (recur))

 ;;;
 (send-off (agent nil) (process))

 (do
  (prn this won't print - execution doesn't make it this far)
  (Thread/sleep 2000)
  (reset! running false))


 It looks like you're passing the result of calling (process) as an argument
 to send-off. Try just (send-off (agent nil) process) to pass the process fn
 as a value.


Doh!  I should have caught that  : )

Thank you for your help!

-- 
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: working with agents and atoms - a beginner question

2010-06-16 Thread Ryan Waters
Thank you for pointing that out.  I notice your style is similar to
Rich's in his ant.clj [1] which seems like the kind of solution that
might be used in other functional and/or lisp languages.  Do you know
if that's the case with self-calling functions and agents?  However,
isn't there more overhead with calls to send-off instead of recur?

I understand functions sent to an agent will only run one at a time,
fifo-style, but was under the impression *agent* was for the current
main thread of the program.  Does *agent* instead refer to whatever
is the current thread in the function's runtime context?  Hope that
question makes sense.


[1]
http://clojure.googlegroups.com/web/ants.clj?gda=uyYClToAAADrLV-d6p24hYFcam_S99IgeBuuRL78NgAsI-ljfFHCWu9OU0NQiFWgQuhmPR7veGf97daDQaep90o7AOpSKHW0


On Tue, Jun 15, 2010 at 3:03 PM, Meikel Brandmeyer m...@kotka.de wrote:
 Hi,

 besides the answer you got from Shawn, I'd like to question your use of the 
 agent system. This is not the way it is supposed to be used. To model a 
 processing loop with agents you should send the action back to the agent 
 itself.

 (def running? (atom true))

 (defn process
  [agent-state step]
  (when @running?
    (send-off *agent* process (inc step)))
  (+ agent-state step))

 (def a (agent 0))
 (send-off a process 1)
 (Thread/sleep 100)
 (reset! running? false)

 Note: in an action *agent* refers to the current agent.

 Sincerely
 Meikel


-- 
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: working with agents and atoms - a beginner question

2010-06-16 Thread Ryan Waters
On Wed, Jun 16, 2010 at 12:17 AM, Christophe Grand
christo...@cgrand.net wrote:
 Hi Ryan,

 On Tue, Jun 15, 2010 at 6:01 PM, Ryan Waters ryan.or...@gmail.com wrote:
 I'm working with the code at the following gist and also pasted below:

 http://gist.github.com/421550

 I'd like to have execution of a separate thread (agent) continue
 running until it sees the atom 'running' change to false.

 Unfortunately, the program doesn't return from the send-off but
 to my understanding it should.  Why won't it return?  I'm using
 clojure 1.1.

 It does return from send-off -- in your gist's version at last thanks
 to Shawn but there are still other errors.

 (ns nmanage)

 (def running (atom true))

 (defn process
  []

 A fn sent as an action to an agent must accept at least one arg: the
 agent's current value (if additional args are passed to args, the
 action fn must accept them too). So the above line should be [_] (_ to
 signify that you don't care about the value) instead of []


Thank you - I was unaware that a function sent to an agent had to
accept at least one arg.

  (when @running
    (prn hi)
    (Thread/sleep 1000))
  (recur))

 Here your recur is misplaced, you want to recur when @running is true
 so the (recur) should be at the end of the when form and it should
 have an extra argument since we changed process to take one arg.
 However this when/recur pattern is what the while macro expands to.

 (defn process [_]
  (while @running
   (prn hi)
   (Thread/sleep 1000)))


Very true - in this example, I totally agree.  The example I put
together is a simplified version of the program I'm working on which
uses some file I/O.  I'm wanting to tail a file and process its
contents over time so I had a loop that would read the file until it
started reading 'nil', then sleep, then try again, creating a loop
within a loop (and polling the file for new contents).  In trying to
keep the example program faithful to the other, I ended up with some
nonsensical clojure  ; )


 ;;;
 (send-off (agent nil) (process))

 Here it should be (send-off (agent nil) process) but Shawn already
 pointed this out.

 I think that using an agent and not caring about its value is kind of
 an abuse, better use a future.

 (def running (atom true))

 (future
  (while @running
    (prn hi)
    (Thread/sleep 1000)))


Here my near total ignorance of futures comes into play.  Thank you
very much for pointing this out as a better way.  I've been so eager
to write a first program in clojure that I haven't gotten through all
the 1.1 (and 1.0) language features yet. :D


 ;;;
 (do
  (prn this prints now - fixed thanks to Shawn Hoover)
  (Thread/sleep 2000)
  (reset! running false))

 hth,

 Christophe

 --
 European Clojure Training Session: Brussels, 23-25/6 http://conj-labs.eu/
 Professional: http://cgrand.net/ (fr)
 On Clojure: http://clj-me.cgrand.net/ (en)


I appreciate yours and everyone's valuable time!

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


working with agents and atoms - a beginner question

2010-06-15 Thread Ryan Waters
I'm working with the code at the following gist and also pasted below:

http://gist.github.com/421550

I'd like to have execution of a separate thread (agent) continue
running until it sees the atom 'running' change to false.

Unfortunately, the program doesn't return from the send-off but
to my understanding it should.  Why won't it return?  I'm using
clojure 1.1.

TIA



(ns nmanage)

(def running (atom true))

(defn process
  []
  (when @running
(prn hi)
(Thread/sleep 1000))
  (recur))

;;;
(send-off (agent nil) (process))

(do
  (prn this won't print - execution doesn't make it this far)
  (Thread/sleep 2000)
  (reset! running false))

-- 
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: tutorial on clojure protocols 1.2

2010-04-26 Thread Ryan Waters
From the perspective of a clojure beginner, it was good information
and I grokked almost everything.  Specifically, any lack of
comprehension on my part has more to do with the topic and my lack of
clojure expertise than with your presentation.  ; )

I wasn't aware of all the resources at the end so I'm glad those items
were included, too.

Thank you!

- Ryan


On Apr 26, 11:20 am, Stuart Halloway stuart.hallo...@gmail.com
wrote:
 I have created a short (30 min) tutorial on clojure protocols 
 athttp://vimeo.com/11236603
 . Hope some of you will find it useful.

 Feedback welcome!

 Stu

 --
 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 
 athttp://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