Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
morgante committed Mar 20, 2024
1 parent 42e07c8 commit df97f35
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div align="center">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/getgrit/gritql/readme-brand/assets/grit-logo-darkmode.png">
<img alt="Grit logo" src="https://raw.githubusercontent.com/getgrit/gritql/readme-brand/assets/grit-logo.png" width="40%">
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/getgrit/gritql/main/assets/grit-logo-darkmode.png">
<img alt="Grit logo" src="https://raw.githubusercontent.com/getgrit/gritql/main/assets/grit-logo.png" width="40%">
</picture>
</div>

Expand Down Expand Up @@ -76,6 +76,25 @@ Run `grit check` to enforce your patterns as [custom lints](https://docs.grit.io
grit check
```

## Why GritQL?

GritQL comes from our experiences with conducting large scale refactors and migrations.

Usually, migrations start with exploratory work with regular expressions. These are easy to start with, but most migrations end up accumulating additional requirements like ensuring the right packages are imported and excluding cases which don’t have a viable migration path.

Eventually, any complex migration ends up being a full codemod program written with a tool like [jscodeshift](https://github.com/facebook/jscodeshift). This comes with its own problems:
- Most of the exploratory work has to be abandoned as you figure out how to represent your original regex search as an AST.
- Reading/writing a codemod requires mentally translating from AST names back to what source code actually looks like.
- Most frameworks are not composable, so you’re stuck copying patterns back and forth.
- Performance is often an afterthought, so iterating on a large codemod can be painfully slow.
- Codemod frameworks are language-specific, so if you’re hopping between multiple languages—or trying to migrate a shared API—you have to learn different frameworks.

GritQL is our attempt to develop a powerful middle ground:
- Exploratory analysis is easy: just put a code snippet in backticks and use `$metavariables` for holes you want to represent.
- Incrementally add complexity by introducing side conditions with where clauses.
- Reuse named patterns to avoid rebuilding queries, and use shared patterns from our standard library for common tasks like ensuring modules are imported.
- Written in Rust for maximum performance: rewrite millions of lines of code in seconds.

## Acknowledgements

GritQL uses [tree-sitter](https://github.com/tree-sitter/tree-sitter) for all language parsers and benefits greatly from the Rust ecosystem.
Expand Down

0 comments on commit df97f35

Please sign in to comment.