views:

749

answers:

11

I am already working on some software in Python but I'm having one of those days where I step back and reflect just to make sure I'm not spinning my wheels. I know that Twitter launched with RoR because it was fast to build. Then they almost moved into another language in 2008 because of scalability issues. This has caused me to step back and introspect for a moment to make sure I'm heading down the right path. I've read in some tutorials and other places that Python is "a great first language" or a "nice beginner language" as though it's not capable of larger tasks. I look at it as Python can do what Java or ASP can but with about 1/4th of the code, not to mention I don't have to build or compile, etc. I've read that Java runs quite a few times faster than Python which is important of course, but then I read everywhere that hardware keeps getting cheaper and there are projects like Unladen Swallow by Google to make Python faster. Should I be concerned or is this just the remnants of Java developers?

+12  A: 

To answer your title, "yes". Python scales all the way from a beginner's language to running massive enterprise systems.

Ignacio Vazquez-Abrams
+7  A: 

Python is a fine beginner language. In fact it's almost an ideal beginner language because it's fairly "pure" in the sense that it's mature, readable, well-designed and consistent so you can concentrate on learning concepts without learning exceptions to syntax.

Python is also used on larger systems. You can write Web apps, desktop apps, cloud apps (eg Google App Engine), etc on it. It's very general purpose.

Your question seems to imply that a language is either a beginner language or robust, which is a strange assertion as a language can be both and arguably robustness is a useful trait in a beginner language.

As for Twitter, yes they did switch from Ruby on Rails to Scala, something the blogosphere was quite abuzz with for awhile. It's a somewhat controversial decision because it seemed to be rooted in lack of performance of a homegrown message queue. But anyway, it's a long story.

You should ignore such things when you're just learning something. They're irrelevant distractions.

cletus
I don't think "pure" is the word you're looking for here. Pure in language design terms tends to imply purely functional (think Common Lisp), or purely OO (think Ruby, Smalltalk) or something. Python tends to favor "practical" over "pure" most of time (to its benefit, imho).
Gregg Lind
I tend to think of Python as purely OO in interface and purely functional in implementation. Everything in Python is an object, and every statement or expression leads to at least one function call in the __ level of the code.
orokusaki
Twitter's front-end is still in Ruby on Rails. They switched out a message bus written in ruby for one written in Scala or erlang. This is one of the biggest myths about Rails that is still circulating without debunking
Michael Mullany
+3  A: 

I know a company which uses Python for front-ends and C++ for backends, communicating via FastRPC protocol (seznam.cz). This is the largest national portal/freemail/fulltext/... serving milions of users daily, so I'd say it's robust enough.

Ondra Žižka
+1  A: 

Python is perhaps the best language to learn programming. And Python is a fine language even if you have several years of experience, because Python is well designed and not limiting. Really big applications (facebook) are build with the (ugly) language PHP which plays in the same performance league as Python. But the bottleneck of big web applications is typically the database and not the frontend.

So the answer is: it depends. You can be happy with Python for your life. Depending on the kind of software you develop you may need a language with more performance like Java. If so, I would look at Scala. Scala is similar concise to Python but statically typed and much faster, but Scala itself is more complex than python. Scala gives developers more liberty to do things as they want, what can be great but can also lead to cryptic code.

deamon
"Scala is similar concise to Python" - the link you show suggests Scala is 2-3 times less concise than Python, and pretty much the same as Java.
igouy
A: 

There are plenty of ways of making Python faster, but that doesn't matter. For the majority of code, what matters is how long it takes to develop it, not how long it takes to run... and a language that is clear and simple enough for beginners, but sufficiently expressive for large systems and flexible enough to stay out of the expert's way is a great thing for keeping the development time under control.

Andrew McGregor
"For the majority of code" - How do you know what matters for the majority of code?
igouy
The majority of code is internal projects for websites or business systems. In those cases speed of development almost always dominates the cost of the project, not hardware or other system resources.
Andrew McGregor
oh my! Andrew says "what matters is how long it takes to develop it, not how long it takes to run". I take it to mean you consider development time to be more important to success than performance. Development time does matter, as developer time is a resource that needs to be properly managed, like any other resource. However, at the end of the day, if a project was finished on time or ahead of schedule, but performance was terrible, most managers I have worked for would consider the project a failure, or give it more time to fix performance issues.
Jay
Oh, of course. Not that Python applications are slow or hard to profile and speed up; they definitely can be made to perform. But you can easily try optimising too early, and language choice is part of that.
Andrew McGregor
+1  A: 

I'd recommend Python to someone just learning to program, and I'd recommend it to a seasoned programmer looking for a new language to learn. I'd recommend it for anyone in between, too.

You said it yourself: Google is behind Python, and that's a sign that it's not just a toy language.

pib
I think they're also behind Java, Go, V8 and a thousand others.
Evan Carroll
@EvanCaroll "Behind" and spending millions of dollars to enhance because their second largest property is running on it are two different things.
orokusaki
So they're **strongly** behind Python, then...
pib
lol, I didn't mean to sound like such an evangelist. I was referring to EvenCaroll's comment on your post.
orokusaki
+24  A: 
Norman Ramsey
Thanks for your answer. Great information. BTW, I just read that YouTube's back end is written 100% in Python. That's where Unladen Swallow came from apparently.
orokusaki
And Facebook's backend is written in PHP, that doesn't mean these are good un-regretted decisions. But, it does mean it /can/ work, so long as "can" is good enough for you then you have the answer you're looking for.
Evan Carroll
+1 Good, even-handed answer.
cjrh
@Evan Caroll I understand that I can take a wagon to work each morning because it can work. I will make it there. Problem is that I want to have fun along the way and not have to change my tires each day, so I use a nice car. I'm not comparing PHP to a wagon, but the idea that "If it works, then who cares" bothers me. Complacency is why the world is such a terrible place.
orokusaki
i'm sooooo glad i'm porting Lua to the .NET framework, then maybe lua will get the attention it deserves
RCIX
Lua isn't that much faster than python
arthurprs
@arthurprs It is way faster than Python, but that doesn't matter. If you only used Python for 10% of it's functionality you could probably get the same speed and you'd still have more functionality than Lua. Lua is a very small language.
orokusaki
+1  A: 

Yes. Assuming you didn't mean xor.

Robert Rossney
+2  A: 

If you are planning to do web stuff with python, just go ahead and have fun. Language choice is hardly ever the bottleneck in web apps. Just to quote Rasmus Lesdorf (creator of PHP):

"However, he continued to say that raw execution speed was "not a significant factor" for many applications. "Even if you double the execution speed of something that is 10% of your overall request cost, that is only a 5% overall improvement...."

Usually, the bottleneck is somewhere else, in your database or the network latency. That being said, python is just great for almost anything (except number crunching and animation).

But even these limitations will go away soon. There are many ongoing projects aimed to speed up python by a large margin. For example, Pypy's jit is already up to 9x faster in some benchmarks (see this graph: http://buildbot.pypy.org/plotone. ).

Unladen Swalow is also getting a lot of attention lately, since it seems to be merged into Cpython soon. Google is behind this project and for good reasons (Youtube is almost entirely written in python, and it is the second largest website after Google itself).

My advice: If you like Python, just enjoy it. It's a great language and a pleasure to use. Your concerns about speed or scalability will be addressed by the time you are profficient with it and making significant things.

Luis

Luis Gonzalez
@Luis Can you point me to the details about it getting merged with CPython. I'm very excited. It seemed like things went dark after 3rd quarter results, not because it wasn't a success but because it was more than Google wanted to bite off.
orokusaki
+4  A: 

Google and Nasa use Python. That alone should address all your concerns: if Youtube can be built using a language, you can rely on it.

e-satis
@e-satis Amen brother 1+
orokusaki
+3  A: 

Youtube is the second largest website today (only surpassed by Google). It is written almost entirely in Python. http://digg.com/programming/YouTube_is_almost_entirely_written_in_Python So I guess that Python scales well.

Note that speed is a quality of language implementations that is not constant in all situations. Python is slower than other languages in many situations, but is very fast in others (for example string handling and I/O). And guess what? The web is a whole lot of text...

Also note that many people are working hard to making it fast (google "pypy jit" or "unalden swallow"). So the situation may improve very soon.

And finally, think about what you want to do with it. Do you think you are about to create a killer web site or application that needs to scale up the wazzo anytime soon? Like, say, Youtube??

I'd say that 95% of the times, Python is fast enough and, if slower, the difference is negligible. Only in very specific situations its speed is a problem (such as 3d graphics applications or highly numeric computations), and even in these cases, there are tools to make it faster (psyco, pyrex, cython, shedskin, numpy, etc).

In all the other situations were speed is not a problem, Python gives you a HUGE productivity advantage.

It's like talking about cars: you can choose between a formula 1 Ferrari which is super fast ( like c++ ) or a BMW which is no near as fast as a Ferrari, but which is still quite fast for the intended use, which is driving to work and going out on week ends.

You may see that even when the Ferrari is much faster than the BMW, it has many shortcomings: only the driver can use it, there's only one seat, no luggage, no air conditioner, no radio, it's uncomfortable, noisy, and it's only good for race speeding.

On the other hand, the BMW is comfortable, you can carry your luggage and your family, it's a pleasure to drive, it's silent, etc, etc... and it's way faster than you need!

Which one should you choose as your every day car?

Luis

Luis
@Luis I agree, but I have to be honest. I have a buddy with an Aston Martin and he drives it every day, and I think that's just awesome.
orokusaki