Live data from Hacker News

Ask HN: PHP for Python programmers

news.ycombinator.com

71–77 of 77 posts

Re: Ask HN: PHP for Python programmers

#71
post #6

You'll be be fine. I've found it very easy to switch from/between C/C++/PHP/Python. Perl on the other hand...

It's easy to write code that works if you're switching between C, C++, PHP, and Python. However, being able to write idiomatic code is a different matter entirely.

Re: Ask HN: PHP for Python programmers

#72
post #14

Earlier quoted context omitted.

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 PH…

Fundamentally, PHP has an entirely separate address space for each web request... This is a much more "robust" (reliable as opposed to "featureful") approach to web development because there are no data structures in RAM that are shared concurrently between requests.

For example, in ASP.NET, I've had a whole team of developers swear up and down that there are no static variables in a particular segment of code that could be the subject of a race condition. Sure enough, I go in there and find one that's hidden away in a very obscure location.

Java has the same problem, as does any environment that exposes threads to the language. Sure, in theory you could do some very nice things by sharing data structures between requests, but practically the whole programming style of PHP encourages people to avoid horrible horrible problems with concurrency, and there are no language features, even in the laboratory that practically make those problems go away.

To take another example, the urldecode function in CPAN has been wrong for 15 years. If you want to write a urldecode that works right, you've got to write your own (possibly using the built-in for a base). Similarly, the URI object in .NET sometimes does incorrect transformations on URIs, and you need to use string URIs if you want to make interoperable semweb systems... PHP has the lowest fraction of 'things that say they work but really don't work' of any web programming languages, and that's the reason why it is so successful. Other languages are "blub" because they don't recognize that it's even possible for things to be this easy.

Re: Ask HN: PHP for Python programmers

#73
Bookmark http://www.php.net/manual/en/.

I suspect that the quality of the code base will affect your happiness much more than the language itself will. I doubt that BigNameCorp belongs to the world where all database fields are VARCHAR(255) and elaborate code is required to ensure that '99' < '100', or where globals float about mysteriously. If so, heaven help you--but they'd probably write Python in the same fashion.

Re: Ask HN: PHP for Python programmers

#74
post #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…

Perhaps I'm irrational, but early in my Python career I got back a source file from a friend that had invisible changes in the spacing (tabs and spaces got confused) and spent entirely too much time fixing the resulting bugs.

I figured whatever benefit I got from Python's other 'good' features, I'd lose back with that kind of BS, so I quit programming Python.

Re: Ask HN: PHP for Python programmers

#75
post #74
post #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…

Perhaps I'm irrational, but early in my Python career I got back a source file from a friend that had invisible changes in the spacing (tabs and spaces got confused) and spent entirely too much time fixing the resulting bugs. I figured whatever benefit I got from Python's other 'good' features, I'd lose back with that kind of BS, so I quit programming Python.

Is it really that hard to search and replace a tab with four spaces?

    %s/\t/    /g
should do it in Vim. Make it /gc if you have tabs in your code for some reason.

If it's really hacked up, then a source code beautifier might be a better bet:

http://www.google.com.au/search?q=python+source+code+beautif...

The alternative is to have wild, all over the place indenting in languages like PHP. Except that the code will still run, so nobody will fix it.

Re: Ask HN: PHP for Python programmers

#76
post #59

PHP is an okay language. I'd never choose it by myself, but most of the time it is bearable. The language is not the problem though - it's the people. PHP breeds mediocrity in such a superb way, it's rivaled only by Visual Basic. It attracts many dumb people and, chances are, you will meet many of them on your new job.I won't go as far as telling you to stay clear of the job - just have that in mind when deciding.

Completely agree!

Both PHP and VB share low barriers of entry. That make them novice friendly, but in the end it encourages practices that everybody else have agreed to call bad habits.

By example, copy & paste. In most languages if you pick a random forum and ask "how do I do X?", you will receive answers that range from "RTFM" to some cryptic link to a Fine Manual to Read. You will be forced by the elders to conceptualize what you want to do, and then learn how does it work. On the other hand, that same request in the PHP and VB forums will get half a dozen of "here is it, dude" responses... including the one form the reading challenged idiot who answered how to do Y instead.

In the mind of the newbie, then, it becomes perfectly acceptable to equate programming to a look up table where there is some arcane incantation that corresponds to every problem.

Not to say that there is no professional people doing quality work in either language. But dealing with the noise in the community is the price you have to pay.

Re: Ask HN: PHP for Python programmers

#77
I started as a PHP programmer and transitioned to Python. I'm currently doing PHP at work, and it's not too bad, despite some of the warts that come with an application designed over 5 years by a single person.

Sure, I'd rather be hacking Python, but I'm not going to go kill myself or anything.

Post reply on HN