<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

  <title><![CDATA[Julian Simioni]]></title>
  <link href="https://juliansimioni.com/atom.xml" rel="self"/>
  <link href="https://juliansimioni.com/"/>
  <updated>2021-01-28T19:26:57+00:00</updated>
  <id>https://juliansimioni.com/</id>
  <author>
    <name><![CDATA[Julian Simioni]]></name>
    
  </author>
  <generator uri="http://octopress.org/">Octopress</generator>

  
  <entry>
    <title type="html"><![CDATA[2017 Books]]></title>
    <link href="https://juliansimioni.com/blog/2017-books/"/>
    <updated>2018-01-10T17:55:04+00:00</updated>
    <id>https://juliansimioni.com/blog/2017-books</id>
    <content type="html"><![CDATA[<p>It&rsquo;s time for another year of book reviews! This was not the year where I read the most, but those I
got to I really enjoyed.</p>

<h2>The Brilliant Disaster by Jim Rasenberger</h2>

<p>This is an incredible story that is so much more complex than is capable of being understood just
from popular knowledge about the famous events involved.</p>

<p>It&rsquo;s a timely book to read and will continue to be relevant as we continue to discover more and more
negative effects of the USA&rsquo;s involvement in other countries affairs.</p>

<h2>Chasing Space by Leland Melvin</h2>

<p>The path astronauts take to space is not always a direct route, and no one can speak to that truth
more than Leland Melvin, the only professional football player to also fly in space and visit the
International Space Station.</p>

<p>This book is a must-read for those interested in the space program, but not for the reasons one
might expect. Our nation and world needs, more than ever, to hear stories about the challenges
people of color and other minorities face to get to the places white people have been from the
beginning. Leland Melvin tells that story well and we should listen.</p>

<h2>Kubernetes: Up and Running by Kelsey Hightower, Brendan Burns, and Joe Beda</h2>

<p>Kubernetes has been one of the hottest technology topics of the year. The authors of this book have
been around the scene since the very beginning. This is a short book, perfect for ensuring
you know the core concepts of, and have a basic familiarity with, Kubernetes.</p>

<p>There is obviously much more to learn, but having confidence in your base knowledge is well worth
the time. In fact, I am now purchasing other books in the O&#8217;Reilly &ldquo;Up and Running&rdquo; series expecting
to see similar benefit.</p>

<h2>Cloud Native Infrastructure by Justin Garrison and Kris Nova</h2>

<p>The technology world is constantly changing and those of us who deal with software infrastructure
would do well to read this book. Unlike <em>Kubernetes: Up and Running</em>, you won&rsquo;t run to the command
line and immediately put to use the knowledge from this book. However, after reading this book you
will think about the changing trends of this industry with a bit more clarity.</p>

<p>I find myself frequently thinking back to nuggets of information from this book when weighing
decisions for new software project architecture, and likely will for some time.</p>

<h2>A Room of One&rsquo;s Own by Virginia Wolf</h2>

<p>If you adjust the currencies for the present day (£500/yr won&rsquo;t really cut it anymore), you&rsquo;d be
hard pressed to find any part of this book that isn&rsquo;t just as relevant today as it was almost 90
years ago. Like the stories from people of color, we need to listen to stories from women just as
much today as in 1929.</p>

<p>Wolf&rsquo;s writing style is wonderful: elegant, flowing, deep, and complex. I&rsquo;d like to think I
recognize elements of it in the writing of talented women I read today. It would makes sense that
this is true.</p>

<h2>The Manager&rsquo;s Path by Camille Fournier</h2>

<p>This is one of those books where you are actually reading about yourself. Hopefully, it&rsquo;s in the
incredibly useful descriptions of how to be a good employee/manager/CTO/etc that are in this book.</p>

<p>Most likely, the toughest but most useful parts of this book will be when you see a bit of yourself
in the &ldquo;Good Manager/Bad Manager&rdquo; sections that detail various levels of unhelpful behavior that all
sorts of team members can exhibit. It was definitely true for me, but that&rsquo;s part of what makes this
book so helpful.</p>

<h2>The Secret Race by Tyler Hamilton and Daniel Coyle</h2>

<p>We all knew professional cycling was full of performance enhancing drugs. But there was always a
shroud of mystery and just enough unknown to ignore it or make it not worth thinking about.
Obviously that&rsquo;s no longer true. Tyler Hamilton does an incredible job with a first hand story that
gives all the details of what being a top level pro cyclist was REALLY like.</p>

<p>It may not really make pro cycling appealing, but if you ever thought about living in Girona, Spain,
you will think about it even more after this book.</p>

<h2>Lance Armstrong&rsquo;s War by Daniel Coyle</h2>

<p>I read this book many years ago (before I was writing about the books I read). Back then, I treated
it like a bible. What you wanted to aspire to, how you should act, if you wanted to become a true
cyclist.</p>

<p>I don&rsquo;t feel that way anymore. The second time reading this book, I read it as a companion to <em>The
Secret Race</em>. When Coyle wrote this book, he could only hint at the things he knew about the real
state of professional cycling. And he didn&rsquo;t know nearly as much as we all do now.</p>

<p>Reading these two books is a great combo. One is direct with every detail. <em>Lance Armstrong&rsquo;s War</em>
is best if you read behind the lines. Most of the wild speculation about how corrupted professional
cycling <em>might</em> be turned out to be true.</p>

<h2>Long Walk to Freedom by Nelson Mandela</h2>

<p>This year, I didn&rsquo;t write my reading list in the order I completed books, because I had to save this
one for last. Without a doubt, this is the best book I have ever read.</p>

<p>Nelson Mandela tells a story with a unique blend of clarity, emotion, humor, and care. And the story he
has to tell is one of the most important of the 20th century.</p>

<p>Throughout this book I was brought to laughter, and to tears. I felt hope and despair. I was along
for the entire journey with Mandela and 40 million South Africans.</p>

<p>As an added bonus, I read much of this book while in Cape Town, South Africa. It is not lost on me
that while I was reading, I was smelling the exact same ocean air that Mandela was smelling when he
wrote much of it from a few miles away on Robben Island.</p>

<p>After I was done, I spent hours reading other accounts. A huge treasure we have today is that there
are countless videos of Mandela available instantly on the internet. Some of them cover his speeches
or other events he wrote about in the book. I can confirm that his incredible wit, charm, and
unstoppable vision is as present when he is speaking live as when he has endless hours in his cell
to write down his thoughts.</p>

<p>I can&rsquo;t recommend enough a trip to South Africa and a read of this book. But if the cost of flying
almost to one end of this Earth is enough, at least read the book.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Troubleshooting GPG git commit signing]]></title>
    <link href="https://juliansimioni.com/blog/troubleshooting-gpg-git-commit-signing/"/>
    <updated>2017-11-26T15:47:27-05:00</updated>
    <id>https://juliansimioni.com/blog/troubleshooting-gpg-git-commit-signing</id>
    <content type="html"><![CDATA[<p>As part of setting up a new laptop recently, I was setting up <a href="https://git-scm.com/book/en/v2/Git-Tools-Signing-Your-Work">git commit signing</a>.</p>

<p>Despite having most of my <a href="https://github.com/orangejulius/dotfiles">configs</a> in a git repository or
otherwise tracked, I ran into a problem with setting this up.</p>

<p>Here&rsquo;s the error:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class='console'><span class='line'><span class="gp">$</span> git commit
</span><span class='line'><span class="go">error: gpg failed to sign the data</span>
</span><span class='line'><span class="go">fatal: failed to write commit object</span>
</span></code></pre></td></tr></table></div></figure>


<p>And the answer (for me):</p>

<p>Make sure the <code>user.signingkey</code> option in your <code>.gitconfig</code> is in the correct format! This is very
silly, but there are some easy ways to get it wrong. First, some correct examples.</p>

<h4>Standard long key format (recommended)</h4>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
</pre></td><td class='code'><pre><code class='ini'><span class='line'><span class="k">[user]</span>
</span><span class='line'>    <span class="na">name</span> <span class="o">=</span> <span class="s">Julian Simioni</span>
</span><span class='line'><span class="s">    email = julian@simioni.org</span>
</span><span class='line'><span class="s">    signingkey = 0x4CEEB1E5A7FD15E1</span>
</span></code></pre></td></tr></table></div></figure>


<p>That&rsquo;s <code>0x</code> followed by the last 16 characters of your key id. At least as of <code>gnupg 2.2.0</code> its the
standard output of a command like <code>gpg --list-secret-keys</code></p>

<h4>Long key format without the hexidecimal prefix</h4>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class='ini'><span class='line'><span class="k">[user]</span>
</span><span class='line'>    <span class="c1"># ...</span>
</span><span class='line'>    <span class="na">signingkey</span> <span class="o">=</span> <span class="s">4CEEB1E5A7FD15E1</span>
</span></code></pre></td></tr></table></div></figure>


<p>Still 16 characters, but without the prefix clarifying that the value is written in hexidecimal.</p>

<h4>Short key format (works, but not recommended)</h4>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class='ini'><span class='line'><span class="k">[user]</span>
</span><span class='line'>    <span class="c1"># ...</span>
</span><span class='line'>    <span class="na">signingkey</span> <span class="o">=</span> <span class="s">A7FD15E1</span>
</span></code></pre></td></tr></table></div></figure>


<p>This is the &ldquo;short&rdquo; format, consisting of only 8 characters. It works too, and was much more
standard in the past. However its not recommended as its now <a href="https://evil32.com/">far too easy</a> to
generate keys that have the same final 8 characters.</p>

<h4>DOESN&rsquo;T WORK: other key lengths</h4>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class='ini'><span class='line'><span class="k">[user]</span>
</span><span class='line'>    <span class="c1"># ...</span>
</span><span class='line'>    <span class="na">signingkey</span> <span class="o">=</span> <span class="s">CEEB1E5A7FD15E1</span>
</span></code></pre></td></tr></table></div></figure>


<p>You might be assuming, like I did, that GPG and git would be smart enough to allow you to use any
suffix of your key, much like git allows you to use any unique prefix of a git commit hash. That is
<em>not</em> the case. I suppose it makes sense. Oh well.</p>

<h2>Other useful debugging steps</h2>

<p>While in my case the issue with my commit signing was simple user error, I did go through quite a
few other debugging steps, and they were helpful in figuring out where the error was not! Here they
are in case they are useful to me again later (quite likely), or others.</p>

<p>Many of these came from <a href="https://stackoverflow.com/questions/39494631/gpg-failed-to-sign-the-data-fatal-failed-to-write-commit-object-git-2-10-0/42265848">this helpful Stackoverflow thread</a>.</p>

<h3>Ensure basic encryption works</h3>

<p>A simple way to test <code>gpg</code> and your secret key itself is to issue a command like the following:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="nb">echo</span> <span class="s2">&quot;test&quot;</span> <span class="p">|</span> gpg --clearsign
</span></code></pre></td></tr></table></div></figure>


<p>This will send a small bit of text (&ldquo;test&rdquo;) to gpg, and have it print out the same text, but with a
plaintext signature attached. If it works, then you know quite a few things are working: <code>gpg</code>
itself, your secret key, whatever method you are using to enter the passkey to your key (if you have
one, which you should!), etc.</p>

<h3>GPG Agent settings, or lack thereof</h3>

<p>GPG internally uses an &ldquo;agent&rdquo; program. Basically, whenever you run <code>gpg</code>, it launches a process in
the background that will stick around. That process is used to remember your passphrase temporarily,
for convenience, and probably other things.</p>

<p>In the past, ensuring the <code>gpg</code> command you run on the command line can communicate with this agent
has been challenging. If you&rsquo;ve ever seen instructions regarding adding various <code>GPG_AGENT_INFO</code>
environment variables, its an attempt to properly set up this communication channel.</p>

<p>The good news is that as of <code>GnuPG</code> version 2.1.0, <strong>none of this is needed</strong>. There is now a
&ldquo;standard&rdquo; method of connecting to the agent and everything is supposed to just work. Compare the
instructions in the documentation for <a href="https://gnupg.org/documentation/manuals/gnupg-2.0/Invoking-GPG_002dAGENT.html">version 2.0</a>
and the <a href="https://gnupg.org/documentation/manuals/gnupg/Invoking-GPG_002dAGENT.html">latest version</a> to see
what I mean.</p>

<h3>GPG_TTY environment variable</h3>

<p>This variable <em>is</em> important to set up. It will help GPG know which terminal it is running on, so
that the prompt to enter your key passphrase is shown in the correct place. Again, from the GnuPG
documentation, this will do the trick:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="nv">GPG_TTY</span><span class="o">=</span><span class="k">$(</span>tty<span class="k">)</span>
</span><span class='line'><span class="nb">export </span>GPG_TTY
</span></code></pre></td></tr></table></div></figure>


<h3>Handling local terminal and SSH connections gracefully</h3>

<p>There&rsquo;s nothing worse than not being able to use <code>gpg</code> because you SSHed into your computer, and
when you ran <code>gpg</code>, it popped up a dialog box to enter your passphrase on the computer display
itself, rather than in your SSH session.</p>

<p>Fortunately, its easy to tell <code>pinentry</code>, the underlying program responsible for managing passphrase
entry, to do the right thing during SSH sessions.</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="k">if</span> <span class="o">[[</span> -n <span class="s2">&quot;$SSH_CONNECTION&quot;</span> <span class="o">]]</span><span class="p">;</span> <span class="k">then</span>
</span><span class='line'>    <span class="nb">export </span><span class="nv">PINENTRY_USER_DATA</span><span class="o">=</span><span class="s2">&quot;USE_CURSES=1&quot;</span>
</span><span class='line'><span class="k">fi</span>
</span></code></pre></td></tr></table></div></figure>


<p>This comes from the <a href="https://wiki.gentoo.org/wiki/GnuPG#Changing_pinentry_for_SSH_logins">GnuPG Gentoo Wiki article</a>.</p>

<p>Pretty fancy.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[2015 Books]]></title>
    <link href="https://juliansimioni.com/blog/2015-books/"/>
    <updated>2016-02-22T15:18:03-05:00</updated>
    <id>https://juliansimioni.com/blog/2015-books</id>
    <content type="html"><![CDATA[<p>Like <a href="https://juliansimioni.com/blog/2014-books">last year</a>, I&rsquo;ve been up to some reading this past year. Here&rsquo;s the list
along with some thoughts.</p>

<h2>Moby Dick by Herman Melville</h2>

<p>I read most of this book in 2014, but didn&rsquo;t quite finish it. There&rsquo;s no doubt Melville has an
unparalleled skill with the English language. Strangely, I found all the characters, especially
Ahab, comical, rather than frightening. Perhaps Ricardo Montalban&rsquo;s performance in <em>The Wrath of
Khan</em> has set the bar too high. A great read both as fiction and as a historical depiction of the
times.</p>

<h2>Talking with Tech Leads by Patrick Kua</h2>

<p>Although not the case for a few years after college, these days I find myself more fascinated and
interested in the challenges of growing and organizing people, rather than software or other
technology. This book, with its many short investigations into the delicate balance the two inherent
in the tech lead role, is a helpful resource. Each essay has a different author and so covers a wide
range of viewpoints and situations. Far from being a deficit, the conclusion of this book &ndash; that
the tech lead role is itself nearly undefinable and that there are no perfect solutions to
efficiently lead groups of people working with software &ndash; is actually a valuable lesson.</p>

<h2>career.fork()</h2>

<p>Having just moved to Berlin and looking for work at the time, I felt compelled to investigate
contracting and freelancing options, as many in Berlin do. Another short read, <em>career.fork()</em>
touches on, but doesn&rsquo;t attempt to completely cover, all the challenges one will face working for
themselves. Like <em>Tech Leads</em>, this brevity is useful, as there aren&rsquo;t any simple solutions to most
of them. This admission is something I respect about both of these books, which was absent in
another, <em>Managing the Unmanagable</em>, that I couldn&rsquo;t finish years ago: it&rsquo;s author seemed to have
claimed the problem of working with developers solved.</p>

<h2>Patterns of Enterprise Application Architecture by Martin Fowler</h2>

<p>A classic architecture book from the 90s, today <em>PEAA</em> is not likely to be as practically useful as
it once was, but is now almost a history book. The proliferation of powerful open source software
frameworks means few people will need to use the techniques in this book. But it&rsquo;s place as a
foundational tome of knowledge on which many of those tools are based is obvious. The first
architecture pattern it describes is familiar to anyone from the Rails world: active record.</p>

<h2>Flatland by Edwin Abbott Abbott</h2>

<p>A silly, short, enjoyable story that is as much a window into its times as it is a dive into
mathematics and abstract thought.</p>

<h2>The Little Tea Book by George Washington Hood</h2>

<p>I don&rsquo;t remember anything about this book.</p>

<h2>Working Effectively with Unit Tests by Jay Fields</h2>

<p>A great and focused book on unit tests. I find myself using and sharing ideas from this book all the
time, and definitely recommend more developers read it.</p>

<h2>From Eternity to Here by Sean Carroll</h2>

<p>I bought this book perhaps 5 years ago, and nearly read through it. I&rsquo;m glad to have decided to
re-read and finish it. Mr. Carroll is a fantastic writer and scientists. This book covers issues
deep enough to fill philosophy, as well as science texts, but is still easy to read.</p>

<h2>The Orphan Master&rsquo;s Son by Adam Johnson</h2>

<p>A rather surreal fiction based in North Korea, I enjoyed and disliked this book for its ridiculously
outlandish plot and characters. It was frustratingly unclear how much of this books ideas are based
in actual facts about North Korea, and which were invented by the author, but none the less it has
some fantastic sections that make it worthwhile.</p>

<h2><strong>The Girl With the Dragon Tattoo by Steig Larsson</strong></h2>

<p>In the past I&rsquo;ve claimed to prefer non-fiction books to fiction, arguing history gives us enough
fascinating stories that there is no need to invent our own. However after <em>The Girl With the Dragon
Tattoo</em> I can no longer defend that position.</p>

<p>Fantastic characters, deep plot with incredible mystery, and scenes that make the suspense of any
horror film feel mild make this one of the best books I&rsquo;ve ever read. While it uses the real
political and historical climate in Sweden to make the story even more riveting, it&rsquo;s immediately
clear where the fiction begins, unlike <em>The Orphan Master&rsquo;s Son</em>.</p>

<p>My only complaint about this book is a practical one: at the time I read it, I had been travelling
between the US and Europe frequently, and used reading as a way to get my sleep schedule back on
track. Mr. Larson&rsquo;s writing ruined those plans: unlike every other book, normally unconquerable
exhaustion after international flights couldn&rsquo;t stop me from staying up all night to finish it.</p>

<h2>102 Minutes by Jim Dwyer</h2>

<p>It would probably be insensitive to say I enjoyed this book, but whatever I felt, I couldn&rsquo;t put
this book down and finished in only a few days. Supported by what must have been a superhuman
quantity of research, <em>102 Minutes</em> covers every human emotion in detailing the heroism and tragedy
of September 11th.</p>

<p>Refreshingly, <em>102 Minutes</em> leaves no room for conspiracy theories, vilification of Muslims or
Islam, or irrational fear of terrorists. In fact, it might be argued the book blames building codes
more than anything for the tragedy: in a break from the minute-by-minute account of the morning of
September 11th, the book details how building codes of the time were written to fit the design of
the twin towers, rather than vice versa, and allowed for a construction that enabled the horrific
collapse of the buildings.</p>

<h2><strong>The Island at the Center of the World by Russel Shorto</strong></h2>

<p>Second in my reading list after moving to New York City, this was a wonderful history on par with
any other I&rsquo;ve read. Despite a setting over 300 years in the past, I see the influence of the
characters and events in this book everywhere I go in New York, which brings me great joy.</p>

<h2>The Girl Who Played With Fire by Steig Larsson</h2>

<p>The sequel to <em>The Girl With the Dragon Tattoo</em> contains the same spectacular writing and
characters, so it&rsquo;s still immensely enjoyable, but it&rsquo;s more complex plot doesn&rsquo;t surpass the first.</p>

<h2>Aviation Weather by the FAA</h2>

<p>Long ago, the FAA distributed information on weather phenomena and the technology used to predict
and measure it together. It turns out weather itself doesn&rsquo;t change, but our weather related tools
sure do, so the topics were split into two books in the 70s. This book covers the former topic, and
it hasn&rsquo;t seen a republishing since 1975. All the information it contains is useful, but it could
use with a bit of modernization still, if even just to show higher quality pictures of different
types of clouds.</p>

<h2>Starting Strength by Mark Rippetoe</h2>

<p>A great and complete book on weight training. Rippetoe has a character that is unforgettable if not
always PC or likable, but he seems to for the most part really know what he&rsquo;s talking about. Why
does he love milk so much though?</p>

<h2>The Girl who Played With Fire by Steig Larsson</h2>

<p>Following up on what is in some respects a cliffhanger ending, it&rsquo;s inevitable that you will read
this book to conclusion once you start on the second book in the trilogy. Despite Larsson&rsquo;s
continued excellent writing, I was happy to be done with this book: the story had gotten rather
boring. I haven&rsquo;t yet decided if I&rsquo;ll read the fourth book.</p>

<h2><strong>The Martian by Andy Weir</strong></h2>

<p>Bookless before a short flight, I bought <em>The Martian</em> at an airport bookstore and finished it less
than 12 hours later. I had already seen the film but it didn&rsquo;t reduce my enjoyment of this funny and
scientifically accurate story.</p>

<p>The movie and book are both excellent, but differ especially in theme. I&rsquo;d love to discuss the
details more with anyone who has enjoyed both.</p>

<p>Notably, I find that my consumption of potatoes has considerably increased since reading this book.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[The Seven Essentials of International Travel]]></title>
    <link href="https://juliansimioni.com/blog/the-seven-essentials-of-international-travel/"/>
    <updated>2015-05-06T22:35:21+02:00</updated>
    <id>https://juliansimioni.com/blog/the-seven-essentials-of-international-travel</id>
    <content type="html"><![CDATA[<p>I love travelling, so I&rsquo;m no stranger to occasional long distance travel. But,
since I moved to Berlin last November, I&rsquo;ve reached another level: In 6 months
I&rsquo;ve crossed an ocean 7 times. I used to be a mess after every flight, but at
this point I think I&rsquo;ve got most of it figured out.</p>

<p>Other than a few simple rules, like drinking lots of water, most of what has
helped has been a few simple items.</p>

<p>I&rsquo;ve got all of them with me right now, since I&rsquo;m writing this at the end of a
trip from San Diego to Berlin, so I want to make a list while it&rsquo;s easiest.
Every traveller should have most or all of these at the ready for all their
trips.</p>

<h2>Eye Mask</h2>

<p>This is one of the cheapest, but probably the most important single item for
travelling.  Without sleeping on a long flight, it&rsquo;s simply not possible to be
ready to go quickly once you arrive, and above all else your body uses light to
decide when to sleep.</p>

<p>I used to try to put a blanket over my head, blocking out only some of the light
but nearly drowning me in warm air, and I still see people do this. A good eye
mask is still cheap, but blocks out more light than any blanket, and more than a
cheap eye mask like the one you might be lucky to get on some airlines.
<img src="https://juliansimioni.com/images/travel/eyemask.jpg" alt="Eye Mask" /></p>

<h2>Noise Cancelling Headphones</h2>

<p>Even the newest airplanes are loud. The engines are loud, the passengers are
loud, the in-flight announcements are loud. A few minutes of this is ok, but
after ten hours, loud noises cause fatigue as much as anything else.</p>

<p>Fortunately, in the last few years the amazing technology of noise cancelling
headphones has emerged. These use advanced signal processing to actively reduce
the loudness of ambient sound around you. They work best with consistent
background noise, so they&rsquo;re perfect for the endless drone of the engines.</p>

<p>They cost a bit more than even a good pair of over the ear headphones (which are
good at insulating from sound, but don&rsquo;t come close to active noise
cancellation), but they&rsquo;re worth it since you can use them every day.
<img src="https://juliansimioni.com/images/travel/headphones.jpg" alt="Headphones" /></p>

<h2>Earplugs</h2>

<p>Before noise cancelling headphones, earplugs were our best defense against
noise, but they aren&rsquo;t useless today. If nothing else, being able to switch
between earplugs and headphones keeps either from getting too uncomfortable.</p>

<p>On the loudest flights, using both may be what&rsquo;s required to get some peace.
<img src="https://juliansimioni.com/images/travel/earplugs.jpg" alt="Earplugs" /></p>

<h2>Neck Pillow</h2>

<p>For those of us who don&rsquo;t get to fly business class, there aren&rsquo;t many positions
that really let us rest on a plane. My neck and my back are what get tired and
uncomfortable the most. A neck pillow can at least help a little bit.</p>

<p>I have to admit I still haven&rsquo;t found a really good one. All the ones I&rsquo;ve
tried, including my own, just don&rsquo;t feel firm enough. I try any new ones I come
across, and would be willing to pay for a good one, but so far the one I got at
Target for $15 is the best.</p>

<h2>Spare Contacts and Glasses</h2>

<p>I can&rsquo;t sleep in my contacts. My eyes quickly dry out, my contacts stick to my
eyes, and its all no good. Fortunately I wear daily lenses, so throwing away a
pair is no big deal. It took me way too long to realize it, but bringing spare
contacts on the plane, in an easy to reach place, is a super simple way to make
flying a lot more comfortable. Glasses help too if I&rsquo;m not sure I want to put
another pair of contacts in just yet.
<img src="https://juliansimioni.com/images/travel/contacts.jpg" alt="Contacts and Glasses" /></p>

<h2>Advil</h2>

<p>I get headaches all the time. I get the worst headaches when I&rsquo;m dehydrated.
It&rsquo;s really easy to get dehydrated on a plane. I almost always get really bad
headaches when flying. So if I don&rsquo;t bring something to help with my headaches,
I&rsquo;m pretty much miserable when flying.</p>

<p>I first started bringing Advil, but in my carry on bag that was not easy to get
to during most of the flight. Now I just put some right in my small bag that&rsquo;s
always with me. Whenever I feel the need I can find some water and take some
Advil. This mostly cures my headaches and makes flying so much better.
<img src="https://juliansimioni.com/images/travel/advil.jpg" alt="Advil" /></p>

<h2>Food</h2>

<p>I really can&rsquo;t stand airline food. It&rsquo;s not that healthy, not at all fresh, and
tastes terrible. These days I generally plan on bringing enough food to keep
myself alive for an entire day or so. That way there&rsquo;s no chances of getting
hungry and not being able to do anything about it, or eating bad food and
feeling terrible after.</p>

<p>My go to flying food is simple stuff: bagels or other bread, some whole fruit
(bananas are perfect because they&rsquo;re already well packaged), and some sliced
meats. Eating something fancy may seem nice, but usually I&rsquo;m too tired to really
enjoy eating anyway, and getting sick on a plane is no fun at all.
<img src="https://juliansimioni.com/images/travel/food.jpg" alt="Food" /></p>

<p>It&rsquo;s taken me a few years to really settle on all these essentials, but now that
I have I can generally handle anything that comes my way on even the longest
flights. Now I just need to work on conquering the jet-lag that comes after.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[HTTPS on Nginx: From Zero to A+ (Part 2) - Configuration, Ciphersuites, and Performance]]></title>
    <link href="https://juliansimioni.com/blog/https-on-nginx-from-zero-to-a-plus-part-2-configuration-ciphersuites-and-performance/"/>
    <updated>2015-02-06T17:37:04+01:00</updated>
    <id>https://juliansimioni.com/blog/https-on-nginx-from-zero-to-a-plus-part-2-configuration-ciphersuites-and-performance</id>
    <content type="html"><![CDATA[<p><em>On the internet today, <a href="https://www.eff.org/encrypt-the-web">all our web sites</a>
need a strong, secure HTTPS setup, even the most basic static sites. This is
part two of a series on how to set up Nginx securely.</em></p>

<p>When we left off after <a href="https://juliansimioni.com/blog/https-on-nginx-from-zero-to-a-plus-part-1/">part 1</a>,
we had a server with a valid, signed certificate, but it was using the default
Nginx configuration. This configuration is far from optimal.</p>

<p>At the end of this post we&rsquo;ll have a secure HTTPS configuration on
Nginx that scores an A+ rating on the SSL Labs report. We&rsquo;ll even do a few extra
tweaks that improve performance and user experience.
<img src="https://juliansimioni.com/images/nginx-https/website-aplus.png" alt="A+ score on juliansimioni.com" /></p>

<p>In addition to the descriptions and code snippets here, I&rsquo;ve compiled a
ready to go <a href="https://github.com/orangejulius/https-on-nginx/blob/master/ssl.conf">SSL configuration file</a>
for Nginx, a nearly ready to go <a href="https://github.com/orangejulius/https-on-nginx/blob/master/example-site.conf">example site configuration file</a>,
and a <a href="https://github.com/orangejulius/https-on-nginx/blob/master/resources.md">complete list</a>
of all the sources I used while researching for these articles, and posted them
for anyone to use freely on Github.</p>

<!-- more -->


<h2>Disable SSLv3</h2>

<p>By default Nginx still enables SSLv3<sup><a href="#7d2f:fn:1" class="footnote" id="7d2f:fn-back:1">1</a></sup>, which has been vulnerable to the
<a href="https://community.qualys.com/blogs/securitylabs/2014/10/15/ssl-3-is-dead-killed-by-the-poodle-attack">POODLE</a> attack
since October 2014. The <a href="http://en.wikipedia.org/wiki/Transport_Layer_Security#Web_browsers">only browser</a>
that doesn&rsquo;t support newer protocols out of the box is IE6, and even it can be
configured to use TLSv1, so there&rsquo;s no reason to support SSLv3 anymore.</p>

<p>SSL Labs rightly limits your server&rsquo;s SSL score to C if SSLv3 is enabled, so
this is the first thing to change.</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class='nginx'><span class='line'><span class="c1"># support only known-secure cryptographic protocols</span>
</span><span class='line'><span class="c1"># SSLv3 is broken by POODLE as of October 2014</span>
</span><span class='line'><span class="k">ssl_protocols</span> <span class="s">TLSv1</span> <span class="s">TLSv1.1</span> <span class="s">TLSv1.2</span><span class="p">;</span>
</span></code></pre></td></tr></table></div></figure>


<h2>Send the Entire Certificate Chain</h2>

<p>Browsers use root certificates from Certificate Authorities to determine which
server certificates (such as the one from your website) should be trusted, but
there&rsquo;s almost always an intermediate certificate. To be sure your server&rsquo;s
certificate is valid, browsers need to know about this intermediate certificate.</p>

<p>Of course, browsers can find and download these intermediate certificates, but
this slows down the process of connecting to your website, and makes the whole
process more complicated giving attackers more surface area to exploit.</p>

<figure>
  <img src="https://juliansimioni.com/images/nginx-https/incomplete-certificate-chain.png" alt="An Incomplete Certificate chain">
  <figcaption>An incomplete certificate chain</figcaption>
</figure>


<p>It&rsquo;s much better to simply configure Nginx to send this intermediate certificate
along when users first connect. In fact, your SSL score is capped at a B if you
don&rsquo;t.</p>

<p>Your Certificate Authority probably provided you with links to download your
intermediate certificate, so once you&rsquo;ve found it, put it somewhere safe on
your server, <del>and tell Nginx about it like this</del>, and then make a new file
that concatenates your certificate and the intermediate certificate together.
Then tell Nginx about that one like this<sup><a href="#7d2f:fn:2" class="footnote" id="7d2f:fn-back:2">2</a></sup>:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class='nginx'><span class='line'><span class="c1"># send intermediate certificate during new sessions</span>
</span><span class='line'><span class="k">ssl_trusted_certificate</span> <span class="s">/etc/nginx/ssl/startssl/sub.class1.server.ca.pem</span><span class="p">;</span>
</span></code></pre></td></tr></table></div></figure>


<h2>Ciphersuite Configuration</h2>

<p>The SSL/TLS protocols actually don&rsquo;t provide any encryption by themselves.
Instead, they simply allow a server and client to agree on and start
communicating via a channel that could have one of any number of
encryption schemes.</p>

<p>Your server and a client will use SSL/TLS to agree on a combination of four
things: key exchange algorithm (how to safely share encryption keys between the
server and client), authentication (to make sure only the intended
sender/recipient are communicating), encryption algorithm (actually encoding the
messages so no one else can read them), and message digest algorithm (to make
sure the message was not tampered with or corrupted).</p>

<p>There are many of each of these algorithms, all with varying features,
performance, cryptographic strength, and browser support. Many of the algorithms
have known weaknesses that make them unsuitable for use today. Using the latest
version of a browser is usually enough to protect an individual user but,
unfortunately, a lot of older browsers have insecure defaults.</p>

<p>The goal of cipher suite configuration is to ensure compatibility with as many
browsers as possible, without compromising security or, to a lesser
extent, performance.</p>

<p>This will be done by setting a configuration string that OpenSSL understands in
our Nginx configuration. To keep thing simple here&rsquo;s the relevant configuration
lines:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
</pre></td><td class='code'><pre><code class='nginx'><span class='line'><span class="c1"># make the server choose the best cipher instead of the browser</span>
</span><span class='line'><span class="c1"># Perfect Forward Secrecy(PFS) is frequently compromised without this</span>
</span><span class='line'><span class="k">ssl_prefer_server_ciphers</span> <span class="no">on</span><span class="p">;</span>
</span><span class='line'>
</span><span class='line'><span class="c1"># support only believed secure ciphersuites using the following priority:</span>
</span><span class='line'><span class="c1"># 1.) prefer PFS enabled ciphers</span>
</span><span class='line'><span class="c1"># 2.) prefer AES128 over AES256 for speed (AES128 has completely adequate security for now)</span>
</span><span class='line'><span class="c1"># 3.) Support DES3 for IE8 support</span>
</span><span class='line'><span class="c1">#</span>
</span><span class='line'><span class="c1"># disable the following ciphersuites completely</span>
</span><span class='line'><span class="c1"># 1.) null ciphers</span>
</span><span class='line'><span class="c1"># 2.) ciphers with low security</span>
</span><span class='line'><span class="c1"># 3.) fixed ECDH cipher (does not allow for PFS)</span>
</span><span class='line'><span class="c1"># 4.) known vulnerable cypers (MD5, RC4, etc)</span>
</span><span class='line'><span class="c1"># 5.) little-used ciphers (Camellia, Seed)</span>
</span><span class='line'><span class="k">ssl_ciphers</span> <span class="s">&#39;kEECDH+ECDSA+AES128</span> <span class="s">kEECDH+ECDSA+AES256</span> <span class="s">kEECDH+AES128</span> <span class="s">kEECDH+AES256</span> <span class="s">kEDH+AES128</span> <span class="s">kEDH+AES256</span> <span class="s">DES-CBC3-SHA</span> <span class="s">+SHA</span> <span class="s">!aNULL</span> <span class="s">!eNULL</span> <span class="s">!LOW</span> <span class="s">!kECDH</span> <span class="s">!DSS</span> <span class="s">!MD5</span> <span class="s">!EXP</span> <span class="s">!PSK</span> <span class="s">!SRP</span> <span class="s">!CAMELLIA</span> <span class="s">!SEED&#39;</span><span class="p">;</span>
</span></code></pre></td></tr></table></div></figure>


<p>Now I&rsquo;ll explain the rationale that went into crafting it.</p>

<h3>Make the server choose the ciphersuite</h3>

<p>Many browsers, especially old ones, will make poor ciphersuite choices on their
own. The first directive ensures your server will choose from the list of
ciphersuites supported by both the browser and server.</p>

<h3>Disable null and low security ciphersuites</h3>

<p>Strangely, it&rsquo;s possible for SSL/TLS to use no encryption if configured
improperly.  Fortunately it is easy to disable this.  OpenSSL also has its own
internal list of ciphersuites with known low security, and disabling those is a
good starting point.</p>

<h3>Disable insecure algorithms</h3>

<p>Some algorithms have known or suspected vulnerabilities, and we can disable or
limit their use where appropriate. The following algorithms in particular should
be disabled:</p>

<h4>MD5: completely broken, still common</h4>

<p>The <a href="https://en.wikipedia.org/wiki/MD5">MD5</a> hashing algorithm is commonly used
but has had known weaknesses since 1996, only 4 years after it was introduced.
Today, MD5 is famously vulnerable to collisions, especially with GPUs. It simply
isn&rsquo;t safe to use any more.</p>

<h4>RC4: former poster child, recently tarnished</h4>

<p>The <a href="https://en.wikipedia.org/wiki/RC4">RC4</a> cypher is also commonly used, and
<a href="https://blog.cloudflare.com/killing-rc4/">until recently</a> was widely
recommended.  However, information revealed by no less than Edward Snowden
himself has <a href="http://www.theregister.co.uk/2013/09/06/nsa_cryptobreaking_bullrun_analysis/">suggested</a>
that it&rsquo;s possible the NSA has the ability to break RC4.</p>

<p>Combined with research showing theoretical vulnerabilities in RC4, the possibility
that there are working attacks against RC4 in the wild is too plausible to
ignore. Microsoft has issued a <a href="http://blogs.technet.com/b/srd/archive/2013/11/12/security-advisory-2868725-recommendation-to-disable-rc4.aspx">security advisory to disable RC4</a>,
and the IETF is
<a href="https://tools.ietf.org/html/draft-ietf-tls-prohibiting-rc4-01">drafting a memo to require clients and servers never use RC4</a>.</p>

<h4>SHA1: rapidly approaching affordable attacks</h4>

<p>In <a href="https://juliansimioni.com/blog/https-on-nginx-from-zero-to-a-plus-part-1/">part 1</a> we generated a
certificate request using <a href="http://en.wikipedia.org/wiki/SHA-2">SHA256</a>
instead of <a href="http://en.wikipedia.org/wiki/SHA-1">SHA1</a>.  For the same reasons, we
also have to disable ciphersuites that use SHA1 as the hashing algorithm. No
attacks against SHA1 have succeeded as of today, as far as we know, but it
probably <a href="https://www.schneier.com/blog/archives/2012/10/when_will_we_se.html">won&rsquo;t be long</a>.</p>

<h3>Disable little-used ciphers</h3>

<p>These are not common, and disabling them just simplifies things and reduces the
surface area for attacks<sup><a href="#7d2f:fn:3" class="footnote" id="7d2f:fn-back:3">3</a></sup>.</p>

<h3>Support perfect forward secrecy whenever possible</h3>

<p><a href="https://en.wikipedia.org/wiki/Forward_secrecy">Perfect forward secrecy</a> allows
a secure connection to use encryption keys that are custom generated for that
specific session. The security advantage this provides is incredible: <strong>even if
the private key for a server is compromised, none of the messages sent to that
server in the past can be decoded</strong>.</p>

<p>Furthermore, even if an attacker manages to successfully compromise a session
key used by your server, they only gain access to a single session. This
increases the cost, and decreases the reward, of attacking communication with
your server.</p>

<p>A great recent example of this is Heartbleed: with perfect forward
secrecy, the Heartbleed vulnerability can only expose
<a href="https://twitter.com/ivanristic/status/453280081897467905">individual sessions</a>.
You&rsquo;d still have to update your server&rsquo;s private key, but almost all user data
would be safe even if your private key were exposed.</p>

<p>Most reasonably modern browsers, with the notable exception of IE8, support key
exchange algorithms with perfect forward secrecy.</p>

<p>There is one additional configuration change that needs to be made to keep PFS
ciphersuites secure. By default Nginx will generate 1024-bit RSA keys for PFS
ciphers, but that can be overridden. Use the configuration changes below and be
sure to use <code>openssl</code> to generate the 2048 bit keys (it can take a few minutes).</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
</pre></td><td class='code'><pre><code class='nginx'><span class='line'><span class="c1"># Use 2048 bit Diffie-Hellman RSA key parameters</span>
</span><span class='line'><span class="c1"># (otherwise Nginx defaults to 1024 bit, lowering the strength of encryption # when using PFS)</span>
</span><span class='line'><span class="c1"># Generated by OpenSSL with the following command:</span>
</span><span class='line'><span class="c1"># openssl dhparam -outform pem -out /etc/nginx/ssl/dhparam2048.pem 2048</span>
</span><span class='line'><span class="k">ssl_dhparam</span> <span class="s">/etc/nginx/ssl/dhparam2048.pem</span><span class="p">;</span>
</span></code></pre></td></tr></table></div></figure>


<h3>Optimize for performance where appropriate</h3>

<p>Despite some algorithms occasionally being found vulnerable, modern browsers
actually support a comprehensive suite of extremely powerful security tools. All
four algorithms specified by NIST for <a href="https://www.nsa.gov/ia/programs/suiteb_cryptography/index.shtml">Suite B cryptography</a>
, including AES and SHA2, are currently supported by a good portion of the
browsers in use today.</p>

<p>Many security experts consider that using the longest key lengths currently
supported does not have any
<a href="http://www.mail-archive.com/dev-tech-crypto@lists.mozilla.org/msg11247.html">measurable impact on security</a>,
and simply reduces performance<sup><a href="#7d2f:fn:4" class="footnote" id="7d2f:fn-back:4">4</a></sup>.</p>

<p>A common configuration that takes this into account is to support these most
secure variants, but prefer more reasonable key lengths. For example, the
configuration above supports both the <code>ECDHE-ECDSA-AES256-SHA384</code> and
<code>ECDHE-ECDSA-AES128-SHA256</code> ciphersuites, but prefers the shorter key length
variant. Both provide excellent security with no known attacks. This makes the
default for most users secure and reasonably performant, but allows users to
demand the most secure ciphersuites if they so desire.</p>

<h2>Enable HSTS</h2>

<p>Many concepts in security involve correctly implementing a specific, precise
procedure like a cryptographic algorithm to achieve a mathematically proven
level of security.
<a href="http://en.wikipedia.org/wiki/HTTP_Strict_Transport_Security">HSTS</a> is not one of them.</p>

<p>Enabling HSTS simply tells browsers not to make any plain text requests to a
server <em>ever again</em>.</p>

<p>In theory, this provides no benefits over a server properly configured to
require a valid HTTPS connection for all resources, at all times. In practice,
<strong>HSTS protects against a huge number of configuration errors that are easy to
make</strong>.</p>

<p>It&rsquo;s also easy to implement: all that is required is for the server to send a
valid HSTS header with each HTTP request, and the browser will do the rest.</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class='nginx'><span class='line'><span class="c1"># enable HSTS including subdomains</span>
</span><span class='line'><span class="k">add_header</span> <span class="s">Strict-Transport-Security</span> <span class="s">&#39;max-age=31536000</span><span class="p">;</span> <span class="k">includeSubDomains</span><span class="p">;</span><span class="k">&#39;</span>
</span></code></pre></td></tr></table></div></figure>


<p>This tells browsers to avoid plain HTTP requests to your server and all
subdomains for one year. It&rsquo;s perfectly reasonable to remove the
<code>includeSubdomains</code> clause if not all your subdomains are ready for HTTPS.</p>

<p>Note that by enabling HSTS, you are essentially promising to browsers that your
server will correctly respond to HTTPS requests until the header expires. This
means its probably <strong>not something that should be enabled on day one of an HTTPS
roll out</strong>.</p>

<p>Once you&rsquo;re comfortably set up running HTTPS with no problems, you can
also <a href="https://hstspreload.appspot.com/">submit your site</a> for HSTS Preload,
allowing the latest versions of popular browsers to ship already knowing your
server expects only HTTPS requests. This is incredible: <strong>modern browsers will
never make even one HTTP request to your server</strong>.</p>

<p>The security benefits of HSTS are profound enough that SSL Labs requires it as
the final prerequisite of an A+ SSL rating.</p>

<h2>Improve Performance</h2>

<p>Finally, there are a few more configuration changes that should be made to improve
performance. As far as I know these either have no detrimental impact on
security, or actually help improve it.</p>

<h3>Set up OCSP Stapling</h3>

<p>Before a browser will connect to a server using HTTPS, it has to check if the
certificate the server is using is still valid. An upgrade or
response to an attack could cause a certificate to be revoked, and its important
to know about it.</p>

<p>Without further action on your part, every browser connecting to your server
will have to pause when first connecting to ask an OCSP server for the latest
revocation information for. OCSP stapling allows your server to do this ahead of
time. The OCSP responses are signed by your Certification Authority, so browsers
will be able to trust them, even if they come directly from your server.</p>

<p>This also cuts down on traffic to OCSP servers(a nice thing for you to do), and
protects your server against unexpected interruptions because of
downtime or denial of service attacks against your OCSP server.</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class='nginx'><span class='line'><span class="c1"># allow Nginx to send OCSP results during the connection process</span>
</span><span class='line'><span class="k">ssl_stapling</span> <span class="no">on</span><span class="p">;</span>
</span></code></pre></td></tr></table></div></figure>


<h2>Support SSL Session Caching</h2>

<p>By far the biggest concern when moving to HTTPS is performance: both extra load
on servers, and slower page load times on the user side. By large, the overhead
for an established secure session is <a href="https://www.imperialviolet.org/2010/06/25/overclocking-ssl.html">not significant</a>
anymore.</p>

<p>However, the process of initially connecting via HTTPS involves many more round
trips between client and server than HTTP, so there is still definitely a
noticeable impact on page load times.</p>

<p>With that in mind, it makes sense to cache SSL sessions for at least a few
minutes, so that users only have to pay that cost once. Nginx is <em>almost</em>
configured correctly out of the box to do this. The only change needed is
setting a size limit for the session cache. The actual timeout is specified with
<code>ssl_session_timeout</code>, which defaults to 5 minutes. The 10MB cache size limit is suggested by
<a href="http://nginx.org/en/docs/http/configuring_https_servers.html">Nginx&rsquo;s own HTTPS configuration guide</a>:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
</pre></td><td class='code'><pre><code class='nginx'><span class='line'><span class="c1"># Cache SSL Sessions for up to 10 minutes</span>
</span><span class='line'><span class="c1"># This improves performance by avoiding the costly session negotiation process where possible</span>
</span><span class='line'><span class="k">ssl_session_cache</span> <span class="n">builtin</span><span class="p">:</span><span class="mi">1000</span> <span class="s">shared:SSL:10m</span><span class="p">;</span>
</span><span class='line'><span class="c1"># ssl_session_timeout 5m; # this is a default, but can be changed</span>
</span></code></pre></td></tr></table></div></figure>


<h2>Resources and Thanks</h2>

<p>I hope this guide can be considered comprehensive enough to be useful, but I
would be lying if I said it was even close to covering everything. Security is a
complicated, rapidly changing challenge. With that in mind I want to call out
some of the best resources I&rsquo;ve found both to provide more information and thank
the authors of these great works.</p>

<ul>
<li>Eric Mill&rsquo;s <a href="https://konklone.com/post/switch-to-https-now-for-free">Switch to HTTPS Now, For Free</a>, which first set me down this path</li>
<li>SSL Lab&rsquo;s <a href="https://www.ssllabs.com/projects/best-practices/index.html">SSL/TLS Deployment Best Practices</a> - a really great and understandable deep dive</li>
<li>Mozilla&rsquo;s extremely complete <a href="https://wiki.mozilla.org/Security/Server_Side_TLS">Server Side TLS</a> wiki page</li>
</ul>


<hr />

<ol class="footnotelist"><p>  <li id="7d2f:fn:1" class="footnotebody" value="1">
    The Nginx blog has an <a href="http://nginx.com/blog/nginx-poodle-ssl/">article about POODLE</a>,
    suggesting that everyone using Nginx disable SSLv3, so hopefully the default
    will change soon.
  <a href="#7d2f:fn-back:1" class="backlink">⏎</a></li></p>

<p>  <li id="7d2f:fn:2" class="footnotebody" value="2">
    <del>Many tutorials, like Eric Mill&rsquo;s <a href="https://konklone.com/post/switch-to-https-now-for-free#generating-the-certificate">Switch to HTTPS Now, For free</a>
    suggest performing something equivalent by concatenating the root certificate,
    intermediate certificate, and your server&rsquo;s certificate together into one
    file. This works just fine, but I prefer keeping the files separate for
    clarity. Use whichever method works better for you.</del></p>

<pre><code>I asked about this on the &lt;a href="http://forum.nginx.org/read.php?2,256613,256621#msg-256621"&gt;Nginx mailing list&lt;/a&gt;
and it turns out this works, but only by accident, and may break in future
versions of OpenSSL or Nginx at any time. Use the standard concatenation method.
</code></pre>

<p>  <a href="#7d2f:fn-back:2" class="backlink">⏎</a></li></p>

<p>  <li id="7d2f:fn:3" class="footnotebody" value="3">
    Some of these ciphersuites are more common in a few contries, and if you&rsquo;re
    serving traffic to primarily one of them, it may make sense for you to
    enable them.
  <a href="#7d2f:fn-back:3" class="backlink">⏎</a></li></p>

<p>  <li id="7d2f:fn:4" class="footnotebody" value="4">
    For the same reasons, I don&rsquo;t believe it makes sense to use certificates
    with 4096-bit keys, 4096-bit <a href="http://en.wikipedia.org/wiki/Diffie%E2%80%93Hellman_key_exchange">Diffie-Hellman key exhange</a>
    parameters, or similar changes. You can actually improve subscores of your
    SSL score using them, but it will come at a performance cost.
  <a href="#7d2f:fn-back:4" class="backlink">⏎</a></li></p>
</ol>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[HTTPS on Nginx: From Zero to A+ (Part 1)]]></title>
    <link href="https://juliansimioni.com/blog/https-on-nginx-from-zero-to-a-plus-part-1/"/>
    <updated>2015-02-01T18:26:02+01:00</updated>
    <id>https://juliansimioni.com/blog/https-on-nginx-from-zero-to-a-plus-part-1</id>
    <content type="html"><![CDATA[<p>A few years ago, the web at large was unencrypted. HTTPS was reserved for only
the most critical sections of a web page. The consensus was only sensitive user
data needed to be encrypted; public parts of a web page were okay to send in the
clear.</p>

<p>Well,
<a href="http://en.wikipedia.org/wiki/Global_surveillance_disclosures_%282013%E2%80%93present%29">things</a>
are
<a href="http://arstechnica.com/security/2015/01/gogo-issues-fake-https-certificate-to-users-visiting-youtube/">different</a>
<a href="https://www.eff.org/deeplinks/2014/11/verizon-x-uidh">now</a>.
Today we know it&rsquo;s not a good idea for any web traffic to be unencrypted, and
anyone running a website, no matter the content, should configure a strong HTTPS
setup today.</p>

<!-- more -->


<p>Embarrassingly, my own website has not supported HTTPS at all for almost two years<sup><a href="#6924:fn:1" class="footnote" id="6924:fn-back:1">1</a></sup>.</p>

<p><a href="https://konklone.com/">Eric Mill</a>&rsquo;s fantastic
<em><a href="https://konklone.com/post/switch-to-https-now-for-free">Switch to HTTPS Now, For Free</a></em>
finally gave me the kick in the pants I needed, and over the holidays I spent
the time to set up HTTPS and tweak the configuration to achieve an
<a href="https://www.ssllabs.com/ssltest/analyze.html?d=juliansimioni.com">A+</a> on the
<a href="https://www.ssllabs.com/ssltest/">Qualys SSL Report</a>.</p>

<p><img src="https://juliansimioni.com/images/nginx-https/website-aplus.png" alt="A+ score on juliansimioni.com" /></p>

<p>It took a good amount of research, but I&rsquo;ve settled on a close to optimal setup,
and want to share how I&rsquo;ve achieved it on Nginx. Besides the actual
configuration, I&rsquo;ve included explanations of what all the components of a secure
setup do, and why it&rsquo;s the best option.</p>

<p>This is part 1, where we&rsquo;ll talk about basics and deal with setting up certificates.</p>

<p><a href="https://juliansimioni.com/blog/https-on-nginx-from-zero-to-a-plus-part-2-configuration-ciphersuites-and-performance/">Part 2</a>
covers more Nginx configuration, especially ciphersuite setup.</p>

<h2>Initial Setup: Use a Self-Signed Certificate</h2>

<p>Simply enabling HTTPS requires very little: a server needs an encryption key and
a certificate file. Both of these can be generated quickly and easily on any
machine with OpenSSL installed.</p>

<p>While these self-signed certificates don&rsquo;t provide any true security<sup><a href="#6924:fn:2" class="footnote" id="6924:fn-back:2">2</a></sup>
its worth the time to set one up up before moving onto a real certificate to get
a feel for the process and fix as many issues as possible early on.</p>

<p>There are <a href="http://stackoverflow.com/questions/10175812/how-to-create-a-self-signed-certificate-with-openssl">far</a>
<a href="https://www.openssl.org/docs/HOWTO/certificates.txt">too</a>
<a href="https://devcenter.heroku.com/articles/ssl-certificate-self">many</a>
<a href="https://www.linode.com/docs/security/ssl/ssl-certificates-with-nginx">tutorials</a>
<a href="https://www.openssl.org/docs/HOWTO/certificates.txt">already</a>
on generating self-signed certs, so I won&rsquo;t go into a huge amount of detail
here. A simple command like the following will suffice:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'>mkdir /etc/nginx/ssl
</span><span class='line'><span class="nb">cd</span> /etc/nginx/ssl
</span><span class='line'>openssl req -new -x509 -sha256 -newkey rsa:2048 -days <span class="m">365</span> -nodes -out /etc/nginx/ssl/nginx.pem -keyout /etc/nginx/ssl/nginx.key
</span></code></pre></td></tr></table></div></figure>


<p>The Nginx configuration section for basic SSL<sup><a href="#6924:fn:3" class="footnote" id="6924:fn-back:3">3</a></sup> is also straightforward. Just add
the following configuration to your nginx file:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
</pre></td><td class='code'><pre><code class='nginx'><span class='line'><span class="k">server</span> <span class="p">{</span>
</span><span class='line'>
</span><span class='line'>      <span class="c1"># [...]</span>
</span><span class='line'>
</span><span class='line'>      <span class="kn">listen</span> <span class="mi">443</span> <span class="s">ssl</span><span class="p">;</span>
</span><span class='line'>      <span class="kn">ssl_certificate</span>      <span class="s">/etc/nginx/ssl/nginx.pem</span><span class="p">;</span>
</span><span class='line'>      <span class="kn">ssl_certificate_key</span>  <span class="s">/etc/nginx/ssl/nginx.key</span><span class="p">;</span>
</span><span class='line'>
</span><span class='line'>      <span class="c1"># [...]</span>
</span><span class='line'><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>


<p><em>(Both code snippets above adapted from the
<a href="https://www.linode.com/docs/security/ssl/ssl-certificates-with-nginx">Linode certifficate guide</a>, also linked above. It&rsquo;s one of the best)</em></p>

<p>Now armed with a valid certificate, restarting Nginx should allow your website
to load over HTTPS, although it will probably greet you with a nasty warning
because the certificate is self-signed. It&rsquo;s time to do a few initial checks for
critical features before we dive in with a full certificate.</p>

<h3>Check for a Modern Version of OpenSSL</h3>

<p>The <a href="https://www.openssl.org/">OpenSSL</a> library is the almost ubiquitous SSL and
TLS library, and its used by nearly every web server, including Nginx. If your
version of OpenSSL is out of date, it might have one of
<a href="https://en.wikipedia.org/wiki/OpenSSL#Notable_vulnerabilities">any number</a> of
security vulnerabilities.</p>

<p>The worst of these is, of course, <a href="http://heartbleed.com/">Heartbleed</a>, which
potentially allows leaking all sorts of data <strong>including your webservers private
keys</strong>. Heartbleed was first made public in April 2014, but many websites are
<a href="http://www.arnnet.com.au/article/564350/more-than-half-all-openssl-remain-vulnerable-heartbleed-cisco/">still vulnerable</a>.
Don&rsquo;t be one of them.</p>

<p>Check the OpenSSL website for the latest stable version, and then check yours
like this:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="nv">$ </span>openssl version
</span><span class='line'>OpenSSL 1.0.1k <span class="m">8</span> Jan 2015
</span></code></pre></td></tr></table></div></figure>


<h3>Ensure You&rsquo;ve Created a 2048-bit, SHA256-signed Certificate</h3>

<p>Self signed certificates can be easily regenerated with no cost
or downtime, so its best to iron out certificate configuration issues now.
Revoking even a free StartSSL certificate <a href="https://www.startssl.com/?app=37">costs $25</a>,
so mistakes later on are more costly and time consuming.</p>

<p>The most important certificate configuration setting is the fingerprint hashing
algorithm.  Until recently, most certificates were signed using
<a href="http://en.wikipedia.org/wiki/SHA1">SHA1</a>.  However,
<a href="http://blog.chromium.org/2014/09/gradually-sunsetting-sha-1.html">Google</a>,
<a href="https://technet.microsoft.com/library/security/2880823">Microsoft</a>, and
<a href="https://www.schneier.com/blog/archives/2012/10/when_will_we_se.html">security researchers</a>
in general are now pushing hard to
deprecate SHA1 quickly: its becoming dangerously insecure as computing power
advances. In its place, new certificates should be signed using
<a href="http://en.wikipedia.org/wiki/SHA-2">SHA256</a>.</p>

<p>There are no known attacks against SHA1 yet, but both Chrome and
<a href="https://blog.mozilla.org/security/2014/09/23/phasing-out-certificates-with-sha-1-based-signature-algorithms/">Firefox</a>
will soon show warnings or errors for certificates signed with SHA1, so creating
a new certificate today without using SHA256 is a big mistake.</p>

<p>Likewise, a 2048-bit RSA key size is currently
<a href="https://www.rapidssl.com/2048-bit-certificate-compliance/">optimal</a><sup><a href="#6924:fn:4" class="footnote" id="6924:fn-back:4">4</a></sup>. 1024-bit
certificates are <em>well</em> into the realm where someone with a sufficiently
powerful computer network could
<a href="https://www.schneier.com/blog/archives/2010/01/768-bit_number.html">break them</a>.
Again, browsers are now actively discouraging their use: Mozilla has
<a href="https://blog.mozilla.org/security/2014/09/08/phasing-out-certificates-with-1024-bit-rsa-keys/">removed</a>
1024-bit Certificate Authority keys from the list of trusted certificates
starting in Firefox 32, released in September 2014.</p>

<p>If you used the commands above to generate your self-signed certificate, it
should already use SHA256 and a 2048 bit RSA key, but the following commands can
be used to check:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'>openssl x509 -in /etc/nginx/ssl/nginx.pem -text -noout <span class="p">|</span> grep <span class="s2">&quot;Signature\|Public-Key&quot;</span>
</span><span class='line'><span class="c"># Should give the following output:</span>
</span><span class='line'><span class="c"># Signature Algorithm: sha256WithRSAEncryption</span>
</span><span class='line'><span class="c"># Public-Key: (2048 bit)</span>
</span><span class='line'><span class="c"># Signature Algorithm: sha256WithRSAEncryption</span>
</span></code></pre></td></tr></table></div></figure>


<p><em>(Adapted from
<a href="https://serverfault.com/questions/325467/i-have-a-keypair-how-do-i-determine-the-key-length">this</a>
ServerFault Answer)</em></p>

<p>If it shows <code>sha1WithRSAEncryption</code> or <code>(1024 bit)</code> instead, go back and
regenerate your certificate with the correct settings.</p>

<h3>Check for Mixed-Content Warnings</h3>

<p>At this point, there&rsquo;s a very good chance some resources on your website, like
Javascript, CSS, or images, are still being loaded over HTTP, even when the
initial request is made over HTTPS.</p>

<p><img src="https://juliansimioni.com/images/nginx-https/mixed-content.png" alt="Mixed content warning in Firefox" />
<em>An example of a mixed-content warning in Firefox</em></p>

<p>It used to be considered enough to use HTTPS only for critical sections of a
website, such as a login page and form submissions, but no longer. Modern
browsers
<a href="https://developer.mozilla.org/en-US/docs/Security/MixedContent/How_to_fix_website_with_mixed_content">block</a>
the more dangerous varieties of mixed contact (namely Javascript and CSS files).</p>

<p>This has a tremendous security benefit to users, because those files can
potentially be modified while in transit and cause
<a href="https://developer.mozilla.org/en-US/docs/Security/MixedContent#Mixed_active_content">serious harm</a>: sensitive user information can be stolen, or malware added to their system.</p>

<p>Fixing mixed-content warnings is very specific to your website&rsquo;s code, but
in principal it simply involves changing any links that start with <code>http://</code> to
<code>https://</code>. This includes links to any resources loaded from other servers. If
those servers don&rsquo;t support HTTPS yet, you have to get rid of the resource
entirely or host it yourself, if possible.</p>

<p>If you really need to support both HTTP and HTTPS,
<a href="http://www.paulirish.com/2010/the-protocol-relative-url/">protocol-relative URLs</a>
can help, but are discouraged.</p>

<h2>Doing it For Real: Use a CA-signed Certificate</h2>

<p>Now that these basic issues are tackled, it&rsquo;s time to create a certificate that
browsers will recognise as trusted. This can be a lengthy process for a couple
of reasons, so let&rsquo;s cover the prerequisites first. You&rsquo;ll need:</p>

<ol>
<li>An account with a Certificate Authority.</li>
<li>Access to <code>webmaster@yourdomain.com</code>, <code>postmaster@yourdomain.com</code> or
whichever email is listed in the SOA record of your domain&rsquo;s DNS entry.</li>
<li>A certificate request(CSR) file.</li>
</ol>


<p>Step 1 is potentially a little more cumbersome than signing up for an average
website, which is understandable considering the security concerns, but should
be manageable. If you haven&rsquo;t chosen a certificate authority,
<a href="https://www.startssl.com/">StartSSL</a> is excellent, and free. Paid options
include <a href="http://www.verisign.com/">Verisign</a> and
<a href="https://www.comodo.com/">Comodo</a>.
Please <a href="http://breakupwithgodaddy.com/">don&rsquo;t use GoDaddy</a>.</p>

<p>Step 2 won&rsquo;t be covered here in detail as it&rsquo;s highly specific to your DNS
setup. If you don&rsquo;t already have this set up properly, it can take a few hours
for the DNS entries to take effect once you&rsquo;ve made the change, so get started
now.</p>

<p>However, if, like me, you are using <a href="https://fastmail.com">Fastmail</a>
for email from your domain, then they have already set up everything for you. If
you <em>aren&rsquo;t</em> using Fastmail, they are awesome and I can&rsquo;t recommend them enough.</p>

<p>Once you&rsquo;ve completed steps 1 and 2, you can create the CSR.  This file details
what domain you want a certificate for, and any options. Some Certificate
Authorities will offer to &ldquo;help&rdquo; you by generating a private key and CSR for you
in the browser.  Decline their offer, since we&rsquo;ve already generated a private
key, and we don&rsquo;t need that potential breach of security.</p>

<p>The following command will generate a nice CSR for you:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'>openssl req -new -sha256 -key /etc/nginx/ssl/nginx.key -out /etc/nginx/ssl/yourwebsite.com.csr
</span></code></pre></td></tr></table></div></figure>


<p>Paste that into the form for the CSR on your CA&rsquo;s webpage, and they will send
back a certificate. Keep it safe and store it on your server, somewhere like
<code>/etc/nginx/ssl/yourwebsite.com.crt</code>.</p>

<p>If you happen to be using StartSSL, Erik Mill&rsquo;s <a href="https://konklone.com/post/switch-to-https-now-for-free">tutorial</a> which I linked to above walks through every step perfectly!</p>

<p>Initially, you can simply point Nginx at the new key and crt file from your CA
just like you did your self-signed cert and things should work<sup><a href="#6924:fn:5" class="footnote" id="6924:fn-back:5">5</a></sup>. Congratulations! Your web server is now running TLS with a valid certificate.</p>

<p>If you were to run the SSL Labs test on your website right now, you&rsquo;d probably
see something like this:</p>

<p><img src="https://juliansimioni.com/images/nginx-https/grade-c-immediately-after-certificate-registration.png" alt="freshly-minted-certificate-test" /></p>

<p>It&rsquo;s not bad, but the default Nginx settings only get you to a C grade - barely
passing. In the next part we&rsquo;ll look at what it takes to configure Nginx so that
you achieve an A+ rating. Stay tuned!</p>

<hr />

<ol class="footnotelist"><p>  <li id="6924:fn:1" class="footnotebody" value="1">
My server didn&rsquo;t even respond to HTTPS, or anything on port 443, for this entire
time!
  <a href="#6924:fn-back:1" class="backlink">⏎</a></li>
  <li id="6924:fn:2" class="footnotebody" value="2">
For truly secure communication, three things are needed: verification the
message came from who you thought it did (authentication), obfuscation of the
message contents so that no one but the intended recipient can read the message
(encryption), and a way to verify that the message was not changed while in
transit (message digest).  A self-signed certificate doesn&rsquo;t provide any
authentication, so it&rsquo;s mostly useless.</p>

<p>The Wikipedia page on <a href="http://en.wikipedia.org/wiki/Transport_Layer_Security">TLS</a>
provides an excellent overview of how this all works.
  <a href="#6924:fn-back:2" class="backlink">⏎</a></li>
  <li id="6924:fn:3" class="footnotebody" value="3">
 When I say SSL, I <a href="https://twitter.com/chriseng/status/560239317574905856">really mean</a>
 TLS. Both SSL and TLS share the same heritage. TLS is simply the name for newer
 versions. All versions of SSL are now out of date, but the name has stuck.
  <a href="#6924:fn-back:3" class="backlink">⏎</a></li>
  <li id="6924:fn:4" class="footnotebody" value="4">
4096 bit keys are, at this point, considered excessive except for Certificate
Authorities, so 2048 is the best size. Remember, a 2048 bit key is not twice as
secure as a 1024 bit key, it&rsquo;s
<a href="http://www.wolframalpha.com/input/?i=2%5E1024"> 2<sup>1024</sup></a> times as
secure! It is twice as slow however. 2048 bits is going to be enough for quite
some time, so 4096 bit keys just make the encryption process slower.
  <a href="#6924:fn-back:4" class="backlink">⏎</a></li>
  <li id="6924:fn:5" class="footnotebody" value="5">
Initially, you will probably get an OCSP error (looks like <a href
="https://juliansimioni.com/images/nginx-https/ocsp-error-after-certificate-creation.png">this</a>). This
will go away in a few hours. The Online Certificate Status Protocol (OCSP) is a
system for determining if a certificate has been revoked. Since your certificate
is brand new, there&rsquo;s no information in the system confirming your certificate
is still valid, and it will take a little while to get there. We&rsquo;ll learn more
about OCSP in the next post.
  <a href="#6924:fn-back:5" class="backlink">⏎</a></li></p>
</ol>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Coaching Beginner Software Developers]]></title>
    <link href="https://juliansimioni.com/blog/coaching-beginner-software-developers/"/>
    <updated>2015-01-21T18:13:04+01:00</updated>
    <id>https://juliansimioni.com/blog/coaching-beginner-software-developers</id>
    <content type="html"><![CDATA[<p>For most of my time as a programmer, I&rsquo;ve thought about learning in exactly one
context: teaching myself more stuff. But In the past few years I&rsquo;ve made an
explicit effort to focus on the opposite problem: teaching others, especially
complete beginners.</p>

<p>Sharing the joy and power of building software with more people is perhaps one
of the <a href="http://www.chris-granger.com/2015/01/26/coding-is-not-the-new-literacy/">most significant</a>
challenges in the world right now, so I&rsquo;ve tried to learn as much as possible
about how to do it.</p>

<p>While I by no means consider myself an expert, I want to share some of what I&rsquo;ve
learned so far.</p>

<!-- more -->


<h2>Praise Often, and Remind Learners that Getting Stuck is Normal</h2>

<p>This is the most basic and core concept I&rsquo;ve learned about teaching.</p>

<p>Remember that almost every student comes into the classroom worried, if not
convinced, that they simply don&rsquo;t have whatever mental faculties or background
it takes to program. The world is full of voices that have told them this.
Unfortunately, many of these voices come from within the software community.</p>

<p>Moreover, however much we programmers debate between ourselves if coding is more
like math or writing, most students are terrified of anything that possibly has
a mathematical foundation.</p>

<p>Women, kids, older people (according to Silicon Valley logic, anyone past 25 is
probably considered &ldquo;old&rdquo;), and minorities are usually especially worried<sup><a href="#f481:fn:1" class="footnote" id="f481:fn-back:1">1</a></sup>,
but you&rsquo;d also be surprised how much fear a few lines of Ruby can impart on
young, well educated white guys.</p>

<p>Programming is hard and the fear of failing and looking dumb is something
everyone struggles with.  As a teacher our job is to combat that.</p>

<p>So far, my go-to tactics are:</p>

<ol>
<li>strongly asserting that every programmer, no matter how experienced,
struggles when learning. There aren&rsquo;t certain people born with an ability to
pick up programming without making any mistakes.</li>
<li>reminding students that they are capable of learning to code, and that the
satisfaction that comes after struggling through something and finally
prevailing is really enjoyable.</li>
</ol>


<p>It&rsquo;s not enough to simply state these things, they have to be proven through
actual actions in the classroom. The first is easier: don&rsquo;t be afraid to admit
what you, even as a teacher, don&rsquo;t know. Anyone who has taught knows that
there&rsquo;s no better way to secure a solid understanding of something than to teach
it to someone else. As your understanding grows, be sure to share it with your
students.</p>

<p>I don&rsquo;t think there&rsquo;s any shortcut for the second: nothing but actually getting
the student to accomplish something that challenged them will do. Any coding
curriculum should focus on quickly getting a new student to successfully build
something, by themselves, to set a mood that encourages them. This is hard, but
easier than ever today: we can write <a href="http://opentechschool.github.io/js-beginners-4h-workshop-1/sandbox/#drawing.js">a few lines of Javascript</a>
and have our students create pretty pictures quickly. It might have taken weeks of
painstaking work learning advanced C++ and OpenGL to do the same thing a few
years ago!</p>

<p>It&rsquo;s not completely clear to me where to draw the line when reminding students
that getting stuck and making mistakes is normal. Sometimes I&rsquo;ve taken a rather
cynical route and said things like &ldquo;our puny human brains simply aren&rsquo;t very
good at writing bug-free code, so we have to do what we can to keep our code
simple, and we&rsquo;ll still make mistakes all the time&rdquo;. Some students probably
appreciate brutal honesty and dark humor, others might appreciate a lighter
touch.</p>

<h2>Teach by Asking Lots of Questions, Carefully</h2>

<p>No less a teacher (and learner!) than Socrates ensured that asking questions
will always be core to every teacher&rsquo;s tool belt<sup><a href="#f481:fn:2" class="footnote" id="f481:fn-back:2">2</a></sup>, but there&rsquo;s some nuance here
that is extremely important to remember to keep it from backfiring.</p>

<p>Remember that every student is almost completely convinced they aren&rsquo;t cut out
for programming. If you&rsquo;re particularly lucky (or good!), they are having a good
time so far and have made something cool already. Still, most new students are
probably one frustrating moment of giving up forever.</p>

<p>The reason why asking questions works so great for teaching is that in the
process of coming up with an answer (any answer, not even a correct one!),
forces students to think hard about something, and that&rsquo;s how you learn. A
talented mentor can ask questions that guide a student towards understanding
without actually <em>telling</em> them anything<sup><a href="#f481:fn:3" class="footnote" id="f481:fn-back:3">3</a></sup>.</p>

<p>But being asked questions on the border of your knowledge is extremely taxing,
and sometimes students just don&rsquo;t come up with a good answer. Sometimes the
question is bad, sometimes the question wasn&rsquo;t properly matched with where they
are in the learning process, and sometimes they just need the question phrased
differently.</p>

<p>Not being able to answer a question can be pretty demoralizing, but there are
ways you as a coach can make it worse! There are two pitfalls: asking &ldquo;obvious&rdquo;
questions, and trick questions.</p>

<p>&ldquo;Obvious questions&rdquo; are useful, but dangerous. One way they often come about is
when walking through some code, mentally performing each operation in turn. As we try
to remind new coders, most math in programming is nothing more complex than
basic arithmetic. For example, a teacher and student might have this exchange
when going over a basic <code>for</code> loop:</p>

<blockquote><p>&ldquo;OK, we set <code>i</code> to zero. Next we add one. Zero plus one is?&rdquo;</p>

<p>&ldquo;One&rdquo;</p>

<p>&ldquo;Then we do [whatever is in the loop]. Then we start over: what was <code>i</code>?&rdquo;</p>

<p>&ldquo;One&rdquo;</p>

<p>&ldquo;Good, next we add one to <code>i</code>. One plus one is?&hellip;&rdquo;</p>

<p>&ldquo;Two&rdquo;</p></blockquote>

<p>If the student is with you, and knows what the result will be, everything is
great. But sometimes all the chaos of learning is overloading their brain for
the moment. They&rsquo;re trying to answer, but they just can&rsquo;t right now. Students
can usually tell from the tone of your voice you expect them to know the answer,
and when they can&rsquo;t it&rsquo;s really demoralizing. Be careful.</p>

<p>Trick questions are also something I try to avoid. It&rsquo;s far too easy to
demoralize your student by making them think you&rsquo;re showing off.</p>

<p>Really, avoiding the pitfalls of asking questions just comes down to doing
everything it takes to ensure to your student is sure you&rsquo;re there to help them
learn, rather than to make them feel bad, or to show off your skills. Create
that environment, and then use questions wisely!</p>

<h2>Don&rsquo;t be Afraid to Review the Basics</h2>

<p>A standard first day of coding ever usually looks something like this:</p>

<ol>
<li>type some extremely simple expressions into a REPL</li>
<li>type almost identical expressions into a REPL, but assign them to named
variables</li>
<li>fool around with strings and classes (maybe)</li>
<li>learn simple functions and loops</li>
<li>do Cool Things&trade; with all that knowledge</li>
</ol>


<p>To keep students from becoming bored, there&rsquo;s often a big push to move through
the basics quickly. It&rsquo;s much more exciting to actually build something cool,
and you generally can&rsquo;t do that with just expressions in a REPL, so this
approach is reasonable.</p>

<p>But typing a few lines is not enough to learn any programming concept, and in
some ways the foundational programming concepts are the hardest to truly grok.</p>

<p>What I often see is students go through the quick intro to variables, or
functions, or loops, and because the examples are so simple, they feel mostly
comfortable and move on. Then, when trying to build something more complicated,
they get stuck not because of the new material, but because they are reaching
the limits of what they&rsquo;ve learned previously.</p>

<p>Most coding tutorials are written assuming students know all about variables by
the time they get to for loops or functions, but that simply isn&rsquo;t the case.</p>

<p>Don&rsquo;t be afraid to go back a step or two when needed.  A coach is absolutely
critical for this, because experience allows the coach to figure out which core
skill is lacking, and figure out how to fix it.  Sometimes the student&rsquo;s current
exercise can be adapted, even if it&rsquo;s for something more advanced, sometimes a
simple example needs to be created on the spot.</p>

<p>In addition, there are some nuances to basic programming that I&rsquo;ve discovered
students have trouble with. They aren&rsquo;t generally given entire chapters in a
curriculum like variables and functions might, so they don&rsquo;t get much coverage.
I&rsquo;ve found it takes a decent amount of time to explain these areas.</p>

<p>The first is scope.  Christina Cacioppo&rsquo;s <em>Learning Online</em> calls out
<a href="http://christinacacioppo.com/blog/learning-online">variable scope</a>
as one of the most challenging basic concepts for students to learn, and my
experience agrees. This is understandable, because every language has different,
complicated, and sometimes
<a href="http://toddmotto.com/everything-you-wanted-to-know-about-javascript-scope/">unexpected</a>
(yes I&rsquo;m looking at you Javascript!) rules for it.</p>

<p>At least for function scope, I&rsquo;ve found something that works reasonably well:
temporarily rearrange the students source code so that only the function they
wrote, OR the code they wrote that calls it, but not both, can be seen on the
screen at once (the low tech solution is to just insert a bunch of newlines).
Then, we can reason about each bit of code independently.</p>

<p>Around this time students often get confused by function arguments and local
variables passed to those functions that share the same name. I would love to
hear peoples thoughts on whether these names should be changed to be unique, or
kept the same.</p>

<p>In any case, when students can&rsquo;t see both functions on their screen, they
usually seem to be able to skirt around this area. I do know its helpful to
remind students that calling functions they themselves have written is no
different than calling other functions, which they&rsquo;ve no doubt already done.</p>

<p>Another tricky concept is control flow during loops. It usually takes students
a while to be able to calculate in their head what values a variable will take
during each iteration of a loop, for example. Perhaps it&rsquo;s the fact that a line
like <code>i = i + 1;</code> looks much like an algebraic formula, but of course isn&rsquo;t
valid, or maybe it&rsquo;s the idea of the same line of code executing multiple times
with a variable having a different value each time that&rsquo;s confusing<sup><a href="#f481:fn:4" class="footnote" id="f481:fn-back:4">4</a></sup>.</p>

<h2>Teach by Modifying Existing Code</h2>

<p>Most of the time, students start with little or no code, and build up something
bigger, but this isn&rsquo;t the only way to learn.</p>

<p>I like to take some existing code, especially code the students have written,
and suggest changes to it. The key is to have the student make the changes, and
before they run the new code, ask them what they think will happen. It&rsquo;s OK if
they don&rsquo;t know, but they have to give it a good thought at least.</p>

<p>This works best once students are working with code with a little bit of
complexity. Loops (especially nested loops), provide lots of parameters to tweak
that can provide interesting learning opportunities.</p>

<p>My favorite path goes something like this:
Start with a simple for loop (a more advanced exercise nests two):</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class='Javascript'><span class='line'><span class="k">for</span> <span class="p">(</span><span class="kd">var</span> <span class="nx">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="nx">i</span> <span class="o">&lt;</span> <span class="mi">10</span><span class="p">;</span> <span class="nx">i</span> <span class="o">+=</span> <span class="mi">1</span><span class="p">)</span> <span class="p">{</span>
</span><span class='line'><span class="p">...</span>
</span><span class='line'><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>


<ol>
<li><p>Ask the student to double the termination condition from 10 to 20. Students
usually get that this will make the loop do more of whatever it was doing
before.</p></li>
<li><p>Change the start condition to something negative, say -5. Most students are
initially perplexed but realize why it works fairly quickly once they see the
output</p></li>
<li><p>Change everything else back, and then change the iteration from <code>i += 1</code> to
<code>i += 2</code>. Interestingly in my experience, students usually realize that the
loop will now &ldquo;skip&rdquo; every other iteration, but don&rsquo;t know, or don&rsquo;t mention,
that the loop will also only run half as many times. With a little more work,
when they figure it out, it&rsquo;s usually a pretty big moment of understanding
that feels good for the student.</p></li>
</ol>


<h2>Do Not Enforce Your Professional Coding Standards</h2>

<p>As an experienced developer, you&rsquo;ve gotten to where you are by being pretty
tough on yourself. You have strict standards for the quality of your code or
your team&rsquo;s code, and are more than willing to call teammates out to make the
code more maintainable in the long term. On a professional team, this is a good
thing.</p>

<p>When working with brand new programmers, it&rsquo;s a great way to demoralize. The
place where this is seen the most is in indentation, whitespace, and general
code formatting. While you&rsquo;ve probably formed strong opinions on exactly how
code should be formatted, new programmers have no such concerns. It isn&rsquo;t even
on their radar. When you&rsquo;re just figuring out how variables work, coming up with
a good variable name isn&rsquo;t something you can even begin to deal with.</p>

<p>Your job as a mentor is to ignore whatever horrors of coding style your students
produce. I&rsquo;m willing to claim that there is no code a first-day student can
write that you can&rsquo;t read well enough to coach them just fine.</p>

<p>At all costs, don&rsquo;t express any disgust at your student&rsquo;s code. Even something
like &ldquo;well, before I can help you, we have to fix your whitespace&rdquo;, is enough to
make someone feel really bad. I personally don&rsquo;t bother pointing out most coding
style issues to beginners.</p>

<p>If you really want to, you can do it, but only when your student is at a point
where they&rsquo;ve just had success solving a problem and are feeling good. Then
very gently suggest syntax improvements. Something like &ldquo;okay, now that you&rsquo;ve
got that working, lets make a quick change so that your code is easier to work
with later&rdquo;.</p>

<p>New students aren&rsquo;t generally concerned with the &ldquo;beauty&rdquo; or &ldquo;elegance&rdquo; of their
code<sup><a href="#f481:fn:5" class="footnote" id="f481:fn-back:5">5</a></sup>, so motivating them with those sorts of concerns probably won&rsquo;t work.
However, students generally ARE receptive to the idea of simplifying code, and
offering ways to make their job easier later is often much appreciated.</p>

<h2>Kids are the Ultimate Challenge</h2>

<p>I&rsquo;ve had the opportunity to help mentor younger kids (below age 12 or so) just a
few times, and it&rsquo;s been a blast: a tiring and intense blast.</p>

<p>In my (limited) experience, the challenges are not fundamentally different than
those for adults, but the magnitude of the challenge, and the amount of leeway
you have in solving those challenges are vastly different.</p>

<p>Like adults, kids are apprehensive about their abilities, and just as
worried about failing. What makes kids different when learning to code is, I
think, what primarily makes kids different from adults in anything else: kids
aren&rsquo;t good at managing their emotions, and kids aren&rsquo;t as able to delay
gratification. Let me give some examples:</p>

<ul>
<li><p>With an adult programmer, seeing a more advanced student&rsquo;s work isn&rsquo;t
discouraging, because they understand that they will be able to build more
impressive things over time. Kids see someone next to them doing something
cooler than they&rsquo;re doing, and are often immediately unhappy. Even if they do
get a little jealous, adults won&rsquo;t tell you. Kids definitely will make it
known!</p></li>
<li><p>Adults are able to push themselves all afternoon to learn something. They&rsquo;ve
experienced enough times when hard work paid off. Kids, when mentally
exhausted, will make it painfully obvious. &ldquo;Lets play an easier game&rdquo;, a kid
once said to me after about 3 hours of working with Scratch.</p></li>
<li><p>Similarly, adults are more receptive to spending time on &ldquo;boring&rdquo; building
blocks, like variables and functions, before building something &ldquo;cool&rdquo;. I
think the only effective way to teach kids is to make the entire process as
fun as any game, and that&rsquo;s just plain hard with some of the basics. This is a
hard problem to solve. Actually, it would make it much easier to teach adults
too, but it&rsquo;s more critical for teaching kids.</p></li>
<li><p>In general, adults have more determination to code. Adults know their time
spent learning to program might have huge professional or financial upside
later. They&rsquo;re willing to put in a little work. Kids on the other hand, aren&rsquo;t
motivated by such things: learning to code has to be a game, and if the game
isn&rsquo;t fun for even a short while, it&rsquo;s hard to press on.</p></li>
</ul>


<h3>Does <em>Show And Tell</em> Help or Harm?</h3>

<p>Here&rsquo;s something interesting I&rsquo;ve been thinking about: a lot of events for kids
have a big demo at the end where all the kids get up on some sort of stage in
front of everyone and show off what they&rsquo;ve built. I can see how this can be
really helpful: telling kids their work is worth showing off, and giving them an
opportunity to do so, sounds like a positive thing.</p>

<p>But like I said, when kids see the work of a more advanced student, it&rsquo;s really
easy for them to get demoralized. The problem with these demos is that they
often mix kids of vastly different ages and skills.</p>

<p>When a 7 year old shows off his or her extremely basic thing that he spent all
day struggling through, and then a 12 year old shows off this complex thing, is
the 7 year old really going to feel good?</p>

<p>I think the answer is more often than not, unfortunately, no. I can&rsquo;t help but
thinking that show and tell is mostly for parents to feel good, and that the
effect they can have on a young students morale can be serious. Maybe demos
should only be allowed when the age and experience level of all the students are
similar.</p>

<h3>Scratch</h3>

<p>One last thought, I want to talk about <a href="http://scratch.mit.edu/">Scratch</a> for a
second. Overall, I think Scratch is amazing for teaching kids. It makes it
quick and easy to add really powerful visuals to programming, and doesn&rsquo;t
involve typing, which is actually a big deal for younger kids. The iPad app is
flat out fantastic and easy to get started with as well.</p>

<p>However, I wish it came with more built in features that were higher level. For
those that aren&rsquo;t familiar, Scratch basically has you click and drag various
blocks that more or less map to programming primitives, like if statements,
variables, for loops, etc.</p>

<p>These primitives can be used to build anything, but it would be nice if it came
with more powerful blocks, even if they didn&rsquo;t correspond to programming
primitives, so that at least some aspects of programming could be taught while
keeping things fun for kids. It would be especially cool if, when the student is
ready, these higher level blocks could be inspected and the actual primitives
underlying them could be seen. Scratch does allow you to define your own blocks,
so maybe someone has done this, and if so I&rsquo;d love to hear about it.</p>

<h2>Onward</h2>

<p>For anyone looking to start coaching without a lot of experience, I can&rsquo;t
recommend enough that you do it! You won&rsquo;t be a perfect coach immediately, but
as long as you are willing to commit to genuinely wanting your student to
succeed, you&rsquo;ll get better.</p>

<p>It&rsquo;s a completely new set of challenges for those of us used to writing code
ourselves, but it&rsquo;s something every software developer should practice.</p>

<p>Before long, when you&rsquo;ve mastered the art of not
<a href="https://opentechschool.github.io/slides/presentations/coaching/?full#donts_keyboard">touching the keyboard</a>,
you&rsquo;ll know you&rsquo;ve gained a valuable skill. Better yet, you&rsquo;ll have helped
excite and encourage a bunch of new software developers!</p>

<p><em>Thanks to <a href="https://twitter.com/pushorpull">Charlotte Chang</a> and
<a href="https://twitter.com/jdaudier">Joanne Daudier</a> for reviewing this post</em></p>

<hr />

<ol class="footnotelist"><p><li id="f481:fn:1" class="footnotebody" value="1">
Without a doubt, coaching events targeting specific groups like
<a href="http://www.blackgirlscode.com/">BlackGirlsCode</a>, <a href="http://railsbridge.org/">RailsBridge</a>,
<a href="http://railsgirls.com/">RailsGirls</a>, etc. are an enormous help and are absolutely
necessary. I&rsquo;d encourage anyone to volunteer at these events: it&rsquo;s an eye
opening experience for those of us who got here without the explicit
discouragement many groups of people face.
<a href="#f481:fn-back:1" class="backlink">⏎</a></li></p>

<p><li id="f481:fn:2" class="footnotebody" value="2">
In fact there&rsquo;s a great term for this form of teaching:
<a href="http://www.csun.edu/~vceed002/ref/pedagogy/scaffolding/index.html">scaffolding</a>.
<a href="#f481:fn-back:2" class="backlink">⏎</a></li></p>

<p><li id="f481:fn:3" class="footnotebody" value="3">
Its probably not a good idea as a coach to only ask questions, but they&rsquo;re
a great start, and knowing what extra bits of clarifying information to add when
a student has figured out something on their own can really help. Adding too
much information can hurt as well, so it&rsquo;s a balancing act like many things.
<a href="#f481:fn-back:3" class="backlink">⏎</a></li></p>

<p><li id="f481:fn:4" class="footnotebody" value="4">
A lot of people will probably say the solution is to teach functional
programming, all variables should be immutable, and all functions pure. I think
this might actually be helpful, at least in some cases. Students definitely are
comfortable with the idea of a function that takes some inputs and just does
something with them. Functions or methods that maintain their own state often
perplex them.
<a href="#f481:fn-back:4" class="backlink">⏎</a></li></p>

<p><li id="f481:fn:5" class="footnotebody" value="5">
According to Charlotte Chang, who recently went through a developer bootcamp
program, many developers quickly do become very focused on code aesthetics, so
if you&rsquo;re coaching more experienced students, this may not be the case. And if
you are coaching very new students: enjoy it while it lasts!
<a href="#f481:fn-back:5" class="backlink">⏎</a></li></p>
</ol>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Why Women Should Code]]></title>
    <link href="https://juliansimioni.com/blog/why-women-should-code/"/>
    <updated>2015-01-19T16:01:04+01:00</updated>
    <id>https://juliansimioni.com/blog/why-women-should-code</id>
    <content type="html"><![CDATA[<p>A few days ago, an article titled <em>Why Women Shouldn&rsquo;t Code</em>, perhaps the ultimate click-bait
headline, was posted on Medium. There were already great responses by
<a href="https://medium.com/@hardaway/why-women-shouldnt-code-82205165e64a">Kelly Ellis</a> and
<a href="http://negativitysandwiches.com/post/108299473795/a-quick-and-dirty-annotation-of-why-women">Jenn Schiffer</a>
by the time I read it, but I quickly started drafting up my own comments.</p>

<!-- more -->


<p>I wrote my response assuming that the author of <em>Why Women Shouldn&rsquo;t Code</em> was just another &ldquo;old
white dude&rdquo; telling women what to do. Embarrassingly, I discovered that in fact the author was a
woman! Here I was, trying to write some words supporting gender equality, and I made the classic
mistake of assuming everyone on the internet is a man. Oops.</p>

<p>It&rsquo;s often said that no-one thinks they are part of the problem of sexism, and this was a good
reminder that it really takes a lot of work to over come biases that are common in society. I&rsquo;ll try
to do better next time.</p>

<p>After all this I was really wondering if I should even publish anything about the original
article. The internet is already full of men telling women what to do or think. Finally I decided
that it is worth speaking up about, if nothing else because I want to make it clear, on my own blog,
what my own opinions are. But also, <em>Why Women Shouldn&rsquo;t Code</em> has some seriously wrong assumptions
about the nature of coding, something I hold very near and dear. So let&rsquo;s talk.</p>

<h2>On the Innate Differences Between Men and Women</h2>

<p>Sure, you don&rsquo;t need to do a brain scan to discover there are biological differences between men and
women.</p>

<p>But taking the leap from &ldquo;the part of the brain that we think is somewhat responsible for extremely
high level activity X is slightly bigger in men, on average&rdquo; to &ldquo;thing X should only be done by men&rdquo;
is simply not a viable line of thought.</p>

<p>Proving differences in aptitude of any high level skill is almost impossible to support with
science. There is way too much complexity in the human experience to ever come to a meaningful
conclusion.</p>

<p>Besides, we can&rsquo;t even measure the differences in productivity between teams of software developers
even if we try to make the composition of the team as identical as possible. Given the same
requirements, different groups of developers won&rsquo;t even build the same thing. One team wouldn&rsquo;t
even build the same thing given a second chance.</p>

<p>Part of what makes creating software hard is that we don&rsquo;t conclusively know what makes a team good
or bad at it, even though we&rsquo;ve been doing it for at least 70 years<sup><a href="#0675:fn:1" class="footnote" id="0675:fn-back:1">1</a></sup>. Under those conditions, is
it really wise to exclude 50% of the population from contributing?</p>

<p>Most importantly, even if we did some day conclusively prove that on average the biology of a woman
makes her less adept at writing code, who cares? Men do things that women are supposedly better at
all the time, and no one bats an eye. <a href="https://www.youtube.com/watch?v=kRUS8Zvg3sg">Let them code</a>.</p>

<h2>On the Definition of the Profession of &ldquo;coding&rdquo;</h2>

<p>If a software job simply consists of writing a program to do exactly what someone else tells
you it should do, then there&rsquo;s no question why women don&rsquo;t want that job: that job sucks. No
one wants that job.</p>

<p>Fortunately, while probably more common than we&rsquo;d like, that job isn&rsquo;t something that&rsquo;s
really needed. What we <em>do</em> need are people who can not only write good code, but talk to other people
who are experts in other things, and together build something that is both useful and possible to
build in a reasonable amount of time, for a reasonable cost. This job is hard, it requires technical
AND people skills, and many people find it extremely enjoyable.</p>

<p>By the way, you don&rsquo;t even have to code as part of a job. Coding can simply be done for fun, on your
own, or with some friends, or even random strangers from the internet.</p>

<p>Even after robots have taken over the world and humans just sit back on their space cruise ships,
someone will surely still be writing code for fun (probably even code that a million other people
have already written). No one needs to tell you what to code, and you don&rsquo;t even need to ask
permission.  That&rsquo;s why it&rsquo;s awesome. It&rsquo;s the pure joy of creation<sup><a href="#0675:fn:2" class="footnote" id="0675:fn-back:2">2</a></sup>.</p>

<h2>On 16 &ldquo;Data Points&rdquo; Being Enough to Prove Something</h2>

<p>When you go to a toy store, the boys section is filled with superheroes, trucks, trains and
airplanes. The girls section is filled with dolls and fake kitchens. Do we make fake kitchen toys
for girls because that&rsquo;s what they like, or is that what they like because that&rsquo;s what we make them?</p>

<p>These sort of questions of causation have confounded humanity for so long that the entire idea of
science was created to help answer them. While still lacking, there are a number of tools that we
have today to help. Sample sizes should be large, biases in selecting the samples should be taken
into account, and the study itself should be administered as a double-blind trial, all to make sure
we aren&rsquo;t tricking ourselves.</p>

<p>What definitely ISN&rsquo;T in that toolkit is cherry-picking a handful of stories from people who&rsquo;s lives
we personally have had a long and significant influence over, and using those stories to support a
belief we&rsquo;ve had since before those people existed.</p>

<hr />

<ol class="footnotelist"><p><li id="0675:fn:1" class="footnotebody" value="1">
For a great collection of mostly sound scientific research into what we DO know about reading
software, watch Greg Wilson&rsquo;s fantastic talk
<a href="https://vimeo.com/9270320">What We Actually Know About About Software Development, and Why We Believe It&rsquo;s True</a>,
and then read the resulting book: <a href="https://www.goodreads.com/book/show/8553359-making-software">Making Software: What Really Works, and Why We Believe It</a>.
<a href="#0675:fn-back:1" class="backlink">⏎</a></li></p>

<p><li id="0675:fn:2" class="footnotebody" value="2">
You could even say the joy of nurturing something.
<a href="#0675:fn-back:2" class="backlink">⏎</a></li></p>
</ol>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[2014 Books]]></title>
    <link href="https://juliansimioni.com/blog/2014-books/"/>
    <updated>2015-01-09T18:20:00-08:00</updated>
    <id>https://juliansimioni.com/blog/2014-books</id>
    <content type="html"><![CDATA[<p>Its a few days late, but like many others, I want to take a moment and give a quick summary of the
books I read this year. I&rsquo;ve got quite a few more partially finished, so the 2015 follow up post
should be great too!</p>

<h2><strong><a href="https://www.goodreads.com/book/show/2422710.Digital_Apollo">Digital Apollo: Human and Machine in Spaceflight</a> by David Mindel</strong></h2>

<p>According to Goodreads, I actually finished this book on December 31st, 2013. But I&rsquo;m putting it
here because I easily re-read it twice in 2014: I based much of my talk from <a href="https://juliansimioni.com/talks/#apolloMWRC">Mountain West Ruby</a>
and <a href="https://juliansimioni.com/talks/#apolloRailsConf">RailsConf</a> on content from the book. <em>Digital Apollo</em> does an
excellent job of covering development of hardware and software during the Apollo Program, and really
all the projects leading up to it. There are technical sections, but they aren&rsquo;t overly in depth and
the main narrative isn&rsquo;t dependent on understanding every detail.</p>

<h2><strong><a href="https://www.goodreads.com/book/show/20899335-the-adventures-of-sherlock-holmes">The Adventures of Sherlock Holmes</a> by Sir Arthur Conan Doyle</strong></h2>

<p>I have to credit Star Trek: The Next Generation for really making me aware of these excellent
stories years ago, and while I&rsquo;ve read a few here and there, it was only this year when I sat down
and finished this 12 story collection. They&rsquo;re amazing bits of writing, and hugely refreshing from
non-fiction, which is what I generally read the most. Some of the plots that must have been original
when these stories were published seem cliché today, but surely they didn&rsquo;t when first published.</p>

<h2><a href="https://www.goodreads.com/book/show/141499.Failure_is_not_an_Option">Failure Is Not An Option</a> by Gene Kranz</h2>

<p>Far more than an interesting story about the space program, this is a great read for anyone who has
ever wanted to accomplish something extremely challenging that no one has done before.  Kranz does
an incredible job of describing the details not just of all the technical challenges and
accomplishments of manned space flight, but of the emotions and team dynamics as well. Anyone
doubting that any person can, with the right amount of determination and teamwork, accomplish
anything should read this book.</p>

<h2><a href="https://www.goodreads.com/book/show/2372.The_Path_Between_the_Seas">The Path Between the Seas</a> by David McCulloug</h2>

<p>I&rsquo;ve been reading this book on and off for almost two years (I started in early 2013). It&rsquo;s truly a
monstrosity, covering the building of the Panama Canal in incredible, but interesting detail. To be
honest, I found the first half of the book, which details the comically failure-ridden initial efforts by
the French, much more entertaining and useful. The second half, where the Americans basically come
in, fix all the problems, and triumph, is great for national pride, but there&rsquo;s not as much to learn
from it.</p>

<h2><a href="https://www.goodreads.com/book/show/13237720-the-day-the-world-discovered-the-sun">The Day the World Discovered the Sun</a> by Mark Anderson</h2>

<p>Astronomy and history are both long time interests of mine, but I found this book mediocre at best.
It covered too many characters, interweaving their stories in a way that was hard to follow, and the
writing felt like it was trying to be too &ldquo;grand&rdquo;. Still, it&rsquo;s a short book, and describes a very
interesting and dramatic series of scientific endeavours spanning the entire globe, so I can&rsquo;t say I
didn&rsquo;t enjoy it a little.</p>

<h2><a href="https://www.goodreads.com/book/show/2998152-javascript">Javascript: The Good Parts</a> by Douglas Crockford</h2>

<p>I re-read this book after working more deeply with Javascript this year than ever before. Having
considerably improved with the language and many of its core concepts, I found the re-read so
valuable I wrote up an entire <a href="https://juliansimioni.com/blog/javascript-the-good-parts-review/">review</a>.</p>

<h2><a href="https://www.goodreads.com/book/show/4865.How_to_Win_Friends_and_Influence_People">How to Win Friends and Influence People</a> by Dale Carnegie</h2>

<p>In some senses, everything in this book is obvious and self-evident to anyone who has ever had
feelings. On the other hand, the writing style is quite enjoyable and it&rsquo;s at least a great reminder
of how to work with others. For most of us, is probably a deeper exploration into describing what
makes humans happy and angry than we&rsquo;ve thought about before. If you&rsquo;re turned off by the
social-engineering-sounding title, one of my friends proposed a more accurate, alternate title:
<em>How to Be Friendly and Be an Influencer</em>.</p>

<h2><a href="https://www.goodreads.com/book/show/11366.The_Guns_of_August">The Guns of August</a> by Barbara Tuchman</h2>

<p>While I found it hard to follow at times, there can be no doubt after a chapter or two why this book
won a Pulitzer: the depth of research and fantastic writing style make this book practically a work
of art. I was pretty tired of epic history books after reading <em>The Path Between the Seas</em> this
year, and <i><a href="https://www.goodreads.com/book/show/13155847-embers-of-war">Embers of War</a></i> last
year, but still had to finish this book once I started. While both have similar themes, I preferred <em>Embers of War</em>.</p>

<h2><a href="https://www.goodreads.com/book/show/46347.All_the_Shah_s_Men">All the Shah&rsquo;s Men</a> by Stephen Kinzer</h2>

<p>After <em>The Guns of August</em>, the straightforward but extremely captivating writing style of this book
was refreshing, and I finished it in just a day or two. Anyone looking for a lens into the cultures
of the middle east would benefit from reading this short but exciting book.</p>

<h2><a href="https://www.goodreads.com/book/show/2606779-one-minute-to-midnight">One Minute to Midnight</a> by Michael Dobbs</h2>

<p>Yet another captivating history, this time on the Cuban missile crisis. Unlike <em>The Day the World
Discovered the Sun</em> this book is not hard to follow despite covering dozens of events all over the
globe happening just minutes apart. As yet another book documenting the folly of war, this time
because of the inability of even leaders like Kennedy and Khrushchev to control their own forces
enough to avoid terrible outcomes, I&rsquo;ve pretty much got that genre covered for a while. Fortunately,
next on my reading list is <em>Moby Dick</em>: a complete departure the trend. I didn&rsquo;t quite finish it in
2014 though.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Brief Words on Functional Programming]]></title>
    <link href="https://juliansimioni.com/blog/brief-words-on-functional-programming/"/>
    <updated>2014-12-12T10:31:43+01:00</updated>
    <id>https://juliansimioni.com/blog/brief-words-on-functional-programming</id>
    <content type="html"><![CDATA[<p><em>A few days ago I
<a href="http://exercism.io/submissions/7e7c495ab72742afa2848db0937f9748">reviewed</a> some code on the awesome
<a href="http://exercism.io">Exercism</a> project. My comments touched on a lot of ideas
I&rsquo;ve been meaning to jot down about functional programming, or at least some
aspects of it when using Ruby, so I&rsquo;ve adapted the comments into the following
blog post.</em></p>

<p>Whenever you have a loop that is modifying a variable in each iteration of the
loop, consider a functional programming approach. It will usually result in less
code setting up and returning variables, which makes the code that actually does
the interesting stuff stand out more.</p>

<p>Any time you are taking every element of an array and want to produce another
array with modified variables, you can use <code>map</code>. And any time you have an array
and want to use each value in the array to construct a single result at the end,
you want <code>reduce</code>.</p>

<p>To explain the difference, from a more common, imperative approach, let&rsquo;s
imagine you have a short array of integers, and you want to create a new array
with all those integers incremented by one. You might do it like this:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="k">def</span> <span class="nf">add_one_to_array</span><span class="p">(</span><span class="n">old_array</span><span class="p">)</span>
</span><span class='line'>  <span class="n">new_array</span> <span class="o">=</span> <span class="o">[]</span>
</span><span class='line'>
</span><span class='line'>  <span class="n">old_array</span><span class="o">.</span><span class="n">each</span> <span class="k">do</span> <span class="o">|</span><span class="n">element</span><span class="o">|</span>
</span><span class='line'>    <span class="n">new_array</span><span class="o">&lt;&lt;</span> <span class="n">element</span><span class="o">+</span><span class="mi">1</span>
</span><span class='line'>  <span class="k">end</span>
</span><span class='line'>  <span class="n">new_array</span>
</span><span class='line'><span class="k">end</span>
</span></code></pre></td></tr></table></div></figure>


<p>That will work just fine. And because you&rsquo;ve probably written tons of loops just
like that one, it feels intuitive. But I would argue you can make the code much
clearer, while doing the same thing, and reducing the chance of bugs sneaking
in. Here&rsquo;s how:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="k">def</span> <span class="nf">add_one_to_array</span><span class="p">(</span><span class="n">old_array</span><span class="p">)</span>
</span><span class='line'>  <span class="n">old_array</span><span class="o">.</span><span class="n">map</span> <span class="k">do</span> <span class="o">|</span><span class="n">element</span><span class="o">|</span>
</span><span class='line'>    <span class="n">element</span> <span class="o">+</span> <span class="mi">1</span>
</span><span class='line'>  <span class="k">end</span>
</span><span class='line'><span class="k">end</span>
</span></code></pre></td></tr></table></div></figure>


<p>When you call <code>.each</code> on an Enumerable (the module that handles all sorts of
stuff regarding working with arrays and other collections), all <code>.each</code> does is
execute whatever is in the block (everything inside the do&hellip;end in each method
is a block). Thats why the code in the first example has to actually do the
heavy lifting of pushing data into the <code>new_array</code> variable.</p>

<p>The <code>.map</code> method on Enumerable does a bit more for you: it uses the return
value of the block you pass to it, and collects all the return values from
running the block with each element, turning that into a new array. You don&rsquo;t
have to bother creating a variable and assigning it into an empty array,
explicitly updating the array, or even returning the array. The return
value of <code>.map</code> is the array that results.</p>

<p>It also tells everyone reading the code something very important: the code that
follows takes some code and uses it to transform one array into another. With
<code>.each</code>, it could do anything, so you have to carefully read the code to ensure
it doesn&rsquo;t do something weird.</p>

<p>There&rsquo;s a whole bunch of helpful methods defined on Enumerable, and the
<a href="http://ruby-doc.org/core-2.1.5/Enumerable.html">docs</a> are quite helpful. They
all do different things, but the idea is similar: they all work on a collection
of some sort, and each one can be thought of as a single, specialized, powerful
tool. Go read through the documentation and fool around with a couple.</p>

<p>The best part about is all this functionality is available across many
languages.  After a while, you&rsquo;ll be able to jump into countless languages:
Scala, Javascript, Haskell, and of course all the Lisps share these ideas, even
if the details or names differ.</p>

<p>Rather than simply learning the quirks of a Ruby library, you&rsquo;re learning a
vocabulary and toolset that all functional programming languages share!</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Deconstructing Fizz Buzz with Flip-Flops in Ruby]]></title>
    <link href="https://juliansimioni.com/blog/deconstructing-fizz-buzz-with-flip-flops-in-ruby/"/>
    <updated>2014-12-03T15:53:52+01:00</updated>
    <id>https://juliansimioni.com/blog/deconstructing-fizz-buzz-with-flip-flops-in-ruby</id>
    <content type="html"><![CDATA[<p>Ruby is small. If it&rsquo;s not your first programming language, picking up all the basic syntax in a
weekend isn&rsquo;t out of the question. I&rsquo;ve been writing and reading Ruby code for several years now,
and figured I was closing in on at least familiarity with all the core concepts.</p>

<p>Of course, there&rsquo;s always more to learn, and there were more than a few very experienced Ruby
programmers that learned about a new operator last week: the
<a href="http://nithinbekal.com/posts/ruby-flip-flop/">flip-flop</a>.</p>

<p>Nithin&rsquo;s blog post gives a great overview of the syntax, so lets look at a more complicated example
from <a href="http://www.reddit.com/r/ruby/comments/2n987g/the_flip_flop_operator_in_ruby/cmbiwt8?context=1">Reddit</a>:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
</pre></td><td class='code'><pre><code class='Ruby'><span class='line'><span class="n">a</span><span class="o">=</span><span class="n">b</span><span class="o">=</span><span class="n">c</span><span class="o">=</span><span class="p">(</span><span class="mi">1</span><span class="o">.</span><span class="n">.</span><span class="mi">100</span><span class="p">)</span><span class="o">.</span><span class="n">each</span> <span class="k">do</span> <span class="o">|</span><span class="n">num</span><span class="o">|</span>
</span><span class='line'>  <span class="nb">print</span> <span class="n">num</span><span class="p">,</span> <span class="sc">?\r</span><span class="p">,</span>
</span><span class='line'>    <span class="p">(</span><span class="s2">&quot;Fizz&quot;</span> <span class="k">unless</span> <span class="p">(</span><span class="n">a</span> <span class="o">=</span> <span class="o">!</span><span class="n">a</span><span class="p">)</span> <span class="o">.</span><span class="n">.</span> <span class="p">(</span><span class="n">a</span> <span class="o">=</span> <span class="o">!</span><span class="n">a</span><span class="p">)),</span>
</span><span class='line'>    <span class="p">(</span><span class="s2">&quot;Buzz&quot;</span> <span class="k">unless</span> <span class="p">(</span><span class="n">b</span> <span class="o">=</span> <span class="o">!</span><span class="n">b</span><span class="p">)</span> <span class="o">.</span><span class="n">.</span><span class="o">.</span> <span class="o">!</span><span class="p">((</span><span class="n">c</span> <span class="o">=</span> <span class="o">!</span><span class="n">c</span><span class="p">)</span> <span class="o">.</span><span class="n">.</span> <span class="p">(</span><span class="n">c</span> <span class="o">=</span> <span class="o">!</span><span class="n">c</span><span class="p">))),</span>
</span><span class='line'>    <span class="sc">?\n</span>
</span><span class='line'><span class="k">end</span>
</span></code></pre></td></tr></table></div></figure>


<p>This code clearly came from an obfuscation contest<sup><a href="#d9dc:fn:1" class="footnote" id="d9dc:fn-back:1">1</a></sup>, and I&rsquo;m not even going to attempt to suggest
that I understood how this code worked after first reading it. But I was intrigued.  Never mind the
flip-flop operator, most of this code looks unfamiliar to someone used to reading idiomatic Ruby,
and I wanted to know how it all worked. So lets break it down piece by piece, and see if some sense
can be made.</p>

<h2>Starting out with some assignment</h2>

<p>The first line is perhaps the most normal. Chaining assignment is used frequently in many languages.
And while many of the methods we use in
<a href="http://ruby-doc.org/core-2.1.5/Enumerable.html">Enumerable</a>, like <code>map</code>, return something useful,
the <code>each</code> method is actually defined on the <code>Range</code> class, and just
<a href="http://www.ruby-doc.org/core-2.1.5/Range.html#method-i-each">returns the range</a>.</p>

<p>But the code above uses the <code>a</code>, <code>b</code>, and <code>c</code> variables <em>before</em> the <code>each</code> iterator finishes, what is
their value then? Let&rsquo;s run a simple test script to find out:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
</pre></td><td class='code'><pre><code class='Ruby'><span class='line'><span class="c1"># a no-op each</span>
</span><span class='line'><span class="n">a</span> <span class="o">=</span> <span class="p">(</span><span class="mi">1</span><span class="o">.</span><span class="n">.</span><span class="mi">2</span><span class="p">)</span><span class="o">.</span><span class="n">each</span> <span class="k">do</span> <span class="o">|</span><span class="n">num</span><span class="o">|</span>
</span><span class='line'>  <span class="nb">puts</span> <span class="n">a</span><span class="o">.</span><span class="n">inspect</span> <span class="c1"># =&gt; nil</span>
</span><span class='line'><span class="k">end</span>
</span><span class='line'><span class="nb">puts</span> <span class="n">a</span><span class="o">.</span><span class="n">inspect</span> <span class="c1"># =&gt; (1..2)</span>
</span></code></pre></td></tr></table></div></figure>


<p>Aha, it just is set to nil. Of course a variable that isn&rsquo;t first initialized will throw an error,
so this first line is really just a short way of initializing the <code>a</code>, <code>b</code> and <code>c</code> variables to
<em>something</em>, before the start of the iterator. Let&rsquo;s do out first refactor of the code then, to make
it more readable:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
</pre></td><td class='code'><pre><code class='Ruby'><span class='line'><span class="n">a</span> <span class="o">=</span> <span class="n">b</span> <span class="o">=</span> <span class="n">c</span> <span class="o">=</span> <span class="kp">nil</span>
</span><span class='line'><span class="p">(</span><span class="mi">1</span><span class="o">.</span><span class="n">.</span><span class="mi">100</span><span class="p">)</span><span class="o">.</span><span class="n">each</span> <span class="k">do</span> <span class="o">|</span><span class="n">num</span><span class="o">|</span>
</span><span class='line'>  <span class="nb">print</span> <span class="n">num</span><span class="p">,</span> <span class="sc">?\r</span><span class="p">,</span>
</span><span class='line'>    <span class="p">(</span><span class="s2">&quot;Fizz&quot;</span> <span class="k">unless</span> <span class="p">(</span><span class="n">a</span> <span class="o">=</span> <span class="o">!</span><span class="n">a</span><span class="p">)</span> <span class="o">.</span><span class="n">.</span> <span class="p">(</span><span class="n">a</span> <span class="o">=</span> <span class="o">!</span><span class="n">a</span><span class="p">)),</span>
</span><span class='line'>    <span class="p">(</span><span class="s2">&quot;Buzz&quot;</span> <span class="k">unless</span> <span class="p">(</span><span class="n">b</span> <span class="o">=</span> <span class="o">!</span><span class="n">b</span><span class="p">)</span> <span class="o">.</span><span class="n">.</span><span class="o">.</span> <span class="o">!</span><span class="p">((</span><span class="n">c</span> <span class="o">=</span> <span class="o">!</span><span class="n">c</span><span class="p">)</span> <span class="o">.</span><span class="n">.</span> <span class="p">(</span><span class="n">c</span> <span class="o">=</span> <span class="o">!</span><span class="n">c</span><span class="p">))),</span>
</span><span class='line'>    <span class="sc">?\n</span>
</span><span class='line'><span class="k">end</span>
</span></code></pre></td></tr></table></div></figure>


<p>This code works the same way, so we know it was really a refactoring, with no changes to the
behavior of the code.</p>

<h2>Fun with Printing</h2>

<p>The next line is actually the entire body of the block passed to <code>each</code>: the
<a href="http://ruby-doc.org/core-2.0.0/Kernel.html#method-i-print">print</a> method takes multiple arguments,
and notably, does not automatically print a newline at the end (<code>puts</code> on the other hand, does
always print a newline).</p>

<p>But what in the world does <code>?\r</code> do? It turns out to be a poorly-documented
<a href="http://en.wikibooks.org/wiki/Ruby_Programming/Syntax/Literals">character literal</a>.
It&rsquo;s one character shorter than creating a string, such as <code>"\r"</code>, but with the same result.</p>

<p>And what is <code>"\r"</code> anyway? It&rsquo;s a <a href="http://en.wikipedia.org/wiki/Carriage_return">carriage return</a>,
the little known sibling of the newline. Even in the 21st century, our computer screens still
basically behave like a typewriter. Advancing to the next line and moving the cursor to the start
of the line are two distinct actions, and so they have distinct character codes. Of course, the fact
that Windows requires both a carriage return and a newline character, whereas Linux and OS X systems
assume a carriage return with just a newline<sup><a href="#d9dc:fn:2" class="footnote" id="d9dc:fn-back:2">2</a></sup>, creates more than a little confusion.</p>

<p>So, in any case, what sort of behavior can a carriage return character give us? Let&rsquo;s run a few
experiments:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class='Ruby'><span class='line'><span class="nb">print</span> <span class="s2">&quot;hello&quot;</span><span class="p">,</span> <span class="s2">&quot; &quot;</span><span class="p">,</span>  <span class="s2">&quot;world&quot;</span><span class="p">,</span> <span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span> <span class="c1"># =&gt; hello world</span>
</span><span class='line'><span class="nb">print</span> <span class="s2">&quot;hello&quot;</span><span class="p">,</span> <span class="s2">&quot;</span><span class="se">\r</span><span class="s2">&quot;</span><span class="p">,</span> <span class="s2">&quot;world&quot;</span><span class="p">,</span> <span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span> <span class="c1"># =&gt; world</span>
</span><span class='line'><span class="nb">print</span> <span class="s2">&quot;hello&quot;</span><span class="p">,</span> <span class="s2">&quot;</span><span class="se">\r</span><span class="s2">&quot;</span><span class="p">,</span> <span class="kp">nil</span>    <span class="p">,</span> <span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span> <span class="c1"># =&gt; hello</span>
</span></code></pre></td></tr></table></div></figure>


<p>How interesting! A carriage return lets us write some text, and then later while writing the same
line, essentially decide to erase that text. Remembering the requirements of the Fizz Buzz problem,
and how one must ONLY print a number when neither Fizz nor Buzz are printed, the utility of this
behavior is obvious.</p>

<h2>Finally, flip-flop</h2>

<p>At this point we can easily describe the overall structure of the code: it loops through the numbers
1 to 100, using control characters to optimistically print the number, and then based on the logic
of flip-flops, print Fizz and/or Buzz instead of the number when appropriate. But when is the
&ldquo;appropriate&rdquo; time to print Fizz or Buzz? And how does a flip-flop and only three temporary
variables achieve that? Lets take a look at just the first use of the flip-flop, on line 3 of the
original code.</p>

<p>The first thing to note is that the conditions of the flip-flop operator are actually assignment.
This took me a long while to spot, and indeed is a
<a href="http://cwe.mitre.org/data/definitions/481.html">common</a> source of bugs. In this case though, it&rsquo;s
not a bug, its a feature.</p>

<p>The flip-flop operator is going to evaluate the &ldquo;truthiness&rdquo; of whatever expression is inside it,
and remembering that the assignment operator in many languages returns a value, we can figure out
what the flip-flop operator will do.</p>

<p>We know the initial value of <code>a</code>, <code>b</code>, and <code>c</code> is nil, so lets start there.</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class='Ruby'><span class='line'><span class="nb">puts</span> <span class="p">(</span><span class="o">!</span><span class="kp">nil</span><span class="p">)</span><span class="o">.</span><span class="n">inspect</span>   <span class="c1"># =&gt; true</span>
</span><span class='line'><span class="nb">puts</span> <span class="p">(</span><span class="o">!</span><span class="kp">true</span><span class="p">)</span><span class="o">.</span><span class="n">inspect</span>  <span class="c1"># =&gt; false</span>
</span><span class='line'><span class="nb">puts</span> <span class="p">(</span><span class="o">!</span><span class="kp">false</span><span class="p">)</span><span class="o">.</span><span class="n">inspect</span> <span class="c1"># =&gt; true</span>
</span></code></pre></td></tr></table></div></figure>


<p>So each invocation of one &ldquo;side&rdquo; of the flip-flop will gracefully handle the initial nil value of
the variables, and then swap them between true and false. The flip-flop operator consists of two
identical expressions though, so what behavior will that produce?</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
</pre></td><td class='code'><pre><code class='Ruby'><span class='line'><span class="n">a</span> <span class="o">=</span> <span class="kp">nil</span>
</span><span class='line'><span class="p">(</span><span class="mi">1</span><span class="o">.</span><span class="n">.</span><span class="mi">9</span><span class="p">)</span><span class="o">.</span><span class="n">each</span> <span class="k">do</span> <span class="o">|</span><span class="n">n</span><span class="o">|</span>
</span><span class='line'>  <span class="nb">puts</span> <span class="s2">&quot;</span><span class="si">#{</span><span class="n">n</span><span class="si">}</span><span class="s2"> </span><span class="si">#{</span><span class="n">a</span><span class="o">.</span><span class="n">inspect</span><span class="si">}</span><span class="s2">&quot;</span>
</span><span class='line'>  <span class="s2">&quot;Fizz&quot;</span> <span class="k">unless</span> <span class="p">(</span><span class="n">a</span> <span class="o">=</span> <span class="o">!</span><span class="n">a</span><span class="p">)</span> <span class="o">.</span><span class="n">.</span> <span class="p">(</span><span class="n">a</span> <span class="o">=</span> <span class="o">!</span><span class="n">a</span><span class="p">)</span> <span class="c1"># no output here, we just care about the changes to a</span>
</span><span class='line'><span class="k">end</span>
</span><span class='line'><span class="c1"># =&gt;</span>
</span><span class='line'><span class="c1"># 1 nil</span>
</span><span class='line'><span class="c1"># 2 false</span>
</span><span class='line'><span class="c1"># 3 true</span>
</span><span class='line'><span class="c1"># 4 false</span>
</span><span class='line'><span class="c1"># 5 false</span>
</span><span class='line'><span class="c1"># 6 true</span>
</span><span class='line'><span class="c1"># 7 false</span>
</span><span class='line'><span class="c1"># 8 false</span>
</span><span class='line'><span class="c1"># 9 true</span>
</span></code></pre></td></tr></table></div></figure>


<p>So the flip-flop operator, with just a single state variable, is able to create a pattern that sets
a to true every third time! This is exactly how often we want to print &ldquo;Fizz&rdquo;!</p>

<p>How does this happen? If the only operation used is negating a boolean, the boolean will return to
its original value after an even number of operations. So how are an even number (maybe 2, 4 or
6) of operations squeezed into three runs of a loop? Lets investigate the value of <code>a</code> after each
condition of the flip-flop, rather than once per loop. We&rsquo;ll use two simple functions to print
within the conditions of the flip-flop:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
<span class='line-number'>24</span>
<span class='line-number'>25</span>
<span class='line-number'>26</span>
<span class='line-number'>27</span>
</pre></td><td class='code'><pre><code class='Ruby'><span class='line'><span class="c1"># given a value, print its negation, then return its negation</span>
</span><span class='line'><span class="k">def</span> <span class="nf">print_negate1</span><span class="p">(</span><span class="n">value</span><span class="p">)</span>
</span><span class='line'>  <span class="nb">puts</span> <span class="s2">&quot;a </span><span class="si">#{</span><span class="p">(</span><span class="o">!</span><span class="n">value</span><span class="p">)</span><span class="o">.</span><span class="n">inspect</span><span class="si">}</span><span class="s2">&quot;</span>
</span><span class='line'>  <span class="o">!</span><span class="n">value</span>
</span><span class='line'><span class="k">end</span>
</span><span class='line'>
</span><span class='line'><span class="c1">#same as above, but print b instead of a so we can tell</span>
</span><span class='line'><span class="c1">#which condition is being checked</span>
</span><span class='line'><span class="k">def</span> <span class="nf">print_negate2</span><span class="p">(</span><span class="n">value</span><span class="p">)</span>
</span><span class='line'>  <span class="nb">puts</span> <span class="s2">&quot;b </span><span class="si">#{</span><span class="p">(</span><span class="o">!</span><span class="n">value</span><span class="p">)</span><span class="o">.</span><span class="n">inspect</span><span class="si">}</span><span class="s2">&quot;</span>
</span><span class='line'>  <span class="o">!</span><span class="n">value</span>
</span><span class='line'><span class="k">end</span>
</span><span class='line'>
</span><span class='line'><span class="n">a</span> <span class="o">=</span> <span class="kp">nil</span>
</span><span class='line'><span class="p">(</span><span class="mi">1</span><span class="o">.</span><span class="n">.</span><span class="mi">3</span><span class="p">)</span><span class="o">.</span><span class="n">each</span> <span class="k">do</span> <span class="o">|</span><span class="n">n</span><span class="o">|</span>
</span><span class='line'>  <span class="nb">puts</span> <span class="s2">&quot;</span><span class="si">#{</span><span class="n">n</span><span class="si">}</span><span class="s2">&quot;</span>
</span><span class='line'>  <span class="s2">&quot;Fizz&quot;</span> <span class="k">unless</span> <span class="p">(</span><span class="n">a</span> <span class="o">=</span> <span class="n">print_negate1</span><span class="p">(</span><span class="n">a</span><span class="p">))</span> <span class="o">.</span><span class="n">.</span> <span class="p">(</span><span class="n">a</span> <span class="o">=</span> <span class="n">print_negate2</span><span class="p">(</span><span class="n">a</span><span class="p">))</span>
</span><span class='line'><span class="k">end</span>
</span><span class='line'>
</span><span class='line'><span class="c1"># =&gt;</span>
</span><span class='line'><span class="c1"># 1</span>
</span><span class='line'><span class="c1"># a true</span>
</span><span class='line'><span class="c1"># b false</span>
</span><span class='line'><span class="c1"># 2</span>
</span><span class='line'><span class="c1"># b true</span>
</span><span class='line'><span class="c1"># 3</span>
</span><span class='line'><span class="c1"># a false</span>
</span></code></pre></td></tr></table></div></figure>


<p>As can be seen in the output, the flip-flop operator does indeed cause <code>print_negate</code> to be called 4
times in every 3 iterations. How? The first time through, the first flip-flop condition evaluates to
true (nil negated is true), so the second condition is checked, and <code>a</code> is set to false (true
negated is false).</p>

<p>The flip-flop is now &ldquo;open&rdquo;. It will only check the second condition now. In the second iteration of
the loop, the flip-flop checks if should &ldquo;close&rdquo;. False negated is true, so the flip-flop does
close. Finally, in the third iteration, the flip-flop checks only if it should open. True negated is
false, so it stays closed, and the cycle repeats.</p>

<p>There&rsquo;s one more complication: the flip-flop doesn&rsquo;t return based on the value of <code>a</code>, but on its
internal state. A flip-flop starts &ldquo;closed&rdquo;, meaning it will return false. Once the first condition
evaluates to true, it is &ldquo;open&rdquo;, and will return true until the second conditional returns true,
&ldquo;closing&rdquo; the flip-flop. So what is the state of the flip-flop after each of the 3 cycles above?</p>

<p>The first time, it starts closed, opens, and then does not close. Because of the <code>unless</code>, this does
not print &ldquo;Fizz&rdquo;. The second time, it starts open, and closes, but still returns true, since &ldquo;Fizz&rdquo;
is again not printed. Finally, the flip-flop fails to open at all in the third iteration, and thus
returns false. This allows &ldquo;Fizz&rdquo; to be printed, exactly when needed.</p>

<p>So an interesting property of the flip-flop is that it returns true if it starts open, but then
closes.</p>

<h2>Buzz!</h2>

<p>After dissecting the logic for printing &ldquo;Fizz&rdquo;, we can describe without even reading the code
how &ldquo;Buzz&rdquo; will be printed: two variables will be used with some flip-flops to create a cycle that
repeats every 5 iterations of the loop.</p>

<p>But that description leaves a lot of the details, and in fact there&rsquo;s quite a bit more to be
learned. Looking at line 4 in the original code, the first thing we notice is a new operator, or at
least a variation: here there is a familiar flip-flop nested in the second conditional of what looks
like another flip-flop operator at first glance. However its important to note this flip-flop
consists of three dots (<code>...</code>) rather than the more familiar two (<code>..</code>). What&rsquo;s the difference?
Using our test code from above with this variant tells us:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
</pre></td><td class='code'><pre><code class='Ruby'><span class='line'><span class="n">a</span> <span class="o">=</span> <span class="kp">nil</span>
</span><span class='line'><span class="p">(</span><span class="mi">1</span><span class="o">.</span><span class="n">.</span><span class="mi">9</span><span class="p">)</span><span class="o">.</span><span class="n">each</span> <span class="k">do</span> <span class="o">|</span><span class="n">n</span><span class="o">|</span>
</span><span class='line'>  <span class="nb">puts</span> <span class="s2">&quot;</span><span class="si">#{</span><span class="n">n</span><span class="si">}</span><span class="s2"> </span><span class="si">#{</span><span class="n">a</span><span class="o">.</span><span class="n">inspect</span><span class="si">}</span><span class="s2">&quot;</span>
</span><span class='line'>  <span class="s2">&quot;Fizz&quot;</span> <span class="k">unless</span> <span class="p">(</span><span class="n">a</span> <span class="o">=</span> <span class="o">!</span><span class="n">a</span><span class="p">)</span> <span class="o">.</span><span class="n">.</span><span class="o">.</span> <span class="p">(</span><span class="n">a</span> <span class="o">=</span> <span class="o">!</span><span class="n">a</span><span class="p">)</span>
</span><span class='line'><span class="k">end</span>
</span><span class='line'><span class="c1"># =&gt;</span>
</span><span class='line'><span class="c1"># 1 nil</span>
</span><span class='line'><span class="c1"># 2 true</span>
</span><span class='line'><span class="c1"># 3 false</span>
</span><span class='line'><span class="c1"># 4 true</span>
</span><span class='line'><span class="c1"># 5 false</span>
</span><span class='line'><span class="c1"># 6 true</span>
</span><span class='line'><span class="c1"># 7 false</span>
</span><span class='line'><span class="c1"># 8 true</span>
</span><span class='line'><span class="c1"># 9 false</span>
</span></code></pre></td></tr></table></div></figure>


<p>This variant simply alternates between true and false, meaning it has an odd number of negations in
every cycle. Theres not much Ruby documentation on the flip-flop operator, but the
<a href="http://perldoc.perl.org/perlop.html">Perl</a> documentation describes the difference:</p>

<blockquote><p>If you don&#8217;t want it to test the right operand until the next evaluation, as in sed, just use<br/>three dots (&#8220;&#8230;&#8221;) instead of two. In all other regards, &#8220;&#8230;&#8221; behaves just like &#8220;..&#8221; does.</p></blockquote>


<p>The Ruby flip-flop behaves the same way, and therefore will only ever perform one negation per
iteration of the loop. Another way to describe the difference: the first flip-flop variant will
allow itself to open and close in the same invocation, whereas the second will not.</p>

<p>Instead of instrumenting all 3 conditionals in the two flip-flops for this part of the code, lets
see if we can just reason about it, and describe how it works.</p>

<p>First, we recognise the inside of the second conditional: its the exact same pattern as in the
&ldquo;Fizz&rdquo; line, but with the <code>c</code> variable. We therefore know that it will cycle through returning true,
true, false. However, its output is negated, so the second conditional in the first flip-flop is
going to cycle through false, false, and true. Lets work through a couple iterations of the loop and
see where this goes.</p>

<p>The first time through, <code>b</code> and <code>c</code> are both nil, and both flip-flops are closed. The first flip-flop
will evaluate <code>b = !b</code> to determine if it should open. That will set <code>b</code> to true and return true, so
the first flip-flop is now open. This flip-flop variant doesn&rsquo;t check if it should immediately
close, so we&rsquo;re done.</p>

<p>The second time through, the first flip-flop checks the second conditional to see if it should
close. We don&rsquo;t need to work through the logic of the second flip-flop, we know it will return false
this time, and so the flip-flop stays open. Remember, the <code>unless</code> statement means we will only
print &ldquo;Buzz&rdquo; when the flip-flop returns false(is closed)!</p>

<p>We also know the result of the third time through: the flip-flop is open, and again the second-flip
flop will return false; the first flip-flop stays open, and nothing is printed.</p>

<p>The fourth time, the first flip-flop DOES close. However, remember that a flip-flop returns true
when it transitions from open to closed, so once again we don&rsquo;t print anything.</p>

<p>On the fifth iteration, the flip-flop starts closed, <code>b</code> is currently true. The first
conditional of the flip-flop is evaluated, and the result is false! This means the flip-flop doesn&rsquo;t
open, returns false, and finally, &ldquo;Buzz&rdquo; is printed, exactly when we need it.</p>

<h2>Fin</h2>

<p>Wow, that was some serious thought for just a few lines of code. I&rsquo;ve put all the example code
on <a href="https://github.com/orangejulius/ruby-flip-flop">Github</a>, feel free to fool around further.</p>

<p>Needless to say, while I enjoyed the exercise, like most of the Perl-isms in Ruby, I won&rsquo;t be using
flip-flops in production code any time soon.</p>

<hr />

<ol class="footnotelist"><p><li id="d9dc:fn:1" class="footnotebody" value="1">
If anyone knows or is the author, let me know!
<a href="#d9dc:fn-back:1" class="backlink">⏎</a></li></p>

<p><li id="d9dc:fn:2" class="footnotebody" value="2">
Probably a gross simplification or outright lie. If anyone wants to suggest a more accurate
explanation that is also concise, please do!
<a href="#d9dc:fn-back:2" class="backlink">⏎</a></li></p>
</ol>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Three Git Commands You Should Never Use]]></title>
    <link href="https://juliansimioni.com/blog/three-git-commands-you-should-never-use/"/>
    <updated>2014-09-04T21:17:00-08:00</updated>
    <id>https://juliansimioni.com/blog/three-git-commands-you-should-never-use</id>
    <content type="html"><![CDATA[<p>Ahh, Git. One of the most powerful tools of our time. Also, one of the most confusing. There&rsquo;s no
doubt that Git has a few rough edges.</p>

<p>Many complain that Git is too difficult to use, and that it&rsquo;s easy to shoot yourself in the foot.
I&rsquo;d agree to an extent, but in my experience, Git also gives you the tools to fix any problems you
cause.</p>

<p>In my mind the most dangerous commands in Git aren&rsquo;t things like <code>git rebase</code>, because any mistakes
you make with already committed data can be fixed (perhaps with a little help from <code>git reflog</code>).</p>

<p>Instead, the most dangerous commands in Git are those that prevent you from getting your data into
Git correctly in the first place, those that make the Git history harder to read than it had to
be, or those that behave unpredictably and hide too much information from the user.</p>

<p>These commands are quite popular, but I stand firm, you should never use any of them.</p>

<h2>git commit -a</h2>

<p>On the surface, <code>git commit -a</code> is just a timesaver, and who doesn&rsquo;t like to save time? In
principle, there&rsquo;s nothing wrong with a command to commit everything at once. But in practice, I
find that invariably when using <code>git commit -a</code>, something not meant to be committed will be
committed. Big surprise. It might be a harmless <code>console.log</code>, or it could be massive temporary
simplification of a critical bit of code.</p>

<p>I like to take a second before each commit and review exactly what is going in. I&rsquo;ve set up a
helpful <code>git st</code> <a href="https://github.com/orangejulius/dotfiles/blob/master/gitconfig#L8">alias</a> that
shows me a denser version of <code>git status</code>.</p>

<p>Usually, I&rsquo;ll use one of my favorite little known Git features, <code>git commit -p</code> (<code>git
checkout</code>, <code>git stash</code>, and many other commands also accept the <code>-p</code> flag), which will go through
each section of changed code and ask whether or not you want to commit it. It comes with handy
keyboard shortcuts meaning you can go through lots of code in only a few seconds, and if anything is
there that shouldn&rsquo;t be committed, you can skip right over it.</p>

<h2>git commit -m</h2>

<p>There are two reasons why I hate <code>git commit -m</code>.</p>

<p>First, it leads to short, unhelpful commit messages. On any size team (even a team of one),
commit messages are one of the most useful ways to record knowledge from that critical time when code
is actually written. <code>git commit -m "fixed big"</code> throws that opportunity right out the window.</p>

<p>Please everyone take a second and write awesome commit messages. Did you know Git commit messages
have a <a href="http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html">well established format</a> that all editors will
help you with, and allows writing as much of a description as you want? It wasn&rsquo;t written for
nothing.</p>

<p>Second, did you know that Git will sometimes write your commit message for you? It&rsquo;s true! Whenever you
perform a merge that isn&rsquo;t simply a fast-forward, Git will generate a beautiful commit message
automatically.  It records which branch was merged into which right in the commit subject, and puts
a list of any files that had conflicts in the body. Those are the most likely places where bugs
might have sprung up, so the value of keeping track of them should be clear.</p>

<p>You get all this for free, unless you use <code>git commit -m</code>.</p>

<h2>git pull</h2>

<p>Of the three commands, this is probably the most used. As a result, the negative effects will be
felt the strongest. And what bad thing happens with <code>git pull</code>? Nothing less than a permanently
confusing history (gasp)! While it&rsquo;s true that one can figure out what happened with even the most
convoluted history, why would you inflict that upon your friends, colleagues, and coworkers if you
don&rsquo;t have to?</p>

<p>So how does it happen? It takes three steps:</p>

<ol>
<li>Work is done by you directly on the master branch (or whichever branch will be pulled from
eventually).</li>
<li>Someone else also works directly on the branch and pushes their changes first.</li>
<li><code>git pull</code> is run and a merge commit is generated for even trivial and completely independent
changes.</li>
</ol>


<p>Taken on its own, one extra merge commit is not a big deal. But if even two or three people are not
working to prevent unneeded merge commits, things get nasty real fast.<sup><a href="#bb24:fn:1" class="footnote" id="bb24:fn-back:1">1</a></sup></p>

<p>The dangers of <code>git pull</code> come partially from it&rsquo;s bloated nature: it both fetches updates from
others, and immediately and automatically decides how to reconcile those changes with yours. This
should be two steps.</p>

<p>My workflow is to periodically run <code>git fetch</code>. This ONLY updates my remote branches, so I can see
what work others have done. Usually, I&rsquo;ll quickly inspect the changes that have been pushed using
another great <a href="https://github.com/orangejulius/dotfiles/blob/master/gitconfig#L7">alias</a>, <code>git lg</code>.
Finally I decide what to do. Usually I simply want to make a linear history with my changes coming
after the changes I just pulled. <code>git rebase</code> will accomplish this just fine, and then if it turns
out the resulting conflict resolution is difficult, I can abort the rebase or start over and know
exactly where thing stand.</p>

<p>On the other hand, even with <code>git pull --rebase</code> (which is a more sensible default than to merge),
any conflict resolution is done immediately. There wasn&rsquo;t a chance for you to figure out what sort
of changes were just pulled in (are they huge refactorings that will change a lot and require
careful analysis? Or were they simple changes that shouldn&rsquo;t be a big deal), so resolving the
conflicts is also hard. And what will the state of your working copy be after you abort the conflict
resolution? Good question.</p>

<h2>In summary</h2>

<p>Everything that I believe makes for good Git usage comes from a few simple rules: understand what is
happening under the hood, use source control as a great source of information, and play nice with
others.</p>

<p>These are a few things that don&rsquo;t work with those rules, next time I&rsquo;ll cover some ways to follow
them.</p>

<hr />

<ol class="footnotelist"><p><li id="bb24:fn:1" class="footnotebody" value="1">
For a great example of good and bad merge commits: check out <a href="https://gist.github.com/jbenet/ee6c9ac48068889b0912">this</a> helpful Gist.
<a href="#bb24:fn-back:1" class="backlink">⏎</a></li></p>
</ol>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[The FAA Made the Right Call on Plane Sharing]]></title>
    <link href="https://juliansimioni.com/blog/the-faa-made-the-right-call-on-plane-sharing/"/>
    <updated>2014-08-25T21:18:00-07:00</updated>
    <id>https://juliansimioni.com/blog/the-faa-made-the-right-call-on-plane-sharing</id>
    <content type="html"><![CDATA[<p>About two years ago I had just received my <a href="https://juliansimioni.com/blog/my-private-pilot-checkride/">private pilot&rsquo;s license</a> and
was excited to share my love of aviation with my friends. My first few flights were never unsafe, but they had their
share of moments that showed just how little one knows even after training with an excellent instructor.</p>

<p>I learned a lot from those first few flights, and I still learn something new with every flight. That should come as no
surprise: pilots that have been flying for decades, and logged tens of thousands of hours in all types of aircraft say
the same. I made a few passengers nervous early on<sup><a href="#4274:fn:1" class="footnote" id="4274:fn-back:1">1</a></sup>, but over time I&rsquo;ve improve not just my flying but my ability to
make my passengers feel calm and safe. I&rsquo;ve had one friend say she overcame her fear of flying commercial just from
flying with me once!</p>

<p>As it happens, the FAA allows me to share the costs of flying with my friends, but only under a very narrow set of
circumstances. Anything beyond that, and I&rsquo;m required to at least have a commercial pilot&rsquo;s license, and possibly comply
with even more regulations. This make sense for ensuring the safety we expect of airlines, but would be impossible for
pilots flying on their own to afford. I have to say that this allows me far more opportunity to share my love of
aviation with my friends than would otherwise be possible, and my flying has improved in the process.</p>

<p>Of course, after the success of companies like Uber and Lyft, it should come as no surprise that someone would
try to adapt the ride-sharing model to general aviation. In fact, at least two such companies have appeared:
<a href="https://flytenow.com">Flytenow</a> and <a href="https://airpooler.com">Airpooler</a>. Both companies offered an
interpretation of FAA regulations that allow their users to share the costs of travel with their passengers under the
same exception that allows me to share expenses with my friends when I fly.</p>

<p>And to their credit, both companies were proactive and reached out to the FAA hoping for clarification and a blessing.</p>

<p>Pilots have been trying to cleverly skirt around these regulations forever (&ldquo;okay, you fly me to New York for free, but
then I&rsquo;ll buy that pen off you for $500&rdquo;) and the FAA has always stated clearly that there are no loopholes<sup><a href="#4274:fn:2" class="footnote" id="4274:fn-back:2">2</a></sup>. So when
those of us in aviation who also follow the happenings of tech companies heard about Flytenow and Airpooler, many of us
were hesitant to try it out. We all know the regulations (our flight instructors no doubt drilled it into our heads
during our training), and there&rsquo;s no mistake that our license in on the line.</p>

<p>It didn&rsquo;t come as a surprise to many pilots when the FAA issued their ruling last week: flight-sharing websites <a href="http://www.faa.gov/about/office_org/headquarters_offices/agc/pol_adjudication/agc200/Interpretations/data/interps/2014/MacPherson-JonesDay%20-%20%282014%29%20Legal%20Interpretation.pdf">violate FAA regulations</a>.</p>

<p>But, of course, governing bodies have come out and ruled against many tech companies. And in those cases many hold the
opinion that the laws are wrong, the government is corrupt, and the tech companies are helping everyone by offering a
little competition to a stagnant industry. So the same logic should be applied here, and we should all lobby the FAA to
allow plane-sharing, right?</p>

<p>Well, not so fast. It&rsquo;s worth taking a minute and examining if the situation really is the same here.</p>

<h2>What good are the regulations anyway?</h2>

<p>I&rsquo;ve always felt that many laws and regulations do more harm than good. Part of the popularity of companies like Uber, and Lyft
comes not just from their product itself but from excitement about giving slow-moving monopolies or oligopolies like the
taxi companies some much needed competition.</p>

<p>I admit myself I find it interesting that I&rsquo;m taking this side. But what I&rsquo;ve also found interesting is that after hours
of reading FAA regulations both during and after my private pilot training, I&rsquo;ve found them to be extremely sensible, if
a bit complicated.</p>

<p>It wasn&rsquo;t always the case, but flying today is incredibly safe. Through decades of work, aviation experts have analyzed
every aspect of flying, from everyday occurrences to the most unusual of incidents<sup><a href="#4274:fn:3" class="footnote" id="4274:fn-back:3">3</a></sup>. While the taxi industry lobbied
to create things like the <a href="http://en.wikipedia.org/wiki/Medallion_taxi#Medallions">medallion system</a> and car accidents
grew to one of the <a href="http://en.wikipedia.org/wiki/List_of_causes_of_death_by_rate">leading causes of death</a> in the United
States, aviation has become dramatically <a href="http://www.aopa.org/About-AOPA/General-Aviation-Statistics/General-Aviation-Safety-Record-Current-and-Historic">safer over time</a>:
the 2010 fatality rate in general aviation is half that what it was in 1970.</p>

<p>Why? As the saying goes: flying is not inherently dangerous, but it is unforgiving. Unlike other industries, where
lobbying and public opinion have overridden careful analysis, with aviation the stakes are high, and the
consequences of even a minor oversight dire. Things that don&rsquo;t work have a much harder time sticking.</p>

<p>That&rsquo;s not to say all in aviation is perfect, but more than any other part of the government I can think of, the aviation
industry uses real data and real science to make decisions.</p>

<h2>A Question of Scale</h2>

<p>Many argued that there is no difference between asking a few friends if they want to go on a weekend flying trip,
posting a paper ad on the bulletin board of your local airport offering to share flight expenses, and using the
internet, perhaps with a flight-sharing app, to extend the same offer to thousands of people. In some senses, this is
true.</p>

<p>However, the key difference, and why the FAA allows a pilot to ask a few friends if they want to go flying, will
probably let pilots get away with posting at their airport but might investigate if things get fishy, and flat out
refuse to allow dedicated, high traffic flight-sharing apps or websites, is simple: scale.</p>

<p>A well-connected pilot asking many of his or her friends and acquaintances to fly could probably set up a trip almost
every weekend. At a busy airport, a note on a bulletin board might allow for a flight both days of every weekend. But
imagine a pilot in a big city being able to advertise to a couple hundred thousand people or more. It would be easy to
schedule multiple flights every day. There&rsquo;d always be someone willing to go.</p>

<p>The FAA allows pilots to share expenses as an exception to the otherwise simple rule that a private pilot can&rsquo;t be in it
for the money. This exception is feasible only because it&rsquo;s expected to apply to a relatively small number of flights.
Flight-sharing companies inherently work directly against keeping this exceptional case limited.</p>

<h2>Not every industry needs to be disrupted</h2>

<p>After the FAA&rsquo;s ruling, many in tech were concerned. Flytenow quickly
<a href="http://blog.flytenow.com/missed-approach-faa-says-flytenow-go-around">replied</a> to the FAA with what I felt was a
disappointing analysis of the FAA&rsquo;s position, and vowed to continue their service with the cost sharing aspect removed.
AirPooler <a href="http://techcrunch.com/2014/08/15/faa-bans-planesharing-startups/">reportedly</a> may attempt to reverse the
ruling.</p>

<p>I have no doubt everyone involved in both of these companies share a strong love of aviation, and are genuinely trying to
make things better for pilots and passengers. I also know how hard it is to build a company from nothing, especially one
that skirts the edge of existing laws. And I know that the founder mindset is specifically geared towards conquering
obstacles, of which this may just appear as the biggest yet.</p>

<p>With all that in mind, I have a request for the founders of Flytenow and Airpooler: <strong>please don&rsquo;t continue to pursue the
current flight-sharing model.</strong></p>

<p>The idea is admirable, and there was no wrong done in testing it out. But the division between a private and commercial
license has stood fairly clearly for a long time, and in general it has worked out. Blurring the lines between flying
with friends and flying with paying customers will inevitably cause issues.</p>

<p>General aviation currently faces opposition on many fronts. Even aside from what will happen in the case of an accident,
there are bound to be cases where the expectations of paying passengers don&rsquo;t match up with the experience a low-time
private pilot like myself can provide. The fallout from these events will be trying for our entire community.</p>

<h2>We still need the help of tech companies</h2>

<p>The last thing I&rsquo;m suggesting is that Flytenow or Airpooler close up shop, go home, and call it a day. Now more than
ever general aviation needs the help of those of us who have the skills and desire to bring technology to our industry.
Everyone among us who can start companies, launch products, and solve problems is extremely valuable.</p>

<p>I couldn&rsquo;t even begin to list all the ways to improve aviation right now. Just look at the advances in mobile hardware,
batteries, sensors of all kinds, and machine learning that are revolutionizing entire industries. And in aviation we
have plenty of innovators to inspire us:</p>

<ul>
<li>The <a href="https://www.foreflight.com/">Foreflight</a> team has arguably made an iPad required equipment and made flight planning easier than ever</li>
<li><a href="https://www.openairplane.com/">OpenAirplane</a> is making renting planes across the country as easy as renting at your
local airport</li>
<li><a href="http://www.pilotedge.net/">PilotEdge</a> has created an amazing network of flight simulator enthusiasts and is helping
real pilots practice their skills safely from their own computers</li>
<li>Even individuals are contributing: developers like <a href="http://www.fivezeromike.com/">Jacob Eiting</a> are making awesome aviation apps, and video series like those from <a href="https://www.youtube.com/user/FlightChops">FlightChops</a> are helping more people learn about aviation, and aviation safety, than ever before</li>
</ul>


<p>Again, I&rsquo;m not suggesting we halt progress on technology in aviation. In fact I know we&rsquo;re going to continue going
forward. But disruption isn&rsquo;t the only way to improve. We&rsquo;ve got some great organizations here in general aviation: we
can all make flying more fun, more popular, and safer with cooperation.</p>

<hr />

<ol class="footnotelist"><p><li id="4274:fn:1" class="footnotebody" value="1">
When you mean to ensure your passengers that despite the somewhat ragged appearance a 1970&rsquo;s Cessna may have, the
engine and components are maintained to the same high level of quality as a new plane, one thing you should never say
is: &ldquo;Yeah, they don&rsquo;t really take care of these old planes&rdquo;.
<a href="#4274:fn-back:1" class="backlink">⏎</a></li></p>

<p><li id="4274:fn:2" class="footnotebody" value="2">
The FAA has ruled definitively on all sorts of schemes: you can&rsquo;t use your private pilots license to aid your
business, even simply flying employees to meetings. You can&rsquo;t act on a hint from your boss that a ride in your plane
will convince him to give you a promotion. You can&rsquo;t offer your mechanic a free flight to get a reduced rates on your
next annual inspection. You can&rsquo;t even fly your drama teacher in exchange for a more prominent part in the school play.
<a href="#4274:fn-back:2" class="backlink">⏎</a></li></p>

<p><li id="4274:fn:3" class="footnotebody" value="3">
Perhaps my favorite story is that of <a href="http://en.wikipedia.org/wiki/United_Airlines_Flight_232">United Airlines Flight 232</a>.
One of the plane&rsquo;s engines failed catastrophically requiring an emergency landing. Investigators
recovered the critical piece of the engine they needed to analyze the failure, even though they had
to search hundreds of square miles of Iowa farmland around where the accident occurred to do it. It
was analyzed and despite being damaged from falling several miles, the analysis detected a crack
caused by fatigue that lead to the accident. The team then investigated the maintenance and
production logs for the airplane going back 18 years, and determined the part was manufactured with
the defect, the defect was detected, but the part was not rejected as it should have been. This is
the lengths we have to go to if we want to ensure flying is safe.
<a href="#4274:fn-back:3" class="backlink">⏎</a></li></p>
</ol>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Javascript: The Good Parts, a Review]]></title>
    <link href="https://juliansimioni.com/blog/javascript-the-good-parts-review/"/>
    <updated>2014-07-06T22:15:00-07:00</updated>
    <id>https://juliansimioni.com/blog/javascript-the-good-parts-review</id>
    <content type="html"><![CDATA[<p><em>Today I wrote up what turned out to be a somewhat lengthy <a href="https://www.goodreads.com/review/show/566827873">review</a> for <a href="http://shop.oreilly.com/product/9780596517748.do">Javascript: The Good Parts</a>.  Since it goes a bit beyond strictly reviewing the book and talking about Javascript itself, I figured I&rsquo;d post it here.</em></p>

<p>I though I had read this book before, but when I sat down to reread it this weekend I found a couple interesting things: 1.) I had never reviewed/rated this book on Goodreads, 2.) I had a bookmark halfway through the book 3.) I didn&rsquo;t remember any of the content for most of the chapters after my bookmark.</p>

<p>So here goes..</p>

<p><i>Javascript: The Good Parts</i> made (or at least helped make) the Javascript language. Yes, the book was published in 2008, and yes, Javascript was created in 1995, and yes Javascript was widely used by at least the year 2000. But before <i>The Good Parts</i>, no one was allowed to view Javascript as anything but a toy. Worse, a toy with many sharp pieces that would hurt you if you tried to use it.</p>

<p><i>The Good Parts</i> is still hard on Javascript, both in the main chapters of the book and in two special appendices cataloguing the Awful Parts and the Bad Parts, and there&rsquo;s plenty of good reasons to be hard on Javascript.</p>

<p>Part of this comes from Crockford&rsquo;s personality. While I find him likeable overall he is sometimes a bit abrasive and critical. In one of his talks, he mentions he considers colored syntax highlighting to be a feature &ldquo;for children&rdquo;. Beyond making more than a few skilled developers angry, I&rsquo;m sure comments like these do their share to keep new people out of our field. The &ldquo;REAL programmers don&rsquo;t use X&rdquo; rhetoric is strong enough without people wondering if finding value in syntax highlighting means they aren&rsquo;t cut out for programming.</p>

<p>I also notice a disconnect between Crockford&rsquo;s suggested pattern of Javascript usage, and that which is actually common today. Crockford was adamant that the &ldquo;new&rdquo; keyword never be used. He suggests we abandon what he called the &ldquo;pseudoclassical&rdquo; inheritance features that somewhat resemble C++ or Java, and embrace the prototypal inheritance that he considers to be the core of the Javascript language. At least in the world of Backbone.js, which is the most widely used framework I know of that isn&rsquo;t trying to rebuild Rails on top of Javascript, but rather work with the language, things have settled on a strange combination where prototypal inheritance handles defining objects that look eerily similar to traditional classes, and then the dreaded &ldquo;new&rdquo; keyword is used to intansiate individual objects.</p>

<p>Finally, I can not believe that Crockford isn&rsquo;t suffering at least a little from a case of Stockholm syndrome. I know this because I&rsquo;ve been writing Javascript for over 10 years, and have seen my own admiration for the language grow even while I questioned whether or not my admiration was valid.</p>

<p>There IS an elegance in the Javascript language that this book helps unearth, but whether or not that elegant system actually makes Javascript useful is more uncertain. I see the beauty in using closures to hide access to private variables, but is it worth the cognitive load over simply declaring something private?</p>

<p>In any case this book is a must read for anyone doing Javascript development. I don&rsquo;t think this book has achieved the top status of &ldquo;must reread every year&rdquo;, but it seems reasonable that you should read this book twice: once after you first dive into Javascript and want some semblance of clarity after the initial confusion you will no doubt encounter, and then sometime later when you are experienced with Javascript and wish to achieve Zen with the language.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Thank you RailsConf!]]></title>
    <link href="https://juliansimioni.com/blog/thank-you-railsconf/"/>
    <updated>2014-04-28T14:23:04-07:00</updated>
    <id>https://juliansimioni.com/blog/thank-you-railsconf</id>
    <content type="html"><![CDATA[<p>I&rsquo;m finally back home and settled in from a crazy and amazing week in Chicago. I just wanted to say
thanks to everyone for an amazing time. Speakers, attendees, staff, everyone.</p>

<p>To everyone I met or talked to during the week, it was great to see you.</p>

<p>Speakers! You guys gave some amazing talks and it was awesome to watch you give them and get to chat
with you about them later.</p>

<p>And last but not least, to everyone who attended my talk: thanks so much! I hope you had as much fun
listening as I did giving it. The slides are
<a href="https://speakerdeck.com/orangejulius/software-development-lessons-from-the-apollo-program">here</a>
and you can see the video of my talk from MWRC on
<a href="https://www.youtube.com/watch?v=jYe2bF7tc2Q">youtube</a>.</p>

<p>See you all at the next conference!</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Drafts are Evil: Write and Be Done]]></title>
    <link href="https://juliansimioni.com/blog/drafts-are-evil-write-and-be-done/"/>
    <updated>2014-02-19T14:04:38-08:00</updated>
    <id>https://juliansimioni.com/blog/drafts-are-evil-write-and-be-done</id>
    <content type="html"><![CDATA[<p>Every 100 days, each of us at <a href="http://www.42floors.com">42floors</a> chooses a personal goal to
accomplish before the 100 days are up. Back in November, I chose my current goal: write 10 blog
posts.</p>

<p>Today is day 100 and this is blog post number 10. There are a lot of things I&rsquo;ve learned that I
could write about, but one in particular stands out to me.</p>

<p>One of the hardest things in the software world is learning to actually ship what you&rsquo;ve made. It&rsquo;s
much easier to simply continue working: adding new features, fixing bugs, refactoring. Often the
work simply isn&rsquo;t as fun. Building the core of a new product is great: you&rsquo;re laying the groundwork,
making important decisions about the entire architecture of your software. It&rsquo;s all too easy to put
off the finishing touches that are required if your software is actually going to be usable.</p>

<p>It&rsquo;s even easier to put off the whole idea of finishing all together. Drawing a line in the sand and
declaring your software ready for others to use is difficult. It means admitting things
aren&rsquo;t perfect and that you aren&rsquo;t going to fix them (yet). Worse, it means exposing those flaws for
everyone to see.</p>

<p>Writing, as it turns out, is exactly the same. In fact, it&rsquo;s even more difficult to ship your
writing. The inevitable flaws you expose when sharing your words are deeper and more personal than
any code. And most writing is much more permanent than software: once shared, it generally doesn&rsquo;t
change very much, except perhaps to fix a few typos<sup><a href="#af06:fn:1" class="footnote" id="af06:fn-back:1">1</a></sup>.</p>

<p>So, really, blogging has been the best practice for shipping software I could have chosen. I&rsquo;ve
intentionally tried to embrace imperfection. Every one of my posts needs more work. It would have
been easier to sit on 10 drafts, unpublished, for all time. And it really would have been for all time,
because none of them will ever be perfect.</p>

<p>My hope then, is that simply by forcing myself to ship lots of imperfect blog posts, my writing will
get a lot better. I&rsquo;ll probably never notice this while I&rsquo;m writing. Every post I ever
work on will have flaws, and whenever I&rsquo;m writing I&rsquo;ll be focusing on those flaws.</p>

<p>Every once in a while though, I&rsquo;ll look back on an old post or two. That&rsquo;s when I&rsquo;ll see how far
I&rsquo;ve come.</p>

<hr />

<ol class="footnotelist"><p><li id="af06:fn:1" class="footnotebody" value="1">
Which, I believe, is why engineers invented the wiki. It&rsquo;s much more comfortable to keep
something an eternal work in progress.
<a href="#af06:fn-back:1" class="backlink">⏎</a></li></p>
</ol>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[The Many Terrors of Giving Talks]]></title>
    <link href="https://juliansimioni.com/blog/the-many-terrors-of-giving-talks/"/>
    <updated>2014-02-19T11:34:53-08:00</updated>
    <id>https://juliansimioni.com/blog/the-many-terrors-of-giving-talks</id>
    <content type="html"><![CDATA[<p>A few weeks ago, I was given some terrible news: my talk proposal had been accepted.</p>

<p>It might seem strange that being granted something I had asked for would be terrible, but given my
reaction to the news, it&rsquo;s the only logical conclusion.</p>

<p>Here&rsquo;s a short sampling of the things that went through my head:
* What if my talk is boring and no one likes it?
* What if no one understands what I&rsquo;m talking about?
* What if nothing I say is new at all?
* What if I completely fail to prepare?
* What if I have a great talk, but poor presentation?
* What if I make a bad joke while on stage?
* What if I say something that offends a whole group of people and the entire internet disowns me?
* What if someone asks a question I can&rsquo;t answer and makes me look stupid?</p>

<p>Judging by what most other people have written about giving talks, this is par for the course.
Public speaking is universally terrifying, causes enormous stress, and take up countless hours of
time in preparation. Why then, does anyone bother?</p>

<p>Because there&rsquo;s nothing better than overcoming new challenges, and talks are full of them.</p>

<p>Giving a talk requires knowing something well enough to teach it to others. It takes hours of
preparation, far beyond that which is required just to be proficient. And you can&rsquo;t just know
fragmented pieces: your knowledge has to be complete and orderly so that you can actually teach
others.</p>

<p>Giving a talk (for most people) requires stepping well outside your comfort zone. It requires
learning new skills that you can, should, but probably don&rsquo;t use on a daily basis. Stepping into new
things requires accepting a lot of mistakes will be made, and requires the confidence and
perseverance to continue despite those mistakes. When giving a talk, all your mistakes happen in
public, which is particularly unsettling.</p>

<p>Giving a talk requires great delivery. In a lot of ways, what you say is as important as how you
say it.</p>

<p>Giving a talk requires a lot of work. More importantly, giving a talk requires a lot of
work with a hard deadline. You have to spend many hours preparing, but you can&rsquo;t spend an infinite
amount of time. You can&rsquo;t practice your talk until it&rsquo;s perfect. At some point, it&rsquo;s the day of your
talk and you&rsquo;re as ready as you can be. The trick then, is to prepare efficiently with the limited
amount of time you have<sup><a href="#0ce4:fn:1" class="footnote" id="0ce4:fn-back:1">1</a></sup>.</p>

<p>I&rsquo;m learning a lot preparing for my talk. I know I&rsquo;ll learn a lot more by actually presenting. And
overall, the process has been, and will continue to be a lot of fun. All this motivates me to work
on my talk, but I have to admit, there&rsquo;s one thing that motivates me most of all: to be done with my
talk.</p>

<hr />

<ol class="footnotelist"><p><li id="0ce4:fn:1" class="footnotebody" value="1">
If you think the time between your proposal&rsquo;s acceptance and the conference is anything but
limited, just wait.
<a href="#0ce4:fn-back:1" class="backlink">⏎</a></li></p>
</ol>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Just Write it. Even if Someone Else Did Too]]></title>
    <link href="https://juliansimioni.com/blog/just-write-it-even-if-someone-else-did-too/"/>
    <updated>2014-02-18T23:13:10-08:00</updated>
    <id>https://juliansimioni.com/blog/just-write-it-even-if-someone-else-did-too</id>
    <content type="html"><![CDATA[<p>For several months now, buried in my growing list of blog post ideas has been a single line:
&ldquo;ruthlessly prioritize&rdquo;. If I remember correctly it&rsquo;s a snippet of something Mark Pincus once said.
While only a line long, somewhere in my brain it&rsquo;s associated with an entire outline of a blog
post.</p>

<p>That blog post would have talked about how there are, at any time in anyone&rsquo;s life, a nearly
infinite list of things that could be done, but time to do only a few. It would have concluded with
a poignant reminder that everything we do is a choice, and it&rsquo;s important to consciously choose to
do the things most important to us.</p>

<p>Then I read Edmond Lau&rsquo;s <a href="http://www.theeffectiveengineer.com/blog/most-important-lesson-ive-learned-in-my-professional-life">blog post</a>
and saw exactly what I wanted to write laid out before me.</p>

<p>It many ways, it would be easy to throw my hands up and never write that blog post. But after
thinking about it for a while, I&rsquo;m more motivated than ever to write down my ideas.</p>

<p>Initially, knowing someone else has written almost exactly what I wanted to write is painful. But
there was going to be a blog post out there similar to mine whether I knew it or not. No writer
expects everything (or possibly anything) they write to be completely original. So really,
confirmation of such a basic reality of writing shouldn&rsquo;t change anything.</p>

<p>In fact, there&rsquo;s a reward to reading someone else&rsquo;s opinion on anything you&rsquo;ve thought deeply about,
even if you haven&rsquo;t yet published your thoughts, even if you haven&rsquo;t yet published your thoughts.
Having put your own thought into a topic, it&rsquo;s much more rewarding to read what others have to say.</p>

<p>For me though, the most exciting thought was how I can improve my own blog post based on what I&rsquo;ve
read. I get to examine someone else&rsquo;s attempt to write about the same topic, and learn from their
work. I can focus on the areas I think they missed, or word things in a different way to avoid
specific counter-arguments. Every writer puts their own personal touch into
their writing; focusing on the differences is better than focusing on the similarities.</p>

<p>So at the end of the day there&rsquo;s no doubt: I&rsquo;ll be writing that blog post and many others. And
whatever I write will be my own, even if someone else has written about it too.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[The Power of Changing History]]></title>
    <link href="https://juliansimioni.com/blog/the-power-of-changing-history/"/>
    <updated>2014-02-17T18:34:51-08:00</updated>
    <id>https://juliansimioni.com/blog/the-power-of-changing-history</id>
    <content type="html"><![CDATA[<p>Writing code that is easy to read and understand later is arguably the most important habit of a
good software developer. There&rsquo;s plenty that has been written about what the resulting code looks like,
but theres more that goes into reading your code than just, well, your code. How you share your code
with others helps too.</p>

<p>If you&rsquo;re using Git (or any other distributed version control), then you have
an incredible new power to aid in the understanding of your code, something someone using
Subversion (or any other centralized version control) simply doesn&rsquo;t have. I&rsquo;m writing all this
because I see so few people taking advantage of it.</p>

<p>The advantage is simple: with Git, you can rewrite history.</p>

<p>As a simple example, consider the common &ldquo;forgot to check in a file&rdquo; commit. With Subersion, there&rsquo;s
no way to fix this simple mistake, no matter how soon after committing you catch it. For all time
one logical group of changes will be split into two places. With git, a simple <code>git commit
--amend</code> makes things right<sup><a href="#44ca:fn:1" class="footnote" id="44ca:fn-back:1">1</a></sup>.</p>

<p>The damage done by not repairing this sort of commit is real: the history of a project is an
extremely valuable source of context and understanding. Every commit is a chance to record
why something was done, and what it is supposed to accomplish. When reading code, these are arguably
the most important questions to answer. Simply looking at code, even well written code, can mean
spending time deducing the answers. With a well managed history, the answers are out in the open.</p>

<p>There&rsquo;s a nearly endless list of ways to create a more valuable history. Most of them are, in fact,
widely talked about. Git has cheap branching; use it to keep changes that solve different problems
separate. There&rsquo;s no reason to have a bugfix commit in a feature branch. There&rsquo;s no reason not to
split work on dependencies of a large feature into separate branches.</p>

<p>Commits should be made frequently. Initially, there&rsquo;s no need for them to have any special meaning
or semantics, because commits are infinitely malleable. Take advantage of <code>git rebase</code> and
massage your many, disorganized commits created during development into a readable, ordered list of
semantically meaningful changes. With practice, these types of improvements can be made quickly.</p>

<p>Invariably, talk of these types of changes seem to devolve into an argument over the concept of an
immutable history. The idea is that as with Subversion, all project histories should record every
change ever made, in the order they were initially made, regardless of the significance of each
change. This is the most basic requirement of source control, but not the only one.</p>

<p>What&rsquo;s often missed is that with Git, you can have the best of both worlds. Develop your feature
however you want. Create dozens of messy, disorderly commits. Use commit messages that convey no
information whatsoever. Stow these changes away somewhere. Use a tag, or a branch specifically for
changes made during active development<sup><a href="#44ca:fn:2" class="footnote" id="44ca:fn-back:2">2</a></sup>.</p>

<p>Now that you know how your code should be written, take just a couple minutes and reorganize,
reorder, and coalesce. The details of how the code came to be are no longer important. The priority
now is separating changes into logical, semantic units that, when taken in order, come together to
make the change in a readable and understandable way.</p>

<p>Everyone on your team will be asking questions your commits can answer. Even future you will ask
need reminders about the history of your code. Don&rsquo;t make anyone have to figure out your code on their
own, give them all the help you can! You&rsquo;re not using Git to the fullest if you don&rsquo;t.</p>

<hr />

<ol class="footnotelist"><p><li id="44ca:fn:1" class="footnotebody" value="1">
With the usual warning to not use <code>git push --force</code> if it would disrupt others.
<a href="#44ca:fn-back:1" class="backlink">⏎</a></li>
<li id="44ca:fn:2" class="footnotebody" value="2">
An awesome feature of git branches is that they can contain nearly any character, including
slashes. I&rsquo;ve seen projects that use this to split branches into categories. There can be categories for bug
fixes, experiments, development, etc. The initial, unstructured writing of code done during early
development can certainly be a category.
<a href="#44ca:fn-back:2" class="backlink">⏎</a></li></p>
</ol>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[I Accidentally Learned Functional Programming From Ruby]]></title>
    <link href="https://juliansimioni.com/blog/i-accidentally-learned-functional-programming-from-ruby/"/>
    <updated>2014-02-15T23:46:10-08:00</updated>
    <id>https://juliansimioni.com/blog/i-accidentally-learned-functional-programming-from-ruby</id>
    <content type="html"><![CDATA[<p>About a year and a half ago, over ten years into my career as web developer, but with only about six
months of using web frameworks of any kind, I made the deliberate choice to switch from Python to
Ruby. My reasoning was short and simple: I had heard far too many people say good things about Ruby
on Rails, and how it was better than Django (that&rsquo;s a debate for another blog post).</p>

<p>I didn&rsquo;t really care for Ruby&rsquo;s syntax, thought Bundler, RVM, rbenv, and co were far more confusing
than pip and virtualenv<sup><a href="#6d70:fn:1" class="footnote" id="6d70:fn-back:1">1</a></sup>, and especially thought the entire mantra of writing code to almost read
like English was laughable (things like <code>5.times</code> especially irritated me).</p>

<p>In short, I expected to essentially carry on programming just like before, except possibly with
better tools to help me along. That&rsquo;s not quite what happened.</p>

<p>Initially little changed. My <code>for i in items:</code> was replaced with <code>for i in items do</code>, but
did exactly the same thing. But questions started coming. Why did Ruby have do/end AND curly braces?
Why were loop counter variables sometimes enclosed in vertical bars? Why did every damn thing
include Enumerable?</p>

<p>As I worked with Ruby more and looked around at code written by more seasoned Rubyists, I noticed
something even more strange: no one seemed to use for loops at all. It didn&rsquo;t even save any typing
(clearly the most important thing to Ruby programmers), yet <code>items.each do |i|</code> was universally
preferred.</p>

<p>Furthermore, Rubyists seemed to hate creating variables. Class methods were short, and seemed to
just take an input, massage it in some small way, and &ndash; without even the courtesy of an explicit return
statement &ndash;  pass it on to the next thing. My C++ trained brain longed to see variables created
simply to iterate through arrays. Instead all I got were calls to <code>map</code>. I found myself using
<code>each_with_index</code> just to stay comfortable, without even needing to use an index.</p>

<p>As time went on though, I began to appreciate the conventions the Ruby community had adopted. There
was great clarity to be had in concentrating on what was being done &ndash; transforming some data &ndash;,
rather than how it was done &ndash; by iterating through every element in some sort of collection and
doing the same thing to each element. My code was shorter, but more importantly, it was more obvious
what it was doing, and why it was doing it.</p>

<p>Meanwhile, a movement was brewing in the programmer community at large. &ldquo;Learn functional
programming&rdquo; they said. &ldquo;Down with side-effects.&rdquo; &ldquo;Bow to your higher-order function gods&rdquo;. I took
note to read up on it some time and kept on coding.</p>

<p>Later, as I was also becoming better with Javascript, a language I had first learned a decade before
and dismissed as <a href="http://www.oreillynet.com/pub/a/javascript/excerpts/javascript-good-parts/bad-parts.html">poorly designed</a>,
I finally started getting comfortable when I discovered Underscore.js and Backbone and immediately
was comfortable with their powerful collection utilities. &ldquo;Finally, someone has brought the power of
Ruby Enumerable&rsquo;s to Javascript&rdquo;, I thought.</p>

<p>The functional programming proponents are at least as numerous in the land of Javascript, so this
was about when I really decided to take a look and see what they had to offer. To my astonishment,
everything I read about functional programming wasn&rsquo;t talking about anything new, but simply giving
names to things I already did.</p>

<p>It was then that I realized many of the things I loved about Ruby weren&rsquo;t Ruby things at all. They
were functional programming things. Underscore didn&rsquo;t bring the power of Ruby to Javascript, it
brought the power of functional programming.</p>

<hr />

<ol class="footnotelist"><p><li id="6d70:fn:1" class="footnotebody" value="1">
I&rsquo;ve completely reversed that decision and can&rsquo;t imagine leaving my Gemfiles behind for
requirements.txt. It seems silly that one would install packages, then
write the list of installed packages to a file for later, instead of just writing a list of packages
to install.
<a href="#6d70:fn-back:1" class="backlink">⏎</a></li></p>
</ol>

]]></content>
  </entry>
  
</feed>
