<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>RubyLearning Blog &#187; Clojure</title>
	<atom:link href="http://rubylearning.com/blog/tag/clojure/feed/" rel="self" type="application/rss+xml" />
	<link>http://rubylearning.com/blog</link>
	<description>Helping Ruby Programmers become Awesome</description>
	<lastBuildDate>Thu, 02 Feb 2012 03:23:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Clojure 101 Course &#8211; 2nd batch</title>
		<link>http://rubylearning.com/blog/2010/09/14/clojure-101-course-2nd-batch/</link>
		<comments>http://rubylearning.com/blog/2010/09/14/clojure-101-course-2nd-batch/#comments</comments>
		<pubDate>Tue, 14 Sep 2010 04:18:20 +0000</pubDate>
		<dc:creator>Satish Talim</dc:creator>
				<category><![CDATA[Clojure]]></category>
		<category><![CDATA[Training]]></category>
		<category><![CDATA[Clojure course]]></category>
		<category><![CDATA[Clojure Training]]></category>

		<guid isPermaLink="false">http://rubylearning.com/blog/?p=4471</guid>
		<description><![CDATA[About RubyLearning RL offers online courses in Ruby programming, Git &#38; GitHub, Shoes, JRuby and Sinatra. Since 2005, over 25,000 participants spread across 140+ countries have learned Ruby and other Ruby related timely topics. This has been possible due to the extensive support provided by the mentors of these courses. RL strives hard to improve [...]<p><a href="http://www.launchbit.com/az/113-209/"><img width="468" height="60" src="http://www.launchbit.com/az-images/113-209/" /></a><br />
<small>(Powered by <a href="http://www.launchbit.com/lb/113-209/">LaunchBit</a>)</small></p>
]]></description>
			<content:encoded><![CDATA[<p></p>
<div class="topsy_widget_data topsy_theme_brick-red" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Frubylearning.com%252Fblog%252F2010%252F09%252F14%252Fclojure-101-course-2nd-batch%252F%22%2C%20%22shorturl%22%3A%20%22http%3A%2F%2Fbit.ly%2F9jRXOw%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22Clojure%20101%20Course%20-%202nd%20batch%22%20%7D);"></div>
<div>
<h3>About RubyLearning</h3>
<p class="update"><abbr title="RubyLearning">RL</abbr> offers online courses in Ruby programming, Git &amp; GitHub, Shoes, JRuby and Sinatra. Since 2005, over 25,000 participants spread across 140+ countries have learned Ruby and other Ruby related timely topics. This has been possible due to the extensive support provided by the mentors of these courses. RL strives hard to improve the methodology and course content based on the extensive and critical feedback we receive. Thanks to <strong>YOU</strong> and people like Fabio Akita who make this possible. <a href="http://rubylearning.com/other/testimonials.html">Our Alumni</a> are our best ambassadors.</p>
<p><span class="drop_cap">Y</span>ou kept asking for it and so here it is &#8211; the second batch of the intensive, online course that helps you get started with <strong>Clojure</strong> programming.</p>
<h3>Acknowledgements</h3>
<p><a href="http://www.ociweb.com/"><img style=' float: right; padding: 4px; margin: 0 0 2px 7px;'  class="alignright" title="Object Computing, Inc. (OCI)" src="http://rubylearning.com/images/OCIlogo.jpg" alt="Object Computing, Inc. (OCI)" /></a></p>
<p>Our special thanks go to <b>Rich Hickey</b> for providing us with this exciting new language as well as <b>Mark Volkmann</b> from Object Computing, Inc. for generously giving us permission to use his articles as teaching material for this course.</p>
<h3>What&#8217;s Clojure?</h3>
<p><img style=' float: right; padding: 4px; margin: 0 0 2px 7px;'  class="alignright" title="Clojure" src="http://clojure.org/file/view/clojure-icon.gif" alt="Clojure" /></p>
<p>According to <a href="http://en.wikipedia.org/wiki/Clojure">Wikipedia</a>: &#8220;Clojure is a modern dialect of the Lisp programming language. It is a general-purpose language supporting interactive development that encourages a functional programming style, and simplifies multithreaded programming. Clojure runs on the Java Virtual Machine and the Common Language Runtime. Clojure honors the code-as-data philosophy and has a sophisticated Lisp macro system.&#8221;</p>
<p><b>Stuart Halloway</b> in his <b><a href="http://www.pragprog.com/titles/shcloj/programming-clojure">Programming Clojure</a></b> book says &#8211; &#8220;Clojure feels like a general-purpose  language beamed back from the near future. Its support for functional programming and software trans-actional memory is well beyond current practice and is well suited for multicore hardware. At the same time, Clojure is well grounded in the past and the present. It brings together Lisp and the Java Virtual Machine. Lisp brings wisdom spanning most of the history of programming, and Java brings the robustness, extensive libraries, and tooling of the dominant platform available today.&#8221;</p>
<h3>What Will I Learn?</h3>
<p>In this course, you will learn the essential features of Clojure that you will end up using every day. The course topics are tentative and could change with the feedback received:</p>
<ul>
<li>Week 0 &#8211; Getting started (no exercises)
<ul>
<li>Getting started</li>
<li>REPL</li>
<li>Functional Programming</li>
</ul>
</li>
<li>Week 1 &#8211; The basics
<ul>
<li>Clojure Overview</li>
<li>Clojure Syntax</li>
<li>Bindings</li>
<li>Defining functions</li>
<li>Destructuring</li>
</ul>
</li>
<li>Week 2 &#8211; Data
<ul>
<li>Collections</li>
<li>StructMaps</li>
<li>Sequences</li>
<li>Concurrency</li>
<li>Reference Types</li>
</ul>
</li>
<li>Week 3 &#8211; Control Flow
<ul>
<li>Conditional Processing</li>
<li>Iteration</li>
<li>Recursion</li>
<li>Predicates</li>
<li>Input/Output</li>
</ul>
</li>
<li>Week 4 &#8211; Advanced topics and tying it all together
<ul>
<li>Namespaces</li>
<li>Metadata</li>
<li>Macros</li>
<li>Java Interoperability</li>
<li>AOT Compiling</li>
</ul>
</li>
</ul>
<h3>Who&#8217;s It For?</h3>
<p>Anyone with an intermediate programming experience. <b>People who have no previous exposure to Lisp and/or Clojure can get up-to-speed with Clojure with these <a href="http://clojure-notes.rubylearning.org/">Clojure Notes</a>.</b></p>
<h3>Mentors</h3>
<h4>Michael Kohl</h4>
<p class="block"><img style=' float: left; padding: 4px; margin: 0 7px 2px 0;'  class="alignleft" title="Michael Kohl" src="http://rubylearning.com/images/michael_kohl.jpg" alt="Michael Kohl" />Michael Kohl (<a href="http://twitter.com/citizen428">Twitter</a> / <a href="http://citizen428.net/">blog</a>) in his day job, works as a Ruby on Rails programmer for <a href="http://tupalo.com/">Tupalo.com</a> in Vienna, Austria. Michael fell in love with Clojure on first sight sometime in early 2009, but unfortunately never seems to have as much time to work with it as he wants to and started being a mentor for <a href="http://www.rubylearning.org/class/">RubyLearning.org</a> in early 2009. His interests include mathematics, literature, travelling, foreign languages, chess and so much more that he really wishes he wouldn&#8217;t need to sleep.</p>
<h4>Daniel Solano Gómez</h4>
<p><img style=' float: right; padding: 4px; margin: 0 0 2px 7px;'  class="alignright" title="Daniel Solano Gómez" src="http://rubylearning.com/images/portrait.jpg" alt="Daniel Solano Gómez" /></p>
<p>Daniel Solano Gómez (<a href="http://twitter.com/deepbluelambda">Twitter</a> / <a href="http://www.deepbluelambda.org/">blog</a>) is the founder of Sattvik Software &#038; Technology Resources, a software development company based in Houston, Texas. He studied mathematics at the University of Texas at Austin, but he discovered his passion for programming and computers as a child. Daniel has been developing software professionally for over a decade, primarily with C++ and Java. He started learning about and developing with Clojure in late 2009.</p>
<h4>Micha&#322; Marczyk</h4>
<p>Micha&#322; Marczyk is a PhD student doing research in logic / universal algebra in Kraków, Poland, always trying to coerce the computer into proving his theorems for him. His programming background is predominantly in functional programming; mostly in Scheme, Haskell and Clojure, which is rapidly becoming his favourite language.</p>
<h4>Anthony Simpson</h4>
<p><img style=' float: left; padding: 4px; margin: 0 7px 2px 0;'  class="alignleft" title="Anthony Simpson" src="http://rubylearning.com/images/cropped.jpg" alt="Anthony Simpson" /></p>
<p>Anthony Simpson (<a href="http://twitter.com/IORayne">Twitter</a> / <a href="http://blog.acidrayne.net">Blog</a>) is a young, ambitious programmer in Eldridge, Alabama. His first language having been Haskell, the majority of his time with programming has been with functional programming languages, most of which has been spent with Clojure. A language person, he enjoys learning about new languages and improvements they make on existing languages. Non-computer-related interests include, (roller)skating, all aspects of music, and hacking life.</p>
<h4>Isaac Hodes</h4>
<p><img style=' float: right; padding: 4px; margin: 0 0 2px 7px;'  class="alignright" title="Isaac Hodes" src="http://rubylearning.com/images/Isaac.jpg" alt="Isaac Hodes" /></p>
<p>Isaac (<a href="http://twitter.com/ihodes">Twitter</a> / <a href="http://www.copperthoughts.com/">Blog</a>) is a Math major studying just about anything he can get his hands on. He likes to program, cook, and read as much as possible in his spare time. Programming in Clojure is what he does on vacation; it&#8217;s that much fun.</p>
<h3>Dates</h3>
<p>The course starts on Monday, 4th Oct. 2010 and runs for a month.</p>
<h3>How do I register?</h3>
<ul>
<li>You first create an account on the site (see right-hand top corner of the <a href="http://rubylearning.org/">RubyLearning.org</a> site). An email will be sent to your registered email address. This email contains a link to confirm your account. Please click on that link.</li>
<li>Once your registration has been confirmed, login to the site and <a href="http://rubylearning.org/class/course/view.php?id=62">enroll into the Clojure 101 course</a>.</li>
<li>Update your profile (with photo) and introduce yourself at the Course Social Forum.</li>
</ul>
<h3>Course Fees</h3>
<p>The course fee is <b>US$ 5 per participant</b>. The course fee goes towards maintaining RubyLearning and helps provide quality content to you.</p>
<p>Hurry, registrations have started.</p>
<p class="alert">At the end of this course you should have all the knowledge to explore the wonderful world of Clojure on your own.</p>
<p><img class="alignleft" src='http://rubylearning.com/images/update.jpg' style="border: 0px none ;;  float: left; padding: 4px; margin: 0 7px 2px 0;" alt="Update" title="Update" /></p>
<p>Many of you wrote in asking for details on how the course works. Here are some details:</p>
<h4>Important:</h4>
<p>Once the course starts, you can login and start with the lessons <b>any day and time</b> and post your queries in the forum under the relevant lessons. Someone shall always be there to answer them. Just to set the expectations correctly, there is no real-time &#8216;webcasting&#8217;.</p>
<h4>Methodology:</h4>
<ul>
<li>The Mentors shall give you URL&#8217;s of pages and sometimes some additional notes; you need to read through. Read the pre-class reading material at a convenient time of your choice &#8211; the dates may be specified only as a guideline. While reading, please make a note of all your doubts, queries, questions, clarifications, comments about the lesson and after you have completed all the pages, post these on the forum <b>under the relevant lesson</b>. There may be some questions that relate to something that has not been mentioned or discussed by the mentors thus far; you could post the same too. Please remember that with every post, do mention the operating system of your computer.</li>
<li>The mentor shall highlight the important points that you need to remember for that week&#8217;s session.</li>
<li>There could be exercises for that week. Please do them.</li>
<li>Participate in the forum for asking and answering questions or starting discussions. Share knowledge, and exchange ideas amongst yourselves during the course period. Participants are strongly encouraged to post technical questions, interesting articles, tools, sample programs or anything that is relevant to the class / lesson. Please do not post a simple &quot;Thank you&quot; note or &quot;Hello&quot; message to the forum. This forum is subscribed by several hundred people, so please be aware that these messages are considered as noises by many people.</li>
</ul>
<h4>Outline of Work Expectations:</h4>
<ol>
<li>The course starts on a Monday and the new course material will be available every Monday.</li>
<li>Most of the weeks, you will have exercises to solve. These are there to help you assimilate whatever you have learned till then.</li>
<li>Some weeks may have some mid-week additional assignments / food for thought articles / programs</li>
<li><strong>Above all, do participate in the relevant forums. Past participants will confirm that they learned the best by active participation.</strong></li>
</ol>
<h4>Some Commonly Asked Questions</h4>
<ul>
<li><b>Qs.</b> Is there any specific time when I need to be online?<br /><b>Ans.</b> No. You need not be online at a specific time of the day.</li>
<li><b>Qs.</b> Is it important for me to participate in the course forums?<br /><b>Ans.</b> YES. You must Participate in the forum(s) for asking and answering questions or starting discussions. Share knowledge, and exchange ideas amongst yourselves (participants) during the course period. Participants are strongly encouraged to post technical questions, interesting articles, tools, sample programs or anything that is relevant to the class / lesson. Past participants will confirm that they learned the best by active participation.</li>
<li><b>Qs.</b> How much time do I need to spend online for a course, in a day?<br /><b>Ans.</b> This will vary from person to person. All depends upon your comfort level and the amount of time you want to spend on a particular lesson or task.</li>
<li><b>Qs.</b> Is there any specific set time for feedback (e.g., any mentor responds to me within 24 hours?)<br /><b>Ans.</b> Normally somebody should answer your query / question within 24 &#8211; 48 hours.</li>
<li><b>Qs.</b> What happens if nobody answers my questions / queries?<br /><b>Ans.</b> Normally, that will not happen. In case you feel that your question / query is not answered, then please post the same in the thread &#8211; &#8220;Any UnAnswered Questions / Queries&#8221;.</li>
<li><b>Qs.</b> What happens to the class (or forums) after a course is over? Can you keep it open for a few more days so that students can complete and discuss too?<br /><b>Ans.</b> The course and its forum is open for a month after the last day of the course.</li>
</ul>
<p>Remember, the idea is to have fun learning Clojure.</p>
</div>
<p>Technorati Tags: <a href="http://technorati.com/tag/Clojure+course" rel="tag">Clojure course</a>, <a href="http://technorati.com/tag/Clojure" rel="tag">Clojure</a>, <a href="http://technorati.com/tag/Clojure+Training" rel="tag">Clojure Training</a></p>
Posted by <b>Satish Talim</b><p><a href="http://www.launchbit.com/az/113-209/"><img width="468" height="60" src="http://www.launchbit.com/az-images/113-209/" /></a><br />
<small>(Powered by <a href="http://www.launchbit.com/lb/113-209/">LaunchBit</a>)</small></p>

]]></content:encoded>
			<wfw:commentRss>http://rubylearning.com/blog/2010/09/14/clojure-101-course-2nd-batch/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Programming Challenge for Newbies in Clojure and Python too?</title>
		<link>http://rubylearning.com/blog/2010/09/02/programming-challenge-for-newbies-in-clojure-and-python-too/</link>
		<comments>http://rubylearning.com/blog/2010/09/02/programming-challenge-for-newbies-in-clojure-and-python-too/#comments</comments>
		<pubDate>Thu, 02 Sep 2010 02:09:35 +0000</pubDate>
		<dc:creator>Satish Talim</dc:creator>
				<category><![CDATA[Beginners]]></category>
		<category><![CDATA[Clojure]]></category>
		<category><![CDATA[RPCFN]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Ruby Challenge]]></category>

		<guid isPermaLink="false">http://rubylearning.com/blog/?p=4408</guid>
		<description><![CDATA[Programming Challenge for Newbies in Clojure and Python too? RubyLearning has been conducting the monthly Ruby Programming Challenge for Newbies for over a year now and so far 12 challenges have been completed. The 13th challenge is in progress. All this was possible due to the extensive support we got from Rubyists across the world. [...]<p><a href="http://www.launchbit.com/az/113-209/"><img width="468" height="60" src="http://www.launchbit.com/az-images/113-209/" /></a><br />
<small>(Powered by <a href="http://www.launchbit.com/lb/113-209/">LaunchBit</a>)</small></p>
]]></description>
			<content:encoded><![CDATA[<p></p>
<div class="topsy_widget_data topsy_theme_brick-red" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Frubylearning.com%252Fblog%252F2010%252F09%252F02%252Fprogramming-challenge-for-newbies-in-clojure-and-python-too%252F%22%2C%20%22shorturl%22%3A%20%22http%3A%2F%2Fbit.ly%2Fa41eyv%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22Programming%20Challenge%20for%20Newbies%20in%20Clojure%20and%20Python%20too%3F%22%20%7D);"></div>
<div>
<h3>Programming Challenge for Newbies in Clojure and Python too?</h3>
<p>RubyLearning has been conducting the monthly Ruby Programming Challenge for Newbies for over a year now and so far 12 challenges have been completed. The 13th challenge is in progress. All this was possible due to the extensive support we got from <a href="http://ruby-challenge.rubylearning.org/">Rubyists</a> across the world. Also, you all indicated that <a href="http://rubylearning.com/blog/2010/08/09/do-you-want-us-to-continue-with-the-ruby-challenge-for-newbies/">we continue with these challenges</a> in the months to come.</p>
<p>Recently, my colleague <a href="http://blog.dhananjaynene.com/">Dhananjay Nene</a> posted a <a href="http://codeblog.dhananjaynene.com/2010/09/code-kata-ruby-programming-challenge-for-newbies-in-python/">Python based solution</a> to the 13th Ruby challenge. While discussing the solution it struck me that it would help Clojure and Python Newbies, if we opened up these challenges in these languages too. Dhananjay and some of my Clojure colleagues are interested in evaluating the submitted solutions in Clojure and Python and maybe we could start the challenges from Oct. 2010.</p>
<p class="update">Clojure and Python enthusiasts &#8211; interested? What Do you Think? What is Your Opinion? Please share in the comments below.</p>
<p><img class="alignleft" src='http://rubylearning.com/images/update.jpg' style="border: 0px none ;;  float: left; padding: 4px; margin: 0 7px 2px 0;" alt="Update" title="Update" /></p>
<p><b>3rd Sept.</b> Thanks for the very encouraging response. Based on the feedback received so far, we have decided the following:</p>
<ul>
<li>We will start the challenges for Clojure, Python and Ruby from <b>1st Oct. 2010</b>. We will call these &#8220;<b>Programming Challenge for Newbies</b>&#8221; and host it on this blog till end Dec. 2010. If the response is encouraging, we can host the challenges on different domains.</li>
<li>We will have separate panels to evaluate the solutions. One each for Clojure, Python and Ruby.</li>
<li>We will keep separate prizes for the 3 languages (and hopefully would find some sponsors).</li>
<li>The challenge problem setters (fixed till Dec. 2010) would be told that the problem should be solvable in all languages and specifically Clojure, Python and Ruby. This means that the problem setter should not set a problem that needs to be solved by some specific language feature.</li>
</ul>
</div>
<p>Technorati Tags: <a href="http://technorati.com/tag/Clojure" rel="tag">Clojure</a>, <a href="http://technorati.com/tag/Python" rel="tag"> Python</a>, <a href="http://technorati.com/tag/RPCFN" rel="tag"> RPCFN</a>, <a href="http://technorati.com/tag/Ruby+Challenge" rel="tag"> Ruby Challenge</a>, <a href="http://technorati.com/tag/Ruby" rel="tag"> Ruby</a>, <a href="http://technorati.com/tag/Programming" rel="tag"> Programming</a></p>
Posted by <b>Satish Talim</b><p><a href="http://www.launchbit.com/az/113-209/"><img width="468" height="60" src="http://www.launchbit.com/az-images/113-209/" /></a><br />
<small>(Powered by <a href="http://www.launchbit.com/lb/113-209/">LaunchBit</a>)</small></p>

]]></content:encoded>
			<wfw:commentRss>http://rubylearning.com/blog/2010/09/02/programming-challenge-for-newbies-in-clojure-and-python-too/feed/</wfw:commentRss>
		<slash:comments>66</slash:comments>
		</item>
		<item>
		<title>Clojure for Beginners Course &#8211; 2nd Batch Announced</title>
		<link>http://rubylearning.com/blog/2010/08/04/clojure-for-beginners-course-2nd-batch-announced/</link>
		<comments>http://rubylearning.com/blog/2010/08/04/clojure-for-beginners-course-2nd-batch-announced/#comments</comments>
		<pubDate>Wed, 04 Aug 2010 09:33:19 +0000</pubDate>
		<dc:creator>Satish Talim</dc:creator>
				<category><![CDATA[Beginners]]></category>
		<category><![CDATA[Clojure]]></category>
		<category><![CDATA[Training]]></category>
		<category><![CDATA[Clojure course]]></category>
		<category><![CDATA[Clojure Training]]></category>

		<guid isPermaLink="false">http://rubylearning.com/blog/?p=4362</guid>
		<description><![CDATA[Introducing an intensive, online course for beginners that helps you get started with Clojure programming. What&#8217;s Clojure? According to Wikipedia: &#8220;Clojure is a modern dialect of the Lisp programming language. It is a general-purpose language supporting interactive development that encourages a functional programming style, and simplifies multithreaded programming. Clojure runs on the Java Virtual Machine [...]<p><a href="http://www.launchbit.com/az/113-209/"><img width="468" height="60" src="http://www.launchbit.com/az-images/113-209/" /></a><br />
<small>(Powered by <a href="http://www.launchbit.com/lb/113-209/">LaunchBit</a>)</small></p>
]]></description>
			<content:encoded><![CDATA[<p></p>
<div class="topsy_widget_data topsy_theme_brick-red" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Frubylearning.com%252Fblog%252F2010%252F08%252F04%252Fclojure-for-beginners-course-2nd-batch-announced%252F%22%2C%20%22shorturl%22%3A%20%22http%3A%2F%2Fbit.ly%2Fazvzmo%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22Clojure%20for%20Beginners%20Course%20-%202nd%20Batch%20Announced%22%20%7D);"></div>
<div>
<p><span class="drop_cap">I</span>ntroducing an intensive, online course for <em>beginners</em> that helps you get started with <strong>Clojure</strong> programming.</p>
<h3>What&#8217;s Clojure?</h3>
<p><img style=' float: right; padding: 4px; margin: 0 0 2px 7px;'  class="alignright" title="Clojure" src="http://clojure.org/file/view/clojure-icon.gif" alt="Clojure" /></p>
<p>According to <a href="http://en.wikipedia.org/wiki/Clojure">Wikipedia</a>: &#8220;Clojure is a modern dialect of the Lisp programming language. It is a general-purpose language supporting interactive development that encourages a functional programming style, and simplifies multithreaded programming. Clojure runs on the Java Virtual Machine and the Common Language Runtime. Clojure honors the code-as-data philosophy and has a sophisticated Lisp macro system.&#8221;</p>
<p><b>Stuart Halloway</b> in his <b><a href="http://www.pragprog.com/titles/shcloj/programming-clojure">Programming Clojure</a></b> book says &#8211; &#8220;Clojure feels like a general-purpose  language beamed back from the near future. Its support for functional programming and software trans-actional memory is well beyond current practice and is well suited for multicore hardware. At the same time, Clojure is well grounded in the past and the present. It brings together Lisp and the Java Virtual Machine. Lisp brings wisdom spanning most of the history of programming, and Java brings the robustness, extensive libraries, and tooling of the dominant platform available today.&#8221;</p>
<p><b><a href="http://programmingzen.com/2010/07/09/thoughts-on-clojure/">Antonio Cangiano</a></b> says: &#8220;Clojure has three main advantages over Ruby:&#8221;</p>
<ol>
<li>It&#8217;s much faster than Ruby, which makes it a better choice for intensive processing.</li>
<li>It greatly simplifies concurrent programming, making the language more future-proof as hardware manufacturers continue to produce processors with more CPU cores.</li>
<li>Clojure emphasizes functional programming and tries to minimize side effects.</li>
</ol>
<h3>What Will I Learn?</h3>
<p>In this introductory course, you will learn the <a href="http://clojure-notes.rubylearning.org/">essential features of Clojure</a> that you will end up using every day.</p>
<h3>Who&#8217;s It For?</h3>
<p><b>An <em>absolute beginner</em> in Lisp and / or Clojure but with some experience in other programming languages</b>.</p>
<h3>Mentor</h3>
<h4>Michael Kohl</h4>
<p class="block"><img style=' float: left; padding: 4px; margin: 0 7px 2px 0;'  class="alignleft" title="Michael Kohl" src="http://rubylearning.com/images/michael_kohl.jpg" alt="Michael Kohl" />Michael Kohl (<a href="http://twitter.com/citizen428">Twitter</a> / <a href="http://citizen428.net/">blog</a>) in his day job, works as a Ruby on Rails programmer for <a href="http://tupalo.com/">Tupalo.com</a> in Vienna, Austria. Michael fell in love with Clojure on first sight sometime in early 2009, but unfortunately never seems to have as much time to work with it as he wants to and started being a mentor for <a href="http://www.rubylearning.org/class/">RubyLearning.org</a> in early 2009. His interests include mathematics, literature, travelling, foreign languages, chess and so much more that he really wishes he wouldn&#8217;t need to sleep.</p>
<h3>Dates</h3>
<p>The course starts on Monday, 13th Sept. 2010 and runs for a week.</p>
<h3>Course Fees</h3>
<p>The course fee is <b>US$ 5</b> and the entire course fee will be <a href="http://clojure.org/funding">donated to the Clojure project</a>.</p>
<p>Hurry, registrations have started.</p>
<p class="alert">At the end of this course you should have all the knowledge to explore the wonderful world of Clojure on your own.</p>
<h3>How do I register?</h3>
<p>You first need to <a href="http://rubylearning.org/">register on the site</a> and then <a href="http://rubylearning.org/class/course/view.php?id=60">enroll into the course</a>.</p>
<p><b>Note</b>: We are planning for an advanced course &#8220;Clojure 101&#8243; around 2nd Oct. 2010. Watch out for an announcement. In the meantime you can read about the <a href="http://rubylearning.com/blog/2010/03/09/clojure-101-a-new-course/">first batch of the Clojure 101 course</a>.</p>
<p><img class="alignleft" src='http://rubylearning.com/images/update.jpg' style="border: 0px none ;;  float: left; padding: 4px; margin: 0 7px 2px 0;" alt="Update" title="Update" /></p>
<p>Many of you wrote in asking for details on how the course works. Here are some details:</p>
<h4>Important:</h4>
<p>Once the course starts, you can login and start with the lessons <b>any day and time</b> and post your queries in the forum under the relevant lessons. Someone shall always be there to answer them. Just to set the expectations correctly, there is no real-time &#8216;webcasting&#8217;.</p>
<h4>Methodology:</h4>
<ul>
<li>The Mentors shall give you URL&#8217;s of pages and sometimes some additional notes; you need to read through. Read the pre-class reading material at a convenient time of your choice &#8211; the dates may be specified only as a guideline. While reading, please make a note of all your doubts, queries, questions, clarifications, comments about the lesson and after you have completed all the pages, post these on the forum <b>under the relevant lesson</b>. There may be some questions that relate to something that has not been mentioned or discussed by the mentors thus far; you could post the same too. Please remember that with every post, do mention the operating system of your computer.</li>
<li>The mentor shall highlight the important points that you need to remember for that day&#8217;s session.</li>
<li>There could be exercises every day. Please do them.</li>
<li>Participate in the forum for asking and answering questions or starting discussions. Share knowledge, and exchange ideas amongst yourselves during the course period. Participants are strongly encouraged to post technical questions, interesting articles, tools, sample programs or anything that is relevant to the class / lesson. Please do not post a simple &quot;Thank you&quot; note or &quot;Hello&quot; message to the forum. This forum is subscribed by several people, so please be aware that these messages are considered as noises by many people.</li>
</ul>
<h4>Outline of Work Expectations:</h4>
<ol>
<li>Most of the days, you will have exercises to solve. These are there to help you assimilate whatever you have learned till then.</li>
<li>Some days may have some additional assignments / food for thought articles / programs</li>
<li><strong>Above all, do participate in the relevant forums. Past participants will confirm that they learned the best by active participation.</strong></li>
</ol>
<h4>Some Commonly Asked Questions</h4>
<ul>
<li><b>Qs.</b> Is there any specific time when I need to be online?<br /><b>Ans.</b> No. You need not be online at a specific time of the day.</li>
<li><b>Qs.</b> Is it important for me to participate in the course forums?<br /><b>Ans.</b> YES. You must Participate in the forum(s) for asking and answering questions or starting discussions. Share knowledge, and exchange ideas amongst yourselves (participants) during the course period. Participants are strongly encouraged to post technical questions, interesting articles, tools, sample programs or anything that is relevant to the class / lesson. Past participants will confirm that they learned the best by active participation.</li>
<li><b>Qs.</b> How much time do I need to spend online for a course, in a day?<br /><b>Ans.</b> This will vary from person to person. All depends upon your comfort level and the amount of time you want to spend on a particular lesson or task.</li>
<li><b>Qs.</b> Is there any specific set time for feedback (e.g., any mentor responds to me within 24 hours?)<br /><b>Ans.</b> Normally somebody should answer your query / question within 24 hours.</li>
<li><b>Qs.</b> What happens if nobody answers my questions / queries?<br /><b>Ans.</b> Normally, that will not happen. In case you feel that your question / query is not answered, then please post the same in the thread &#8211; &#8220;Any UnAnswered Questions / Queries&#8221;.</li>
<li><b>Qs.</b> What happens to the class (or forums) after a course is over? Can you keep it open for a few more days so that students can complete and discuss too?<br /><b>Ans.</b> The course and its forum is open for a month after the last day of the course.</li>
<li><b>Qs.</b> How do I quit from a course?<br /><b>Ans.</b> We wouldn&#8217;t like that to happen. However, in case you want to &#8216;quit&#8217; from a course or for some reason want to un-subscribe, kindly message Satish Talim or email him at <b>satish.talim [at] gmail [dot] com</b></li>
</ul>
<p>Remember, the idea is to have fun learning Clojure.</p>
</div>
<p>Technorati Tags: <a href="http://technorati.com/tag/Clojure+course" rel="tag">Clojure course</a>, <a href="http://technorati.com/tag/Clojure" rel="tag">Clojure</a>, <a href="http://technorati.com/tag/Clojure+Training" rel="tag">Clojure Training</a></p>
Posted by <b>Satish Talim</b><p><a href="http://www.launchbit.com/az/113-209/"><img width="468" height="60" src="http://www.launchbit.com/az-images/113-209/" /></a><br />
<small>(Powered by <a href="http://www.launchbit.com/lb/113-209/">LaunchBit</a>)</small></p>

]]></content:encoded>
			<wfw:commentRss>http://rubylearning.com/blog/2010/08/04/clojure-for-beginners-course-2nd-batch-announced/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>Clojure: A Chat with Andrew Boekhoff</title>
		<link>http://rubylearning.com/blog/2010/07/29/clojure-a-chat-with-andrew-boekhoff/</link>
		<comments>http://rubylearning.com/blog/2010/07/29/clojure-a-chat-with-andrew-boekhoff/#comments</comments>
		<pubDate>Thu, 29 Jul 2010 07:00:55 +0000</pubDate>
		<dc:creator>Satish Talim</dc:creator>
				<category><![CDATA[Clojure]]></category>
		<category><![CDATA[Interview]]></category>
		<category><![CDATA[Andrew Boekhoff]]></category>
		<category><![CDATA[congomongo]]></category>
		<category><![CDATA[MongoDB]]></category>

		<guid isPermaLink="false">http://rubylearning.com/blog/?p=4332</guid>
		<description><![CDATA[In this brief interview, Satish Talim of RubyLearning talks to Andrew Boekhoff, author of CongoMongo, a toolkit for using MongoDB with Clojure. Satish>> Welcome Andrew and thanks for taking out time to share your thoughts. What programming languages have you used seriously? Andrew>> Seriously: Ruby and Clojure. Less Seriously: C, C++, Java and now: Haskell, [...]<p><a href="http://www.launchbit.com/az/113-209/"><img width="468" height="60" src="http://www.launchbit.com/az-images/113-209/" /></a><br />
<small>(Powered by <a href="http://www.launchbit.com/lb/113-209/">LaunchBit</a>)</small></p>
]]></description>
			<content:encoded><![CDATA[<p></p>
<div class="topsy_widget_data topsy_theme_brick-red" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Frubylearning.com%252Fblog%252F2010%252F07%252F29%252Fclojure-a-chat-with-andrew-boekhoff%252F%22%2C%20%22shorturl%22%3A%20%22http%3A%2F%2Fbit.ly%2Fbh4v19%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22Clojure%3A%20A%20Chat%20with%20Andrew%20Boekhoff%22%20%7D);"></div>
<div>
<p class="alert">In this brief interview, Satish Talim of RubyLearning talks to <b>Andrew Boekhoff</b>, author of <a href="http://github.com/somnium/congomongo">CongoMongo</a>, a toolkit for using MongoDB with Clojure.</p>
<p><span style="color:#0000FF;"><strong>Satish>></strong> Welcome Andrew and thanks for taking out time to share your thoughts. What programming languages have you used seriously?</span></p>
<p><strong>Andrew>></strong> Seriously: Ruby and Clojure. Less Seriously: C, C++, Java and now:  Haskell, Scheme.</p>
<p><span style="color:#0000FF;"><strong>Satish>></strong> Why and when did you decide to start working on Clojure?</span></p>
<p><strong>Andrew&gt;&gt;</strong> I&#8217;ve been using Clojure for a little over a year. I had read Paul Graham&#8217;s essays, so I wanted to try a lisp dialect. I also wanted to learn what functional programming was all about. Then I watched Rich Hickey&#8217;s presentations on Clojure and by that point I was pretty much sold.</p>
<p><span style="color:#0000FF;"><strong>Satish>></strong> Could you name three features of Clojure that you like the most, as compared to other languages? Why?</span></p>
<p><strong>Andrew&gt;&gt;</strong></p>
<ol>
<li><b>Immutability</b>: Using immutable locals and data structures as the default eliminates a huge class of potential errors. I&#8217;ve never written as much code that worked on the first try in any other language. Concurrency is often mentioned as a great benefit from pervasive immutability &#8212; and it certainly is &#8212; but for me, the net reduction in complexity is what I love most.</li>
<li><b>It&#8217;s a Lisp: It has Macros</b>: Whether its for shearing off boiler plate, or embedding a parser for an internal DSL, the ability to easily extend the syntax of the language is a uniquely expressive trait of the lisp family.</li>
<li><b>The immense practicality of the JVM</b>: By being hosted on the JVM, Clojure comes with batteries-included and can be deployed anywhere that Java can (almost anywhere).</li>
</ol>
<p><span style="color:#0000FF;"><strong>Satish>></strong> You have written a Clojure wrapper (congomongo) for the mongo-db java api. Can you tell us more about this wrapper? Also, why did you target MongoDB?</span></p>
<p><strong>Andrew&gt;&gt;</strong> I really like working with MongoDB. The combination of schema-less document storage and ad-hoc queries is fantastic. The JSON format fits Clojure&#8217;s data structures well, and the mongo-java-driver is high quality and maintained. Congomongo is fairly light-weight &#8212; its main goal is to make interacting with the database from Clojure convenient and idiomatic.</p>
<p><span style="color:#0000FF;"><em>Thank you Andrew. In case you have any queries and/or questions, kindly post your questions here (as comments to this blog post) and Andrew would be glad to answer.</em></span></p>
</div>
<p>Technorati Tags: <a href="http://technorati.com/tag/Andrew+Boekhoff" rel="tag">Andrew Boekhoff</a>, <a href="http://technorati.com/tag/Clojure" rel="tag">Clojure</a>, <a href="http://technorati.com/tag/MongoDB" rel="tag">MongoDB</a>, <a href="http://technorati.com/tag/congomongo" rel="tag">congomongo</a></p>
Posted by <b>Satish Talim</b><p><a href="http://www.launchbit.com/az/113-209/"><img width="468" height="60" src="http://www.launchbit.com/az-images/113-209/" /></a><br />
<small>(Powered by <a href="http://www.launchbit.com/lb/113-209/">LaunchBit</a>)</small></p>

]]></content:encoded>
			<wfw:commentRss>http://rubylearning.com/blog/2010/07/29/clojure-a-chat-with-andrew-boekhoff/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Clojure Tips from the Experts</title>
		<link>http://rubylearning.com/blog/2010/07/26/clojure-tips-from-the-experts/</link>
		<comments>http://rubylearning.com/blog/2010/07/26/clojure-tips-from-the-experts/#comments</comments>
		<pubDate>Mon, 26 Jul 2010 02:49:15 +0000</pubDate>
		<dc:creator>Satish Talim</dc:creator>
				<category><![CDATA[Beginners]]></category>
		<category><![CDATA[Clojure]]></category>
		<category><![CDATA[Tricks]]></category>
		<category><![CDATA[Clojure Tips]]></category>

		<guid isPermaLink="false">http://rubylearning.com/blog/?p=4283</guid>
		<description><![CDATA[RubyLearning wrote to a lot of experts, gathering their best tips on Clojure. The tips are still coming in, but here are some to get you started with. Feel free to add your own tips in the comments section or send the same to satishtalim [at] gmail.com. Enjoy! Antonio Cangiano Find him on Twitter. His [...]<p><a href="http://www.launchbit.com/az/113-209/"><img width="468" height="60" src="http://www.launchbit.com/az-images/113-209/" /></a><br />
<small>(Powered by <a href="http://www.launchbit.com/lb/113-209/">LaunchBit</a>)</small></p>
]]></description>
			<content:encoded><![CDATA[<p></p>
<div class="topsy_widget_data topsy_theme_brick-red" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Frubylearning.com%252Fblog%252F2010%252F07%252F26%252Fclojure-tips-from-the-experts%252F%22%2C%20%22shorturl%22%3A%20%22http%3A%2F%2Fbit.ly%2Fd7qpuU%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22Clojure%20Tips%20from%20the%20Experts%22%20%7D);"></div>
<div>
<p class="alert">RubyLearning wrote to a lot of experts, gathering their best tips on Clojure. The tips are still coming in, but here are some to get you started with. Feel free to add your own tips in the comments section or send the same to <b>satishtalim [at] gmail.com</b>. Enjoy!</p>
<h3>Antonio Cangiano</h3>
<p>Find him on <a href="http://twitter.com/acangiano">Twitter</a>. His <a href="http://programmingzen.com/">Blog</a>.</p>
<p>When learning a new programming language, I find <a href="http://projecteuler.net/">Project Euler</a> to be an invaluable source of self-contained, increasingly more challenging exercises. By solving these mathematical problems in your language of choice, you&#8217;ll get some degree of exposure and familiarity with that language before tackling more complex, real world tasks.</p>
<p>When you solve a problem, you gain access to a forum where you can compare your implementation with those of other people who may have used the same language as you, or a different one. Normally there is a variety of common (and not so common) languages used by fellow participants.</p>
<p>Through the forum you&#8217;ll learn about more efficient algorithms and clever tricks, but above all you&#8217;ll get to see different ways to solve the same problem. It&#8217;s not hard to spot clean, concise, and idiomatic implementations and as a result end up learning more about the language you used.</p>
<p>Unfortunately for Clojure beginners, the threads in the forum for many of the initial problems were closed a long time ago. In practice, this means that you can usually read solutions implemented in many established programming languages, including Ruby and Haskell, but you won&#8217;t find solutions in Clojure for most of the problems (Clojure is after all much newer).</p>
<p>Thankfully, <a href="http://clojure-euler.wikispaces.com/">a wiki</a> which collects many solutions in Clojure exists. If you solve the problems first on your own, you can then use this resource to compare your approach with those of other Clojure programmers. You may discover that there is a better, more idiomatic way of solving a given problem.</p>
<p>In short, use <a href="http://projecteuler.net/">Project Euler</a> and the <a href="http://clojure-euler.wikispaces.com/">Clojure Euler wiki</a> if you want to get some experience with Clojure&#8217;s syntax and fundamental concepts, which you may have only read about in books or online tutorials.</p>
<hr />
<h3>Baishampayan Ghose</h3>
<p>Find him on <a href="http://twitter.com/ghoseb">Twitter</a>. His <a href="http://github.com/ghoseb/">GitHub</a> a/c.</p>
<p>It&#8217;s hard to pin point a few good tips because Clojure can do so many things in very nice and ingenious ways, that it&#8217;s not even funny. Anyway, here are a few:</p>
<p><b>Tip #1</b>: Sort a map on multiple keys:</p>
<pre>
;;; Tip #1
;;; A vector of maps
(def some-maps [{:x 1 :y 2} {:x 2 :y 1} {:x 1 :y 4} {:x 2 :y 8}])

;;; Sort the maps first on &#58;x and then on :y

(defn sort-maps-by
  "Sort a sequence of maps (ms) on multiple keys (ks)"
  [ms ks]
  (sort-by #(vec (map % ks)) ms))

;;; (sort-maps-by some-maps [:x :y])
;;; output> ({:x 1, :y 2} {:x 1, :y 4} {:x 2, :y 1} {:x 2, :y 8})
</pre>
<p><b>Tip #2</b>: When dealing with infinite sequences on the REPL, you can set the number of items to be printed:</p>
<pre>
;;; Tip #2
;;; When you type something like (iterate inc 1) on the REPL (or any
;;; kind of infinite, lazy sequence) the REPL will try to evaluate the
;;; whole thing and will never finish. One way to print some parts of
;;; an infinite sequence on the REPL is to do this on the REPL and
;;; then try to print the sequence -
;;; (set! *print-length* 10)
;;; (iterate inc 1)
;;; Which will only print the first 10 items of the above infinite
;;; sequence -
;;; (1 2 3 4 5 6 7 8 9 10 ...)
;;; There is also *print-level* which can be used to determine how
;;; nested/recursive data-structures are printed on the REPL
</pre>
<p><b>Tip #3</b>: Use of the -> &#038; ->> threading macros:</p>
<p>The -> &#038; ->> threading macros are very useful to sometimes untangle nested function calls. The -> macro takes a bunch of &#8216;forms&#8217; and &#8216;threads them&#8217; into each other by inserting every form as the second item of the next form and so on. So, (->> a (b c) (d e f) (g h)) becomes (g (d (b a c) e f) h). ->> is similar but it puts the form as the last item of the next form. (->> a (b c) (d e f) (g h)) then becomes (g h (d e f (b c a))).</p>
<pre>
(ns tips
  ;; requires clojure 1.2 if you are on 1.1.x, use this instead
  ;; (:require [clojure.contrib.duck-streams :as io])
  (:require [clojure.contrib.io :as io]))

;;; Tip #3
;;; Use of the -> &#038; ->> threading macros.
(defn word-freq
  "Calculate a frequency map of words in a text file."
  [f]
  (take 20 (->> f
                io/read-lines
                (mapcat (fn [l] (map #(.toLowerCase %) (re-seq #"\w+" l))))
                (remove #{"the" "and" "of" "to" "a" "i" "it" "in" "or" "is"})
                (reduce #(assoc %1 %2 (inc (%1 %2 0))) {})
                (sort-by (comp - val)))))

;;; Run it like this (word-freq "/path/to/file.txt")
</pre>
<hr />
<h3>Brian Carper</h3>
<p>Find him on <a href="http://twitter.com/BrianCarper">Twitter</a>. His <a href="http://briancarper.net/">Blog</a>.</p>
<p>&#8220;Named&#8221; or &#8220;keyword&#8221; arguments for functions have some benefits over positional arguments:</p>
<ol>
<li>You can specify arguments in any order.</li>
<li>The arguments are named explicitly, resulting in less room for error compared to positional arguments, where it&#8217;s easy to transpose two arguments in the list.</li>
<li>Your function can easily provide default argument values.</li>
</ol>
<p>For a function that takes only one or two arguments, keyword arguments might be overkill. But the benefits of keyword arguments quickly become more apparent the more argumentss your function accepts.</p>
<p>Clojure doesn&#8217;t have canonical support for keyword arguments.  But there are a couple of ways you can achieve the same result.</p>
<p>The first is simply to force the user to pass a hash-map explicitly.</p>
<pre>
(defn named-args-1 [foo argmap]
 (println "foo:" foo
          "bar:" (:bar argmap 0)
          "baz:" (:baz argmap 0))
 (println "bar-given?" (contains? argmap :bar)
          "baz-given?" (contains? argmap :baz)))

user> (named-args-1 1 {:baz 2})
foo: 1 bar: 0 baz: 2
bar-given? false baz-given? true
</pre>
<p>But wrapping arguments in braces is arguably an unnecessary burden on users of your code. A better way is to use destructuring to allow the user to &#8220;flatten&#8221; the map:</p>
<pre>
(defn named-args-2 [foo &#038; args]
 (let [argmap (apply hash-map args)
       {:keys [bar baz]
        &#58;or   {bar 0 baz 0}} argmap]
   (println "foo:" foo
            "bar:" bar
            "baz:" baz)
   (println "bar-given?" (contains? argmap :bar)
            "baz-given?" (contains? argmap :baz))))

user> (named-args-2 1 :baz 2)
foo: 1 bar: 0 baz: 2
bar-given? false baz-given? true
</pre>
<p>This is OK for the user, but verbose for the function-writer. And the argument list for the function is specified as &#8220;args&#8221;, giving the user no clue as to what keys are expected or legal.</p>
<p>As of recent releases of Clojure, you can do the destructuring right in the function&#8217;s argument list, leading to this version:</p>
<pre>
(defn named-args-3 [foo &#038; {:keys [bar baz]
                          &#58;or   {bar 0 baz 0}
                          :as   argmap}]
 (println "foo:" foo
          "bar:" bar
          "baz:" baz)
 (println "bar-given?" (contains? argmap :bar)
          "baz-given?" (contains? argmap :baz)))

user> (named-args-3 1 :baz 2)
foo: 1 bar: 0 baz: 2
bar-given? false baz-given? true
</pre>
<p>It&#8217;s also possible to roll your own macro to do keyword arguments. See <b>clojure.contrib.def/defnk</b>, for example.</p>
<hr />
<h3>Craig Andera</h3>
<p>Find him on <a href="http://twitter.com/craigandera">Twitter</a>. His <a href="http://www.pluralsight-training.net/community/blogs/craig/">Blog</a>.</p>
<p>I have two. The first one I stole from Mike Fogus: to use &#8220;,,,&#8221; as a placeholder in the <b>-></b> and <b>->></b> macros. Since commas are whitespace, they can be used as markers to indicate how the expressions flow through the threading macros. So, for instance, you can write:</p>
<pre>
(->>
 (iterate inc 1)
 (map #(* 5 %) ,,,)
 (filter odd? ,,,))
</pre>
<p>and the commas indicate &#8220;the previous expression will be inserted here&#8221;.</p>
<p>It&#8217;s not something you should put in production code, but I found it enormously helpful in &#8220;getting&#8221; the -> and ->> macros. Honestly, I only had to write it out this way once or twice before it clicked with me and I stopped using the commas altogether.</p>
<p>The other tip I have, has to do with understanding when to use <b>map</b>, <b>filter</b>, and <b>reduce</b>. These three functions are where an enormous amount of Clojure&#8217;s power comes from, but I find that beginners (such as myself) sometimes have a hard time selecting which one &#8211; or which combination &#8211; to use. What I&#8217;ve found is that it&#8217;s helpful to think of these in terms of what you *have* and what you *need*:</p>
<ul>
<li>If you *have* a sequence of length n and you *need* a sequence of length n, use <b>map</b>.</li>
<li>If you *have* a sequence of length n and you *need* a shorter sequence, use <b>filter</b>.</li>
<li>If you *have* a sequence of length n and you *need* a scalar, use <b>reduce</b>.</li>
</ul>
<p>It seems pretty obvious when stated like that, but it has been helpful to me on occasion when I start to get lost in how to express a particular algorithm.</p>
<hr />
<h3>Meikel Brandmeyer</h3>
<p>Find him on <a href="http://twitter.com/kotarak">Twitter</a>. His <a href="http://bitbucket.org/kotarak">BitBucket Id</a>.</p>
<p>Here is my tip on <b>atoms</b>.</p>
<p>Clojure provides a lot of facilities to tackle the complexity of concurrent programming. But still you have to understand the semantics of the underlying facilities. One of these are <b>refs</b>, which allow coordinated access to several different entities at once. However, their use inflicts quite a bit of ceremony. You have to invoke the STM machinery whenever you want to write to a <b>ref</b> or want a consistent snapshot of several <b>refs</b>. Also your transaction is rolled back should a surrounding transaction retry. This is not always what you want.</p>
<p>In such cases, it is interesting to use an <b>atom</b>. They are cheaper in terms of overhead and don’t interact with the STM. So the retry of a surrounding transaction doesn’t affect them. However they are uncoordinated: you can&#8217;t safely update multiple <b>atoms</b> at once.</p>
<p>What is not so well known, is the fact, that <b>refs</b> also coordinate several accesses to the *same* <b>ref</b>. Again, this does *not* work well with <b>atoms</b>. Consider a cache, eg. for a <b>memoized</b> function.</p>
<pre>
(defn memoize
 [f]
 (let [cache (atom {})]
   (fn [&#038; args]
     (when-not (contains? @cache args)
       (swap! cache assoc args (apply f args)))
     (get @cache args))))
</pre>
<p>This code uses an <b>atom</b> and clojure datastructures, so we have no problems with concurrency, right? <b>Wrong!</b> There are plenty of race conditions between the different calls to <b>contains?</b>, <b>swap!</b> and <b>get</b>. In the example, the worst thing that can happen is that we compute the value of the function call several times. This can already be quite annoying if the call is expensive in computation time and/or resources. But consider a more involved cache implementation which could also remove entries from the cache. Then the call to <b>contains?</b> could see the value, but when we call get it might already be removed.</p>
<p>The problem is, that we access the atom’s contents several times and this is not coordinated. Contrary to <b>refs</b> where we could call ensure to – well – ensure that the <b>ref</b> doesn’t change under our hands.</p>
<p>How to solve this problem? Well, the problem is that we touch the <b>atom</b> several times. So the solution is to touch the <b>atom</b> only once!</p>
<pre>
(defn memoize
 [f]
 (let [cache  (atom {})
       update (fn [state args]
                (if-not (contains? state args)
                  (assoc state args (apply f args))
                  state))]
   (fn [&#038; args]
     (get (swap! cache update args) args))))
</pre>
<p>Here we do the contains check and update in one function which will see a consistent view of the cache state. Note that we also use the return value of the <b>swap!</b>. Otherwise we would again have to access to the atom several times!</p>
<p>So while Clojure provides a lot of tools to tackle the problems of a concurrent world, you still have to understand what the semantics of the different tools are. And even then you have to carefully reason about your code. How it behaves. Where race conditions might hide. Life is not easy.</p>
<p><b>Note</b>: There are other problems to the above problem. Eg. doing expensive work – namely calling f – in a <b>swap!</b>. Please read <a href="http://kotka.de/blog/2010/03/memoize_done_right.html">Meikel&#8217;s blog post</a> on <b>memoize</b> where even more such considerations are taken into account.</p>
<hr />
<h3>Michael Fogus</h3>
<p>Find him on <a href="http://twitter.com/fogus">Twitter</a>. His book <a href="http://fogus.me/">The Joy of Clojure</a>.</p>
<p>Many macros that I write start exactly the same way:</p>
<pre>
   (defmacro a-macro [&#038; forms]
     `'~forms)
</pre>
<p>Then it proceeds to be transformed into a pipeline where each piece does a gradual transformation of forms:</p>
<pre>
   (defn do-something [forms]
     (frobnicate forms))

   (defn do-something-else [forms]
     (moidilize forms))

   (defmacro a-macro [&#038; forms]
     (let [forms (do-something forms)
           forms (do-something-else forms)])
     `'~forms)
</pre>
<p>This makes it easy to see the transformations occurring at each step, keeps my macros small, and allows me to put error handling in each of the transformation functions for compile-time exceptions.</p>
<p>Although this is all pretty arcane as I try really really hard to avoid writing macros else I get beaten.</p>
<hr />
<h3>Michael Kohl</h3>
<p>Find him on <a href="http://twitter.com/citizen428">Twitter</a>. His <a href="http://citizen428.net/">Blog</a>.</p>
<p>My tip would be the <a href="http://clojure.org/reader">Clojure reader macro <b>#_</b></a> which completely ignores the next form. From the docs:</p>
<p>&#8220;The form following <b>#_</b> is completely skipped by the reader. (This is a more complete removal than the <b>comment</b> macro which yields <b>nil</b>).&#8221;</p>
<p>This can be immensely useful while debugging.</p>
<hr />
<h3>Nurullah Akkaya</h3>
<p>Find him on <a href="http://twitter.com/nakkaya">Twitter</a>. His <a href="http://nakkaya.com/">Blog</a>.</p>
<p>My tip would be on destructuring, which allows you to pull apart data structures into local bindings.</p>
<pre>
     (let [[x y] [1 2]]
       x)
     ;;user=> 1

     (let [[a b c] "abc"]
       c)
     ;;user=> \c

     (let [[[x1 y1][x2 y2]] [[1 2] [3 4]]]
       [x1 y1 x2 y2])
     ;;user=> [1 2 3 4]
</pre>
<p>Besides destructuring sequential things (vectors, lists, seqs, strings, arrays, or anything that supports nth), you can destructure maps as well:</p>
<pre>
     (let [{key1 :key1 key2 :key2} {:key1 5 :key2 6}]
       [key1 key2])
     ;;user=> [5 6]

     (let [{[x1 y1] :player1 [x2 y2] :player2} {:player1 [5 6] :player2 [9 9]}]
       [x1 y1 x2 y2])
     ;;user=> [5 6 9 9]
</pre>
<p>Most of the time, your local variables has the same names as the keywords, Clojure provides a shortcut that saves you from typing binding x keyword &#58;x over and over again:</p>
<pre>
     (let [{:keys [key1 key2]} {:key1 5 :key2 6}]
            [key1 key2])
     ;;user=> [5 6]
</pre>
<p>For more on destructuring, checkout the <a href="http://clojure.org/special_forms#Special Forms--(let[bindings* ] exprs*">documentation</a>.</p>
<hr />
<h3>Ramakrishnan Muthukrishnan</h3>
<p>Find him on <a href="http://twitter.com/vu3rdd">Twitter</a>. His <a href="http://github.com/vu3rdd">GitHub Id</a>.</p>
<p><b>Tip #1</b>:</p>
<p>If you have a sequence and want to remove duplicates, there are (atleast) two ways to do it:</p>
<pre>
(vec (into #{} [1 2 2 3 4 5])) ; => [1 2 3 4 5]
</pre>
<p>or</p>
<pre>
(distinct [1 2 2 3 4 5]) ; => [1 2 3 4 5]
</pre>
<p>The second one is preferred.</p>
<p><b>Tip #2</b>:</p>
<p>In a function, if you have a list of parameters, you can do the following:</p>
<pre>
(defn foo [x &#038; xs]
 (...))
</pre>
<p>The same can be done in anonymous functions too. What if you are using the abbreviated form (reader macro form) of an anonymous function? You can still use it by using the &#8220;%&#038;&#8221; to denote the rest of the argument as a list. One example of the use of this form is shown <a href="http://www.bestinclass.dk/index.clj/2009/10/brians-functional-brain.html">here</a>.</p>
<p><b>Tip #3</b>: I echo Craig Andera&#8217;s opinions on <b>map</b>, <b>filter</b> and <b>reduce</b>. It is extremely important to master these three constructs. Especially, the way <b>reduce</b> can be used with hash-maps.</p>
<p><b>Tip #4</b>: If you want to have default values for some of the input parameters, one way is to define functions of diferent arity.</p>
<pre>
(defn foo
 ([] (foo "bar"))
 ([s] (........)))
</pre>
<p>Here, when &#8216;foo&#8217; is called without any arguments, we assume a default value of &#8220;bar&#8221;, a string as argument to the function and call foo with that argument.</p>
<hr />
<h3>Stuart Sierra</h3>
<p>Find him on <a href="http://twitter.com/stuartsierra">Twitter</a>. His <a href="http://stuartsierra.com/">Blog</a>.</p>
<p>Well, I&#8217;ve said this before, but it bears saying again: Don&#8217;t write a macro where a function will do. Functions are more flexible: they can be composed and passed as values. Do not use macros solely to make the syntax &#8220;prettier.&#8221;</p>
<hr />
<p class="alert">Do you like these tips? We are eager to know your reactions as comments to this post.
</p></div>
<p>Technorati Tags: <a href="http://technorati.com/tag/Clojure" rel="tag">Clojure</a>, <a href="http://technorati.com/tag/Clojure+Tips" rel="tag">Clojure Tips</a></p>
Posted by <b>Satish Talim</b><p><a href="http://www.launchbit.com/az/113-209/"><img width="468" height="60" src="http://www.launchbit.com/az-images/113-209/" /></a><br />
<small>(Powered by <a href="http://www.launchbit.com/lb/113-209/">LaunchBit</a>)</small></p>

]]></content:encoded>
			<wfw:commentRss>http://rubylearning.com/blog/2010/07/26/clojure-tips-from-the-experts/feed/</wfw:commentRss>
		<slash:comments>29</slash:comments>
		</item>
	</channel>
</rss>

