Live data from Hacker News

PHP: A fractal of bad design

me.veekun.com

461–470 of 514 posts

Re: PHP: A fractal of bad design

#461
post #74

Earlier quoted context omitted.

Ha, I actually avoided doing this so as to not sound like a shill for better-thing-X :) I namedropped Python a couple times, and I do enjoy it for webdev. I've been considering writing something about getting into Python webdev from a purely PHP background; might do that sooner rather than later.

As someone who goes to PHP when he needs to program for the web, and has been doing so for some 13 years now, seeing the horse beaten again didn't move me. I can't say I spent much time on your article, mostly because at this stage of my life, focusing on the negative doesn't earn you anything. I say that because, while it's clear you spent a lot of time on this, it's not really useful precisely because you don't pro…

PHP doesn't really have any strengths any more. The last one was ease of use and setup, but nginx and FastCGI seem to have beaten that too. The only things keeping it around as far as I can see are:

* the huge lock-in with existing code + knowledge

* network effects (aka. "Facebook and my mate Ken use PHP, therefore it must be good")

* Most PHP devs don't know/want to know anything else.

Like the post above says, learn anything other than PHP. Python or Ruby are both solid choices - you can go with something wacky, like Lua, Scheme or Erlang, but if you only really know PHP, that might be too much.

It really doesn't matter - just pick a language and (small-ish) project, google for a framework that looks good (Django, Bottle, Flask, Rails, Sinatra, ...) and go! By the time you get that done you'll be better placed to pick something new that works...

Re: PHP: A fractal of bad design

#462
post #293

Earlier quoted context omitted.

> So your complaint is that when you use @ to suppress an error it... suppresses the error? From your edit, you've only been working with PHP for about 6 months, so you may not have seen some of the code most others have. Can you imagine, then, diving into a website's back-end to see @ all over? It turns out, the previous developer realized all those nasty notices and errors stopped happening if he slapped a @ on eve…

> Can you imagine, then, diving into a website's back-end to see @ all over? It turns out, the previous developer realized all those nasty notices and errors stopped happening if he slapped a @ on everything. You've turned something that's a person's fault into something that's the language's fault. Other languages have some sort of warning suppression as well, like Java's @SuppressWarnings or C#'s #pragma warning di…

> I've written PHP for about 3 years and I've never once used the @ to suppress errors.

Is it so wrong to use @? I've always used (@$_REQUEST['foo'] === 'bar') as a shorter way of writing (isset($_REQUEST['foo']) && $_REQUEST['foo'] === 'bar') - I'm curious if there's a problem with that approach.

Re: PHP: A fractal of bad design

#463
post #362

Earlier quoted context omitted.

> You've turned something that's a person's fault into something that's the language's fault. > You're taking a look at other people's code, and judging the language from it. At some point, you have to start blaming the language for fostering an environment where that code is acceptable.

You can write bad code in any language. It's the programmers responsibility to make sure the stuff they are writing is good and that only comes from experience with the language.

It's easier to write bad code in certain languages, as well as vice versa.

Re: PHP: A fractal of bad design

#464
post #453

Earlier quoted context omitted.

> Want to write an ORM that uses classes or objects as column declaration in PHP? What prevents you from doing that in PHP?

PHP doesn't allow you to pass functions and classes as arguments.

You can. Here's my code as an example:

https://github.com/gigablah/fsphinxphp/blob/master/src/FSphi...

Note the $getter parameter.

Re: PHP: A fractal of bad design

#465
post #136

Earlier quoted context omitted.

Having used php and run across many if not all of the issues the article lists personally I can pretty confidently say it's as close 1o 100% correct as anything I've read on the subject.

The article lists "E_ACTUALLY_ALL" as if it's really a PHP constant. I'm not sure the author has even used PHP -- this is just a bunch of information culled together from different blog posts with very different levels of understanding. There are many things that are just factually wrong with it. I could complain about PHP all day but at least I know what I'm talking about!

really? that's your example? I read that constant name very clearly as "snark". If that's the best you can come up with then I think you just made my point for me.

Re: PHP: A fractal of bad design

#466

Earlier quoted context omitted.

>> Here where I live, about 80% of webdev jobs are PHP. I'm getting the impression that this is why a lot of people hate PHP - Money. People don't like that the market is full of money wasted on an inferior language. Perhaps there's a bit of envy in that, perhaps not. The winners in the marketplace aren't always the best, and it's not easy to change minds. People get religious about the things that make their living,…

People hate PHP because it's an incredibly stupid and frustrating language to use, and most of the people who use it don't know anything else. The money comes from them fucking things up, and their boss having to call in people who know what they're doing to fix it (aka. hack it back into some semblance of "working"). The amount of waste that goes on in most PHP shops is what irks me - use the right tool, spend at le…

>>The amount of waste that goes on in most PHP shops is what irks me - use the right tool, spend at least 50% less time working around stupid quirks.

Yeah, but why would you care unless you're begrudgingly participating in the PHP industry? It's not your problem unless you make it your problem - i.e., if you're so against it, don't work in a PHP shop, don't take PHP contracts. Problem solved - if other people want to use lame/bad languages, who cares?

The impression I'm getting is that a segment people who hate on PHP are participating in the PHP economy because there aren't as many local opportunities in {insert language here}. To me, that's not much different from the guy who's stuck working in a "lowly" coffee shop because he can't find a job in his field of study, which of course, makes him entitled to be rude to customers and his fellow employees.

Re: PHP: A fractal of bad design

#467
post #42

I'm going to be unfair and quote just two words from the article: > empowered amateur PHP is a gateway drug to web development. And that's awesome. With almost every other popular web development language I've heard of[1], there's this grey area between "my app works on my local machine" and "my app works on the server" that is really hard to grok as a beginner. There's a reason entire businesses are built on the ide…

I agree with you and I'm really surprised in 15 years, or how over old PHP is, THERE IS NOT ONE SINGLE ALTERNATIVE!! Why? For PHP I sign up for one of the million LAMP ISPs, I upload a .php file with .php embedded in HTML and I'm done. Where's the Ruby version of this? The Python version? The JavaScript version? The Perl version? THEY DON'T EXIST. You wanna use Perl or Python. You either have to use slow slow cgi or…

The Perl equivalent to the PHP model (request handler entry point is already your template) is called Mason. It's had a pretty huge customer for about a decade now.

http://www.masonhq.com/?AmazonDotCom

Re: PHP: A fractal of bad design

#468
post #462

Earlier quoted context omitted.

> Can you imagine, then, diving into a website's back-end to see @ all over? It turns out, the previous developer realized all those nasty notices and errors stopped happening if he slapped a @ on everything. You've turned something that's a person's fault into something that's the language's fault. Other languages have some sort of warning suppression as well, like Java's @SuppressWarnings or C#'s #pragma warning di…

> I've written PHP for about 3 years and I've never once used the @ to suppress errors. Is it so wrong to use @? I've always used (@$_REQUEST['foo'] === 'bar') as a shorter way of writing (isset($_REQUEST['foo']) && $_REQUEST['foo'] === 'bar') - I'm curious if there's a problem with that approach.

Actually yes because the error gets generated anyway (and that is slow) and then it's just suppressed at the last moment.

You'd probably be better off creating a function to do what you want succinctly rather than using the suppression operator.

Re: PHP: A fractal of bad design

#469
post #432
post #365

Earlier quoted context omitted.

And again you make the same mistake. You take one solution, you say it doesn't work like your favorite solution (while obviously all proper solutions should be done exactly like the one you prefer, since there's only one right way to do anything and it's, not surprisingly, exactly the way you prefer) and you make it the fault of the language used for it's implementation. How that even makes sense? I write code in a n…

> How that even makes sense? Maybe my point wasn't clear. It's not a difference in how those two ORMs accomplish their goal; it's that PHP doesn't let you do what SQLAlchemy does, even if you wanted to . Want to write an ORM that uses YAML, XML, or comment annotation in Python? Great! Want to write an ORM that uses classes or objects as column declaration in PHP? Too bad. > Rehashing old tired "strpos doesn't have un…

> Want to write an ORM that uses classes or objects as column declaration in PHP? Too bad.

I'm actually doing just that; it's not as clean as you can do in Python but it's not outrageously verbose either. Trying to map one languages features onto another is not a valid critique.

Re: PHP: A fractal of bad design

#470
post #88

Meh, I've written a lot of PHP code. I also work in Ruby and Python. All three have problems, but I like all three. With PHP, you have to develop a coding style that naturally avoids PHP's weird areas. It's not really that hard to avoid the mines, but you do have to be aware of them. In exchange, you get a scalable web server and a language that requires minimal babysitting. Instead of automatically throwing a 500 on…

Lets say for someone who is new to PHP, how long does it normally takes to learn where the minefields are? Is there anyway to start on this? I know in JS there is Javascript The Good Part. Is there anything equivalent in PHP?

Probably using a mature PHP framework and following it's style would avoid almost everything.
Post reply on HN