<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Coder Legion - Recent posts tagged compiler</title>
<link>https://coderlegion.com/tag/compiler</link>
<description>Powered by Question2Answer</description>
<item>
<title>Programming Is Magic: Bryan MacLee’s Journey Building scrml</title>
<link>https://coderlegion.com/29769/programming-is-magic-bryan-maclees-journey-building-scrml</link>
<description>&lt;blockquote&gt;&lt;p&gt;&lt;strong&gt;Real developers. Real journeys. Real ideas.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://coderlegion.com/user/Bryan+MacLee&quot;&gt;Bryan MacLee&lt;/a&gt; is a truck driver specialising in the oil and gas industry, but programming is much more than a hobby for him. Driven by a deep love of JavaScript, frustration with web development's complexity, and an unconventional idea about how software should work, he is building &lt;strong&gt;scrml&lt;/strong&gt; — an open-source compiled language for the web.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;strong&gt;Interview &amp;amp; Story by Mehadi Hasan&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;CoderLegion Community &amp;amp; Editorial Team&lt;/em&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;it-started-with-hello-world-&quot;&gt;It Started With “Hello World”&lt;/h3&gt;
&lt;p&gt;For Bryan MacLee, the answer to what initially attracted him to programming is surprisingly simple:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;“Hello world.”&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;But explaining why programming became such an important part of his life takes a little longer.&lt;/p&gt;
&lt;p&gt;Bryan describes programming as:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;“The truest form of magic that we humans have ever created.”&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;It is a statement he stands by.&lt;/p&gt;
&lt;p&gt;For him, programming is a recursively unfolding logic puzzle. You begin with a question, follow the logic, discover another layer, and continue uncovering how things work.&lt;/p&gt;
&lt;p&gt;Even when a particular language or technology becomes repetitive, the underlying activity never really loses its appeal.&lt;/p&gt;
&lt;p&gt;And that love of solving problems eventually led him somewhere unusual: instead of simply using programming languages, Bryan decided to build one.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;a-truck-driver-building-a-programming-language&quot;&gt;A Truck Driver Building a Programming Language&lt;/h3&gt;
&lt;p&gt;Bryan works as a truck driver specialising in the oil and gas industry.&lt;/p&gt;
&lt;p&gt;Outside that professional world, he spends his time exploring programming, JavaScript and the development of scrml.&lt;/p&gt;
&lt;p&gt;He doesn't believe in the conventional idea of work-life balance.&lt;/p&gt;
&lt;p&gt;As he puts it:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;“Work and grow like progression is air. Laugh and love like the world ends tomorrow. To hell with balance.”&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;His oilfield work and programming are largely separate worlds. He doesn't claim that driving trucks has directly shaped his coding philosophy.&lt;/p&gt;
&lt;p&gt;However, his enthusiasm for software and technology sometimes follows him into his day job.&lt;/p&gt;
&lt;p&gt;One important difference is that Bryan has the freedom to choose what he works on and when.&lt;/p&gt;
&lt;p&gt;He doesn't have a software manager demanding features or deadlines. He can explore ideas because they interest him, without having to turn every experiment into a commercial deliverable.&lt;/p&gt;
&lt;p&gt;That freedom has helped him preserve something many developers struggle to maintain: his excitement about programming.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;loving-javascript-but-disliking-how-it-handles-the-web&quot;&gt;Loving JavaScript, but Disliking How It Handles the Web&lt;/h3&gt;
&lt;p&gt;Bryan's preferred programming language is JavaScript.&lt;/p&gt;
&lt;p&gt;Not TypeScript.&lt;/p&gt;
&lt;p&gt;JavaScript.&lt;/p&gt;
&lt;p&gt;He loves how quickly he can write code, experiment and see whether an idea works. For prototyping, he considers it an excellent language.&lt;/p&gt;
&lt;p&gt;But there has always been something that frustrated him.&lt;/p&gt;
&lt;p&gt;JavaScript's role in interacting with the DOM and styling the web can become complicated, especially when building complex reactive components.&lt;/p&gt;
&lt;p&gt;Bryan has experienced those frustrations firsthand.&lt;/p&gt;
&lt;p&gt;Initially, he tried to solve them by building a library.&lt;/p&gt;
&lt;p&gt;But as his ambitions grew, he began considering a framework.&lt;/p&gt;
&lt;p&gt;That idea didn't last long either.&lt;/p&gt;
&lt;p&gt;He felt frameworks could only go so far because they still operated on top of JavaScript, relying on conventions and abstractions that the underlying language itself didn't understand.&lt;/p&gt;
&lt;p&gt;Around the same time, he developed an academic interest in Rust.&lt;/p&gt;
&lt;p&gt;He admired its design, despite describing it as a beautifully hideous language.&lt;/p&gt;
&lt;p&gt;That exploration prompted a question:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;What if he could take some of the ideas he admired and build something around them?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The answer would eventually become scrml.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;the-small-frustration-that-started-scrml&quot;&gt;The Small Frustration That Started scrml&lt;/h3&gt;
&lt;p&gt;The origin of scrml wasn't a grand plan to create a new programming ecosystem.&lt;/p&gt;
&lt;p&gt;It began with a small annoyance.&lt;/p&gt;
&lt;p&gt;Bryan was working on a complex function and had written an expression whose result he wanted to reference.&lt;/p&gt;
&lt;p&gt;But he couldn't think of a suitable name for a temporary local variable.&lt;/p&gt;
&lt;p&gt;He sat staring at the cursor, increasingly frustrated.&lt;/p&gt;
&lt;p&gt;Eventually, he typed a generic name and tried to move on.&lt;/p&gt;
&lt;p&gt;But the interruption stayed with him.&lt;/p&gt;
&lt;p&gt;He wanted to write an expression and reference its last fall-through value without having to invent a name for something that would only be used once.&lt;/p&gt;
&lt;p&gt;As Bryan explains:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;“I wish I could just write the expression and reference the last ‘fall-through’ value.”&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;And that was the moment scrml was born.&lt;/p&gt;
&lt;p&gt;Not because he wanted to recreate Rust's enums or pattern matching.&lt;/p&gt;
&lt;p&gt;Not because JavaScript state management was frustrating, although that was certainly part of his broader motivation.&lt;/p&gt;
&lt;p&gt;It began because he wanted to stop naming one-time-use local variables.&lt;/p&gt;
&lt;p&gt;Everything else, as he jokes, was a bonus.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;what-exactly-is-scrml-&quot;&gt;What Exactly Is scrml?&lt;/h3&gt;
&lt;p&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://scrml.dev/&quot;&gt;scrml&lt;/a&gt; is a compiled programming language designed for web development.&lt;/p&gt;
&lt;p&gt;It takes &lt;code&gt;.scrml&lt;/code&gt; source files and generates HTML, CSS and JavaScript.&lt;/p&gt;
&lt;p&gt;But its central idea goes beyond translating one language into another.&lt;/p&gt;
&lt;p&gt;A single scrml file brings together:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Markup&lt;/li&gt;
&lt;li&gt;Application logic&lt;/li&gt;
&lt;li&gt;Styles&lt;/li&gt;
&lt;li&gt;SQL&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The compiler examines the whole program and determines how its parts relate.&lt;/p&gt;
&lt;p&gt;It then separates client-side and server-side responsibilities and generates the necessary connections.&lt;/p&gt;
&lt;p&gt;That includes server routes, fetch calls, CSRF handling and reactive dependency tracking.&lt;/p&gt;
&lt;p&gt;Bryan wants developers to describe what their application should do without manually writing all the repetitive wiring required to make different parts communicate.&lt;/p&gt;
&lt;p&gt;The language also introduces concepts that are central to his design philosophy:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;First-class state&lt;/li&gt;
&lt;li&gt;Exhaustive enum matching&lt;/li&gt;
&lt;li&gt;State-machine constructs&lt;/li&gt;
&lt;li&gt;Typed errors&lt;/li&gt;
&lt;li&gt;A cohesive syntax across the application&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Scrml is built to produce web technologies rather than operate as another framework sitting on top of JavaScript.&lt;/p&gt;
&lt;p&gt;That distinction is fundamental to Bryan's vision.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;one-language-one-compiler-one-understanding-of-the-program-&quot;&gt;One Language. One Compiler. One Understanding of the Program.&lt;/h3&gt;
&lt;p&gt;Bryan believes modern web development can become unnecessarily fragmented.&lt;/p&gt;
&lt;p&gt;A typical project may involve separate tools for markup, styles, logic, compilation, server communication and other responsibilities.&lt;/p&gt;
&lt;p&gt;Each tool sees only part of the source code.&lt;/p&gt;
&lt;p&gt;That fragmentation is one of the problems he wants scrml to address.&lt;/p&gt;
&lt;p&gt;His philosophy is:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;“One walk. One language. One compiler that reads the markup, the logic, the styles and the SQL together, and actually understands how they relate.”&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Because the compiler sees the whole program, it can generate connections that developers would otherwise have to create manually.&lt;/p&gt;
&lt;p&gt;For example, when an application needs to communicate between the browser and server, scrml can generate the necessary routes, fetch calls and serialization.&lt;/p&gt;
&lt;p&gt;Bryan also dislikes what he calls leaky abstractions and coloured functions.&lt;/p&gt;
&lt;p&gt;His goal is to move responsibility into the language and compiler rather than leaving developers to manage conventions across multiple layers.&lt;/p&gt;
&lt;p&gt;In his view, if the compiler understands the program, entire categories of mistakes can become impossible to express.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;making-state-a-first-class-concept&quot;&gt;Making State a First-Class Concept&lt;/h3&gt;
&lt;p&gt;One of the ideas that influenced scrml was Bryan's exploration of state in functional programming.&lt;/p&gt;
&lt;p&gt;He encountered a conventional definition of state as stored data, variables and conditions remembered by a program at a particular moment.&lt;/p&gt;
&lt;p&gt;He wasn't satisfied with that explanation.&lt;/p&gt;
&lt;p&gt;Instead, he developed his own description:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;“A snap-shot of a data set, at the moment of observation.”&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;That led him to question why programming languages commonly provide logic and type systems but don't necessarily offer state as a first-class language feature.&lt;/p&gt;
&lt;p&gt;Scrml incorporates state directly into its design.&lt;/p&gt;
&lt;p&gt;For example, a state cell can be declared using a tag-like form and then referenced through the language's state syntax.&lt;/p&gt;
&lt;p&gt;The compiler can track dependencies and manage the connections required for reactive behaviour.&lt;/p&gt;
&lt;p&gt;Bryan is also working on stronger lifecycle and validation contracts, along with new approaches to state declarations.&lt;/p&gt;
&lt;p&gt;These are part of his broader ambition to make the compiler responsible for more of the correctness guarantees.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;why-bryan-is-so-serious-about-dependencies&quot;&gt;Why Bryan Is So Serious About Dependencies&lt;/h3&gt;
&lt;p&gt;Bryan has a strong preference for minimal external dependencies.&lt;/p&gt;
&lt;p&gt;He describes himself as someone who likes to build things himself and has a visceral dislike of not understanding the code in his own source tree.&lt;/p&gt;
&lt;p&gt;He also sees automatically updating dependencies as a potential security problem.&lt;/p&gt;
&lt;p&gt;That doesn't mean scrml prohibits importing external code.&lt;/p&gt;
&lt;p&gt;Instead, Bryan wants imported code to enter through an explicit capability-gated mechanism.&lt;/p&gt;
&lt;p&gt;His underlying principle is that a program should retain ownership and awareness of the code it uses.&lt;/p&gt;
&lt;p&gt;He is particularly critical of developers introducing dependencies for trivial functionality.&lt;/p&gt;
&lt;p&gt;His example is &lt;code&gt;isEven&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;For something that can be expressed through a simple mathematical operation, he questions why a developer would need to search the web for an external package.&lt;/p&gt;
&lt;p&gt;For Bryan, fewer dependencies can encourage developers to understand what their applications actually contain.&lt;/p&gt;
&lt;p&gt;Scrml includes a standard library intended to cover most common web application needs.&lt;/p&gt;
&lt;p&gt;The goal isn't to eliminate useful code sharing, but to make dependencies more intentional.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;-assume-the-compiler-works-perfectly-&quot;&gt;“Assume the Compiler Works Perfectly”&lt;/h3&gt;
&lt;p&gt;Bryan's article &lt;a rel=&quot;nofollow&quot; href=&quot;https://coderlegion.com/28387/assume-the-compiler-works-perfectly&quot;&gt;Assume the compiler works perfectly&lt;/a&gt; addresses a particular challenge he has encountered when introducing scrml to other developers.&lt;/p&gt;
&lt;p&gt;A couple of people had tried it and responded that nothing worked.&lt;/p&gt;
&lt;p&gt;Bryan understands that this is a fair reaction, particularly when working with a new compiler.&lt;/p&gt;
&lt;p&gt;But he wanted to ask a different question.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;What if the compiler were already finished and worked perfectly?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Would developers actually want to write applications in scrml?&lt;/p&gt;
&lt;p&gt;That is the question behind the article.&lt;/p&gt;
&lt;p&gt;He isn't asking people to ignore technical problems or pretend the implementation is complete.&lt;/p&gt;
&lt;p&gt;He wants to separate two questions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Is the underlying language idea appealing?&lt;/li&gt;
&lt;li&gt;Is the current compiler implementation mature enough to deliver it?&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Building a compiler is a substantial undertaking, and Bryan knows the implementation still has work ahead.&lt;/p&gt;
&lt;p&gt;But he wants feedback on the vision itself, not only on the current state of the tooling.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;the-current-state-of-scrml&quot;&gt;The Current State of scrml&lt;/h3&gt;
&lt;p&gt;Scrml is open source under the MIT licence.&lt;/p&gt;
&lt;p&gt;At the time of Bryan's interview, the compiler was at version &lt;strong&gt;0.8.0&lt;/strong&gt;, running on Bun, and was not published to npm.&lt;/p&gt;
&lt;p&gt;He has also reached an important turning point in its development.&lt;/p&gt;
&lt;p&gt;The original TypeScript compiler prototype gradually became the product.&lt;/p&gt;
&lt;p&gt;Over time, technical debt accumulated to the point where continuing to extend the existing implementation became increasingly difficult.&lt;/p&gt;
&lt;p&gt;Rather than continuing to patch the old structure, Bryan has paused that compiler work and begun building a bootstrap approach.&lt;/p&gt;
&lt;p&gt;The current TypeScript compiler is intended to compile a natively written scrml compiler.&lt;/p&gt;
&lt;p&gt;In theory, this should help eliminate entire classes of bugs through construction rather than relying only on testing.&lt;/p&gt;
&lt;p&gt;He is also working on standalone left-hand-side state declarations, as well as stronger lifecycle and validation rules.&lt;/p&gt;
&lt;p&gt;It is a significant undertaking, but one that reflects his willingness to rethink the foundations rather than keep extending an architecture that no longer serves the language's direction.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;why-he-still-loves-javascript-but-doesn-t-want-to-write-it&quot;&gt;Why He Still Loves JavaScript but Doesn't Want to Write It&lt;/h3&gt;
&lt;p&gt;Bryan's relationship with JavaScript is unusual.&lt;/p&gt;
&lt;p&gt;He genuinely loves the language.&lt;/p&gt;
&lt;p&gt;He appreciates its simplicity, speed and ability to support rapid experimentation.&lt;/p&gt;
&lt;p&gt;But building scrml has changed where his excitement now lies.&lt;/p&gt;
&lt;p&gt;He says that writing JavaScript has lost much of its appeal compared with the anticipation of writing applications in his own language.&lt;/p&gt;
&lt;p&gt;He isn't less interested in programming.&lt;/p&gt;
&lt;p&gt;His excitement has shifted from using existing tools toward creating a different way to work.&lt;/p&gt;
&lt;p&gt;That enthusiasm is also what keeps him moving when scrml becomes difficult.&lt;/p&gt;
&lt;p&gt;There are naturally moments of discouragement during a project of this size.&lt;/p&gt;
&lt;p&gt;But the thought of eventually using the language he is building is a powerful motivator.&lt;/p&gt;
&lt;p&gt;He intends to continue regardless of what others think.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;building-a-language-for-more-than-himself&quot;&gt;Building a Language for More Than Himself&lt;/h3&gt;
&lt;p&gt;Bryan recognises that he doesn't need a production-level compiler simply to enjoy experimenting with his own ideas.&lt;/p&gt;
&lt;p&gt;He could build a much smaller tool and still benefit from it personally.&lt;/p&gt;
&lt;p&gt;But that's not the entire reason he's building scrml.&lt;/p&gt;
&lt;p&gt;He believes the ideas have value for other developers.&lt;/p&gt;
&lt;p&gt;He wants people to use it, question it, debate its assumptions and help improve it.&lt;/p&gt;
&lt;p&gt;Scrml is released under an open-source MIT licence, and Bryan doesn't see it as something that belongs exclusively to him.&lt;/p&gt;
&lt;p&gt;His ambition is to make it a shared project.&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;“I don't view this as ‘my’ language. MIT, open source, I gave it to the world.”&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;For Bryan, the value of scrml is directly connected to the number of people willing to engage seriously with its ideas.&lt;/p&gt;
&lt;p&gt;He wants developers to challenge his assumptions and help make the language better.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;what-would-success-look-like-&quot;&gt;What Would Success Look Like?&lt;/h3&gt;
&lt;p&gt;Bryan's definition of success is refreshingly modest.&lt;/p&gt;
&lt;p&gt;He doesn't need thousands of users or a large company to feel that the project has been worthwhile.&lt;/p&gt;
&lt;p&gt;His ideal milestone is simply hearing from one real developer who enjoys using scrml.&lt;/p&gt;
&lt;p&gt;As he puts it, success would be receiving an email or message from someone saying:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;“I enjoy writing scrml.”&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;That alone would make the work worthwhile.&lt;/p&gt;
&lt;p&gt;He hopes scrml may eventually stand alongside other interesting programming languages, but he doesn't measure its value only through popularity.&lt;/p&gt;
&lt;p&gt;The immediate goal is to build something genuinely useful and invite other developers to help shape it.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;the-freedom-to-keep-programming-for-the-right-reasons&quot;&gt;The Freedom to Keep Programming for the Right Reasons&lt;/h3&gt;
&lt;p&gt;One of the most interesting parts of Bryan's story is that he hasn't followed the conventional professional software-development route.&lt;/p&gt;
&lt;p&gt;He isn't building scrml because an employer assigned it to him.&lt;/p&gt;
&lt;p&gt;He isn't chasing a job title or trying to meet a commercial delivery deadline.&lt;/p&gt;
&lt;p&gt;He codes when and what he wants to.&lt;/p&gt;
&lt;p&gt;That freedom has helped him avoid becoming burned out or jaded about programming.&lt;/p&gt;
&lt;p&gt;He also doesn't force himself to read documentation or follow technologies that don't interest him.&lt;/p&gt;
&lt;p&gt;Instead, he can focus deeply on the ideas that capture his attention.&lt;/p&gt;
&lt;p&gt;That doesn't mean the journey is free of frustration.&lt;/p&gt;
&lt;p&gt;Building a programming language is difficult, and Bryan is candid about the challenges.&lt;/p&gt;
&lt;p&gt;But his motivation comes from genuine curiosity rather than external pressure.&lt;/p&gt;
&lt;p&gt;It is a reminder that unconventional paths can provide their own advantages.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;advice-for-developers-with-unusual-ideas&quot;&gt;Advice for Developers With Unusual Ideas&lt;/h3&gt;
&lt;p&gt;Bryan's advice to someone with an unconventional programming idea is direct:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;“If you have an idea, and you think it is worth attention. Scream it from the rooftops.”&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;He doesn't believe that a lack of a traditional background, job title or established resources should automatically stop someone from pursuing an interesting idea.&lt;/p&gt;
&lt;p&gt;Ideas should be exposed to discussion.&lt;/p&gt;
&lt;p&gt;They should be questioned.&lt;/p&gt;
&lt;p&gt;They should be challenged.&lt;/p&gt;
&lt;p&gt;And sometimes they should be corrected.&lt;/p&gt;
&lt;p&gt;Bryan sees correction as an opportunity rather than something to fear.&lt;/p&gt;
&lt;p&gt;The worst outcome, in his view, is that someone points out where your assumptions are wrong.&lt;/p&gt;
&lt;p&gt;That is far better than allowing insecurity to prevent you from trying.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;from-truck-driver-to-language-creator&quot;&gt;From Truck Driver to Language Creator&lt;/h3&gt;
&lt;p&gt;Bryan MacLee's journey is not a conventional story about becoming a software engineer and climbing a corporate career ladder.&lt;/p&gt;
&lt;p&gt;It is about someone who loves programming enough to question the tools he uses and attempt to build something different.&lt;/p&gt;
&lt;p&gt;His journey began with JavaScript, frustration with web development's complexity, curiosity about language design and one seemingly insignificant problem: naming a temporary variable.&lt;/p&gt;
&lt;p&gt;That small frustration grew into scrml, a compiled language with ambitions around state, type safety, application structure and compiler-driven correctness.&lt;/p&gt;
&lt;p&gt;The implementation is still evolving.&lt;/p&gt;
&lt;p&gt;The architecture is being reconsidered.&lt;/p&gt;
&lt;p&gt;And the project needs developers willing to test, question and contribute.&lt;/p&gt;
&lt;p&gt;But Bryan's motivation remains clear.&lt;/p&gt;
&lt;p&gt;He isn't building scrml simply to prove that he can build a programming language.&lt;/p&gt;
&lt;p&gt;He's building it because he believes programming can be made better — and because the act of creating software is, to him, one of the most remarkable things humans have ever learned to do.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;about-bryan-maclee&quot;&gt;About Bryan MacLee&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://coderlegion.com/user/Bryan+MacLee&quot;&gt;Bryan MacLee&lt;/a&gt;&lt;/strong&gt; is a truck driver specialising in the oil and gas industry and an independent programming-language developer.&lt;/p&gt;
&lt;p&gt;He is the creator of &lt;a rel=&quot;nofollow&quot; href=&quot;https://scrml.dev/&quot;&gt;scrml&lt;/a&gt;, an open-source compiled language for web development that generates HTML, CSS and JavaScript.&lt;/p&gt;
&lt;p&gt;His preferred technologies include JavaScript, HTML and CSS, and his interests include language design, compiler development, state management and reducing unnecessary complexity in web development.&lt;/p&gt;
&lt;p&gt;Connect with &lt;a rel=&quot;nofollow&quot; href=&quot;https://coderlegion.com/user/Bryan+MacLee&quot;&gt;Bryan MacLee on CoderLegion&lt;/a&gt;.&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;Bryan's story is a reminder that a good idea doesn't need to come from a conventional career path.&lt;/p&gt;
&lt;p&gt;Sometimes it starts with a simple frustration — and the willingness to ask:&lt;/p&gt;
&lt;hr&gt;
&lt;h4 id=&quot;interview-amp-story-by-mehadi-hasan&quot;&gt;Interview &amp;amp; Story by Mehadi Hasan&lt;/h4&gt;
&lt;p&gt;&lt;em&gt;CoderLegion Community &amp;amp; Editorial Team&lt;/em&gt;&lt;/p&gt;
</description>
<category>Dev Stories</category>
<guid isPermaLink="true">https://coderlegion.com/29769/programming-is-magic-bryan-maclees-journey-building-scrml</guid>
<pubDate>Sun, 04 Oct 2026 22:32:36 +0000</pubDate>
</item>
<item>
<title>Why C++ Compilers Prefer Performance Over Safety Checks?</title>
<link>https://coderlegion.com/3375/why-c-compilers-prefer-performance-over-safety-checks</link>
<description>&lt;p&gt;C++ is a language synonymous with performance, control, and portability. For decades, it has powered the world's most demanding software systems, from operating systems to game engines and real-time trading platforms. At the heart of its power lies a controversial feature: undefined behavior (UB). This feature, or rather lack of behavior definition, has led to immense performance gains but also to programming pitfalls. When modern C++ compilers like GCC and Clang prioritize performance, they do so by aggressively assuming that undefined behavior never occurs. In this article, we will explore why these compilers make such design choices, the benefits and trade-offs involved, and how developers can harness these tools responsibly.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;1-the-c-design-philosophy-trust-the-programmer&quot;&gt;1. The C++ Design Philosophy: Trust the Programmer&lt;/h3&gt;
&lt;p&gt;One of the key tenets of C++ is that it &quot;trusts the programmer.&quot; This trust is not blind; it is intentional and foundational. Unlike languages like Java or Python that emphasize safety and abstraction, C++ offers low-level memory and hardware access. It does so while striving for zero-overhead abstractions. The premise is that a knowledgeable programmer can write highly efficient code if the compiler doesn't impose runtime safety checks that might slow execution.&lt;/p&gt;
&lt;h4 id=&quot;control-and-efficiency&quot;&gt;Control and Efficiency&lt;/h4&gt;
&lt;p&gt;C++ gives developers precise control over resource management. You decide how memory is allocated, how objects are constructed, and when resources are released. This fine-grained control enables performance tuning at a level unmatched by most high-level languages.&lt;/p&gt;
&lt;h4 id=&quot;no-built-in-safety-net&quot;&gt;No Built-in Safety Net&lt;/h4&gt;
&lt;p&gt;By default, C++ does not include bounds checking, null pointer validation, or automatic garbage collection. This lack of safety net is a double-edged sword. On one side lies blazing speed and fine control. On the other, the danger of undefined behavior.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;2-what-is-undefined-behavior-&quot;&gt;2. What is Undefined Behavior?&lt;/h3&gt;
&lt;p&gt;In the context of C++, undefined behavior refers to code that does not have a well-defined effect according to the C++ standard. When such code is executed, anything can happen. It may crash the program, produce unexpected results, or appear to work fine (only to break later).&lt;/p&gt;
&lt;h4 id=&quot;common-sources-of-ub&quot;&gt;Common Sources of UB&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Dereferencing null or dangling pointers&lt;/li&gt;
&lt;li&gt;Accessing array elements out of bounds&lt;/li&gt;
&lt;li&gt;Using uninitialized variables&lt;/li&gt;
&lt;li&gt;Violating strict aliasing rules&lt;/li&gt;
&lt;li&gt;Shifting integers by more than their width&lt;/li&gt;
&lt;li&gt;Modifying a variable more than once between sequence points&lt;/li&gt;
&lt;li&gt;Invoking functions through function pointers with the wrong signature&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;These are not bugs that merely produce wrong results; they allow the compiler to &lt;strong&gt;assume&lt;/strong&gt; they never happen.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;3-why-compilers-exploit-undefined-behavior&quot;&gt;3. Why Compilers Exploit Undefined Behavior&lt;/h3&gt;
&lt;p&gt;Both GCC and Clang are highly optimizing compilers. They use undefined behavior as a license to transform code under the assumption that such errors never occur. This leads to several advantages:&lt;/p&gt;
&lt;h4 id=&quot;a-dead-code-elimination&quot;&gt;a. Dead Code Elimination&lt;/h4&gt;
&lt;p&gt;Consider the following:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-cpp&quot;&gt;if (ptr != nullptr) {
   *ptr = 10;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If the compiler determines that &lt;code&gt;ptr&lt;/code&gt; is never null (or that dereferencing null is UB), it might remove the check entirely, resulting in more streamlined code.&lt;/p&gt;
&lt;h4 id=&quot;b-loop-optimizations&quot;&gt;b. Loop Optimizations&lt;/h4&gt;
&lt;p&gt;UB assumptions allow the compiler to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Unroll loops&lt;/li&gt;
&lt;li&gt;Perform strength reduction&lt;/li&gt;
&lt;li&gt;Vectorize operations for SIMD instructions&lt;/li&gt;
&lt;li&gt;Parallelize independent iterations&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;c-constant-folding-and-propagation&quot;&gt;c. Constant Folding and Propagation&lt;/h4&gt;
&lt;p&gt;If a branch or operation leads to UB under certain conditions, compilers may discard it entirely or simplify control flow under the assumption that such branches are never taken.&lt;/p&gt;
&lt;h4 id=&quot;d-register-allocation-improvements&quot;&gt;d. Register Allocation Improvements&lt;/h4&gt;
&lt;p&gt;Assuming UB allows for more flexible reuse of registers, reducing memory access and increasing pipeline throughput.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;4-benefits-of-this-approach&quot;&gt;4. Benefits of This Approach&lt;/h3&gt;
&lt;h4 id=&quot;4-1-performance&quot;&gt;4.1 Performance&lt;/h4&gt;
&lt;p&gt;By ignoring checks and relying on the programmer's correctness, the compiler produces leaner, faster machine code. In performance-critical domains (e.g., embedded systems, high-frequency trading), even a 1-2% gain can be significant.&lt;/p&gt;
&lt;h4 id=&quot;4-2-simpler-compiler-internals&quot;&gt;4.2 Simpler Compiler Internals&lt;/h4&gt;
&lt;p&gt;When the compiler is allowed to assume certain operations never happen (like null pointer access), it simplifies the internal logic for code generation and optimization passes.&lt;/p&gt;
&lt;h4 id=&quot;4-3-portability&quot;&gt;4.3 Portability&lt;/h4&gt;
&lt;p&gt;This model ensures the same code can run efficiently across different platforms without runtime dependencies like garbage collectors or VM-based safety checks.&lt;/p&gt;
&lt;h4 id=&quot;4-4-greater-flexibility-for-developers&quot;&gt;4.4 Greater Flexibility for Developers&lt;/h4&gt;
&lt;p&gt;Developers who understand their system well can fine-tune performance and optimize memory usage, trading safety for precision when necessary.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;5-the-cost-dangerous-flexibility&quot;&gt;5. The Cost: Dangerous Flexibility&lt;/h3&gt;
&lt;h4 id=&quot;5-1-debugging-nightmares&quot;&gt;5.1 Debugging Nightmares&lt;/h4&gt;
&lt;p&gt;Because UB can manifest unpredictably, bugs are often hard to detect. Code that works on one compiler version may break on another. Debuggers might show misleading or inconsistent information when UB is triggered.&lt;/p&gt;
&lt;h4 id=&quot;5-2-security-vulnerabilities&quot;&gt;5.2 Security Vulnerabilities&lt;/h4&gt;
&lt;p&gt;Many buffer overflows and privilege escalation exploits originate from UB that goes unchecked during development. Attackers exploit these flaws to insert malicious code, steal data, or crash systems.&lt;/p&gt;
&lt;h4 id=&quot;5-3-non-deterministic-behavior&quot;&gt;5.3 Non-deterministic Behavior&lt;/h4&gt;
&lt;p&gt;A program might behave differently on each run or platform due to optimizations exploiting UB. This leads to issues in testing, especially in distributed or multithreaded applications.&lt;/p&gt;
&lt;h4 id=&quot;5-4-loss-of-portability&quot;&gt;5.4 Loss of Portability&lt;/h4&gt;
&lt;p&gt;Code relying unknowingly on UB may work on one architecture but fail on another. For example, pointer alignment or endianness assumptions may cause subtle and hard-to-detect issues.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;6-mitigation-strategies-for-developers&quot;&gt;6. Mitigation Strategies for Developers&lt;/h3&gt;
&lt;h4 id=&quot;6-1-use-static-analysis-tools&quot;&gt;6.1 Use Static Analysis Tools&lt;/h4&gt;
&lt;p&gt;Tools like &lt;code&gt;Clang-Tidy&lt;/code&gt;, &lt;code&gt;Cppcheck&lt;/code&gt;, and &lt;code&gt;Coverity&lt;/code&gt; help detect UB patterns in source code before runtime. They analyze control flow, memory access patterns, and data usage.&lt;/p&gt;
&lt;h4 id=&quot;6-2-enable-compiler-sanitizers&quot;&gt;6.2 Enable Compiler Sanitizers&lt;/h4&gt;
&lt;p&gt;Compiler sanitizers are invaluable for catching UB during testing:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;-fsanitize=undefined&lt;/code&gt;: Catches most UB issues like invalid casts or pointer arithmetic&lt;/li&gt;
&lt;li&gt;&lt;code&gt;-fsanitize=address&lt;/code&gt;: Detects heap buffer overflows, use-after-free&lt;/li&gt;
&lt;li&gt;&lt;code&gt;-fsanitize=thread&lt;/code&gt;: Catches race conditions in multithreaded programs&lt;/li&gt;
&lt;li&gt;&lt;code&gt;-fsanitize=leak&lt;/code&gt;: Helps track memory leaks&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;6-3-adopt-safe-subsets&quot;&gt;6.3 Adopt Safe Subsets&lt;/h4&gt;
&lt;p&gt;Frameworks like MISRA-C++ or AUTOSAR C++ define subsets of the language that eliminate or constrain UB-prone features. These are essential in safety-critical industries like automotive and aerospace.&lt;/p&gt;
&lt;h4 id=&quot;6-4-use-modern-c-features&quot;&gt;6.4 Use Modern C++ Features&lt;/h4&gt;
&lt;p&gt;Prefer smart pointers (&lt;code&gt;std::unique_ptr&lt;/code&gt;, &lt;code&gt;std::shared_ptr&lt;/code&gt;), &lt;code&gt;std::optional&lt;/code&gt;, &lt;code&gt;std::variant&lt;/code&gt;, &lt;code&gt;std::array&lt;/code&gt; over raw pointers and C-style arrays. These features enforce safer access and clearer intent.&lt;/p&gt;
&lt;h4 id=&quot;6-5-enforce-code-reviews-and-testing&quot;&gt;6.5 Enforce Code Reviews and Testing&lt;/h4&gt;
&lt;p&gt;Robust peer reviews and extensive unit/integration testing help catch unintended UB before code reaches production.&lt;/p&gt;
&lt;h4 id=&quot;6-6-leverage-formal-verification-advanced-&quot;&gt;6.6 Leverage Formal Verification (Advanced)&lt;/h4&gt;
&lt;p&gt;For critical systems, formal methods can be used to prove the absence of UB under all conditions using mathematical techniques.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;7-why-not-just-eliminate-ub-&quot;&gt;7. Why Not Just Eliminate UB?&lt;/h3&gt;
&lt;p&gt;Eliminating undefined behavior would fundamentally change what C++ is:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;More runtime checks would degrade performance.&lt;/li&gt;
&lt;li&gt;It would become more like Java or Rust.&lt;/li&gt;
&lt;li&gt;Backward compatibility with decades of C/C++ code would break.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;UB is a deliberate, though controversial, part of the design. It is the price for raw power and flexibility.&lt;/p&gt;
&lt;p&gt;Languages like Rust take a different path: they eliminate most classes of UB at compile time through strict ownership and borrowing rules. But this comes at the cost of a steeper learning curve and more restrictive coding patterns.&lt;/p&gt;
&lt;p&gt;C++ allows expert programmers to write fast code with minimal abstraction costs, but the responsibility lies with the programmer to avoid UB through discipline and tooling.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;8-real-world-use-cases-embracing-ub-for-speed&quot;&gt;8. Real-World Use Cases Embracing UB for Speed&lt;/h3&gt;
&lt;h4 id=&quot;8-1-operating-systems&quot;&gt;8.1 Operating Systems&lt;/h4&gt;
&lt;p&gt;Linux kernel code is filled with performance-critical sections that rely on UB being carefully avoided but never checked. Kernel developers rely on strict coding guidelines and peer review to manage UB risk.&lt;/p&gt;
&lt;h4 id=&quot;8-2-game-engines&quot;&gt;8.2 Game Engines&lt;/h4&gt;
&lt;p&gt;Engines like Unreal Engine are written in C++ with heavy use of UB-ignoring constructs for maximum speed. Real-time rendering and physics engines must meet frame deadlines every few milliseconds.&lt;/p&gt;
&lt;h4 id=&quot;8-3-trading-systems&quot;&gt;8.3 Trading Systems&lt;/h4&gt;
&lt;p&gt;Low-latency trading platforms depend on compiler-optimized binaries where every nanosecond counts. Programmers in this domain carefully avoid UB through disciplined coding and extensive testing.&lt;/p&gt;
&lt;h4 id=&quot;8-4-embedded-systems&quot;&gt;8.4 Embedded Systems&lt;/h4&gt;
&lt;p&gt;In microcontrollers and IoT firmware, memory and processing power are limited. Developers must write tight, efficient code and often disable runtime checks, accepting the trade-offs of UB.&lt;/p&gt;
&lt;h4 id=&quot;8-5-scientific-simulations&quot;&gt;8.5 Scientific Simulations&lt;/h4&gt;
&lt;p&gt;High-performance computing (HPC) relies on C++ to run simulations on massive datasets. UB assumptions allow compilers to fully exploit hardware capabilities.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;9-compiler-flags-that-matter&quot;&gt;9. Compiler Flags That Matter&lt;/h3&gt;
&lt;p&gt;GCC and Clang both offer many flags to control optimization and UB behavior:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;-O2&lt;/code&gt;, &lt;code&gt;-O3&lt;/code&gt;: Enable aggressive optimizations&lt;/li&gt;
&lt;li&gt;&lt;code&gt;-fstrict-aliasing&lt;/code&gt;: Assumes pointers don’t alias unless explicitly cast&lt;/li&gt;
&lt;li&gt;&lt;code&gt;-fno-strict-overflow&lt;/code&gt;: Prevents assuming signed integer overflow is UB&lt;/li&gt;
&lt;li&gt;&lt;code&gt;-fsanitize=&lt;/code&gt;: Enables various runtime checks&lt;/li&gt;
&lt;li&gt;&lt;code&gt;-Wall -Wextra&lt;/code&gt;: Turns on helpful warnings&lt;/li&gt;
&lt;li&gt;&lt;code&gt;-pedantic&lt;/code&gt;: Enforces strict standard compliance&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id=&quot;recommended-combinations&quot;&gt;Recommended Combinations&lt;/h4&gt;
&lt;p&gt;For development:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;g++ -O0 -g -fsanitize=undefined,address -Wall -Wextra
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;For production:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;g++ -O3 -fstrict-aliasing -fomit-frame-pointer
&lt;/code&gt;&lt;/pre&gt;
&lt;hr&gt;
&lt;h3 id=&quot;10-conclusion-master-the-power-respect-the-danger&quot;&gt;10. Conclusion: Master the Power, Respect the Danger&lt;/h3&gt;
&lt;p&gt;C++ gives you a powerful toolset, but with it comes responsibility. GCC and Clang prioritize performance because that’s what the language promises: speed without overhead. Undefined behavior is not a mistake in the spec; it's a contract with the programmer. The compiler trusts you not to invoke UB, and in return, it gives you unmatched performance.&lt;/p&gt;
&lt;p&gt;To use C++ effectively:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Understand the risks of undefined behavior&lt;/li&gt;
&lt;li&gt;Use the right tools to catch it early&lt;/li&gt;
&lt;li&gt;Write clean, testable, standards-compliant code&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In the world of systems programming, performance often trumps safety—but with the right knowledge and practices, you don’t have to choose between them.&lt;/p&gt;
&lt;h4 id=&quot;final-thoughts&quot;&gt;Final Thoughts&lt;/h4&gt;
&lt;p&gt;While undefined behavior may seem like a flaw, it is in fact a feature that empowers developers to write some of the fastest code in the world. If used with care, and backed by tooling and discipline, it allows C++ to remain at the forefront of high-performance software engineering.&lt;/p&gt;
</description>
<category>C++</category>
<guid isPermaLink="true">https://coderlegion.com/3375/why-c-compilers-prefer-performance-over-safety-checks</guid>
<pubDate>Fri, 20 Jun 2025 09:24:12 +0000</pubDate>
</item>
</channel>
</rss>