Earlier quoted context omitted.
This is why: http://www.google.com/search?q=php+mysql Searching for PHP and MySQL yields tons of tutorials, code examples, and documentation related to the now-deprecated mysql interface. When I wrote my first comprehensive PHP application last year I spent half a day trying to determine best practices before finally settling on PDO. Newbies won't go through that effort, and will naively land on mysql rather than PDO…
There's a lot of tutorials, and that makes PHP bad? Sure the tutorials don't teach what you prefer. This just seems like a silly argument.
PHP: A fractal of bad design
301–310 of 514 posts
Re: PHP: A fractal of bad design
#302Earlier quoted context omitted.
What is the problem with eval? Even Python lets you do that. There are legitimate uses for it.
Name one. I can't think of any that aren't better served by other constructs. eval does have one huge, honking problem though: it permits text to be interpreted as code. This is just asking for code injection attacks. If you really need incremental/multi-stage evaluation, see MetaOCaml ( http://www.metaocaml.org/ ) for the proper way to do it (without exposing yourself to injection vulnerabilities). It's a consequenc…
User input of code. It's hard to implement a REPL without it. Even if you do implement without it there's still an "exec" implementation hiding in there somewhere.
Also, on rare occasions, it is actually an optimization when used carefully, like the Python nametuple example mentioned nearby.
I'm just answering your challenge. I totally agree that in general it's a bad idea and that's an unusual case. While for it to work properly it has to ship with the interpreter, if I were designing a language I would move it out of the global namespace at least, and require some sort of explicit module import with lots of dire warnings in the documentation.
Re: PHP: A fractal of bad design
#303What really can be done? Should they make a new version that provides more consistant function names and break backwards incompatibility? I've yet to hear what people think should be done with PHP besides abandoning it.
That being said I don't think it should die, I think it has it's place. I'm not as smart as the rest of the folks on here, but for doing client sites, PHP gets the job done very fast.
Re: PHP: A fractal of bad design
#304If this one thing that annoys me on HN it's the pervasive anti-PHP snobbery. A selection from the OP: > Because of the @, the warning about the non-existent file won’t be printed. So your complaint is that when you use @ to suppress an error it... suppresses the error? > The language is full of global and implicit state. "Global" is one of those dogmatic points. Nothing is truly "global" in PHP. The "global" in PHP j…
> 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…
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 disable. Although they won't suppress all errors like PHP does, it can still bite you if you don't fix them.
It IS snobbery. You're taking a look at other people's code, and judging the language from it. I've written PHP for about 3 years and I've never once used the @ to suppress errors.
Re: PHP: A fractal of bad design
#305Re: PHP: A fractal of bad design
#306Re: PHP: A fractal of bad design
#307Re: PHP: A fractal of bad design
#308Re: PHP: A fractal of bad design
#309If this one thing that annoys me on HN it's the pervasive anti-PHP snobbery. A selection from the OP: > Because of the @, the warning about the non-existent file won’t be printed. So your complaint is that when you use @ to suppress an error it... suppresses the error? > The language is full of global and implicit state. "Global" is one of those dogmatic points. Nothing is truly "global" in PHP. The "global" in PHP j…
> 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…
I do maintenance for a lot of PHP sites at my job, and the code is staggeringly difficult to debug or modify. It's punishment for my sins.
PHP was a tool for generating textual data structures (HTML) and it should've been leveraged by another tool for control flow and business logic, but it wasn't. The code I maintain is pre-frameworks; it's got no DRY, no separation of concerns, no design forethought at all. It's just HTML generation that satisfies its needs as they arise.
Now PHP is a quirky, mediocre, and capable language that's still really good at generating HTML.
Re: PHP: A fractal of bad design
#310Earlier quoted context omitted.
What English is good at is expressing a huge variety of ideas. I once heard someone argue on NPR (sorry, no citation) that English is perhaps the /best/ language at expressing absolutely any idea to another person precisely because it has such a huge vocabulary and so many idiomatic phrases. I've sometimes heard of programming as an art, like poetry, but if so I'd prefer to maintain that it is a minimalist art that e…
> I once heard someone argue on NPR (sorry, no citation) that English is perhaps the /best/ language at expressing absolutely any idea to another person precisely because it has such a huge vocabulary and so many idiomatic phrases. I heard that on the radio, and I've been looking for it for years! If anyone knows the show, ideally the specific show or interviewee, I'd be supremely grateful!