3 ms·
I see the discussion turns out to be general about programming languages. Here is my take: I am doing Ops (aka DevOps, aka system administration) and I was usi
by ilyash 5y ago
I see the discussion turns out to be general about programming languages. Here is my take:
I am doing Ops (aka DevOps, aka system administration) and I was using bash and Python. I never clicked with Ruby. I was suffering. Constant thought "why is it so shitty?"
Outdated bash doesn't meet any modern expectation from a programming language.
Python, as other general purpose languages, was not created for Ops specifically. Running external process is a pain, data manipulation is with list comprehensions instead of more straightforward map() and filter() (or do non-idiomatic Python), quite a few other features missing which I would expect when writing small scripts.
I think Ops people deserve better. Result - my own programming language - https://github.com/ngs-lang/ngs https://github.com/ngs-lang/ngs . Is it "better" language? Probably not. I do think it sucks less than others for Ops though.
- freedomben 5y agoIt sounds like we do very similar jobs and feel the same way about Python. I'm 97% sure you're going to stick with your own language, but for others seriously give Ruby a look. I absolutely adore Ruby as a scripting language. It's so easy and elegant to shell out to bash and do something with the output. When brevity or familiarity with bash is desired, variables like $? are there also (although there are generally less esoteric ways to do things). Running a simple shell command in Ruby is as easy as using backticks and having the output from the command returned to you as a String (and I always add a .chomp to strip the trailing \n)[1] Example: datestr = `date '+%Y-%m-%d-%H-%M-%S'`.chomp Worth noting too is that Ruby also has a fantastic one-liner command line syntax like perl and awk for example. Check out https://robm.me.uk/2013/11/ruby-enp/ https://robm.me.uk/2013/11/ruby-enp/ and https://benoithamelin.tumblr.com/ruby1line/ https://benoithamelin.tumblr.com/ruby1line/ Also the community is amazing. There are gems for almost everything, and really neat/fun projects like Ruby Warrior: https://github.com/ryanb/ruby-warrior https://github.com/ryanb/ruby-warrior I'll stop now, but suffice it to say Ruby is one of the best tool sin my belt, and I haven't even mentioned the number of times I've thrown down a simple single-file HTTP service based on Sinatra in record time ;-) [1] https://stackoverflow.com/a/2400/2062384 https://stackoverflow.com/a/2400/2062384
- ilyash 5y ago> I'm 97% sure you're going to stick with your own language Agree with the estimation :) > but for others seriously give Ruby a look Of course. Python is not out of the question either. I think it's mostly about alignment of how you think and what is possible to express in the language in a straightforward manner. > It's so easy and elegant to shell out That's the area where I think NGS has better facility than pretty much anything else I've seen out there. In NGS, it's the "domain". From the top of my head: * Short syntax for run-the-command-and-parse-output (currently auto detects JSON but customizable) - like backticks in bash but double-backtick on each side. * backticks syntax like in bash (but don't strip the last newline) * Argv facility for constructing command line arguments (if the command is complex) * Automatic handling of exit codes. Errors throw exceptions and no, not any non-zero is an error. * ok: option to specify non-error exit codes for particular run of a program * log: option to log the command being run More at https://github.com/ngs-lang/ngs/wiki/Use-Cases#use-case-ops-scripting https://github.com/ngs-lang/ngs/wiki/Use-Cases#use-case-ops-... > Worth noting too is that Ruby also has a fantastic one-liner command line syntax like perl and awk for example. NGS is somewhat there and somewhat getting there