DEV Community

Lopy
Lopy

Posted on

Luna Compiler Devlog #1

Hey all!

Introduction

I got curious about how languages like C++ or Rust does work and wanted to make my own. I use Luau (lua but typed) on my daily, but it is an interpreted language, so I wanted to make it work in native (binary).

Overview

I've started this proyect using Rust, LLVM bindings (inkwell) and a Luau parser, I got the most dummy program working:

return 2
Enter fullscreen mode Exit fullscreen mode

When I run the binary, the exit code is 2. I'm really new to compilers and this is my first one. I know this will be a very hard and ambitious project, but at least I want something functional, maybe not for daily usage.

Compilation process

Well, the Rust project only takes the .luau file and emits an object file (.obj/.o) and also I have another Rust project (yes, I'm using cargo's workspaces) that takes that object file and converts it into a binary file using the LLVM toolset (clang).

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay