Table of Contents
Husht
This project aims to fill a niche for Rust broadly along the lines of CoffeeScript for JavaScript or Civet for TypeScript: provide all the resources and power of the Rust language via a clean, non-redundant, significant-whitespace syntax. Husht will be just Rust, but quieter. As such, the project is not looking to gratuitously alter syntax, but instead, to do things in a Rust-y way, while allowing less typing and less "line noise" in a source file. As a point of guidance, where the Civet decision on how to handle a language construct is "Rust-compatible," that will be taken as one item in favor of making a similar decision for Husht syntax, as a significant amount of thought has gone into construction of the Civet syntax.
Implementation plan
Here are some key ideas of how the plan will be accomplished.
- The Husht syntax engine will be two-way: it should be able both to convert Husht syntax to fully correct Rust, but also take a Rust file and produce a Husht file with the same semantics. The Rust -> Husht -> Rust roundtrip should be basically equivalent to running
rustfmt
on the original file. - Implementation will start with Husht == Rust, and use the tree-sitter grammar for Rust to produce tree-sitter parse trees for "Husht" (=Rust) code, which will be transformed into essentially the same trees as rustc_parse would produce (in Rust's own ast structure), and then use the rustfmt code generator to produce Rust code. In the other direction, we will use rustc_parse itself, and likely use algorithms from the prettyplease pretty printer to convert that to a tree-sitter concrete syntax tree, from which it is of course easy to generate "Husht" code.
- Once that roundtrip is working, we will fork and diverge the Husht tree-sitter parse from its starting point identical to the Rust tree-sitter parser, to implement the syntax that will make Husht a pleasure to use.
Examples will serve to guide the development of the Husht syntax. There are some other ideas that didn't necessarily come up in the examples.