Hacker News new | past | comments | ask | show | jobs | submit login

Honestly, I've done a lot of professional work in both languages, and there is pretty much nothing you can't do with ruby that you can in python. There is no intrinsic difference in power of expressiveness between the languages. Although ruby is lagging a little behind with the asyncio syntactic sugar stuff. You may reach a point where there simply isn't any client written for the service you are trying to automate in either language. And python got more love in that aspect what with all the being the number one preferred scripting language on planet earth, but in case your target of automation provides a simple rest or websocket protocol you could easily do without a dedicated client library for it.



Thanks. I really don't have any idea about the asyncio syntatic sugar that you mention. Can you point me to some books / articles?


Oh async/await is just python's and javascript's way of executing functions concurrently within the same process. asyncio emerges as a rewrite of a standard library to support this idiom. Browsers that execute javascript ES6 and node v7 onwards have this feature. Instead of passing callbacks to functions and have them executed concurrently, you create a task or future (in python 3.6+) or a Promise (in javascript) and await that. That is very useful because it untangles the callback-inside-callback structure.

There's a comparison between node and python's async/await syntaxes here https://medium.com/@interfacer/intro-to-async-concurrency-in...

For ruby I found this article which shows the gist of what we are trying to accomplish with async/await (we want to gather a bunch of promises and await all their results and have them run concurrently in an event loop so that when one is waiting for IO to complete, the other one takes over and runs) https://www.codeotaku.com/journal/2018-06/asynchronous-ruby/...


I understand async/await as I'm conversant with NodeJs. When you mentioned asyncio, I assumed it be something specific in the Python library.

In case of Ruby, I've found these libraries (ruby gems) to be very useful.

1. Sidekiq - https://github.com/mperham/sidekiq

2. RocketJob - https://github.com/rocketjob/rocketjob

What I'm guessing you're saying is that this kind of behavior is available natively in Python, whereas in Ruby, it is achieved by some roundabout fashion.


These gems are not really related to the asyncio stuff in python. (They're async job runners though... overloaded names can be annoying)

async/await works at a function level in the same process. Asyncio in python is pretty much the async/await from node/js.

Sidekiq alternative in python would be closer to http://www.celeryproject.org/


Yes, async functions are natively available in python3.6+ and node7+, and requires a gem in ruby. Ruby can also use fibers and eventloop to do concurrency using just the standard library, but it is missing the async/await syntactic sugar.


> [Python] being the number one preferred scripting language on planet earth

Is it?

I'd imagine JavaScript usage/execution is probably way way higher.


Yes python is more preferred when choosing a scripting language and javascript is more executed in browsers. And the two do not contradict.


I think you're both correct. For sysadmin definition of scripting, python would be most popular. For the 'fast to write' definition of scripting then sure, JavaScript.


I don't think I've ever heard that as a definition of "scripting".


Which one?

For the second, the definition of 'scripting language' used to be 'doesn't use a compiler' but JS and everything else has a JIT now, so 'make something quick' is a modern equivalent.


But people don't use javascript to write scripts. Javascript is mostly used in writing web services.


I mostly write javascript now for my day job... But python is nicer for scripts... The asynchronous nature of node makes it a pain for me


Async/await largely solves that though.


To an extent... If you're using something that supports promises and not callbacks, which not all of the things you want to use to write an actual script do.


You can easily transform a callback into a promise via simple glue-functions:

    let result = await CallbackPromise.from(some.callbackConventionFunction, param);
Then you get a unified form for the code-base.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: