I' m using php+mysql for developing small to medium dynamic sites, especially for intranets (budget, customer service etc etc).
I' m not a guru but I'm pretty fluent in php and now I was thinking of studing AJAX to add that 2.0 whiff to my applications. A couple of days ago I discovered that reddit is not AJAX + php but instead is based on python (pylons framework?). A whole world discovered, ruby, phyton and the such. Now I was wondering if it would be wiser to study those framework instead of the old (?) java?

Also:

1) Are python/ruby a complete substitute of php or they work toghether, i mean: can i write a forum in phyton that interface with a sql database that outputs html?

2) Are these interpreted languages like php (i write them in notepad++ upload the script to the server and i see the results) or they must be compiled?

Personally, I tried lots of frameworks and concluded that they all had some showstopper that prevented me from doing what I wanted to do. What I found is that you have "anarchic" PHP or "app-centric" frameworks like Rails or Django (or CakePHP, etc).

In the end I decided to just roll my own. It's now been in production on highly trafficked sites for over one year.

If anyone is interested, I'll be happy to personally support any early adopters. Please take a moment to check out the docs:
http://zentools.net

Python/Ruby can be complete substitute for Php. Or you can write one service in php and another in Python/Ruby and have them cooperate.

They are interpreted. But You can't just upload the script and see the result like in php. You have to run separate language specific application server to host this web site. This may be a problem if your don't have control over the host.

Python and Ruby are programming languages. I tend to think of PHP as a incoherent blob of language and library functions. So in order to have a "complete substitute of php" you will need to learn the language (Python or Ruby) and find the libraries you need to get the job done. You would have to use some sort of programming framework such as Django and Ruby on Rails.

Both Python and Ruby are interpreted. Python can byte-compile your source and you can distribute only byte-compiled files. Current version of Ruby does not write out byte-compiled files so there is a bit of performance overhead when running Ruby.

If you have programmed in some structured BASIC variant such as VB, you should be able to pick up Ruby pretty easily. Both languages are pretty much on par in terms of expressiveness but in their current versions, Python is much faster. If you want to learn Python, start out with the "older" 2.6 version first. There are still a lot of useful libraries that need to be ported to Python 3K. My suggestion, try them both out and use whichever language you feel most comfortable and productive in. Pay no attention to rabid fanboys.

You must understand that deployment is a bit different for Python or Ruby based applications. The usual "upload scripts and run them" that used to work so well with PHP is not going to work with Python or Ruby if you are going to use a framework such as Django or Rails. You can mimic the "upload and run" process by programming using CGI though. On Python you can also choose a hosting provider that supports the WSGI standard (normally via mod_wsgi).

So all that expensive setup work is amortized across a whole load of requests. PHP throws state away at the end of each request (if you're not using an opcode cache, it even throws away the compiled bytecode!), and so you end up doing:

foreach request:
setup()
process(request)

Which sucks quite a bit if your routing needs to build some complex state machine or regexp tree or so every single hit. This is a good reason to go for lighter frameworks which play more to PHP's strengths rather than trying to copy Rails or whatever:

Bad benchmark to quote. All it does is a simple SELECT and when I ran it with latest Cake it performed just as fast as CodeIgniter did on my machine (downloaded his exact zip).

Frameworks are a tradeoff. You get stable and well developed features but of course its going to have more overhead than if you did the minimum that your app needs. For 95% of devs out there, these frameworks will work great. Even Rails which has issues on big sites like Twitter will be fine for most of us.

3) Python, because it seems to be much more stable than Ruby, and a bit faster too.

I'd recommend studying Python, and a web-framework called Django.

Edit:

Yes, nitpickers.. The difference in speed between Python and Ruby is not very remarkable, but it's there in case the OP happens to care.

Apparently Zed Shaw found quite a lot of problems hiding in the Ruby codebase, and Ruby + Rails has been known to leak memory & require restarts, no?

Ruby & Rails has a lot of "magic" happening, whereas Python wants to be as clear and straightforward as possible.

Python and Django are both extremely well-managed projects. Both are developed by sensible people, making sensible decisions, making releases in a sensible way. Hence the claim of Python being "stable". Happy now?

I thought that the OP could get by with less detail, but of course, Reddit couldn't.

I 'do' both Ruby and Python and though Python is said to be a bit faster, you might want to start off with Ruby nonetheless. The Rails framework (very popular at the moment) has pretty good documentation and there are some decent books written about it.

There is nothing more 'stable' about Python, though you can argue that Python has a more stable implementation, since Python has a proper standard, where Ruby lacks this.

On the other hand: Rails has the momentum, with more and more hosting providers supporting it, so if you do not host yourself, go for Ruby and Rails.

If you dig Ruby, Python will be easy to switch to if you'd ever want to.

Ruby's also got a very high quality Java implementation, which introduces concurrent native threading, the very good JVM GC, and typically significantly improved performance, which is a nice option to have for deployments.

Python is a bit faster, but claiming that this is a solid advantage in favour of python is a joke. When people want speed, they use C or C++. When people want to deliver stuff quickly, they use "scripting" languages. Making a huge difference among the speed of scripting languages when multiple core and +2 GiG RAMs are soon ubiquitous is really a joke.

Also, I want to ask you what you mean with "stable", because I am using Ruby since 4 years, and I never had ANY problem with stability in the 1.8.x branch. (I had problems with 1.9.x but it was a moving target all throughout).

Anyway, to the guy in question - I recommend you to choose on your own and not listen to what people like anonymous_hero recommend. In reality, ruby and python are very close together in many key aspects, more than they have in common with php.