<?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: Miraly</title>
    <description>The latest articles on DEV Community by Miraly (@miraly).</description>
    <link>https://dev.to/miraly</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%2F3787885%2F38cd7e68-e53a-4b79-a10a-d616ae751a2d.jpg</url>
      <title>DEV Community: Miraly</title>
      <link>https://dev.to/miraly</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/miraly"/>
    <language>en</language>
    <item>
      <title>Low-Level Mastery: The Mechanics of Pointer Arithmetic</title>
      <dc:creator>Miraly</dc:creator>
      <pubDate>Wed, 25 Feb 2026 20:31:21 +0000</pubDate>
      <link>https://dev.to/miraly/low-level-mastery-the-mechanics-of-pointer-arithmetic-33f1</link>
      <guid>https://dev.to/miraly/low-level-mastery-the-mechanics-of-pointer-arithmetic-33f1</guid>
      <description>&lt;h4&gt;
  
  
  0. Introduction
&lt;/h4&gt;

&lt;p&gt;Imagine a program that manipulates memory with the precision of a grandmaster moving pieces on a chessboard. This capability is granted to developers through pointer arithmetic. Let’s explore the underlying mechanics of this powerful tool.&lt;/p&gt;

&lt;h4&gt;
  
  
  1. The Pointer: A Foundation
&lt;/h4&gt;

&lt;p&gt;A pointer is a variable that stores the memory address of an object. Through a pointer, you can perform any operation that you would on the object directly: reading, writing, and lifecycle management.&lt;/p&gt;

&lt;p&gt;A key distinction in C++ is the member access operator (-&amp;gt;). When dealing with pointers to structs or classes, -&amp;gt; is used to dereference the pointer and access the member in a single step:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="nc"&gt;Car&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;speed&lt;/span&gt;&lt;span class="p"&gt;{};&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="n"&gt;Car&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;ptr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;Car&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;ptr&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;speed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;150&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Syntactic shorthand for (*ptr).speed&lt;/span&gt;
&lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;cout&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;ptr&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;speed&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;endl&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;delete&lt;/span&gt; &lt;span class="n"&gt;ptr&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  2. Dynamic Arrays and Syntactic Sugar
&lt;/h4&gt;

&lt;p&gt;Pointers allow for the creation of dynamic arrays whose size is determined at runtime. While the subscript operator [] is standard, it is essentially "syntactic sugar" for pointer arithmetic. &lt;/p&gt;

&lt;p&gt;Let’s examine a pure C implementation that bypasses the sugar to manipulate memory directly:&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="cp"&gt;#include&lt;/span&gt; &lt;span class="cpf"&gt;&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;span class="cp"&gt;
#include&lt;/span&gt; &lt;span class="cpf"&gt;&amp;lt;stdlib.h&amp;gt;&lt;/span&gt;&lt;span class="cp"&gt;
&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Allocate memory for 10 integers&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;arr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="n"&gt;malloc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;sizeof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&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;arr&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="nb"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Error handling: a must for senior code&lt;/span&gt;

    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;arr&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Direct pointer arithmetic&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="n"&gt;free&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  3. The Scale Factor
&lt;/h4&gt;

&lt;p&gt;Why do we use &lt;em&gt;(arr + i) instead of manually calculating the byte offset like *(arr + i * 4)?&lt;br&gt;
The compiler handles this through type-based scaling. When you increment an int&lt;/em&gt;, the address increases by sizeof(int). This abstraction ensures that the developer focuses on logic rather than manual memory offsets.&lt;/p&gt;

&lt;h4&gt;
  
  
  4. Arrays vs. Pointers: Key Distinctions
&lt;/h4&gt;

&lt;p&gt;While arrays often "decay" into pointers when passed to functions, they are not identical:&lt;br&gt;
•   Allocation: Stack-allocated arrays have a fixed size at compile-time. Pointers can manage heap memory of arbitrary size.&lt;br&gt;
•   Mutatibility: A pointer is a variable that can be reassigned; an array name acts as a constant pointer to the first element.&lt;br&gt;
•   Performance: At the assembly level, arr[i] and *(arr + i) result in the same machine instructions. The difference lies solely in memory management and scope.&lt;/p&gt;

&lt;h4&gt;
  
  
  5. Real-World Applications and Critical Risks
&lt;/h4&gt;

&lt;p&gt;Pointer arithmetic is the backbone of high-performance engineering:&lt;br&gt;
•   Data Processing: Efficiently traversing large datasets, buffers, or image pixels.&lt;br&gt;
•   System Architecture: Implementing complex data structures (trees, graphs) and custom memory allocators.&lt;br&gt;
•   Security &amp;amp; Red Teaming: Developing exploits and performing memory forensics.&lt;/p&gt;

&lt;p&gt;Common Pitfalls:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Buffer Overflows: Accessing memory outside of allocated bounds leads to Undefined Behavior.&lt;/li&gt;
&lt;li&gt; Memory Leaks: Failing to deallocate memory, leading to resource exhaustion.&lt;/li&gt;
&lt;li&gt; Dangling Pointers: Attempting to dereference memory that has already been freed.&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  End
&lt;/h4&gt;

&lt;blockquote&gt;
&lt;p&gt;The pointer in C/C++ is like fire. In the right hands, it's a powerful and very useful weapon, but fire in the hands of a fool will cause his own house to crumble.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That's all, I hope you learned something new.&lt;/p&gt;

</description>
      <category>c</category>
      <category>cpp</category>
      <category>memory</category>
      <category>pointer</category>
    </item>
    <item>
      <title>Bootstrapping: A compiler written in its own language</title>
      <dc:creator>Miraly</dc:creator>
      <pubDate>Tue, 24 Feb 2026 00:28:58 +0000</pubDate>
      <link>https://dev.to/miraly/bootstrapping-a-compiler-written-in-its-own-language-47nl</link>
      <guid>https://dev.to/miraly/bootstrapping-a-compiler-written-in-its-own-language-47nl</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;Bootstrapping&lt;/strong&gt;: A sign of the maturity of programming languages
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;Bootstrapping is the process by which a programming language or its compiler is written in the same language. This is an indicator of his maturity.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What language are compilers written in?&lt;/strong&gt;&lt;br&gt;
For example, many people believe that &lt;strong&gt;C++&lt;/strong&gt; is written in &lt;strong&gt;C&lt;/strong&gt;, and this is true, but only partially. In the past, the first versions of &lt;strong&gt;C++&lt;/strong&gt; were indeed written in C, but today languages like &lt;strong&gt;C&lt;/strong&gt;, &lt;strong&gt;C++&lt;/strong&gt;, &lt;strong&gt;Java&lt;/strong&gt;, &lt;strong&gt;Rust&lt;/strong&gt; and &lt;strong&gt;Go&lt;/strong&gt; are largely written in themselves. Interestingly, the &lt;strong&gt;nasm&lt;/strong&gt; assembler compiler is written in &lt;strong&gt;C&lt;/strong&gt;. Many might assume that it is written in "zeros and ones", but this is not the case.&lt;/p&gt;

&lt;h2&gt;
  
  
  The value of &lt;strong&gt;Bootstrapping&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Bootstrapping&lt;/strong&gt; demonstrates that the language has sufficient flexibility and maturity to support its own implementation. It also means that the language can serve projects of various levels of complexity, from small scripts to large systems. For example, Rust, written on its own, is actively used to create secure and efficient software, from embedded systems to server applications.&lt;/p&gt;

&lt;h2&gt;
  
  
  Varieties of &lt;strong&gt;Python&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;You've probably asked yourself if &lt;strong&gt;Python&lt;/strong&gt; is written in &lt;strong&gt;Python&lt;/strong&gt;. The main version of &lt;strong&gt;Python&lt;/strong&gt;, &lt;strong&gt;CPython&lt;/strong&gt;, is indeed written in &lt;strong&gt;C&lt;/strong&gt;, as are most of its libraries. However, there is also a version of &lt;strong&gt;Python&lt;/strong&gt; written in &lt;strong&gt;Python&lt;/strong&gt; — &lt;strong&gt;PyPy&lt;/strong&gt;. Although &lt;strong&gt;Python&lt;/strong&gt; is not by nature the fastest language, &lt;strong&gt;PyPy&lt;/strong&gt; is significantly faster than &lt;strong&gt;CPython&lt;/strong&gt; thanks to &lt;em&gt;JIT&lt;/em&gt;-compilation (&lt;em&gt;Just-In-Time&lt;/em&gt;). This process optimizes code execution during its execution, which can lead to significant performance gains, but also requires more RAM than a Java virtual machine.&lt;/p&gt;

&lt;p&gt;There are also alternatives:&lt;br&gt;
&lt;strong&gt;Jython&lt;/strong&gt;, a version written in &lt;strong&gt;Java&lt;/strong&gt; that allows you to use &lt;strong&gt;Java&lt;/strong&gt; libraries directly from the &lt;strong&gt;Python&lt;/strong&gt; code. However, it does not support all the features of Python, such as some C extension modules.&lt;br&gt;
&lt;strong&gt;IronPython&lt;/strong&gt; is a version for &lt;strong&gt;.NET&lt;/strong&gt; that allows you to use &lt;strong&gt;.NET&lt;/strong&gt; libraries and create interfaces with applications on the &lt;strong&gt;.NET&lt;/strong&gt; platform.&lt;/p&gt;

&lt;p&gt;Besides these options, there are others such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;MicroPython&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;CircuitPython&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Brython&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Transcrypt&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Stackless Python&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Pyjamas&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Nuitka&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Pyston&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Bootstrapping&lt;/strong&gt; is a sign of the maturity of the language. If the compiler or interpreter of a language is written in the same language, this indicates the quality and development of the language.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Hi! My name is Mirali. I study hacking and low-level development, going down to the very bottom to see what lies behind a ton of layers of abstractions. I write in &lt;strong&gt;Asm&lt;/strong&gt;, &lt;strong&gt;C&lt;/strong&gt;, &lt;strong&gt;C++&lt;/strong&gt;, and also use scripting languages: &lt;strong&gt;Python&lt;/strong&gt; and &lt;strong&gt;JavaScript&lt;/strong&gt;. This is my first post, and I'd be interested to know which versions of Python you prefer and why. Subscribe if you want to learn more about low-level programming or hacking!&lt;/em&gt;&lt;/p&gt;

</description>
      <category>c</category>
      <category>cpp</category>
      <category>compiling</category>
      <category>assembly</category>
    </item>
  </channel>
</rss>
