<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Alper Yazar</title>
    <description>The latest articles on DEV Community by Alper Yazar (@ayazar).</description>
    <link>https://dev.to/ayazar</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F952111%2F613e593e-c641-45a8-a976-18d03003f3ea.jpeg</url>
      <title>DEV Community: Alper Yazar</title>
      <link>https://dev.to/ayazar</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ayazar"/>
    <language>en</language>
    <item>
      <title>Why do we have programming languages in the first place? Part 1</title>
      <dc:creator>Alper Yazar</dc:creator>
      <pubDate>Fri, 29 Mar 2024 23:16:01 +0000</pubDate>
      <link>https://dev.to/ayazar/why-do-we-have-programming-languages-in-the-first-place-part-1-cjp</link>
      <guid>https://dev.to/ayazar/why-do-we-have-programming-languages-in-the-first-place-part-1-cjp</guid>
      <description>&lt;p&gt;In this two-part mini-series, I will share my understanding and thoughts on programming languages and computers in general. This first part will cover:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Types of processors&lt;/li&gt;
&lt;li&gt;The language bridging us and processors&lt;/li&gt;
&lt;li&gt;Key terms such as &lt;strong&gt;instruction set, instruction set architecture (ISA), machine
code, assembly language&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We have at least 500 programming languages in existence today. &lt;sup id="fnref1"&gt;1&lt;/sup&gt; But why do we continue to invent them? Let's talk! But first:&lt;/p&gt;

&lt;h2&gt;
  
  
  Why do computers exist in the first place? 💻
&lt;/h2&gt;

&lt;p&gt;Computers are expensive and require extensive engineering effort to develop. As individuals, we invest hundreds of dollars 💲 each year in our personal computers, including laptops, gaming consoles, mobile phones, desktops, and more. &lt;strong&gt;But why?&lt;/strong&gt; They must serve a purpose, correct? Indeed. Actually, each of these computers addresses a specific problem we encounter. Computers can perform complex mathematical computations, facilitate aircraft landings, entertain us, enable over-the-air communication, and even contribute to the discovery of planets in space! But how do they accomplish these tasks? &lt;strong&gt;What is the magic behind their functionality?&lt;/strong&gt;&lt;/p&gt;




&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpo4yj84c3dxmzlxxhz9g.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpo4yj84c3dxmzlxxhz9g.jpg" alt="ENIAC" width="628" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://en.wikipedia.org/wiki/ENIAC"&gt;ENIAC&lt;/a&gt;, &lt;strong&gt;designed in 1945&lt;/strong&gt; to solve military-related problems, stands as one of the earliest computers (The whole thing in the room is a single computer. Power consumption was &lt;strong&gt;higher than 150 kW&lt;/strong&gt;). With a cost exceeding &lt;strong&gt;6 million US Dollars&lt;/strong&gt; (adjusted for inflation), it was capable of performing only &lt;strong&gt;5000 operations per second&lt;/strong&gt;—a figure that may seem modest compared to today's standards but still exceeded human capacity at the time. &lt;a href="https://commons.wikimedia.org/wiki/File:Classic_shot_of_the_ENIAC.jpg"&gt;The Photo&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;The magic lies in the ability to &lt;strong&gt;leverage information&lt;/strong&gt; to accomplish these tasks. Computers possess &lt;strong&gt;memory&lt;/strong&gt; to &lt;strong&gt;store&lt;/strong&gt; information and fast &lt;strong&gt;communication&lt;/strong&gt; links to facilitate the exchange of data. Ultimately, the crux of computer functionality revolves around the generation and processing of information.&lt;/p&gt;

&lt;p&gt;Computers are incredible inventions created by smart people, but there's no actual magic involved. They work because they've been carefully designed and engineered. If you want to experience something truly magical, consider exploring the wonders of nature through the study of natural sciences. 🪄&lt;/p&gt;

&lt;p&gt;Nearly all problems solved by computers boil down to mathematical problems. Computers excel with numbers, capable of executing algorithms on data orders of magnitude faster than a human could. &lt;strong&gt;But how do they achieve this?&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Processors
&lt;/h2&gt;

&lt;p&gt;Processors serve as the heart ❤️ of computers (or brains 🧠, whatever organ you choose). A processor is an electronic hardware component capable of manipulating numbers at an incredibly high speed. While processors themselves can't store data, they "process" (hence their name) the stored data, such as in RAM, and generate new data. They can achieve this at rates of billions of operations per second. Examples of processors include the &lt;strong&gt;CPU&lt;/strong&gt; (Central &lt;strong&gt;Process&lt;/strong&gt;ing Unit), &lt;strong&gt;GPU&lt;/strong&gt; (Graphics &lt;strong&gt;Process&lt;/strong&gt;ing Unit), and &lt;strong&gt;TPU&lt;/strong&gt; (Tensor &lt;strong&gt;Process&lt;/strong&gt;ing Unit).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;CPU&lt;/strong&gt;s, or &lt;strong&gt;Central Processing Units&lt;/strong&gt;, are general-purpose processors found in nearly all computers and many electronic devices. They are designed to handle a wide range of tasks, such as text editing, web surfing, and number crunching, typical of personal computers. Unlike specialized processors optimized for specific tasks, CPUs are not tailored to excel in any single function but rather are engineered to efficiently handle a variety of tasks.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi5zj9umcf2k33asy7ruh.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi5zj9umcf2k33asy7ruh.jpg" alt="6502" width="790" height="287"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://en.wikipedia.org/wiki/MOS_Technology_6502"&gt;MOS Technology 6502&lt;/a&gt; is a highly renowned microprocessor introduced in 1975, widely utilized in numerous microcomputers and video game consoles during the 1980s era. Capable of executing 1-2 million operations per second, it represented a significant leap in computing power compared to the 5000 operations per second capability of the ENIAC, which was designed in 1945. Despite its enhanced performance, the price of the 6502 remains relatively affordable, around $150 today when adjusted for inflation (originally $25 in 1975). &lt;a href="https://en.wikipedia.org/wiki/File:MOS_6502AD_4585_top.jpg"&gt;Photo&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;GPU&lt;/strong&gt;s, or &lt;strong&gt;Graphics Processing Units&lt;/strong&gt;, differ from CPUs. While they are also processors, their internal architecture is specifically optimized to efficiently handle calculations required for graphical tasks. GPUs excel in processing graphical data by leveraging parallel computing, utilizing thousands of multiple processors designed to execute tasks simultaneously. Because neural network problems share a similar parallel nature to graphics tasks, GPUs are increasingly being utilized not only for graphical applications but also for solving AI problems. Nonetheless, they remain processors at their core.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd1funepeo0fa0a3d2agk.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd1funepeo0fa0a3d2agk.jpg" alt="RTX 4090" width="726" height="375"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The modern GPU card, Nvidia's RTX 4090, released in 2022 for approximately $1600, boasts impressive capabilities. With its &lt;a href="https://en.wikipedia.org/wiki/GeForce_40_series"&gt;GeForce 40 series GPU&lt;/a&gt;, it can perform 73,000 billion single-precision floating-point operations per second while operating under 450W. &lt;a href="https://en.wikipedia.org/wiki/File:NVIDIA_RTX_4090.jpg"&gt;Photo&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;TPU&lt;/strong&gt;s, or &lt;strong&gt;Tensor Processing Units&lt;/strong&gt;, are custom processors specifically designed for neural network applications. Developed by Google, &lt;a href="https://en.wikipedia.org/wiki/Tensor_Processing_Unit"&gt;TPU&lt;/a&gt;s are engineered to perform the mathematical operations necessary for neural network tasks more efficiently than GPUs. Unlike GPUs, TPUs are tailored solely for optimizing the performance of neural network computations.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbj84r6p6do2cfu6oolpr.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbj84r6p6do2cfu6oolpr.jpg" alt="TPU" width="640" height="456"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Photo of TPUv3 processors. We can't see them directly because they are under heatsinks. TPUv4 announced in 2021 is capable of doing 275,000 billion operations per second while operating under 170W. &lt;a href="https://en.wikipedia.org/wiki/File:Tensor_Processing_Unit_3.0.jpg"&gt;Photo&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Microcontroller&lt;/strong&gt;s, MCUs, present in nearly all electronic devices, also contain processors within them. In general, these processors are specifically designed to handle tasks that are not computationally intensive. However, certain microcontrollers are engineered to execute tasks with minimal power consumption, enabling devices to operate for years a single battery.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff2cb3yv3yshhciwz1b0q.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff2cb3yv3yshhciwz1b0q.jpg" alt="PIC" width="425" height="425"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A &lt;a href="https://en.wikipedia.org/wiki/PIC_microcontrollers"&gt;PIC&lt;/a&gt; microcontroller from &lt;a href="https://en.wikipedia.org/wiki/Microchip_Technology"&gt;Microchip Technology&lt;/a&gt;. &lt;a href="https://commons.wikimedia.org/wiki/File:PIC18F8720.jpg"&gt;Photo&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;As evident, there exist numerous types of processors, beyond the examples provided, each tailored for specific purposes. Various companies are involved in the design and manufacturing of these processors. For instance, Intel and AMD are renowned for their CPUs, while Nvidia specializes in GPUs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;However, regardless of the type or manufacturer, all these processors fundamentally operate in a similar manner. The process of utilizing or programming them has remained essentially the same for decades, spanning across a wide range of processors.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Talking with Processors
&lt;/h2&gt;

&lt;p&gt;Now that we've grasped the importance of the processor in a computer system, whether it's a CPU, GPU, TPU, or any other variant, let's delve into its primary functions. Broadly speaking, a processor performs two types of tasks: &lt;strong&gt;arithmetic operations&lt;/strong&gt;, which involve mathematical computations like addition, multiplication, and division, and &lt;strong&gt;logical operations&lt;/strong&gt;, which entail making decisions based on conditions—for instance, determining if number &lt;code&gt;A&lt;/code&gt; is greater than &lt;code&gt;B&lt;/code&gt; and taking appropriate actions accordingly. But how exactly do we communicate with a processor to get our tasks done?&lt;/p&gt;

&lt;p&gt;Let's imagine that I've purchased an &lt;a href="https://www.amd.com/en/products/apu/amd-ryzen-7-8700g"&gt;AMD Ryzen 7 8700G&lt;/a&gt; CPU from a computer store. This CPU, designed by AMD and released in early 2024, is capable of performing billions of operations per second, which is quite impressive. Now, let's say I simply want to add two numbers together and obtain the result. How can I communicate this task to the CPU? How do I tell the CPU, &lt;strong&gt;"Hey, here are two numbers. Please add them together and return the result to me?"&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx0rimr91x4kp2g5r5796.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx0rimr91x4kp2g5r5796.jpg" alt="AMD Ryzen 7 8700G" width="452" height="390"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;AMD Ryzen 7 8700G. Photo by &lt;a href="https://www.tomshardware.com/pc-components/cpus/amd-ryzen-7-8700g-cpu-review"&gt;Tom's Hardware.&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;As we've observed, there is a wide array of processors available today, each tailored to different applications with various optimizations such as power consumption and speed. Over the past 80 years, these processors have undergone dramatic changes in size, performance, and price. Comparing the computational power of a modern basic cell phone to that of the &lt;a href="https://en.wikipedia.org/wiki/Apollo_Guidance_Computer"&gt;Apollo Guidance Computer&lt;/a&gt;, for example, would be practically meaningless. However, with all these historical advancements and variations, one fundamental aspect remains nearly unchanged: &lt;strong&gt;the basic operational principle of a processor.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Processors are essentially devices designed to execute tasks, functioning as an &lt;em&gt;execution engine&lt;/em&gt; of sorts. Regardless of their processing power, a processor simply carries out the instructions it is given—no more, no less. We provide a list of commands, or &lt;strong&gt;instruction&lt;/strong&gt;s, to a processor, and it executes them one by one. Each instruction tells the processor precisely what action to take. A computer program essentially consists of an ordered set of instructions for the processor to follow. These instructions are stored in memory, typically RAM, and can be accessed by the processor. The processor then begins executing these instructions sequentially, from start to finish. Below is an illustration of how a program appears in memory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Instruction 001: Do this
Instruction 002: Do that
Instruction 003: If A &amp;lt; N, do this otherwise do that
...
Instruction 875: Do this
Instruction 876: End
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you may have noticed, for a processor to be capable of performing useful tasks, it needs to support more than just one instruction. A processor that can only add two numbers together without any additional functionality wouldn't be very practical, would it? Therefore, processors are designed to support a wide range of instructions, and the set of instructions supported by a processor is called its &lt;strong&gt;Instruction Set&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;If you're interested in this topic, you may have come across two terms: &lt;strong&gt;RISC&lt;/strong&gt; and &lt;strong&gt;CISC&lt;/strong&gt;. In these terms, &lt;code&gt;IS&lt;/code&gt; in the middle stands for &lt;strong&gt;I&lt;/strong&gt;nstruction &lt;strong&gt;S&lt;/strong&gt;et. RISC stands for &lt;strong&gt;R&lt;/strong&gt;educed &lt;strong&gt;I&lt;/strong&gt;nstruction &lt;strong&gt;S&lt;/strong&gt;et &lt;strong&gt;C&lt;/strong&gt;omputer, while CISC stands for &lt;strong&gt;C&lt;/strong&gt;omplex &lt;strong&gt;I&lt;/strong&gt;nstruction &lt;strong&gt;S&lt;/strong&gt;et &lt;strong&gt;C&lt;/strong&gt;omputer. Anyway, let's proceed with our exploration: talking with processors.&lt;/p&gt;




&lt;p&gt;Let's delve into instructions in more detail. As mentioned earlier, instructions are stored in memory and are accessible by the processor. Computers operate using numbers, &lt;a href="https://en.wikipedia.org/wiki/Binary_number"&gt;binary numbers&lt;/a&gt; most of the time, which consist of 0s and 1s. This applies to both memory and processors. Each instruction communicates to the processor what action to take. To efficiently store these commands in memory, each command is encoded with a number. For instance, for a specific processor, reading a "01" from memory might indicate an addition operation, "10" for subtraction, "11" for comparison, and so on. In a moment, I'll provide a real-life example from a processor to illustrate this further. Stay tuned!&lt;/p&gt;

&lt;h3&gt;
  
  
  Example: PIC16F84
&lt;/h3&gt;

&lt;p&gt;Let's examine a real-life example. To maintain simplicity and focus on the topic without getting distracted by advanced features implemented by a processor, I've chosen an old microcontroller from Microchip Technology: the &lt;a href="https://www.microchip.com/en-us/product/pic16f84"&gt;PIC16F84&lt;/a&gt;. This microcontroller holds a special significance for me because it was the first microcontroller I programmed when I began experimenting with hobby electronics in high school.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0xxvfhz6r1ultbenmafr.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0xxvfhz6r1ultbenmafr.jpg" alt="PIC 16C84" width="621" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://en.wikipedia.org/wiki/PIC16x84"&gt;PIC16C84&lt;/a&gt; is an older version of PIC16F84. It was introduced in 1993. &lt;a href="https://commons.wikimedia.org/wiki/File:Two_Microchip_PIC16C84_chips.jpg"&gt;Photo&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The datasheet of the PIC16F84 microcontroller is available on the &lt;a href="https://ww1.microchip.com/downloads/aemDocuments/documents/MCU08/ProductDocuments/DataSheets/30430D.pdf"&gt;manufacturer's website.&lt;/a&gt; Let's navigate to the "Instruction Set Summary" section, located on page 55, to gain insight into the instructions supported by this microcontroller.&lt;/p&gt;

&lt;p&gt;This microcontroller consists of a CPU and an internal memory to store instructions that will be executed sequentially by the CPU. However, the memory structure is somewhat unusual because each row has a width of &lt;strong&gt;14 bits.&lt;/strong&gt; Typically, we are familiar with memories with widths that are multiples of 8 bits, such as 8, 16, or 32 bits. Nevertheless, there's nothing inherently wrong with having a memory width of 14 bits. We can visualize the memory as follows:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5pspnmg1006zc39pa1vl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5pspnmg1006zc39pa1vl.png" alt="PIC 16F84 Memory" width="384" height="532"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Note that each row is filled with random 14-bit data just for illustrative purposes.&lt;/p&gt;

&lt;p&gt;The internal program memory of the PIC16F84 is capable of holding 1024 instructions, each with a width of 14 bits.&lt;/p&gt;

&lt;p&gt;On the same page, page 55, the instruction format is illustrated as follows:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdxz985htuaj341rxlcb6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdxz985htuaj341rxlcb6.png" alt="PIC16F84 Instruction Format" width="390" height="571"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;PIC16F84 Instruction Format&lt;/p&gt;

&lt;p&gt;The first notable aspect is that this particular processor can interpret four different instruction formats. Depending on the instruction category, each bit in the 14-bit word carries a distinct significance. Every instruction includes a common field known as &lt;strong&gt;OPCODE&lt;/strong&gt;. All instructions supported by the processor are assigned a unique number, referred to as the OPCODE. The remaining bits may be interpreted differently by the processor based on the instruction, i.e., the OPCODE.&lt;/p&gt;

&lt;p&gt;On the next page in the datasheet, Table 9-2 lists all instructions, i.e., the &lt;strong&gt;Instruction Set&lt;/strong&gt;, along with their corresponding OPCODEs.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd2j0dwdz6b78sil2y2xw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd2j0dwdz6b78sil2y2xw.png" alt="PIC16F84 All Instructions" width="665" height="782"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;All instructions supported by PIC16F84&lt;/p&gt;

&lt;p&gt;The PIC16F84 supports 35 distinct instructions. For humans, it is not practical to memorize the bit patterns for all instructions. Therefore, each instruction is assigned a &lt;em&gt;nickname&lt;/em&gt; called a &lt;strong&gt;mnemonic.&lt;/strong&gt; In this context, a mnemonic is the term for the instruction name.&lt;/p&gt;

&lt;p&gt;Some instructions, like &lt;code&gt;SLEEP&lt;/code&gt;, don't require any additional information from the programmer. However, many instructions do need additional information to operate. For instance, &lt;code&gt;CLRF&lt;/code&gt; is used to fill a memory location with all 0s. However, we have to provide the address of the location, otherwise &lt;code&gt;CLRF&lt;/code&gt; won't know which memory location to clear. These additional parameters given with instruction names are called &lt;strong&gt;operands&lt;/strong&gt; in this context.&lt;/p&gt;

&lt;p&gt;To delve deeper into the subject, let's analyze an instruction thoroughly. Let's consider the &lt;code&gt;ANDLW&lt;/code&gt; instruction. The detailed explanation is provided on page 57 of the datasheet as follows:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8ott125tz6hhp8wxgt2m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8ott125tz6hhp8wxgt2m.png" alt="ANDLW" width="540" height="627"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The first 6-bit value, &lt;code&gt;111001&lt;/code&gt;, represents the OPCODE of this instruction. The remaining 8 bits constitute the single operand required for the instruction. Essentially, the &lt;code&gt;ANDLW&lt;/code&gt; instruction performs a logical AND operation between the content of the &lt;code&gt;W&lt;/code&gt; register and the constant value encoded in the 8-bit operand field. The result is then stored back into the &lt;code&gt;W&lt;/code&gt; register.&lt;/p&gt;

&lt;p&gt;Note that the &lt;code&gt;W&lt;/code&gt; register is a special storage area found in the processor of this microcontroller. This name is specific to this processor, and other processors may have a different number of registers with different names. Therefore, don't worry too much about this naming convention—it's unique to this particular microcontroller.&lt;/p&gt;

&lt;p&gt;The processor in the microcontroller essentially reads 14-bit wide instructions from the program memory, row by row. Let's say the processor reads the value &lt;code&gt;11100100010010&lt;/code&gt;. When we split this value, we have &lt;code&gt;111001&lt;/code&gt; concatenated with &lt;code&gt;00010010&lt;/code&gt;. This represents the &lt;code&gt;ANDLW&lt;/code&gt; instruction with an operand value of 0x12 (in hexadecimal, 18 in decimal). When the processor reads this particular 14-bit value, it performs a logical AND operation between the value stored in the &lt;code&gt;W&lt;/code&gt; register and 0x12, and then writes the result back to the &lt;code&gt;W&lt;/code&gt; register.&lt;/p&gt;

&lt;p&gt;The program memory could be like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;14-bit wide instruction&amp;gt;
&amp;lt;14-bit wide instruction&amp;gt;
...
11100100010010 -&amp;gt; ANDLW 0x12
...
&amp;lt;14-bit wide instruction&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you continue reading the remaining part of the datasheet, you'll notice that each instruction is explained in detail. Similarly, all processors have similar documents that explain each instruction and its effects on the state of the processor (such as registers).&lt;/p&gt;

&lt;p&gt;The set of instructions + the architecture that behaves according to those instructions is referred to as the &lt;strong&gt;Instruction Set Architecture (ISA)&lt;/strong&gt;.&lt;/p&gt;




&lt;p&gt;In summary, processors only understand instructions, often accompanied by operands. To achieve meaningful outcomes, programmers must provide instructions in a logical order. Processors lack awareness of the tasks they are performing (such as calculating the Fibonacci Sequence); it is the programmer's responsibility to ensure that the set of instructions executed by the processor yields a meaningful result. This result may be stored in main memory, such as RAM. Importantly, &lt;strong&gt;processors do not understand programming languages like JavaScript, Python, or C.&lt;/strong&gt; They can only execute instructions stored in memory, supported by their own ISA, one by one, without deviation.&lt;/p&gt;

&lt;h2&gt;
  
  
  ISA: The Contract
&lt;/h2&gt;

&lt;p&gt;Commonly, ISA is defined as the contract between software and hardware. Considering ISA as an agreement between hardware and software people is a very apt representation. Let's explore why.&lt;/p&gt;

&lt;p&gt;In the previous example, we explored the ISA implemented by Microchip company in the PIC16F84 microcontroller. However, we didn’t delve into the internals of the processor. We don’t know how Microchip uses flip-flops and transistors to build the processor. We don’t know how the logical AND operation is implemented at the transistor level, and &lt;strong&gt;we don’t need to!&lt;/strong&gt; The only thing we need to utilize a processor designed by a company is the details explained in the ISA.&lt;/p&gt;

&lt;p&gt;The concept of &lt;strong&gt;ISA is similar to API (Application Programming Interface)&lt;/strong&gt; in the software world. As programmers who are willing to utilize existing processors, rather than design them, we only need to know how to use them, not their internal structure. As long as processor manufacturers adhere to the rules defined in the corresponding ISA, they are free to design whatever circuit they like, and programmers won't notice any difference.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffb7kktxpme4mk9qk8p85.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffb7kktxpme4mk9qk8p85.png" alt="ISA" width="159" height="280"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;ISA is the contract between software and hardware. Taken from &lt;a href="https://people.inf.ethz.ch/omutlu/"&gt;Onur Mutlu&lt;/a&gt;'s lecture slides.&lt;/p&gt;

&lt;p&gt;Processor design companies, also known as hardware companies, have the flexibility to design processors with vastly different internal architectures while still supporting exactly the same ISA. These differences in internal structures can result in the design of processors that are more power-efficient, faster, or cheaper.&lt;/p&gt;

&lt;p&gt;The contrast between two processors supporting the same ISA can be significant. One processor may be widely adopted and used in numerous systems, while the other may not be used at all, potentially leading to financial crises within a company.&lt;/p&gt;

&lt;p&gt;In summary, the metrics of two processors can be dramatically opposite, even if they implement the same ISA.&lt;/p&gt;

&lt;h2&gt;
  
  
  ISA: Bad and Good News
&lt;/h2&gt;

&lt;p&gt;Okay, we understand that in order to utilize a processor and write programs that perform valuable tasks, we have to study the ISA of the processor and program it accordingly. &lt;strong&gt;But how many ISAs are currently in use?&lt;/strong&gt; Can we talk about a &lt;strong&gt;universal ISA&lt;/strong&gt; that all processors support, so we as programmers can learn one ISA to work with all processors?&lt;/p&gt;

&lt;p&gt;The bad news is that there is not just one ISA, I'm afraid. Since the inception of the first electronic processors, companies began developing their own ISAs. Therefore, we can't talk about a universal ISA. However, the good news is that processors are grouped together in such a way that a group of processors implements the same ISA. So, the number of ISAs is less than the number of designed processors.&lt;/p&gt;

&lt;p&gt;For example, as programmers, we don't need to learn a different ISA for each CPU designed by Intel; fortunately, they share a common ISA base.&lt;/p&gt;

&lt;p&gt;The term &lt;strong&gt;architecture&lt;/strong&gt; commonly refers to the ISA implemented by a processor. From a CPU standpoint, common architectures (ISAs) include &lt;strong&gt;ARM (v7, v8, v9...), x86, x86-64, MIPS, RISC-V,&lt;/strong&gt; etc. For example, there are multiple processor design companies designing ARM CPUs. From a programmer's viewpoint, instructions suitable for the ARMv7 ISA, for instance, can be executed on CPUs from both companies.&lt;/p&gt;

&lt;p&gt;Today, many architectures (ISAs) have "plugin" capabilities. While maintaining the base instructions as a minimum requirement, a vendor may implement additional instructions. These additional instructions are often referred to as &lt;strong&gt;extensions.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For example, ARM has SVE (Scalable Vector Extension) to implement fast vector-based operations. If a program uses these kinds of extensions, these instructions won't work on a similar processor lacking that extension.&lt;/p&gt;

&lt;h2&gt;
  
  
  Putting Instructions into The Memory
&lt;/h2&gt;

&lt;p&gt;Until now, we've assumed that instructions executed by the processor are available in the memory somehow. &lt;strong&gt;But how do we actually put those instructions into memory?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In today's computers, when we double-click an application, the instructions for the application are loaded into memory by the operating system (OS). We don't even think about the process of reading instructions from disk and putting them into memory (RAM) and letting the CPU run the instructions. However, this process wasn't as trivial in the old days as it is today.&lt;/p&gt;

&lt;p&gt;Many old computers lacked an operating system to read instructions from storage and load them into memory. Some had operating systems available, but the cost of operating systems or computers capable of running them was prohibitively high, so people often didn't choose those systems. Additionally, storing programs on paper (punch cards) could be cheaper than storing them on hard disks. Since this subject is beyond the scope of this post, I won't go into details, but if you're interested, I recommend watching the following video:&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/nwDq4adJwzM"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=nwDq4adJwzM"&gt;The video&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;and&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/KG2M4ttzBnY"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=KG2M4ttzBnY"&gt;The video&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Altair 8800
&lt;/h3&gt;

&lt;p&gt;As an example, I would like to talk about the Altair 8800. According to many resources, it is considered the first personal (micro)computer. &lt;sup id="fnref2"&gt;2&lt;/sup&gt; It features an Intel 8080 processor and was designed by MITS in 1974. The Altair 8800 played a significant role in the history of Microsoft and Apple.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4u5d4q3rhwu64xf7azr0.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4u5d4q3rhwu64xf7azr0.jpg" alt="Altair 8800" width="800" height="721"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://commons.wikimedia.org/wiki/File:Altair_8800_Computer.jpg"&gt;Altair 8800&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Did you notice something? This computer doesn't have a keyboard, mouse, or screen! How are you supposed to program it? Well, you would use the front panel, which consists of a bunch of switches and LEDs, and perform something called &lt;strong&gt;Front Panel Programming.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuubmq9gpmnr9ykcle2yn.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuubmq9gpmnr9ykcle2yn.jpg" alt="Altair 8800 Front Panel" width="800" height="339"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://commons.wikimedia.org/wiki/File:MITS_Altair_8800_Front_Panel.jpg"&gt;Altair 8800 Front Panel&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;By toggling switches, a programmer inputs 0s and 1s into the memory, which are then read by the processor. After inputting all instructions one by one and hitting the &lt;code&gt;RUN&lt;/code&gt; button, the processor executes the instructions stored in the memory. After running all instructions, the results can be read back by toggling switches and observing LEDs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;This is how a "real programmer" operates a computer!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/cwEmnfy2BhI"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=cwEmnfy2BhI"&gt;The video&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;and&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/7nDcTRqZu8E"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=7nDcTRqZu8E"&gt;The video&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Machine Language
&lt;/h2&gt;

&lt;p&gt;As you can see, we communicate with computers via instructions given in the corresponding ISA. The instruction set resembles a dictionary for a language that a processor can understand. This language, which a processor can understand or "speak," is called &lt;strong&gt;machine language.&lt;/strong&gt; Communicating with a processor, or with a more technical term, programming it with raw instructions using 0s and 1s, is called &lt;strong&gt;machine language programming.&lt;/strong&gt; Programming a computer with 0s and 1s directly is the lowest level of programming possible. Machine language is also known as &lt;strong&gt;machine code.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In programming terminology, we have &lt;strong&gt;low-level&lt;/strong&gt; and &lt;strong&gt;high-level&lt;/strong&gt; languages. Low-level languages are closer to the machine than to a human. On the other hand, high-level languages are more suitable for humans; they resemble natural human language more than machine language.&lt;/p&gt;

&lt;p&gt;Clearly, programs written with 0s and 1s are very close to machines but not to humans. However, this is what computers or processors understand: 0s and 1s.&lt;/p&gt;

&lt;h2&gt;
  
  
  Assembly: The First Step Towards to Programming Languages
&lt;/h2&gt;

&lt;p&gt;Although programming a computer with machine language is a natural way of programming from the perspective of a processor or computer, understanding a bunch of 0s and 1s put together isn't an easy task for a human. A programmer needs to communicate with colleagues, review code, and so on. However, trying to understand 0s and 1s and writing programs with them is error-prone and a very time-consuming task.&lt;/p&gt;

&lt;p&gt;So instead of writing programs in 0s and 1s, why can't we write them in a more human-readable way and then convert them to 0s and 1s that a processor can understand? This is exactly how &lt;strong&gt;assembly languages&lt;/strong&gt; work!&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;🤔 Trivia: It is believed that the first assembler program was developed for a British computer known as EDSAC in 1949. &lt;sup id="fnref3"&gt;3&lt;/sup&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If you remember, we defined two terms with the PIC16F84 example: &lt;em&gt;mnemonic&lt;/em&gt; and &lt;em&gt;operand.&lt;/em&gt; Instead of writing raw 0s and 1s, we can write instructions using "nicknames" of instructions like &lt;code&gt;ADD&lt;/code&gt;, &lt;code&gt;SUB&lt;/code&gt;, &lt;code&gt;GOTO&lt;/code&gt;, &lt;code&gt;CLRF&lt;/code&gt;, etc. Then, a computer program called an &lt;strong&gt;assembler&lt;/strong&gt; converts those words into 0s and 1s that a particular CPU can understand. Programmers can interpret words like &lt;code&gt;ADD&lt;/code&gt; more easily than &lt;code&gt;000100101&lt;/code&gt;, right?&lt;/p&gt;

&lt;p&gt;An assembler serves a broader purpose beyond simply translating words into 0s and 1s. I'll delve deeper into this concept with an explanation using a specific assembly program designed for the &lt;a href="https://www.microchip.com/en-us/product/pic16f628"&gt;PIC16F628&lt;/a&gt;, a well-known microcontroller from Microchip.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CNTR1 EQU H'20'
CNTR2 EQU H'21'

  CLRF    PORTB ; Clear PORTB
  BANKSEL TRISB
  CLRF    TRISB
  BANKSEL PORTB
LOOP
  MOVLW h'00'
  MOVWF PORTB
  CALL  DELAY
  MOVLW h'FF'
  MOVWF PORTB
  CALL  DELAY
  GOTO  LOOP
DELAY
  MOVLW h'FF'
  MOVWF CNTR1
LOOP1
  MOVLW h'FF'
  MOVWF CNTR2
LOOP2
  DECFSZ CNTR2, F
  GOTO   LOOP2
  DECFSZ CNTR1, F
  GOTO   LOOP1
  RETURN
  END
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This code doesn't accomplish anything particularly useful; it simply sets some registers and then loops through two nested loops. However, the intention here is to illustrate the structure of an assembly language program.&lt;/p&gt;

&lt;p&gt;Most of the lines in the program correspond to a single instruction for the processor, such as &lt;code&gt;MOVLW&lt;/code&gt;, &lt;code&gt;MOVWF&lt;/code&gt;, and &lt;code&gt;CALL&lt;/code&gt;. Some of them are included for the sake of simplicity in creating assembly programs.&lt;/p&gt;

&lt;p&gt;For example, &lt;code&gt;CNTR1 EQU H'20'&lt;/code&gt; creates a substitution word &lt;code&gt;CNTR1&lt;/code&gt;, which will be replaced by &lt;code&gt;0x20&lt;/code&gt; when the assembler converts the program into 0s and 1s that the processor can understand. This functionality is very similar to the &lt;code&gt;#define CNTR1 0x20&lt;/code&gt; preprocessor directive in C. The same concept applies to &lt;code&gt;CNTR2&lt;/code&gt;, &lt;code&gt;PORTB&lt;/code&gt;, and &lt;code&gt;TRISB&lt;/code&gt;. This feature of the assembler simplifies modifications to the program. Instead of writing &lt;code&gt;0x20&lt;/code&gt; everywhere and then performing a search-and-replace, one can easily change &lt;code&gt;CNTR1 EQU H'20'&lt;/code&gt; to another value if needed. The definitions for &lt;code&gt;PORTB&lt;/code&gt; and &lt;code&gt;TRISB&lt;/code&gt; are provided by the vendor so that the user doesn't need to memorize the actual register addresses.&lt;/p&gt;

&lt;p&gt;Another feature commonly supported by assemblers is the use of labels. &lt;code&gt;DELAY&lt;/code&gt;, &lt;code&gt;LOOP&lt;/code&gt;, &lt;code&gt;LOOP1&lt;/code&gt;, and &lt;code&gt;LOOP2&lt;/code&gt; are labels. When a label is used with an instruction like &lt;code&gt;GOTO&lt;/code&gt;, the assembler automatically calculates the address of the instruction labeled by the label and generates the correct instruction that directs the processor to start executing that instruction. This simplifies the programmer's life, as otherwise, the programmer would need to manually calculate offsets between instructions.&lt;/p&gt;

&lt;p&gt;Many assemblers offer features to fill a memory region with text, typically represented in ASCII, along with other handy functionalities. However, an assembly language for a processor strictly adheres to its ISA and machine language specifications. These additional features simply make a programmer's life a bit easier. Since assembly language closely mirrors machine language with some helpful additions, it is also referred to as &lt;strong&gt;symbolic machine language&lt;/strong&gt; or &lt;strong&gt;symbolic machine code.&lt;/strong&gt; While we write programs in a manner similar to machine language but we use symbols to create them. Ultimately, the assembler converts the program into machine language, consisting solely of 0s and 1s.&lt;/p&gt;

&lt;h3&gt;
  
  
  Example
&lt;/h3&gt;

&lt;p&gt;Since assembly languages strictly adhere to the instructions defined in a particular ISA, &lt;strong&gt;we have different assembly languages for each architecture.&lt;/strong&gt; Let's write a very simple function for different architectures. The function takes two inputs and calculates the sum of their squares: &lt;code&gt;x^2 + y^2&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;For &lt;strong&gt;x86-64&lt;/strong&gt; architecture:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mov     eax, DWORD PTR [rbp-20]
imul    eax, eax
mov     edx, eax
mov     eax, DWORD PTR [rbp-24]
imul    eax, eax
add     eax, edx
mov     DWORD PTR [rbp-4], eax
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For &lt;strong&gt;RISC-V 64-bits&lt;/strong&gt; architecture:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;lw      a5,-36(s0)
mulw    a5,a5,a5
sext.w  a4,a5
lw      a5,-40(s0)
mulw    a5,a5,a5
sext.w  a5,a5
addw    a5,a4,a5
sw      a5,-20(s0)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and for &lt;strong&gt;MIPS&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;lw      $2,24($fp)
nop
mult    $2,$2
mflo    $3
lw      $2,28($fp)
nop
mult    $2,$2
mflo    $2
addu    $2,$3,$2
sw      $2,8($fp)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you may easily notice, the same functionality is achieved with different assembly programs for different architectures. Since their ISAs are different, the corresponding assembly programs also differ. Although all of them share a similar pattern and some instructions appear similar, one has to learn each assembly language for the processors they work on.&lt;/p&gt;

&lt;p&gt;A similar issue persists even when working with very similar processors. Let's consider another example. In this case, assume we have three variables, x, y, and z, and we aim to implement &lt;code&gt;z = x + y&lt;/code&gt;, where all of them are integers with a width of 64 bits.&lt;/p&gt;

&lt;p&gt;For ARMv7:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ldr     r1, [sp, #16]
ldr     r0, [sp, #20]
ldr     r3, [sp, #8]
ldr     r2, [sp, #12]
adds    r1, r1, r3
adc     r0, r0, r2
str     r1, [sp]
str     r0, [sp, #4]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For ARMv8:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ldr     x8, [sp, #24]
ldr     x9, [sp, #16]
add     x8, x8, x9
str     x8, [sp, #8]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The assembly programs for both architectures are very similar; they both contain almost the same instructions. However, the program for ARMv8 has almost half the number of instructions compared to the program for ARMv7. This is because ARMv8 is a 64-bit processor architecture, and since the "natural" word length of this architecture is 64 bits, a single &lt;code&gt;add&lt;/code&gt; instruction is sufficient to sum up two 64-bit variables. On the other hand, ARMv7 is a 32-bit processor architecture and cannot handle 64-bit variables as easily as ARMv8. Therefore, one has to split a 64-bit variable into two 32-bit variables and perform multiple additions.&lt;/p&gt;




&lt;p&gt;As you can see, programming in assembly language is easier than programming in machine language. However, one must learn the ISA for each architecture and consider other factors such as variable sizes and architectural details. Let's imagine that you've written a fairly large assembly program for the ARMv7 architecture, and one day you need to run the same program on an x86-64 architecture. In that case, you would have to rewrite your program in x86-64 assembly language. Rewriting the same program for a different architecture or system is known as &lt;strong&gt;porting.&lt;/strong&gt; At the assembly language level, porting is not an easy task because you have to rewrite the entire program again. If you are supposed to port the same program to five different architectures, good luck! You will have to rewrite and debug the same program five times using different assembly languages.&lt;/p&gt;

&lt;p&gt;As we conclude this section, it's important to recognize that even within the same architecture, there can be multiple assembly language variants. Take x86 assembly, for instance, where two prominent styles exist: &lt;strong&gt;AT&amp;amp;T and Intel.&lt;/strong&gt; &lt;sup id="fnref4"&gt;4&lt;/sup&gt; While these styles may appear similar, they differ in the order of instruction parameters. Nevertheless, despite these variations, they ultimately produce the same machine code.&lt;/p&gt;

&lt;p&gt;This concludes part 1. In part 2, we'll explore what can be built on top of assembly language, and I'll share my personal insights on the existence of various programming languages. Stay tuned for more!&lt;/p&gt;




&lt;ol&gt;

&lt;li id="fn1"&gt;
&lt;p&gt;&lt;a href="https://en.wikipedia.org/wiki/List_of_programming_languages"&gt;https://en.wikipedia.org/wiki/List_of_programming_languages&lt;/a&gt; ↩&lt;/p&gt;
&lt;/li&gt;

&lt;li id="fn2"&gt;
&lt;p&gt;&lt;a href="https://en.wikipedia.org/wiki/Altair_8800"&gt;https://en.wikipedia.org/wiki/Altair_8800&lt;/a&gt; ↩&lt;/p&gt;
&lt;/li&gt;

&lt;li id="fn3"&gt;
&lt;p&gt;&lt;a href="https://en.wikipedia.org/wiki/EDSAC"&gt;https://en.wikipedia.org/wiki/EDSAC&lt;/a&gt; ↩&lt;/p&gt;
&lt;/li&gt;

&lt;li id="fn4"&gt;
&lt;p&gt;&lt;a href="https://en.wikipedia.org/wiki/X86_assembly_language#Syntax"&gt;https://en.wikipedia.org/wiki/X86_assembly_language#Syntax&lt;/a&gt; ↩&lt;/p&gt;
&lt;/li&gt;

&lt;/ol&gt;

</description>
      <category>programming</category>
      <category>languages</category>
      <category>processor</category>
    </item>
    <item>
      <title>C is an imperative language.</title>
      <dc:creator>Alper Yazar</dc:creator>
      <pubDate>Sun, 07 May 2023 10:51:26 +0000</pubDate>
      <link>https://dev.to/ayazar/c-is-an-imperative-language-5ff1</link>
      <guid>https://dev.to/ayazar/c-is-an-imperative-language-5ff1</guid>
      <description>&lt;p&gt;The C language (or any programming language) can be characterized from many different perspectives. One property of the C language is being an &lt;strong&gt;imperative language.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  imperative vs declarative
&lt;/h2&gt;

&lt;p&gt;C is an &lt;strong&gt;imperative&lt;/strong&gt; (&lt;code&gt;buyurgan&lt;/code&gt; in Turkish) language. As programmers, we explicitly control the state or flow of the program by writing statements [1]. Writing in C is similar to &lt;em&gt;giving orders to a computer&lt;/em&gt;. Codes in C++ and Python are also &lt;em&gt;usually&lt;/em&gt; written imperatively. The opposite is &lt;strong&gt;declarative&lt;/strong&gt; (&lt;code&gt;bildirimsel&lt;/code&gt; in Turkish). When we are programming with declarative languages, we describe &lt;em&gt;what&lt;/em&gt; should be done, but not &lt;em&gt;how&lt;/em&gt;. With declarative languages, we do not control the flow of the program explicitly.&lt;/p&gt;

&lt;p&gt;The following code may be a part of a C program.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="c1"&gt;//...&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;foo&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt;
    &lt;span class="nf"&gt;bar&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="c1"&gt;//...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see, we explicitly control the flow of the program by an &lt;code&gt;if&lt;/code&gt; statement and give &lt;em&gt;orders&lt;/em&gt; by calling functions &lt;code&gt;foo()&lt;/code&gt; and &lt;code&gt;bar()&lt;/code&gt; and somehow modify the program state by changing the value of &lt;code&gt;y&lt;/code&gt;. Depending on the result of the comparison of &lt;code&gt;x&lt;/code&gt; by &lt;code&gt;20&lt;/code&gt;, the flow of the program takes a different direction. Each line tells the computer what to do explicitly.&lt;/p&gt;

&lt;h2&gt;
  
  
  a declarative example
&lt;/h2&gt;

&lt;p&gt;The following SQL code (query) fetches data from &lt;code&gt;Users&lt;/code&gt; table which is stored in a database.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;Users&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;username&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'admin'&lt;/span&gt; &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;PASSWORD&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'admin'&lt;/span&gt; &lt;span class="k"&gt;ORDER&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="k"&gt;DESC&lt;/span&gt; &lt;span class="k"&gt;LIMIT&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Unlike C, in that case, we describe &lt;em&gt;what&lt;/em&gt; we want but not &lt;em&gt;how&lt;/em&gt; the database engine should work to satisfy our query. We want a single row from the table &lt;code&gt;Users&lt;/code&gt; where both username and password are &lt;code&gt;admin&lt;/code&gt; and if multiple users are found, the user with the highest &lt;code&gt;id&lt;/code&gt; is returned. Did we implement the sorting algorithm used to sort entries? No! We don't care about the exact operations and flow executed by the database engine, we only care about the result. But while programming in C, we must give &lt;em&gt;orders&lt;/em&gt; and control the flow.&lt;/p&gt;

&lt;h2&gt;
  
  
  computer architecture and imperative programming
&lt;/h2&gt;

&lt;p&gt;The imperative programming paradigm is the natural way of computer programming. The basics of computer and processor architectures haven't changed too much since the beginning of the microprocessor era. Almost all processors work by executing orders (instructions) sequentially. Some instructions (branch instructions) change the flow that the processor follows. From that perspective, programming in C is very parallel to programming in assembly language, only at a &lt;em&gt;slightly&lt;/em&gt; higher level.&lt;/p&gt;

&lt;p&gt;Programs coded in a declarative language run on the same processors. There is no different processor to run SQL code or a procedural language. The difference between these two paradigms comes from the perspective that a programmer sees the computer. Of course, the database engine executing SQL codes runs similar instructions on the processor as a C program. The engine itself could be programmed in an imperative language, like C. In general, if you use a declarative language, computer architecture becomes more abstract to you compared to programming in an imperative language. This doesn't have to be necessarily a good or a bad thing. As always, it depends on your needs…&lt;/p&gt;

&lt;h2&gt;
  
  
  functional programming
&lt;/h2&gt;

&lt;p&gt;The functional programming paradigm is a subset of the declarative programming paradigm. There are purely functional languages like Haskell. Nowadays, most modern programming languages like Python or C++ have some tools that allow us to program in a functional programming fashion (like lambda functions).&lt;/p&gt;

&lt;p&gt;A programming language does not have to be in either category. Most programming languages are multi-paradigm languages supporting both paradigms more or less.&lt;/p&gt;

&lt;h2&gt;
  
  
  summary
&lt;/h2&gt;

&lt;p&gt;Notice that a language may support programming in both imperative and declarative fashion. For example, in Python or C++, one can program in both paradigms [2]. &lt;strong&gt;But of course, C is an imperative language.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Unlike many modern languages, C does not support the declarative programming paradigm inherently. It is possible to add some declarative programming features to C with 3rd party libraries. However, extending a language with 3rd party libraries doesn't change its paradigm or category. The key point is that the features should be native to that language.&lt;/p&gt;

&lt;h2&gt;
  
  
  resources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://en.wikipedia.org/wiki/C_(programming_language)"&gt;https://en.wikipedia.org/wiki/C_(programming_language)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Personal notes from &lt;a href="https://github.com/necatiergin/kurs_programlari/blob/main/c_programlama_dili.md"&gt;Necati Ergin's C course&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  references
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;[1]: &lt;a href="https://en.wikipedia.org/wiki/C_(programming_language)"&gt;https://en.wikipedia.org/wiki/C_(programming_language)&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;[2]: &lt;a href="https://www.educative.io/blog/declarative-vs-imperative-programming"&gt;https://www.educative.io/blog/declarative-vs-imperative-programming&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>c</category>
    </item>
    <item>
      <title>Recommend Visual Studio Code extensions along with your code</title>
      <dc:creator>Alper Yazar</dc:creator>
      <pubDate>Sat, 22 Oct 2022 14:26:23 +0000</pubDate>
      <link>https://dev.to/ayazar/recommend-visual-studio-code-extensions-along-with-your-code-5c8b</link>
      <guid>https://dev.to/ayazar/recommend-visual-studio-code-extensions-along-with-your-code-5c8b</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;VS Code allows us to recommend extensions to developers along with code.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://code.visualstudio.com/"&gt;Visual Studio Code&lt;/a&gt;, VS Code in short, is a very popular editor (my main editor for several years) among many developers &lt;sup id="fnref1"&gt;1&lt;/sup&gt;. Its power is at least doubled by &lt;a href="https://marketplace.visualstudio.com/vscode"&gt;variety of extensions&lt;/a&gt;. &lt;strong&gt;In this post, I will show you a way of recommending VS Code extensions to developers along with code.&lt;/strong&gt; &lt;a href="https://code.visualstudio.com/docs/editor/extension-marketplace"&gt;The steps&lt;/a&gt; are already explained by Microsoft but here I will add my tips.&lt;/p&gt;

&lt;h2&gt;
  
  
  Basics
&lt;/h2&gt;

&lt;p&gt;If you open a project in VS Code and the root of the project has a directory named &lt;code&gt;.vscode&lt;/code&gt; then the editor searches some specific files in that directory. One of them is &lt;code&gt;extensions.json&lt;/code&gt;. This file enables us to recommend extensions with our code. As an example, let's look at source code of my blog. Source code of my blog is open and &lt;a href="https://github.com/alperyazar/blog"&gt;hosted on Github&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0pnzf0yrpf87vh9g35gu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0pnzf0yrpf87vh9g35gu.png" alt="My blog as an example" width="800" height="540"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Source of my blog as an example&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;If you clone or download source of &lt;a href="https://github.com/alperyazar/blog"&gt;my blog&lt;/a&gt;, you will see &lt;code&gt;.vscode/extensions.json&lt;/code&gt;. Notice that lines started with &lt;code&gt;//&lt;/code&gt; are shown in red by Github, I will come to this issue later. For now, 8 extensions are recommended in this file. If you open the project (via &lt;code&gt;File&lt;/code&gt; → &lt;code&gt;Open Folder&lt;/code&gt;) with VS Code and if recommended extensions are not installed (or partially installed) on your system, you will see a box at bottom right of the editor asking for installing recommended extensions.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8zdqb37264q3ik0lv4bp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8zdqb37264q3ik0lv4bp.png" alt="Recommended Extensions Warning" width="561" height="152"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Asking for installing recommended extensions&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Install&lt;/code&gt; will install all recommended extensions as the name suggests. Click &lt;code&gt;Show Recommendations&lt;/code&gt; to see recommended extensions. They are listed under &lt;code&gt;WORKSPACE RECOMMENDATIONS&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff2t0jtw7l331quniqt81.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff2t0jtw7l331quniqt81.png" alt="WORKSPACE RECOMMENDATIONS" width="356" height="538"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;2 of 8 extensions are not installed on my machine&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;From there, you can install extensions one by one.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Hint:&lt;/strong&gt; If you want to list recommended extensions for a project in any time, open the project, go to &lt;code&gt;Extensions&lt;/code&gt; (&lt;code&gt;Ctrl-Shift-X&lt;/code&gt; by default) and search for &lt;code&gt;@recommended&lt;/code&gt;. Here you will see both Workspace Recommendations given by &lt;code&gt;extensions.json&lt;/code&gt; and Other Recommendations offered by VS Code itself.&lt;/p&gt;

&lt;p&gt;Now you see the basics of the mechanism. With your code, create a file named &lt;code&gt;extensions.json&lt;/code&gt; under &lt;code&gt;.vscode&lt;/code&gt; and write names of extensions that could be useful for other developers working on your project and you're done!&lt;/p&gt;

&lt;h2&gt;
  
  
  Working with git
&lt;/h2&gt;

&lt;p&gt;I assume that the project you created &lt;code&gt;extensions.json&lt;/code&gt; for it is a git repository. It is not recommended to commit whole &lt;code&gt;.vscode&lt;/code&gt; directory with your code since this directory may include some user specific configurations irrelevant to codebase&lt;sup id="fnref2"&gt;2&lt;/sup&gt;. We should add some rules to &lt;code&gt;.gitignore&lt;/code&gt;. I recommend to use &lt;a href="https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore"&gt;template suggested by Github team&lt;/a&gt; for this purpose. The template looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets

# Local History for Visual Studio Code
.history/

# Built Visual Studio Code Extensions
*.vsix
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The first line excludes all files under &lt;code&gt;.vscode&lt;/code&gt;. The following lines define some exceptions. As you can see, &lt;code&gt;extensions.json&lt;/code&gt; will be in your commits. Don't forget to add these line to your &lt;code&gt;.gitignore&lt;/code&gt; file. You can put these line to anywhere (most probably) in &lt;code&gt;.gitignore&lt;/code&gt; but don't change their order. Personally, I don't like tracking &lt;code&gt;settings.json&lt;/code&gt; with project but you can leave like this, it won't affect extension recommendation system. &lt;a href="https://github.com/alperyazar/blog/blob/master/.gitignore"&gt;.gitignore of my blog&lt;/a&gt; can be taken as an example.&lt;/p&gt;

&lt;h2&gt;
  
  
  extensions.json
&lt;/h2&gt;

&lt;p&gt;This JSON file has a very simple structure:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"recommendations"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;Similar&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;(same)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;markdownlint&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;used&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;in&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;CI&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="s2"&gt;"DavidAnson.vscode-markdownlint"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;Easy&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;indentation&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="s2"&gt;"oderwat.indent-rainbow"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;.editorconfig&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="s2"&gt;"EditorConfig.EditorConfig"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You list names of recommended extensions one by one.&lt;/p&gt;

&lt;h3&gt;
  
  
  Wait! This is an invalid JSON file!
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Yes!&lt;/strong&gt; You can not comment in JSON with &lt;code&gt;//&lt;/code&gt; or &lt;code&gt;/**/&lt;/code&gt; or with any character&lt;sup id="fnref3"&gt;3&lt;/sup&gt;. JSON doesn't support comments. So, if you try to validate the example with a &lt;a href="https://jsonlint.com/"&gt;validator/linter&lt;/a&gt;, you will get errors. Do you remember the first image where lines starting with &lt;code&gt;//&lt;/code&gt; are in red? This is because parser of Github thinks that there is a syntax error and yes, there is. BUT, VS Code allows comments in its configuration files (like &lt;code&gt;extensions.json&lt;/code&gt;) with &lt;strong&gt;JSON with Comments (jsonc).&lt;/strong&gt;&lt;sup id="fnref4"&gt;4&lt;/sup&gt; Therefore, it is valid to have C-like comments in &lt;code&gt;extensions.json&lt;/code&gt;. &lt;strong&gt;I highly recommend commenting&lt;/strong&gt; for each extensions like writing purpose of the extension or human readable name of it since some extension names could be little cryptic. If your project CI pipeline runs some JSON linter on all project files ending with &lt;code&gt;.json&lt;/code&gt;, this may cause your CI pipeline to fail. Don't forget to exclude &lt;code&gt;extensions.json&lt;/code&gt; (if you are adding comments) from JSON linting process if you have any.&lt;/p&gt;

&lt;h2&gt;
  
  
  Finding names of extensions
&lt;/h2&gt;

&lt;p&gt;The last step is adding extensions names to &lt;code&gt;extensions.json&lt;/code&gt; file. How can we find the names? If the extension is installed on your VS Code, go to &lt;code&gt;Extensions&lt;/code&gt; and click little gear symbol (⚙) next to extension name and click &lt;code&gt;Copy Extension ID&lt;/code&gt; and then paste into &lt;code&gt;extensions.json&lt;/code&gt;. The second method is searching the extension on &lt;a href="https://marketplace.visualstudio.com/vscode"&gt;Marketplace&lt;/a&gt;. After finding the extension, open the extension page and look for &lt;code&gt;Unique Identifier&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why?
&lt;/h2&gt;

&lt;p&gt;We saw how we can utilize &lt;code&gt;extensions.json&lt;/code&gt; to recommend VS Code extensions with code to developers. But why do we want to do this? The purpose is making life of developers/contributors easier. For example, I use &lt;a href="https://marketplace.visualstudio.com/items?itemName=oderwat.indent-rainbow"&gt;indent-rainbow&lt;/a&gt; to make indents more readable. Let's say that you are using &lt;a href="https://github.com/igorshubovych/markdownlint-cli"&gt;markdownlint-cli&lt;/a&gt; with your CI setup then you may consider adding &lt;a href="https://marketplace.visualstudio.com/items?itemName=DavidAnson.vscode-markdownlint"&gt;markdownlint&lt;/a&gt; to &lt;code&gt;extensions.json&lt;/code&gt;. This extension runs same rules with &lt;code&gt;markdownlint-cli&lt;/code&gt; and immediately detects linting errors while you typing. This allows contributors to detect linting errors before pushing anything and waiting CI pipeline (linting) to fail. This shortens the loop significantly. So if you (as a repository/codebase maintainer) think that a particular VS Code extension helps contributors then add it. But don't recommend anything satisfying your personal choices like color theme, icon set, etc. They won't help other developers much.&lt;/p&gt;

&lt;h2&gt;
  
  
  Do not trust developers!
&lt;/h2&gt;

&lt;p&gt;No, please trust them. What do I mean that don't assume that all developers are using VS Code and they will install all recommended extensions. This is impossible for open source projects. A contributor may use any editor or even web IDEs of Github or Gitlab. One may choose to use VS Code without installing the recommended extensions. So if you are linting markdown files with CI pipelines, you should consider suggesting some extension to developers to make merge/pull request loops shorter. But you should have always linting tests running before merging and you should assume that all recommended extensions are disabled by developers.&lt;/p&gt;

&lt;p&gt;Happy (VS)coding!&lt;/p&gt;




&lt;ol&gt;

&lt;li id="fn1"&gt;
&lt;p&gt;&lt;a href="https://survey.stackoverflow.co/2022/#most-loved-dreaded-and-wanted-new-collab-tools-love-dread"&gt;https://survey.stackoverflow.co/2022/#most-loved-dreaded-and-wanted-new-collab-tools-love-dread&lt;/a&gt; ↩&lt;/p&gt;
&lt;/li&gt;

&lt;li id="fn2"&gt;
&lt;p&gt;&lt;a href="https://stackoverflow.com/questions/32964920/should-i-commit-the-vscode-folder-to-source-control"&gt;https://stackoverflow.com/questions/32964920/should-i-commit-the-vscode-folder-to-source-control&lt;/a&gt; ↩&lt;/p&gt;
&lt;/li&gt;

&lt;li id="fn3"&gt;
&lt;p&gt;&lt;a href="https://stackoverflow.com/questions/244777/can-comments-be-used-in-json"&gt;https://stackoverflow.com/questions/244777/can-comments-be-used-in-json&lt;/a&gt; ↩&lt;/p&gt;
&lt;/li&gt;

&lt;li id="fn4"&gt;
&lt;p&gt;&lt;a href="https://code.visualstudio.com/docs/languages/json#_json-with-comments"&gt;https://code.visualstudio.com/docs/languages/json#_json-with-comments&lt;/a&gt; ↩&lt;/p&gt;
&lt;/li&gt;

&lt;/ol&gt;

</description>
      <category>vscode</category>
    </item>
  </channel>
</rss>
