5 ms·
PHP is a scripting language and Django is a python web framework. PHP to Python would make more sense.
by xd 16y ago
PHP is a scripting language and Django is a python web framework. PHP to Python would make more sense.
- IgorPartola 16y agoIn some sense, yes. However, PHP is a language + a giant standard library geared towards web development. In some sense it is a web framework or at least is often used that way. Since as a web framework, PHP's standard library falls short, things like CakePHP and CodeIgniter were created, but have their own shortcomings. But I consider Django a better framework than either PHP's standard offering or things built on top of it. However, the transition from developing web applications in PHP to using Python/Django is not as straightforward and I think a nice guide could be in order.
- xd 16y agoPHP is NOT in any sense a framework. A framework is an abstraction built up USING a programming language, like PHP. In what way does PHP's standard library fall short that Python overcomes?
- IgorPartola 16y agoPHP's standard library provides function likes parse_str, headers and setcookie. It provides language constructs such as $_GET, $_POST, $_FILES, $_COOKIES, $_SESSION which are web specific. Its standard library comes geared towards outputting HTML and it provides a FastCGI process manager. I think most importantly, it provides a templating capability (albeit a very poor one), that is geared towards embedding dynamic content in HTML. It is by all means at least an attempt at a web framework. In what ways does PHP's standard library fall short of Python's? I was never comparing the two. I have always found that both could get the job done, except PHP's uses a very weak naming convention/has none at all. I was comparing PHP's standard library features with those of Django. Here, Django wins hands down. If you are not familiar with either, I recommend trying reading through their tutorials and seeing which one comes out with a more complete product in which one feels less messy. Lastly, implying that PHP's standard library is not a framework because it is not built in PHP ("A framework is an abstraction built up USING a programming language, like PHP.") is just plain wrong. If I decided to speed up Django by re-writing every line of its code in C and making it an extension to Python rather than a Python module, without breaking any function signatures, would Django cease being a web framework? What would it become then? What if instead of C I chose Visual Basic, or Common Lisp, or F#, or even PHP (assuming I found a decent way to compile it to a binary)? A framework is collection of code that abstracts certain functionality. See http://en.wikipedia.org/wiki/Software_framework http://en.wikipedia.org/wiki/Software_framework for further information. EDIT: I am not at all talking about PHP the language vs Python. The two are different and both have some very interesting features. PHP 5 has grown up to be a pretty interesting general purpose dynamic language. I am specifically talking about using PHP on the web.
- xd 16y agoI'm not sure where to begin with all this. It's late and been a long day so I will try and follow up most of this tomorrow morning. However, to your first set of points .. Where you call pre-populated global variables "language constructs". They are not. PHP calls them "super globals". These are global variables mapped from the GET/POST/Cookie client headers into the server environment by the PHP SAPI, for instance the Apache SAPI. PHP has many SAPIs, including a command line one, which doesn't populate these globals for obvious reasons. Oh and FastCGI for PHP is provided by a SAPI as well (nothing to do with the standard library). Oh and quickly - "I was comparing PHP's standard library features with those of Django." Can I pick a PHP framework of choice and start comparing it to Python?
- weaksauce 16y agoA lot of php(most?) is done as a backend for webpages. The php to django book title makes sense in the common usage.
- xd 16y agoDjango is Python code that sits on the server, just like PHP code.
- weaksauce 16y agoNot all php is code that sits on the server. It's a general purpose scripting language.
- xd 16y agoI was attempting to make the point that Django is Python code that sits on the server as a backend for web pages like your stated common use of PHP. So why PHP to Django? How would the Python crowd feel if it was the other way around, for instance: Python to Codeigniter.