Live data from Hacker News

PHP: the quiet powerhouse

blog.appfog.com

121–130 of 140 posts

Re: PHP: the quiet powerhouse

#121
post #68
post #58

Earlier quoted context omitted.

Have you used PHP? Spend 5 minutes with it and you'll understand; a very expressive language, simple to learn, massive library of functions, massive number of examples to copy, no framework to learn, no syntactical overhead like in Java, practically everything works with, or has bindings for PHP. I prefer to work in python, but I don't much care anymore, each language has it's strengths and weakness' but PHP most def…

Yes you can get up and running quickly with php, but my comment was mostly about the fact that it is not much slower in other languages (most of the time not slower at all). And yes I did a lot of PHP but that was 5-6 years ago. I know things have changed a lot since then but the language still has a lot of the same flaws.

It is when you consider the deployment models, the development server setup etc.

The language has as many flaws as it's always had but it still works.

Re: PHP: the quiet powerhouse

#122

Earlier quoted context omitted.

I don't understand this argument. The way I use server side templates is much simpler and more powerful than any demo of client side templating I've seen. I think you're reading a little too much into the hype, otherwise maybe you can share an example of superior Javascript templating patterns because I can't find them.

It depends what you are trying to do. If you are only targeting browsers, and especially if you don't need a lot of responsiveness, it's much simpler to just render views on the server side and optimize your server for speed. It takes a lot of effort to write a thick client. But if you are targeting a browser and a native iPhone app, the view logic lives on the iPhone app. It used to be that you could just serve up a…

I think I see what you're talking about: more non-browser clients exist so the web servers need to be able to expose an API. I agree with that.

Besides that, the ability to "template" output on the server is still my ideal way to transform the business API to something the client can read. In the case of a browser, I'm templating for HTML. For a mobile app, we may just pass through in JSON and let the native mobile app handle the views, even output HTML5 for mobile in addition.

In all of these cases, server side templating of output plays a role I think. For browser targeted output, server side templates are still simpler in the implementations I've seen.

Re: PHP: the quiet powerhouse

#123
post #79

Earlier quoted context omitted.

Agree with all your points except this one. >> Maybe all of this will change once Facebook releases Hiphop VM AND people actually start using it. The argument that PHP doesn't scale is a strawman. To scale anything to the likes of Facebook or Google you have to have serious architecture in place regardless of the language you choose.

I wasn't thinking of scale. Correct me if I'm wrong, but wouldn't hiphop VM essentially expand PHP from just being a web language into something more?

I stand corrected. I hadn't thought of it really. But the thought of PHP for non-web kind of makes me cringe even if it's translated into another language by an intermediary. For sanity sake I'm going to assume NO :).

Re: PHP: the quiet powerhouse

#124
post #42

"It’s been very interesting beginning my trajectory in web development in 2012... [PHP] might be the best language to use in gaining an understanding of the fundamentals of web development... No web development language outside of PHP grants you the kind of flexibility to both (a) produce genuine functionality from scratch, outside of an MVC framework, and also to (b) work within the bounds of MVC in deeply sophistic…

I certainly didn't mean to say that languages like Python and Ruby are inflexible! What I meant to say is that you can't use either of them in direct conjunction with HTML the way that you can use PHP. This was what I meant when I said "genuine functionality from scratch." Would I prefer Python+Django/Flask for lots of use cases. Absolutely. As for the "useless overhead," there are things like the command line (which…

Look, there are two things you are saying. One is "you can't do this with Ruby/Python" -- which is a superiority-of-PHP argument -- and the other is a plea of "PHP has done a lot, so let's not be too hasty dismissing it." You made both of these arguments. In fact, you made the first one in this very comment where you say you're not arguing for PHP's superiority over other languages.

In some ways this is true but I would be hesitant. What you're really advertising is that PHP has an implicit `echo("` statement which looks like `?>` and also implicitly occurs at the beginning of the file. A lot of new folks write really hard-to-follow code. Here is the seed of badness from which such code eventually germinates and blossoms:

    ' . $user['name']. '';
        ?>';
If you do not see why this is bad, imagine that you have a loop within a loop and they get separated by more than 20-30 lines of PHP. Notice how some of the HTML occurs within the PHP statement but pairs with tags outside of the PHP statement, and imagine functions which are producing such code. Et cetera.

Python+Flask will force you to either do it in a Jinja template, which avoids the problem because you cannot 'return back to Python' midway through:

    {% for user in users %}
        {{ user.name }}
    {% endfor %}
Or else you could define the file within Python using strings, in which case your syntax highlighter will be able to tell you exactly where these strings begin and end:

    output += """
    
        """ + "".join(["""
            %s""" % (u['id'], u['name'])
                for u in users]) + """
        
            '%s % (u['id'], u['name']) 
            for u in users]) + """
Of course, Jinja is more readable in this case, and that's kind of the point. For most web apps, you want a sort of preamble which calculates and formats a bunch of information, selects a template, and renders the template to the user. For PHP, this preamble is Apache, and if you want more, you probably need to generate an include() file to force yourself to stay sane. (PHP doesn't force this however, and many people write bad code which simply does the calculations in the HTML wherever they are needed -- and then you get massive code duplication and the joys of trying to match curly braces through large blocks of HTML.)

Re: PHP: the quiet powerhouse

#125
post #117

Earlier quoted context omitted.

Some of the problems with PHP are things that are problematic or irritating to development (e.g. its inconsistent standard library) but other things are actively dangerous to security and correctness. For example, in PHP, '9223372036854775807' == '9223372036854775808' returns true.[1] Now imagine those two strings are hashed passwords. The overall problem is not with specific flaws of PHP; the problem is that flaws i…

php > var_dump('9223372036854775807' == '9223372036854775808'); bool(true) This made me cry.

Because in a real application people are checking to see if those lazily match every 3 to 4 lines... Half of this stuff that makes the haters "cry" is unrealistically used things.

Re: PHP: the quiet powerhouse

#126
post #95

Earlier quoted context omitted.

Just like Python, Perl, Rails, Node.js, and any other language out there. Why all the hate towards PHP?

"Rails" isn't a language, and PHP has fundamental design flaws that those other languages don't have. It's not that it has flaws, it's that it has unavoidable flaws.

It's something I find interesting. PHP "haters" keep pointing at flaws, yet in almost 10years of doing PHP, the only thing that really ever annoyed me is the string and array parameters order...

And I've done a wide range of thing in PHP, including scaling websites to millions of pageviews per day.

PHP might have design flaw, but in the end, they don't matter because they actually don't affect the day to day developer.

And I've tried my hands at Ruby, Python (still use it but more for scripting than web dev), C# (was actually my first language for webdev), and weirdly enough I find that they get in the way more that PHP does when it comes to building websites.

Re: PHP: the quiet powerhouse

#127
post #95

Earlier quoted context omitted.

"Rails" isn't a language, and PHP has fundamental design flaws that those other languages don't have. It's not that it has flaws, it's that it has unavoidable flaws.

It's something I find interesting. PHP "haters" keep pointing at flaws, yet in almost 10years of doing PHP, the only thing that really ever annoyed me is the string and array parameters order... And I've done a wide range of thing in PHP, including scaling websites to millions of pageviews per day. PHP might have design flaw, but in the end, they don't matter because they actually don't affect the day to day develope…

Exactly, most PHP "haters" are bitching about personal preference and not anything that in the end, makes a difference.

Re: PHP: the quiet powerhouse

#129

You're killing kittens by using PHP. PHP could be a wonderful thing if not for its original sins. It is easy and fast, but it is also bad. It is "good enough", and for many years it prevented just "good" from arising and gaining adoption. I would pick "good" over "good enough" even if it costs me a bit because I think this is fundamentally right.

[deleted]

Re: PHP: the quiet powerhouse

#130

You're killing kittens by using PHP. PHP could be a wonderful thing if not for its original sins. It is easy and fast, but it is also bad. It is "good enough", and for many years it prevented just "good" from arising and gaining adoption. I would pick "good" over "good enough" even if it costs me a bit because I think this is fundamentally right.

But how often does trying-to-be-better-and-failing come along and torpedo good-enough-for-the-job?
Post reply on HN