<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Joël Sepulveda Franusic</title>
    <description>The latest articles on DEV Community by Joël Sepulveda Franusic (@jf).</description>
    <link>https://dev.to/jf</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F107499%2Fd85184c1-e9a8-4341-b683-f5fd877d0d67.jpeg</url>
      <title>DEV Community: Joël Sepulveda Franusic</title>
      <link>https://dev.to/jf</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jf"/>
    <language>en</language>
    <item>
      <title>Thoughts after 6 months of literate programming</title>
      <dc:creator>Joël Sepulveda Franusic</dc:creator>
      <pubDate>Fri, 12 Oct 2018 14:05:23 +0000</pubDate>
      <link>https://dev.to/jf/thoughts-after-6-months-of-literate-programming-3o0p</link>
      <guid>https://dev.to/jf/thoughts-after-6-months-of-literate-programming-3o0p</guid>
      <description>

&lt;p&gt;I wrote my first &lt;a href="https://en.wikipedia.org/wiki/Literate_programming"&gt;literate program&lt;/a&gt; in &lt;a href="https://github.com/jpf/token-cleaner/commit/29f589b054c12f779d18cf8907826ef20231eab4"&gt;November of 2015&lt;/a&gt;. Since then, I've been&lt;br&gt;
writing literate programs on an almost daily basis. It has been an&lt;br&gt;
experience with a sort of enlightenment that I haven't had in a long&lt;br&gt;
time. Not only is it a lot of fun to write literate programs, I feel&lt;br&gt;
like I have gained a new "super power" of sorts.&lt;/p&gt;

&lt;p&gt;Below are my thoughts on my experiences with literate programming so&lt;br&gt;
far.&lt;/p&gt;

&lt;h2&gt;Literate programs I've written to date&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Project name&lt;/th&gt;
&lt;th&gt;Lines of code&lt;/th&gt;
&lt;th&gt;Words in literate document&lt;/th&gt;
&lt;th&gt;Ratio of words to lines&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://github.com/jpf/token-cleaner#token-cleaner"&gt;Token Cleaner&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;46&lt;/td&gt;
&lt;td&gt;496&lt;/td&gt;
&lt;td&gt;10.782609&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="http://developer.okta.com/docs/guides/okta_sign-in_widget.html"&gt;Okta Sign-In Widget&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;120&lt;/td&gt;
&lt;td&gt;3862&lt;/td&gt;
&lt;td&gt;32.183333&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://github.com/joelfranusic-okta/okta-scim-beta#welcome-to-the-okta-scim-beta"&gt;Okta SCIM Beta&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;360&lt;/td&gt;
&lt;td&gt;7966&lt;/td&gt;
&lt;td&gt;22.127778&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://github.com/jpf/dial-a-cat#1-855-meow-jam-sending-cat-pictures-over-the-phone-via-space-age-technology"&gt;Dial-a-cat&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;370&lt;/td&gt;
&lt;td&gt;3620&lt;/td&gt;
&lt;td&gt;9.7837838&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://github.com/jpf/okta-oidc-beta#introduction"&gt;Okta OIDC Beta&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;752&lt;/td&gt;
&lt;td&gt;7731&lt;/td&gt;
&lt;td&gt;10.280585&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Explanation:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Lines of code&lt;/strong&gt; is the number of lines of "code" generated by
the literate program. "code" is in quotes because the code is
anything in an &lt;strong&gt;Org Babel&lt;/strong&gt; "source" block, it could be Python,
Shell, HTML, etc. This number comes from running this command on
an &lt;strong&gt;Org Babel&lt;/strong&gt; file: &lt;code&gt;awk '/BEGIN_SRC/,/END_SRC/' $filename&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Words in document per lines of code&lt;/strong&gt; is the number of words in a
file, note that in includes the source code as well. This number
comes from running this command on an &lt;strong&gt;Org Babel&lt;/strong&gt; file: &lt;code&gt;wc -w&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Ratio of words to lines&lt;/strong&gt; is: &lt;em&gt;Words in literate document&lt;/em&gt; divided by &lt;em&gt;Lines of code&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;What I like about literate programming&lt;/h2&gt;

&lt;h3&gt;The expressiveness of literate programming&lt;/h3&gt;

&lt;p&gt;I feel hobbled by in-line code comments now. One of the clearest&lt;br&gt;
benefits of literate programming is being able to weave my code&lt;br&gt;
into large sections of prose, instead of interleaving small&lt;br&gt;
sections of prose into code.&lt;/p&gt;

&lt;p&gt;Now I find myself spending time to add in detailed references an&lt;br&gt;
explanations with my code. One example of this is including a&lt;br&gt;
&lt;code&gt;curl&lt;/code&gt; command, links to RFCs, and a note about "1-indexed" versus&lt;br&gt;
"0-indexed" differences in the "&lt;a href="https://github.com/joelfranusic-okta/okta-scim-beta#resource-paging"&gt;Resource Paging&lt;/a&gt;" section of my&lt;br&gt;
&lt;a href="https://github.com/joelfranusic-okta/okta-scim-beta"&gt;Okta SCIM Beta&lt;/a&gt; document. Another example is being able to cover a&lt;br&gt;
function line-by-line, as well as include unit tests in-line in&lt;br&gt;
the "&lt;a href="https://github.com/jpf/okta-oidc-beta#validating-an-oidc-id_token-from-okta"&gt;Validating an OIDC id_token from Okta&lt;/a&gt;" section of my&lt;br&gt;
&lt;a href="https://github.com/jpf/okta-oidc-beta"&gt;Okta OIDC Beta&lt;/a&gt; document.&lt;/p&gt;

&lt;h3&gt;Ability to generate data from tables&lt;/h3&gt;

&lt;p&gt;Take a look at the table listed in the "&lt;a href="https://github.com/joelfranusic-okta/okta-scim-beta#dependencies"&gt;Dependencies&lt;/a&gt;" section of&lt;br&gt;
the &lt;a href="https://github.com/joelfranusic-okta/okta-scim-beta"&gt;Okta SCIM Beta&lt;/a&gt; document. Then take a look at the&lt;br&gt;
&lt;a href="https://github.com/joelfranusic-okta/okta-scim-beta/blob/master/requirements.txt"&gt;requirements.txt&lt;/a&gt; file in the same repository. The dependencies&lt;br&gt;
table and the &lt;code&gt;requirements.txt&lt;/code&gt; file are both generated from a&lt;br&gt;
&lt;a href="https://github.com/joelfranusic-okta/okta-scim-beta/commit/80fb95bbb315caea9ef0734f98f296923ffa03b8#diff-aacb4ce123f9200898dff4a35e6a8461R1229"&gt;single table&lt;/a&gt; in &lt;strong&gt;Org Babel&lt;/strong&gt;!&lt;/p&gt;

&lt;p&gt;This is all made possible by the ability to write in-line code to&lt;br&gt;
&lt;a href="https://github.com/joelfranusic-okta/okta-scim-beta/commit/80fb95bbb315caea9ef0734f98f296923ffa03b8#diff-aacb4ce123f9200898dff4a35e6a8461L1099"&gt;generate the requirements.txt file&lt;/a&gt; and code to generate the &lt;a href="https://github.com/joelfranusic-okta/okta-scim-beta/commit/80fb95bbb315caea9ef0734f98f296923ffa03b8#diff-aacb4ce123f9200898dff4a35e6a8461R1318"&gt;table&lt;br&gt;
markdown for GitHub Pages&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;Being able to include a Copyright notice across multiple files&lt;/h3&gt;

&lt;p&gt;In the &lt;a href="https://github.com/joelfranusic-okta/okta-scim-beta"&gt;Okta SCIM Beta&lt;/a&gt; document, I am able define a copyright&lt;br&gt;
notice in &lt;a href="https://github.com/joelfranusic-okta/okta-scim-beta/commit/80fb95bbb315caea9ef0734f98f296923ffa03b8#diff-aacb4ce123f9200898dff4a35e6a8461L1131"&gt;one place&lt;/a&gt; and have that copyright notice written to a&lt;br&gt;
&lt;a href="https://github.com/joelfranusic-okta/okta-scim-beta/commit/80fb95bbb315caea9ef0734f98f296923ffa03b8#diff-aacb4ce123f9200898dff4a35e6a8461L1133"&gt;LICENSE.txt&lt;/a&gt; file and have the same notice included into the&lt;br&gt;
&lt;a href="https://github.com/joelfranusic-okta/okta-scim-beta/commit/80fb95bbb315caea9ef0734f98f296923ffa03b8#diff-aacb4ce123f9200898dff4a35e6a8461L1155"&gt;scim-server.py&lt;/a&gt; file.&lt;/p&gt;

&lt;h3&gt;Having shell commands, and output, all in one place&lt;/h3&gt;

&lt;p&gt;When I was writing the &lt;a href="https://github.com/jpf/okta-oidc-beta"&gt;Okta OIDC Beta&lt;/a&gt; document, I spent a lot of&lt;br&gt;
time finding the arcane &lt;code&gt;openssl&lt;/code&gt; incantations needed to generate&lt;br&gt;
x509 certificates that I needed for a unit test. Because I was&lt;br&gt;
writing a literate document, I was able to include &lt;a href="https://github.com/jpf/okta-oidc-beta/commit/95e14a2de01fffb5d8ecd689e1c815bc39b689d2#diff-aacb4ce123f9200898dff4a35e6a8461L1398"&gt;all of the&lt;br&gt;
commands that I used&lt;/a&gt;, along with a detailed explanation of what&lt;br&gt;
each command did.&lt;/p&gt;

&lt;p&gt;Being able to execute these commands and see their output without&lt;br&gt;
needing to switch to a terminal made it really easy to&lt;br&gt;
interactively explore the commands that I needed to generate the&lt;br&gt;
certificates, and to keep track of those commands for the next&lt;br&gt;
time that I need to generate similar certificates or keys.&lt;/p&gt;

&lt;h3&gt;Tracking time and future work in the same document&lt;/h3&gt;

&lt;p&gt;Since &lt;strong&gt;Org Babel&lt;/strong&gt; is part of &lt;a href="http://orgmode.org/"&gt;Org Mode&lt;/a&gt;, it is trivial to make use&lt;br&gt;
of Org's time tracking and project planning features.&lt;/p&gt;

&lt;p&gt;I usually keep track of my time in my usual Org setup, but when&lt;br&gt;
appropriate it's nice to be able to keep track of my time inside&lt;br&gt;
the same literate document that I'm working on.&lt;/p&gt;

&lt;p&gt;You can see an example of time tracking and project planning in&lt;br&gt;
the &lt;a href="https://github.com/jpf/dial-a-cat/commit/bdb90f1d9b7ba1e7fd97152169330d026b45e812#diff-aacb4ce123f9200898dff4a35e6a8461L901"&gt;dial-a-cat document&lt;/a&gt;. (Look for the lines with &lt;code&gt;CLOCK&lt;/code&gt;, &lt;code&gt;DONE&lt;/code&gt;,&lt;br&gt;
or &lt;code&gt;TODO&lt;/code&gt;. &lt;/p&gt;

&lt;h3&gt;Easily keep code and prose consistent&lt;/h3&gt;

&lt;p&gt;Being able to keep code and prose synchronized is a problem that I&lt;br&gt;
first encountered when I was writing &lt;a href="https://www.twilio.com/blog/author/joel"&gt;blog posts for Twilio&lt;/a&gt;,&lt;br&gt;
searching for this "holy grail" is what first got me interested in&lt;br&gt;
literate programming. What I wanted was a tool that could generate&lt;br&gt;
Markdown and code from the same file, which is exactly what &lt;strong&gt;Org&lt;br&gt;
Babel&lt;/strong&gt; can do. &lt;/p&gt;

&lt;p&gt;I was sold on &lt;strong&gt;Org Babel&lt;/strong&gt; after I converted my favorite&lt;br&gt;
&lt;a href="https://www.twilio.com/blog/2013/10/1-855-meow-jam-sending-cat-pictures-over-the-phone-via-space-age-technology.html"&gt;blog post on the Twilio blog&lt;/a&gt; to a literate document, and&lt;br&gt;
&lt;a href="https://github.com/jpf/dial-a-cat/commit/5096cf9a58e87ac677e5303653c57861928444a4#diff-3f41e546893dc64b71aaacad12cad815L143"&gt;found an inconsistency in the process&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Now, because I &lt;em&gt;know&lt;/em&gt; that my code and prose will always be&lt;br&gt;
consistent, I find myself making quick changes to code that I&lt;br&gt;
wouldn't have made otherwise.&lt;/p&gt;

&lt;h2&gt;What is the best way to describe code?&lt;/h2&gt;

&lt;p&gt;Now that I have a tool which makes it easy to write an "essay"&lt;br&gt;
about my code, I'm faced with new questions that I never had the&lt;br&gt;
luxury of considering before.&lt;/p&gt;

&lt;p&gt;I imagine that satisfactorily answering the question "how can I describe this code best?"&lt;br&gt;
is a lifelong endeavor.&lt;/p&gt;

&lt;p&gt;Here are the specific questions that I find myself facing at this moment:&lt;/p&gt;

&lt;h3&gt;Literate documents are harder to refactor&lt;/h3&gt;

&lt;p&gt;Once a section of code is embedded in prose, it becomes a lot&lt;br&gt;
harder to change that code.&lt;/p&gt;

&lt;p&gt;Because of this, I find that the best way to write a literate&lt;br&gt;
program is to start with the code first and wait to turn the code&lt;br&gt;
into a literate document after extensive refactoring.&lt;/p&gt;

&lt;h3&gt;The structure of a document wants to change as a project grows&lt;/h3&gt;

&lt;p&gt;Describing a short program can be as easy as describing the&lt;br&gt;
program from "top to bottom", as I do in my&lt;br&gt;
&lt;a href="https://github.com/jpf/token-cleaner"&gt;token cleaner&lt;/a&gt; project.&lt;/p&gt;

&lt;p&gt;However, as a project grows, I'm finding that the structure I used&lt;br&gt;
to describe a small project will change when it becomes a medium&lt;br&gt;
sized project, and change again when it becomes a large project.&lt;/p&gt;

&lt;h3&gt;Should I describe every line of every program?&lt;/h3&gt;

&lt;p&gt;Another thing that I've been struggling with is figuring out the&lt;br&gt;
right balance between describing a program line-by-line, or&lt;br&gt;
skipping large sections of code entirely. I feel like the ideal&lt;br&gt;
method will lean more towards the "line-by-line" approach, but I&lt;br&gt;
think I need more hands on experience in this area.&lt;/p&gt;

&lt;h1&gt;Closing&lt;/h1&gt;

&lt;p&gt;Literate programming has been a very worthwhile discipline to learn,&lt;br&gt;
I still have a lot of things to learn, and I look forward to&lt;br&gt;
getting better at writing literate programs in the decades ahead.&lt;/p&gt;

&lt;p&gt;I'd love to hear and feedback that you have on this document. Please&lt;br&gt;
reach out to me on &lt;a href="https://twitter.com/jf"&gt;Twitter&lt;/a&gt;!&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Joël Franusic, May 2016&lt;/li&gt;
&lt;/ul&gt;


</description>
      <category>literate</category>
      <category>orgmode</category>
    </item>
  </channel>
</rss>
