Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] please rename sg to ag (sg is now used in semgrep) #778

Closed
aryx opened this issue Dec 12, 2023 · 7 comments
Closed

[bug] please rename sg to ag (sg is now used in semgrep) #778

aryx opened this issue Dec 12, 2023 · 7 comments
Labels
bug Something isn't working

Comments

@aryx
Copy link

aryx commented Dec 12, 2023

The semgrep program now includes a shortcut called 'sg' https://github.com/semgrep/semgrep/tree/develop/cli/bin
for semgrep, so it would be better to rename your 'sg' to 'ag'.

⏯ Playground Link

Playground link with relevant code

💻 Code

Code:

Pattern:

🙁 Actual behavior

🙂 Expected behavior

@aryx aryx added the bug Something isn't working label Dec 12, 2023
@HerringtonDarkholme
Copy link
Member

HerringtonDarkholme commented Dec 12, 2023

Hi Padioleau, thank you for dropping a comment on ast-grep! We appreciate your feedback and understand your concerns regarding the sg command name.

The release timing of our sg command overlaps with semgrep's, but it's important to note that ast-grep has been in circulation for approximately one year while semgrep's alias was added one month ago.

Additionally, the ag alias is already claimed by the silversearcher project. Adopting ag also creates conflicting command names.
Indeed, sg itself has been used in the Linux ecosystem as a shadow-utils command for 16 years. Changing ast-grep's alias will not stop semgrep from conflicting with the Linux command.

To address potential conflicts and ensure a smooth user experience, maintaining both the full ast-grep command and the sg alias offers a balanced solution.

This approach aligns with existing usage within ast-grep and minimizes the risk of confusion with other projects.

@aryx
Copy link
Author

aryx commented Dec 12, 2023

And what 's' stands for in sg in ast-grep ???
ast-grep is already a clear clone of semgrep ... I think using 'sg' for its alias is a bit insulting.
Maybe 'asg' ?

@HerringtonDarkholme
Copy link
Member

Thank you for your comment on ast-grep. I am glad to hear from you and I value your input.

And what 's' stands for in sg in ast-grep ???

The s stands for syntax as in the Abstract Syntax Tree, which is on the homepage.

image

Indeed, ast-grep does not have semantic features like taint-analysis or constant propagation. And it is not designed to do so.

ast-grep is already a clear clone of semgrep

I appreciate your interest in ast-grep and I would like to explain how it differs from semgrep. While both tools use abstract syntax trees to analyze code, they have different goals and features. As previously explained elsewhere[1] [2], ast-grep offers unique capabilities (like a CSS selector-like rule) and caters to different user needs (refactoring and searching).

[1] https://news.ycombinator.com/item?id=38594457
[2] https://ast-grep.github.io/advanced/tool-comparison.html

I think using 'sg' for its alias is a bit insulting.

I am sorry to hear that you find the name sg insulting. That was never my intention. The name sg was chosen to reflect the syntax-based approach of ast-grep and it has been used consistently since the first release in October 2022.

While I hold great admiration for the semgrep project and its author, the adoption of a later naming scheme shouldn't automatically restrict earlier names, would you agree? :)

@aryx
Copy link
Author

aryx commented Dec 12, 2023

As the semgrep author, I made the request; Of course you're free to ignore it. I think it's confusing to have a tool called ast-grep, which is clone of semgrep, and which uses 'sg' for its shortcut, while the tool is actually called ast-grep ... now if you don't see the obvious, there's not much I can do.

@HerringtonDarkholme
Copy link
Member

Thank you for your reply again, and I value your input!

uses 'sg' for its shortcut, while the tool is actually called ast-grep

ast-grep was designed to be fast and can be used frequently on command line as rg/ag/grep. Search finishes in sub second and typing the full ast-grep name defeats its purpose of being fast.

This was how I came up with the short name:

  • ag: It was already taken by silversearcher
  • sg: I was not aware of shadow-utils then but it does not conflict with OSX/windows utils
  • tg: This instantly reminds me of telegram and also there was a package there https://github.com/vysheng/tg

I chose sg after considering several alternatives and finding it the most suitable for ast-grep.

a tool called ast-grep, which is clone of semgrep,

ast-grep is inspired by semgrep, but it has many unique features that distinguish it from semgrep.

ast-grep doesn't have semantic features like semgrep. But it deserves the name of syntax-grep. I would be happy if you have time and can take a look at ast-grep's documentation site! As a quick spoiler, ast-grep can easily match Python generator expression, while, to my best knowledge, it is challenging to do so in semgrep.

now if you don't see the obvious, there's not much I can do.

It is not a shame to acknowledge ast-grep is inspired by semgrep. I have paid respects multiple times in the doc.

That said, I don't think it is confusing for users to misunderstand sg with semgrep/ast-grep. There are tons of similar projects on the internet where syntax-aware searching have similar names. Indeed, we already have predecessors like more/less, git/tig. Similar names for similar projects are quite common.

Thank you again for your reply and your interest in ast-grep. I hope this clarifies some of the questions and concerns you had.

And I hope, if possible, the documentation site can pique your interest about its uniqueness! :)

@aryx
Copy link
Author

aryx commented Dec 13, 2023

Ok, I'll close then.
Thx indeed for the reference to semgrep in the doc.

@aryx aryx closed this as completed Dec 13, 2023
@milahu
Copy link

milahu commented Feb 17, 2024

both are wrong. both ag and sg are too short as program names

when users want alias names, they should learn to use their shell

alias sg=ast-grep

edit: more nitpickery: tree-sitter is a CST parser
that allows code transformations with minimal diff

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants