<?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 Ali Azizjahan on Medium]]></title>
        <description><![CDATA[Stories by Ali Azizjahan on Medium]]></description>
        <link>https://medium.com/@kyxey?source=rss-c802af61b692------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*I2BDyziSFRWV-8l6vDa0Tw.jpeg</url>
            <title>Stories by Ali Azizjahan on Medium</title>
            <link>https://medium.com/@kyxey?source=rss-c802af61b692------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 04 Jun 2026 07:01:41 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kyxey/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[Do I Need Math to Become a Software Engineer?]]></title>
            <link>https://kyxey.medium.com/do-i-need-math-to-become-a-software-engineer-8b5b6c2a3a73?source=rss-c802af61b692------2</link>
            <guid isPermaLink="false">https://medium.com/p/8b5b6c2a3a73</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[mathematics]]></category>
            <dc:creator><![CDATA[Ali Azizjahan]]></dc:creator>
            <pubDate>Tue, 17 Feb 2026 13:31:00 GMT</pubDate>
            <atom:updated>2026-02-17T13:32:14.718Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*EDIOaZdt4kt9_Z3eYZSu5w.jpeg" /><figcaption>To math or not to math, that is the question!</figcaption></figure><h3>TL;DR</h3><p>Many people start coding and wonder if they have to be a math genius. The short answer is: <strong>Not really</strong>! Most coding jobs rely more on logic and problem-solving than on complex math. Beginner-friendly programming (like building websites or apps) usually only needs basic arithmetic and clear thinking. In fact, writing code is often more like writing in a foreign language than solving equations . In other words, you can absolutely write code without deep math skills.</p><p>However, it’s also true that software engineering spans many areas, and some roles use more math than others. We’ll walk through the spectrum of developer jobs, from low-math to high-math, and explain how math skills help along the way. We’ll also see that logic and problem-solving are really the core of programming, so even without a heavy math background you can have a successful coding career.</p><h3>Low-Math and High-Math Engineering Roles</h3><p>Software engineering isn’t one-size-fits-all. Different roles need different math levels. At one end, web developers, mobile app builders, and QA/testers mostly do practical tasks with little math. They use programming languages, frameworks, and libraries, but rarely use advanced math in their day-to-day work. For example, front-end web developers often work with pixel dimensions and layouts. They might use basic geometry or algebra (e.g. calculating a column’s width or form field size), but that usually just involves simple arithmetic . DevOps engineers and QA testers likewise focus on processes, debugging, and automation, not math formulas. In this low-math category, the biggest math you’ll do might be gentle estimations (like how many users a system can handle) or basic statistics (like understanding an A/B test result).</p><p>On the other hand, some fields demand heavy math. Think game development, graphics, machine learning, data science, and cryptography. In game and graphics programming, you constantly deal with vectors, matrices, and physics. You need linear algebra to transform 3D objects and geometry to calculate collisions. Game engines often simulate forces, gravity, or light, which involves calculus and physics equations. Likewise, an AI or machine learning engineer must use linear algebra, calculus, and statistics to build and train models . Even building something like a recommendation engine or image recognizer relies on advanced math under the hood.</p><p>Between those extremes are many mid-level roles. Back-end web developers (server-side) might use a bit more math than front-end. They often query databases (calculating totals or averages) and might handle algorithms with moderate complexity. They should know basic algebra and maybe some geometry or even basic calculus to understand certain formulas or performance estimates . Mobile developers fall in between: if an app has no heavy computation, you might hardly touch math at all; but if you build something like a navigation or finance app, you’ll use trigonometry or statistics depending on the feature . Data engineers and analytics engineers use more statistics and probability to process data, but often rely on libraries and tools for the hard work.</p><p>You can think of roles from least math to most math like this:</p><ul><li><strong>Low math:</strong> Front-end web developer, UI/UX designer, QA/testing, technical support. These focus on code, design, and tools, and “no special math course” is needed.</li><li><strong>Some math:</strong> Back-end developer, mobile app developer, DevOps engineer. You use basic algebra and logic for things like formulas, database queries, or simple physics for animations.</li><li><strong>More math:</strong> Systems programmer, embedded systems, cybersecurity specialist. You might need discrete math (logic, bitwise ops), number theory, or signal processing math.</li><li><strong>High math:</strong> Game/graphics developer, ML/AI engineer, data scientist. These need linear algebra, calculus, probability, stats every day. Cryptography experts need number theory and abstract math. Also, computer science researchers or algorithm developers (often in academic or R&amp;D settings) use the most math of all, designing new algorithms or proving things with discrete math and proofs.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SEwBoM5xpkLrGydeIQdm6Q.jpeg" /><figcaption>How much math is needed in each computer engineering role?</figcaption></figure><p>The level of math required varies by role. Some projects need extensive math while others need none at all . In fact, many web or app projects simply never touch advanced math. Instead, they rely on libraries to handle any heavy lifting. Writing code is no math at all! no need to take a special course about math for software engineers.</p><h3>How Math Skills Help Software Engineers</h3><p>Even if you don’t need calculus every day, math is still a helpful tool in many areas of software engineering. Understanding math can make you a sharper problem-solver and open doors to advanced fields. Here are some ways strong math skills pay off:</p><ul><li><strong>Algorithms and efficiency:</strong> Algorithms often use discrete math concepts. Sorting, searching, and graph algorithms rely on logic and combinatorics. Analyzing an algorithm’s speed means using mathematical concepts like Big-O notation (which is about functions and growth rates). For example, to optimize code, a math background helps you improve the performance of systems and make solutions scalable. When writing loops or recursive functions, you implicitly use math to figure out how they grow with input size. Discrete math (logic, sets, graph theory, recursion) is foundational in programming for making sure code is efficient.</li><li><strong>Game graphics and simulations:</strong> If you venture into game development or simulations, math is crucial. Modeling a 3D world on a 2D screen is literally a math problem. You need geometry and linear algebra to handle rotations and 3D projections. Physics engines use calculus and algebra to simulate movement and forces. For example, to simulate wind resistance or gravity you solve differential equations. Math-savvy developers can create more realistic games and graphics.</li><li><strong>Machine learning and data science:</strong> Building neural networks or data models is math-heavy by nature. ML engineers use linear algebra (to handle matrices of data), calculus (for optimization like gradient descent), and probability/statistics (to model uncertainty). Without these math tools, they can’t truly understand or innovate in AI. Math helps in creating new models. Knowing advanced math and statistics will allow you to create new ML models.</li><li><strong>Cryptography and security:</strong> Modern encryption is built on number theory and modular arithmetic. If you work on security features, you will eventually use math to encrypt and decrypt data. Learning math principles like prime numbers and modular math is essential for cryptography.</li><li><strong>Data analysis and optimization:</strong> Many developers do at least some data crunching or performance tuning. Math helps you analyze numbers (like understanding metrics or logs) and optimize code. For instance, when balancing server load, you might do capacity planning calculations; a background in math makes you confident in those estimates. Engineers apply math to optimize systems, make algorithms efficient, and ensure designs can handle large-scale problems.</li><li><strong>Logical thinking:</strong> Beyond specific topics, studying math trains your brain to think logically. Math classes teach you to break a problem into steps and prove why a solution works. This logical mindset is invaluable in coding. Learning math sharpens your ability to approach complicated problems using logic, which directly improves your programming skills. The reasoning used in math is very similar to the reasoning in software engineering. In fact, someone who enjoys solving math puzzles or logic problems will find that programming feels natural because it’s all about applying rules and logic to produce a result (much like composing music or writing code).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/943/1*30OoqnsWzfL8AGML-7d_rA.png" /><figcaption>How Math Skills Help Software Engineers</figcaption></figure><p>Strong math skills help when you need them. They let you design better algorithms, tackle specialized fields, and understand the “why” behind advanced techniques. But for everyday coding tasks, those advanced topics are optional. Even if advanced math isn’t used on the job, the thinking skills gained from math (logic, structured problem solving) are always useful.</p><h3>Building a Career Without Heavy Math</h3><p>What if math isn’t your strength? Don’t worry! Plenty of successful software engineers have thrived with only basic math. In fact, many developers don’t have a math degree or any college math beyond high school. They learned to code through bootcamps, self-study, or non-traditional paths, focusing on programming practice and projects.</p><p>You don’t need to be good at advanced math to become a good software developer. Basic math like order of operations and simple algebra suffices, because most math-heavy work is already handled by programming languages and libraries. In coding you really need a basic working knowledge of math (order of operations, basic algebra) and knowing how to use built-in math methods. In practice, software engineers rely on math for tasks like adding numbers, comparing values, or using library functions, things we learn in middle or high school.</p><p>Moreover, daily coding often feels more like writing a story or composing music than solving equations. The key is to break problems into logical steps and test your code, not to derive new mathematical formulas from scratch. Many beginners find that they use math only for simple tasks: estimating project effort, tweaking variables, or understanding runtime of loops (Big-O). For example, Some occasional math-related tasks are as follows: rough system load estimates, analyzing an A/B test (stats), a little probability, or thinking about Big-O notation. These tasks use only basic math and logic, not calculus.</p><p>And companies agree! Most software jobs expect only fundamental math skills. Practical programming requires attention to detail, clear thinking, and creativity rather than heavy math. Frameworks, libraries, and even Google and AI are there to handle any tricky math you encounter. If a problem really does need math, you can usually learn just that piece on the spot.</p><p>The essence of programming is logical thinking and problem-solving. With that approach, even a background in non-STEM fields (philosophy, writing, arts) can produce great coders. In short, don’t let math anxiety stop you. You likely already have the math you need: arithmetic, logic, and a dash of algebra. Focus on building projects, learning to think in code, and practicing problem-solving, and you’ll advance in software engineering just fine.</p><h3>Academic vs Industrial Contexts: Who Uses More Math?</h3><p>It’s also useful to distinguish academic computer science from industry software engineering. Academic CS (or research) is math and theory heavy. It’s about understanding fundamental principles: algorithms, computational complexity, machine learning theory, etc. A CS degree typically requires courses in calculus, linear algebra, discrete math, probability, etc. In other words, computer science as a field delves into “why things work”, and that’s grounded in math. Many CS grads go into research, AI, security research, or theoretical work. In academia, you might design new algorithms or prove the limits of computation, jobs that do require strong math.</p><p>By contrast, industrial software engineering (working at tech companies) is more practical and application-focused. The goal is to build products and services: websites, mobile apps, business software, etc. In other words, computer science (the degree) requires a lot of math. Software engineering (the career) usually requires much less math. Industry roles emphasize tools, frameworks, teamwork, and shipping working code. Typical developer jobs (front-end, back-end, full-stack, mobile) use the essentials of computer science but rely on creativity and code craftsmanship more than advanced math.</p><p>That isn’t to say industry engineers never use math; they do use logical thinking and sometimes basic algorithms. But they generally aren’t proving theorems or deriving formulas. In fact, many software engineering educational programs are project-based and hands-on, covering only the math needed for the job. And there are many pathways into industry (such as coding bootcamps or self-learning) that skip heavy math entirely, focusing on programming skills and problem-solving.</p><p><strong>Academic CS = math-heavy, theoretical; industry SE = applied, practical</strong>. If you’re passionate about inventing new algorithms or researching AI theory, math will be front and center. But if you want to build apps, websites, or consumer software, basic math (algebra, logic, arithmetic) plus your coding know-how will take you far.</p><h3>Conclusion</h3><p>In the end, you don’t need to be a math genius to become a software engineer. For most developers, especially beginners, basic math is enough. The real focus is on learning to think logically, solve problems step-by-step, and write clear code. Math is a helpful tool in certain specialties (like graphics, ML, crypto), but it’s not a barrier to entry in programming. Programming relies on problem-solving skills and built-in tools, not constant calculations.</p><p>If you’re starting out, use whatever math you know to your advantage. Arithmetic, logical operations, and simple algebra. Don’t let math anxiety stop you! The programming community welcomes people with diverse strengths. With practice, curiosity, and persistence, you can build a great software career. And who knows? Along the way, you might even start to enjoy some of the mathematical ideas too, now that you see them in action in your own code.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ftenor.com%2Fembed%2F7960154131707394613&amp;display_name=Tenor&amp;url=https%3A%2F%2Ftenor.com%2Fview%2Fcaps-lock-texting-writing-complaining-twitter-fingers-gif-7960154131707394613&amp;image=https%3A%2F%2Fmedia.tenor.com%2FbngmAhHG-jUAAAAN%2Fcaps-lock-texting.png&amp;type=text%2Fhtml&amp;schema=tenor" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/65e85dae58f94a6cf792b9dee7cd3790/href">https://medium.com/media/65e85dae58f94a6cf792b9dee7cd3790/href</a></iframe><h3>Sources</h3><ul><li><a href="https://educatingengineers.com/blog/how-much-math-for-computer-engineering/#:~:text=The%20reality%20is%20that%20math,from%20coding%20to%20system%20optimization">EducatingEngineers.com: <em>“How Much Math Do You Need for Computer and Software Engineering?”</em> (Nov 2024)</a></li><li><a href="https://www.codecademy.com/resources/blog/how-much-math-do-you-need-to-know-to-be-a-software-engineer#:~:text=While%20the%20programming%20languages%20we,absolutely%20write%20code%20without%20math">Codecademy Blog: <em>“Can You Be a Software Engineer Without Strong Math Skills?”</em> (2024)</a></li><li><a href="https://www.institutedata.com/us/blog/does-software-engineering-require-math-a-comprehensive-guide/#:~:text=Educational%20requirements%20for%20software%20engineers">Institute of Data: <em>“Does Software Engineering Require Math? A Comprehensive Guide”</em></a></li><li><a href="https://medium.com/better-programming/you-dont-need-math-to-be-a-software-engineer-4ebd345be1d5#:~:text=I%20will%20make%20a%20distinction,heavy">Brett Fazio (Medium, Better Programming): <em>“You Don’t Need Math to Be a Software Engineer”</em></a></li><li><a href="https://www.educative.io/blog/how-much-math-do-developers-need#:~:text=This%20role%20typically%20requires%20basic,involve%20calculations%20and%20solving%20problems">Educative.io: <em>“How much math do you need to know to be a developer?”</em> (July 2022)</a></li><li><a href="https://www.bloomtech.com/article/does-coding-require-math#:~:text=One%20of%20the%20questions%20we,become%20a%20good%20software%20developer">BloomTech (Fullstack Academy): <em>“Does Coding Require Math? The Answer Might Surprise You”</em> (July 2022)</a></li><li><a href="https://www.intuit.com/blog/innovative-thinking/computer-science-vs-software-engineering/#:~:text=Think%20of%20computer%20science%20as,that%20people%20use%20every%20day">Intuit Blog: <em>“What’s the difference between software engineering and computer science?”</em> (2025)</a></li><li><a href="https://tripleten.com/blog/posts/can-you-be-a-successful-software-engineer-without-math-skills#:~:text=To%20many%20of%20those%20who,about%20math%20for%20software%20engineers">TripleTen Blog: <em>“Does Software Engineering Require Math Skills?”</em> (2024)</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8b5b6c2a3a73" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Just-In-Time (JIT) Compilers: Simple Explanation with C Examples]]></title>
            <link>https://kyxey.medium.com/just-in-time-jit-compilers-simple-explanation-with-c-examples-e56a5ecf46a5?source=rss-c802af61b692------2</link>
            <guid isPermaLink="false">https://medium.com/p/e56a5ecf46a5</guid>
            <category><![CDATA[compilers]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[software]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Ali Azizjahan]]></dc:creator>
            <pubDate>Thu, 12 Feb 2026 14:41:52 GMT</pubDate>
            <atom:updated>2026-02-12T14:43:00.683Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uWpK5-FSLkO620kaeNUL-g.jpeg" /><figcaption>Mr. Speed Booster AKA The JIT Compiler listens to and watches for “hot codes”.</figcaption></figure><h3>What is a JIT Compiler?</h3><p>Meet Mr. Speed Booster: The JIT Compiler. He doesn’t wait until your code is done cooking. Nope. He jumps in <em>while</em> your program is running, turning it into blazing-fast machine code just in time for execution. Hence the name: Just-In-Time!</p><p>Imagine you’re talking to someone who only understands a secret language. You can either:</p><ul><li>Translate everything <strong>before</strong> the conversation (like a regular compiler), or</li><li>Translate <strong>line by line</strong> as you speak (like an interpreter).</li></ul><p>A JIT compiler is the genius friend who listens, figures out what’s being said most often, and starts <strong>translating those parts perfectly on the fly</strong> while you’re still talking. That’s JIT compilation. It compiles code <strong>while the program is running</strong>, not before.</p><p>In programming terms: a JIT compiler takes your program’s intermediate code (like Java bytecode or .NET IL) and compiles it into <strong>real machine code during execution</strong>. The goal? To mix the <strong>speed of compiled languages</strong> with the <strong>flexibility of interpreted ones</strong>.</p><p>Languages like <strong>Java</strong>, <strong>C#</strong>, and <strong>JavaScript (V8 engine)</strong> all rely heavily on JIT compilers. The JIT watches what your code does, finds the “hot” parts (the functions that run a lot), and compiles those into fast native code. The result? A program that keeps learning and optimizing itself as it runs. Pretty smart, right?</p><h3>Why Do We Even Need a JIT?</h3><p>Let’s break it down into bite-sized reasons:</p><h4>1. Speed Boost</h4><p>JITs take code that would normally be interpreted and compile it into native CPU instructions <strong>while the program runs</strong>. So, instead of reading instructions one by one, your CPU can just <strong>execute</strong> them directly, way faster.</p><h4>2. Adaptive Optimization</h4><p>A JIT compiler doesn’t waste time compiling everything at once. It monitors which functions or loops are executed often (a.k.a. <em>hot code</em>), and only compiles those. If a function gets even hotter over time, the JIT can recompile it with <strong>smarter optimizations</strong>.</p><h4>3. Perfect for Dynamic Languages</h4><p>Languages like JavaScript and Python are constantly changing types and doing runtime checks. A JIT can handle these dynamic behaviors gracefully, because it compiles code <strong>as it goes</strong>, adjusting for real runtime conditions.</p><h4>4. Cross-Platform Flexibility</h4><p>Java and C# ship platform-independent bytecode. Then, each machine’s JIT compiles that bytecode into the native instructions of that CPU. So, one .class file works on both Windows and Linux, but still runs at native speed.</p><h3>The Trade-Offs (Because Nothing’s Free)</h3><p>Every hero has a weakness, and the JIT is no exception:</p><h4>1. Startup Delay</h4><p>Compiling during runtime takes CPU time. If a JIT tried to compile <em>everything</em> at startup, your app would open like a sleepy turtle. That’s why JITs are smart — they start with interpreted code and compile only when needed.</p><h4>2. Limited Optimization Time</h4><p>JITs can’t afford to spend 10 minutes analyzing your entire codebase like a C compiler does. They focus on quick, practical optimizations; enough to get good performance fast.</p><h4>3. More Memory Usage</h4><p>Every piece of generated machine code lives in memory. On large, long-running programs, this adds up.</p><p>Think of it like cooking:</p><ul><li><strong>Interpreter:</strong> Fast food =&gt; instant but not fancy.</li><li><strong>AOT Compiler:</strong> Gourmet meal =&gt; slow to prepare, perfect results.</li><li><strong>JIT Compiler:</strong> Omelette on demand =&gt; fast, fresh, and tailored for you.</li></ul><h3>How Does a JIT Compiler Actually Work?</h3><p>Let’s go step by step through the JIT’s secret recipe:</p><h4><strong>1. Load &amp; Interpret</strong></h4><p>The runtime starts reading bytecode or intermediate code. It might interpret it first for quick startup.</p><h4><strong>2. Profiling</strong></h4><p>While running, the runtime tracks which functions or loops are used the most.</p><h4><strong>3. Trigger Compilation</strong></h4><p>When something becomes “hot,” the JIT decides to compile it.</p><h4><strong>4. Machine Code Generation</strong></h4><p>The JIT converts the hot code into native CPU instructions. It might also inline small functions or unroll loops for extra speed.</p><h4><strong>5. Install &amp; Execute</strong></h4><p>The compiled code is placed in executable memory, and the runtime jumps straight to it. From now on, that function runs natively!</p><h4><strong>6. Re-Optimize</strong></h4><p>If it keeps getting hotter, the JIT might compile it again with even better optimizations. Some JITs even discard old compiled code when memory is tight.</p><p>At the CPU level, what’s happening is simple:</p><p>The JIT writes machine code bytes into memory, marks that memory as executable, and then runs it. Just like calling a regular function.</p><p>Here’s a minimal C example that mimics what a JIT does:</p><pre>#include &lt;stdio.h&gt;<br>#include &lt;sys/mman.h&gt;<br>#include &lt;string.h&gt;<br><br>typedef int (*func_t)(int,int);<br><br>int main() {<br>    // Imagine these bytes represent compiled machine code for:<br>    // int add(int a, int b) { return a + b; }<br>    unsigned char machineCode[] = { /* ... machine code bytes ... */ };<br>    size_t codeSize = sizeof(machineCode);<br>    // Allocate a read/write/execute memory region<br>    void *buf = mmap(NULL, codeSize, PROT_READ | PROT_WRITE | PROT_EXEC,<br>                     MAP_PRIVATE | MAP_ANON, -1, 0);<br>    memcpy(buf, machineCode, codeSize);<br>    // Cast and call it like a function<br>    func_t add = (func_t)buf;<br>    int result = add(3, 4);<br>    printf(&quot;3 + 4 = %d\n&quot;, result);<br>    return 0;<br>}</pre><p>Here, we use mmap() to create executable memory, copy some machine code into it, and then call it like a regular function. That’s literally what a JIT compiler does behind the scenes; it builds and runs code on the fly.</p><h3>JIT vs. Interpreter vs. AOT Compiler</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6be09b0759343fc63770cc61c2d80115/href">https://medium.com/media/6be09b0759343fc63770cc61c2d80115/href</a></iframe><p>Most modern languages like Java, C#, and JavaScript, actually use a <strong>mix</strong> of techniques. They start by interpreting code for fast startup, then JIT-compile hot code for maximum performance. This is called <strong>tiered compilation</strong>.</p><h3>When and Why to Use a JIT</h3><ul><li><strong>Runtime Environments:</strong> Perfect for VMs like JVM or .NET CLR.</li><li><strong>Dynamic Languages:</strong> Ideal for JavaScript or Python (e.g., PyPy, V8).</li><li><strong>Game Engines or Emulators:</strong> They can translate instructions dynamically and optimize them.</li><li><strong>Big Data Systems:</strong> JITs like those in Apache Spark speed up repeated computations.</li></ul><p>If you ever want to write your own JIT (which is a fun challenge), check out tools like <strong>LLVM</strong> or <strong>GNU Lightning</strong>. They handle most of the heavy lifting — you just focus on what to compile and when.</p><h3>Final Thoughts</h3><p>A <strong>Just-In-Time Compiler</strong> is like having a translator who learns as you talk.</p><p>It listens to your program, finds the important parts, compiles them right when you need them, and keeps making them faster the more you run them.</p><p>It gives you the <strong>speed of compiled code</strong> and the <strong>flexibility of interpreted code</strong>, all rolled into one.</p><p>In simple terms:</p><p>A JIT takes some memory, writes machine code into it, and executes it like magic.</p><p>Understanding it isn’t hard, it’s just a clever trick that turns time into performance.</p><p>Now you know the secret sauce behind how modern languages get so fast.</p><p>When someone mentions “JIT Compiler,” you can confidently say,</p><p>“Oh yeah, that’s Mr. Speed Booster doing his thing.”</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ftenor.com%2Fembed%2F25519285&amp;display_name=Tenor&amp;url=https%3A%2F%2Ftenor.com%2Fview%2Fspeed-cola-gif-25519285&amp;image=https%3A%2F%2Fmedia.tenor.com%2F5ufMYYWmnkAAAAAN%2Fspeed-cola.png&amp;type=text%2Fhtml&amp;schema=tenor" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/953d172daf2114cda57785a61794719e/href">https://medium.com/media/953d172daf2114cda57785a61794719e/href</a></iframe><h3>Sources</h3><ol><li><a href="https://stackoverflow.com/questions/219323/difference-between-just-in-time-jit-and-interpretation">https://stackoverflow.com/questions/219323/difference-between-just-in-time-jit-and-interpretation</a></li><li><a href="https://en.wikipedia.org/wiki/Just-in-time_compilation">https://en.wikipedia.org/wiki/Just-in-time_compilation</a></li><li><a href="https://stackoverflow.com/questions/627132/what-is-a-jit-compiler">https://stackoverflow.com/questions/627132/what-is-a-jit-compiler</a></li><li><a href="https://blogs.oracle.com/javamagazine/post/jit-compiler-java">https://blogs.oracle.com/javamagazine/post/jit-compiler-java</a></li><li><a href="https://stackoverflow.com/questions/29784125/what-is-a-jit-compiler-how-does-it-work">https://stackoverflow.com/questions/29784125/what-is-a-jit-compiler-how-does-it-work</a></li><li><a href="https://stackoverflow.com/questions/70348619/creating-jit-code-at-runtime-in-c">https://stackoverflow.com/questions/70348619/creating-jit-code-at-runtime-in-c</a></li><li><a href="https://stackoverflow.com/questions/46818642/how-to-execute-machine-code-generated-at-runtime">https://stackoverflow.com/questions/46818642/how-to-execute-machine-code-generated-at-runtime</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e56a5ecf46a5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is a Compiler? How Does It Work? (An Easy Explanation)]]></title>
            <link>https://kyxey.medium.com/what-is-a-compiler-how-does-it-work-an-easy-explanation-482a7280f1be?source=rss-c802af61b692------2</link>
            <guid isPermaLink="false">https://medium.com/p/482a7280f1be</guid>
            <category><![CDATA[software]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[compilers]]></category>
            <dc:creator><![CDATA[Ali Azizjahan]]></dc:creator>
            <pubDate>Thu, 23 Nov 2023 00:10:47 GMT</pubDate>
            <atom:updated>2023-11-23T00:10:47.111Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="MR. Code Translator AKA The Compiler. He takes in human-readable code, and translates it to CPU-readable one." src="https://cdn-images-1.medium.com/max/1024/1*jJHX5z-V40w8_e55uMQHAw.jpeg" /><figcaption>MR. Code Translator AKA The Compiler. He takes in human-readable code, and translates it to CPU-readable one.</figcaption></figure><h3>Introduction</h3><p>A computer’s CPU, which is responsible for running your code, doesn’t understand JavaScript, Go, C++ or any other <em>high-level programming languages</em> that we know. These high-level languages, are basically some layers of abstraction, made by computer programmers and engineers, so speaking to a computer becomes easier for us as humans.</p><h3>What is a Compiler?</h3><p>A CPU, and computer’s hardware in general, only understand zeros and ones, which we technically refer to as <em>binary code</em>. The reason behind this is that a computer’s hardware is basically made out of billions of transistors, which can only have two states: <em>on</em> or <em>off</em>. These “on” and “off” states are represented with zeros and ones; 1 meaning on, thus the electrons pass through, and 0 meaning off, which stops electricity from passing through a transistor. Literally everything that a computer does, is made possible by these on or off states of those tiny transistors.</p><p>Now, compilers are fascinating tools that transform the high-level code written by programmers, which is more easily readable by humans compared to zeros and ones, into binary code language that computers understand.</p><p>At its core, a compiler is like a translator. Just as a person might translate Spanish into English, a compiler translates the code written in a high-level programming language, into <em>machine code</em> (binary code).</p><h3>But How Do Compilers Work?</h3><p>The process of <em>compilation</em>, which is the name of what a compiler does under the hood, involves several stages. Here we take a brief look at each of these stages, all with real examples:</p><p><strong>1. Lexical Analysis:</strong> This is the first step where the compiler breaks down the code into basic elements or <em>tokens</em>. For example, in the line String greeting = &quot;Hello&quot;;, the tokens would be String, greeting, =, &quot;Hello&quot;, and ;​.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mw6_nJsfZF5oVEYHswzWcA.jpeg" /><figcaption>Step 1: Lexical Analysis</figcaption></figure><p><strong>2. Syntax Analysis:</strong> Here, the compiler uses the tokens to build a structure called an <em>Abstract Syntax Tree (AST)</em>, which represents the logical structure of the program. This step checks the grammatical structure of the code and looks for syntax errors​. If an AST’s structure becomes invalid, the compiler immediately knows that the original code had a syntax error, and in most cases it knows exactly where the error is coming from.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LXd44b1xT__hfrTYfCuiKQ.jpeg" /><figcaption>Step 2: Syntax Analysis</figcaption></figure><p><strong>3. Semantic Analysis:</strong> The compiler uses the AST to detect semantic errors, such as assigning the wrong type to a variable or using a keyword as a variable name. This stage includes type checking, flow control checking, and label checking​.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3QyaKDQ9G3iFtGNjmPG6cw.jpeg" /><figcaption>Step 3: Semantic Analysis</figcaption></figure><p><strong>4. Intermediate Code Generation:</strong> The compiler generates an intermediate code that is machine-independent; meaning that it can be used on any hardware later on to generate the final binary code for that specific machine. This also means that the code can be easily translated into the machine code of any target machine. The intermediate code can be either high-level, similar to the source language, or low-level, closer to machine code​. Now you might ask, if the generated intermediate language may be sometimes similar to the source code or another high-level language, what is the need for generating it at all? Can’t we just make the original source code machine-independent? The answer is pretty easy: The compiler does that so it can optimize the code way more easily, make sure that the code has the least amount of dependencies to your current hardware, and the complexity of designing a compiler decreases.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8_d7731FY1Ea2bv-297J6Q.jpeg" /><figcaption>Step 4: Intermediate Code Generation</figcaption></figure><p><strong>5. Optimization:</strong> In this phase, the compiler makes the code more efficient without altering its meaning and purpose. The optimization focuses on consuming fewer resources and speeding up the operation of the software​. This is where the intermediate language that was generated in the previous step becomes really handy! In the upcoming example, the original source code written in C was this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*rpYHXfK9PnZtBqGnl310xA.png" /><figcaption>The original source code written in C</figcaption></figure><p>Then it was used to generate the intermediate code, which consists of a highly inefficient loop, and then was optimized by the compiler to eliminate the problematic part:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZGl_z0VnrsIAKDsi0Bntzg.jpeg" /><figcaption>Step 5: Optimization</figcaption></figure><p><strong>6. Code Generation:</strong> Finally, the compiler converts the optimized intermediate code into the machine code specific to the target machine. This code should be efficient in terms of memory and CPU resource usage​. This is actually where the compiler does its magic! It knows if your CPU understands Spanish Binary (which is a word that I just made up to make it easier to understand) or English Binary. Our Mr. Translator knows exactly what each of those words of the intermediate language mean in the binary language of your own CPU. How? By examining and using the actual hardware that you’re using, and sometimes some of the high-level APIs that are accessible from the operating system itself.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H51Oxujc0mmL63Bgvk2BXg.jpeg" /><figcaption>Step 6: Code Generation</figcaption></figure><h3>Advanced Resources</h3><p>The overall process of a compiler design isn’t really hard to understand. But if you want to get deep and actually design a compiler yourself or even contribute to an already-existing compiler, you definitely need more advanced knowledge about each steps. Here, I include some resources that I think they may be helpful for the advanced readers. I haven’t studied all of them myself, so please do your own research before actually studying any of them:</p><ul><li>Compilers: Principles, Techniques, and Tools” by Alfred V. Aho, Monica S. Lam, Ravi Sethi, and Jeffrey D. Ullman, often referred to as the “<em>Dragon Book</em>”.</li><li>“Engineering a Compiler” by Keith Cooper and Linda Torczon.</li><li>Online courses on platforms like Coursera, edX, and MIT OpenCourseWare, which often feature in-depth lectures and materials on compiler design.</li></ul><p>If you’re really into designing a compiler, I suggest you start with reading the code of open-source compilers. This gives you a clear vision of what is exactly going on under the hood. Also by contributing to these open-source compilers, you’re not only helping yourself learn more by getting your hands dirty, but also helping a lot of people out there who are actually using those tools! That’s how we, as software engineers, have each other’s backs. :)</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ftenor.com%2Fembed%2F16104083722391378834&amp;display_name=Tenor&amp;url=https%3A%2F%2Ftenor.com%2Fview%2Fcat-typing-typing-on-computer-computer-work-laptop-gif-16104083722391378834&amp;image=https%3A%2F%2Fmedia.tenor.com%2F330y0opJ25IAAAAN%2Fcat-typing.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=tenor" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/79e44c5ffddd4c17e0f135e8db947156/href">https://medium.com/media/79e44c5ffddd4c17e0f135e8db947156/href</a></iframe><h3>Sources</h3><p><a href="https://www.baeldung.com/cs/how-compilers-work">https://www.baeldung.com/cs/how-compilers-work</a></p><ul><li><a href="https://medium.com/@mayanksingh0068/introduction-to-compiler-552b5000bf0d">Introduction to Compiler</a></li><li><a href="https://www.freecodecamp.org/news/what-is-a-compiler-in-c/">What is a Compiler? Compilers in C Explained for Beginners</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=482a7280f1be" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Folder Structure of macOS: Everything You Need to Know]]></title>
            <link>https://kyxey.medium.com/the-folder-structure-of-macos-everything-you-need-to-know-d9314ae3bf01?source=rss-c802af61b692------2</link>
            <guid isPermaLink="false">https://medium.com/p/d9314ae3bf01</guid>
            <category><![CDATA[operation-systems]]></category>
            <category><![CDATA[apple]]></category>
            <category><![CDATA[mac]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[macos]]></category>
            <dc:creator><![CDATA[Ali Azizjahan]]></dc:creator>
            <pubDate>Mon, 20 Nov 2023 15:58:09 GMT</pubDate>
            <atom:updated>2024-05-11T19:27:20.075Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zfdfW_4m-AL38cCypes3XQ.jpeg" /><figcaption>What are all these folders?</figcaption></figure><h3>Introduction</h3><p>In macOS, the folder structure is integral to understanding how the system organizes files and applications. For many of us, knowing the correct path for everything is only to fulfill our sense of curiosity. However, for some people, specially programmers and software developers, knowing what is where in their computer means more than that.</p><h3>Why Am I Writing This?</h3><p>As someone with a keen interest in this operating system, I spent some time understanding the correct folder structure of a Mac system and gathering this information all in one place, so you don’t have to. :)</p><p>Please note that all these data are subjective to change. If you find anything missing, or stated incorrectly, please let me know in the comments and I will fix them for the next fellow Mac user who’s reading this.</p><h3>Enough Talking. Let’s Dive In!</h3><p>Here’s a detailed list of what you need to know:</p><ul><li><strong>Applications:</strong> This folder contains all the applications installed on your Mac, such as Mail, Calendar, Safari, etc. These apps are also accessible through Launchpad​. Any new apps that you install, will end up here.</li><li><strong>Library:</strong> This is where fonts and other items used by applications are stored. It’s accessible to all users on the Mac and is not intended for personal file storage​. Some of the apps store the files that they need to function with in this directory.</li><li><strong>System:</strong> This folder houses the macOS operating system itself. You cannot change its name, location, or contents​.</li><li><strong>Users:</strong> It contains the home folders of all users on your Mac. Each user’s home folder is represented by a house icon when logged in. It also includes a Shared folder for items available to all users​.</li><li><strong>Home:</strong> Named after your username, this folder holds your personal files and folders, such as desktop files, downloads, pictures, documents, movies, music, and public files. You can create new folders here​. This is where you mostly work in. Well, usually.</li><li><strong>Developer:</strong> Appears only if Apple’s Developer Tools are installed, containing tools, documentation, and files for development​. (If you’re planning to make and publish apps for macOS, iOS, or any other Apple devices.)</li><li><strong>Network:</strong> Contains network-related devices, servers, libraries, etc​.</li><li><strong>Volumes:</strong> This directory includes mounted devices and volumes, such as hard disks, CDs, DVDs, DMG mounts, etc​.</li><li><strong>Root Directory (/):</strong> The topmost directory in macOS, parent to all other files and directories​.</li><li><strong>Bin (/bin):</strong> Holds essential common binaries necessary for booting the operating system and its proper functioning​. (Not the OS itself)</li><li><strong>Etc (/etc):</strong> Contains local system configuration files, including administrative and system files​.</li><li><strong>Dev (/dev):</strong> Includes device files representing peripheral devices like keyboards, mice, and trackpads​.</li><li><strong>Usr (/usr):</strong> A major hierarchy containing subdirectories with information, configuration files, and other essentials used by the operating system​.</li><li><strong>Sbin (/sbin):</strong> Contains essential system binaries and utilities for system administration​. Somehow similar to Bin (/bin).</li><li><strong>Tmp (/tmp):</strong> A directory for temporary files and caches​.</li><li><strong>Var (/var):</strong> Holds variable data, which includes files whose contents change as the operating system runs​.</li><li><strong>Opt (/opt):</strong> This directory is typically used for installing optional software packages that are not part of the core operating system. It provides a location for add-on software that is not managed by the package manager of the operating system. For example, third-party software like Homebrew may install packages under `/opt`. [UPDATED on 2024/05/11 — Thanks to <a href="https://pyprocrast.medium.com/">PyProcrast</a> for their comment.)</li></ul><p>Now this, specially the part that contains /bin, /usr, /tmp etc. may trick you into thinking that these are the same as a Linux operation system. While your guess is not incorrect, it’s not totally correct neither. Let’s see how.</p><h3>How macOS and Linux Differ?</h3><p>Both macOS and Linux are UNIX-based operating systems, and their file structures share similarities. Like macOS, Linux also has a hierarchical tree structure starting from the root directory (denoted by a forward slash /). However, Linux treats everything as a file, including external devices, and allows files with the same name in the same directory if they use different cases, which is not the case in macOS.</p><h3>Sooo, Why Is It Called “A Closed OS” Then?!</h3><p>If the folder structure in macOS is very much similar to Linux and other Unix-based systems, then why is it called “A Closed Operating System”?</p><p>Well, the answer is, that’s not directly related to the folder structure. macOS is often referred to as a closed operating system compared to Linux, but for these reasons:</p><ul><li><strong>Source Code Accessibility:</strong> macOS, developed by Apple, is proprietary software. Its source code is not publicly accessible, unlike Linux, which is open-source and allows users to view, modify, and distribute its code.</li><li><strong>Customization and Control:</strong> macOS offers limited customization options compared to Linux. Linux users have more freedom to alter the system’s core functionalities, including its kernel, which is not possible with macOS.</li><li><strong>Software Ecosystem:</strong> Apple controls the macOS software ecosystem tightly. This includes restrictions on software installation sources and stringent app store policies. Linux, conversely, supports a wide range of software from various sources without such restrictions.</li><li><strong>Hardware Compatibility:</strong> macOS is designed primarily for Apple hardware and is not officially supported on non-Apple hardware. In contrast, Linux can be installed on a wide variety of hardware platforms, including Apple hardware.</li></ul><p>Thus, the “closed” nature of macOS stems more from its proprietary, controlled approach to software distribution, customization, and hardware compatibility, rather than its folder structure or file system organization.</p><h3>Conclusion</h3><p>Understanding the macOS folder structure is crucial, especially for new users transitioning from other operating systems. I hope this guide could serve as a comprehensive overview for anyone new to macOS, providing insights into how the system organizes and manages files.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ftenor.com%2Fembed%2F5553323&amp;display_name=Tenor&amp;url=https%3A%2F%2Ftenor.com%2Fview%2Fapple-computer-applause-excited-mac-book-gif-5553323&amp;image=https%3A%2F%2Fmedia.tenor.com%2FqgMlUjh3FNQAAAAF%2Fapple-computer.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=tenor" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/079a856ebecf698e88df1f3da3c8c364/href">https://medium.com/media/079a856ebecf698e88df1f3da3c8c364/href</a></iframe><h3>Sources:</h3><ul><li><a href="https://support.apple.com/guide/mac-help/folders-that-come-with-your-mac-mchlp1143/mac#:~:text=,154%E2%80%A0Install%20and%20uninstall%20apps%E3%80%91">Folders that come with your Mac</a></li><li><a href="https://osxdaily.com/2007/03/30/mac-os-x-directory-structure-explained/">Mac OS X Directory Structure explained</a></li><li><a href="https://shiftweb.com/the-differences-between-mac-windows-and-linux/">The Differences Between Mac, Windows, and Linux (2021 Update) - ShiftWeb</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d9314ae3bf01" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Let’s GO! Part 12: Reference Types 4: Channels]]></title>
            <link>https://kyxey.medium.com/lets-go-part-12-reference-types-4-channels-555c2aad4c28?source=rss-c802af61b692------2</link>
            <guid isPermaLink="false">https://medium.com/p/555c2aad4c28</guid>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[go]]></category>
            <category><![CDATA[programming-languages]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Ali Azizjahan]]></dc:creator>
            <pubDate>Fri, 11 Feb 2022 10:56:01 GMT</pubDate>
            <atom:updated>2022-02-12T12:22:38.898Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aPqe_lNPQKims-e0o8cVMw.jpeg" /><figcaption>Concurrency is when more than 1 gopher are digging holes at the same time.</figcaption></figure><h3>Overview</h3><p>Channels are here to solve the concurrency problem in GO! They’re basically some bunch of pointers as well that hide the hardness of implementing FIFO queues under the hood to read from and write to.</p><h3>Concurrency, You Say?</h3><p>Yes! Concurrency is when you want to run more than one block of code at the same time. Concurrent jobs in GO are called <strong>goroutines</strong> and GO, under the hood, is very efficient when it comes to concurrency as it sends each job (block of code) to a different CPU core to be executed as a completely separated thread. This is unlike some other programming languages like Javascript that your entire program gets run on only one single thread thus they can’t take advantage of multicore systems, making them not very efficient when it comes to concurrent jobs.</p><h3>How To Run Something In A Concurrent Manner?</h3><p>Say go before it. Yup! That simple! When you wanted to run a function in the usual synchronized way, you’d simply say it’s name like myFuncName(). Now if you want to run it in an asynchronized manner, just say go myFuncName() and it’ll be sent to it’s own thread to be executed, thus it won’t block the next lines of codes that come after it to get executed like it did in the synchronized way. Now if you want to know that how concurrency helps to solve some major problems in programming, you’re a Google search away from your answer.</p><h3>So What Are Channels?</h3><p>Channels, in appearance, are basic variables that work like a FIFO queue. However, their syntax is a little bit different than simple variables. At the first glance they might look a little hard to grasp but believe me they’re not that hard. As soon as you know how do they work, you’ll get addicted to using them left and right! The idea of the Channels is to <strong>solve the mutual exclusion issues</strong> when working in an asynchronous way <strong>by reversing the dependencies</strong>. Read this sentence carefully a few times to understand how Channels do such job:</p><blockquote>Instead of trying to establish the communication across your application by sharing the memory, Channels try to share the memory by establishing the communication across your application.</blockquote><p>It might sound hard a little bit but it’s really not. As you get more familiar with them you’ll see this yourself in action.</p><h3>So, How Do They Work?</h3><p>We have receive-only Channels, which you can only receive (read) values from them, and we have send-only Channels, which you can only send (write) values to them, and we have receive/send Channels which you can perform both of the operations on them. Based on your use case, you can decide which one to use. For example if your function only wants to read the value from the Channel and never intends to write a value to it, you may want to pass your receive/send Channel as a receive-only Channel to your function to prevent logical errors. But what is really happening with Channels is that when you try to read from a Channel, GO will wait for a value to be written to it if there’s no values inside it already. And if there are multiple values inside a Channel, GO will <strong>pop</strong> the first value that is sent to it and gives it back to you when you try to read from it once. (Hence the FIFO structure) It means that the second time you try to read, you’ll get the second value. <strong>So any written values to a Channel can be read only once, and after that, the value is gone</strong>. Try to think of it as a tube; A block of code pushes a value inside the tube. The other end of the tube is where you can receive the value from it. But once you get the value out of the tube (read it) it’s not inside the tube for anyone else to receive anymore. Now if you try to read from a Channel that you never send to it anywhere inside your code flow, GO’s compiler will complain that it is a deadlock, because it waits for an infinite time for a value to be sent inside the tube but it never happens. Thus the next lines of code will never be executed and GO is very intelligent finding where the things are going wrong.</p><h3>Syntax! Shall We?</h3><p>Since the syntax of the Channels is a little bit different than simple variables, it’s a good thing to know it before we see them in action.</p><p>The birth of a Channel:</p><pre># The &quot;CHANNEL_TYPE&quot; can be any type that we already know<br># But it should be prefixed with &quot;chan&quot;</pre><pre>myChannelName := make(chan CHANNEL_TYPE)</pre><p>Writing (sending) to a Channel:</p><pre># the &quot;VALUE&quot; should be of the type that the Channel is made of<br># It&#39;s basically saying &quot;send the value inside the tube (queue-Channel)&quot;</pre><pre>myChannelName &lt;- VALUE</pre><p>Read from a Channel:</p><pre># Get the latest value of a Channel in a Variable</pre><pre>myVariableName := &lt;-myChannelName</pre><pre># OR use the value directly. Either way it&#39;s now popped out of the queue</pre><pre>fmt.Println(&lt;-myChannelName)</pre><p>Note the &lt;- that does the read and write operations on Channels based on whether it comes before or after the Channel’s name respectively.</p><p>Typing a Channel as an argument:</p><pre># Receive/send Channel</pre><pre>func myFunctionName(myChannelName chan CHANNEL_TYP) {</pre><pre># Now you can perform both read and write ops on the Channel<br>  ...<br>}<br></pre><pre># Receive-only Channel</pre><pre>func myFunctionName(myChannelName &lt;-chan CHANNEL_TYP) {</pre><pre># Now you can only receive (read) values from the Channel<br>  ...<br>}<br></pre><pre># Send-only Channel</pre><pre>func myFunctionName(myChannelName chan&lt;- CHANNEL_TYP) {</pre><pre># Now you can only send (write) values to the Channel<br>  ...<br>}</pre><p>Aight we good. Let’s see the code.</p><h3>Code.</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7c4a010d68aef0c0e740dc98d16e1652/href">https://medium.com/media/7c4a010d68aef0c0e740dc98d16e1652/href</a></iframe><p>The result should be:</p><pre>144</pre><p>Some important notes about the above code:</p><ul><li>The Pow function that comes from the built-in math package simply powers it’s first argument by it’s second argument. Both arguments should be of type float64 and so the result.</li><li>As you can see in the code, if you run two goroutines at the same time and they’re dependent, you’ll run into a race condition! Be very careful with this. Not everything needs to be asynchronous. Only the jobs that are time consuming and are not dependent on some other jobs that are running on some other simultaneous goroutines. But if you run everything on a synchronized manner you won’t have this race condition problem. However in that case, if the square function is calculating something that it’s a little time consuming (say that it’s making an HTTP request inside it), you’re entire program is blocked until it does it’s job. Try messing around in your IDE/Editor and you’ll eventually know how to thing like GO.</li></ul><p>Are we good now? Hell yeah! Next we’re gonna talk about the Function Receivers. Buckle up!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ftenor.com%2Fembed%2F14282082&amp;display_name=Tenor&amp;url=https%3A%2F%2Ftenor.com%2Fview%2Fdancing-group-dance-synchronized-dance-routine-happy-clones-gif-14282082&amp;image=https%3A%2F%2Fc.tenor.com%2FWR2SOqTK-R8AAAAC%2Fdancing-group-dance.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=tenor" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/49ff94a992ee65db0bdc6f71cbaf8d4e/href">https://medium.com/media/49ff94a992ee65db0bdc6f71cbaf8d4e/href</a></iframe><h3>Next:</h3><p>Coming soon…</p><h3>Previous:</h3><p><a href="https://kyxey.medium.com/lets-go-part-11-reference-types-3-maps-849f4e3c91bb">Let’s GO! Part 11: Reference Types 3: Maps</a></p><h3>List Index:</h3><p><a href="https://kyxey.medium.com/lets-go-list-index-2c111b0e74b6">Let’s GO! List Index</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=555c2aad4c28" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Let’s GO! Part 11: Reference Types 3: Maps]]></title>
            <link>https://kyxey.medium.com/lets-go-part-11-reference-types-3-maps-849f4e3c91bb?source=rss-c802af61b692------2</link>
            <guid isPermaLink="false">https://medium.com/p/849f4e3c91bb</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[programming-languages]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[go]]></category>
            <category><![CDATA[golang]]></category>
            <dc:creator><![CDATA[Ali Azizjahan]]></dc:creator>
            <pubDate>Tue, 01 Feb 2022 10:23:36 GMT</pubDate>
            <atom:updated>2022-02-11T10:57:59.735Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*Gne3-uo3IXvOK2Xj6CdtTQ.jpeg" /><figcaption>Hashmaps and Dictionaries?! In GO?!!</figcaption></figure><h3>Overview</h3><p>If you’re already familiar with some other languages like Java or Python, Maps in GO are exactly what we call them Hashmaps or Dictionaries respectively in those languages. They’re basically a key-value pair data structure that both the keys and the values are statically typed.</p><h3>How Do They Work?</h3><p>Exactly like Hashmaps and Dictionaries, Maps in GO are implemented using a <strong>hash table</strong> underneath. Now we’re not gonna go into how the hash tables work in this course. If you don’t know them already, there are pretty good articles out there about them that are only a Google search away from you!</p><p>Exactly like Hashmaps in Java, Maps in GO <strong>are not multi thread safe</strong>. This means if you are willing to write to or read from them in a concurrent manner, you need to implement a synchronization mechanism yourself. You can read more about how to do it safely in this article:</p><p><a href="https://medium.com/@luanrubensf/concurrent-map-access-in-go-a6a733c5ffd1">Concurrent map access in Go</a></p><h3>Code, Sweet Code!</h3><p>First the syntax, which is really simple:</p><pre># First declare a map:<br>myMapName := make(map[KEY_TYPE]VALUE_TYPE)</pre><pre># Then assign key-pair values to it:<br>myMapName[KEY] = VALUE</pre><p>Pretty straightforward, right? Now let’s see it in action:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/50019a5eb6d8560d798f5c50168a1a62/href">https://medium.com/media/50019a5eb6d8560d798f5c50168a1a62/href</a></iframe><p>The output should be:</p><pre>myMap: map[one:1 two:2]<br>oneValue: 1     twoValue: 2<br>myMap after deletion: map[two:2]<br></pre><p>Some important notes:</p><ul><li>You can specify any types for the keys and the values. It’s really up to you and it’s very flexible.</li><li>The time order to search, insert and delete in maps are mostly constant. Meaning that they’ll be done in the most efficient way possible.</li><li>In Maps, unlike arrays and slices, if you iterate through them with a for loop, you’ll get <strong>different orders</strong> of key-value pairs in each iteration. Meaning that you <strong>can’t</strong> put a trust on the order of them.</li><li>In Maps, unlike structs, your keys should not be determined at the build time. You needed to tell GO that which keys your struct will be having when writing it and then you could use features like auto code completion on the key names provided by your IDE/Editor. But in Maps, you only tell GO that the keys will have what type, and then you can even make new keys with the same type at the runtime. Thus the auto code completion on the key names wouldn’t work. So be careful not to encounter errors about specifying wrong key names at runtime.</li></ul><p>This is it! With Maps you’re now very powerful!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ftenor.com%2Fembed%2F8577829&amp;display_name=Tenor&amp;url=https%3A%2F%2Ftenor.com%2Fview%2Fbaby-strong-flex-gif-8577829&amp;image=https%3A%2F%2Fmedia.tenor.com%2FD5numtVEMfIAAAAF%2Fbaby-strong.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=tenor" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/a0d89cdb850bc88eb3272110d4825324/href">https://medium.com/media/a0d89cdb850bc88eb3272110d4825324/href</a></iframe><p>We’ll talk about Channels in the next part. 👀</p><h3>Next:</h3><p><a href="https://kyxey.medium.com/lets-go-part-12-reference-types-4-channels-555c2aad4c28">Let’s GO! Part 12: Reference Types 4: Channels</a></p><h3>Previous:</h3><p><a href="https://kyxey.medium.com/lets-go-part-10-reference-types-2-slices-18224077c1aa">Let’s GO! Part 10: Reference Types 2: Slices</a></p><h3>List Index:</h3><p><a href="https://kyxey.medium.com/lets-go-list-index-2c111b0e74b6">Let’s GO! List Index</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=849f4e3c91bb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Let’s GO! Part 10: Reference Types 2: Slices]]></title>
            <link>https://kyxey.medium.com/lets-go-part-10-reference-types-2-slices-18224077c1aa?source=rss-c802af61b692------2</link>
            <guid isPermaLink="false">https://medium.com/p/18224077c1aa</guid>
            <category><![CDATA[go]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[programming-languages]]></category>
            <category><![CDATA[tutorial]]></category>
            <dc:creator><![CDATA[Ali Azizjahan]]></dc:creator>
            <pubDate>Sat, 29 Jan 2022 20:07:29 GMT</pubDate>
            <atom:updated>2022-02-01T10:25:37.815Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/660/1*B6XBkDnr5hWYxjTMgb8GZw.jpeg" /><figcaption>Swole Gopher (AKA Chad Gopher) because Slices are a really clever type in GO!</figcaption></figure><h3>Overview</h3><p>Slices are a very clever data type that you see in GO. They’re a concept originated in the GO language itself and you won’t find them in any other languages like they are in GO. Thus you might find them slightly hard at the first glance but they’re really easy.</p><h3>Wait A Minute, What Are Them?!</h3><p>Slices are basically simple views on Arrays! Think of them as a middleware class between you and your array which provides some very useful methods on your array, as well as hiding the complexity of working with arrays and providing you a very consistent and easy-to-use API to do things on arrays that weren’t possible in a simple and clean manner before.</p><h3>No! They’re NOT Slower Than Arrays!</h3><p>With the given explanation above, you might think that Slices might be slower than arrays since they’re providing more features than arrays and doing some magic under the hood; but that’s not true. Since the provided methods in Slices are implemented in the most efficient way possible, and since they do some magic when allocating and deallocating memory (which we’ll talk about soon), they’re even faster and more efficient than simple arrays in the most use cases!</p><h3>What Magic?!</h3><p>A Slice has basically 3 different parts. First part is a pointer named ptr. A pointer to an array. Yes! You heard it right! The two other parts are two integers named len and cap which contain the length and the capacity of the Slice respectively. Now, when you create a Slice, basically an array gets created on the disk. A pointer to that specific array is stored inside ptr. The length of the array is stored inside cap and the size of the Slice itself is stored inside len. What is happening here, is that GO tells you Ok don’t worry about anything! You want an array-like structure, you got one. You want to be able to resize it, you got it. You want all the methods to be efficient, you also got it! But how? Since a Slice is a pointer to an array, resizing it is a matter of changing the pointer and the two integers. If you initialize a Slice from an existing array or another Slice, GO will only add a pointer to that array or Slice on the disk. It doesn’t copy the data to a new place on the disk, although it will if you ask it to with the copy function. Now if you modify one of the members of such Slice, surprise surprise, the same member of that array or the other Slice is also modified since they’re all pointing to the same place on the memory. Now since we’re only dealing with pointers and not copy pasting values over new places on the disk, it’s very efficient to work with Slices. And since GO provides built-in functions to deal with Slices, which in all cases they’re dealing with the pointers as well instead of copy pasting values, you have great power added to your array with a simple abstraction called Slice. Everybody’s happy, right?</p><h3>The Difference Between len and cap</h3><p>len is the size of the Slice. It tells you how many elements are inside this Slice. However cap is the size of the array that this Slice points to. These two values are usually the same but sometimes they’re not. Imagine when you’re making a Slice from a range (from an index to another) from your array. That’s when len and cap become different. But in this case cap won’t be the exact size of the underlying array, but the size of the underlying array starting from the element that the range starts from to the end of the array. For reading more about these details, here’s two good articles about Slices:</p><ul><li><a href="https://appliedgo.net/slices/">Go slices are not dynamic arrays - Applied Go</a></li><li><a href="https://go.dev/blog/slices-intro">Go Slices: usage and internals - The Go Programming Language</a></li></ul><h3>Code, Code, COOOOODEEEE!</h3><p>Enough with the long and boring descriptions. Let’s see some code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/15f55e97b325157d2e170e7d7faffd50/href">https://medium.com/media/15f55e97b325157d2e170e7d7faffd50/href</a></iframe><p>The output should be this:</p><pre>myFirstSlice: [1 2 3]<br>myFirstSlice after modification: [5 2 3 10]<br>mySecondSlice: [5 2 3 10]<br>mySecondSlice after modification: [5 2 73 10]<br>myFirstSlice after modifying mySecondSlice: [5 2 3 10]<br>myThirdSlice: [5 2 3 10]<br>myThirdSlice after modification: [5 153 3 10]<br>myFirstSlice after modifying myThirdSlice: [5 153 3 10]<br>Length of mySecondSlice: 4<br>Capacity of mySecondSlice: 4</pre><p>Some important notes about Slices:</p><ul><li>The built-in make function has two implementations: The first one takes 2 arguments (as you already saw in the code). The first argument is the type of your Slice, and the second one is the length of it. This way the capacity of your Slice is equal to the length you specified as the second argument. The second implementation takes 3 arguments. The first 2 arguments are as same as the first implementation, and the third one is the capacity of your Slice. This is useful when you know how much the underlying array of your Slice is going to expand throughout your application. Something a little more professional to keep an eye on the efficiency since if you expand your Slice more than it’s capacity, GO has to allocate a new space on the memory with the needed capacity and copy the data to the new location as well as changing the pointer value. Which you can say it’s somehow expensive.</li><li>Earlier we talked about ranges. If you’re familiar with Python, ranges in GO work as same as they do in Python. On both arrays and Slices, you can get a portion of them like this: Imagine you have a Slice named mySlice that has 6 elements inside it. You want to get the elements from index 2 to index 4 (excluding the index 4 itself). You can basically say it like this: mySlice[2:4]. That will give you a new Slice that contains the third and the fourth elements of mySlice. If you don’t mention the left side of the :, it’ll be considered from the first element of the array or Slice, and if you don’t mention the right side, it’ll be considered until the end of it.</li><li>Same as the arrays, the order of the values stored in Slices are always constant. Meaning that if you try to loop through them with a for loop, which you’ll see later on in the part about loops, you’ll get the same order of the results in each iteration. Thus it’s safe to trust their orders.</li></ul><p>Ok well done! You’re a giga gopher now by knowing Slices!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ftenor.com%2Fembed%2F23352842&amp;display_name=Tenor&amp;url=https%3A%2F%2Ftenor.com%2Fview%2Fgigachad-gif-23352842&amp;image=https%3A%2F%2Fc.tenor.com%2FyPUAJMwL2uwAAAAC%2Fgigachad.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=tenor" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/38724f5c05a08e6993608b5f46ec46f7/href">https://medium.com/media/38724f5c05a08e6993608b5f46ec46f7/href</a></iframe><h3>Next:</h3><p><a href="https://kyxey.medium.com/lets-go-part-11-reference-types-3-maps-849f4e3c91bb">Let’s GO! Part 11: Reference Types 3: Maps</a></p><h3>Previous:</h3><p><a href="https://kyxey.medium.com/lets-go-part-9-reference-types-1-pointers-8ffc5ad69b7e">Let’s GO! Part 9: Reference Types 1: Pointers</a></p><h3>List Index:</h3><p><a href="https://kyxey.medium.com/lets-go-list-index-2c111b0e74b6">Let’s GO! List Index</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=18224077c1aa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Let’s GO! Part 9: Reference Types 1: Pointers]]></title>
            <link>https://kyxey.medium.com/lets-go-part-9-reference-types-1-pointers-8ffc5ad69b7e?source=rss-c802af61b692------2</link>
            <guid isPermaLink="false">https://medium.com/p/8ffc5ad69b7e</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[go]]></category>
            <category><![CDATA[programming-languages]]></category>
            <dc:creator><![CDATA[Ali Azizjahan]]></dc:creator>
            <pubDate>Sat, 25 Dec 2021 19:53:01 GMT</pubDate>
            <atom:updated>2022-01-29T20:08:12.434Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mAsnNy4tIDXu6Sj3JAKb8w.jpeg" /><figcaption>Pointers give you the exact address of the gopher’s hideout</figcaption></figure><p>Reference Types, as the name suggests, are those that are somehow referential. These types are classified as Reference Types in GO:</p><ul><li>Pointers</li><li>Slices</li><li>Maps</li><li>Functions</li><li>Channels</li></ul><p>We’ll be talking about each and every one of them on their own parts.</p><h3>Overview</h3><p>Pointers are simple variables or arguments (if passed to functions) that hold the address of another variable on the memory. If you’re already familiar with C or C++, you might wanna think about pointers in GO as they are in C and C++. Well that is not false but also not true. The main functionality is the same but they’re somehow different.</p><h3>How Pointers Differ in GO from C/C++?</h3><p>Since C and C++ are not automatically garbage collected, it might be a good idea to pass the arguments as pointers in those languages to reduce the overhead of holding the copied values on the memory and prevent memory leaks, and also be faster because the value doesn’t get copied to a new address. But GO is smarter. GO has an automatic garbage collector which only works on the heap. When you pass the variable as it is, it’ll go on the stack which will be pushed and popped only. But if you pass your variable as a pointer to another variable it might go to the heap and may even be slower due the garbage collection process that runs on the heap. Read more about this on <a href="https://medium.com/@meeusdylan/when-to-use-pointers-in-go-44c15fe04eac">this great article</a>.</p><h3>When to Use Pointers?</h3><p>While it’s totally up to you either to use them at all or not, because almost anything that can be done with Pointers can simply be done with simple variables as well and it’s even faster most of the times, but there are some cases that you might want to consider using them:</p><ul><li><strong>Passing large structs.</strong> The overhead of copying large structs might be worse than the overhead of the garbage collector process that runs on the heap. If this is the case, maybe it’s better to use pointers.</li><li><strong>Mutability.</strong> If you pass a variable as it is as an argument to a function, since the value gets copied to a new address, the function will not be able to mutate the original variable directly in it’s body. If you want to mutate the original variable directly inside the body of your function (“But why? Why would you do that? Why would you do any of that?” -JonTron), you have to use pointers instead. Jokes aside, there will be some cases where you want to do that and you’ll see them in the part about Receivers.</li><li><strong>API consistency.</strong> You might want to have an API consistency in your application as some of the Receiver Functions (which you’ll see in the part about Receivers) NEED to get the value by pointer so they can mutate the original value. In this case, having your other Receiver Functions getting their values also as pointers makes your API consistent.</li><li><strong>To signify true absence.</strong> Since the default value of pointers is nil instead of the original default values of the variables (which you saw at <a href="https://kyxey.medium.com/lets-go-part-6-basic-types-5d66208a63c9">Part 6: Basic Types</a>), they’re useful to know if the value is assigned or not. I mean you might assign 0 to a variable of type int and you want to know which variables of this type are assigned the value of 0 and which are 0 by default because no value is assigned to them. In this case using pointers is a good idea. But be careful of the <a href="https://www.infoq.com/presentations/Null-References-The-Billion-Dollar-Mistake-Tony-Hoare/">billion dollar mistake</a>.</li></ul><p>Again, more info about this on <a href="https://medium.com/@meeusdylan/when-to-use-pointers-in-go-44c15fe04eac">this great article</a>.</p><h3>Syntax</h3><p>There are two operators that you need to be aware of before diving into the syntax of Pointers:</p><ul><li><strong>* operator</strong> which is called the <strong>Dereferencing Operator</strong> and it’s used to define pointer variables and access the value stored in the address.</li><li><strong>&amp; operator</strong> which is called the <strong>Address Operator</strong> and it’s used to return the address of a variable or to access the address of a variable to a pointer.</li></ul><p>Lesss gooo:</p><pre># Either the long syntax<br>var myPointerName <strong>*</strong>TYPE<br>myPointerName = <strong>&amp;</strong>myVariableName</pre><pre># Or the shorthand syntax<br>myPointerName := <strong>&amp;</strong>myVariableName</pre><ul><li>The type of your pointer should be as same as the type of the variable that you want your pointer to point to.</li><li>Get the address by the variable’s name with <strong>&amp;</strong> and get the value by the address with <strong>*</strong>.</li></ul><p><strong>IMPORTANT NOTE:</strong> If you log the value of a pointer, you’ll see a hexadecimal number starting with 0x. That number is the address of your variable on the disk. The note here is that you can store hexadecimal numbers even in simple variables in GO. Every number that starts with 0x will be considered a hex number. In the Printf function that comes from the built-in fmt package, if you format your hex variable with %v you’ll get the decimal value of it, whilst if you format it with %X you’ll get the exact hexadecimal value. Try it yourself in your editor.</p><p>Let’s see some code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/10a6b4867e91d8ef6c623628cc1c2eb6/href">https://medium.com/media/10a6b4867e91d8ef6c623628cc1c2eb6/href</a></iframe><p>The output should be:</p><pre>The address of myVar on disk is: [Some hex number starting with 0x]<br>The value that is stored in that address is: 23<br>The address of myVar after mutating should remain the same: [Some hex number starting with 0x]<br>But the value should change to: 25<br>The value of myVar after mutation inside the function&#39;s body: 12</pre><p><strong>Note:</strong> In the above code, the hex number you’ll get from each iteration of the program for the address will be different.</p><p>Yup that’s it! That’s the Pointers! Good job so far. I think it’s too soon to decide either to use pointers at all or not as there are some related things remained to learn that’ll help you decide better while designing the flow of your applications. So just know what the Pointers are and how are they declared for now and we’ll talk about these concepts later on.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iulq1oIEC0reN3oZVPcgJQ.jpeg" /><figcaption>What will happen if you have a pointer that points to another pointer?!</figcaption></figure><p>Let’s learn about the Slices next.</p><h3>Next:</h3><p><a href="https://kyxey.medium.com/lets-go-part-10-reference-types-2-slices-18224077c1aa">Let’s GO! Part 10: Reference Types 2: Slices</a></p><h3>Previous:</h3><p><a href="https://kyxey.medium.com/lets-go-part-8-aggregate-types-2-arrays-d348cb049abc">Let’s GO! Part 8: Aggregate Types 2: Arrays</a></p><h3>List Index:</h3><p><a href="https://kyxey.medium.com/lets-go-list-index-2c111b0e74b6">Let’s GO! List Index</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8ffc5ad69b7e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Let’s GO! List Index]]></title>
            <link>https://kyxey.medium.com/lets-go-list-index-2c111b0e74b6?source=rss-c802af61b692------2</link>
            <guid isPermaLink="false">https://medium.com/p/2c111b0e74b6</guid>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[programming-languages]]></category>
            <category><![CDATA[go]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Ali Azizjahan]]></dc:creator>
            <pubDate>Fri, 24 Dec 2021 18:26:28 GMT</pubDate>
            <atom:updated>2022-02-11T10:57:10.991Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/506/1*zVc7cJcaSpV5pGeupKjQzg.gif" /><figcaption>What? Where?</figcaption></figure><ol><li><a href="https://kyxey.medium.com/lets-go-part-0-introduction-2ed3d021b64c">Let’s GO! Part 0: Introduction</a></li><li><a href="https://kyxey.medium.com/lets-go-part-1-a-word-or-two-about-go-2fe6de772295">Let’s GO! Part 1: A Word or Two About GO</a></li><li><a href="https://kyxey.medium.com/lets-go-part-2-setup-b01359f33563">Let’s GO! Part 2: Setup</a></li><li><a href="https://kyxey.medium.com/lets-go-part-3-hello-world-105128b7d5d3">Let’s GO! Part 3: Hello, world!</a></li><li><a href="https://kyxey.medium.com/lets-go-part-4-variables-and-constants-2e248ed0d40b">Let’s GO! Part 4: Variables and Constants</a></li><li><a href="https://kyxey.medium.com/lets-go-part-5-functions-6db1c36ff3bb">Let’s GO! Part 5: Functions</a></li><li><a href="https://kyxey.medium.com/lets-go-part-6-basic-types-5d66208a63c9">Let’s GO! Part 6: Basic Types</a></li><li><a href="https://kyxey.medium.com/lets-go-part-7-aggregate-types-1-structs-406a7d81c813">Let’s GO! Part 7: Aggregate Types 1: Structs</a></li><li><a href="https://kyxey.medium.com/lets-go-part-8-aggregate-types-2-arrays-d348cb049abc">Let’s GO! Part 8: Aggregate Types 2: Arrays</a></li><li><a href="https://kyxey.medium.com/lets-go-part-9-reference-types-1-pointers-8ffc5ad69b7e">Let’s GO! Part 9: Reference Types 1: Pointers</a></li><li><a href="https://kyxey.medium.com/lets-go-part-10-reference-types-2-slices-18224077c1aa">Let’s GO! Part 10: Reference Types 2: Slices</a></li><li><a href="https://kyxey.medium.com/lets-go-part-11-reference-types-3-maps-849f4e3c91bb">Let’s GO! Part 11: Reference Types 3: Maps</a></li><li><a href="https://kyxey.medium.com/lets-go-part-12-reference-types-4-channels-555c2aad4c28">Let’s GO! Part 12: Reference Types 4: Channels</a></li><li>Coming soon…</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2c111b0e74b6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Let’s GO! Part 8: Aggregate Types 2: Arrays]]></title>
            <link>https://kyxey.medium.com/lets-go-part-8-aggregate-types-2-arrays-d348cb049abc?source=rss-c802af61b692------2</link>
            <guid isPermaLink="false">https://medium.com/p/d348cb049abc</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[programming-languages]]></category>
            <category><![CDATA[go]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[golang]]></category>
            <dc:creator><![CDATA[Ali Azizjahan]]></dc:creator>
            <pubDate>Fri, 24 Dec 2021 17:59:26 GMT</pubDate>
            <atom:updated>2023-04-19T22:57:15.487Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/873/1*jF5ZofDK77-uPNT-t0trOg.jpeg" /><figcaption>Arrays are many gophers of the same type under one name</figcaption></figure><h3>Overview</h3><p>Arrays are basically <strong>different values</strong> from <strong>the same type</strong> that come under <strong>one name</strong>. These are the conceptual differences between Arrays and Structs:</p><ul><li>In Structs your values can have different types while in Arrays they must be from the same type.</li><li>In Structs each value has it’s own name that you can access that specific value with that specific name later on, while in Arrays values only have index numbers and no names.</li><li>In Arrays the order of the stored values is always constant. Meaning that if you try to loop through an array with a for loop, which you will see later on in the part about Loops, in each iteration the order of the values remains the same as the last time. With that said, you can put a trust on their order. However this isn’t a case with structs. The order that the key/value pairs get stored inside a struct, is not easily determined (it depends on how the compiler will decide that the is more efficient.) Thus not trustable, and the order that you define them in your code has no effect on how the compiler will decide in which order to store them.</li></ul><p>Knowing the above info may lead you to think that Arrays are much simpler aggregate types than Structs, and that is true. Let’s see them in action.</p><h3>How to Define and Use Arrays?</h3><p>The syntax is very easy and almost like defining simple variables:</p><pre># Either define the type first and assign it to a variable later on<br>type MyArrayTypeName [ARRAY_SIZE]TYPE<br>var MyArrayName MyArrayTypeName<br>MyArrayName[INDEX] = VALUE<br>...</pre><pre># Or define the type when initializing the variable itself<br>var MyArrayName [ARRAY_SIZE]TYPE<br>...</pre><p>In the above syntax:</p><ul><li>ARRAY_SIZE is the size of your array that should be determined while defining your array’s type.</li><li>TYPE can be any types that exist in GO. Even functions type!</li><li>INDEX is the index number of the value starting from 0.</li></ul><p>Let me show you some code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/acd09978566fd737f8179e4f29466cdd/href">https://medium.com/media/acd09978566fd737f8179e4f29466cdd/href</a></iframe><p>The output should be:</p><pre>The third value of mySecondArray: 1<br>myFirstArray: [10 3 89 54 4378]<br>mySecondArray: [23 34 1 832 33]<br>myThirdArray: [Ali Gopher You Let&#39;s GO!]<br>myFourthArray: [false true true]<br>myThirdArray after mutation: [KYXEY Gopher You Let&#39;s GO!]<br>myFourthArray after mutation: [true false false]</pre><p><strong>Note 1:</strong> Arrays are mutable. Only their <strong>size</strong> and <strong>type</strong> are <strong>not mutable</strong>.</p><p><strong>Note 2:</strong> Arrays in GO can be multidimensional. But like the first dimension, the other dimensions should have a determined length as well when defining. Also the type of the elements of the other dimensions is as exact as the first dimension. For example, for defining a simple 3 dimensional array of integers, you can simply say var myArray [SIZE_OF_FIRST_DIM][SIZE_OF_SECOND_DIM][SIZE_OF_THIRD_DIM]int. This is basically an array of arrays of arrays.</p><p>Alright all done! That’s it for the Aggregate Types in GO. Let’s see a cute gopher gif together:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*3QmnUz35v4QCWnJGUPEmpw.gif" /><figcaption>IT HAS A SKIRT OMG!!</figcaption></figure><p>We’ll talk about the Reference Types in the next few parts.</p><h3>Next:</h3><p><a href="https://kyxey.medium.com/lets-go-part-9-reference-types-1-pointers-8ffc5ad69b7e">Let’s GO! Part 9: Reference Types 1: Pointers</a></p><h3>Previous:</h3><p><a href="https://kyxey.medium.com/lets-go-part-7-aggregate-types-1-structs-406a7d81c813">Let’s GO! Part 7: Aggregate Types 1: Structs</a></p><h3>List Index:</h3><p><a href="https://kyxey.medium.com/lets-go-list-index-2c111b0e74b6">Let’s GO! List Index</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d348cb049abc" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>