6 ms·
cool job right there, but just curious, why this is php >> python and not php << >> phython ? does that need a lot more work?
by jeffisabelle 14y ago
cool job right there, but just curious, why this is php >> python and not php << >> phython ? does that need a lot more work?
- redegg 14y agoBecause mostly everyone hates PHP. This site serves to show the Python way of doing things if anyone's interested, or is moving away from PHP. Edit: I am wrong, not everyone hates PHP.
- azio 14y agoI am using Python since 6 months after working with PHP for many years. Guess what? I don't hate PHP.
- dsl 14y agoAs someone who doesn't know much in the way of Python, it seems odd to me that many of the examples are blocks of code vs one line replacements for PHP functions. Is Python just more verbose?
- paranoiacblack 14y agoNo, there are a lot of shortcuts and beautiful one-liners in Python. However, Pythonic code always focuses on being the simplest and cleanest as opposed to being the shortest. I suspect it's the author's way of imposing some good python coding standards at the same time.
- buster 14y agoThere is xmlrpclib inlcuded per default and it does all the XML stuff, so i think you can easily get away far more readable then what is shown in the python reimplementation of the PHP function. http://docs.python.org/2/library/xmlrpclib.html#example-of-client-usage http://docs.python.org/2/library/xmlrpclib.html#example-of-c... It just doesn't have xmlrpc_encode_request() with the exact method signature. P.S.: I am wondering if it is normal to have functions marked as EXPERIMENTAL with a biiiig warning sign for 11 years in the language? That really scares me. This function has been introduced in PHP 4.1.0 which was releases in 10-Dec-2001... That's just... edit: removed rant about xmlrpc_encode_request being built-in. It's a non-default extension, apparently..
- aptwebapps 14y agoI don't think it's complete. For example this: http://www.php2python.com/wiki/function.array-walk/ http://www.php2python.com/wiki/function.array-walk/ could be replaced with map() in Python.
- nikcub 14y agoI know both languages well. Python is much more succinct than PHP because of array literals, list comprehensions, lambda's and better native data types with ways to navigate them (all the functional methods are there). Only PHP 5.4 with a literal array syntax is beginning to approach some of the things you can do in Python. You think PHP is short because you have functions like xmlrpc_encode_request and the equivalent in Python is 20 lines. What you don't see if that xmlrpc_encode_request is pages and pages of C code and PHP macro's behind the scenes. That function should be in a library, not in a programming language, which is why PHP is more comparable to other web frameworks, not to other programming languages.
- emidln 14y agoxmlrpc_encode_request on this site should probably be fixed to use xmlrpclib.dumps (or loads if you need the other direction). This has existed in Python since version 2.2. I realize this is beside the point, but I'm willing to fix it myself.
- Firehed 14y agoIt IS a PHP library - just one written in C rather than in user-land PHP code. Why is this a problem? The XML-RPC extension isn't even enabled by default.
- scott_w 14y agoNo it's not. The reason the examples appear longer is because the website is documenting how to implement PHP functions in Python. Since Python is not PHP, it won't implement line-for-line replacement functions.
- yareally 14y agoUsing both PHP5 in the past and Python more recently, I find that most things in Python need far less code to write than PHP. The examples here are kind of disingenuous to that, but if you start writing code that takes advantage of the features of Python, your lines of code should be less than PHP or equal.
- smsm42 14y agoNo, just PHP has a tradition of implementing frequently used code in C. This means PHP has tons of functions that serve specific use case, while Python has less of them, at least in standard package (of course you can have a module that does the same and then you'd have one-liners too). So you're not comparing the same thing here.
- shanelja 14y ago"Everyone hates PHP"? Really? It might not be the most popular language around the HN crowd, but this forum is subject to trends and "emerging technologies" - not necessarily to say that these technologies are better or worse, just that they are the flavor of the month. It's hard to argue with the numbers, PHP is still the most popularly used language [1] and while the gap is being bridged, it is really minuscule in comparison. I'm sure that while you may hate PHP, not every single developer does. Yes, yes, down vote me, I'm a proud PHP developer and to even utter such words on this site seems to result in the most powerful of criticisms, but subjective to this entire argument is that behind every person who writes PHP is a ruby coder, tutting and shaking his head, stood behind him is a Node.js developer, laughing at him, behind him is somebody writing Assembly, scowling in to the distance in disgust, behind him is a C coder, eyes wide with surprise that someone is working in Assembly, etc. I give it a few years until people are crying out loud on here that Node.js is dead and superlanguageemulator.pm or whatever comes next is the only way to code, at least, for people wise and intelligent enough to embrace this new technology. [1] http://w3techs.com/technologies/overview/programming_language/all http://w3techs.com/technologies/overview/programming_languag...
- 10098 14y agoDid you just compare node.js to assembly? :)
- shanelja 14y agoClearly not, it was a satire of our industry. I was comparing the attitudes of people, the languages they use were merely for the purpose of the narrative, it could quite easily have been Node.js and Perl or Python and Haskell
- agf 14y agoThat link isn't really credible at all. There are two obvious and major omissions that render their chart meaningless. They don't say how they determine whether a technology is being used server side -- it could be only if they see ".php" URLs on the site, for example, which would mean there would be a strong bias against languages that make it easy to write sane URLs. They also don't share what % of sites they're able to make a determination for at all, so these numbers could be based on a statistically insignificant sample.
- jeffisabelle 14y agoI agree that "hate php and love python" part, however, we may still need to use php or at least read php code at work/school. and this app could be useful for that purpose if it had python to php conversion too.
- 10098 14y agoI wish everyone hated PHP. Then one one would write it.
- mylittlepony 14y agoI don't hate PHP, so you are wrong.