How Cyclone was concieved, and Why?

How Cyclone was concieved, and Why?

Before we dive into the How the Cyclone was concieved, let's first understand Why.

Just, Why?

Honestly, I don't remember. As far as I know, 6 months before writing of this blog, I started learning how a Programming Language is designed and how its Compiler is built. Why I started learning this? I don't know. Maybe I was bored, maybe I wanted to learn something new, or maybe my fleeble mind, in its dazed state of some midnight's stupor, conjured up the thought that it would be a good idea.


Image

Sometimes I think, then I forget.

Maybe while working on Code Generation in BuildDubs for DubsUI the Idea that instead of generating code for a language, why not build a language itself, struck me. Maybe it goes futher back than that, might be that learning about Design Principles of Programming Lanugages (DPPL) inspired me.

Whatever the reason might be, here we are, 6 months later, having created a Programming Language from scratch, Cyclone, with its own Compiler and Interpreter.

Here's how I started with Cyclone.

Turbulant Beginnings

When I started learning, I didn't have any idea of where to start. So, like any sane person does, I searched it on YouTube. While it did return some results, none of them were as extensive and through as I wanted. Many only talked about surface level theory, and some that did go into depth, were series of 1 - 2 hour long videos, spanning over 10 - 20 videos.

So, intead of watching 20 hours of videos, I decided to refer books, and that's the story of how I ended up wasting 6 months istead of 20 hours.

Image

Oh god, Why did I take the red pill? WHY?

Still, Keith Cooper's and Linda Torczon's book, Engineering a Compiler, and Compilers: Principles, Techniques, and Tools, also called The Dragon Book proved very insightful.

Especially the Engineering a Compiler took me down the rabbit hole of Compiler Design, and I was hooked. I started learning about Lexical Analysis, Parsing, Semantic Analysis, Intermediate Code Generation, Code Optimization, and Code Generation.

But instead of boring you with compiler jargon here, let's talk about Cyclone. If you want to learn about more technical details of Cyclone, you can find it in this blog post How Compilers are Made.

Realizing how dimwitted I was

4 months down the line, I was already in too deep with Compiler Design. In that time I had created and published DubsUI, designed and build the website builder BuildDubs and had started working on a non-public project. Through it all, I was learning about compilers on the side.

Truthfully, by this time I had already accepted the horrendous but not surprising fact that I was stupid. Stupid to have started such project when I could have been doing anything else. But, I was too deep in to back out now.

Image
No turning back now.

Inspiration for Cyclone

Knowing that I was falling for the classic Sunk Cost Fallacy, but being unable to do anything about it, I pushed through.

I spent next month scouring the source code of well-established compilers, Parser generators, and Lexical Analyzers, trying to get gist of their inner workings.

The one that has influenced Cyclone the most is Roslyn. Roslyn is the open-source .NET Compiler Platform, which provides C# and Visual Basic compilers. That's why you'll find many similarities between Cyclone and Roslyn compiler-frontend.

Coding Cyclone

In the last month, I started coding Cyclone. I started on 20th October, and by 10th November (with break of 5 days from 27th October to 2nd November for another project), I had a working version of Cyclone. Last few days were spent on fixing bugs, writing documentaion and creating Online Compiler.

Future plans

When I say Frontend and Backend, I mean in terms of Compiler Design not Web Development:

  • Frontend of Compiler includes Lexical Analysis, Parsing, and Semantic Analysis.
  • Backend of Compiler includes Intermediate Code Generation, Code Optimization, and Code Generation.

Currently, the only way to describe Cyclone is through meme:

Image

Frontend of Compiler (Lexical and Semantic Analysis) and Backend of Compiler(Code Optimization and Generation)

In future, I hope to add ability to emit native Assembly code for x86, x86_64, ARM, and RISC-V architectures. I also plan to add more features to the language, like Generics, Enums, and more. But, that's for future.

Hope you enjoyed this blog post. If you have any questions or feedback, feel free to reach out to us.

Happy coding!



The Three Dubs,

DevsTomorrow,

@jayshiai


    Theme

    Presets

    Background

    Custom:

    Primary

    Custom:

    Secondary

    Custom:

    Border

    Custom:

    Mode

    Light
    Dark