Hacker News new | ask | show | jobs
by Igglyboo 4305 days ago
Do you have any experience with Python? IMHO I think python fits that niche better than ruby or perl.
3 comments

Ruby 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.

Try the python 'sh' module (https://github.com/amoffat/sh). For example:

  from sh import git
  print git('version')
I 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.
In 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: _)?).
Can you give reasons?
Python 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).