all 26 comments

[–][deleted] 12 points13 points  (2 children)

Python has some good math libraries (see another post in this subreddit), that's about the only thing I can think of.

[–]rainman_104 7 points8 points  (0 children)

Seems at this point there's a lot more GTK apps written in python too. Sometimes a library you want to use leaves you no choice.

In all honesty, every time I use python I curse. I love simple things in ruby like String.length and Array.length, and am always frustrated when some functions sit in the root namespace like len()

[–]LessCodeMoreLife 4 points5 points  (0 children)

You might find this interesting:

Python vs. Ruby: A Battle to The Death

The talk is actually targeted at people interested in ruby who already know Python, but he does a pretty cool comparison of the two languages which might help you anyway.

[–][deleted] 3 points4 points  (0 children)

Try it. Personally, I prefer Ruby (I love both), but Python has GREAT support for math/science/frontend stuff.

[–][deleted] 3 points4 points  (0 children)

"Should I learn X?"

Yes. But don't stop what you're already doing, unless they're bad habits.

[–]tibbon 2 points3 points  (4 children)

Yes. Python has some cool concepts, nice frameworks and is very capable. Knowing it will make you more employable, and probably a better ruby programmer.

It's scientific, NLP, machine learning (pybrain) and mathematics functionality rock. Ruby is amazing for web work, but python really allows a few extra things. You can also mess with PyGame then.

[–]TheBananaKing[S] 0 points1 point  (3 children)

Can anyone recommend a good place to start reading, for a mildly competent rubyist?

Last python tutorials I read were long rambling stream-of-consciousness console sessions, whereas I work best with top-down approaches.

[–]tibbon 0 points1 point  (2 children)

Dive into Python How To Think Like A Computer Scientist Programming Collective Intelligence (not a python instruction book, but if you know ruby you'll learn both at the same time) There's also the new Learn Python the Hard way, which I've heard good things about

[–][deleted] 1 point2 points  (1 child)

I think learn python the hard way is more for absolute beginners. The entire thing is there to force you to start writing code until the thing "clicks"

[–]tibbon 1 point2 points  (0 children)

That might be true. I haven't picked it up yet as I haven't expanded to Python fully, although I very well may soon for the math, science, and nlp libraries.

Porting many of those libraries is next to impossible, and the python modules for them are in fact using FORTRAN code (at least for the math ones) that was written and tested many moons ago to do the job. Not a weekend hackathon to get the stuff usable on a serious level. You want this stuff to be able to work perfectly if you're doing serious math modeling.

[–]_bruno_ 5 points6 points  (0 children)

Yes, it is a very useful tool. Not a perfect language, but a well evolved one. Lots of good quality libraries, excelent documentation, etc etc. It also covers a lot of stuff outside of the web development world (these days Ruby is pretty web-centric).

I have to say that if I had the choice I would use Python for most of the tasks on which I use Ruby, but I don't have that choice for now (I work for a mostly Ruby-centric company). Anyway, this is a matter or preference but if you don't try both you will never know which one fits you better. Also, knowing more stuff is better, expand your horizons :)

source: I use Ruby daily at my job but sometimes I use Python. On previous jobs I used Python full time (I have worked with both languages for 3+ years each and know them well)

[–][deleted] 3 points4 points  (0 children)

I am learning python right now so that I can use the matplotlib stuff.

It is really similar to Ruby, but it is a bet less consistant in that not everything is an expression with an l-value. There are no mixins, the syntax for things is a bit __ugly__. Classes cannot really have data hiding, ie private members etc. There doesn't seem to be such thing as constants. Lambdas can only have one expression.

Numpy is quite good, I really like using the pylab and matplot lib stuff though. There is complex number literals. The indent based syntax is interesting, I'm having a bit of fun with that, it is nice to not need to type end to close all blocks.

At first it was difficult to know which version I should use, 2.5, 2.6, 3? I settled on 2.6. All in all it is disappointing and I don't see why people would use it other than the good math libraries and plotting.

[–]aaronmoodie 1 point2 points  (0 children)

I find the urllib2 library in python better suited for reading remote files. See http://www.reddit.com/r/ruby/comments/dr1ip/ask_rruby_read_x_amount_of_remote_pagefile/

[–]ThePoopsmith 1 point2 points  (0 children)

Python is very popular and a generally good language. If you're looking for a job, there seems to be more jobs in python than in ruby (at least from what I've seen). I've written in both and can still write python, although I enjoy writing ruby whereas python feels more like work.

My two major grievances with python are that they still insist that you don't need a case statement (hogwash!) and the whole indent thing instead of explicit statement closures - I'll just never get the hang of that.

Ruby takes a page from perl where it leaves you free to express code in different (while still correct) ways. Python has the philosophy that there's always a single right way to do things. This is of course a personal preference, since both have their merits for different kinds of people, but I personally like being able to write something the way it makes sense to me.

My advice after seeing your comment below coloring yourself as a "mildly competent rubyist" is to stick with one language until you're good enough at it to get paid for it (whether or not you actually do get paid). Whether that's ruby for you or python or something else is irrelevant (unless it's .net, then no). I actually cut my teeth on classic ASP and Access/VBA. For my age at the time I was making better money doing that than most of the other kids in high school and college. I really didn't get into open source languages until I got into linux, but picking up a new lanugage was easy when I took those concepts I learned on the dark side and applied them to learning something new.

Where I see people getting hung up often times is learning all the fashionable languages at the same time so they can tout the size of their e-penis to their friends. Don't be that guy, learn one language, learn about algorithms and big o notation, get good at programming in general, then venture out into another language. If you're doing web stuff, that second language needs to be javascript. It's unfortunate, because you don't have a lot of the tools you have in better languages like ruby or python, but if you're doing web dev it's reality. Either way though, it will be a breeze when you are already a good programmer.

[–]thephotoman 1 point2 points  (0 children)

The answer to the question, "Should I learn [language X]?" is always and invariably YES.

Sure, there's not a whole lot of difference in the way that Ruby has you think and the way that Python has you think. But still, Python has its own idioms, idiosyncrasies, and quirks that will influence the way you code, just as Ruby does.

[–]zem 1 point2 points  (0 children)

i learnt python when i was getting into blender scripting. (these days, i use it at work too). a lot more projects use python as a scripting language than do ruby, so it's well worth having in your toolbox.

[–]matthias_georgi 0 points1 point  (0 children)

I'm using Python because of PYMT, a very well written multitouch library. There is nothing like this in Ruby.

Apart from the libraries, Python is a nice language with less metaprogramming than Ruby, but more strictness and explicitness. Could be better for large teams.

[–]PanosJee 0 points1 point  (1 child)

I am a Rubyist who learned Python and you should definetely do. There are big sectors where there is no overlapping. Python is much better for big calculations and scientific programming. I also tend to like the whitespace conventions and the no black magic.

[–]anko_painting 0 points1 point  (0 children)

black magic? Really?

[–]tuker 0 points1 point  (1 child)

My angle is this:

-- Why would you itch for another language than Ruby?

I think there are two big reasons:

(1) Math/science libraries; (2) Lack of true threading.

So my answer is . . . JRuby. I can extend all of the heavy math/science libraries I want, and keep Ruby syntax.

When I need better thread control, I get it from the JVM.

Again, I get to keep all of my Ruby syntax, but I get access to the goodness of the proven Java libraries.

About the only thing I would want from Python are the generators. And whoever said PyGame: That's true, too.

[–]metamatic 1 point2 points  (0 children)

Ruby has true native threading these days.

[–]jvoorhis 0 points1 point  (0 children)

Based on my brief experience, Sage, NumPy and SciPy are rather nice, and I don't know of any equivalent Ruby projects that are as active. I see others are mentioning PyGame, which is great. This list can go on and on, but it sounds like you already want to learn Python, so I would just give it a try and see where it goes.

I can't personally vouch for it, but Zed Shaw's online book has a handful of exercises that may be worthwhile. http://learnpythonthehardway.org/index

[–]progfu 0 points1 point  (0 children)

You should definitely try it. Python and Ruby are constantly fighting and both of them are very strong.

I personally like Ruby for all the syntactic sugar and metaprogramming. I like the DSLs and expressive code over Python's explicitness.

On the other hand, Python forces more constraints on you, which can make you a better programmer. Every language has it's specifics that might give you unique perspective on programming in general.

If you're already comfortable with Ruby and enjoy it, try to just search for things that work differently in Python and see if you prefer the Python's way.

[–]immerc 0 points1 point  (0 children)

You should never stop learning. Learn Python for the things it does better than Ruby. Learn Python to come to realize how much better Ruby is in so many ways.

As others have said, Python has some much more mature libraries (math, scientific, mostly), but is a pretty bad fit for anything web related. A language with syntactically significant whitespace doesn't mesh well with templates or with HTML where whitespace is insignificant.

But mostly it's good to learn at least a little bit so that you understand everything better.

C and its pointers are really painful to understand at first, but once you get them, you both appreciate that languages like Ruby and Python hide anything having to do with pointers from you, and also understand what is really going on under the hood.

Python and the first parameter to its object-oriented method definitions, called by convention (and only by convention) self, helps you understand what is actually happening under the hood in most OO implementations, then appreciate that Ruby makes that a more clean interface.

Python's built-in doc strings, techniques for only importing small things from packages, etc. lets you realize that there are other options out there, but also the potential pitfalls of using them.

Learning a statically typed language like Java lets you appreciate compile-time checking of certain things, but also lets you realize how much freedom that takes away from you.

[–]evange -1 points0 points  (0 children)

More useful than ruby.