Live data from Hacker News

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

devopsanywhere.blogspot.com

11–20 of 47 posts

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

#11
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'…

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').

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

#12
This essentially reduces to "it's easier to write a fluent, readable, flexible and powerful DSL in Ruby than it is in Python.

Sysadmin tools benefit greatly from using such a DSL as their interface vs custom parsers or configuration files.

Hence, Ruby is a good choice for these sorts of things.

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

#13
I use puppet in a mostly Python shop. I like that it uses a DSL and not raw Ruby/Pyhton/etc. However, I diagree with TFA about Ruby becoming the dominant language for a very simple reason: all UNIX-like systems have sh and in recent ones it supports all the same things. Most distros which I would consider installing onto servers, managed workstations, etc. have a Python interpreter and a standard library which includes everything from process management to a web server. These two tools are ubiqutous. However, not many distros ship with Ruby installed. Writing a 200 line Ruby script means that it is noe your job to ensure you have Ruby on all your machines, not the dist maintainers'.

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

#14

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…

you also seem to have missed the multiple times I state my personal preference for Python but am shifting to ruby for practical reasons.

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

#15
post #11
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'…

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').

There's one big problem with code like that. If you're doing devops-y stuff, then you really, really don't want to debug something like that when your pager goes off at 3am. The cleaner the solution the better, because after you wake up `$><<$<` is just a blurred thing with no meaning...

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

#16
This is a rather misguided article. Unless everything has completely changed, Ruby is used for almost nothing in mainstream Linux. Bash and Python dominate "stock" system management code, and Bash and Perl seem to dominate for top-level add-on scripts written by a given sysadmin.

I've never even heard of any of those Ruby projects besides puppet, and I've only ever once installed Ruby- to support some obscure v0.03a library a developer wanted to try.

(Was a part-time sysadmin for 2 years)

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

#17
post #6
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'…

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 the end, then reading backwards.

The point being, these 'little tools' can contain important optimisations - they aren't necessarily equivalent to a naive reimplementation.

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

#18
post #11
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'…

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)"

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

#19
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.

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

#20

This is a rather misguided article. Unless everything has completely changed, Ruby is used for almost nothing in mainstream Linux. Bash and Python dominate "stock" system management code, and Bash and Perl seem to dominate for top-level add-on scripts written by a given sysadmin. I've never even heard of any of those Ruby projects besides puppet, and I've only ever once installed Ruby- to support some obscure v0.03a…

The unstated premise of this article is that all sysadmins will very soon be using puppet or chef, thus programming in some subset or DSL that looks a lot like ruby (puppet).

However, that's a separate article that I need to get around to writing.

Post reply on HN