oracle / graal

GraalVM compiles Java applications into native executables that start instantly, scale fast, and use fewer compute resources 🚀
https://www.graalvm.org
Other
20.28k stars 1.63k forks source link

Requesting in-depth tutorial on Simple Language creation, from the very start to the end #4168

Open rishavs opened 2 years ago

rishavs commented 2 years ago

Feature request

Please include the following information:

Is your feature request related to a problem? Please describe. as programmer with intermediate skills, I am unable to make any headway into creating a toy language with Truffle as the documentation is simply not good enough. For someone new to the ecosystem, it is not clear how to even start - what tools to use for the lexing/parsing.

Describe the solution you'd like. An in depth tutorial using the Simple language (or a real world small language like lua) would be great, where we can start from the very scratch and look at every stage of the language creation - including lexing/parsing - and all the way to running sample programs on the completed compiler.

Describe who do you think will benefit the most. New users to Graal/Truffle.

Describe alternatives you've considered. Not a lot of alternatives. There are only 2-3 tutorials on Truffle and they are all not very beginner friendly.

eregon commented 2 years ago

I think there are already several existing resources which introduce Truffle: https://www.graalvm.org/graalvm-as-a-platform/language-implementation-framework/

And I know of the following blog post series:

An official tutorial would of course be better.

OTOH I don't think a Truffle tutorial should explain (in depth) what is parsing, etc.

what tools to use for the lexing/parsing.

A short answer is: anything you want, the only requirement is you need to be able to create Java node objects in the end for AST nodes, so a parser written in Java is probably easiest. You can parse however you like (manually-written recursive descent, LALR, PEG, etc) and for an existing language it's of course easier to use an existing parser in Java if there is, or the grammar.

In general, it's easier to start by implementing an existing language or a subset of it, otherwise you have two tasks at hand instead of one: designing a new language and implementing it.

fniephaus commented 2 years ago

It doesn't solve this issue but I wanted to mention that there's going to be a Truffle workshop at ECOOP'22: https://2022.ecoop.org/home/truffle-2022