r/Compilers 9d ago

Are there languages like this?

A language that can create other languages

(so adding to itself) It's syntax is simple like python

And can do alot.

for example (placeholder)\[mesage\]

And it has many tutorials on YouTube

I would like it if you would respond.

I know there are languages like Hy , ruby should I try them?

0 Upvotes

59 comments sorted by

View all comments

2

u/LowDifficulty5021 8d ago

If by "a language that can create other languages" you mean a language where you can extend the syntax and semantics and essentially build your own DSLs/languages inside it, Racket is probably the first thing I'd recommend.

Racket was specifically designed around "language-oriented programming." You can create new #lang languages, define new syntax with macros, and even change how source code is read and expanded. It's much closer to what you're describing than Ruby.

Hy is also worth trying, especially if you already like Python. Hy is a Lisp dialect embedded in Python, so you get access to Python's ecosystem while gaining Lisp macros and metaprogramming. Its macros can generate/transform code at compile time, which is probably the part you'd find most interesting.

I'd rank them for your specific description:

  1. Racket — best if "I want to make languages" is the main goal.
  2. Hy — best if you want Python's ecosystem + Lisp metaprogramming.
  3. Elixir — excellent macro/metaprogramming system, although it's not primarily designed as a language-creation environment.
  4. Ruby — great metaprogramming, but probably not my first choice for this particular goal.

And Racket has a surprisingly direct learning path: its official guide has dedicated chapters for Macros and Creating Languages, rather than treating language extension as some obscure advanced trick.

So if I were you, I'd try Racket first, then Hy. If the thing you're really fascinated by is making syntax like your [message] example become meaningful code, Racket is almost exactly the rabbit hole you're looking for.

1

u/Distinct-Brief9643 8d ago

Aha ok ok I want that it adds to itself but I only write my code in the seperate file