Ask HN: In which programming language is it better to make your own language?

5 Forgret 10 8/9/2025, 2:36:05 PM
I decided to create my own programming language but I don't know which one to use, some say Python, others say C.

Please help me decide.

Comments (10)

twosdai · 3m ago
This doesn't answer your question. But it would be an interesting project to try and make a programming language where you as the dev only and solely use an llm to do all the work.

So then you could say it was programmed in english*

*Or whatever human language you want.

jokoon · 13m ago
I used lexy, which is a great C++ parser combinator.

I then used python match syntax to convert my ast to C.

ForceBru · 1h ago
Some years ago I used the Python library Lark (https://github.com/lark-parser/lark) to parse my programming language. It lets you write your grammar in basically EBNF, builds parse trees (that you can automatically reduce by removing leaves for parentheses, for example) and generates standalone pure-Python LALR(1) parsers for your grammar. Back then, I had a blast with it, it was fast, super easy to use and just worked. Now it's got 5k stars and seems to be a mature and production-ready library.

Thus, I vote Python: it has this amazing parser library, it's garbage-collected (no need to fiddle with memory allocations, like in C), it's dynamically typed (so you basically don't need to think about types at all), it now has a `match` statement (!) that makes it super easy to dissect your parse trees and abstract syntax trees.

Forgret · 52m ago
Hmm, sounds appealing, and I agree, C is still pretty complicated and the slow speed of the program is not that critical, in exchange for this wonderful library that will save me a lot of time, unlike C.
stargrazer · 54m ago
Use C++ with one of the following:

Boost.Spirit https://www.boost.org/library/latest/spirit/ Boost.Parser https://www.boost.org/library/latest/parser/ (which I think succeeds Boost.Spirit Boost.Metaparse: https://www.boost.org/doc/libs/latest/doc/html/metaparse.htm...

All of these allow you to build a parser using C++ syntax and then add semantic or composed actions.

thesuperbigfrog · 2h ago
Prototype in Python with PLY (https://github.com/dabeaz/ply) or you could try Raku (https://raku.org/) which has nice functionality for building grammars.

After you know what you want to build, you could convert it to C, C++, or Rust to make it fast.

Forgret · 2h ago
Thanks, that sounds interesting, I'll try to find out more information about it, and maybe use your advice.
john-h-k · 1h ago
OCaml
wslh · 2h ago
Well, ANTLR[0] includes many programming language targets. I can also recommend OMeta [1] for quick prototyping. Other developers has implemented it in JS, .NET, etc. I just found Panini[2] in Rust but I am sure you can find others[3].

[0] https://www.antlr.org/

[1] https://en.wikipedia.org/wiki/OMeta

[2] https://github.com/pczarn/panini

[3] https://github.com/topics/parser

Forgret · 1h ago
Thank you, for these materials you have helped me a lot to understand everything better.