<?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>Ruby Archives | Programming Zen</title>
	<atom:link href="https://programmingzen.com/tag/ruby/feed/" rel="self" type="application/rss+xml" />
	<link>https://programmingzen.com/tag/ruby/</link>
	<description>Meditations on programming, startups, and technology</description>
	<lastBuildDate>Thu, 12 Nov 2020 02:23:39 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
<site xmlns="com-wordpress:feed-additions:1">1397766</site>	<item>
		<title>Developing with Elixir/OTP Course Review</title>
		<link>https://programmingzen.com/developing-with-elixir-otp-course-review/</link>
					<comments>https://programmingzen.com/developing-with-elixir-otp-course-review/#comments</comments>
		
		<dc:creator><![CDATA[Antonio Cangiano]]></dc:creator>
		<pubDate>Thu, 30 Apr 2020 04:01:22 +0000</pubDate>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Reviews]]></category>
		<category><![CDATA[elixir]]></category>
		<category><![CDATA[erlang]]></category>
		<category><![CDATA[online courses]]></category>
		<category><![CDATA[OTP]]></category>
		<category><![CDATA[pragmaticstudio]]></category>
		<category><![CDATA[review]]></category>
		<category><![CDATA[Ruby]]></category>
		<guid isPermaLink="false">https://programmingzen.com/?p=2457</guid>

					<description><![CDATA[<p>Ruby was the first programming language I truly fell in love with. Yes, I had used several others before (and have since), but Ruby was and still is something dear to me. I can appreciate the usefulness of Python, the simplicity of Go, and the mind-expanding nature of Haskell. Yet, anything that isn&#x2019;t Ruby felt like a usability downgrade. It&#x2019;s all highly subjective, &#xE7;a va sans dire, but Ruby was always my favorite. It&#x2019;s not every day that a language comes along and genuinely excites me to the point of putting Ruby aside (within the scope of what it&#x2019;s great </p>
<p>The post <a href="https://programmingzen.com/developing-with-elixir-otp-course-review/">Developing with Elixir/OTP Course Review</a> appeared first on <a href="https://programmingzen.com">Programming Zen</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Ruby was the first programming language I truly fell in love with. Yes, I had used several others before (and have since), but Ruby was and still is something dear to me.</p>



<p>I can appreciate the usefulness of Python, the simplicity of Go, and the mind-expanding nature of Haskell. Yet, anything that isn&#8217;t Ruby felt like a usability downgrade. It&#8217;s all highly subjective, ça va sans dire, but Ruby was always my favorite.</p>



<p>It&#8217;s not every day that a language comes along and genuinely excites me to the point of putting Ruby aside (within the scope of what it&#8217;s great at doing).</p>



<h2 class="wp-block-heading">I &lt;3 Elixir</h2>



<p>That language is Elixir. I&#8217;ve been using it on and off for a few years now. I first <a href="https://programmingzen.com/next-programming-language/">talked about it</a> back in 2016 and even managed to convince my team at IBM to adopt it to an extent. It&#8217;s working out well for us so far and I have a hunch we might double down on it soon.</p>



<p>Since I have a little more time, due to being stuck inside, I&#8217;ve been on a &#8220;study anything in sight related to Elixir and Phoenix&#8221; kick lately.</p>



<p>I am a big fan of Mike and Nicole Clark of The Pragmatic Studio and in the past have highly <a href="https://programmingzen.com/rails-books/">recommended their Ruby and Rails courses</a>. So I decided to start taking their Elixir courses as well. In this post, I&#8217;ll give you a fairly detailed review of their largest course on the subject, <a rel="noreferrer noopener" href="https://pragmaticstudio.com/elixir" target="_blank">Developing with Elixir/OTP</a>.</p>



<h2 class="wp-block-heading">Who is it for?</h2>



<figure class="wp-block-image size-full is-resized"><img data-recalc-dims="1" fetchpriority="high" decoding="async" src="https://i0.wp.com/programmingzen.com/wp-content/uploads/2020/04/developing-with-elixir-otp-review.png?resize=768%2C434&#038;ssl=1" alt="Developing with Elixir/OTP Course Review" class="wp-image-2460" width="768" height="434" srcset="https://i0.wp.com/programmingzen.com/wp-content/uploads/2020/04/developing-with-elixir-otp-review.png?w=1536&amp;ssl=1 1536w, https://i0.wp.com/programmingzen.com/wp-content/uploads/2020/04/developing-with-elixir-otp-review.png?resize=300%2C169&amp;ssl=1 300w, https://i0.wp.com/programmingzen.com/wp-content/uploads/2020/04/developing-with-elixir-otp-review.png?resize=1024%2C578&amp;ssl=1 1024w, https://i0.wp.com/programmingzen.com/wp-content/uploads/2020/04/developing-with-elixir-otp-review.png?resize=768%2C434&amp;ssl=1 768w" sizes="(max-width: 768px) 100vw, 768px" /></figure>



<p>Developing with Elixir/OTP is aimed at programmers. It&#8217;s so well explained that beginners can give it a shot, however, they are not the target audience.</p>



<p>The course assumes you have zero knowledge of Elixir itself but it&#8217;s not going to explain basic programming concepts when they are not novel or unique to Elixir.</p>



<p>Experience with Ruby is not required nor assumed, but it&#8217;s beneficial. This isn&#8217;t so much due to the way the course is presented (though there are a couple of nods to Ruby programmers). Rather, it&#8217;s the similarity (on the surface) between the two languages.</p>



<h2 class="wp-block-heading">How much time do you need to invest?</h2>



<p>Developing with Elixir/OTP is a 6.5 hour course divided across 30 modules. There is no way for you to take this course in 6.5 hours and get anything worthwhile from it.</p>



<p>In fact, the secret sauce is that each module has a Notes section dedicated to expanding on the topic, providing tips and tricks, as well as exercises.&nbsp;</p>



<p>I would estimate that it took me around 20 hours or so to finish, despite being very familiar with the subject matter. Mind you, I do like to experiment quite a bit within IEx to veer off the beaten path.</p>



<p>Estimate 30 hours of your time, an hour per module, if you intend to fully absorb and experiment with the material presented.</p>



<p>Unlike their Rails course, you won&#8217;t develop two applications (one while watching the videos and one in the Notes section). In this course, there is only one application that is mostly developed in the videos and then enhanced in the Notes through exercises.</p>



<p>This will save you a lot of time at the small expense of having to pause and resume the video to type along.</p>



<p>Another time-saver is that the code for each module in the course is provided so that you&#8217;re never lost. Particularly useful to copy and paste the more tedious parts (e.g., sample data and template code).</p>



<h2 class="wp-block-heading">What will you build?</h2>



<p>The course starts off by developing a simple web server. Think, high-level transformations of requests into responses. It builds it from the ground up and then layers a simple RESTful API for a fictitious wildlife reserve on top.</p>



<p>They start off with the simplest thing, a function that transforms one specific request into one specific response, and then move up all the way to actually serving the API over HTTP.</p>



<p>The goal, as often stated in the course, is not to replace an established and much more robust web server like Cowboy or a framework like Phoenix. At all.</p>



<p>Instead, it serves two pedagogical purposes. First, it teaches you how to use the language to solve a fairly complex problem. Second, it gives you a deeper understanding of how the production-ready tools you are going to adopt actually work within.</p>



<p>This approach is endemic to their teaching method. For example, they&#8217;ll develop a simple web server and API from scratch and then show you how similar it is to the equivalent Phoenix version. By the time you hit module 17 on Phoenix, you don&#8217;t quite know Phoenix but it should feel oddly familiar. After all, you built a naïve/simplified version of the same controllers, router, templates, etc. from scratch. This is, of course, a deliberate choice.</p>



<p>The same is true when they implement a simple GenServer from scratch and then are able to seamlessly replace it with the real deal (with <code>use GenServer</code>). Yes, you developed the Fisher-Price version of the production-ready tools, but you now understand how they work under the hood. All before Mike and Nicole proceed to teach you how to use the battle-tested ones.</p>



<p>I&#8217;m a fan of this didactic approach and I think it will serve most people well.</p>



<h2 class="wp-block-heading">What will you learn?</h2>



<p>It might be surprising to some but this course does not provide the typical tour of data types and data structures available in the language.</p>



<p>Instead, it uses the language to build something from the beginning and, in the process, it quickly exposes you to a variety of concepts, including how to use common data types.</p>



<p>It doesn&#8217;t cover them thoroughly, however, so reading the <a rel="noreferrer noopener" href="https://elixir-lang.org/getting-started/introduction.html" target="_blank">Elixir tutorial</a> on the official site would be very beneficial prior to or after taking this course.</p>



<p>The course starts off with several modules that are heavily focused on pattern matching. This is a good choice because pattern matching is one of the most valuable and pervasive features of Elixir.</p>



<p>As you would expect, there is also quite a bit of emphasis on immutable data structures, the pipe operator, recursion, and the Enum module.</p>



<p>In the process you&#8217;ll also learn a lot about IEx, Mix, organizing your code in a logical and idiomatic manner, defining Structs as the safer alternatives to maps, and comprehensions. </p>



<p>Testing is covered adequately but not extensively in its own module. Not in a TDD manner from the very start of the course like they did in some of their previous courses. This has, again, didactical advantages even if you choose to adopt TDD in your actual work.</p>



<p>In the second half of the course, things get a little more serious courtesy of OTP, delving deeper into working with sockets, the actor model, Task, GenServer, and linking and monitoring processes.</p>



<h2 class="wp-block-heading">Other points worth making</h2>



<p>In more or less random order:</p>



<ul class="wp-block-list"><li>The course is up to date to Elixir 1.10.x, somewhat rare among Elixir courses. Some of the videos show Mike and Nicole using a previous version (i.e., 1.5), but the Notes use the latest version and the rare differences are noted.  For example, the video shows the old <code>mix new</code> project format which included a <code>config</code> folder. In their hands-on notes for the video, they have a comprehensive &#8220;I don&#8217;t see a config directory&#8221; section to address it. You&#8217;re basically never lost or confused due to version discrepancies.</li><li>The overall quality is excellent. It&#8217;s a really polished product in terms of audio, video, text, and visuals used to aid in explaining the more conceptual parts.</li><li>They answer the overwhelming majority of your &#8220;wait a second&#8221; questions and objections. Either later in the video or right in the notes for that particular module. They genuinely anticipate most questions, which is the hallmark of a great course.</li><li>Most modules have a single 5-15 minute video, but some modules include two videos. So the modules are&#8230; well, modular.</li><li>Although this course will equip you to start studying Phoenix, it doesn&#8217;t really cover the subject. There is a module, as I mentioned, which is just enough to whet your appetite for the framework.</li><li>Erlang interoperability is at least in part addressed in module 20, where sample code from the documentation of <code>gen_tcp</code> is converted from Erlang to Elixir code.</li><li>The course is full of small tips like enabling command history in IEx (with <code>export ERL_AFLAGS="-kernel shell_history enabled"</code>), speeding up unit tests by making them asynchronous (i.e., <code>use ExUnit.Case, async: true</code>), using <code>flush()</code> to clear a process&#8217; mailbox, etc.</li></ul>



<h2 class="wp-block-heading">Is it worth the price?</h2>



<p>At $89, <a href="https://pragmaticstudio.com/elixir">Developing with Elixir/OTP</a> is not your average Udemy course that&#8217;s routinely discounted to $12. That&#8217;s because it&#8217;s not your average course.</p>



<p>If I had to rate it, I&#8217;d give it a 4.5 out of 5. I highly recommend it to working programmers who are interested in picking up Elixir quickly.</p>



<p>I would argue that it&#8217;s a great, current resource that is well worth the price of admission if you favor learning from videos.</p>
<p>The post <a href="https://programmingzen.com/developing-with-elixir-otp-course-review/">Developing with Elixir/OTP Course Review</a> appeared first on <a href="https://programmingzen.com">Programming Zen</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://programmingzen.com/developing-with-elixir-otp-course-review/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2457</post-id>	</item>
		<item>
		<title>Installing rbenv on Zsh (on MacOS)</title>
		<link>https://programmingzen.com/installing-rbenv-on-zsh-on-macos/</link>
					<comments>https://programmingzen.com/installing-rbenv-on-zsh-on-macos/#comments</comments>
		
		<dc:creator><![CDATA[Antonio Cangiano]]></dc:creator>
		<pubDate>Fri, 06 Sep 2019 17:44:37 +0000</pubDate>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[rbenv]]></category>
		<category><![CDATA[rbenv zsh]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[ruby-build]]></category>
		<category><![CDATA[zsh]]></category>
		<guid isPermaLink="false">https://programmingzen.com/?p=2197</guid>

					<description><![CDATA[<p>Recently, I updated my Mac to the latest beta of macOS. It&#x2019;s not a polished product yet, but overall it&#x2019;s been a fairly enjoyable operating system. One of the changes that will impact you as a developer is that Apple switched the default shell from Bash to Zsh (Z shell). You can, of course, change it back to Bash, but I don&#x2019;t mind Zsh (or Fish) so I decided to keep it. I needed to install htmlbeautifier, a gem used by some prettifier extensions within Visual Studio Code. If you try it with the default system installation of Ruby, you&#x2019;ll </p>
<p>The post <a href="https://programmingzen.com/installing-rbenv-on-zsh-on-macos/">Installing rbenv on Zsh (on MacOS)</a> appeared first on <a href="https://programmingzen.com">Programming Zen</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Recently, I updated my Mac to the latest beta of macOS. It&#8217;s not a polished product yet, but overall it&#8217;s been a fairly enjoyable operating system.</p>



<p>One of the changes that will impact you as a developer is that Apple switched the default shell from Bash to Zsh (Z shell). You can, of course, change it back to Bash, but I don&#8217;t mind Zsh (or Fish) so I decided to keep it.</p>



<p>I needed to install <g class="gr_ gr_4 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" id="4" data-gr-id="4">htmlbeautifier</g>, a gem used by some prettifier extensions within Visual Studio Code. If you try it with the default system installation of Ruby, you&#8217;ll get a permission error:</p>



<pre class="wp-block-code"><code>$ gem install htmlbeautifier
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /Library/Ruby/Gems/2.6.0 directory.</code></pre>



<p>At this point, you might be tempted to simply <code>sudo</code> it, but that&#8217;s not a smart approach. Instead, I like to have multiple versions through an environment management system such as <a rel="noreferrer noopener" aria-label=" (opens in a new tab)" href="https://github.com/rbenv/rbenv" target="_blank">rbenv</a> or <a href="https://asdf-vm.com/#/" target="_blank" rel="noreferrer noopener" aria-label=" (opens in a new tab)">asdf</a>.</p>



<p>For this particular machine, I picked rbenv. Unfortunately, following the usual setup instructions didn&#8217;t really work, so I&#8217;m sharing the setup that worked for me here.</p>



<p>I updated brew and used it to install <g class="gr_ gr_4 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling" id="4" data-gr-id="4">rbenv</g> and ruby-build. The latter allows us to select a series of Ruby versions to chose from.</p>



<pre class="wp-block-code"><code>$ brew update &amp;&amp; brew install rbenv ruby-build</code></pre>



<p>To ensure that rbenv is correctly loaded when we start a new shell, I had to edit a couple of files. I added the following line to <code>.zshenv</code>:</p>



<pre class="wp-block-code"><code>export PATH="$HOME/.rbenv/bin:$PATH"</code></pre>



<p>This adds gem-specific binaries to the PATH so that they are accessible to the shell without fully qualifying them with their path.</p>



<p>Then I added the following lines to <code>.zshrc</code>:</p>



<pre class="wp-block-code"><code>source $HOME/.zshenv
eval "$(rbenv init - zsh)"</code></pre>



<p>This ensures that the previous file is sourced when a new session is started and that rbenv is initialized for Zsh.</p>



<p>At this point, you&#8217;ll want to source <code>.zshrc</code> (or simply restart the terminal of your choice like iTerm2, instead):</p>



<pre class="wp-block-code"><code>$ source ~/.zshrc</code></pre>



<p>With rbenv ready to go, I installed the latest version of Ruby and set it as my global default for this machine.</p>



<p>You can determine the latest stable version by running:</p>



<pre class="wp-block-code"><code>$ rbenv install -l</code></pre>



<p>Go ahead and run:</p>



<pre class="wp-block-code"><code>$ rbenv install 2.7.2
$ rbenv global 2.7.2</code></pre>



<p>After restarting the terminal again, do a quick sanity test to ensure that the right version of Ruby is being selected:</p>



<pre class="wp-block-code"><code>$ ruby -v
ruby 2.7.2p137 (2020-10-01 revision 5445e04352) &#91;x86_64-darwin20]

$ ruby -e "puts (1..100).reduce(:+)"
5050</code></pre>



<p>Finally, you&#8217;ll be able to install htmlbeautifier, like I did:</p>



<pre class="wp-block-code"><code>$ gem install htmlbeautifier</code></pre>



<p>No need for <code>sudo</code>.</p>



<p>I hope this helps anyone who is trying to install rbenv on zsh. It did the trick for me.</p>
<p>The post <a href="https://programmingzen.com/installing-rbenv-on-zsh-on-macos/">Installing rbenv on Zsh (on MacOS)</a> appeared first on <a href="https://programmingzen.com">Programming Zen</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://programmingzen.com/installing-rbenv-on-zsh-on-macos/feed/</wfw:commentRss>
			<slash:comments>12</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2197</post-id>	</item>
		<item>
		<title>Rails Is Old Hat, and That&#8217;s Okay</title>
		<link>https://programmingzen.com/rails-is-an-old-hat/</link>
					<comments>https://programmingzen.com/rails-is-an-old-hat/#comments</comments>
		
		<dc:creator><![CDATA[Antonio Cangiano]]></dc:creator>
		<pubDate>Tue, 09 Dec 2014 16:43:23 +0000</pubDate>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[elixir]]></category>
		<category><![CDATA[Node.js]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<guid isPermaLink="false">http://programmingzen.com/?p=1579</guid>

					<description><![CDATA[<p>Not too long ago, someone I know said, &#x201C;At this point in time, Rails is old hat&#x201D;, in reference to the fact that many developers are adopting newer technologies like Node.js. I don&#x2019;t see this as a negative, true as it might be. When Rails arrived on the scene a decade ago, it was thoroughly impressive and quite the improvement over the status quo in the PHP, Java, and even Ruby communities. At the time, despite some shortcomings, it was revolutionary. Not surprisingly, as time went on the framework evolved, improved, and became more mature. The whole ecosystem around it </p>
<p>The post <a href="https://programmingzen.com/rails-is-an-old-hat/">Rails Is Old Hat, and That&#8217;s Okay</a> appeared first on <a href="https://programmingzen.com">Programming Zen</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Not too long ago, someone I know said, “At this point in time, Rails is old hat”, in reference to the fact that many developers are adopting newer technologies like Node.js.</p>
<p>I don’t see this as a negative, true as it might be. When Rails arrived on the scene a decade ago, it was thoroughly impressive and quite the improvement over the status quo in the PHP, Java, and even Ruby communities. At the time, despite some shortcomings, it was revolutionary.</p>
<p>Not surprisingly, as time went on the framework evolved, improved, and became more mature. The whole ecosystem around it grew exponentially. You can now deploy scalable Rails applications. It is the darling framework of most startups in Silicon Valley. You can leverage advanced support in editors and IDEs, run it on different platforms (e.g., on the JVM via JRuby), and find Rails developers to hire with relative ease.</p>
<p>As it grew to become the tool of choice of countless web developers, it managed to have a massive influence on other communities as well. It contributed to raising the bar for frameworks in other languages and as a result we have at least a bit of Rails inspired frameworks in virtually every language today. We are more productive almost regardless of the language we choose, and in many cases we have Rails to thank for it.</p>
<p>What Rails lost in the process is the massive competitive advantage it had in its early days over virtually everything else that was out there. <a id="fnref-1" class="footnote" title="see footnote" href="#fn-1">[1]</a> It hasn’t failed to grow. It hasn’t failed to innovate. It simply matured and so did the rest of the web world.</p>
<p>I think it’s important for developers to reinvent themselves, or at least stay up-to-date on what’s available out there. That’s how I came to discover Rails in the first place. This is true for programmers in general, and its especially true for my professional role which includes technical evangelism in a team that continually reinvents itself.</p>
<p>When you go talk to a new generation of programmers, you need to be able to speak their language. And today for many, in my experience, that means speaking Node.js, instead of Rails.</p>
<p>That’s okay. Ruby on Rails might be old news by now, but it remains a perfectly capable solution for a wide array of problems. It has become the status quo and there is nothing wrong with that.</p>
<p>As we look for new runtimes, languages, and frameworks that innovate further and better solve those particular use cases where Rails doesn’t shine, we might stumble upon a new and innovative solution that make today’s Rails look like J2EE or PHP did to us back in 2004. <a id="fnref-2" class="footnote" title="see footnote" href="#fn-2">[2]</a> Until then, it’s worth keeping an eye open while still wearing that old, comfortable, and very trusty hat that has been helping us get the job done for a decade now.</p>
<div class="footnotes">
<hr />
<ol>
<li id="fn-1">A few exceptions aside. Django comes to mind. <a class="reversefootnote" title="return to article" href="#fnref-1">^</a></li>
<li id="fn-2">Elixir is headed in the right direction, language wise. Meteor.js shows flashes of brilliance at times. Still, we’re not there yet. <a class="reversefootnote" title="return to article" href="#fnref-2">^</a></li>
</ol>
</div>
<p>The post <a href="https://programmingzen.com/rails-is-an-old-hat/">Rails Is Old Hat, and That&#8217;s Okay</a> appeared first on <a href="https://programmingzen.com">Programming Zen</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://programmingzen.com/rails-is-an-old-hat/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1579</post-id>	</item>
		<item>
		<title>On Programming Languages as Languages</title>
		<link>https://programmingzen.com/programming-languages-as-languages/</link>
					<comments>https://programmingzen.com/programming-languages-as-languages/#comments</comments>
		
		<dc:creator><![CDATA[Antonio Cangiano]]></dc:creator>
		<pubDate>Thu, 27 Nov 2014 16:05:32 +0000</pubDate>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[programming languages]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[Ruby]]></category>
		<guid isPermaLink="false">http://programmingzen.com/?p=1571</guid>

					<description><![CDATA[<p>When you look up the word &#x201C;Language&#x201D; in the dictionary, you&#x2019;ll find a few variations of similar definitions. My trusty Google Dictionary extension in Chrome, offers up a first definition that is rather obvious, but nevertheless: The method of human communication, either spoken or written, consisting of the use of words in a structured and conventional way. The second definition is more interesting because it allows me to make a point about programming languages. It goes like this: The system of communication used by a particular community or country. Look at that. Isn&#x2019;t that beautiful? Let&#x2019;s cut the country stuff, </p>
<p>The post <a href="https://programmingzen.com/programming-languages-as-languages/">On Programming Languages as Languages</a> appeared first on <a href="https://programmingzen.com">Programming Zen</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>When you look up the word “Language” in the dictionary, you’ll find a few variations of similar definitions. My trusty <a href="https://chrome.google.com/webstore/detail/google-dictionary-by-goog/mgijmajocgfcbeboacabfgobmjgjcoja?hl=en">Google Dictionary extension</a> in Chrome, offers up a first definition that is rather obvious, but nevertheless:</p>
<blockquote><p>The method of human communication, either spoken or written, consisting of the use of words in a structured and conventional way.</p></blockquote>
<p>The second definition is more interesting because it allows me to make a point about programming languages. It goes like this:</p>
<blockquote><p>The system of communication used by a particular community or country.</p></blockquote>
<p>Look at that. Isn’t that beautiful? Let’s cut the country stuff, and shorten it to, “The system of communication used by a particular community”. Tell me that it’s not a spectacular definition of programming languages as well.</p>
<p>We can look at programming languages in two possible ways. They can be a means for us to instruct the computer, and incidentally communicate with fellow programmers, or they can allow us to communicate with other programmers in specific terms that are ultimately executable.</p>
<p>The first interpretation is technically more accurate. Or, more specifically, the worst kind of accurate.</p>
<p>I like to think of programming languages as languages because, outside of trivial programs, above all else they enable programmers to communicate with one another when it comes to resolving a problem or completing a particular task, while incidentally producing code that is also understood by computers via “translators” (e.g., compilers and interpreters).</p>
<p>There are plenty of benefits that can be derived from thinking about programming in terms of the second interpretation.</p>
<p>When you view programming in this light, you start considering the value of comments expressing the “why” and code expressing the “how”. Tests become a way to communicate to a fellow programmer <a id="fnref:1" class="footnote" title="see footnote" href="#fn:1">[1]</a> that a change to the codebase has violated a given requirement. Above all, writing idiomatic code becomes important.</p>
<p>Remember the Google Dictionary definition. “The system of communication of a particular community”. It is in fact the community, for better or for worse, that sets the guidelines and de facto style of a particular programming language.</p>
<p>Since we are operating in a system of communication, programming is a bit like driving: predictability is important. That’s why in the Ruby community we have the <a href="https://en.wikipedia.org/wiki/Principle_of_least_astonishment">principle of least surprise</a> <a id="fnref:2" class="footnote" title="see footnote" href="#fn:2">[2]</a> and in the Python community one finds the “There should be one – and preferably only one – obvious way to do it” mantra. <a id="fnref:3" class="footnote" title="see footnote" href="#fn:3">[3]</a></p>
<p>When you think of programming languages as a series of conventions adopted by a community, and incidentally understood by the computer, you avoid recklessly monkey patching classes just because you can. You know that doing so leads to unexpected results and miscommunications with other programmers.</p>
<p>You also avoid features which are technically legal in the language, but rare and confusing to fellow experienced developers in that particular language. For an example of this, take a look a the <a href="https://nithinbekal.com/posts/ruby-flip-flop/">Flip-Flop</a> operator in Ruby (a reminiscence of its Perl heritage). Technically legal Ruby, even useful at times, however you shouldn’t use it because only a handful of fellow Rubyists will understand what you’re doing. <a id="fnref:4" class="footnote" title="see footnote" href="#fn:4">[4]</a> Worse yet, it will be hard to Google for an answer unless you are familiar with its name already.</p>
<p>When you’re first picking up a human language, you learn the meaning of common words. Then you use simple sentences that you memorize from books, people around you, songs, movies, and TV shows. Then you try to mimic the idioms you see used by mother tongue speakers. Often you won’t get them right at first, resulting in comical variations that are close, but not quite right, to those of native speakers.</p>
<p>When it comes to programming languages things really aren’t all that different. That’s why it’s critically important to read other people’s code, write code and receive feedback in code reviews, do peer programming, take part in open source contribution, and engage in other forms of social interaction pertaining to code. Doing so is immensely important when it comes to truly mastering a programming language.</p>
<p>Another consequence of this emphasis on communication among programmers through a common, precise, language whose style, conventions, and idioms are defined by the community is that you should choose your communities carefully. What are the community’s priorities? If there is no love for beautiful, clear, elegant, easy to understand code, tread very carefully. <a id="fnref:5" class="footnote" title="see footnote" href="#fn:5">[5]</a></p>
<p>As someone who had to learn English as an adult, pretty much from scratch, I can tell you that I find many parallels between the experience of learning a new language and that of a new programming language.</p>
<p>Even if the two are not a perfect match &#8211; and seeing a programming language as a human language is an imperfect metaphor &#8211; I feel that thinking of it in these terms has allowed me to quickly acquire key skills in the programming languages that I needed or wanted to learn.</p>
<div class="footnotes">
<hr />
<ol>
<li id="fn:1">At times, that other programmer is just your future self. <a class="reversefootnote" title="return to article" href="#fnref:1">&#8593;</a></li>
<li id="fn:2">Well, at least that doesn’t surprise Ruby’s creator, <a href="https://en.wikipedia.org/wiki/Yukihiro_Matsumoto">Matz</a>. <a class="reversefootnote" title="return to article" href="#fnref:2">&#8593;</a></li>
<li id="fn:3">Run <code>import this</code> in your iPython shell. What, you’re not using iPython? Stop reading. Go <a href="https://ipython.org/">install it</a>. <a class="reversefootnote" title="return to article" href="#fnref:3">&#8593;</a></li>
<li id="fn:4">Idiomatic code can be hard to understand by inexperienced programmers. And that’s fine, as long as reasonably experienced developers can parse its meaning. If nine out of ten programmers in your own community are unable to understand what you are doing, you are equivalent to someone who intentionally uses archaic words in conversation. You end up sounding <em>grandiloquent</em> for no good reason. <a class="reversefootnote" title="return to article" href="#fnref:4">&#8593;</a></li>
<li id="fn:5">At the risk of getting backlash for these remarks, the PHP community comes to mind. Or even the JavaScript community prior to jQuery and Node.js. There were excellent PHP and JavaScript developers back in the day of course, but the community as a whole had a tendency to hack things together, as long as it worked. Somehow. <a class="reversefootnote" title="return to article" href="#fnref:5">&#8593;</a></li>
</ol>
</div>
<p>The post <a href="https://programmingzen.com/programming-languages-as-languages/">On Programming Languages as Languages</a> appeared first on <a href="https://programmingzen.com">Programming Zen</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://programmingzen.com/programming-languages-as-languages/feed/</wfw:commentRss>
			<slash:comments>12</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1571</post-id>	</item>
		<item>
		<title>Review of the screencast series The Ruby Object Model and Metaprogramming (episodes 1-3)</title>
		<link>https://programmingzen.com/review-of-the-ruby-object-model-and-metaprogramming/</link>
					<comments>https://programmingzen.com/review-of-the-ruby-object-model-and-metaprogramming/#comments</comments>
		
		<dc:creator><![CDATA[Antonio Cangiano]]></dc:creator>
		<pubDate>Thu, 12 Jun 2008 04:08:09 +0000</pubDate>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Reviews]]></category>
		<category><![CDATA[metaprogramming]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[videos]]></category>
		<guid isPermaLink="false">http://antoniocangiano.com/?p=190</guid>

					<description><![CDATA[<p>Even if you&#x2019;re new to the Ruby community, you are unlikely not to have heard about the Pragmatic Programmers, who are well reputed for publishing great programming books. You may not have noticed that lately though, they&#x2019;ve also been releasing several series of screencasts. Each episode lasts about half an hour and sells for a mere $5. This strategy will work well in their favor because screencasts are a great way to teach programming. So far they&#x2019;ve put out 5 series: Expression Engine, Core Animation, Erlang by Example, Everyday Active Record and, their latest entry, The Ruby Object Model and </p>
<p>The post <a href="https://programmingzen.com/review-of-the-ruby-object-model-and-metaprogramming/">Review of the screencast series The Ruby Object Model and Metaprogramming (episodes 1-3)</a> appeared first on <a href="https://programmingzen.com">Programming Zen</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Even if you&#8217;re new to the Ruby community, you are unlikely not to have heard about the Pragmatic Programmers, who are well reputed for publishing great programming books. You may not have noticed that lately though, they&#8217;ve also been releasing several series of screencasts.</p>
<p>Each episode lasts about half an hour and sells for a mere $5. This strategy will work well in their favor because screencasts are a great way to teach programming. So far they&#8217;ve put out <a href="https://www.pragprog.com/screencasts">5 series</a>: Expression Engine, Core Animation, Erlang by Example, Everyday Active Record and, their latest entry, <a href="https://www.pragprog.com/screencasts/v-dtrubyom/the-ruby-object-model-and-metaprogramming">The Ruby Object Model and Metaprogramming</a>.</p>
<p>If you are reading this blog, I&#8217;ll assume you&#8217;re mostly interested in the last two topics. I haven&#8217;t had a chance yet to watch the Active Record ones, so I can&#8217;t say much about them, other than that I have faith in their author, thanks to his magnificent work on the <a href="https://railscasts.com/">Railscasts</a>.</p>
<p>Today after work however, I spent about an hour and a half watching the first three available episodes of The Ruby Object Model and Metaprogramming. This is a brief review of my thoughts on them. In short: they&#8217;re fantastic. But let me provide you with a bit more of a in-depth analysis than that.</p>
<p>These screencasts shine for the simple reason that you feel as though you&#8217;re sitting right there, next to a master programmer like Dave Thomas, as he explains Ruby concepts in detail to you. Whenever you&#8217;re not very clear about a concept, you can go back and listen to the explanation as many times as you&#8217;d like. You can pause, experiment with irb, and then go back to the screencast. After watching the first episode, I though that the $5 price was a steal.</p>
<p>Currently the following three episodes are available:</p>
<ol>
<li>Objects and Classes (29 mins)</li>
<li>Sharing Behavior (39 mins)</li>
<li>Dynamic Code (31 mins)</li>
</ol>
<p>The first episode lays the groundwork for the series and introduces a useful diagram that enables you to easily visualize the Ruby object model correctly. Concepts like singleton methods and ghost classes are really well explained. The first episode also covers &#8216;self&#8217; and the concept of current class, which is often confusing to beginners.</p>
<p>The second episode explores what constitutes good object oriented design, as well as the usage of prototype programming, inheritance (and how not to abuse it), and finally an excellent explanation of modules and mixins. If you are a beginner you may not know the difference between including and extending a module, or the true power of mixins. Fear not, the last part of second episode really covers those subject well.</p>
<p>The third episode starts by defining blocks and their usage, including the difference between lamdba and Proc.new. It then moves on to explore the concept of bindings capturing the execution context, and the importance of closures in metaprogramming. The last 12 minutes or so are spent dealing with the subject of dynamically defining methods, which is at the heart of metaprogramming, and the video includes a nice example of how to create your own version of attr_accessor by defining, in a module, a method that dynamically defines getter and setter methods.</p>
<p>I&#8217;d say that aside from the feeling that I was enjoying a &#8220;private lesson&#8221;, what I liked the most was the coding style recommendations about when to employ a given concept and when to opt for something else. The examples were clear and easy to follow as well.</p>
<p>I can&#8217;t recommend this series highly enough to any Ruby programmer with a basic grasp of the language. I feel that intermediate developers will get the most out of these videos, but they&#8217;ll also definitely be very beneficial for beginners. Real experts shouldn&#8217;t find any alien concepts, at least in the first three episodes; I know I didn&#8217;t. Yet, they&#8217;ll appreciate, just like I did, the fresh slant when it comes to reviewing some of the illustrated concepts and examples. There will also be a few &#8220;ah-ah!&#8221; moments here and there, I guarantee you.</p>
<p>Five stars, and I&#8217;m certainly looking forward to future episodes.</p>
<p>The post <a href="https://programmingzen.com/review-of-the-ruby-object-model-and-metaprogramming/">Review of the screencast series The Ruby Object Model and Metaprogramming (episodes 1-3)</a> appeared first on <a href="https://programmingzen.com">Programming Zen</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://programmingzen.com/review-of-the-ruby-object-model-and-metaprogramming/feed/</wfw:commentRss>
			<slash:comments>5</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">190</post-id>	</item>
	</channel>
</rss>
