Portal Home > Knowledgebase > Articles Database > php vs. python
php vs. python
Posted by hq12, 12-29-2009, 10:02 PM |
Hey guys, for quite some time I have been learning php/mysql. Although, I know the basics of it; I was wondering if I should change to python given that it seems that it is being used more widely. what do you think?
|
Posted by Crothers, 12-29-2009, 10:39 PM |
I made the switch to Python a while ago, I would consider my PHP comprehension to be between extremely high and mastered.
When I switched to Python it literally took me weeks to get the syntax right when I'm punching through code. However I feel that I'm a better developer because of this change. Python is a far more capable language than PHP can ever hope to be in my opinion.
tl;dr: Python is a big switch, its far more powerful. You'll thank yourself for learning Python. However it will take longer to learn the syntax and learn to properly read the manual then it did to learn PHP.
|
Posted by jjk2, 12-29-2009, 11:40 PM |
what do you want to achieve ?
python is more powerful but relatively more difficult to learn than php. if you are just building frontend web properties, php is good enough. of course you can do it in python but why ? always choose the path of lowest resistance.
|
Posted by mwatkins, 12-29-2009, 11:57 PM |
Python the language is actually quite small and concise. Learning the language generally doesn't take all that long; learning the standard library (of any language) is usually where you spend more time in the long run.
PHP is a web-focussed language; Python is a general purpose language which happens to have quite a few well-supported web framework communities.
In order to compare web development in PHP vs same in Python you'll need to select one or more Python web frameworks - try out their tutorials - and see which fits your brain best. Perhaps one of them will appeal to you more than PHP, perhaps not.
If you have control over the execution environment (web hosting) for your web apps, I'd have no hesitation in recommending you have a close look at Python - perhaps check out Django or TurboGears2 web frameworks - each has a simple tutorial that will get you going.
These frameworks usually deliver quite a bit more than a templating system - often you get a testing environment, boilerplate code generation (a project skeleton quick start), some helpful separation of logic, models and views, a library of web app "helpers" and such.
Of course you can get the same from a PHP framework as well.
I would disagree with comments that suggest Python is somehow harder than PHP; in my experience it is quite the opposite - doing hard things is easier in Python and often far less verbose. I often post code snippets here showing just that.
What is harder, especially for those who have only experienced the PHP style of code in HTML development it makes so easy, is choosing a web app execution environment. You get that for free in PHP, and virtually all web hosts support default PHP web app hosting (whether it is secure or not is another matter depending on the host). For Python and other general purpose languages, the interface between web server and app needs to be put in place. Run of the mill web hosts rarely have a good solution for this. Better hosts do.
Last edited by mwatkins; 12-30-2009 at 12:05 AM.
|
Posted by addcomex, 12-30-2009, 05:35 AM |
The difference between PHP and Python
Posting in the full realization of the futility of doing so, there’s some PHP bashing (as usual) happening on reddit at the moment: PHP vs Python – the real difference, brought on by this mildly amusing image. While I can accept the points – technically it’s actually much harder in handle errors uniformly in PHP and the community is less rich in computer scientists than Python – the corresponding flame war on reddit manages to miss a different point, which is easiest expressed in code.
What’s the most significant difference between these two scripts?
1 >
Last edited by bear; 12-30-2009 at 09:43 AM.
|
Posted by hq12, 12-30-2009, 10:27 PM |
Hey guys thank you very much for the advice. I appreciate it! for those who have experience both langugages, do not hesitate to comment!
|
Posted by Simfan147, 12-31-2009, 11:26 AM |
I know Python for simple scripting. I tried using Django. A couple things stopped. You have to use a Linux or Mac OS to develop it. You cannot do it on a Windows machine. Configuring URLs was a pain so I just quit it and went back to ASP.NET. I would go with PHP.
|
Posted by FreeKill, 12-31-2009, 02:35 PM |
I've used both quite a bit. In 99.99999% of cases, choosing a language is pure preference. Most people aren't pushing languages to the maximum, so deciding on whether to use PHP or Python really comes down to which one you prefer.
The only caveat I would point out is that if you choose Python, it is much less broadly adopted by web hosting providers, so your choices are more limited in where you can host your site or move your site to down the road...
|
Add to Favourites Print this Article
Also Read