Introduction
Hi maintainers (and interested watchers),
For the last few weeks I’ve been experimenting with the idea of having a centralised system for generating representations, analysing code, and creating snippets, rather than having individual tools. I’ve now got to the stage where I’m certain this is the route forward we’ll take.
It is not yet ready for review, but as there’s been lots of talk about adding/improving analyzers/representers, and Bethany’s work in updating the Python track to the latest version involves involves regenerating millions of representations, I wanted to flag it now so people don’t invest tons of work into systems we will replace, but can also get excited about this world becoming much easier to get into.
Rosetta
My motivations for doing this are three-fold:
- Making it more accessible to contributors, so we can improve the breadth of tracks that have analyzers and representers.
- Making this whole system much faster so we can do more with it.
- Making the whole system lots cheaper, so we can regenerate things as and when we need to.
I’ve now got to the point where I’ve got a single repository that does everything all the existing tooling does, using tree-sitter grammars. It effectively turns every language into the same system that we can work with consistently. The project is called Rosetta.
Rosetta is about 3000x faster than any of the existing tools as it doesn’t need to compile code using real compilers. It can generate a representation, analyze the solution, and create a snippet sequentially in about 2ms, whereas this currently takes about 4-8s for existing tracks. (To put that into a wider perspective, that means generating the millions of Python representations will take half an hour, rather than 23 days).
I’ve created a DSL that makes it very easy to add things and is very readable. I’ve also left the ability to write manual code in case you want to go beyond the DSL too, but my aims is that 99% of the time, we can use the DSL to achieve what we want.
I’ve ported all the representer normalisations and all¹ the analyzer rules across all languages that have them.
Some comparisons using Elixir, as it’s one of the best and most complete tracks for all tools:
- Snippet: old vs new
- New Representer stages: rules, normalise and reorder.
- Analyzer for Lasagna exercise: old vs new (DSL-based)
This same DSL will work across all languages.
There’s a dedicated transition folder that goes into detail on any changes in languages (for languages with existing tooling, there’s quite a few bugfixes, and for those without it explains the decisions made by the new representers). I’m still manually working through these to check any regressions etc.
Plan for launching it
Again, this is not yet ready for review. I’m still working through everything, improving and expanding. the DSL, etc.
My aim is to launch this some time in the next 6 weeks. To start with, I intend to just sub out the existing systems for this, then regenerate representations for all solutions.
But then there’s so much more we can do. We can generate analysis and representations effectively instantly - whenever students run tests or quickly before they submit, which gives us tons of new potential opportunities.
And it’s really easy to add analysis now. If you want to say “Make sure the student doesn’t use this library”, you can do in one line. If you want to look for different patterns that’s students use, and block on bad ones, you can write some more complex rules (e.g. Ruby TwoFer). LLMs understand this very easily. You can give an LLM a solution to an exercise and say “If the student does XYZ, leave this comment” and it will write those rules very easily. And we have tons of golden tests in the repository which give me a lot of confidence about how it works.
Reflections
In line with the letter I sent to maintainers this week, this is a good example of something that has been very humbling. I spent a lot of time exploring tree-sitter when we were originally considering analyzers/representers years ago, and there have been several well-funded, failed, projects to unify ASTs into one system. It all seemed pretty impossible. And now Claude has created dozens of tree-sitter grammars and a whole system to use them in a couple of days².
I will be sad to see the existing code retired, as I and many of you put a huge amount of effort into that, but all of that product-thinking and the ideas and rules we created are still in Rosetta. Over the last year, there’s only been a handful of meaningful improvements to the analyzers/representers so I see those projects as having stalled, largely due to the complexity of them and the lack of time of our their original creators. I hope now there’s a central system we can get a lot more momentum in adding more rules across tracks, from a more time-rich group in the community.
The one thing I’ve not decided on yet is linting. Some tracks have analyzers that are either partially or entirely linters. I don’t think moving those bits into Rosetta will work, so I need to decide whether to keep those in the current state or do something else with them. I think linting is different to educational feedback anyway, so I think having the more formal split is good, and we should treat linting output differently in the product journey.
I will let you know when things are ready to dig into (although feel free to explore if you’re curious!), and I’m happy to answer any questions you have! ![]()
¹ all but one or two that I’m not sure we care about. We can bring them over - it’s just a lot of code for little gain.
² This has also been a good example of Claude being able to do stuff, but it being quite horrible code, and lots of stupid ideas. I’ve had to take it through a lot of iterations to get to a point where I’m comfortable enough to believe in this, and there are more to come pre-launch.