<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Chris J. Agius on Medium]]></title>
        <description><![CDATA[Stories by Chris J. Agius on Medium]]></description>
        <link>https://medium.com/@chrisjagius?source=rss-771c02c6f907------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*SBuD02MfMs7YplIdYhjDmg.jpeg</url>
            <title>Stories by Chris J. Agius on Medium</title>
            <link>https://medium.com/@chrisjagius?source=rss-771c02c6f907------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 14 Nov 2026 08:18:31 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@chrisjagius/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[A First Foray into C from JavaScript]]></title>
            <link>https://medium.com/@chrisjagius/a-first-foray-into-c-from-javascript-1ce08eddec32?source=rss-771c02c6f907------2</link>
            <guid isPermaLink="false">https://medium.com/p/1ce08eddec32</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[c-programming]]></category>
            <category><![CDATA[learning-to-code]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Chris J. Agius]]></dc:creator>
            <pubDate>Tue, 26 Jun 2018 18:38:24 GMT</pubDate>
            <atom:updated>2018-06-26T18:38:24.358Z</atom:updated>
            <content:encoded><![CDATA[<h4>Comparison of Structures and Concepts at Differing Levels of Abstraction</h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fi.imgur.com%2FhCUS4iK.mp4&amp;src_secure=1&amp;url=https%3A%2F%2Fi.imgur.com%2FhCUS4iKh.jpg&amp;image=https%3A%2F%2Fi.imgur.com%2FhCUS4iKh.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=video%2Fmp4&amp;schema=imgur" width="480" height="236" frameborder="0" scrolling="no"><a href="https://medium.com/media/540aa5e03baa978683a18a1da631bc0f/href">https://medium.com/media/540aa5e03baa978683a18a1da631bc0f/href</a></iframe><p>A little background: Before I started studying full-stack web development in earnest at <a href="https://www.accesslabs.org/">Flatiron School’s Access Labs Initiative</a>, I dabbled very briefly in a number of programming languages over the years. The language where I got the furthest was probably C++ back in college. We studied from a textbook called <a href="http://a.co/abVVZBN">Starting Out With C++ from Control Structures to Objects</a> by Tony Gaddis (which I HIGHLY recommend—and I don’t think I’ve ever said that about a textbook).</p><p>That single semester of C++ probably did more to prepare me for my future programming endeavors than any of the other languages I’ve studied. While experienced programmers may balk at the idea that C++ is a low-level programming language, it certainly operates at a lower level of abstraction than many popular languages used today (Python, Swift, Ruby, etc). This is extremely useful in helping you understand how computers “think” and what actually goes on under the hood.</p><p>After spending some time immersed in Ruby and now JavaScript, I decided to venture back into some lower-level systems programming territory. Except this time, I decided to go to the granddaddy of many modern programming languages: C. Why, you ask?</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FQezS57OODKc%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DQezS57OODKc&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FQezS57OODKc%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/0523889d52a14f6541e4cc43dbdbd76a/href">https://medium.com/media/0523889d52a14f6541e4cc43dbdbd76a/href</a></iframe><p>Abstraction is great! It can help you write functioning code very, very quickly. But I have to be honest: I kind of miss seeing what’s going on under the hood. I want to gain a better understanding of how the computer processes instructions. Finally, I want to learn how to write systems from the ground up with fast, powerful code. First things first, though: we need to start with basics.</p><h3>Should you be intimidated by C?</h3><p>No!! Look—if you’re like me, coming from a language like modern JavaScript where it’s relatively simple to do very complex things, I don’t want to understate the differences. There are very big differences. C doesn’t come with as much “out of the box.” C is not interpreted; you MUST compile your code in order to run it. It doesn’t support many of the nice high-level data types you’d expect from a high-level language these days; for instance, there’s no structure that’s quite like a JavaScript object with key/value pairs, and “string” is not a data type—it’s just an array of characters that’s terminated with the null character!</p><p>BUT! Certain fundamental programming concepts will have familiar implementations in C, and for writing basic programs, it’s not nearly as unapproachable as you may think. I realized this very quickly when I started reading <a href="http://a.co/desSHgf">The C Programming Language, 2nd Edition</a>, by Brian W. Kernighan and Dennis M. Ritchie. The following is a simple program from Chapter 1 which converts Fahrenheit values into their corresponding values in Celsius, with some basic output formatting:</p><pre>#include &lt;stdio.h&gt;<br> <br>/* print Fahrenheit-Celsius table<br>   for fahr = 0, 20, ..., 300 */</pre><pre>main()<br>{<br>  int fahr, celsius;<br>  int lower, upper, step;<br> <br>  lower = 0;      /* lower limit of temperature table */<br>  upper = 300;    /* upper limit */<br>  step = 20;      /* step size */<br> <br>  fahr = lower;</pre><pre>  while (fahr &lt;= upper) {<br>    celsius = 5 * (fahr-32) / 9;<br>    printf(&quot;%d\t%d\n&quot;, fahr, celsius);<br>    fahr = fahr + step;<br>  }<br>}</pre><p>What really struck me about this code is how similar a JavaScript implementation could be! In fact, to get a similar result in JavaScript, we need only make a few small modifications.</p><pre>function fcConvert()<br>{<br>  let fahr, celsius;<br> <br>  const lower = 0;<br>  const upper = 300;<br>  const step = 20;<br> <br>  fahr = lower;</pre><pre>while (fahr &lt;= upper) {<br>    celsius = 5 * (fahr-32) / 9;<br>    console.log(`${fahr}\t\t${celsius}`)<br>    fahr = fahr + step;<br>  }<br>}</pre><p>Compare the JavaScript code above with the C example. They’re incredibly close. Let’s highlight the main differences:</p><ul><li>C has this weird #include &lt;stdio.h&gt; line at the beginning. What gives? This line is called a <em>preprocessor directive</em>. There are several steps to compiling a C program that we won’t get into here, but this line is basically telling our C compiler, “In the process of compiling this application, be sure to include the standard library functions for input and output.” This is what allows us to use printf() to get formatted output in the terminal (another one of our differences with JavaScript).</li><li>Wait, does that main() look like a function definition?? Yup. When we work with C, main() is always first thing that gets run when we compile and execute our application. In larger applications, we won’t write all of our code inside this function, but will define other functions and call those from within main().</li><li>In C, we have to declare our variables as a specific type from the very beginning; in this case, as integers. This is different from JavaScript where we can put pretty much whatever we want, any time we want, inside of a variable.</li></ul><p>That about covers it! In a later example, the C code above is modified to use a for loop, and to calculate floating point numbers rather than integers.</p><pre>#include &lt;stdio.h&gt;<br> <br>/* print Fahrenheit-Celsius table */</pre><pre>main()<br>{<br>  int fahr;<br><br>  for (fahr = 0; fahr &lt;= 300; fahr = fahr + 20)<br>    printf(&quot;%3d %6.1f\n&quot;, fahr, (5.0/9.0)*(fahr-32));<br>}</pre><p>The code inside our for loop is a single line and thus, in C, we do not need to enclose it within curly braces. Aside from that, the syntax for our for loop is exactly what we’re used to with JavaScript! Our conditional expression contains an initializer, a condition to test, and an increment. That’s it!</p><h3>Wait, but what about that compilation stuff!?</h3><p>The one additional thing you’ll have to figure out is how to compile your programs. If you’re using Bash on macOS/Linux/BSD, here are a couple of pointers:</p><ul><li>For simple programs, you can create a single file ending in a .c extension, open it up in your code editor of choice, write your code, and save.</li><li>You can compile in a terminal using gcc or clang—the syntax is similar. As an example, if I were in a directory with a file I created called main.c, the simplest syntax I could use would be something like clang main.c. By default, this generates an executable named a.out which I can then run like any other.</li><li>A common thing to do is to change the name of the executable which the compiler outputs. For instance, say that instead of a.out I would like my executable to be called app. I could run clang main.c -o app.</li></ul><p>If you’ve been thinking about playing around with C, I hope this convinces you to just dive in and give it a go. <a href="http://a.co/desSHgf">The C Programming Language</a> which I mentioned earlier is widely considered to be one of the best resources when starting out, and I highly recommend it!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1ce08eddec32" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cryptography—What Is It and How Does It Work?]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@chrisjagius/cryptography-what-is-it-and-how-does-it-work-2a21a730d694?source=rss-771c02c6f907------2"><img src="https://cdn-images-1.medium.com/max/820/1*5WajhLbPptMMtDIOyS44aw.png" width="820"></a></p><p class="medium-feed-snippet">A High-Level Overview With Examples Using Ruby + OpenSSL</p><p class="medium-feed-link"><a href="https://medium.com/@chrisjagius/cryptography-what-is-it-and-how-does-it-work-2a21a730d694?source=rss-771c02c6f907------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@chrisjagius/cryptography-what-is-it-and-how-does-it-work-2a21a730d694?source=rss-771c02c6f907------2</link>
            <guid isPermaLink="false">https://medium.com/p/2a21a730d694</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[cryptography]]></category>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Chris J. Agius]]></dc:creator>
            <pubDate>Tue, 05 Jun 2018 19:41:35 GMT</pubDate>
            <atom:updated>2019-05-17T20:05:20.209Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Quick and Dirty XML Parsing with XmlSimple]]></title>
            <link>https://medium.com/@chrisjagius/quick-and-dirty-xml-parsing-with-xmlsimple-56bb84a13e86?source=rss-771c02c6f907------2</link>
            <guid isPermaLink="false">https://medium.com/p/56bb84a13e86</guid>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[xml]]></category>
            <category><![CDATA[transit]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[codingbootcamp]]></category>
            <dc:creator><![CDATA[Chris J. Agius]]></dc:creator>
            <pubDate>Mon, 14 May 2018 17:42:41 GMT</pubDate>
            <atom:updated>2018-05-14T17:42:41.420Z</atom:updated>
            <content:encoded><![CDATA[<p>Recently, a classmate and I worked on an application that would allow a user to create trips involving the MTA subway, and get status information for the lines used for each trip. This required us to poll the MTA’s status feed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hr5MvoSjkHOhIeYo." /><figcaption>Obligatory subway photo. (<a href="https://unsplash.com/@ingle_jake?utm_source=medium&amp;utm_medium=referral">Jake Ingle</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a>)</figcaption></figure><p>At first we struggled to understand the MTA’s feeds and their respective formats; the first real time feed we encountered used a protocol called GTFS Realtime, which is an extension of the existing GTFS format using Google’s <a href="https://developers.google.com/protocol-buffers/">protocol buffers</a> (this is will probably be the topic of a future blog post).</p><p>Ultimately, we realized that we spent a bunch of time trying to parse the wrong feed. The MTA’s line status feed uses a protocol called <a href="https://en.wikipedia.org/wiki/Service_Interface_for_Real_Time_Information">SIRI (Service Interface for Real time Information)</a>. This protocol is based on XML, which is easier to parse compared to the binary protocol buffers.</p><p>At first, we tried using Nokogiri to parse the XML. I started going through the documentation, but I had a hard time just figuring out how to traverse the structure. As we were in a time crunch, I wasn’t very keen on reading deeply into the documentation. I wondered if there was a gem that would convert an XML document into a Ruby hash so that I could work with a structure I already knew. Enter XmlSimple.</p><p>As a disclaimer, use of XmlSimple is generally discouraged, as XML and hashes are somewhat dissimilar ways to structure data. However, for our purposes, it worked beautifully.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ci9bJLdUDnlxZQqNNe8ZmQ.png" /><figcaption>Sweet, sweet MTA status updates.</figcaption></figure><p>One thing to note is that XmlSimple enables an option called ‘ForceArray’ by default, meaning the resulting hash is a little bit ugly as it contains a bunch of single-element arrays. You can turn this option off, but this is also not recommended as it helps to retain the parent-child structure present in XML.</p><p>Once we had our XML parsed into collections of collections, we traversed the collections using standard hash and array notation to get the relevant information. We then passed that information into status objects associated with subway line objects, giving us the structure and relationship information we needed to report back to the user.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=56bb84a13e86" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ruby’s ‘self’ in the Context of Objects]]></title>
            <link>https://medium.com/@chrisjagius/rubys-self-in-the-context-of-objects-571e904d5315?source=rss-771c02c6f907------2</link>
            <guid isPermaLink="false">https://medium.com/p/571e904d5315</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[object-oriented]]></category>
            <dc:creator><![CDATA[Chris J. Agius]]></dc:creator>
            <pubDate>Mon, 07 May 2018 16:21:04 GMT</pubDate>
            <atom:updated>2018-05-07T16:21:04.511Z</atom:updated>
            <content:encoded><![CDATA[<p>Pretty much everything in Ruby is an object, and all objects in Ruby are self-aware. This is very useful for automation and abstracting functionality. Ruby itself is context-aware. This is useful for both abstraction and reducing keystrokes, as objects don’t always have to be called explicitly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*SKjS724rfmzX7Vaj." /><figcaption>No, not THAT kind of self-aware. (<a href="https://unsplash.com/@agkdesign?utm_source=medium&amp;utm_medium=referral">Alex Knight</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a>)</figcaption></figure><p>Unfortunately, these features often confuse developers who are just starting out. In particular, the ‘self’ keyword trips many people up. So what is ‘self’? <a href="http://blog.honeybadger.io/ruby-self-cheat-sheet/">Honeybadger’s ‘self’ cheat sheet</a> puts it succinctly:</p><blockquote>self is a special variable that points to the object that &quot;owns&quot; the currently executing code.</blockquote><p>But what does that actually mean? Let’s dive into the most basic of code and have a look using <a href="http://pryrepl.org/">Pry</a>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4bdb6b51d2e42bdb297d04e8f872c974/href">https://medium.com/media/4bdb6b51d2e42bdb297d04e8f872c974/href</a></iframe><p>Some people might be thinking, “Why couldn’t we just use IRB?” I do it this way to illustrate that we are not within any class or class instance. This is the entirety of our Ruby code. So what happens when we execute this code and type ‘self’ into our console?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0y1Nn5KdM_MnfOcVqNsp3g.png" /></figure><p>As we can see, ‘self’ in this context refers to Ruby’s ‘main’ object, or the top-level scope of our program. This is what we’d expect, as this is where we’ve written our code. Now, let’s create a class, define some methods, and create some instances to play with.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d3af41ac0beb305a834717ac13ccd7d3/href">https://medium.com/media/d3af41ac0beb305a834717ac13ccd7d3/href</a></iframe><p>Yes, this code is pretty useless and yes, we normally wouldn’t cram everything into a single file. But for the purposes of illustration, this should do just fine. The first thing you may notice is ‘plural’ and ‘where_go?’ are defined as both instance and class variables.</p><p>Now, let’s pry into our code and see what happens when we call our methods:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y92L4jpytevDVfR6WOxWLg.png" /></figure><p>So what exactly is happening here? Let’s put in some more calls to Pry:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/db1c0cb469c7ad598e8ebcf401cf5695/href">https://medium.com/media/db1c0cb469c7ad598e8ebcf401cf5695/href</a></iframe><p>Now that we can get into our ‘where_go?’ functions, let’s take a look inside.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wq_nL3-krHDjpXeiy008Ug.png" /></figure><p>Above I’ve called .where_go? on the Dog class. As we can see, while inside of .where_go? (which is a class method for the Dog class), self refers to the Dog class. Easy peasy. Now let’s look at the #where_go? instance method:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6V5Z3Nm5x9pSF2-oQv5t3A.png" /></figure><p>Here inside of our instance method, ‘self’ refers to <strong>the particular instance of the Dog class on which we called our method,</strong> in this case ‘lassie’. This is where the usefulness of ‘self’ really shines. Let’s call our #where_go? method on a couple of other instances:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QWBr_Kb4peAcOnysLkqDbQ.png" /><figcaption>Here, ‘self’ refers to the ‘fido’ instance of the Dog class.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XWJivcJmu8MQOuEVoNASRQ.png" /><figcaption>And in this case, ‘self’ refers to ‘benji’.</figcaption></figure><p>When working with instances, ‘self’ allows us to work on any instance of a class without needing to know in advance what that instance will be called. We don’t know in advance what our instances will be named; the possibilities are infinite. Using ‘self’ means that we don’t <strong>need</strong> to know in advance what instances might be created.</p><p>Okay, so what about our #plural and .plural functions? They both call a method ‘name’. What is ‘name’ being called on? This is the <strong>implicit self</strong>. If we call a method without specifying the object on which it should be called, Ruby will call the method on ‘self’. If we changed ‘name’ in these methods to ‘self.name’, they would work just the same.</p><p>One pitfall to watch out for when using the implicit self: when Ruby has multiple options in deciding where to look for a method or variable, it will go from greatest to least specificity. In other words, imagine we define our ‘plural’ methods with an argument we call ‘name’. The method would then interpolate whatever we pass in as our ‘name’ argument. For example, if we were to call Dog.plural and pass in “turtles” as an argument, our result would be, “All turtles go to heaven.”</p><p>Hope this helps someone! Please do comment if anything is unclear or if you have any questions.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=571e904d5315" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>