I just started today looking into Groovy. I consider using it to replace some of my more complex bash scripts.
One of its very interesting concepts for me is the possibility to use pipes easily:
proc1 = 'ls'.execute()
proc2 = 'tr -d o'.execute()
proc3 = 'tr -d e'.execute()
proc4 = 'tr -d i'.execute()
proc1 | proc2 | proc3 | proc4
proc4.waitFor()
That’s amazing. But my question is: Does this use real UNIX pipes (when run e.g. on Linux), or is this just a simulation with Java streams? (And if so, is it much slower/more inefficient?)
Due to operator overloading, it eventually calls into ProcessGroovyMethods.pipeTo() in the Groovy runtime, which does indeed simulate pipes using java streams:
I can’t speak to the amount of overhead involved off the top of my head though.