doc: explain re-write in Go
Signed-off-by: Brian McGee <brian@bmcgee.ie>
This commit is contained in:
parent
f5c81e64ec
commit
e375574aad
44
README.md
44
README.md
|
@ -24,6 +24,29 @@ time you switch between projects or call them manually.
|
||||||
Formatting requires less effort if a universal formatter for multiple languages, which is also project-specific, is in
|
Formatting requires less effort if a universal formatter for multiple languages, which is also project-specific, is in
|
||||||
place.
|
place.
|
||||||
|
|
||||||
|
## Moving from Rust To Go
|
||||||
|
|
||||||
|
You may be familiar with [Version 1], which is written in [Rust]. So, why re-write it in [Go]?
|
||||||
|
|
||||||
|
Ultimately, `treefmt` is spending most of it's time shelling out calls to the underlying formatters. This process is
|
||||||
|
just as fast/performant in [Go] as it is in [Rust].
|
||||||
|
|
||||||
|
The remaining tasks are processing some cli args and parsing a config file. Do we really need something as _heavy duty_
|
||||||
|
as [Rust] for that?
|
||||||
|
|
||||||
|
Despite all this, you can make good, sane arguments for continuing with [Version 1] in [Rust] instead of a re-write.
|
||||||
|
So here's a _bad argument_.
|
||||||
|
|
||||||
|
> Not everything has to be written in [Rust]
|
||||||
|
|
||||||
|
[Brian] wanted to improve performance by moving away from a [Toml] cache file, introduce pipelines for applying multiple
|
||||||
|
formatters against the same file set, and add an extensible approach for how `treefmt` walks file systems. He knows [Go]
|
||||||
|
much better than [Rust].
|
||||||
|
|
||||||
|
[zimbatm] thought it was a good idea too.
|
||||||
|
|
||||||
|
So here we are :shrug:.
|
||||||
|
|
||||||
## About treefmt
|
## About treefmt
|
||||||
|
|
||||||
`treefmt` runs all your formatters with one command. It’s easy to configure and fast to execute.
|
`treefmt` runs all your formatters with one command. It’s easy to configure and fast to execute.
|
||||||
|
@ -34,17 +57,17 @@ Its main features are:
|
||||||
|
|
||||||
- **Providing a unified CLI and output**
|
- **Providing a unified CLI and output**
|
||||||
- You don’t need to remember which formatters are necessary for each project.
|
- You don’t need to remember which formatters are necessary for each project.
|
||||||
Once you specify the formatters in the config file, you can trigger all of them with one command and get a
|
- Once you specify the formatters in the config file, you can trigger all of them with one command and get a
|
||||||
standardized output.
|
standardized output.
|
||||||
- **Running all the formatters in parallel**
|
- **Running all the formatters in parallel**
|
||||||
- A standard script loops over your folders and runs each formatter
|
- A standard script loops over your folders and runs each formatter sequentially.
|
||||||
consequentially. In contrast, `treefmt` runs formatters in parallel. This way, the formatting job takes less time.
|
- In contrast, `treefmt` runs formatters in parallel. This way, the formatting job takes less time.
|
||||||
- **Tracking file changes**
|
- **Tracking file changes**
|
||||||
- When formatters are run in a script, they process all the files they encounter, no matter
|
- When formatters are run in a script, they process all the files they encounter, regardless of whether or not
|
||||||
whether the code has changed. This unnecessary work can be eliminated if only the changed files are formatted.
|
they have changed.
|
||||||
`treefmt` caches the changed files and marks them for re-formatting.
|
- `treefmt` tracks file changes, and only attempts to format files which have changed.
|
||||||
|
|
||||||
To reformat the whole source tree, just type `treefmt` in any folder. This is a fast and simple formatting solution.
|
> To reformat the whole source tree, just type `treefmt` in any folder. This is a fast and simple formatting solution.
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
|
@ -153,3 +176,10 @@ Source projects: <https://numtide.com/contact>
|
||||||
|
|
||||||
Unless explicitly stated otherwise, any contribution intentionally submitted for inclusion will be licensed under the
|
Unless explicitly stated otherwise, any contribution intentionally submitted for inclusion will be licensed under the
|
||||||
[MIT license](LICENSE.md) without any additional terms or conditions.
|
[MIT license](LICENSE.md) without any additional terms or conditions.
|
||||||
|
|
||||||
|
[Brian]: https://github.com/brianmcgee
|
||||||
|
[zimbatm]: https://github.com/zimbatm
|
||||||
|
[Version 1]: https://github.com/numtide/treefmt
|
||||||
|
[Rust]: https://www.rust-lang.org/
|
||||||
|
[Go]: https://go.dev/
|
||||||
|
[Toml]: https://toml.io/en/
|
Reference in New Issue
Block a user