<?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: Alexandru Biscoveanu</title>
    <description>The latest articles on DEV Community by Alexandru Biscoveanu (@bisqottii).</description>
    <link>https://dev.to/bisqottii</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%2F1577924%2F35e0d5dc-37c3-4122-8554-45cb9cc2bb5b.png</url>
      <title>DEV Community: Alexandru Biscoveanu</title>
      <link>https://dev.to/bisqottii</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/bisqottii"/>
    <language>en</language>
    <item>
      <title>Episode 1: Reimagining Assembly for the 21st Century</title>
      <dc:creator>Alexandru Biscoveanu</dc:creator>
      <pubDate>Thu, 17 Jul 2025 23:37:53 +0000</pubDate>
      <link>https://dev.to/bisqottii/episode-1-reimagining-assembly-for-the-21st-century-1ll9</link>
      <guid>https://dev.to/bisqottii/episode-1-reimagining-assembly-for-the-21st-century-1ll9</guid>
      <description>&lt;p&gt;It started with a file called &lt;code&gt;grammar.txt&lt;/code&gt;. I opened VS Code, typed the first rule, and thought: okay… now what?&lt;/p&gt;

&lt;p&gt;That moment felt familiar. The cursor blinking, the code editor open, the idea too big for the page. I wasn’t just trying to write a program, I was trying to design a language. And not just any language. One that would reimagine how we write something many have long left untouched: assembly.&lt;/p&gt;

&lt;p&gt;Let me back up.&lt;/p&gt;

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

&lt;p&gt;I've always had a deep love for low-level programming, the kind where you feel the metal, every memory address, every instruction, every register. There’s a thrill in commanding the machine directly, watching each clock tick count. That’s the charm of working close to the hardware. That’s what drew me to assembly.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Spark: LLVM IR
&lt;/h2&gt;

&lt;p&gt;This all started during a research project in my QA class at university. I was working with LLVM IR, the intermediate representation used by the LLVM compiler infrastructure. For most students, it was just another layer of the toolchain. For me, it felt like a secret door, like someone left a raw sketch of how modern code becomes machine logic, and nobody bothered to make it usable.&lt;/p&gt;

&lt;p&gt;And that’s what started a thought I couldn’t shake:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;What if we didn’t treat IR as just a step in the compilation process? What if it was the programming language — a real alternative for those who love assembly, but want their code to be portable?&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Not in the way people write inline assembly for a quick optimization. I mean: what if we made a real language, with structure, modularity, and sanity, that keeps the low-level precision of IR, but is something you can actually live in?&lt;/p&gt;

&lt;h2&gt;
  
  
  Designing a Language from Scratch
&lt;/h2&gt;

&lt;p&gt;In my last post, &lt;a href="https://dev.to/bisqottii/buffing-a-50-year-old-programming-language-58la"&gt;Buffing A 50 Year Old Programming Language&lt;/a&gt;, I explored Lex and Yacc, and I have also taken a compiler course at university where we used Flex, Bison, and LLVM.&lt;/p&gt;

&lt;p&gt;Personally, I am not a fan of Flex and Bison. The structure of Lex and Yacc files is hard to read and feels cumbersome to work with. Because of that, I decided to build my own lexer and parser instead, giving me more control and flexibility.&lt;/p&gt;

&lt;p&gt;The feedback from my last post encouraged me to think more creatively about the language design. As I mentioned earlier, this whole idea was sparked by my fascination with LLVM IR and the possibilities it opened up.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Hardest Part Was the Structure
&lt;/h2&gt;

&lt;p&gt;The first thing you realize when designing a language based on IR is that IR isn’t meant for humans. It’s flat, it’s verbose, and while it’s consistent, it lacks narrative. It’s like trying to write a novel using only CSV files. You can’t express relationships, intent, or abstraction easily. There’s no scaffolding to build upon.&lt;/p&gt;

&lt;p&gt;In traditional assembly, the challenge isn’t just writing operations, it’s organizing them. Structuring a readable flow from instruction to instruction feels like carving logic into stone tablets. You can’t see the shape of your code at a glance. I wanted to change that.&lt;/p&gt;

&lt;p&gt;So I started borrowing structure from high-level languages. Not the syntax, necessarily, but the ideas: functions with type signatures, modules with imports, structured types, even lambdas and macros. The goal wasn’t to simplify IR, it was to make it expressive without sacrificing control.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Language (So Far)
&lt;/h2&gt;

&lt;p&gt;The grammar grew. I started defining literals, types, structs, and eventually entire modules. I borrowed LLVM’s naming conventions, inspired by how &lt;code&gt;%&lt;/code&gt; and &lt;code&gt;@&lt;/code&gt; make local and global identifiers visually distinct. The syntax evolved to be declarative but deterministic, prioritizing clarity and predictability.&lt;/p&gt;

&lt;h2&gt;
  
  
  Instructions and Types
&lt;/h2&gt;

&lt;p&gt;Instructions follow this form:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;operation identifier : type = operands
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5nip14fbgpkh5krsn5jo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5nip14fbgpkh5krsn5jo.png" alt="instructions" width="800" height="436"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Every instruction uses Static Single Assignment (SSA) form: one instruction, one output. This avoids ambiguity and makes data flow analysis straightforward. Types are explicitly defined, no inference, so you always know what kind of value you’re working with. Even non-standard widths like &lt;code&gt;i17&lt;/code&gt; are supported, reflecting LLVM’s flexibility. In general, types follow the &lt;code&gt;iN&lt;/code&gt; format.&lt;/p&gt;

&lt;h2&gt;
  
  
  Functions
&lt;/h2&gt;

&lt;p&gt;Personally I'm a fan of how more languages tend to go down the route of writing functions as:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhtg37msmnfdsll1xtgez.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhtg37msmnfdsll1xtgez.png" alt="functions" width="800" height="403"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But considering I am getting my inspiration from LLVM I define them as so:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwyksnthwgqf6h700p4vr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwyksnthwgqf6h700p4vr.png" alt="functions" width="800" height="401"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Functions are global values, marked with &lt;code&gt;@&lt;/code&gt;. Parameters and return types are explicitly annotated. Each block (like &lt;code&gt;entry&lt;/code&gt;) scopes instructions, making control flow clear and manageable.&lt;/p&gt;

&lt;p&gt;(Notice how the function layout mirrors instructions. Keeps things coherent and easy to follow.)&lt;/p&gt;

&lt;h2&gt;
  
  
  Higher‑Order Functions and Lambdas
&lt;/h2&gt;

&lt;p&gt;Functions are treated as first-class values in the language. This means they can be passed around, returned, and stored, just like any other value. This opens up possibilities for expressive and abstract programming patterns typically reserved for high-level functional languages.&lt;/p&gt;

&lt;p&gt;Lambdas are anonymous functions you can define inline, enabling concise, localized behavior without the overhead of a full function declaration. Combined with higher-order functions, functions that take other functions as parameters or return them, you get a powerful composition model. This lets you build logic in small, testable, and reusable blocks.&lt;/p&gt;

&lt;p&gt;For example, &lt;code&gt;@higher_order&lt;/code&gt; accepts a function as input and invokes it. The &lt;code&gt;@example&lt;/code&gt; function defines a lambda that squares its input and passes it to the higher-order function:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjt64pjuq9fam2gkn042f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjt64pjuq9fam2gkn042f.png" alt="Higher‑Order Functions and Lambdas" width="800" height="678"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;By enabling this functional flexibility, even a systems level language can support modern design patterns like callbacks, deferred execution, and runtime code assembly all while staying type-safe and deterministic.&lt;/p&gt;

&lt;h2&gt;
  
  
  Generics and Macros
&lt;/h2&gt;

&lt;p&gt;Low level code is often riddled with repetition. Swapping two values of type &lt;code&gt;i32&lt;/code&gt;, &lt;code&gt;i64&lt;/code&gt;, or even a pointer all requires separate boilerplate unless you have a mechanism for reuse. That’s where generics and macros come in.&lt;/p&gt;

&lt;p&gt;Generics provide compile time type abstraction. You can write one macro for any type &lt;code&gt;T&lt;/code&gt; and the compiler will generate the appropriate concrete version when used. This avoids copy pasting instruction sequences with tiny tweaks.&lt;/p&gt;

&lt;p&gt;Macros take that idea further: they’re like inline templates that can represent not just expressions, but control flow and instruction blocks. Unlike runtime polymorphism, these constructs are fully expanded at compile time, making them efficient and predictable, perfect for systems programming.&lt;/p&gt;

&lt;p&gt;Here’s a simple generic macro that swaps two values:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuwdqmc4an3la7i4jw4nu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuwdqmc4an3la7i4jw4nu.png" alt="Generics and Macros" width="800" height="440"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;These tools help strike a balance: the expressiveness and flexibility of abstraction, without giving up the deterministic output that low-level work demands.&lt;/p&gt;

&lt;h2&gt;
  
  
  Protocol-Oriented Programming
&lt;/h2&gt;

&lt;p&gt;In a high-level language, interfaces and traits provide abstraction without inheritance. In low-level languages, we often lose that structure and fall back to manual boilerplate. Protocols in this language bring some of that higher-order organization down to the metal.&lt;/p&gt;

&lt;p&gt;A protocol defines a contract, a set of function signatures that a type must implement. In this language, all protocol conformance is resolved at compile time. There is no runtime dispatch, no vtables, and no hidden indirection. The result is code that is just as efficient as if it had been written manually, while still offering the clarity and reuse of higher-level abstractions. Protocols enable powerful organization and type safety without giving up control or performance.&lt;/p&gt;

&lt;p&gt;This lets you build reusable libraries and algorithms that work on any type conforming to a given protocol, like an iterable container or a serializable value, without sacrificing performance or control.&lt;/p&gt;

&lt;p&gt;Here’s a protocol for iterables:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg1fic5fklnomsgy9iwef.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg1fic5fklnomsgy9iwef.png" alt="Protocol-Oriented Programming" width="800" height="308"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And an implementation:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk1w78dqd1y2gfmj2rok8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk1w78dqd1y2gfmj2rok8.png" alt="Protocol-Oriented Programming" width="800" height="467"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This pattern encourages a declarative and type safe way of building abstractions, supporting reuse without dynamic allocation, virtual calls, or unpredictable branching.&lt;/p&gt;

&lt;h2&gt;
  
  
  Algebraic Types and Enums
&lt;/h2&gt;

&lt;p&gt;Algebraic data types allow expressing rich control flow and states:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faoba5xsao1euzq9r7srs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faoba5xsao1euzq9r7srs.png" alt="Algebraic Types and Enums" width="800" height="515"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can destructure variants cleanly with &lt;code&gt;switch&lt;/code&gt;, matching on semantics, not structure.&lt;/p&gt;

&lt;h2&gt;
  
  
  Namespaces and Modules
&lt;/h2&gt;

&lt;p&gt;As the codebase grows, especially in a language targeting low-level systems, organizing functionality becomes vital. Without a coherent system of separation, large IR based programs can quickly descend into chaos.&lt;/p&gt;

&lt;p&gt;That’s where namespaces and modules step in. They allow you to group related functions, types, and constants into logical units, enabling better organization and preventing naming collisions.&lt;/p&gt;

&lt;p&gt;Each file can define multiple namespaces, and code can be explicitly imported and referenced using qualified paths. This design mirrors what we see in languages like Rust, while maintaining the minimal overhead required for low-level output.&lt;/p&gt;

&lt;p&gt;Consider this module:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fltpz1rm0d4rmsivm1zhf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fltpz1rm0d4rmsivm1zhf.png" alt="Namespaces and Modules" width="800" height="449"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And another with a nested namespace:&lt;/p&gt;

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

&lt;p&gt;Then, in the main file:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiagbfkt0gxouqs4f0tuy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiagbfkt0gxouqs4f0tuy.png" alt="Namespaces and Modules" width="800" height="403"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This lets you think about system boundaries and interfaces, even at the IR level, making it easier to collaborate, test, and scale your codebase across modules.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where This Is Going
&lt;/h2&gt;

&lt;p&gt;This language isn’t meant to replace established systems languages like Rust or C. Instead, it aims to bring structure, clarity, and usability to a programming layer that’s traditionally difficult to work with.&lt;/p&gt;

&lt;p&gt;Right now, I’m focused on completing the lexer and refining the grammar. This is just the surface of the language, there’s more in the works, like GPU instruction support, which I also plan to add to better extend the language for low-level compute workloads.&lt;/p&gt;

&lt;p&gt;This is still early stage work. The syntax is evolving, the semantics are being tested, and the implementation is growing week by week.&lt;/p&gt;

&lt;p&gt;And for a 77 year old programming model, that feels like a fresh coat of paint.&lt;/p&gt;

&lt;p&gt;I’d love to hear your thoughts, ideas, or any feedback you have.&lt;/p&gt;

</description>
      <category>showdev</category>
      <category>opensource</category>
      <category>programming</category>
      <category>cpp</category>
    </item>
    <item>
      <title>Buffing A 50 Year Old Programming Language</title>
      <dc:creator>Alexandru Biscoveanu</dc:creator>
      <pubDate>Thu, 06 Jun 2024 01:57:11 +0000</pubDate>
      <link>https://dev.to/bisqottii/buffing-a-50-year-old-programming-language-58la</link>
      <guid>https://dev.to/bisqottii/buffing-a-50-year-old-programming-language-58la</guid>
      <description>&lt;p&gt;Hello, everyone! Today, I'm excited to take you on a journey through the fascinating world of programming languages and compilers. We'll be exploring a new language I'm developing called "Mantle" (or simply "M"). But before we get into the nitty-gritty, let's discuss the architecture of Mantle and what I aim to achieve with it.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Inspiration Behind Mantle
&lt;/h2&gt;

&lt;p&gt;I've been immersed in programming with C and C++ for a considerable time, primarily working on 3D computer graphics using Vulkan. My initial exploration into programming began with C++, which I grew to love for its high-level constructs and powerful memory management capabilities. However, I often found C++ to be overly complex. I gradually developed a preference for C. C's simplicity, with its minimal abstraction over assembly, provided a clearer understanding of how the hardware operates.&lt;/p&gt;

&lt;p&gt;Yet, I frequently found myself torn between C and C++ when starting new projects. Each language has its strengths and weaknesses, and I wanted to create one that blends the best aspects of both. Thus, Mantle was born.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Design Philosophy of Mantle
&lt;/h2&gt;

&lt;p&gt;Today I will just briefly show you an overview of what I think Mantle can look like.&lt;/p&gt;

&lt;h3&gt;
  
  
  Organizing Code: Namespaces
&lt;/h3&gt;

&lt;p&gt;One of the challenges in C is the lack of a robust mechanism for code organization, leading to messy codebases. Mantle addresses this by incorporating namespaces from C++, allowing for better code grouping and organization.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fydhfvd8yqmtbcebb9y8m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fydhfvd8yqmtbcebb9y8m.png" alt="Namespaces" width="467" height="462"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Defining Interfaces: Protocols
&lt;/h3&gt;

&lt;p&gt;Mantle introduces the concept of “protocols". Protocols define requirements, such as functions and variables, that must be implemented by adopting types. This brings us to the “prototype” keyword, which acts as a placeholder for types specified when the protocol is adopted. This design encourages composition over inheritance, promoting flexible and modular code.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6sguqe7wqovzqljw1mq1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6sguqe7wqovzqljw1mq1.png" alt="Protocols" width="607" height="587"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating Classes: Blueprints
&lt;/h3&gt;

&lt;p&gt;In Mantle, “blueprints” are akin to classes in other languages. Blueprints support public and private members, constructors, and destructors for managing resources. Unlike C++, Mantle distinguishes between structs and blueprints. Structs are used for grouping related variables, while blueprints facilitate object-oriented programming.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffpfa2hpqhe92rsykcp99.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffpfa2hpqhe92rsykcp99.png" alt="Blueprints" width="591" height="879"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Extending Functionality: Extensions
&lt;/h3&gt;

&lt;p&gt;To extend a blueprint's functionality for specific parts of the code, Mantle uses the “extension” keyword. This allows functions to be associated with a blueprint only within a particular file, providing modular and context-specific extensions.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8cre13c5oljdkuwfawnp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8cre13c5oljdkuwfawnp.png" alt="Extensions" width="470" height="782"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9bbnu3z2b3znukio8ido.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9bbnu3z2b3znukio8ido.png" alt="Extensions" width="472" height="326"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Eliminating Redundancy: Generics
&lt;/h3&gt;

&lt;p&gt;Generics are a powerful feature in Mantle, enabling the definition of functions, blueprints, structs, and variables with types specified later. This reduces code repetition and enhances flexibility.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fszkr1o8l5dvlejjwlavy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fszkr1o8l5dvlejjwlavy.png" alt="Generics" width="800" height="654"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Powerful Preprocessing: Macros
&lt;/h3&gt;

&lt;p&gt;In Mantle, macros are defined with the “macro” keyword, leveraging generics for powerful code inclusion before compilation. This concept builds on the preprocessor directives of C and C++.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdqv4kvczaiijtxqnymlc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdqv4kvczaiijtxqnymlc.png" alt="Macros" width="776" height="302"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Core Concepts: Pointers and Optionals
&lt;/h3&gt;

&lt;p&gt;Mantle incorporates pointers and optionals as core language features. If you have ever programmed in Swift or have used the &lt;code&gt;std::optional&amp;lt;T&amp;gt;&lt;/code&gt; in C++ you might be quite familiar with this. Optionals represent values that may or may not be present, providing a type-safe way to handle absent values. Pointers, on the other hand, store memory addresses, enabling direct memory manipulation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Building Mantle: The Lexical Analyzer
&lt;/h2&gt;

&lt;p&gt;With an understanding of Mantle's design, let's dive into building the language, starting with Lexical Analysis, or lexing. Lexing transforms raw source code into tokens, which are the fundamental syntax elements.&lt;/p&gt;

&lt;h3&gt;
  
  
  Defining Token Types
&lt;/h3&gt;

&lt;p&gt;We'll begin by defining the types of tokens Mantle will recognize:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;    &lt;strong&gt;Keywords:&lt;/strong&gt; Data types, control flow constructs, data structures, and reserved words.&lt;/li&gt;
&lt;li&gt;    &lt;strong&gt;Operators:&lt;/strong&gt; Arithmetic, relational, pointer, bitwise, and assignment operators.&lt;/li&gt;
&lt;li&gt;    &lt;strong&gt;Punctuators:&lt;/strong&gt; Parentheses, curly brackets, square brackets, commas, etc.&lt;/li&gt;
&lt;li&gt;    &lt;strong&gt;Identifiers:&lt;/strong&gt; Names given to variables, functions, and types.&lt;/li&gt;
&lt;li&gt;    &lt;strong&gt;End of File:&lt;/strong&gt; Marks the end of the source file.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These tokens will evolve as the language matures and its functionality is refined.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Lexing Process
&lt;/h3&gt;

&lt;p&gt;Next, we'll write a lexer that processes a file, identifies tokens, and stores information for error handling, such as the token's position in the source file. Once identified, tokens are categorized and queued for further processing.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmfsp7qe0h8acd2ilqhdb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmfsp7qe0h8acd2ilqhdb.png" alt="Lexing" width="488" height="829"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Testing the Lexer
&lt;/h3&gt;

&lt;p&gt;To test our lexer, we'll hardcode a function that processes tokens and generates assembly code. For example, writing a "return" statement followed by a value, passing this file through our lexer, and generating assembly code will validate our lexer's functionality.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff02rt5h30880nxs92f9a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff02rt5h30880nxs92f9a.png" alt="Testing" width="800" height="150"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here are some more extreme tests.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs9m0z34b0b2r1cpe3mht.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs9m0z34b0b2r1cpe3mht.png" alt="Testing" width="800" height="483"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyiwdm9w9ebb12o3lia82.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyiwdm9w9ebb12o3lia82.png" alt="Testing" width="800" height="771"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;We've successfully laid the groundwork for Mantle and developed a basic lexer. There's much more to explore and build, but I hope you've enjoyed this initial exploration into the process. If you found this interesting, feel free to connect with me and to share any suggestions.&lt;/p&gt;

&lt;p&gt;If you have some feedback/suggestions let me know in the comments! Thanks for joining me on this journey, and I'll see you in the next time!&lt;/p&gt;

</description>
      <category>showdev</category>
      <category>opensource</category>
      <category>programming</category>
      <category>cpp</category>
    </item>
  </channel>
</rss>
