Live data from Hacker News

How Ruby is beating Python in the battle for the Soul of System Administration

devopsanywhere.blogspot.com

21–30 of 47 posts

Re: How Ruby is beating Python in the battle for the Soul of System Administration

#24
post #18
post #11

Earlier quoted context omitted.

tail can be done in ruby can be quite succinctly with the $ ruby -e'$> For the rest of the ruby one-liners in the page the author references, most can be done more easily with standard command line tools (although most people aren't well-versed in sed, so 'ruby -pe puts' might be better than 'sed G').

Cool. That hurts my eyes. ruby -e "print ARGF.readlines.last(10)"

on, say, a 5GB log file?..

If I read this correctly (http://www.ruby-doc.org/core/classes/IO.html#M000914) it'll read the whole file into an array, then spit out last 10 entries?

Re: How Ruby is beating Python in the battle for the Soul of System Administration

#25
As a sysadmin who uses Puppet for a few hundred servers, I strongly disagree with the assertion that "After spending 25% of your time working with Puppet, you will be much more likely to reach for ruby for your next scripting task." I'm not even sure how you reach this conclusion since Puppet uses a DSL and not Ruby. I've been using Puppet for a while now and I don't know and have never used Ruby, and I'm not planning to. Much of what you have written seems like you're really stretching to validate your decision to start using Ruby instead of Python, which I'm not even sure why it matters. Use what you/your organization prefers, otherwise it doesn't really matter.

Re: How Ruby is beating Python in the battle for the Soul of System Administration

#26
post #25

As a sysadmin who uses Puppet for a few hundred servers, I strongly disagree with the assertion that "After spending 25% of your time working with Puppet, you will be much more likely to reach for ruby for your next scripting task." I'm not even sure how you reach this conclusion since Puppet uses a DSL and not Ruby. I've been using Puppet for a while now and I don't know and have never used Ruby, and I'm not plannin…

I somewhat agree even as a Ruby fan of 14 years.

We have puppet now at work, and going through the recipes, its rather obvious at times that people can use Ruby, without really learning the language.

I managed to shorten a number of the recipes and configs from 60 lines of... well WTF basically, to 10-20ish lines of much more readable ruby.

I will however agree with the assertion that if the management tools that are most popular are written in Ruby, one would be more likely to do more within them.

Re: How Ruby is beating Python in the battle for the Soul of System Administration

#27
post #17
post #6

Earlier quoted context omitted.

Last 10 lines in a file? 'tail -10 filename.txt' A lot uglier, but you can do a one liner ... ruby -e 'lines=[]; while gets(); lines The problem with using "the right tool for the right job" is that there are many tools and many jobs, and a general purpose language helps you get things done in case you're stuck. In general I use Ruby for doing string manipulation before piping to other commands. Here's an (ugly) one…

> A lot uglier, but you can do a one liner ... Yeah, but that one-liner reads the whole file. 'tail' can be more clever (and is). 'strace' output: open("a", O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0644, st_size=545975512, ...}) = 0 lseek(3, 0, SEEK_CUR) = 0 lseek(3, 0, SEEK_END) = 545975512 lseek(3, 545972224, SEEK_SET) = 545972224 read(3, "tu 11.04 \\n \\l\n\nUbuntu 11.04 \\n "..., 3288) = 3288 'tail' is seeking to…

Reminds me on that article on GNU grep doing some speedy magic: http://lists.freebsd.org/pipermail/freebsd-current/2010-Augu...

Re: How Ruby is beating Python in the battle for the Soul of System Administration

#28

The Python example is completely broken. It'd be something like: import os if 'vmware' in os.popen('dmidecode').upper(): print 'this is a vmware vm' else: print 'this is not a vmware vm' I like regexps as much as the next ex-Perl hacker, but sometimes a little string manipulation is a lot better.

fixed, tks

Re: How Ruby is beating Python in the battle for the Soul of System Administration

#29
post #3

Neither Python nor Ruby are best suited for one-liners that the author is emphasising. One liners are bash-fu or commandline-fu. Anything above 100 lines (just a figure from the article) is what Python or Ruby should be used for. Last 10 lines in a file? 'tail -10 filename.txt' Right tools for the right job. As to Python vs Ruby? I believe the argument isn't about the language (although I think Python is more 'sane'…

Not that you can't do this in python:

python -c "print '\n'.join(open('LICENSE.txt','r').read().split('\n')[:-10])"

But this is besides the point.

Re: How Ruby is beating Python in the battle for the Soul of System Administration

#30

I'm not persuaded that the arrow of causality has been drawn correctly here. I.e., it seems rather that Ruby has gained a high profile in system administration, not due to any inherent characteristics of the language or library, but because Puppet and subsequently Chef happened to be written by people who wanted to use Ruby. Based on TFA, this was a matter of taste. I can't, for example, see why it should particularl…

I fail to see how Perl-golf style conciseness is inherently more "productive" (particularly when it makes it harder to understand and maintain operationally important software).

I'm not sure the author made a great case, but it does matter. Unix admins often think in terms of lines, because lines are the default unit of action. No matter how much planning and cfengining you do, there are still times when an admin must take direct action on a system. When that happens, they use the interactive command lines. These lines often aren't repeated frequently and have no need to be stored in any file other than .bash_history, and therefore do not need to be read or maintained. In those situations, the conceptual and physical overhead incurred by something like 'import re' is most assuredly significant.

Post reply on HN