[newbie] Equivalent to PHP?

G

Gilles

Most high level languages probably have some sort of HTTP server
available. Some make it trivially easy to plug some code in and start
serving. Python is advertised as "batteries included", and one of its
packets of batteries is a fairly full-featured set of internet
protocol handlers.

Thanks for the longer explanation. With so many frameworks, I'd like
to know what benefits they offer as compared to writing an application
from scratch, and if they do offer obvious benefits, which one to pick
:-/

http://wiki.python.org/moin/WebFrameworks
 
G

Grant Edwards


I just started learning PHP about a week ago in order to do some work
on an embedded device's web site implementation my employer contracted
out. I've done a fair bit of web stuff using CGI in shell, C, and
Python as well as server-side Javascript. I've done a lot of normal
application programming in C and Python and have used a smattering of
other languages (Smalltalk, Scheme, Modula, FORTRAN, BASIC, assembly
for a variety of processors, and even Prolog).

I must say that I agree with the assessement of PHP linked above.
It's not that the language has a design that's not to my taste -- it's
that it has no design at all. It seems to be a mass of miscellaneous
bits and bobs from other languages that have accreted over the years
via some sort of random-walk process.

PHP seems to encourage (if not require) bad practices such as
returning values from functions via global or instance variables.
 
P

Prasad, Ramit

Thanks for the longer explanation. With so many frameworks, I'd like
to know what benefits they offer as compared to writing an application
from scratch, and if they do offer obvious benefits, which one to pick

I am going to state up front that I have never tried any of the
frameworks so take my recommendation with a *lot* of salt! :)

I would recommend Django as it seems to scale up nicely and I know
that it has an active community which can be a godsend for getting
help as a "newbie". That being said it does have a bit of a learning
curve compared to some of the lighter frameworks, but not so much
of one as to counteract the advantage of scalability. Again, this
is all based on opinions that I have read (and remember) and not
on any facts.

Maybe this article will help you http://www.infoworld.com/d/applicat...hon-six-python-web-frameworks-compared-169442
The comments on /. should round out anything missing from the article (I hope)
http://developers.slashdot.org/story/11/08/10/2111203/six-python-web-frameworks-compared


Ramit


Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
712 Main Street | Houston, TX 77002
work phone: 713 - 216 - 5423

--
This email is confidential and subject toimportant disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.
 
G

Gilles

A long running process has lots of benefits that makes design and
development easier and makes your app faster.

Thanks much for the infos. Makes you wonder why commercial companies
still choose PHP to write their web site.
 
S

Steven D'Aprano

Thanks for the longer explanation. With so many frameworks, I'd like to
know what benefits they offer as compared to writing an application from
scratch

Surely the obvious answer is that a framework offers the benefit that you
don't have to write the application from scratch.

Why write in Python instead of creating your application from scratch
written in assembly? Because you get the benefit of 40+ years of
collective programming language design experience, 10+ years of
collective Python experience, tens or hundreds of thousands of lines of
carefully debugged and tuned code, and a large community of users with
experience in the language, books, training courses, etc. whom you can
call on for advice (free or paid consulting) and as a pool of would-be
employees if you need to hire developers.

You wouldn't (or at least shouldn't) even *consider* writing your own
language unless you had really good reason, and no other existing
language would do.

Web frameworks are similar: you get tens or hundreds of thousands of
lines of carefully debugged and tuned code, and a community of users,
books, etc. Unless your needs are minuscule, writing your application
from scratch will end up duplicating much of the framework, only (let's
be realistic here) badly. By the time your application is as stable,
debugged and tuned as as existing framework, you will have spent probably
in excess of ten person-years.

At which point, you have a community of one, yourself. (Or possibly you
and a handful of your fellow project members.)

For anything but the smallest web applications, where no framework is
necessary, and the very largest, if no existing framework will do, why
would you even consider reinventing the wheel?
 
G

Gilles

Surely the obvious answer is that a framework offers the benefit that you
don't have to write the application from scratch.

Yes, but between receiving the query and sending the response, what
features do frameworks offer that I'd have to write myself otherwise?
 
P

Prasad, Ramit

PHP was developed for non-developers. (see
And as to why Facebook chose PHP...

You are not Facebook (at least yet).

They also choose to transform PHP into C++ for performance reasons. Not
something the average large website would want to do.
http://www.sdtimes.com/blog/post/2010/01/30/Facebook-rewrites-PHP-runtime.aspx
http://www.datacenterknowledge.com/the-facebook-data-center-faq-page-2/


The real question is would they use it again if they were to start over?
http://www.quora.com/Quora-Infrastructure/Why-did-Quora-choose-Python-for-its-development


These decisions are influenced bya multitude of factors
1. familiarity/popularity of a framework
2. support
3. what someone thinks is "best" for specifications
4. cost
Notice only 1 of those factors was what was actually"best".


Also remember you asked this on a *Python* mailing list. I am sure you
will get different responses on a PHP mailing list.

Ramit


Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
712 Main Street | Houston, TX 77002
work phone: 713 - 216 - 5423

--
This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.
 
G

Gilles

You are not Facebook (at least yet).

Indeed, but with so much criticism about PHP, it's odd that they would
still choose it.

Anyway, thanks much for the infos. I'll look at the web frameworks and
how to connect the Python app to a front-end web server.
 
T

Tim Chase

Yes, but between receiving the query and sending the response, what
features do frameworks offer that I'd have to write myself otherwise?

Let's see

- CRSF protection
- keeping things DRY
- templating (or you could use many others)
- user management
- administrative interface
- database creation/introspection
- i18n
- an ecosystem of pluggable add-on apps
- URL routing
- view decorators
- easily swappable back-ends
- active development across multiple lines of business
- GIS support
- abstracted ORM (or you could use SQLObject or its kin) to allow
you mobility between DB back-ends should you want to

That's just my off-the-top-of-my-head list of things that you'd have
to come up with that Django happens to give you out-of-the-box.

-tkc
 
S

Steven D'Aprano

Yes, but between receiving the query and sending the response, what
features do frameworks offer that I'd have to write myself otherwise?

What, google broken for you? *wink*

Copied and pasted from http://cherrypy.org/

FEATURES
A fast, HTTP/1.1-compliant, WSGI thread-pooled webserver.
Easy to run multiple HTTP servers (e.g. on multiple ports) at once.
A powerful configuration system for developers and deployers alike.
A flexible plugin system.
Built-in tools for caching, encoding, sessions, authorization, static
content, and many more.
Swappable and customizable...everything.
Built-in profiling, coverage, and testing support.
Runs on Python 2.5+, 3.1+, Jython and Android.


Plus you have a whole community of people working on the framework,
fixing bugs and writing documentation, and you don't have to pay them a
cent.

http://duckduckgo.com/?q=cherrypy+features

Repeat as needed for any other framework you are interested in.

Essentially, using a framework means you get to concentrate on the actual
problem your application is meant to solve instead of spending most of
your time worrying about building the infrastructure (the framework!) to
hold your application.
 
P

Prasad, Ramit

Indeed, but with so much criticism about PHP, it's odd that they would
still choose it.

Could be a familiarity/ease issue as it was originally started by a
college student (and college students seldom have meaningful real
world experience) before it exploded in size. Also do not forget
that it was developed nearly a decade ago and technology has
changed (hopefully improved) a lot since then.
Ramit


Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
712 Main Street | Houston, TX 77002
work phone: 713 - 216 - 5423

--



This email is confidential and subject to important disclaimers and
conditions including onoffers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.
 
T

Terry Reedy

And as to why Facebook chose PHP...

*When* did 'Facebook' choose it? (My brief search did not reveal this.)
Facebook started as a quick hack (Facemash) by student Mark Zuckerberg
in Nov 2003. If he used PHP (1995) then or for his next site or for the
initial Facebook a few months later, that would suggest an answer.
 
G

Gilles

That's just my off-the-top-of-my-head list of things that you'd have
to come up with that Django happens to give you out-of-the-box.

Thanks much. So the next step will have to find a framework that's
right for a given application.
 
G

Gilles

I'm an amateur programmer, and would like to know what the main
options are to build web applications in Python instead of PHP.

When I need to host my Python application (preferably in Europe since
my users will be located there), what are the options?

Do Python hosters provide a VM so that it's just like a remote Linux
server where I'm free to install whatever I want, or do they force
users to use specific versions of Python and specific frameworks eg.
Django?

Thank you.
 
P

Paul Rubin

Gilles said:
Do Python hosters provide a VM so that it's just like a remote Linux
server where I'm free to install whatever I want, or do they force
users to use specific versions of Python and specific frameworks eg.
Django?

There are both kinds. The first kind is called a Virtual Private Server
(VPS). The second kind is called shared hosting. VPS is very flexible
but shared hosting can be cheaper, and easier to use if you have no
sysadmin skills. I'm assuming you don't have enough workload to want to
rent a physical server (sometimes called a "dedi", short for dedicated
server) or colo (colocation, meaning you buy your own hardware and
install it in a rack slot that you rent at the data center).


OVH (www.ovh.com/fr) is the biggest French hosting place and they have
all three types of service, I think. Their low cost branch is
www.kimsufi.fr which has extremely attractive prices. I have heard
mixed things about them: you get a lot of resources for the money, but
that they can be hard to deal with in various ways. So it sounds not
great but not terrible. Kimsufi dedis are cheaper than anything
comparable that we can get in the USA, so I have been interested in
renting one for some of my own stuff, but I haven't pursued this yet.

www.webhostingtalk.com and www.lowendbox.com are good places to research
this sort of thing. lowendbox.com is specifically for cheap VPS's.
 

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,776
Messages
2,569,603
Members
45,196
Latest member
ScottChare

Latest Threads

Top