Live data from Hacker News

Ask HN: PHP for Python programmers

news.ycombinator.com

11–20 of 77 posts

Re: Ask HN: PHP for Python programmers

#11
post #9

Don't worry about it. I was in a similar position a few months ago when I, a python programmer, was offered a perl position. Eventually you just get used to it, and you might even find things you like. I've stopped being as much of a language snob. Some features and most syntax are just decorative, and you'll adjust. The whole giant namespace thing would bother me a lot, but hey its worked for other people before.

Amen.... I've started to use more than one language, and it's made me a better programmer and far more understanding of how different languages approach problems. PHP does have problems, but it's easy to pick up. I don't know that learning it will make you a better programmer, but a good programmer can definitely make it solve problems efficiently enough.

Any new language you learn will make you a better programmer.

Try picking one that is as far as possible from the ones you know and then try building something useful in it. That's the fastest way to broaden your horizons.

Re: Ask HN: PHP for Python programmers

#12
post #8

Don't worry about it. I was in a similar position a few months ago when I, a python programmer, was offered a perl position. Eventually you just get used to it, and you might even find things you like. I've stopped being as much of a language snob. Some features and most syntax are just decorative, and you'll adjust. The whole giant namespace thing would bother me a lot, but hey its worked for other people before.

Language snobs, as a rule, are people that have not programmed in more than one language, or that somehow think that their chosen superior tool makes them superior as well. Nice to see that learning a 'crappy' language like PHP got you on to a more even keel in that respect.

Technically perl, not PHP, but now all I see is arbitary syntax. It's nice.

Re: Ask HN: PHP for Python programmers

#13
Can you learn PHP and be successful with it? Absolutely. Do you want to? As a Python programmer who's had to do PHP from time to time, I can say it isn't terribly fun. If I were to make a decision based solely on the programming language though, I wouldn't choose a shop whose main language was PHP. Again though, that's assuming that I was just basing it on language. I've found choice of programming language to be one of the less reliable indicators of how good a company would be to work for.

Re: Ask HN: PHP for Python programmers

#14
post #7

Earlier quoted context omitted.

Seriously? Don't get me wrong, I could imagine valid reasons to use PHP. But the quality of the language itself is at the very bottom of that list. I don't usually hear PHP advocates making that case. Usually it's a combination of "the language isn't that bad" and "there are a lot of libraries for PHP".

If you define quality as 'orthogonal naming of functions' and 'elegant constructs' then yes, PHP has its flaws. But it's been absolutely bullet proof in production for me and when I did find a bug I've had a patch within 24 hours straight from the core devs. They do take quality serious there, they just don't define it as language elegance.

I'm not sure I understand what your argument is. That there aren't major showstopper bugs that make PHP unusable due to various segfaults? Sure, that's true. But do you mean to suggest that such things exist in greater quantity in other such languages? You say the PHP devs have a sharper focus on quality than other languages; can you provide and kind of evidence for those claims? Not just good response time by the PHP devs, but systemic failures in other languages that go unaddressed, as well?

PHP tends to be at the bottom of the "language quality totem pole" because as a language it's pretty low quality. The PHP interpreter may be fine as a piece of software, but that's a completely separate matter from being a quality language.

Re: Ask HN: PHP for Python programmers

#15
Switching languages, for me, has usually been a matter of remembering syntax, some minor differences (such as how arrays work, what things are built-in, etc), and the patterns in each language that naturally arise from those two. Of course, things get more complicated if the language itself is structured differently (eg: Javascript), but there are a lot of underlying concepts that carry over (scope, stack, OOP, etc). In short, it just takes practice. If you're "advanced", you should be able to pick up on it pretty quickly.

To get a feel for syntax and how PHP works (especially == and reference/value), you should read the docs. They're a breeze and provide lots and lots of examples. The user comments are generally incredibly helpful and will notify you of caveats that you might need to be aware of.

You'll also want to start off by learning how to build objects in PHP, how associative arrays work (they are great), and how to use __autoload() to include classes on the fly.

Re: Ask HN: PHP for Python programmers

#16

Switching languages, for me, has usually been a matter of remembering syntax, some minor differences (such as how arrays work, what things are built-in, etc), and the patterns in each language that naturally arise from those two. Of course, things get more complicated if the language itself is structured differently (eg: Javascript), but there are a lot of underlying concepts that carry over (scope, stack, OOP, etc).…

Magic quotes is also worth a mention. It's bound to throw anyone coming from another language for a loop.

Re: Ask HN: PHP for Python programmers

#17
post #16

Switching languages, for me, has usually been a matter of remembering syntax, some minor differences (such as how arrays work, what things are built-in, etc), and the patterns in each language that naturally arise from those two. Of course, things get more complicated if the language itself is structured differently (eg: Javascript), but there are a lot of underlying concepts that carry over (scope, stack, OOP, etc).…

Magic quotes is also worth a mention. It's bound to throw anyone coming from another language for a loop.

Magic quotes has been disabled by default for several years. All you need to know about them are: disable them if enabled.

Re: Ask HN: PHP for Python programmers

#19
I think one of the main things is to go into it with a more positive attitude, i'm not criticising you or anything, but you seem to already view PHP with disdain.

Personally i'm a PHP dev and love it, sure its got its ugly parts, but what language doesnt. Its a very easy language to learn especially if you have prior coding knowledge, pretty much every single host out there supports it by default, and there is an excellent manual as well as a ridiculous amount of resources for learning it.

Personally i'd view learning any new language as a good thing, as at the very least it makes you a better coder in your own "native" coding language.

Re: Ask HN: PHP for Python programmers

#20
If `BigNameCorp` writes a lot of PHP seriously, you won't notice that many problems. It's not going to be PHP anymore. It's going to be Symfony, Zend, Cake, or something else (maybe even some proprietary, internally used framework). It isn't that easy to find pure-PHP code these days - it just takes too much time to write.

If you do however see an old-style "let's just include everything", "global variables are cool", "just shove it into $_SESSION" kind of code... well - good luck, you'll need it ;)

There's also going to be some forehead slapping as you discover what is not possible (like `function_returning_array()[0]` => syntax error)

I get to write PHP once in a while but normally prefer Python. It's easy to spot in the style of the code written... but otherwise, no problems. I'd just suggest changing the error reporting level to maximum - it's not hard to write a lot of PHP code that will both work correctly and report tens of warnings per line.

Post reply on HN