Create own programming language (OOP)

Is there an example project available on how I can build my own programming language? I would like to create a compiler for a new OOP language with LLVM, but I can’t find a way to get started.

The idea is a Java-like programming language, but with different requirements.

  • Fully object-oriented

  • Fully typed

  • Native code

  • Generics

  • No virtual machine

  • No byte code

  • No scripting

  • No header files like in C++

  • No multiple inheritance

If possible, unsigned data types should also be available.

I would reconmend you to start learning llvm using the Kleidoscope tutorial: My First Language Frontend with LLVM Tutorial — LLVM 20.0.0git documentation

Unfortunately, this example doesn’t help me.

What exactly do you need help with in this case? Writing a new language from scratch is a huge task and require a lot of experimentation, this guide shows you how to get started with writing a language on top of LLVM, sure that toy language doesn’t really support all of the features you want, but it should be enough for you to get to “Hello world”.

Hi!

Is this your first try at making a language?

If this is your first try at creating a language, I recommend starting with something like Introduction · Crafting Interpreters
r/ProgrammingLanguages is also a great community that helped me quite a bit when I first got into PL design, their Discord is very active and friendly.
Learning LLVM can come at a much later stage once you have a language specification and you’re well into creating a frontend for it.

I also recommend starting very small, and progressing in small steps, one feature at a time. Start by making a simple compiler that processes expressions, then add variables, functions, conditionals, etc.
(If you want I can elaborate a bit on what roadmap I’d personally recommend, I’ve been there before; most of my compiler knowledge is self-taught)

OOP and Generics are, IMHO, very late stage features that need a lot of careful planning and designing before you even write a line of code for them.

I haven’t used it myself, but a tutorial language with objects is Cool, part of a Stanford course - search for “stanford cool language”. You’d still need the LLVM information.

A working example with object orientation would help me. It’s easier for me to have a working project to experiment with instead of constantly looking at these toy projects where nothing works.