4 ms·
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 in
by nurettin 7y ago
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.
- mattlondon 7y ago> [Python] being the number one preferred scripting language on planet earth Is it? I'd imagine JavaScript usage/execution is probably way way higher.
- sampo 7y agoBut people don't use javascript to write scripts. Javascript is mostly used in writing web services.
- wilsonrocks 7y agoI 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
- josteink 7y agoAsync/await largely solves that though.
- wilsonrocks 7y agoTo 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.
- josteink 7y agoYou 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.
- nurettin 7y agoYes python is more preferred when choosing a scripting language and javascript is more executed in browsers. And the two do not contradict.
- nailer 7y agoI 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.
- thunderbong 7y agoThanks. I really don't have any idea about the asyncio syntatic sugar that you mention. Can you point me to some books / articles?
- nurettin 7y agoOh 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-python-and-node-js-69315b1e3e36 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/index https://www.codeotaku.com/journal/2018-06/asynchronous-ruby/...
- thunderbong 7y agoI 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 https://github.com/mperham/sidekiq 2. RocketJob - https://github.com/rocketjob/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.
- nurettin 7y agoYes, 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.