News for hackers. Stuff that matters.
Re:Show HN: Rb – Turns Ruby into a command line utility by nerdponx on Monday August 13, 2018 @11:11PM (#17755325)
I have no idea what this is doing, but it sure looks interesting.
Re:Show HN: Rb – Turns Ruby into a command line utility by tptacek on Monday August 13, 2018 @11:26PM (#17755387)
It's using Ruby to replace Awk, the way Perl once tried to.
Re:Show HN: Rb – Turns Ruby into a command line utility by Annatar on Tuesday August 14, 2018 @01:36AM (#17755796)
Why the hell would anybody want to replace AWK? It’s super fast, extremely light on resources, doesn’t have any dependencies, does auto memory management and type inference, and is extremely powerful for large dataset processing, not to mention easy to learn and program.
Re:Show HN: Rb – Turns Ruby into a command line utility by damagednoob on Tuesday August 14, 2018 @04:00AM (#17756229)
> easy to learn and program

I think that's relative and it certainly hasn't been my experience. If I program in Ruby, Node, Python, etc for 8 hours of every day, it makes sense that I would reach for that over a command line tool with a syntax that looks a bit arcane. The best tool for the job sometimes is the tool you know best.

Re:Show HN: Rb – Turns Ruby into a command line utility by Annatar on Wednesday August 15, 2018 @02:40AM (#17764144)
It’s arcane only if you don’t know C. If you’re on a UNIX-like or a true UNIX system, not knowing C will come to haunt you with a vengeance sooner or later.
Re:Show HN: Rb – Turns Ruby into a command line utility by DarkWiiPlayer on Tuesday August 14, 2018 @04:47AM (#17756339)
> The best tool for the job sometimes is the tool you know best.

That's like hammering in screws because you know your hammer and screwdrivers seem arcane to you.

For ad-hoc stuff `ruby -e` is more than enough, and if you want to write a program once and use it a lot, it's worth investing the time in doing it the way it works best, which in this case, would be a (fast) language like awk that makes it easier to process line-by-line instead of reading until EOF and making the rest of the pipeline wait.

Re:Show HN: Rb – Turns Ruby into a command line utility by tragomaskhalos on Tuesday August 14, 2018 @05:40AM (#17756510)
I want to say that Perl, and Ruby, and even Python are superior tools .... except that awk is also my default go-to for pipiing into to munge output data, so yes it's clearly still hitting the sweet spot for many tasks.
Re:Show HN: Rb – Turns Ruby into a command line utility by gfodor on Tuesday August 14, 2018 @12:04AM (#17755515)
Technically Ruby tried to replace Perl, so I guess the shoe fits. It sure has taken a while for someone to do this!
Re:Show HN: Rb – Turns Ruby into a command line utility by star-techate on Tuesday August 14, 2018 @12:17AM (#17755562)
Well the thing is, matz did it a decade ago when he carefully copied all these features that Perl came up with or itself carefully copied from awk and sed.
Re:Show HN: Rb – Turns Ruby into a command line utility by simonista on Monday August 13, 2018 @11:27PM (#17755390)
It's feeding stdin to ruby code you specify on the command line, either as an array of lines, or repeated strings. So in:

  docker ps | rb drop 1 | rb -l split[1]
The output of docker ps is passed as an array of lines to ruby, and the first line is dropped, and then that output is fed to ruby again, but line by line, so each line is split (which defaults to split on whitespace), and returns the second element. With parentheses for function calls it would be:

  docker ps | rb drop(1) | rb -l split()[1]
Re:Show HN: Rb – Turns Ruby into a command line utility by nerdponx on Monday August 13, 2018 @11:45PM (#17755457)
So drop is just a Ruby function? This is a great idea, seems like a good application of Ruby's syntax.