r/programmingtools • u/knd256 • Oct 29 '24
Workflow sim The Easy to Learn Hack-able Alternative to sed
I have always head about the tool `sed` but I never really got into it because it does not have a very beginner user interface in my opinion. Recently however, I saw a [video by Charles Cabergs](https://www.youtube.com/watch?v=akN2TFarz0A) which showed off exactly what `sed` could do and I got super interested as it seems like an invaluable tool when it comes to re-factoring code or otherwise editing large streams of data.
`sed` is a turing complete stream editor, which can be used to re-factor and re-arrange code in a number of ways which I find helpful on a daily basis. It is powerful enough to write [terminal tetris in](https://github.com/uuner/sedtris). I would recommend watching the video to see exactly how it can be used.
I implemented a, in my opinion, more user friendly hack-able version of `sed` which I call `sim`. It uses a json schema as its current front end and supports all of GNU `sed`s commands but can be extended in the following ways:
- The front end can change without having to change the infrastructure of the program.
- Commands can be added without awareness of the surrounding context. The only implementation that the developer is required to understand is the name of the command and a general function which has access to all of the information which the program has access to.
For a more detailed explanation of exactly how this can be accomplished you can see the [hacking guide](https://github.com/millipedes/sim/blob/develop/docs/dev/hacking_sim.md).
I use this tool in my job daily and think that there are some cool abstractions in it that allow it to fit many workflows and thought I would share. Thanks for reading, if you have any questions I will answer them to the best of my ability.
My implementation can be found [here](https://github.com/millipedes/sim/tree/develop).