Live data from Hacker News

Comby - Structural code search and replace for every language

comby.dev

1–10 of 26 posts

Re: Comby - Structural code search and replace for every language

#5
Okay wow. I didn't tools like this existed! There's been more than once where I've found myself in a situation like "find all code like this, change if this, delete if this". Regex can only get you so far.

Does someone know if this or something similar is available as a VSCode extension? It'd be fun to make one if not!

Re: Comby - Structural code search and replace for every language

#7

License? Also, how does it compare to Coccinelle?

License seems to be apache V2, see https://github.com/comby-tools/comby/blob/master/LICENSE.

They have a comparison section in their faq (https://comby.dev/docs/faq):

"Coccinelle uses a declarative syntax for matching constructs like function calls, if-statements, expression blocks, and so on for the C language. Some notable differences are that Coccinelle provides a patch-like format to express transformations (handy when you want to inline smaller changes in a broader context) and metavariable declarations (handy for developing and organizing more sophisticated patterns). For an example, see the file null_ref.cocci. Coccinelle works only for the C language, and may struggle to parse files that contain non-standard C constructs, like GCC inline assembly. Recent Coccinelle work has started expanding support for Java. In contrast, Comby’s syntax targets a wide range of languages and is more robust to matching patterns in the presence of unrecognized constructs. Comby is more suited to writing quick find-replace patterns for languages beyond C, and works well on C languages too."

Re: Comby - Structural code search and replace for every language

#10
A more interesting comparison than with Coccinelle is with semgrep (https://semgrep.dev/) since it also supports semantic/structural pattern matching over a number of languages, but also adds in a bunch of Boolean logic into the mix, as well as some more advanced semantic features like constant propagation.

Curious whether the teams behind these tools are aware of each other? I suppose it's unlikely that they're not.

Post reply on HN