Trying to decide between PHP and Python

A

Alice Bevan–McGregor

I confess that I haven't used PHP so someone correct me if I'm wrong.
[snip]

+1

You're pretty much on the ball with your description. I might summarize it as:

PHP (PHP: Hypertext Processor) is a templating language with a
significant enough standard library for aspirations of general-purpose
scripting. Python is a general-purpose scripting language with
numerous templating languages, let alone the terrifyingly large
standard library. ;)

Yes, PHP has templating language syntaxes like Smarty, but you're
running a template parser within another template parser...

A fairly common sarcastic quote is:

"You aren't a real Python programmer until you write your own
[coroutine framework | web framework | templating language | ...]!"

I've done all three, and this probably does not make me a good person.
;) The coroutine framework was a hack to see how they work through
experimentation, but I'm quite proud of the web framework and
templating system! :D

- Alice.
 
Joined
Jan 5, 2011
Messages
1
Reaction score
0
As Alan said PHP is really geared towards web programming of dynamic webpages, python is a much more general programming language (scripting language) that can be used in almost every application (including web programming - though it is a lot less mature in that capacity).

Python is very powerful and has a nice neat syntax as well as libraries for pretty much everything under the sun!
 
T

Tomasz Rola

My two cents, I am understanding python far better by learning scheme.
Didn't intentionally set out to achieve that as a goal just a by
product. An excelent resource http://htdp.org and using the racket
scheme ide(as much of an ide as idle), simple thorough well explained
concepts via worked examples and a very encouraging and enthusiastic
mail group, much like this list.

I would so love a book like that for python but after i complete htdp
I may not need it.

Agreed. I freezed my Racket usage while it was called DrScheme but I keep
my eye on it ever since. It is really nice and well designed environment.
It took me by a storm, which I cannot say about Idle ;-) .

I also agree that every Python programmer could gain something valuable by
at least trying it, as well as reading their docs and mailing list for a
while. Or every programmer regardless of his/her current language.

HTDP is interesting book, pity I couldn't read it when it might have made
a bigger difference to my development.

Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature. **
** As the answer, master did "rm -rif" on the programmer's home **
** directory. And then the C programmer became enlightened... **
** **
** Tomasz Rola mailto:[email protected] **
 
G

Grant Edwards

Heh. One day, guys, when you have nothing better to do, try writing a
parser for Lisp-like language (Common Lisp, Scheme, whatever). After that,
do the same with some other language of your preference (Python, Java,
whatever). Compare time and code spent...

I've heard that justification many times, but I think it's 200%
specious.

1) How often is a compiler for language X written?

2) How often is source code written in language X?

3) How often is that source code in language X read/modified?

If you compare those numbers you'll realize that optimizing for case 1
at the expense of cases 2 & 3 is just plain stupid. Perhaps there is
somebody on the planet who finds Lisp as easy to read/modify as
Python, but I've never met him/her and never have you...

Optimizing a language for the ease of the compiler writer is like
saying, sure, that car is expensive to buy, expensive to run, doesn't
work well, and tends to kill a lot of people, but it took less time to
design!
 
N

Neil Cerutti

Optimizing a language for the ease of the compiler writer is
like saying, sure, that car is expensive to buy, expensive to
run, doesn't work well, and tends to kill a lot of people, but
it took less time to design!

A simple to parse syntax has non-trivial benefits. It makes a
macro system feasible.
 
T

Tomasz Rola

I've heard that justification many times, but I think it's 200%
specious.

1) How often is a compiler for language X written?

2) How often is source code written in language X?

3) How often is that source code in language X read/modified?

If you compare those numbers you'll realize that optimizing for case 1
at the expense of cases 2 & 3 is just plain stupid.

You are right here. OTOH, a parser or even a compiler are just nice
examples of non-trivial code. IMHO, the more non-trivial task one is
trying to perform with a language, the more one appreciates language
features that seem nonsense for less trivial programs. While in theory one
can do the same job with a shovel and an excavator, in practice one should
use the right tool depending on the job. Trying to get a car from a
snowdrift with excavator requires a lot of attention and caution. It is
easy (even if tiring) task for a man with a shovel. So one could
extrapolate from this, that using excavator is ridiculous compared to
using shovel. However, building dams or digging mile-long trenches with a
shovel is not only ridicule but a sign of bad planning or desperation. And
maybe even an incompetence.

Now, how often they are building dams, trenches and other nontrivial
constructions? I would hypothesise that in a society well developed, this
happens quite often. Maybe even once every two days.

The truth is, once you have an excavator, you don't shy away from using
it and you more often than not are open for doing non-trivial assignments.
Perhaps there is
somebody on the planet who finds Lisp as easy to read/modify as
Python, but I've never met him/her and never have you...

Here you are wrong. I meet the guy every day in a mirror. Now you have met
him, too.

I doubt, however, that I am so extraordinary as to be just one on the
whole planet.
Optimizing a language for the ease of the compiler writer is like
saying, sure, that car is expensive to buy, expensive to run, doesn't
work well, and tends to kill a lot of people, but it took less time to
design!

I guess every compiled language designed so far has been somewhat
optimised for compilation by it's designers.

If you say that some language, like Common Lisp, had been optimised for
compiler at the expense of human programmer, I disagree. I find programing
in CL to be nice experience, maybe even a refreshing one. From what I have
read about Lisp history so far, your claims don't match the facts (at
least facts as I know them).

True, it requires some learning. AFAIK, nobody has to learn, so it is
purely voluntary effort.

Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature. **
** As the answer, master did "rm -rif" on the programmer's home **
** directory. And then the C programmer became enlightened... **
** **
** Tomasz Rola mailto:[email protected] **
 
T

Tomasz Rola

There. Now that I've tossed some gasoline on the language wars fire,
I'll duck and run in the other direction :)

May I suggest a better strategy? Run first, duck next :).

Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature. **
** As the answer, master did "rm -rif" on the programmer's home **
** directory. And then the C programmer became enlightened... **
** **
** Tomasz Rola mailto:[email protected] **
 
J

John Nagle

About once a year, I have to learn yet another programming language.
Given all the recommendations (an outstanding accolade from Bruce
Eckel, author of "Thinking in Java") I have set my aim to Python.
Sounds kinda cool.

If you're just doing simple web-based services, PHP is the
way of least resistance. It's supported by almost all hosting
services. Trying to run Python on shared hosting is generally
painful. Either you're stuck running in CGI, which means you
take the cost of a Python load on every transaction, or you
have to find someone who will let you run long-running
processes so you can run FCGI/WSGI or some Python framework.

Efforts to compile PHP to hard code have been more successful
than the corresponding efforts for Python. Facebook developed
and uses their HipHop compiler for their huge internal PHP
code base.

John Nagle
 
C

Chris Rebert

   If you're just doing simple web-based services, PHP is the
way of least resistance.  It's supported by almost all hosting
services.  Trying to run Python on shared hosting is generally
painful.  Either you're stuck running in CGI, which means you
take the cost of a Python load on every transaction, or you
have to find someone who will let you run long-running
processes so you can run FCGI/WSGI or some Python framework.

VPS hosting can be surprisingly cheap these days though (e.g. prgmr's
super-cheapo plan is $4-5/month); you get root access, so setting up a
Python web application is much easier.

Cheers,
Chris
 
J

John Nagle

VPS hosting can be surprisingly cheap these days though (e.g. prgmr's
super-cheapo plan is $4-5/month); you get root access, so setting up a
Python web application is much easier.

That makes it possible, but not easier. If you're just running a
typical web site with some "web 2.0" pages, forms, and a database,
it's probably easier to use PHP. Administering a virtual machine
instance puts you in the system administration business. With
PHP, the hosting service will routinely handle that for you.
You just create PHP pages, upload them, and the behind the scenes
machinery is someone else's problem. If PHP breaks on shared hosting,
enough users will be screaming that it gets fixed.

John Nagle
 
A

Alan Meyer

1) How often is a compiler for language X written?

2) How often is source code written in language X?

3) How often is that source code in language X read/modified?

If you compare those numbers you'll realize that optimizing for case 1
at the expense of cases 2& 3 is just plain stupid.

Today? Sure.

But let's remember the context. LISP was created in 1958 at a time when
the only other high level language (if the Wikipedia is right) was
Fortran. Writing a practical interpreter or compiler to run on a 16 or
32 K word memory machine, using punched cards and maybe mag tape, and
probably starting in assembly language, was a pretty daunting task. It
required gobs of intelligence and not a little fortitude.

So instead of calling it "plain stupid" I'd be more comfortable saying
that it is "no longer the best design choice for modern computers."

Alan
 
G

geremy condra

   That makes it possible, but not easier.  If you're just running a
typical web site with some "web 2.0" pages, forms, and a database,
it's probably easier to use PHP.  Administering a virtual machine
instance puts you in the system administration business.  With
PHP, the hosting service will routinely handle that for you.
You just create PHP pages, upload them, and the behind the scenes
machinery is someone else's problem.  If PHP breaks on shared hosting,
enough users will be screaming that it gets fixed.

                               John Nagle

I'm not exactly a god unto sysadmins and I've had no problems with
either bargain-basement Python managed hosting or VPS's.

I'd encourage anybody looking at the differences between PHP and
Python to try both and get some hosting that lets you use either. I'm
pretty confident that in the long run Python will win out.

Geremy Condra
 
B

Benjamin J. Racine

Cython/Sage is no small undertaking, but I have no idea how to measure relative success between that and hiphop.

Ben
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top