Re: Learning Idiomatic Clojure
Thanks all for the recommendation of The Joy of Clojure! I received my copy in the mail about two hours ago and I've already read up to Chapter 2 (am I the only that reads the foreword and acknowledgments?). It's hard to work with this book sitting next to me. It's been great so far! Thanks again, J.R. Garcia On May 12, 5:27 pm, Paul deGrandis paul.degran...@gmail.com wrote: I'll also jump on that, I'm on my second or third full read of Joy of Clojure. Just a great book about the why and when of the language features (why does feature X exist, when should I use it, when am I abusing it). Paul On May 12, 2:55 pm, Sean Corfield seancorfi...@gmail.com wrote: I'll +1 on The Joy of Clojure. I have the PDF on my iPhone and dip into it early and often. Probably on my fourth full read of it now on my iPad too. On Thu, May 12, 2011 at 9:31 AM, Islon Scherer islonsche...@gmail.com wrote: Read the joy of clojure, it's an amazing book that will teach you the way of clojure. -- 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: Learning Idiomatic Clojure
On Wed, 11 May 2011 19:10:13 -0700 (PDT) J.R. Garcia mrjohngar...@gmail.com wrote: I'm wondering what resources would be best to learn how Clojurians write their code. I've been developing for about 4 years in several object-oriented languages (mostly C# and Ruby). I understand Clojure's syntax well and I'm familiar with a lot of the features of Clojure (although I'm sure several of you would prove me wrong). One problem I keep running into is how to attack a problem the Clojure way. I often find myself writing Clojure like I would write C# code with LINQ, only in Clojure's syntax. As others have said, this sounds like you need a book on functional/LISP programming. There are some excellent books for other LISP dialects. Structure and Interpretation of Computer Programs (aka SICP) would be my recommendations, but Practical Common Lisp and On LISP are both excellent. I don't know of a book at that quality level using Clojure. There is an effort underway to translate SICP to clojure at http://sicpinclojure.com/. I'm not interested in Java interop or Clojure on the web or Clojure's syntax. I've had no problem finding answers for those things on the Internet. I'm really more interested in stuff like http://www.bestinclass.dk/index.clj/2010/10/taking-uncle-bob-to-school.html, but covering a wider range of things rather than a small example. I'm interested in any resource whether it's a book, a video, a blog, a person, etc. This, no the other hands, is a little bit contradictory. The example about syntax and white space than writing code the Clojure way, though you explicitly say that's not what you're interested in. Seems like you're asking for a community style guide. Again, I don't know that such exists. If it does, Google didn't find it, thought it sounds like a good idea if someone wanted to write one - maybe starting with a LISP or Scheme style guide (there are lots of those to choose from). mike -- Mike Meyer m...@mired.org http://www.mired.org/ Independent Software developer/SCM 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
Re: Learning Idiomatic Clojure
This, no the other hands, is a little bit contradictory. The example about syntax and white space than writing code the Clojure way, though you explicitly say that's not what you're interested in. Seems like you're asking for a community style guide. Again, I don't know that such exists. If it does, Google didn't find it, thought it sounds like a good idea if someone wanted to write one - maybe starting with a LISP or Scheme style guide (there are lots of those to choose from). There is a (incomplete!) style guide that we (sometimes) follow for library work. http://dev.clojure.org/display/design/Library+Coding+Standards Contrib authors should feel free to enhance this document, after discussing their ideas on the dev list. 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 at http://groups.google.com/group/clojure?hl=en
Re: Learning Idiomatic Clojure
Read the joy of clojure, it's an amazing book that will teach you the way of clojure. Islon -- 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: Learning Idiomatic Clojure
On May 12, 11:54 am, Mike Meyer m...@mired.org wrote: As others have said, this sounds like you need a book on functional/LISP programming. There are some excellent books for other LISP dialects. Structure and Interpretation of Computer Programs (aka SICP) would be my recommendations, but Practical Common Lisp and On LISP are both excellent. I don't know of a book at that quality level using Clojure. There is an effort underway to translate SICP to clojure athttp://sicpinclojure.com/. Obviously, these are excellent texts, but I wonder if a Haskel book might be better place to look. The problem is I have not looked at any Haskel books, but I expect it would be a better place to read about the joys of laziness. Adam -- 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: Learning Idiomatic Clojure
Here's a style guide for Scheme, another dialect of Lisp: http://mumble.net/~campbell/scheme/style.txt It's a fun read, and mostly applicable to Clojure. On Thu, May 12, 2011 at 6:54 AM, Mike Meyer m...@mired.org wrote: On Wed, 11 May 2011 19:10:13 -0700 (PDT) J.R. Garcia mrjohngar...@gmail.com wrote: I'm wondering what resources would be best to learn how Clojurians write their code. I've been developing for about 4 years in several object-oriented languages (mostly C# and Ruby). I understand Clojure's syntax well and I'm familiar with a lot of the features of Clojure (although I'm sure several of you would prove me wrong). One problem I keep running into is how to attack a problem the Clojure way. I often find myself writing Clojure like I would write C# code with LINQ, only in Clojure's syntax. As others have said, this sounds like you need a book on functional/LISP programming. There are some excellent books for other LISP dialects. Structure and Interpretation of Computer Programs (aka SICP) would be my recommendations, but Practical Common Lisp and On LISP are both excellent. I don't know of a book at that quality level using Clojure. There is an effort underway to translate SICP to clojure at http://sicpinclojure.com/. I'm not interested in Java interop or Clojure on the web or Clojure's syntax. I've had no problem finding answers for those things on the Internet. I'm really more interested in stuff like http://www.bestinclass.dk/index.clj/2010/10/taking-uncle-bob-to-school.html , but covering a wider range of things rather than a small example. I'm interested in any resource whether it's a book, a video, a blog, a person, etc. This, no the other hands, is a little bit contradictory. The example about syntax and white space than writing code the Clojure way, though you explicitly say that's not what you're interested in. Seems like you're asking for a community style guide. Again, I don't know that such exists. If it does, Google didn't find it, thought it sounds like a good idea if someone wanted to write one - maybe starting with a LISP or Scheme style guide (there are lots of those to choose from). mike -- Mike Meyer m...@mired.org http://www.mired.org/ Independent Software developer/SCM 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: Learning Idiomatic Clojure
On Thu, 12 May 2011 07:45:50 -0700 (PDT) Adam Burry abu...@gmail.com wrote: On May 12, 11:54 am, Mike Meyer m...@mired.org wrote: As others have said, this sounds like you need a book on functional/LISP programming. There are some excellent books for other LISP dialects. Structure and Interpretation of Computer Programs (aka SICP) would be my recommendations, but Practical Common Lisp and On LISP are both excellent. I don't know of a book at that quality level using Clojure. There is an effort underway to translate SICP to clojure athttp://sicpinclojure.com/. Obviously, these are excellent texts, but I wonder if a Haskel book might be better place to look. The problem is I have not looked at any Haskel books, but I expect it would be a better place to read about the joys of laziness. SICP and On LISP both deal with lazy data structures, but as a special case. While clojure has the same data structures, their libraries don't seem to try and conserve it the way that Clojure libraries do, so those are probably inadequate for people doing clojure. I think Haskell might take you to far the other way, since everything is lazy, which changes things radically. The best I know of here would be Concepts, Techniques, and Models of Computer Programming, but that takes you well away from Clojure's mostly-functional paradigm. I suspect that dealing properly with Clojure's laziness is a topic for a clojure-specific book. mike -- Mike Meyer m...@mired.org http://www.mired.org/ Independent Software developer/SCM 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
Re: Learning Idiomatic Clojure
Thanks for the recommendations, guys! I'll be checking those resources out. On May 12, 10:25 am, Mike Meyer m...@mired.org wrote: On Thu, 12 May 2011 07:45:50 -0700 (PDT) Adam Burry abu...@gmail.com wrote: On May 12, 11:54 am, Mike Meyer m...@mired.org wrote: As others have said, this sounds like you need a book on functional/LISP programming. There are some excellent books for other LISP dialects. Structure and Interpretation of Computer Programs (aka SICP) would be my recommendations, but Practical Common Lisp and On LISP are both excellent. I don't know of a book at that quality level using Clojure. There is an effort underway to translate SICP to clojure athttp://sicpinclojure.com/. Obviously, these are excellent texts, but I wonder if a Haskel book might be better place to look. The problem is I have not looked at any Haskel books, but I expect it would be a better place to read about the joys of laziness. SICP and On LISP both deal with lazy data structures, but as a special case. While clojure has the same data structures, their libraries don't seem to try and conserve it the way that Clojure libraries do, so those are probably inadequate for people doing clojure. I think Haskell might take you to far the other way, since everything is lazy, which changes things radically. The best I know of here would be Concepts, Techniques, and Models of Computer Programming, but that takes you well away from Clojure's mostly-functional paradigm. I suspect that dealing properly with Clojure's laziness is a topic for a clojure-specific book. mike -- Mike Meyer m...@mired.org http://www.mired.org/ Independent Software developer/SCM 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
Re: Learning Idiomatic Clojure
I'll +1 on The Joy of Clojure. I have the PDF on my iPhone and dip into it early and often. Probably on my fourth full read of it now on my iPad too. On Thu, May 12, 2011 at 9:31 AM, Islon Scherer islonsche...@gmail.com wrote: Read the joy of clojure, it's an amazing book that will teach you the way of clojure. -- 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: Learning Idiomatic Clojure
I'll also jump on that, I'm on my second or third full read of Joy of Clojure. Just a great book about the why and when of the language features (why does feature X exist, when should I use it, when am I abusing it). Paul On May 12, 2:55 pm, Sean Corfield seancorfi...@gmail.com wrote: I'll +1 on The Joy of Clojure. I have the PDF on my iPhone and dip into it early and often. Probably on my fourth full read of it now on my iPad too. On Thu, May 12, 2011 at 9:31 AM, Islon Scherer islonsche...@gmail.com wrote: Read the joy of clojure, it's an amazing book that will teach you the way of clojure. -- 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: Learning Idiomatic Clojure
This is good advice, but I can't parse 1a after the phrase or maybe, and I'm not sure about 1b. Can you reword them, making it clearer when you're using a Clojure keyword? I want to be sure I understand what you're saying--it sounds insightful! Thanks. On May 11, 9:09 pm, Ken Wesson kwess...@gmail.com wrote: On Wed, May 11, 2011 at 10:10 PM, J.R. Garcia mrjohngar...@gmail.com wrote: I'm wondering what resources would be best to learn how Clojurians write their code. I've been developing for about 4 years in several object-oriented languages (mostly C# and Ruby). I understand Clojure's syntax well and I'm familiar with a lot of the features of Clojure (although I'm sure several of you would prove me wrong). One problem I keep running into is how to attack a problem the Clojure way. I often find myself writing Clojure like I would write C# code with LINQ, only in Clojure's syntax. I'm not interested in Java interop or Clojure on the web or Clojure's syntax. I've had no problem finding answers for those things on the Internet. I'm really more interested in stuff like http://www.bestinclass.dk/index.clj/2010/10/taking-uncle-bob-to-schoo..., but covering a wider range of things rather than a small example. I'm interested in any resource whether it's a book, a video, a blog, a person, etc. Any suggestions? I don't know about any books or other resources, but a few general pointers: 1. Think functional. Try to express as much as possible as data plumbing: here is an input, here is the desired result, how to get there from here? Think in terms of calculating a new value in terms of an existing one, rather than changing things in place. Familiarize yourself with map, filter, remove, reduce, iterate, and friends, and the data structures (maps, sets, vectors, seqs) and use those to represent as much as possible and to do as much as possible. In particular, when a processing step has to be repeated: 1a. If it's for each element of a sequence, consider map, reduce, and for. If it has to walk several sequences in tandem, use map, or maybe reduce or for with (map vector s1 s2 ...). If it's for each combination in some sequences, so for all in the first sequence, and for each of those for all in the second, etc., use for. 1b. If it's accumulating a result, consider reduce, even if the input isn't (obviously) a sequence, or iterate, before resorting to loop/recur. 2. When the time comes to abstract things, abstract as much as you can using function arguments and, perhaps, returns and using maps before resorting to defmulti/defrecord/etc. 3. Look at other Clojure code, including what shows up here from time to time, and ask here about making specific code more idiomatic. Many people here will likely answer fairly quickly, and even when they disagree, the disagreement and their stated reasons for disagreeing may themselves be illuminating -- and then anything *everyone* agrees is ugly or poor practice almost certainly is. :) -- 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: Learning Idiomatic Clojure
On Fri, May 13, 2011 at 12:29 AM, Gregg Williams greg...@innerpaths.net wrote: This is good advice, but I can't parse 1a after the phrase or maybe, and I'm not sure about 1b. Can you reword them, making it clearer when you're using a Clojure keyword? I want to be sure I understand what you're saying--it sounds insightful! Thanks. OK -- 1. Think functional. Try to express as much as possible as data plumbing: here is an input, here is the desired result, how to get there from here? Think in terms of calculating a new value in terms of an existing one, rather than changing things in place. Familiarize yourself with map, filter, remove, reduce, iterate, and friends, and the data structures (maps, sets, vectors, and seqs) and use those to represent as much as possible and to do as much as possible. In particular, when a processing step has to be repeated: 1a. If it's for each element of a sequence, consider map, reduce, and for. If it has to walk several sequences in tandem, use map, or maybe reduce or for with (map vector s1 s2 ...) as the input. If it's for each combination in some sequences, so for all in the first sequence, and for each of those for all in the second, etc., use for. 1b. If it's accumulating a result, consider reduce, even if the input isn't (obviously) a sequence, or iterate, before resorting to loop/recur. 2. When the time comes to abstract things, abstract as much as you can using functions as arguments and, perhaps, as return values and using maps before resorting to defmulti/defrecord/etc. 3. Look at other Clojure code, including what shows up here from time to time, and ask here about making specific code more idiomatic. Many people here will likely answer fairly quickly, and even when they disagree, the disagreement and their stated reasons for disagreeing may themselves be illuminating -- and then anything *everyone* agrees is ugly or poor practice almost certainly is. :) That better? I made a few other tweaks as well as quoting all the names of core functions and macros I was referring to. -- 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: Learning Idiomatic Clojure
On Wed, May 11, 2011 at 10:10 PM, J.R. Garcia mrjohngar...@gmail.com wrote: I'm wondering what resources would be best to learn how Clojurians write their code. I've been developing for about 4 years in several object-oriented languages (mostly C# and Ruby). I understand Clojure's syntax well and I'm familiar with a lot of the features of Clojure (although I'm sure several of you would prove me wrong). One problem I keep running into is how to attack a problem the Clojure way. I often find myself writing Clojure like I would write C# code with LINQ, only in Clojure's syntax. I'm not interested in Java interop or Clojure on the web or Clojure's syntax. I've had no problem finding answers for those things on the Internet. I'm really more interested in stuff like http://www.bestinclass.dk/index.clj/2010/10/taking-uncle-bob-to-school.html, but covering a wider range of things rather than a small example. I'm interested in any resource whether it's a book, a video, a blog, a person, etc. Any suggestions? I don't know about any books or other resources, but a few general pointers: 1. Think functional. Try to express as much as possible as data plumbing: here is an input, here is the desired result, how to get there from here? Think in terms of calculating a new value in terms of an existing one, rather than changing things in place. Familiarize yourself with map, filter, remove, reduce, iterate, and friends, and the data structures (maps, sets, vectors, seqs) and use those to represent as much as possible and to do as much as possible. In particular, when a processing step has to be repeated: 1a. If it's for each element of a sequence, consider map, reduce, and for. If it has to walk several sequences in tandem, use map, or maybe reduce or for with (map vector s1 s2 ...). If it's for each combination in some sequences, so for all in the first sequence, and for each of those for all in the second, etc., use for. 1b. If it's accumulating a result, consider reduce, even if the input isn't (obviously) a sequence, or iterate, before resorting to loop/recur. 2. When the time comes to abstract things, abstract as much as you can using function arguments and, perhaps, returns and using maps before resorting to defmulti/defrecord/etc. 3. Look at other Clojure code, including what shows up here from time to time, and ask here about making specific code more idiomatic. Many people here will likely answer fairly quickly, and even when they disagree, the disagreement and their stated reasons for disagreeing may themselves be illuminating -- and then anything *everyone* agrees is ugly or poor practice almost certainly is. :) -- 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