<?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 Lucas Marinho Dias on Medium]]></title>
        <description><![CDATA[Stories by Lucas Marinho Dias on Medium]]></description>
        <link>https://medium.com/@lhollowwizard?source=rss-17953e27b12b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*TP-AaLxGWyVvTHjG_w_60w.png</url>
            <title>Stories by Lucas Marinho Dias on Medium</title>
            <link>https://medium.com/@lhollowwizard?source=rss-17953e27b12b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 05:33:58 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@lhollowwizard/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[Beginnings — What is an API?]]></title>
            <link>https://medium.com/@lhollowwizard/beginnings-what-is-an-api-2b107b6963ee?source=rss-17953e27b12b------2</link>
            <guid isPermaLink="false">https://medium.com/p/2b107b6963ee</guid>
            <category><![CDATA[api]]></category>
            <category><![CDATA[backend]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[backend-development]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Lucas Marinho Dias]]></dc:creator>
            <pubDate>Thu, 24 Apr 2025 12:40:16 GMT</pubDate>
            <atom:updated>2025-04-24T12:40:16.655Z</atom:updated>
            <content:encoded><![CDATA[<h3>Beginnings — What is an API?</h3><h4>It’s APIs all the way down.</h4><p>When we start on our journey to become developers, there are many concepts thrown around and, even when searching for them, they can be surprisingly tricky to understand. People with experience expect you to know these foundational concepts, as it is ingrained into their brains, but that can make you feel lost and alienated, even more so when beginning your journey.</p><p>The idea for this series I am starting is to get these concepts and try my best to explain them easily and casually. We won’t go very deep, but I hope that it is enough so that you don’t feel lost when they are used during a conversation and maybe even enough so that you can dig deeper afterwards.</p><p>One of these concepts we throw around a lot is API, and I think it is one of the most deceptively easy concepts, but it is so broad and all-encompassing that it can be a dangerous one sometimes. In my experience, most of the time someone says API, they mean Web API, which we will cover later in the article, but let’s see how it can mean so much more.</p><h3>Breaking it Down</h3><p>If you search for it, you will see that it means “<strong>Application Programming Interface</strong>”. It used to sound vague to me until I started working with them. Let’s break it down a bit:</p><ul><li><strong>Application</strong>: An application is any software; it could be a standard library like C’s <a href="https://www.w3schools.com/c/c_ref_stdio.php">stdio.h</a>, an external library like JavaScript’s <a href="https://react.dev/">React</a>, the API your Operating System exposes or someone else’s program, like <a href="https://pokeapi.co/">PokéAPI</a>.</li><li><strong>Programming</strong>: The literal act of writing code, meaning that the API’s creator made the application to be used by a programmer in the code; it could be used to write another API or an end-user program.</li><li><strong>Interface</strong>: Not related to OOP’s meaning of interface, although that could be used to create an API, but simply meaning something for you to interact with.</li></ul><p>To summarize, an API is simply any piece of <em>software</em> that is made for <em>programmers</em> to <strong>interact</strong> with <em>programmatically</em>. <br>As I said, deceptively easy, and anything from printing something on the terminal to calling an external LLM service are examples of using APIs. Let’s see where else we can find it.</p><h3>Interacting with your Computer</h3><p>If you have ever started learning Game Programming, you probably put some sprites or 3D objects in the game that appeared on the computer’s screen. However, notice how you probably didn’t need to tell your computer what color you wanted a specific pixel to be, and neither did you calculate the 2D projection of the 3D object on the screen (okay, maybe you have done this, and congratulations if you did).</p><p>When you use a game engine, you’re working with an API. You’re letting another piece of software handle the heavy lifting — graphics, rendering, input — so you can focus on the fun part, like making yet another roguelite. Now, you can extrapolate this to all other things, you are most likely not the person interacting with your drivers or getting the raw data from the IP packages you receive through the internet (more on this later), and you don’t need to, APIs make our lives easier and simple, you rarely need to go that deep, <em>so don’t</em>. Life is better on the surface, but just remember that someone had to write <em>tons</em> of code so you wouldn’t have to!</p><p>To handle most necessary interactions with our computers, we have our Operating System, which exposes APIs that allow the use of more complex algorithms that know how to interact with your machine. It has a bunch of neat features that allow you to easily access and manipulate a lot of things about your computer without understanding the stuff beneath. However, most of the time, we use another API to abstract the OS’s APIs even further, narrowing what we can do, making it easier to do. Even deeper than this is the Kernel, which also exposes APIs, albeit very low-level ones; the OS might use them when you call its APIs. It’s APIs all the way down.</p><h3>Libraries and Frameworks</h3><h4>Libraries</h4><p>Let’s think about the first thing most programmers have ever done: printed “Hello, World!” somewhere; let’s assume it was on a terminal using C.</p><pre>#include &lt;stdio.h&gt;<br><br>int main() {<br>  printf(&quot;Hello, World!&quot;);<br>  return 0;<br>} </pre><p>Okay, now let’s think about how this piece of code puts that string into the terminal. You might know that it writes it to the stdin of the terminal running the application, but how does it know where that is? If you have multiple terminals open, it only writes to the one running that application. So, even with this simple program that is the first thing most of us learn, there is a bunch of stuff behind that we don’t even think about, thanks to the power of APIs, in this case, the stdio library, which allows us to interact with it through functions, such as printf.</p><p>But there are libraries for pretty much anything you want to do. Not all of them interact with an external program, like stdio. It might just have a bunch of math functions that you can use to do some calculations. How do you even write a pow function that can receive real numbers and exponents? You don’t know? Don’t worry! You can use <a href="https://www.w3schools.com/c/ref_math_pow.php">math.h</a>. You are interacting with a piece of software (in this case, an algorithm that knows how to raise a number by another number) in a program, so… API!</p><p>Now, these libraries, although hard to write, are relatively simple in their scopes, being standard libraries with specific functions, but there are huge libraries that have thousands of classes and functions available for you to use, like React. It is still an API, just like those other libraries, although with a bigger scope.</p><h4>Frameworks</h4><p>Just like programming paradigms, frameworks are intended to force you to work in a certain way. It is still an API, although unlike a library that you can simply call and use whatever you want however you, you must follow the <em>framework’s</em> way of doing things. Frameworks also have a lot of things ready and done; you configure things, and it’s ready. They are pretty good for starting a project quickly, as you don’t need to do all the scaffolding and complex parts, but you might give up flexibility later as the project grows.</p><h3>Web API</h3><h4>What is Web API?</h4><p>As we have seen so far, an API is just software that you interact with through your software. What puts the “Web” in Web API is that this one happens through the internet. That’s it.<br>They are an isolated category because they are the main way we interact on the internet, and they have their properties and conventions.</p><h4>Protocols and HTTP</h4><p>Computers need a way to “speak the same language”. If your computer understands one language and another computer speaks another language, they can&#39;t understand each other.</p><p>So, some really smart people many years ago decided that communications through the web should be done using protocols. These protocols are the Esperanto of computers; every computer can speak them and can understand them. The most basic protocol is the Internet Protocol (IP), where we get IP addresses from.<br>Another very important protocol is Hyper-Text Transfer Protocol (<a href="https://developer.mozilla.org/en-US/docs/Web/HTTP">HTTP</a>), where the beginning of the URL comes from. This is the most used protocol for communication nowadays. It defines some rules about what you send with your message and what you will receive in return.</p><p>Every time you open a website, you are sending an HTTP request to another computer asking for the data on that site. This other computer sends a response with the necessary information, and the browser can understand it and prepare it.<br>But that is not the only way to interact via HTTP, you can request many things, like data about your favorite Pokémon or the current exchange rates of currencies. <br>There are many public Web APIs that you can send these requests to for different information.</p><h4>Making an HTTP Request</h4><p>Let’s jump into our first real example using Go’s HTTP standard library.</p><pre>package main<br><br>import (<br> &quot;encoding/json&quot;<br> &quot;fmt&quot;<br> &quot;net/http&quot;<br>)<br><br>func main() {<br> // 1<br> resp, err := http.Get(&quot;https://pokeapi.co/api/v2/pokemon/pikachu&quot;)<br> if err != nil {<br>  fmt.Println(&quot;Error fetching data:&quot;, err)<br>  return<br> }<br><br> // 2<br> defer resp.Body.Close()<br><br> // 3<br> var data map[string]interface{}<br> if err := json.NewDecoder(resp.Body).Decode(&amp;data); err != nil {<br>  fmt.Println(&quot;Error decoding JSON:&quot;, err)<br>  return<br> }<br> <br> // 4<br> fmt.Println(&quot;Name:&quot;, data[&quot;name&quot;])<br> fmt.Println(&quot;Height:&quot;, data[&quot;height&quot;])<br> fmt.Println(&quot;Weight:&quot;, data[&quot;weight&quot;])<br>}</pre><p>Okay, wow, that’s a lot of stuff happening all at once. Let’s break it down.</p><ol><li>As you might notice, the URL string has https at the beginning, which just means what protocol is being used, followed by the domain and path. A request through the internet, unlike previous examples that interacted with APIs via functions, can fail; maybe the other computer broke down, maybe you don’t have internet access, or maybe you just sent the request incorrectly. That’s why you must always verify if the request worked.</li><li>This is just Go’s idiomatic way of cleaning up after using the response.</li><li>HTTP responses have a body, they are where the data you requested comes from (if you didn’t have a protocol, how would you know where to get the data from?). This body can be anything, it is just an array of bytes. How do you get data from it then? We create another contract, the way the data is going to be sent; this particular API responds using JSON, a data format. Since it is a standard format, you can easily decode it into usable data in the code. Here, this is done using a HashMap.</li><li>We use the field names (name, height, weight) based on what the API promises in its documentation.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/520/1*V5b0IpTp_X6VVOUfx2svUA.png" /><figcaption>First you send your request and then PokéAPI sends a response</figcaption></figure><p>To summarize, I can use HTTP, which is a protocol that defines how I communicate with another computer to request things from that computer. This computer uses HTTP to send a response with the data encoded in the JSON format. Just like with the other APIs examples, we don’t need to know HOW it will get the data to us, it could be someone typing the answer manually or a very complex process that needs hundreds of computers to do, it doesn&#39;t matter to us, we got what we wanted and we can use it for our purposes now.<br>Most of the time, for the scope of doing a request, you don’t need to understand what the request API is doing or how the other side receives your request and processes it. An important thing a developer should learn is the importance of the scope it is working at, you need to be able to go as deep or as shallow as you need for a certain specific task. Most of the time, knowing how to make the request and what it will get you afterwards is enough.</p><h4>Endpoints</h4><p>When talking about Web APIs, you often hear about endpoints. In the Hello, World example above, we talked about how we interacted with the API using functions. There are many different functions for many different functionalities. For Web APIs, instead of having functions, you have endpoints; they define what are the functionalities of a certain API.</p><p>When creating an API, one concern you have is what your users are using it for, what they need, and what are they interacting with. For instance, in the PokéAPI example, they need an endpoint that lets users ask for Pokémons by name, another endpoint to ask for Pokémons by number, and another endpoint to ask for a list of Pokémons of a certain type. Each action a user can take is represented by an endpoint. An API can have just a single endpoint to dozens or even hundreds of endpoints; there are no limits.</p><p>These endpoints are defined, usually, by two things, the Method of the request and the Path of the request, which we’ll dive into in the next article, suffice to say that you define what endpoint you are sending your request to, while the other computer defines the endpoints that exist and what they do.</p><h4>Complex Systems</h4><p>Sometimes, one API is enough to get the information you need, but frequently, for real-life problems, the solutions aren’t simple. Many times, you will need a bunch of APIs interacting with each other in different ways using different protocols for different reasons. It can be a bit overwhelming at first when you’re trying to understand how a new system works. There might be internal and external web APIs that your API depends on while relying on many different libraries and even frameworks.<br>When faced with that, my advice is, take your time, choose a specific API and a specific endpoint, follow it through until the end, then go back and choose another, <strong>go slow and go only as deep as necessary</strong>.</p><h4>The Other Computer</h4><p>In a tangent, I am referring to the computer sending the request as your computer and the computer receiving the request as the other computer. There is a better term to define this relationship, the Client-Server model. Any computer can act as both a client and a server at any given point, Server is just the name given to the computer that is <strong>serving</strong> some data at some point. So, at the moment a certain computer is sending a request, it is a client, and at the moment a certain computer receives a request, it is a server.<br>In our day-to-day lives, we use the word Server pretty often in phrases like “The Server is down” or in gaming when you have to choose a server location. This might give the impression that the server is a complex and unknown entity; tarry not, however, it is just a computer that receives your requests.</p><p>To make it easier: Client and Server are just roles that a certain computer can play. When sending a request, it is the Client, and when receiving a request, it is the Server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/521/1*N0jj5eSi7ipn2h4aAVdB7g.png" /><figcaption>Instagram acting as both client and server</figcaption></figure><h3>Conclusion</h3><p>When I was starting in my journey to become a back-end developer, the term API was always a bit hard to grasp. It was used in so many different contexts and for things that seemed pretty unrelated to each other. It took me a while to realize that it was all APIs. It is a word that is thrown around because it is a broad term that touches pretty much ALL of programming; every programmer uses them all the time for every single thing. Our work would be impossible without the amazing men and women who dedicated their time and careers to make everything possible.</p><p>I hope this article sheds some light on some of the possible meanings of API and a new appreciation for what they are and represent.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2b107b6963ee" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Levels of Programming — Part 1]]></title>
            <link>https://medium.com/@lhollowwizard/the-levels-of-programming-part-1-ed394d6886c3?source=rss-17953e27b12b------2</link>
            <guid isPermaLink="false">https://medium.com/p/ed394d6886c3</guid>
            <category><![CDATA[iot]]></category>
            <category><![CDATA[baremetal]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[operating-systems]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Lucas Marinho Dias]]></dc:creator>
            <pubDate>Thu, 06 Feb 2025 14:15:47 GMT</pubDate>
            <atom:updated>2025-02-06T14:15:47.026Z</atom:updated>
            <content:encoded><![CDATA[<h3>The Levels of Programming — Part 1</h3><figure><img alt="There are many layers of paper, each with a slight offset and different color. From the middle to the right, each paper is cut in a random shape, revealing more of its colors." src="https://cdn-images-1.medium.com/max/915/1*7YvhP5EvX6CUR8vTMYl-Jw.jpeg" /><figcaption>Representing the abstraction layers on a computer.</figcaption></figure><p>As developers, we all begin our programming journey from different starting points. Some dive into frontend development using interpreters like <strong>Google’s V8</strong>. Others venture into the world of <strong>C</strong>, leveraging its standard libraries to communicate with the terminal. Some embark on the path of AI, exploring AI with Python and its powerful libraries. Many others choose <strong>C++ or C# </strong>for game development, exploring the vast possibilities that engines like <strong>Unreal</strong> and <strong>Unity </strong>offer.</p><p>These initial leaps forward are crucial for novice programmers, as they provide abstractions and simplicity that allow us to focus on learning logic and other fundamental concepts. However, once we become proficient in a language or domain, we seldom return to peel back the layers of abstraction we once relied on. How you receive data from your internet provider, the mysteries behind how the standard library sends text to a terminal using printf go unexplored, and the blazing speed of interpreted languages that should be slow becomes an overlooked phenomenon.</p><p>My goal with this article is simple: to spark your curiosity and open your eyes to the many layers of abstraction that exist between you and the CPU. I want to nudge you out of your comfort zone and get you thinking about areas of programming you might not have explored before. From there, it’s up to you — dive deeper into whatever fascinates you most!</p><p>Throughout this exploration, we will pass through the levels of programming and shed some light on the hidden realms beneath the surface. We will discuss bare metal programming, kernel development, embedded systems, operating systems, compilers, interpreters, and APIs, and even touch upon the fascinating world of AI and machine learning. Each level offers unique growth opportunities.</p><h3>Bare Metal</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vW0K10HCSyF9V7r1K03C4A.png" /></figure><p>It is rare to program without relying on libraries, bootloaders, or abstractions that hide the underlying operations. These layers of abstraction serve to simplify development by handling tasks like file systems, standard input/output streams, and other functionalities. However, in the realm of bare metal programming, the goal is to shed these abstractions and directly communicate with the CPU, using only the compiler (and sometimes even bypassing certain compiler features).</p><p><strong>Stability and reliability</strong> are critical in bare metal programming due to the low-level nature of the work. Since there is no operating system or runtime safety mechanism, developers must be meticulous in managing memory to prevent leaks, buffer overflows, and dangling pointers. Mishandling memory can lead to system crashes, unpredictable behaviour, or even security vulnerabilities, making careful resource management essential.</p><h4>So, what is bare metal programming used for?</h4><ul><li>Microcontroller Software: Bare metal programming finds its application in writing software for microcontrollers. These devices typically consist of a processor, memory, and various input/output interfaces. By programming at the bare metal level, developers have direct control over the microcontroller’s functionality, enabling the creation of tailored applications.</li><li>Custom <a href="https://en.wikipedia.org/wiki/Bootloader">Bootloaders</a>: Bare metal programming allows the development of custom bootloaders, which provide the initial software execution environment for a device. By crafting a custom bootloader, it becomes possible to directly launch applications, such as games on a small console, or even chain multiple bootloaders to load different software components.</li><li><a href="https://en.wikipedia.org/wiki/Kernel_(operating_system)">Kernel</a> Development: Another significant application of bare metal programming lies in creating kernels. Kernels are the fundamental components of operating systems or embedded systems. They manage low-level system operations, including memory management, device communication, networking, and more. Developing a custom kernel provides complete control over the system’s behaviour and allows for tailoring it to specific requirements.</li></ul><h4>How can you learn bare metal programming?</h4><p>While the following online resources serve as a starting point, it’s important to note that there are also numerous books and courses available for a more comprehensive understanding:</p><ul><li><a href="https://google.github.io/comprehensive-rust/bare-metal.html">For Rust developers</a></li><li><a href="https://github.com/cpq/bare-metal-programming-guide">From scratch using the GCC compiler</a></li><li><a href="https://hackaday.com/2022/12/05/epic-guide-to-bare-metal-stm32-programming">Hackaday</a></li></ul><h4>Conclusion</h4><p>By diving into the realm of bare metal programming, you unlock a deeper understanding of the underlying systems and gain the ability to create highly optimized and specialized software. However, it’s essential to approach this level of programming with caution, as it requires diligent attention to safety and potential security risks.</p><h3>Embedded Systems</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*loDi8qOKm6aZDXOL-Gm28g.png" /></figure><p>Embedded systems have become so ubiquitous in our lives that we often fail to notice their presence. However, these systems have been evolving for decades, growing increasingly powerful. Embedded systems refer to computer systems specifically designed to perform dedicated tasks or functions within larger systems, typically with limited resources.</p><p>Working with embedded systems can be a complex endeavour, as they find application in a wide range of domains, offering invaluable knowledge and presenting various challenges. The field of embedded systems encompasses three primary components: hardware, software, and the specific application or purpose for which the system is designed.</p><p>The hardware of an embedded system is typically designed to be compact, power-efficient, and cost-effective, catering to the system’s specific task. The software component usually incorporates a kernel for handling system-level operations and algorithms tailored to the system’s intended application. The application itself represents the specific use case for which the embedded system is deployed, encompassing a wide array of possibilities.</p><h4>So, what are embedded systems used for?</h4><p>The applications of embedded systems are vast and diverse. Here are just a few examples:</p><ul><li>Household applications: Embedded systems are found in everyday household appliances like refrigerators, washing machines, air conditioners, microwave ovens, and more;</li><li>Air travel: Embedded systems play critical roles in air travel, including collision avoidance systems, air traffic control, flight recorders, flight control systems, navigation systems, and more;</li><li>Other applications: Embedded systems are utilized in ATMs, MRI scanners, pacemakers, satellites, automobiles, and countless other areas that require dedicated and specialized functionality.</li></ul><h4>Where to start?</h4><p>To venture into the field of embedded systems, it is recommended to begin by learning a low-level programming language, but not necessary. Due to the limitations of embedded systems in terms of size and capabilities, writing highly performant code is crucial. It is also important to develop a solid understanding of data structures and algorithms. Additionally, learning the specific system and how to manipulate its hardware using its public API may be necessary.</p><p>It’s important to note that the information presented here only scratches the surface of the vast field of embedded systems. For a more comprehensive understanding and to delve deeper into this area, the following resources are recommended as a starting point:</p><ul><li><a href="https://www.rust-lang.org/what/embedded">Rust</a>: Rust is a fast and safe programming language, with many libraries dedicated to embedded system development.</li><li><a href="https://www.amazon.com/Embedded-Cortex-M-Microcontrollers-Assembly-Language/dp/0982692668?crid=FQXOQMPYSRS&amp;keywords=embedded+systems&amp;qid=1646676723&amp;sprefix=embedded+systems,aps,135&amp;sr=8-8&amp;linkCode=sl1&amp;tag=365blottochal-20&amp;linkId=cf9a0186540b065723716d447960bbfb&amp;language=en_US&amp;ref_=as_li_ss_tl">Book for Beginners</a>: The most recommended books to get into embedded systems.</li><li><a href="https://www.edx.org/course/embedded-systems-shape-the-world-microcontroller-i?index=product&amp;queryID=1a6334aca9b88e4b53f053a829a3f128&amp;position=1&amp;search_index=product&amp;results_level=first-level-results&amp;term=embedded+systems&amp;campaign=Embedded+Systems+-+Shape+The+World%3A+Microcontroller+Input%2FOutput&amp;source=edX&amp;product_category=course&amp;placement_url=https%3A%2F%2Fwww.edx.org%2Fsearch">Free course</a>: An amazing course from Texas University, you only need to pay for the certificate.</li></ul><p><a href="https://blog.felgo.com/embedded/embedded-systems-programming#Learn-Embedded-Programming-Language">This blog</a> also has some tips on where to start learning embedded systems. Wherever you might start, I&#39;m pretty sure you will have an amazing time creating your solution for real-life problems.</p><h4>Conclusion</h4><p>Embedded systems offer a vast and diverse field of opportunities for programmers. Whether working on projects in gaming, household appliances, space exploration with NASA, military applications, or even contributing to the development of robotic components, the possibilities are endless. Embedded systems provide an exciting and ever-evolving field, filled with challenges and opportunities for growth.</p><h3>Operating Systems</h3><p>Operating systems (OS) serve as the crucial bridge between software and hardware, providing a stable environment for applications to run. Every program you execute — from a simple text editor to a complex game — relies on the OS to <strong>manage resources</strong>, <strong>handle user input</strong>, and ensure<strong> smooth operation</strong>. While many developers interact with an OS through <strong>high-level APIs</strong>, such as file system operations or network requests, fewer venture into its internals — where memory management, process scheduling, and hardware abstraction take place.</p><p>At its core, an operating system handles multiple responsibilities that would be overwhelming for individual applications to manage on their own. Imagine running multiple programs at once: a web browser streaming a video, a code editor running a compilation, and a chat application receiving messages in real time. Without an OS <strong>orchestrating</strong> how CPU time is allocated to each process, your system would quickly descend into chaos. <strong>Process scheduling</strong> ensures that every program gets its fair share of computational power while preventing any single application from monopolizing resources.</p><p>Another critical function of an OS is <strong>memory management</strong>. When an application requests memory, the OS allocates a portion of RAM and keeps track of it, ensuring that different processes don’t accidentally overwrite each other’s data. If memory wasn’t managed properly, a single faulty program could corrupt data across the entire system. This is why concepts like <strong>virtual memory</strong>, <strong>paging</strong>, and <strong>memory protection</strong> exist — allowing software to run reliably without interfering with other processes or the operating system itself.</p><p>Beyond managing CPU time and memory, an OS also serves as an <strong>abstraction layer for hardware</strong>. Without it, software would need to interact directly with different hardware components, each with its unique interface and complexities. Instead, the OS provides a consistent way to communicate with devices like keyboards, printers, and storage drives through device drivers. This abstraction enables developers to write software that works across different hardware configurations without worrying about the underlying differences.</p><p>Security is another major responsibility of an OS. Modern operating systems enforce strict user permissions, preventing unauthorized applications from accessing sensitive files or system settings. Features like <strong>process isolation</strong>, <strong>encryption</strong>, and <strong>secure boot mechanisms</strong> help protect against malware and unauthorized access. Without these security measures, even simple software bugs could become serious vulnerabilities.</p><p>Despite their complexity, operating systems are often taken for granted. Most developers interact with them indirectly, relying on system calls and frameworks to perform tasks like reading files or opening network connections. However, diving into OS development or studying how systems like <strong>Linux</strong>, <strong>Windows</strong>, or <strong>macOS</strong> work can provide invaluable insights into performance optimization, security best practices, and low-level programming.</p><h4>Diving Into OS Development</h4><p>Building an OS is one of the most challenging yet rewarding projects in programming. It requires:</p><ol><li><strong>Understanding Low-Level Programming</strong>: Languages like C and Assembly are essential.</li><li><strong>Bootloader Development</strong>: The first piece of code executed when a computer starts.</li><li><strong>Kernel Programming</strong>: Writing core OS functionality such as task scheduling and memory handling.</li><li>I<strong>nterfacing with Hardware</strong>: Managing I/O, interrupts, and device drivers.</li></ol><p>Developing even a minimal OS teaches you how modern systems function and deepens your appreciation for high-level abstractions.</p><h4>Where to Start?</h4><p>If you want to explore OS development:</p><ul><li>“<a href="https://pages.cs.wisc.edu/~remzi/OSTEP/">Operating Systems: Three Easy Pieces</a>” — A widely recommended book on OS fundamentals.</li><li><a href="https://www.linuxfromscratch.org/">Linux From Scratch</a> — A hands-on guide to building a Linux-based OS step by step.</li><li><a href="http://wiki.osdev.org/Expanded_Main_Page">OSDev Wiki </a>— A great online resource for bootloaders, kernel development, and system internals.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ed394d6886c3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data Structures and Algorithms — Introduction]]></title>
            <link>https://medium.com/@lhollowwizard/data-structures-and-algorithms-introduction-f4281f6a3de1?source=rss-17953e27b12b------2</link>
            <guid isPermaLink="false">https://medium.com/p/f4281f6a3de1</guid>
            <category><![CDATA[data-structures]]></category>
            <category><![CDATA[develop]]></category>
            <category><![CDATA[big-o-notation]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[c-sharp-programming]]></category>
            <dc:creator><![CDATA[Lucas Marinho Dias]]></dc:creator>
            <pubDate>Thu, 06 Jan 2022 20:46:15 GMT</pubDate>
            <atom:updated>2022-09-28T19:47:52.337Z</atom:updated>
            <content:encoded><![CDATA[<h3>Data Structures and Algorithms — Introduction</h3><p>In a day where really powerful frameworks can be learned by free videos on YouTube, games can be made with very powerful, and even free, Engines that hide some of the hardest parts and with many different languages to learn from, sometimes it’s easy to forget to learn the basics of Software Engineering, and one example that can sometimes go over the heads of a beginner developer are Data Structures and Algorithms.</p><p>All examples will be on C#.</p><h3>BIG(O)</h3><p>Big(O) is a way to represent the time and space complexity of an algorithm.<br>An algorithm is a finite sequence of instructions, usually made in order to solve a problem, such as sorting a list or finding some result from an input, however, there are always multiple ways of making the same algorithm, and Big(O) helps you make more optimal.<br>The true name of Big(O) (if you want to show off in interviews) is <strong>Asymptotic Analysis</strong>, but anyone should understand Big(O) just fine.</p><p>The operand of a Big(O) represents the how many times something happens:</p><ul><li>O(1) — Constant Time (No Loops)</li><li>O(logn) — Logarithmic Time (Usually in Searchs of Sorted Arrays or Trees)</li><li>O(n) — Linear Time (For or While loops)</li><li>O(n . logn) — Log Linear (Sorting)</li><li>O(n²) — Quadradic (Nested Loops)</li><li>O(2^n) — Exponential (Recursive algorithms)</li><li>O(n!) — Factorial (Each element adds a loop)</li></ul><p>There are some rules for Big(O) annotation:</p><ul><li>Worst Case — Big(O) is the annotation for Worst Cases of an algorithm, there are other annotations for Best Case and Average Case, however the most useful is Big(O)</li><li>Remove Constants — Sometimes you can calculate that an algorithm is 2*n, or 10*n² + 100, however, you can ignore the constants, so 2*n becomes O(n) and 10*n² + 100 becomes O(n²).</li><li>Different Terms for Input — When using different elements for the same algorithm, you must use different terms inside the algorithm. For nested loops O(a*b) and for loops in a sequence O(a+b).</li><li>Drop non-Dominants — Algorithms can be n² + n, n*logn * 10n, however what drives the function is the dominant value, so it would be, respectively, O(n²) and O(n*logn).</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5f08a899b5644968b05054a82b317727/href">https://medium.com/media/5f08a899b5644968b05054a82b317727/href</a></iframe><h3>Data Structures</h3><p>Data structures are simply ways to organize data. You can define the way you interact with this Data, and how it is arranged in RAM.<br>The most common Data Structures are:</p><ul><li>Array</li><li>Stacks</li><li>Queues</li><li>Linked List</li><li>Trees</li><li>Tries</li><li>Graphs</li><li>Hash Tables</li></ul><p>Each Data Structure has its tradeoffs, they each serve a certain purpose in development, and it is important to where to use each of them.<br>Data structures, in general, have certain common actions that are shared amongst them:</p><ul><li>Insert — Adding a new item into the collection</li><li>Delete — Removing an Item from a collection</li><li>Traversal — Loop through the whole collection, accessing each item once to process it</li><li>Search — Looking for the location of a certain item, if it exists, inside the collection</li><li>Sorting — Sorting the items of a collection</li><li>Access — Accessing an item of the collection</li></ul><h3>Algorithms</h3><p>The algorithm has a broad definition, it pertains to all processes or sets of rules in order to solve a problem. While developing, your code will have many algorithms, from simple to complex, but some are especially useful:</p><ul><li>Sorting — The process of ordering a collection.</li><li>Searching (BFS, DFS, Binary Search) — Searching a collection for a value.</li><li>Recursion — The use of recursive properties in order to solve problems.</li><li>Dynamic Programming — The use of memory and loops to solve problems</li></ul><p>There are many other famous and important algorithms, such as Tree Balancing, Autocomplete, Clustering, A*, etc, but as an introductory article, I’ll mostly focus on the more useful algorithms for beginners.</p><h3>Last Words</h3><p>This was an introduction to what is Data Structures, their commonalities and what to expect in the following parts. And, to what is Algorithms, and some algorithms that we will go over afterwards.</p><p>If you want to learn more of the basics, plus some very useful stuff you can use for job interviews and job hunting for Developers, I can’t recommend enough <a href="https://www.udemy.com/course/master-the-coding-interview-data-structures-algorithms">this </a>Udemy course.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f4281f6a3de1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Generics in C#]]></title>
            <link>https://medium.com/@lhollowwizard/generics-in-c-569a5c64c4e8?source=rss-17953e27b12b------2</link>
            <guid isPermaLink="false">https://medium.com/p/569a5c64c4e8</guid>
            <category><![CDATA[c-sharp-programming]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[generics]]></category>
            <category><![CDATA[microsoft]]></category>
            <category><![CDATA[oop]]></category>
            <dc:creator><![CDATA[Lucas Marinho Dias]]></dc:creator>
            <pubDate>Thu, 06 Jan 2022 05:49:40 GMT</pubDate>
            <atom:updated>2022-10-04T23:22:55.979Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>I didn’t understand at first the power of generics. When I first started learning OOP in Java, I couldn’t yet understand how important generics are for the paradigm. My lack of creativity at the time made me somewhat not interested in the subject, I just understood enough to know what it was and moved on.</p><p>However, after I started working, using C# this time, it became clearer the power and flexibility that generics give you.</p><p>You must have heard of DRY (Don’t Repeat Yourself), which is basically the idea of taking equal or similar code and grouping it in a type or method. However, without generics, problems can appear:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8409ca5702899b1db6a215785074492a/href">https://medium.com/media/8409ca5702899b1db6a215785074492a/href</a></iframe><p>As you can see, since int and string are of different types, a method that works for both would need to have an object as a parameter, which would necessitate<a href="https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/types/boxing-and-unboxing"> boxing and unboxing</a> every time you called Print(), which are very taxing operations!<br>If you use generics though, DRY can be easily achieved:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ff41c76d02664d6b798d5b3d0bfbe4a5/href">https://medium.com/media/ff41c76d02664d6b798d5b3d0bfbe4a5/href</a></iframe><p>Using the generic parameter there allows easier application of DRY, without any boxing/unboxing happening.</p><p>This is only one of the many advantages of Generics, but I chose to start with this example since, in my experience, every programmer, even at beginner levels, knows about DRY.</p><h3>Origins</h3><p>Generics first appeared on C# 2, and their primary use was for Collections, although now they appear everywhere:</p><ul><li>Delegates</li><li>Asynchronous Code (Using Task&lt;T&gt;)</li><li>Nullable value types</li></ul><p>At the beginning of C#, on .NET 1, there were only 3 kinds of Collections:</p><ul><li>Arrays -&gt; Fixed size and initialization. Language and Runtime support. This wouldn’t be as useful on more complex code where you don’t know the final size.</li><li>Object-based Collections -&gt; Values would be described using System. Object. It does not have Language nor Runtime support. (Examples are ArrayList and Hashtables). The problem is that you could have multiple different types inside and it forces a lot of boxing and unboxing.</li><li>Specialized Collection -&gt; You could also implement a Collection of a specific type, such as StringList, which could be a dynamic array composed of strings. However, as the code base grows, the necessity for specialized collections also grows, which implies an inefficient cost for compilation, increased assembly size, size of code in memory, and human cost for remembering all the custom collections.</li></ul><p>Naturally, there was a problem here, and with C# 2 the solution came with List&lt;T&gt;, it has a dynamic size, and the type is decided at compile time (making it harder for bugs to appear and impossible for many different types existing on the same List) and no additional code would need to be generated.<br>Not only Collections have been made better with Generics, but many Design Patterns and new solutions also arrived with them.</p><h3>Type Parameters and Type Arguments</h3><p>The terms parameters and arguments are way older than C#, however, it is as useful now as it was then.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/82fb546d3b9846fece6dab15729d5038/href">https://medium.com/media/82fb546d3b9846fece6dab15729d5038/href</a></iframe><p>In generics, you have the Type parameter and the Type Argument, which works as it does on methods.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7c8277dba8fb763eb42519088737e002/href">https://medium.com/media/7c8277dba8fb763eb42519088737e002/href</a></iframe><h3>Arity of Generics</h3><p>Arity is a mathematical term that means the number of arguments taken by a function. Generic types or methods can declare multiple type parameters, each separated by a comma within the &lt;&gt;.</p><p>public class Tuple&lt;T1, T2&gt;<br>public class Dictionary&lt;TKey, TItem&gt;</p><p>The generic arity of a declaration is the number of type parameters it has. A nongeneric declaration has generic arity of 0.</p><p>The generic arity of a declaration also makes it unique, allowing for overloading methods and types based on the arity.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0b1a7ffea8ff0a3947661d23dfd1cb6d/href">https://medium.com/media/0b1a7ffea8ff0a3947661d23dfd1cb6d/href</a></iframe><h3>What can be Generic?</h3><p>Not all types or type members can be generic.<br>Enums can’t be generic, but other types, such as structs, classes, interfaces and delegates can be.<br>As for type members, it is important to remember that a declaration is generic only if it introduces new type parameters.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/30065e6a4213bc9a710809e044f62d6e/href">https://medium.com/media/30065e6a4213bc9a710809e044f62d6e/href</a></iframe><p>Methods and nested types can be generic, but all the following have to be NONGENERIC:</p><ul><li>Fields</li><li>Properties</li><li>Indexers</li><li>Constructors</li><li>Events</li><li>Finalizers</li></ul><h3>Inferring Types on Methods</h3><p>The compiler is smart enough to infer the argument type on a method call.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2ad6af9bf9e22b93d802dd1e8d789e80/href">https://medium.com/media/2ad6af9bf9e22b93d802dd1e8d789e80/href</a></iframe><p>The compiler can’t infer based on the return type, only by the type argument given. Also, in case a method has an arity of 2 or higher, you need to give all type arguments to the method or none at all, otherwise, the compiler can’t know which parameters to infer.</p><h3>Type Constraints</h3><p>As I said at the beginning, I couldn’t quite work out the full usefulness of generics, and one of the reasons is that I didn’t know about type constraints.<br>Obviously knowing only that a type inherits from object is not so useful, since you can’t be sure it has default constructors, or if they do or do not have a field, or specific method. This is where constraints come, <strong>they allow you to specify restrictions on the types that can be provided as type arguments.</strong></p><p>In order to add a constraint to a type parameter, you use the <strong>where </strong>clause at the end of the type or method declaration.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4732770312067030d49ca5075f3d0719/href">https://medium.com/media/4732770312067030d49ca5075f3d0719/href</a></iframe><p>Constraining T doesn’t change just the values that can be passed to the type or method, it also changes what can be done with the value of type T. <br>The compiler knows that the type T inherits from the interface IComparable&lt;T&gt;, which allows the usage of the method Equals() inside the code implementation.</p><p>The following constraints are available:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b96e2a1a7d027566a51f55fb5ebcbc62/href">https://medium.com/media/b96e2a1a7d027566a51f55fb5ebcbc62/href</a></iframe><ul><li>The reference type constraint can be any reference type, such as classes, interfaces and delegates.</li><li>The Value Type constraint only allows non-nullable value types, either struct or enum.</li><li>Constructor constraint says that the type argument of T must have a public parameterless constructor, which enables the use of <strong>new T()</strong> within the body of the code</li><li>Conversion constraints allow only types that inherit from the specified class, interface or other type parameters.</li></ul><h3><strong>Default and Typeof</strong></h3><ul><li>Default() -&gt; The operand is the name of a type or type parameter, and the result is the default value for that type.<br>The default operator can be used with type parameters and with generic types with appropriate type arguments supplied<br>For example, in a generic method declaring a type parameter T, all of these are available:<br>- default(T)<br>- default(int)<br>- default(List&lt;T&gt;)<br>- default(Dictionary&lt;List&lt;string&gt;, T&gt;)</li><li>Typeof() -&gt; It has these cases:<br>- No generics -&gt; typeof(string), which returns the string type<br>- Generics, but no type parameter -&gt; typeof(List&lt;int&gt;), returns the type with the name of the List, the arity of the type and which type instance it is.<br>- Just a type parameter -&gt; typeof(T), returns what T is at that point in the code.<br>- Generics, type parameter in the operation -&gt; typeof(List&lt;T&gt;), also returns the same information with T as the current type in the code.<br>- Generics, without type parameter specified in the operand -&gt; typeof(List&lt;&gt;), this is a special syntax for the typeof operand and refers to the generic type definition.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/30a9beb3c7f610c9319c7c3540c5c3d8/href">https://medium.com/media/30a9beb3c7f610c9319c7c3540c5c3d8/href</a></iframe><h3>Generic Type Initialization</h3><p>As seen on the previous topic, List&lt;int&gt; and List&lt;string&gt; are instantiated as different types, that are constructed by the same generic type definition.<br>That’s not only true for how you use the type but how types are initialized and static fields are handled.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/446d950a3d2e0fdd2514e3a63394588f/href">https://medium.com/media/446d950a3d2e0fdd2514e3a63394588f/href</a></iframe><p>The values of StaticList are independent, a instance is created for each type, creating new values and calling the constructor, as it normally would.</p><p>Another thing to look out for, is generic types can be nested, and each possible combination would also be independent.</p><h3>Final Words</h3><p>I hope I helped you understand the use and importance of generics in the C# context. It is a very powerful tool that can be a bit tricky for beginners to understand!<br>This text is based on C# in Depth 4e, in which the author goes deeper into the aspects of generics, so even if you liked the article, please check the book, I am sure it will be really helpful!<br>Also, I plan on continuing studying the book and posting more interesting topics about the complexities of the C# language, I hope to see you soon!</p><p>References:<br>1. <a href="https://learn.microsoft.com/en-us/dotnet/csharp/">Documentation</a><br>2. <a href="https://www.manning.com/books/c-sharp-in-depth-fourth-edition">C# in Depth</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=569a5c64c4e8" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>