r/Compilers • • 27d ago

Building a native compiler for my own programming language using Rust and Cranelift

I'm developing a programming language called NORTEX, and one of the central parts of the project is its own compiler.

The compiler, called nortexc, is written in Rust and uses Cranelift for native x64 code generation.

The goal is to compile .nx source files into Windows executables that can run without a separately installed NORTEX runtime.

The project also includes a custom IDE with an editor, IntelliSense, console and other development tools.

Recent compiler progress:

I've implemented additional functionality for:

  • Text manipulation (Text.trim, Text.replace, etc.)
  • String conversion (Convert.toString)
  • File reading (File.readAllText)
  • File writing (File.writeAllText)

Example:

public int main() {
    File.writeAllText("test.txt", "  NORTEX  ");

    string value = Text.trim(File.readAllText("test.txt"));

    Console.writeLine(value);

    return 0;
}

Current limitations:

The language is still early in development. Native floating-point numbers, lists and classes are not implemented yet.

I'm developing this as a solo project, so I'm particularly interested in avoiding architectural mistakes before the language becomes more complex.

Questions for compiler developers:

  • What should I prioritize when designing the compiler architecture?
  • How important is a formal language specification at this stage?
  • What are common mistakes when using Cranelift for a custom language?
  • Which compiler tests would you consider essential?

I'd appreciate honest technical feedback.

4 Upvotes

2 comments sorted by

2

u/Friendly_Disk8193 27d ago

How can one provide an honest technical feedback if you haven’t shared the source code? Are you simply describing the capabilities of the language and runtime in the abstract, and then asking for feedback? If you genuinely want a review, please elaborate on some of the more interesting aspects of the implementation, what challenges did you encounter during development? You mention that classes haven’t been implemented yet, so how are you invoking methods in your example? Are these functions within a namespace, or are they static functions? It’s unclear...