<?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 Wescott Sharples on Medium]]></title>
        <description><![CDATA[Stories by Wescott Sharples on Medium]]></description>
        <link>https://medium.com/@wesc_19420?source=rss-ec734f0a0464------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*zjdp-Xl8buUfV5LK.</url>
            <title>Stories by Wescott Sharples on Medium</title>
            <link>https://medium.com/@wesc_19420?source=rss-ec734f0a0464------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 13:59:36 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@wesc_19420/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[What happens when you type “https://holbertonschool.com" in your browser?]]></title>
            <link>https://medium.com/@wesc_19420/what-happens-when-you-type-https-holbertonschool-com-in-your-browser-b9ec815cc108?source=rss-ec734f0a0464------2</link>
            <guid isPermaLink="false">https://medium.com/p/b9ec815cc108</guid>
            <category><![CDATA[servers]]></category>
            <category><![CDATA[browsers]]></category>
            <category><![CDATA[https]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Wescott Sharples]]></dc:creator>
            <pubDate>Mon, 15 Apr 2019 06:53:33 GMT</pubDate>
            <atom:updated>2019-04-16T18:10:00.141Z</atom:updated>
            <content:encoded><![CDATA[<p>…and press Enter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z7YmDo4_eLit0PPBbWtKjA.jpeg" /></figure><p>So there I was: typing <a href="https://holbertonschool.com&/#39;">https://holbertonschool.com</a> into my browser and hitting Enter. The screen hung for a second or two, then <em>BAM</em>: I was at a beautifully mocked up landing page of my school. I thought to myself, what is this sorcery? What happened in those one to two seconds (subject to variation based on your internet speed)? Here is my best attempt at demystifying this magic.</p><p>What is <a href="https://holbertonschool.com&/#39;">https://holbertonschool.com</a>? It’s a Uniform Resource Locator (URL). A URL is a type of Uniform Resource Identifier which is a label used to identify things on the World Wide Web. You may be more familiar with URLs such as <a href="https://google.com&/#39;">https://google.com</a> or <a href="http://www.cutecatgifs.com/&#39;">http://www.cutecatgifs.com/</a>; I don’t judge.</p><p>The ultimate goal is to convert a URL like <a href="https://holbertonschool.com&/#39;">https://holbertonschool.com</a> into an Internet Protocol address (IP address) like 99.84.216.49.</p><p>Often we can simply type holbertonschool.com and get to the page we desire because our browser will fill in the missing information. The protocol identifier is often added automatically by your browser. What is it?</p><h3>Breaking Down the URL</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ohyfYwEe33frAZS_fJBVPA.jpeg" /></figure><h4>HTTP</h4><p>HyperText Transfer Protocol (HTTP) is a protocol for sending and receiving messages. It essentially instructs web servers, browsers, and the World Wide Web on how to respond to commands.</p><h4>HTTPS</h4><p>HyperText Transfer Protocol Secure (HTTPS) is like HTTP, but, umm, secure. More specifically, all communication between your browser and the websites are encrypted. HTTPS is typically used to protect confidential online transactions but has become somewhat of an industry standard for all websites today.</p><p>It’s important to use HTTPS because all HTTP communication is sent as plain text. So, if you enter sensitive information like your credit card number in an unsecured website, hackers can break into that connection and steal the information with ease.</p><h4>://</h4><p>:// signifies the beginning of the protocol which accesses a resource. It separates the protocol identifier and resource name.</p><h4>www</h4><p>www is a subdomain. Subdomains can be configured by the website provider to serve different web pages. Often `www` will point to the home page of a website, but that’s not always the case. Websites will often use subdomains to separate their content clearly, such as using an `info` subdomain to direct you to the information page of their website.</p><h4>.com</h4><p>.com is a top-level domain (TLD). There are now over 1000 TLDs from your common .com to your esoteric .pizza. The TLD tells the Domain Name Service which server to ask for the IP address if it can’t find it.</p><h3>Converting the URL to an IP Address</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C_KCdZkvLmxSSO9KSGiYhg.png" /></figure><p>What exactly goes on during this process?</p><p>0) You type in a URL and hit Enter<br>1) The browser and operating system (OS) check if they have the IP stored in memory<br>2) If not yet found, they check with the Domain Name Service (DNS), whose job it is to translate human-readable URLs into machine-readable IP addresses<br>3) If not yet found, the DNS checks with the Resolving Name Server (RNS)<br>4) If not yet found, the RNS checks with the root servers<br>5) Then the TLD server which holds the information for each specific TLD (.com, .org, .pizza)<br>6) Then the Authoritative Name Servers (ANS)</p><p>The buck stops here. If we haven’t found the IP address at this point, then you either made a typo or got really unlucky. Once the IP address is located, it’s passed back down the line to your browser, which will cache it in memory for next time.</p><h3>How Websites Serve Content</h3><h4>SSL</h4><p>Remember earlier, when HTTPS came up and I threw around the words “secure” and “encrypted” like I knew what I was talking about? Well, I feel like I owe you a better explanation of how the encryption actually works. HTTPS uses Secure Sockets Layer (SSL) and Transport Layer Security (TLS) certificates. <a href="https://holbertonschool.com&/#39;">https://holbertonschool.com</a> will send an SSL certificate to your browser which contains a public key. That public key initiates a handshake. When HTTPS is in effect, there should be a green lock on the left side of the URL.</p><h4>TCP/IP</h4><p>Transmission Control Protocol (TCP)/Internet Protocol (IP) is the combination of protocols used by all devices connected to the internet to communicate. It specifies that data should be broken into packets and how those packets should be transmitted, routed, and received. While TCP defines the “how” behind communication across the internet, IP defines the, well I guess it defines the “how” also. But, it’s a different kind of “how.” IP species how the addressing is handled to ensure the packets reach the desired location.</p><h4>Server</h4><p>A server is typically a computer without a keyboard, mouse, or screen that is only accessible through a network. It can be either physical or virtual. A server designed to serve web content usually includes an application server, web server, database, and source code. Nothing on the web works without servers.</p><p>Multiple servers are important for the speed at which your website serves content and redundancy in case anything goes wrong.</p><h4>Application Server</h4><p>The application server is a software framework designed to handle all operation between a user and the back-end of a website. It serves dynamic content by creating HTML files on the fly using languages such as Python, PHP, or Ruby.</p><h4>Web Server</h4><p>Web servers are server software or hardware designed to serve web pages. It processes dynamic and static web content and delivers the HTML, CSS, and other items such as images to the browser.</p><h4>Database</h4><p>The database is an organized and structured set of data stored on a computer. It exists so information can be accessed, deleted, and updated easily and efficiently.</p><p>Databases can be configured in Master-Slave formation. This sounds ominous, but all it means is that one device (the master) is in charge of letting all the other slave devices know when the “master logs” are updated. This way all data remains synchronized.</p><h4>Load Balancer</h4><p>The load balancer distributes the workload to multiple servers: increasing the overall reliability, efficiency, and speed of your website. Load balancers can be configured with different algorithms. One such algorithm is the “round robin” passes each incoming connection to the next server in line. Load balancers can be configured in Active-Active or Active-Passive modes. Active-Active means all servers are active, while `Active-Passive` means one or more servers are standing by in case of failure. Regardless of the configuration, it’s important the servers keep up to date with one another, so if one fails your data is not lost.</p><h4>Firewalls</h4><p>Firewalls are the final element of web configuration we are going to discuss in this article. Firewalls are additional security measures which prevent unauthorized users from accessing private networks connected to the Internet. You can also use additional monitoring tools to access data being collected by your server.</p><h3>Recap</h3><p>I know that was a lot of modular information, but it’s important to not lose sight of the larger objective: getting from <a href="https://holbertonschool.com&/#39;">https://holbertonschool.com</a> to a fully functioning website. To summarize: you type in a URL, hit Enter, the DNS converts the URL into an IP address, the OS passes the IP through TCP/IP, creates a handshake using SSL if available, and passes the connection to the load balancer. The load balancer finally connects you to the optimal server which makes use of the application server in the case of dynamic content to generate HTML. Finally, the web server serves the HTML page to your browser.</p><p>All in all, it’s not magic, but it may as well be.</p><p>Thanks for reading. If anything is unclear or I got anything wrong, please let me know.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b9ec815cc108" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Conversation about Machine Learning with Mom]]></title>
            <link>https://medium.com/@wesc_19420/a-conversation-about-machine-learning-with-mom-97390453d90?source=rss-ec734f0a0464------2</link>
            <guid isPermaLink="false">https://medium.com/p/97390453d90</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Wescott Sharples]]></dc:creator>
            <pubDate>Sun, 27 Jan 2019 05:48:15 GMT</pubDate>
            <atom:updated>2019-01-27T05:51:55.339Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/940/0*-x1jPb6xfSc0ZRPh" /></figure><p>My mom is visiting from Seattle and we got into a conversation about machine learning and artificial intelligence. Some of the questions she asked seemed like questions a lot of people may have.</p><p>MOM: Hey Wescott, you know how there are so many buzzwords these days like “machine learning,” “artificial intelligence” and “big data?” Can you please explain what they are and how they relate to each other? It is really confusing.</p><p>ME: OK….why don’t you tell me what you think machine learning is first.</p><p>MOM: I kind of think that it means building the capacity for a non-biological item to gain “smarts” over time based on input. Does that make any sense?</p><p>ME: Yes, that is basically it.</p><p>I think that there is an unnecessary complexity ascribed to machine learning. People assume that it must be some complicated thing but it is really not. It is actually what it says. Machine learning is getting a machine to understand and draw conclusions through a series of steps, called algorithms, which are really just based on the probability of data sets.</p><p>The advantage of machine learning is that machines can analyze extremely large data sets that would take humans eons to parse with just our six senses. Therefore, if we can teach a machine how to do it, the machine can intake all of the information and then give us conclusions that maybe humans would have arrived at if we had the capacity to analyze all the data, but we don’t. So that’s the advantage and that is why it is such an important technology in the present day.</p><p>MOM: Ok. So can I propose a simple example and you can tell me if it is machine learning or not?</p><p>ME: Sure.</p><p>MOM: Ok….let’s say I want to teach my toaster to toast my bread perfectly for me, would that be considered machine learning?</p><p>ME: Yes.</p><p>MOM: So is machine learning at the core just software teaching software? Because how do you teach a physical item to do anything?</p><p>ME: Yes, it is software “learning.” And “learning” is in quotes because it is a big debate as to what really constitutes “learning.” In fact, there is a whole branch of philosophy called epistemology that tests the theories of knowledge but that is a tangent for another conversation. Essentially, teaching your toaster would be similar to teaching a toddler how to make toast every morning.</p><p>MOM: So if I could add thumbprint technology to my toaster so that it knew it was me and then als add “smiley face” and “frowny face” buttons that I press afterward to indicate whether I liked or didn’t like the toast, the toaster could learn over time to toast more bread the way I like and less the way I don’t like.</p><p>ME: Yes, you are using an example of one of the most popular types of machine learning called supervised machine learning because you are giving it human input that is an indicator of success. Over time, the success factor will mold the machine into creating the desired output.</p><p>MOM: So basically, the next level of machine learning is the one that so many scientists are debating right now which is the version where you don’t need the human input and the machine is learning and iterating on its own?</p><p>ME: Yes, we already have unsupervised machine learning and it is very popular right now. It is up to the programmer to decide which algorithm is best suited for the given problem.</p><p>MOM: And by algorithm you mean supervised or unsupervised?</p><p>ME: Yes. And unsupervised would look like a machine taking a very large data set and pointing out anomalies in it simply based on patterns it recognizes. This can be helpful for applications like credit card fraud or spam because it might figure out new indicators for these anomalies that might never occur to a human because it is something extremely nuanced or because it takes a really large amount of data processing to figure out that it is an anomaly.</p><p>MOM: Right, for example, if there were millions and millions of records, to a human it would be way too daunting to go through it all where a machine can do it in seconds. And can do so without making a single error or missing anything.</p><p>ME: Yes.</p><p>MOM: Is this unsupervised machine learning at the core of artificial intelligence? Is this where AI comes in? What is the difference between AI and machine learning? They sound kind of the same to me.</p><p>ME: Machine learning is just a sub-discipline of artificial intelligence. It is an implementation of artificial intelligence.</p><p>MOM: Oh.</p><p>ME: Way back when electronics companies created the first calculators in the 1950s, that was considered artificial intelligence. Now our definition of artificial intelligence has grown beyond calculations and intelligent acts that humans can perform and it is now about cognition and decision making and categorization. Tomorrow who knows what it will be. The definition keeps expanding and machine learning is a way to achieve artificial intelligence.</p><p>MOM: Interesting. So you’re saying that the definition of artificial intelligence is a moving target in terms of what it encompasses. I remember reading a few of years ago about many of the smartest minds, including Stephen Hawking, Bill Gates and Elon Musk speaking out with concern regarding machine learning and artificial intelligence. I recall they warned that it could be the end of humanity. Do you remember that? What was that about?</p><p>ME: Yes, they are very worried about the advent of general AI which would be artificial intelligence that can infer outcomes of its actions in the world and can interact with the world. It is an existential risk.</p><p>MOM: So their concern is that at some point machines get so good at learning on their own that they can become smarter than humans and overtake humans and make decisions beyond the scope of what we have the capacity to understand right now?</p><p>ME: That is one worry, but I think the more immediate concern for those people is best illustrated by a video I watched on YouTube called <strong><em>The Deadly Truth Of General AI </em></strong>on The Computerphile Channel. It is a story about AI gone awry that outlines where it could go wrong and shows we are closer than we think to this disruptive capability of AI. In the video, a programmer decides he wants to amass a stamp collection and he gives a machine learning algorithm a parameter to collect as many stamps as possible. The programmer wants the algorithm to adapt and find new approaches to gathering more and more stamps.</p><p>MOM: Are these physical stamps or digital stamps?</p><p>ME: Physical stamps. He is just a stamp collector. So the program first operates online and analyzes HTML and starts buying stamps on eBay and optimizes buying at the last second to get the best price. Then the algorithm realizes it can disintermediate other buyers by going directly to the sellers to get the entire inventory. Next it recognizes that it can hack into the wireless printers making the stamps and print its own stamps to yield the highest number of stamps. Finally, the machine gets every printer in the world making stamps and then runs out of the raw materials to make stamps including paper, carbon, oxygen so it starts harvesting all the trees. After deleting those resources, the machine could leap directly to trying to get the materials from human bodies. The video ends with a caution that these machines can be extremely dangerous and they are dangerous the moment you turn them on because all of this can happen in milliseconds.</p><p>MOM: Because it can propagate to other computers before you are able to turn it off?</p><p>ME: Yes, this can happen in less than a second before humans can even perceive what is going on. This is why stock brokers who have experimented with machine learning and AI in the past to buy and sell stocks have lost millions in less than a second. There was an example of an algorithm that bought and sold and bought and sold millions of stocks in less than a second. It all happened in fractions of a second before the brokers could realize the machine was failing at what it was supposed to do, it was too late.</p><p>MOM: Before they could even perceive what was happening?</p><p>ME: Yes. This is why they have to build preventative measures into algorithms. This is what The Future Of Humanity Institute at Oxford University is trying to do. Build fail-safes into general AI in case there are no humans who can pull the plug; the machine can pull the plug on itself.</p><p>MOM: Ok…last question. If Elon Musk, Bill Gates and Stephen Hawking, all really smart people, are worried about this, why did Mark Zuckerberg say he isn’t worried? Is he just trying to be a contrarian, does he know something we don’t know or is he just not thinking about the issue correctly?</p><p>ME: No, I think AI is like any tool. Any tool that has a lot of capabilities, both constructive and destructive is going to be adored by some people and despised and feared by others. Sebastian Thrun, Founder of Google X, says every technology comes with its risks and with its potential for abuse. You can use a knife to cut your food but also to stab somebody and the same is true for AI. I am not sure that is a great analogy.</p><p>MOM: No, it is good. Machine learning and AI can be used for good or for bad.</p><p>ME: Yes, it is a tool. Nick Bostrom, Founder of The Future Of Humanity Institute, asserts as part of his central thesis, that if we program machines right, we will drastically change our lives for the better but we have to be careful.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=97390453d90" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mutable vs. Immutable Objects in Python]]></title>
            <link>https://medium.com/@wesc_19420/mutable-vs-immutable-objects-in-python-ada760cdcc69?source=rss-ec734f0a0464------2</link>
            <guid isPermaLink="false">https://medium.com/p/ada760cdcc69</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[oop]]></category>
            <category><![CDATA[object-oriented-design]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Wescott Sharples]]></dc:creator>
            <pubDate>Fri, 11 Jan 2019 07:53:35 GMT</pubDate>
            <atom:updated>2019-01-11T10:05:26.745Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Fxs0U2V57SgsO_DdfuZXSg.jpeg" /></figure><p>Python is an object-oriented programming language. When we create variables in Python, they refer to objects which belong to predefined classes. You can think of a class as a cookie cutter from which we create different cookies with features, such as shape, already established.</p><p>Take a look at a simple illustration of this idea below. Please note that everything after the # is considered a comment and ignored by the interpreter.</p><pre>&gt;&gt;&gt; var = 1 #Assigning variable &#39;var&#39; to the value 1<br>&gt;&gt;&gt; id(var) #Printing the ID of &#39;var&#39;<br>10105088</pre><p>var is an object instantiated from the integer class. When an object is instantiated, it is assigned a unique ID (the 10105088 in our example)which typically corresponds to its address in memory, but this can depend on your system and version of Python.</p><p>Given the ubiquity of objects in Python, it would be wise to familiarize ourselves with an important and confounding concept: <strong>object mutability</strong>. <em>In Python, objects can either be mutable or immutable.</em> What does that mean?</p><h3>Mutable Objects</h3><p>Mutable objects are objects which can change state and data after inception.</p><blockquote>Lists, dictionaries, sets, and byte arrays are mutable</blockquote><p>Every time a mutable object is changed, its ID will remain the same because it is fundamentally the same object.</p><pre>&gt;&gt;&gt; list = [1, 2, 3] #Creating a new list variable &#39;list&#39;<br>&gt;&gt;&gt; list #Printing the contents of &#39;list&#39;<br>[1, 2, 3]<br>&gt;&gt;&gt; id(list) #Printing the ID of &#39;list&#39;<br>140184172169224<br>&gt;&gt;&gt; list += [4] #Adding a fourth element to &#39;list&#39;<br>&gt;&gt;&gt; list <br>[1, 2, 3, 4] #The list now contains four numbers<br>&gt;&gt;&gt; id(list)<br>140184172169224 #The ID remains the same</pre><p>You may be inclined to think that Python would economize memory by automatically assigning the same ID to mutable objects with the same data. However, Python errs on the side of caution and always assigns mutable objects distinct IDs because there is a likelihood they will be changed in the future.</p><pre>&gt;&gt;&gt; list1 = [1, 2, 3] #Creating two identical lists with different names<br>&gt;&gt;&gt; list2 = [1, 2, 3]<br>&gt;&gt;&gt; list1 == list2 #Are they equivalent in value?<br>True<br>&gt;&gt;&gt; list1 is list2 #Are they the same object?<br>False #This means they have different and unique IDs<br>&gt;&gt;&gt; id(list1)<br>140184172169224 #Unique ID<br>&gt;&gt;&gt; id(list2)<br>140184172177544 #Unique ID</pre><p>Well, almost always. There is one exception in which case mutable objects will share an ID. When the object is initialized through assignment it shares the ID.</p><pre>&gt;&gt;&gt; list1 = list2 #Assigning &#39;list1&#39; to &#39;list2&#39;<br>&gt;&gt;&gt; list1 is list2 #Are they the same object?<br>True<br>&gt;&gt;&gt; id(list1)<br>140184172177544<br>&gt;&gt;&gt; id(list2)<br>140184172177544 #Same ID</pre><h3>Immutable Objects</h3><p>Immutable objects are objects which cannot be altered. Once you create an immutable object, it’s fixed until it’s assigned a new value.</p><blockquote>Integers, floats, complex, strings, tuples, frozen sets (the immutable version of a set), and bytes</blockquote><p>When you change an immutable object, its ID will change as well because you are instantiating a new object.</p><pre>&gt;&gt;&gt; var = 1 #Assigning integer variable &#39;var&#39; to the value 1<br>&gt;&gt;&gt; id(var)<br>10105088<br>&gt;&gt;&gt; var += 1 #Incrementing &#39;var&#39; thus changing its value to 2<br>&gt;&gt;&gt; id(var)<br>10105120 #New ID<br>&gt;&gt;&gt; var = 99 #Assigning &#39;var&#39; to new value of 99<br>&gt;&gt;&gt; id(var)<br>10105152 #Another new ID</pre><p>Upon declaration, if immutable objects share data, they will possess the ID. Python automatically does this to save memory because it knows that the immutable objects will not change.</p><pre>&gt;&gt;&gt; name1 = &quot;Wescott&quot; #Creating a string &#39;name1&#39;<br>&gt;&gt;&gt; name2 = &quot;Wescott&quot; #Creating another string with same content as &#39;name1&#39;<br>&gt;&gt;&gt; name1 is name2 #Is &#39;name1&#39; the same object as &#39;name2&#39;?<br>True</pre><p>We call name2 an alias for name1 because it refers to the same object, just with a new name.</p><h3>Identifying Object Mutability</h3><p>How can we tell if an object is mutable or immutable?</p><p>The id() function accepts an object as a parameter and returns the “identity” of that object.</p><pre>&gt;&gt;&gt; var = 1<br>&gt;&gt;&gt; id(var)<br>10105088</pre><p>This “identity” is a unique number (in this case: 10105088). You can think of this number as the object’s social-security number.</p><p>The type() function accepts an object as a parameter and returns the type of that object.</p><pre>&gt;&gt;&gt; var = 1<br>&gt;&gt;&gt; type(var)<br>&lt;class &#39;int&#39;&gt;</pre><p>Using these functions, and our knowledge of object mutability, we can infer that if an object changes IDs every time we change its value, then it is immutable. Conversely, if an object’s ID remains the same despite being changed then it is mutable. We can also just remember the mutable and immutable object types as we get more familiar with Python, and use the type() function to figure out what we are dealing with.</p><h3>Why does it matter?</h3><p>Memory efficiency, code safety, and readability greatly benefit from picking the correct data types.</p><p>Immutable objects are more efficient to access and store than mutable objects. Immutable objects are expensive to alter because doing so involves creating a copy. Changing mutable objects however is cheap.We should use mutable objects when we know the contents or size of an object will change, but use immutable objects when we want to ensure the contents will be preserved.</p><h3>Immutable Object Nuance</h3><p>Not all immutable objects in Python are completely immutable.</p><p>For example, tuples are immutable. But what do tuples really hold? Tuples hold references to objects in the form of object IDs. These object IDs must be preserved, however the objects they refer to may be mutable.</p><p>If you have a tuple with a list element, the contained list element can be changed because the ID will remain the same, thus leaving the contents and state of the tuple intact.</p><pre>&gt;&gt;&gt; dog = (&quot;Wasabi&quot;, [&quot;Black&quot;, &quot;White&quot;]) #Defining tuple variable &#39;dog&#39; containing the dog&#39;s name and colors<br>&gt;&gt;&gt; id(dog)<br>139761689815368<br>&gt;&gt;&gt; dog[1][1] = &quot;Brown&quot; #Changing dog&#39;s second color to brown<br>&gt;&gt;&gt; dog<br>(&quot;Wasabi&quot;, [&quot;Black&quot;, &quot;Brown&quot;])<br>&gt;&gt;&gt; id(dog)<br>139761689815368 #ID remains unchanged</pre><p>It is important to remember that the values of an immutable object can’t change, but if those values are mutable, then the values of those values can. Hopefully, that makes sense.</p><h3>Passing Objects to Functions</h3><p>When you pass mutable objects to a function by reference, you can permanently change it.</p><pre>&gt;&gt;&gt; def alter(list): #Defining a new function &#39;alter&#39;<br>...     list += [99] #Adds 99 to the parameter &#39;list&#39;<br>...<br>&gt;&gt;&gt; numbers = [1, 2, 3] #Making a new list called &#39;numbers&#39;<br>&gt;&gt;&gt; alter(numbers) #Calling &#39;alter&#39; on &#39;numbers&#39;<br>&gt;&gt;&gt; numbers<br>[1, 2, 3, 99] #Changed numbers outside the scope of &#39;alter&#39;</pre><p>We call this a function side effect because it changes a variable without explicitly doing so through a return statement. You will sometimes see functions that make a copy of a variable before altering it to avoid side effects.</p><p>When you pass an immutable object into a function, its value can only be changed within the scope of that function.</p><pre>&gt;&gt;&gt; def alter(number): #New function &#39;alter&#39; now takes &#39;number&#39; as parameter<br>...     number += 99<br>...<br>&gt;&gt;&gt; var = 1 #Defining new integer variable &#39;var&#39;<br>&gt;&gt;&gt; alter(var) #Passing integer variable to &#39;alter&#39;<br>&gt;&gt;&gt; var<br>1 #Value is not changed outside the scope of &#39;alter&#39;</pre><p>The changes will not permeate into the code that calls the function. This is referred to as pass by value because we are passing the object’s value instead of the object itself.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ada760cdcc69" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Static vs. Dynamic Libraries in C]]></title>
            <link>https://medium.com/@wesc_19420/static-vs-dynamic-libraries-in-c-38d2ff1db934?source=rss-ec734f0a0464------2</link>
            <guid isPermaLink="false">https://medium.com/p/38d2ff1db934</guid>
            <category><![CDATA[libraries]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[c]]></category>
            <dc:creator><![CDATA[Wescott Sharples]]></dc:creator>
            <pubDate>Tue, 11 Dec 2018 07:26:37 GMT</pubDate>
            <atom:updated>2018-12-11T07:26:37.125Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5qpcOrSwad1u-jE5Ls8Fsg.jpeg" /></figure><h3>When and why would we use libraries?</h3><p>Imagine you are writing a paper on the evolution and history of tortoises in Madagascar. You just want to dive right into writing about tortoises and don’t want to be bothered rehashing Darwin’s entire theory of evolution. Naturally, you just simply invoke his theory by name: “Darwin’s theory of evolution.” Additionally, you cite Darwin’s seminal book, <em>“On the Origin of Species”</em>, so those who don’t know what the “theory of evolution” is can go to the <strong>library</strong><em> </em>and see what exactly those three words, when combined, really stand for.</p><p>C libraries are more or less built upon the same premise: <em>one can save a lot of time and effort by reusing the work someone (including your past self) already did</em>. We also benefit from the fact that Darwin probably articulated his theory better than we can, and similarly, the collective consciousness of developers who worked on something like the C standard library most likely wrote a more robust function for printing a string than we could given time constraints (at least that’s true in my case).</p><p>A library is a lot like an executable, but instead of being directly executed, they are invoked by name from your program with the parameters you specify.</p><h3>How to create a static library on Linux?</h3><p>To create static libraries, we use the command ar which stands for the program “archiver”. This program can create, list, and modify static libraries, or “archive files,” from our command line.</p><p>To create the static library for the function we used in our above example, use the command:</p><pre>ar -r -c libalphabet.a print_alphabet.o</pre><p>This command creates a static library called libalphabet.a and puts a copy of the file print_alphabet.o in it.</p><ul><li>The -r flag tells the archiver to replace any older object files with the newer object files.</li><li>The -u flag tells the archiver to create the file libalphabet.a if it doesn’t exist.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4i1ApziyX7O5Umg58cCM0g.jpeg" /></figure><p>But, that’s not all. We can, and should, index our library, so the compiler will find our linked programs faster and more efficiently. The command to create an index of our library (or update an existing index) is ranlib which takes our library as the argument:</p><pre>ranlib libalphabet.a</pre><p>This step isn’t always necessary since it is sometimes done automatically.</p><p>To see the contents of our library we can use the ar -t combo. But if we want even more info, then we can use the nm command. This command lists each symbol’s value, type, and name.</p><h3>How to create a dynamic library on Linux?</h3><p>To create a dynamic library, we first need to compile all of the files containing the desired functions for the linking stage using the flag -fPIC which generates Position Independent Code.</p><pre>gcc -c -fPIC *.c</pre><p>Next, we need to convert this object code code into a shared library. Instead of using the archiver tool, as we did with static library generation, we use the flag -shared in another run with gcc. Make sure you include the -o flag to give your library a custom name. The library needs the extension .so for shared object and, by convention, the prefix lib to indicate it’s a library. To include all of our object code, we use the wildcard * followed by the .o (object file) extension.</p><pre>gcc -shared -o libalphabet.so *.o</pre><p>Finally, if you want to check and see which exact function are contained within your newly created library, you can use the command nm with the -D flag which references the symbols in the initialized data section.</p><pre>nm -D libalphabet.so</pre><h3>What are the key differences between static and dynamic libraries?</h3><p>Static libraries differ from dynamic (sometimes called: shared) libraries in that static library code is linked directly into your final executable.</p><p>Dynamic linking points to the address of your function in memory rather than pasting the object code directly in. The actual object code comes in only when the program is run (during run-time).</p><p>Static linking has a couple of drawbacks when compared with dynamic linking.</p><ul><li>Size: each function in your program will have the object code linked directly in. This is the equivalent of copying and pasting <em>“On the Origin of Species” </em>every time you want to say “theory of evolution”. Which, as you can imagine, would make your essay on tortoises much more bulky and inefficient than it needs to be.</li><li>Updates: if the library you static linked is updated (for a bug-fix or something), then you have to recompile your entire program.</li></ul><p>Consider the function print_alphabet(). It resides within a file called print_alphabet.c and it looks something like this:</p><pre>#include &lt;stdio.h&gt;</pre><pre>void print_alphabet(void)<br>{<br>     printf(&quot;abcdefghijklmnopqrstuvwxyz&quot;);<br>}</pre><ul><li>#include &lt;stdio.h&gt; includes the C standard I/O library which has the printf() function in it.</li><li>printf() is a standard library function which simply prints a string.</li></ul><p>Our print_alphabet() function doesn’t do anything flashy; it does one thing and it does it well: printing the alphabet.</p><p>We can convert this program to object code using the following command:</p><pre>gcc -c print_alphabet.c</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rNtEp8ILdQeAgXyuc5A0lw.jpeg" /></figure><p>Our file is now print_alphabet.o and contains object code instead of source code. This object code is directly pasted into any program that uses the static library containing the print_alphabet() function: static linking in a nutshell.</p><h3>What are the pros and cons of static and dynamic libraries?</h3><pre><br>Static libraries:</pre><pre>╔════════════════════════════╦══════════════════════════════╗<br>║            Pros            ║             Cons             ║<br>╠════════════════════════════╬══════════════════════════════╣<br>║ 1. No runtime dependencies ║ 1. Uses lots of memory       ║<br>║                            ║ 2. Needs to be recompiled if ║<br>║                            ║    updated                   ║<br>╚════════════════════════════╩══════════════════════════════╝</pre><pre>                            vs.</pre><pre>Dynamic libraries:</pre><pre>╔════════════════════════════╦════════════════════════════╗<br>║            Pros            ║            Cons            ║<br>╠════════════════════════════╬════════════════════════════╣<br>║ 1. Takes up less memory    ║ 1. Library must be present ║<br>║                            ║    in order for program    ║<br>║                            ║    to run                  ║<br>║ 2. Don&#39;t need to recompile ║ 2. Less portable           ║<br>║    main program following  ║                            ║<br>║    an update               ║                            ║<br>╚════════════════════════════╩════════════════════════════╝<br></pre><p>Thanks for reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=38d2ff1db934" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[On C Static Libraries]]></title>
            <link>https://medium.com/@wesc_19420/on-c-static-libraries-85c5b97ea5d3?source=rss-ec734f0a0464------2</link>
            <guid isPermaLink="false">https://medium.com/p/85c5b97ea5d3</guid>
            <category><![CDATA[holberton-school]]></category>
            <category><![CDATA[libraries]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[c]]></category>
            <dc:creator><![CDATA[Wescott Sharples]]></dc:creator>
            <pubDate>Mon, 08 Oct 2018 01:11:49 GMT</pubDate>
            <atom:updated>2018-10-08T01:11:49.436Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aDgoXhDYOWjfYnzXzGl-rA.jpeg" /></figure><p>Today, we will be covering static libraries in the C programming language. I know you can barely quell your excitement, so let’s jump right in.</p><h3><strong>What are libraries in C?</strong></h3><p>In C, a library is basically just an organized (or, in other words: indexed) collection of object files that you can use when executing your program. Oh, and if you’re wondering: an object file is simply the compiler’s real output during compilation. Object files are mostly machine code, but with extra information which allows them to be combined with other files during the linking phase of compilation to form one executable. More can be found about the compilation process <a href="https://medium.com/@wesc_19420/what-happens-when-you-type-gcc-main-c-3017fb1033f4">here</a>.</p><h3><strong>When and why would we use libraries?</strong></h3><p>Imagine you are writing a paper on the evolution and history of tortoises in Madagascar. You just want to dive right in to writing about tortoises and don’t want to be bothered rehashing Darwin’s entire theory of evolution. Naturally, you just simply invoke his theory by name: “Darwin’s theory of evolution.” Additionally, you cite Darwin’s seminal book, <em>“On the Origin of Species”</em>, so those who don’t know what the “theory of evolution” is, can go to the <strong>library</strong><em> </em>and see exactly those three words, when combined, really stand for.</p><p>C libraries are more or less built upon the same premise: one can save a lot of time and effort by reusing the work someone (including your past self) already did. We also benefit from the fact that Darwin probably wrote about evolution better than we can, and similarly, the collective consciousness of developers who worked on something like the C standard library probably wrote a more optimal function for printing a string than we could (at least that is true in my case).</p><p>A library is a lot like an executable, but instead of being directly executed, they are invoked by name from your program with the parameters you specify.</p><h3><strong>What is the difference between static and dynamic libraries?</strong></h3><p>Static libraries differ from dynamic (sometimes called: shared) libraries in that static library code is linked directly into your final executable.</p><p>Dynamic linking points to the address of your function in memory rather than pasting the object code directly in. The actual object code comes in only when the program is run (during run-time).</p><p>Static linking has a couple of drawbacks when compared with dynamic linking.</p><ul><li>Size: each function in your program will have the object code linked directly in. This is the equivalent of copying and pasting <em>“On the Origin of Species” </em>every time you want to say “theory of evolution”. Which, as you can imagine, would make your essay on tortoises much more bulky and inefficient than it needs to be.</li><li>Updates: if the library you static linked is updated (for a bug-fix or something), then you have to recompile your entire program.</li></ul><p>Consider the function print_alphabet(). It resides within a file called print_alphabet.c and it looks something like this:</p><pre>#include &lt;stdio.h&gt;</pre><pre>void print_alphabet(void)<br>{<br>     printf(&quot;abcdefghijklmnopqrstuvwxyz&quot;);<br>}</pre><ul><li>#include &lt;stdio.h&gt; includes the C standard I/O library which has the printf() function in it.</li><li>printf() is a standard library function which simply prints a string.</li></ul><p>Our print_alphabet() function doesn’t do anything flashy; it does one thing and it does it well: printing the alphabet.</p><p>We can convert this program to object code using the following command:</p><pre>gcc -c print_alphabet.c</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rNtEp8ILdQeAgXyuc5A0lw.jpeg" /></figure><p>Our file is now print_alphabet.o and contains object code instead of source code. This object code is directly pasted into any program that uses the static library containing the print_alphabet() function: static linking in a nutshell.</p><h3>How can we create static libraries?</h3><p>To create static libraries, we use the command ar which stands for the program “archiver”. This program can create, list, and modify static libraries, or “archive files,” from our command line.</p><p>To create the static library for the function we used in our above example, use the command:</p><pre>ar -r -c libalphabet.a print_alphabet.o</pre><p>This command creates a static library called libalphabet.a and puts a copy of the file print_alphabet.o in it.</p><ul><li>The -r flag tells the archiver to replace any older object files with the newer object files.</li><li>The -u flag tells the archiver to create the file libalphabet.a if it doesn’t exist.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4i1ApziyX7O5Umg58cCM0g.jpeg" /></figure><p>But, that’s not all. We can, and should, index our library, so the compiler will find our linked programs faster and more efficiently. The command to create an index of our library (or update an existing index) is ranlib which takes our library as the argument:</p><pre>ranlib libalphabet.a</pre><p>This step isn’t always necessary since it is sometimes done automatically.</p><p>To see the contents of our library we can use the ar -t combo. But if we want even more info, then we can use the nm command. This command lists each symbol’s value, type, and name.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vENHhTyy77-Y4yL-kTw5Ug.jpeg" /></figure><h3><strong>How can we use them?</strong></h3><p>Say, for some bizarre reason, you want a program that prints the alphabet twice. You ingeniously title it double_alphabet.c and the code inside looks something like this:</p><pre>#include &quot;alphabet.h&quot;</pre><pre>int main(void)<br>{<br>     print_alphabet();<br>     print_alphabet();</pre><pre>return (0);<br>}</pre><ul><li>#include &quot;alphabet.h&quot; links a header file which contains the name, return type, and parameter type of our print_alphabet() function (if we don’t include this the compiler will complain).</li><li>The int main(void) is our main function that runs when we execute our program.</li><li>The two print_alphabet() functions will print the alphabet twice.</li></ul><p>But, you may be wondering: how does our program know what print_alphabet() does? That, my frinds, is where the library comes in.</p><p>When compiling, we use the command gcc followed by the program we wish to compile, in this case: gcc double_alphabet.c will make an executable which, when run, will print the alphabet twice. Or will it? This won’t work because the compiler doesn’t know what print_alphabet() is, which is why we need to add the library containing the code for the print_alphabet() function as an argument to gcc. To link our libalphabet.a library with our program, we can simply use the following command:</p><pre>gcc double_alphabet.c libalphabet.a</pre><p>Keep in mind the output of our file will be called a.out since we didn’t use the -o flag to specify a name. So, when we run our program using ./a.out we will see the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lOc8K-O8K2lCS8WW1X3C4Q.jpeg" /></figure><p>Thank you for reading. 🐢</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=85c5b97ea5d3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What happens when you type “gcc main.c”?]]></title>
            <link>https://medium.com/@wesc_19420/what-happens-when-you-type-gcc-main-c-3017fb1033f4?source=rss-ec734f0a0464------2</link>
            <guid isPermaLink="false">https://medium.com/p/3017fb1033f4</guid>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Wescott Sharples]]></dc:creator>
            <pubDate>Wed, 12 Sep 2018 22:50:14 GMT</pubDate>
            <atom:updated>2018-09-14T23:33:53.136Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2-86wUXX2mRHEjGkZhvQGg.jpeg" /></figure><p>In this blog post, I’m going to break down the compilation process of the C programming language to the best of my ability.</p><p>The C compilation process has four main stages: preprocessing, compilation, assembly, and linking. These stages happen individually from one another, and take place in that exact order.</p><p><strong>What is “gcc main.c”?</strong></p><p>When we use “main.c” in the context of “gcc main.c” it is the name of the file which we want to be compiled. A “.c” file is a file written in the C programming language. The C programming language cannot be understood by our computer. This is why we need to compile in the first place. Compilation is what takes us from a “high-level” programming language like C to low-level machine code that the computer will understand.</p><p>When using “gcc” in this context, it is a default command on Linux and Unix-like operating systems that when invoked will do preprocessing, compilation, assembly, and linking on whichever file we specify. There are gcc options that allow us to stop the compilation process at any of the four stages which illustrates the fact that the stages operate in isolation of one another.</p><p><strong>The Preprocessor</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ck26RBC0JvuIA6vSKOfZ-w.jpeg" /></figure><p>Our main.c file is first processed by the preprocessor. The preprocessor generates an intermediate file that is then passed on to our compiler. The preprocessor will firstly remove comments from our code. Next, the preprocessor will include header file code in our main.c file. Finally, the preprocessor will expand all macros.</p><p>Take this C test file (creatively named “testfile.c”) as an example.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aZgiH0Bji-kxyaSf3cOpXA.png" /></figure><p>This file simply prints “Hello, Holberton.” with a new line. You can see that I have a multi-line comment declared using “/*” before what I want to comment out and “*/” after. Additionally, I have the “#include &lt;stdio.h&gt;” at the top of my file. This is known as a header. In my header, I am including the standard input/output library which contains a bunch or ready-to-go functions such as “printf()” which we use later in the code.</p><p>Once, I run testfile.c through the preprocessor it will get rid of my multi-line comment that appears before my “main” function. It will also include the header file code from the standard input/output library.</p><p>To run testfile.c through the preprocessor alone — and not the compiler, assembler, or linker — we use the option “-E” with our command gcc. We are going to also run the gcc command with “-o” which is a flag that names the output file of gcc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rSO9D8J42AihFBjX9FNWWg.png" /></figure><p>Now you can see that testfile has been run through the preprocessor and will no longer contain our multi-line comment. Our file also now contains a ton of code from the standard input/output library before our main function. A piece of it is pictured below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b3vm1aM5LRRPqFxfLTfDGQ.png" /></figure><p><strong>The Compiler</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kBpeiVhq_bFpuT3D97n6qg.jpeg" /></figure><p>Once preprocessed, our main.c file is converted from C syntax to assembly code. Eventually, we want to get main.c from C to binary, but we need to take the intermediate step of assembly code before we can convert to binary. Below, we can see that testfile has been converted from C to assembly code using the “-S” flag for our gcc command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6YHrTqhqmUfJVZFHXUEwQw.png" /></figure><p>See that stuff that looks like gibberish after we look into testfile. That is assembly. I can’t believe people program in that language.</p><p><strong>The Assembler</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9mx9ZiIk_2oFnW-dQaF57g.jpeg" /></figure><p>The assembler converts the assembly code into binary, (aka. machine code or object code). Binary is comprised entirely of 1’s and 0’s. We are going to run the gcc command with “-c” to compile it without going into the linking phase.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8lfrQA1AsF8I6yVZ_9zr6A.png" /></figure><p>Our shell warns me when I try to see into this file because it knows that I’m too much of a rookie to understand what it means. I’m going to go ahead and respond “y” for yes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B4BQu1eN8vprK6ftxdqrhw.png" /></figure><p>Less, our terminal pager program, is trying to render the binary as ASCII characters. This is why we see a bunch of @ and ^ signs surrounding “Hello, Holberton.” Here I was thinking assembly code was hard to read.</p><p><strong>The Linker</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_LALIxrdxf7lUdyycJweMA.jpeg" /></figure><p>The linker links numerous object code files into a single executable file. That way, if you are working on a program with other people, you can write separate files, but in the end have one central executable file with all of your code combined. The linker also links code from any libraries we are using.</p><p>There are two types of linking: dynamic and static. Static linking is done at “compile time” by the linker. Dynamic linking is done when you run a file via the operating system. Since this is the final stage that the compiler takes, we can just use the standard gcc command without any options.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E4scF1hE5ZsN2aHM3f8z3g.png" /></figure><p>That’s it. Since we are on Ubuntu, the compiler’s output is by default a file called “a.out” which is executable. The executable file’s name can vary based on your operating system.</p><p>Let’s run our program.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W2Q73yvlPsLLE9EELbHFOw.png" /></figure><p>Glorious.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3017fb1033f4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is the difference between a hard link and a symbolic link?]]></title>
            <link>https://medium.com/@wesc_19420/what-is-the-difference-between-a-hard-link-and-a-symbolic-link-633730b2052c?source=rss-ec734f0a0464------2</link>
            <guid isPermaLink="false">https://medium.com/p/633730b2052c</guid>
            <category><![CDATA[terminal]]></category>
            <dc:creator><![CDATA[Wescott Sharples]]></dc:creator>
            <pubDate>Tue, 11 Sep 2018 05:29:08 GMT</pubDate>
            <atom:updated>2018-09-11T05:29:08.483Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Pkp0QQo1w1SYRm9B5J5Yag.png" /><figcaption>A hard link and soft link being created with the target file of test.txt</figcaption></figure><p><strong>What is a hard link?</strong></p><p>A hard link is essentially another name for a file. This way we can have a bunch of different names that all reference the contents of a single file. When any of these names are acted upon, the original file they are linking to is acted upon as well.</p><p><strong>How do you create a hard link?</strong></p><p>A hard link is created using the following syntax:</p><p>$ln File Link</p><p>Substitute “File” with the name of the file that you’d like to link to, and substitute “Link” with the name of the hard link that you’d like to use and you got yourself a hard link.</p><p><strong>Why use hard links?</strong></p><p>Hard links can come in handy when you want to use a file, such as a script that automatically pushes your code to GitHub, in a directory that doesn’t contain that file. However, hard links do have their limitations. For one, they cannot be created for directories themselves. Additionally, hard links cannot reference files located on separate computers. This brings us to symbolic links.</p><p><strong>What is a symbolic link?</strong></p><p>A symbolic link, or a soft link as some call it, is a file that references or links to another file in our system. The important distinction between a hard and symbolic link is that a symbolic link does not contain the data of the target file, whereas a hard link does.</p><p><strong>How do you create a symbolic link?</strong></p><p>A symbolic link is created using the following syntax:</p><p>$ln -s SourceFile SymbolicLink</p><p>Again, replace “SourceFile” with the name of the file you want to link to and replace “SymbolicLink” with the name of the symbolic link you want to create. You may have noticed we are using the same “ln” command that we used for creating a hard link. This is our linking command, the option of “-s” is what tells Bash to make this a symbolic link and not a hard link. If you forget the “-s” then you will get a hard link.</p><p><strong>Why use symbolic links?</strong></p><p>Symbolic links can come in handy when you want to link to directories or computers connects by <a href="https://kb.iu.edu/d/adux">NFS</a>. Again, symbolic links do not contain the actual data of the target file as a hard link would. This is why if a target file is deleted or moved, a symbolic link will no longer function properly whereas a hard link will.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pYiw37b8IPSGD9YO-b6jTg.png" /><figcaption>A soft link attempting to be copied after the file it was linking to was removed. Notice how we get an error telling us SoftLink no longer exists.</figcaption></figure><p><strong>A quick note on inodes</strong></p><p>An inode is a data structure that describes a file or directory. It carries metadata such as the file’s owner ID, group ID, size, number of hard links, etc. Directories are really just files that contain a table which lists all files and their assigned inodes. A file’s inode can be found using the following command:</p><p>$ls -i</p><p>When you hard link to a file, you are assigning another name to a file’s inode. This new name is just as important to the kernel as the original file’s name because they both share the exact same inode. In contrast, when you make a symbolic link, it has a different inode altogether because symbolic links are dependent on the file’s name not the inode.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BS5AIgHSx64L-hGI3dRnDw.png" /><figcaption>A listing of a file test.txt and a hard and soft link to test.txt. Notice how the hard link and test.txt share the same inode, while the soft link does not.</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=633730b2052c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What happens when you type “ls *c” into the shell?]]></title>
            <link>https://medium.com/@wesc_19420/what-happens-when-you-type-ls-c-into-the-shell-41cb12954ec6?source=rss-ec734f0a0464------2</link>
            <guid isPermaLink="false">https://medium.com/p/41cb12954ec6</guid>
            <category><![CDATA[terminal]]></category>
            <dc:creator><![CDATA[Wescott Sharples]]></dc:creator>
            <pubDate>Mon, 10 Sep 2018 22:19:33 GMT</pubDate>
            <atom:updated>2018-09-11T05:31:06.339Z</atom:updated>
            <content:encoded><![CDATA[<p>(and hit enter)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/702/1*pLsfqOrnnhvj2RvvQUzO7g.png" /></figure><p><strong>What is the shell?</strong></p><p>The shell is an application that accepts commands through its command-line interface. The shell allows you to request actions of the kernel.</p><p><strong>What is the kernel?</strong></p><p>The kernel is a program that is really important to our operating system, controlling all other programs and allowing communication between the software and hardware.</p><p><strong>What does the “ls” command do?</strong></p><p>Without getting into <em>how</em> the “ls” command does what it does, what does the it do? The “ls” command simply lists the contents of your directory. For example: if I type “ls” into my terminal, it will list all of my files from my “0x02-shell_redirections” directory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lHB04ae_cZgjjdPI26WtHQ.png" /></figure><p>If you don’t have a lot of experience with terminal or a command-line interface, then the word “directory” may seem intimidating at first glance. “Directory” is simply another term for “folder.” The command “ls” defaults to your current working directory, or whatever folder you are currently in, if you don’t provide it with a specific path to a specific folder. In my case, “0x02-shell_redirections” was my current working directory.</p><p><strong>What is a directory path?</strong></p><p>A directory path is just the route of directories that leads to a specific directories. So when you have a directory within a directory within a directory, you can specify exactly where it is using its path. Let’s take a look at my terminal again.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tfnf5OJWDN3LixsQeXCCpw.png" /></figure><p>The parent directory is the directory that <em>contains</em> a directory or file. The child directory is the directory that is <em>contained </em>by another directory. A directory path is read left to right from the utmost parent of parents to the final child of children. In my case, “~” is the most parent directory and contains the directories “holberton-system_engineering-devops” and “0x02-shell_redirections”. On Unix-like operating systems “~” stands for the current user’s home directory.</p><p><strong>So, what exactly happens when we type “ls *c” into the shell?</strong></p><ol><li>The shell reads the command using the “getline()” function. Shell is written mostly in the C programming language. The “getline()” function is a standard C function that, as you probably guessed, gets the line from wherever it is told to, in our case from the shell’s command-line.</li><li>Now that shell knows we typed “ls *.c” it checks to see if “ls” is an alias. An alias is a command declared by the user and not built into shell by default. If we wanted “ls” to echo the value of the speed of light instead of list the directories and files in our current working directory, then we could do that and it would take precedence over the default “ls” command.</li><li>If the shell verifies that “ls” is in fact not an alias, it checks that “ls” is a built-in command. The shell looks for an executable “ls” file in the system. Shell searches for the executable file in the “$PATH” variable. “$Path” is a variable that stores a list of directories that shell looks through whenever a command is entered.</li><li>Shell performs the necessary expansions. In our case shell needs to expand our “* .c” into a list of files and directories. “*” is a symbol that tells the shell to look for all of the files whose name matches a given set of characters. We call this symbol a wildcard. The characters that either precede or follow our wildcard “*” will be searched for by shell and it will return any matching files or directories. In our case, since “.c” <em>follows </em>our “*” wildcard, shell will return us all files or directories ending with a “.c”. These could, and would likely be files written and saved in the C programming language. Alternatively, they could be files or directories whose name happens to end in “.c”.</li><li>Given “ls” is a file in our system located somewhere in our “/usr/bin” directory, shell will execute the file and list everything with a “.c” at the end. The “ls” command will never act directly upon “* .c” since the wildcard expansion takes place before the “ls” command is executed.</li><li>We finally get the following result: “ls: connot access *c: No such file or directory”. It’s anticlimactic, I know, but since I have no files or directories ending in “.c”, “ls” lists nothing and returns the error “No such file or directory.”</li><li>Post-execution of our “ls” command, the shell executes shutdown commands, frees up memory, and re-prompts the user for input.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=41cb12954ec6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[In Pursuit of Adventure]]></title>
            <link>https://medium.com/@wesc_19420/in-pursuit-of-adventure-c92b93c47e60?source=rss-ec734f0a0464------2</link>
            <guid isPermaLink="false">https://medium.com/p/c92b93c47e60</guid>
            <category><![CDATA[software]]></category>
            <category><![CDATA[holberton-school]]></category>
            <category><![CDATA[education]]></category>
            <dc:creator><![CDATA[Wescott Sharples]]></dc:creator>
            <pubDate>Tue, 12 Jun 2018 19:09:49 GMT</pubDate>
            <atom:updated>2018-06-12T19:09:49.065Z</atom:updated>
            <content:encoded><![CDATA[<p>An Application Essay for Holberton School</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I1e9sf0gfTqCrZvFv6yIaA.jpeg" /></figure><p>Simply put, I want to become a software engineer because it excites me.</p><p>As a small child, I was entranced by tales of exploration. The bulk of my primary school recesses were spent poring over elementary biographies of famous voyagers like Henry Hudson, Christopher Columbus, and Ferdinand Magellan. At home, I would practice nautical knots while dreaming of the day when I too would set sail for some illusory island in pursuit of adventure.</p><p>That is until one fateful evening. It was around 2008 when I became aware of Google Earth and its implications on my whimsical aspirations. I don’t remember how exactly I stumbled upon the program. But given Google’s omnipresence, it’s surprising I didn’t find it sooner. What I do remember, however, is my heart sinking as I read their tagline: <em>“Explore the far reaches of the world, right in your browser.”</em> I felt robbed. Despondently, I dragged my cursor to the middle of the screen and hit the launch button. A loading bar appeared and I remember thinking: “So much for adventure.” Seconds later, a perfect globe of blue and green suspended in space materialized on my screen. My gloom promptly changed to intrigue as I started spinning Earth with my mouse. I could be anywhere in seconds; nothing was off limits. The world was mine to do with as I pleased. A smile crept onto my lips.</p><p>Google Earth had simultaneously squashed and remolded my perception of discovery. I realized that just because almost all of Earth’s surface had been photographed and mapped at a 1:500,000 scale didn’t mean there wasn’t anything left to explore. There was an enormous and exciting frontier in software, and I could explore it “right in my browser.”</p><p>For the past decade, I’ve worked towards a better understanding of this digital domain’s complexity. I skipped around online resources for a while, completing several web development and computer science related courses on sites like Codecademy, Lynda, and Udemy. Despite years of learning independently, I can’t shake the feeling that my knowledge is a bit shallow. I have learned how to interact with software, but not why or how the interaction is possible. I feel incomplete and an incomplete ship cannot sail. Similarly, an incomplete education isn’t suitable for navigating the uncharted waters of software development. I began to research more comprehensive learning environments and came across Holberton.</p><p>Holberton’s uncompromising intensity and depth of coursework immediately stood out to me. I admire that the program is two years long with extensive work weeks. Mastery, or even competency, in a topic such as software development takes time and Holberton embraces that. Two years feels like the perfect compromise between a rushed and often cursory month-long coding intensive and a lengthy, sometimes circuitous, four-year collegiate program.</p><p>As I do more research, it’s apparent that Holberton and I share more than just the value of dedication. As exemplified by the project and peer-based pedagogy, Holberton clearly emphasizes collaboration and creativity. Additionally, Holberton values the powerful marriage of academic study and practical experience. Skills developed in a controlled microcosm like school need to be tested in the chaotic throes of a work environment to attain maximal development. Which is why I’m taken with Holberton’s idea of an internship phase among two school phases.</p><p>The all-encompassing nature of Holberton initially drew me in, the school’s core values and teaching method tempted me to go, but it wasn’t until I started reading the papers of current students that I promptly made the decision to apply. I came across Bennett Buchanan’s essay titled<em> A Beautiful Neural Network</em> and was floored. I had always wondered how people produced the fractal-like junction of images using a machine learning algorithm. I followed along with Buchanan’s primer and was eventually able to successfully produce a slightly awkward, but awesome amalgam of my pet French Bulldog and Vincent van Gogh’s The Starry Night. Here was a student who had been attending Holberton for no more than a few months teaching me with extreme clarity and understanding one of machine learning’s fascinating capabilities. Ultimately, I want to attend Holberton because these are the explorers I want to learn from and call my peers.</p><p>I’m positive Holberton’s approach to education will equip me with an intellectual vessel capable of rivaling Columbus’s Santa María.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c92b93c47e60" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>