Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Please advise on Ruby vs Python, for someone who likes LISP a lot

Tags:

python

ruby

lisp

I am a C++ developer, slowly getting into web development. I like LISP a lot but don't like AllegroCL and web-frameworks available for LISP. I am looking for more freedom and ability to do cool hacks on language level. I don't consider tabs as a crime against nature.

Which one is closer to LISP: Python or Ruby?

I can't seem to be able to choose from Python and Ruby: they seem very similar but apparently Ruby is more functional and object-oriented, which are good things, while Python is more like Perl: a simple scripting language. Do I have the right impression?

PS - This might seem like a flame bait but it's not really, I'm just trying not to go crazy from OCD about switching from RoR to Python/Django and back.

like image 594
mannicken Avatar asked Jan 01 '09 17:01

mannicken


People also ask

Is Ruby like Lisp?

Ruby is a denser functional language than LISP A dense language lets you say things concisely, without obfuscation. You can see more of your program in one glance, and there aren't as many places for bugs to hide. Beyond a certain point, the only way to make programs denser is to use more powerful abstractions.

Should I use Ruby or Python?

Python is generally better for educational use or for people who want to build quick programs rather than work as developers, while Ruby is better for commercial web applications. There are more specific differences when comparing Ruby versus Python, and they have in common that there are many ways to learn both.

What is easier to learn Ruby or Python?

Learning Curve Without a doubt, Python is much easier to learn because of how the language is structured - and how explicit it is. One can literally become proficient in two to three months. Ruby takes much longer to learn due to its flexibility.

Why is Ruby better than Python?

Yes, certain super functional-style code is far easier to write in Ruby than in Python, but Python, despite its drive for simplicity, can be used in ways rather similar to Ruby. Ruby, however, tends to be more expressive, and strikes a bit closer to functional languages like Lisp or Scheme than Python.


3 Answers

Peter Norvig, a famous and great lisper, converted to Python. He wrote the article Python for Lisp Programmers, which you might find interesting with its detailed comparison of features.

Python looks like executable pseudo-code. It's easy to pick up, and often using your intuition will just work. Python allows you to easily put your ideas into code.

Now, for web development, Python might seem like a more scattered option than Ruby, with the plethora of Python web frameworks available. Still, in general, Python is a very nice and useful language to know. As Ruby and Python's niches overlap, I agree with Kiv that it is partly a matter of personal taste which one you pick.

like image 118
namin Avatar answered Sep 22 '22 12:09

namin


I'd go with Ruby. It's got all kinds of metaprogramming and duck punching hacks that make it really easy to extend. Features like blocks may not seem like much at first, but they make for some really clean syntax if you use them right. Open classes can be debugging hell if you screw them up, but if you're a responsible programmer, you can do things like 2.days.from_now (example from Rails) really easily (Python can do this too, I think, but with a bit more pain)

PS: Check out "Why Ruby is an acceptable LISP".

like image 34
zenazn Avatar answered Sep 19 '22 12:09

zenazn


Devils Advocate: Who Cares?

They are both good systems and have an ecosystem of good web frameworks and active developer communities. I'm guessing that you're framing your decision based on the wrong criteria. The question sounds like you're fretting about whether you will hit implementation problems or other difficulties by choosing one over the other. Don't.

This is similar to Java/.Net decisions. There may be compelling reasons in a specific instance, but soft factors like the architect's familiarity with the platform are a much stronger predictor of project success.

I will admit that I've used Python much more than Ruby, but I wouldn't say that I have any great preference between the two apart from familiarity. I've used Python off and on since about 1998 and I like the Smalltalkish-ness of Ruby as I used Smalltalk briefly about 15 years ago. They both do similar things slightly differently.

I would like certain features from Ruby (or Smalltalk for that matter) but Python doesn't work that way. Instead, it has other features and language idioms are slightly different from Ruby or Smalltalk. Several of the other posters have linked out to articles that compare the two.

If you're worrying about Rails vs. Django, that suggests you're looking for a platform for web applications. Both languages have good tool support and an active developer community. Django seems to be the winner of the Python web framework melee and Rails seems to be in the process of 'crossing the chasm' and bringing Ruby along with it. Both are reasonably mature systems and have been demonstrated to work well for respectable traffic volumes.

ProTip: The presence of religious wars is a good indicator that neither side has a compelling arguement.

So, I'm going to play devil's advocate and say that worrying about the choice is pointless. The languages have advantages and disadvantages with respect to each other but nothing that could be viewed as compelling in the general case. Fretting about the detailed merits of one platform or the other is framing the decision wrongly.

Pick one and use it. You will be able to build systems effectively with either.

like image 36
ConcernedOfTunbridgeWells Avatar answered Sep 18 '22 12:09

ConcernedOfTunbridgeWells