News for hackers. Stuff that matters.
Re:No script is too simple by jiofih on Tuesday September 22, 2020 @03:21PM (#24558671)
Ruby is a much better candidate for this. Nicer syntax and a vastly better standard library.
Re:No script is too simple by cle on Tuesday September 22, 2020 @03:48PM (#24558989)
This kind of conversation is never productive in a team setting. The strongest criteria is "what would the majority of people on the team prefer to use?". That'll yield the highest productivity, regardless of whatever syntactic sugar it has.
Re:No script is too simple by nfrmatk on Tuesday September 22, 2020 @03:42PM (#24558921)
Nicer syntax? Vastly better standard library? Those seem like subjective statements to me. Can you provide some examples to support those claims?
Re:No script is too simple by deeg on Tuesday September 22, 2020 @03:53PM (#24559044)
I dunno about a better standard library but I do think Ruby has nicer syntax. You can use back-ticks to run system commands, like:

listing = `ls -oh`

puts listing

puts $?.to_i # Prints status of last system command.

Re:No script is too simple by nfrmatk on Tuesday September 22, 2020 @05:52PM (#24560381)
That might just come down to the usual differences between Python and Ruby. A Python programmer would likely appreciate an explicit call to `subprocess.run`.

Some equivalent Python 3.7+ would be

  import subprocess
  listing = subprocess.run(("ls", "-oh"), capture_output=True, encoding="utf-8")
  print(listing.stdout)
  print(listing.returncode)
As an experienced Ruby programmer I imagine the code you provided looks like a no-brainer. To a Ruby neophyte the backticks, $? sigil, and .to_i method don't strike me as intuitive (but maybe they would be do someone else). We may just have to disagree about the nicety of syntax.

As cle mentioned[1], the strongest criteria is

> what would the majority of people on the team prefer to use?

and I'd agree that ultimately that's what makes the most sense.

[1]: https://news.ycombinator.com/item?id=24558989

Re:No script is too simple by deeg on Tuesday September 22, 2020 @06:35PM (#24560800)
The back-ticks and $? are shell standards so I would expect those to be familiar to shell scripters. I agree that if one knows nothing about any of the languages then neither is much better.