Introduction to rinha-de-compiler
The "rinha-de-compiler" project is an intriguing venture focused on developing an interpreter or compiler capable of running on a machine with modest specifications—such as 2 CPU cores and 2GB of RAM. This project revolves around processing and interpreting an "abstract syntax tree" (AST) formatted in JSON. This AST is generated specifically with a tool available within the project's repository.
Key Objectives
The primary goal is straightforward:
- The team provides a JSON file containing an abstract syntax tree.
- Participants execute this JSON, performing interpretation or compilation based on its contents.
- Successful execution leads to obtaining the desired results.
Execution
Each participant's project must include a Dockerfile
, ensuring the ease of execution within a Docker environment.
Testing Process
Participants are encouraged to test their work using provided resources. For instance, the file files/fib.rinha
can be used to generate a JSON file or participants may directly utilize files/fib.json
to test their compiler or interpreter. The project includes various test cases beyond just the Fibonacci sequence to ensure versatility and robustness.
Requirements and Contributions
To contribute:
- Participants must create a Pull Request (PR) updating the PARTICIPANTS.md file with a link to their repository.
- Each repository should include a root image for ranking purposes.
Specification
The language interprets or compiles scripts based on AST JSON files located at:
/var/rinha/source.rinha.json
- Or manually read from
/var/rinha/source.rinha
This programming language is dynamic, reminiscent of languages like JavaScript and Ruby. The completion of this project involves a JSON "interpreter" which processes ASTs and verifies the compiled code through various algorithms beyond the standard Fibonacci example.
Example Code
Here is a simple script example calculating Fibonacci numbers:
let fib = fn (n) => {
if (n < 2) {
n
} else {
fib(n - 1) + fib(n - 2)
}
};
print("fib: " + fib(10))
Competition Details
Participants had until September 23 to submit their initial Pull Requests (PRs), with a subsequent adjustment period open until September 27, allowing for refinement of implementation upon release of testing phases.
Ranking and Results
The results are displayed in a ranked table, showcasing the top performers with pertinent data such as their language of choice, type of implementation, and points scored.
Additional Resources
For those embarking on creating their own interpreter or compiler, several resources are provided to guide and educate:
- Video tutorials and comprehensive guides
- Useful links:
Conclusion
With the "rinha-de-compiler" project, participants engage in an exciting challenge that combines computer science fundamentals with practical application, fostering a deeper understanding of language processing and interpreting within constrained environments. This initiative not only tests coding and problem-solving skills but also encourages innovation within a collaborative community setting.