Live data from Hacker News

PHP: A fractal of bad design

me.veekun.com

451–460 of 514 posts

Re: PHP: A fractal of bad design

#451
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.

Meanwhile, people still manage to write memory leaks in garbage collected languages specifically designed to not leak memory.

GC is not about preventing memory leaks, it's there to make managing memory easier not automatic. One of it's biggest advantages is the ability to deal with memory fragmentation which is ridiculously hard to do well in C++ style languages.

Re: PHP: A fractal of bad design

#452
post #425
post #298

Earlier quoted context omitted.

I agree with the general point but this seems more of an indictment of other languages than a plus for PHP: with PHP, it's easy to get started with the most simple features - and then it takes years to learn how to cope with the language quirks and inconsistencies, deal with outright bugs, and learn a number of non-obvious ways in which your “working” site might be hacked due to a hidden language feature. There are t…

Maybe I'm missing something in your comment here, but - Python and Ruby already have smooth dev server installs. In fact, much smoother than PHP, as you don't need apache or fancy permissions to just run something local. Ruby, rails: "rails server" Ruby, sinatra: "ruby " Python, django: "python manage.py runserver" All of these spin up an app server on some port > 1024. I'm honestly not sure how it can get much easie…

Start as J. Random Noob: they need to install python, virtualenv, etc. before learning how to create a module, create multiple config files and so forth.

Technically PHP isn't much easier if you need to compile it, configure Apache, etc. but in practice they just pay $1/mo for a crappy hosted account where they simply upload a file and start fiddling.

This is a trivial distinction for a professional developer but there are quite a few PHP users who started with a personal homepage and grew from there – and despite the stereotype, they're not all designers, either. That's why I like the Rails.app idea: give today's bright 13-year-old a nice, easy path to getting something visible and let them get hooked before they need to learn all of this other stuff.

Re: PHP: A fractal of bad design

#453
post #432

Earlier quoted context omitted.

> 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? What prevents you from doing that in PHP?

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

Re: PHP: A fractal of bad design

#454
post #442
post #432

Earlier quoted context omitted.

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

I have no idea what you mean by "what SQLAlchemy does" - I'm sure it does lots of things and most of these are perfectly doable in any language out there. You must be meaning some specific thing that is a favorite of yours - and indeed maybe it is hard to do it in PHP (or maybe not - since you didn't tell what this thing is nobody can have any idea). Who cares? I can name a bunch of things that is harder to do in Pyt…

> I have no idea what you mean by "what SQLAlchemy does"

You must have missed the rest of that paragraph. I specified what it does.

> What he's talking about here is known and talked about for 10 years. It's just function names, it's not that big a problem.

Again, missing the point. Python has these same minor inconsistencies in its stdlib. It's the combination of all these minor inconsistencies with a language that gives you more tools to write bad code than good that makes PHP torturous. It's everything that the author wrote about in one neat little package.

Re: PHP: A fractal of bad design

#455
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.

Unless I'm misunderstanding you, passing functions as arguments is definitely possible with anonymous functions/closures.

Re: PHP: A fractal of bad design

#456
post #386

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…

> Other languages have some sort of warning suppression as well But there is a huge difference here. PHP directly encourages it, making it so easy to do "just prefix it with @" and dedicating a part of the core language syntax to it (thus spending such a nice character for such a triviality). I believe (correct me if I'm wrong) that in Java, it is just another annotation, and in C# just another preprocessor directive…

In Java annotations can be used to ignore compiler warnings, not runtime errors.

To get the same effect as @ you'd have to use try {} catch {} blocks all over the place and leave the catch blocks empty, as with any other language with runtime exceptions. Sadly this is done more that one would think...

Re: PHP: A fractal of bad design

#457
post #327

Earlier quoted context omitted.

Don't start with rails, start with ruby. Doing otherwise is like trying to learn PHP by looking at the Drupal codebase.

I did, and Ruby was quick and easy. I wrote a bunch of programs and felt comfortable enough that I could understand stuff if I looked at it. But Rails seems like a whole other animal. And your right, this is the difference between languages and frameworks. But, without Rails I'm not sure how to get to a web app with Ruby. With PHP I was writing web apps before I really understood the language. I don't mean to be sayi…

Start with Sinatra (http://www.sinatrarb.com/) instead. I had worked with PHP for a little while, and I decided to try out ROR. I could not understand it at all. I did some plain ruby for a while.

Eventually, I heard about Sinatra, and decided to try it out. It's a great way to learn about web apps. You'll learn the HTTP verbs if you haven't already, and you'll understand the routing process.

When you jump into Rails, you'll already understand Controllers and Routers, since Sinatra is basically the router and controller of Rails combined. You'll probably learn about views too.

Basically, learn sinatra, then go to Rails.

Re: PHP: A fractal of bad design

#458
post #358

Earlier quoted context omitted.

Oh, you mean as opposed to the usefulness of calling people snobs because they understand that PHP is terribly designed? Fuck outta here.

There are a lot of snobs out there. It is a sad fact, regardless of that article. PHP snobbery is hugely widespread and 99.9% of people disparaging PHP are completely ignorant in PHP and don't bother to spend a minute even on reading the PHP manual - which answers 99% of things they complain about as being hard to understand (and try using Python without reading any manuals at all - see how far you go). I'm not sayin…

> if you take time to write a long article about PHP deficiencies while refusing to take 10 seconds to look up a thing in the docs - it doesn't look good.

When did the original article ever suggest that? I got the impression that he had looked it up in the docs, and found the docs seriously broken. That fits my recollection of PHP's docs - there are a lot of them, but they often don't tell you what you need to know, so you have to go trawl through the comments. Of course, most of the code in the comments is crap, full of errors, has security holes or all three.

> function called strpos instead of str_pos - really, that's your problem?

Yes, that's a problem. Ditto for arguments in random order. It means that it's much harder to remember the function without having the docs open in another window.

"PHP sucks, nobody should use it, anybody who uses it is an idiot"? Sounds about right. I know people who are security consultants, who've worked with PHP for years and years - I even know a guy who works at Wordpress. None of them think that you should be using PHP...

Re: PHP: A fractal of bad design

#459
post #264

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

> I, for one, hate throwing an exception when an item isn't found. This sucks: You can always do: index = a_list.index(a_value) if a_value in a_list else -1

Why would you do that? You're going to have to have a branch to deal with the -1 further down in your code anyway. Why not just deal with it when it happens:

  if value not in list:
      # value not found
      return
  index = list.index(value)
  # Code to deal with the thing

Re: PHP: A fractal of bad design

#460
post #394

Earlier quoted context omitted.

> If you're not going to use it, why complain about it? I can tell you my reasons: the market. Not all of us can roll a globe, close our eyes, pinpoint a place and tomorrow have a job there. Here where I live, about 80% of webdev jobs are PHP. Even when I do manage to get a Ruby or a Python job, chances are that I will be doing lots of PHP code maintenance and migration anyway. I would like to change it, and I don't…

>> 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 least 50% less time working around stupid quirks.

> the OP's either preaching to the choir, or his message is falling on deaf ears.

That was the point of the post. If he points people to it, and they read it but still disagree that PHP is crap, then there's obviously no hope for them.

Post reply on HN