Python vs. Ruby for metaprogramming


Question

I'm currently primarily a D programmer and am looking to add another language to my toolbox, preferably one that supports the metaprogramming hacks that just can't be done in a statically compiled language like D.

I've read up on Lisp a little and I would love to find a language that allows some of the cool stuff that Lisp does, but without the strange syntax, etc. of Lisp. I don't want to start a language flame war, and I'm sure both Ruby and Python have their tradeoffs, so I'll list what's important to me personally. Please tell me whether Ruby, Python, or some other language would be best for me.

Important:

  1. Good metaprogramming. Ability to create classes, methods, functions, etc. at runtime. Preferably, minimal distinction between code and data, Lisp style.
  2. Nice, clean, sane syntax and consistent, intuitive semantics. Basically a well thought-out, fun to use, modern language.
  3. Multiple paradigms. No one paradigm is right for every project, or even every small subproblem within a project.
  4. An interesting language that actually affects the way one thinks about programming.

Somewhat important:

  1. Performance. It would be nice if performance was decent, but when performance is a real priority, I'll use D instead.
  2. Well-documented.

Not important:

  1. Community size, library availability, etc. None of these are characteristics of the language itself, and all can change very quickly.
  2. Job availability. I am not a full-time, professional programmer. I am a grad student and programming is tangentially relevant to my research.
  3. Any features that are primarily designed with very large projects worked on by a million code monkeys in mind.
1
89
7/26/2018 1:03:04 PM

Accepted Answer

There's not really a huge difference between python and ruby at least at an ideological level. For the most part, they're just different flavors of the same thing. Thus, I would recommend seeing which one matches your programming style more.

15
9/28/2008 12:31:09 AM

I've read up on Lisp a little and I would love to find a language that allows some of the cool stuff that Lisp does, but without the strange syntax, etc. of Lisp.

Wouldn't we all.

minimal distinction between code and data, Lisp style

Sadly, the minimal distinction between code and data and "strange" syntax are consequences of each other.

If you want easy-to-read syntax, you have Python. However, the code is not represented in any of the commonly-used built-in data structures. It fails—as most languages do—in item #1 of your 'important' list. That makes it difficult to provide useful help.

You can't have it all. Remember, you aren't the first to have this thought. If something like your ideal language existed, we'd all be using it. Since the real world falls short of your ideals, you'll have to re-prioritize your wish list. The "important" section has to be rearranged to identify what's really important to you.


Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon