4 ms·
Do you have any experience with Python? IMHO I think python fits that niche better than ruby or perl.
by Igglyboo 12y ago
Do you have any experience with Python? IMHO I think python fits that niche better than ruby or perl.
- humanrebar 12y agoRuby is generally more concise and easier to write though probably harder to maintain. For example, when shelling out, ruby lets you do it many ways, including the familiar backtick syntax. In python, you shell out with popen -- you need to contruct argument lists, wire up stdout and stderr, etc. Python's way might actually be better (more explicit, less ambiguity, easier to handle errors) but often you might just want something that's simple and readable. For the record, there are nicer python APIs and safer ruby APIs. These are just general comments on the different ecosystems.
- rch 12y agoTry the python 'sh' module (https://github.com/amoffat/sh https://github.com/amoffat/sh). For example: from sh import git print git('version')
- rboling91 12y agoI think that both Python and Ruby can serve this purpose well, but both the block and method_missing functionality in Ruby can result in highly flexible and concise APIs. Correct me if I'm wrong, but I don't think there's a precise analog in Python to the Proc/Block syntax found in Ruby, maybe with the exception of lambdas. Furthermore, delegation using method_missing can result in APIs/libraries being very concise and readable.
- btown 12y agoIn Python, since functions can be defined anywhere, and decorators can execute arbitrary code (including registering and running the functions they decorate) and be passed variables from the scope they're used, you can make some pretty powerful DSLs. And method_missing delegation can largely be replaced by defining classes at runtime, especially now that people are getting used to passing hashes as arguments (in fact, Rails seems to be slowly deprecating find_by_foo_and_bar in favor of where(foo: _, bar: _)?).
- wtetzner 12y agoCan you give reasons?
- Igglyboo 12y agoPython is installed by default on most linux distros, from my experience it is rare if ruby is pre-installed. Python in my opinion is easier to write, and reading it is usually like reading plain english. Python has a much larger community/ecosystem than ruby outside of web frameworks (rails kills django in popularity).