DEV Community

Discussion on: We created the Crystal language, ask us anything!

maestromac profile image
Mac Siri

In the shortest steps possible, how does one go about creating a new programming language?

asterite profile image
Ary Borenszweig
  1. Create a repository
  2. Start with a very basic language, with very few features (maybe only support numbers)
  3. Write a lexer, parser and AST for it
  4. Write semantic analysis over the AST
  5. Turn the AST into executable code (this is relatively easy if you use LLVM)

That's at least for a compiled language. Steps 4 and 5 would be replaced with an interpreter.

There are plenty of tutorials on the web on how to write you own language. What I always like to say is that a language is just a tool like "ls", "cat", or any application you develop: you take some input, analyze it and produce some output.

The tricky parts are:

  • Ending up with a language you like, but others like too
  • Ending up with a consistent language (this is really hard)
  • Thinking about all the language pieces at the same time

That's at least the technical part of it. The community part is a whole world of its own, tackling issues and PRs, and I'd say it's even more challenging (but also rewarding!) than developing the language itself :-)

sdogruyol profile image
Serdar Dogruyol

Wow, one of the best answers I've ever heard about creating a programming language :) Thanks Ary!

Thread Thread
ben profile image
Ben Halpern

Yeah, loved it!