Live data from Hacker News

The new PHP

programming.oreilly.com

181–190 of 203 posts

Re: The new PHP

#181
post #177

Earlier quoted context omitted.

Literally bought the same book by Larry Ulman.

I bought the same book metaphorically.

Same here. Larry's a great author. I got started with his books years ago. He definitely makes Web dev feel more approachable, which is invaluable to a newbie. I believe Patrick Collison from Stripe also got started on Larry's books (for some reason I recall a conversion on Twitter or the like about this).

Re: The new PHP

#182
post #138

Earlier quoted context omitted.

> PHP's "closures" require you to write down the free variables in an enclosed function and tell PHP that they exist Can you give an example? I googled "closure conversion" but didn't understand.

It is an algorithm used in compiling languages like Scheme where you calculate the set of free variables in a function and then create a closure (a function pointer and an environment, which is basically a way to lookup free variables). PHP requires you to do this by hand with the "use" keyword, e.g. use($a, $b, $c) where $a, $b, and $c are free variables (that is they are not bound in the current scope). I see no re…

AFAIK, `use` were required because PHP has variable-variables:

    
Hopefully, nobody uses variable-variables these days, however this is the reason behind the introduction of `use` for closures.

Re: The new PHP

#183
post #156

It really pains me that there are so many utter misunderstandings about modern PHP from people that used it years ago and have no clue about the current landscape, even in this thread. Yes, the PHP core api is still a bit messy due to backward compatibility, but everything else it pretty awesome really. Please take a closer look if you haven't touched PHP in years, before you talk it down.

Oh, did you mean PHP the language? The webserver? The FastCGI server? The runtime? PHP starts as a fucking mess and gets worse. Maybe once the developers figure out what it is I'll take a look but yeah it's pretty much the developers taking standard features from other languages and fucking them up just like they did yesteryear. Closures with a use block... even in C you don't have to do that... it's a joke and a mes…

Yeah, the functional programming side of PHP is ugly as sin.

Forgot to add your latest variable to the use block? No "closing over" for you.

What's that? All array function are prefixed with "array_"... except for the old ones which aren't, making it both verbose and confusing.

Re: The new PHP

#184

Whenever I hear "the new PHP" or "its not the old mess anymore", I say to myself, thats hardly the point. The key flaw I find with PHP is with its community and lack of any mature frameworks. Half of the PHP coders are hopeless script kiddies, thanks to low barrier entry it has, and I don't feel a single framework exists that can match Rails or Django. For the matter of fact, the framework with largest community, Cod…

Codeigniter has been all but abandoned by EllisLab, the community is giving up on it and there are far better frameworks available now. For example Laravel, the growth that Laravel is experiencing right now is huge, it has overtaken Codeigniter as the most popular PHP framework on GitHub and has a growing and active community. Anyone even thinking about Codeigniter any more is doing themselves a disservice, Laravel i…

Not a PHP fan, but I'm using Laravel at my current client, and it's pretty slick and well-thought out. Quite nice.

Re: The new PHP

#185
post #182

Earlier quoted context omitted.

It is an algorithm used in compiling languages like Scheme where you calculate the set of free variables in a function and then create a closure (a function pointer and an environment, which is basically a way to lookup free variables). PHP requires you to do this by hand with the "use" keyword, e.g. use($a, $b, $c) where $a, $b, and $c are free variables (that is they are not bound in the current scope). I see no re…

AFAIK, `use` were required because PHP has variable-variables: Hopefully, nobody uses variable-variables these days, however this is the reason behind the introduction of `use` for closures.

Yep that occurred to me after I posted this, but I believe it should be possible to exclude variable variables from this at the cost of a runtime error if you try to use them in a closure. Someone else pointed out to me that PHP has other ways of messing with variables as well and that it would require full evaluation to determine all of them, so maybe it "makes sense", but only because of the extremely dynamic nature of variables in PHP.

Re: The new PHP

#186
To me the criticisms about PHP are pedantic and is a result of misunderstanding the philosophy behind PHP. The kneejerk reaction language modifications the PHP community made because of the 'PHP sucks lol' meme is detrimental to the language itself.

PHP is a mature webdevelopment language that features an easy to learn, read, and develop feature set. Scala or Perl are not. (See Perl 6) So I don't see how emulating it will provide any form of benefit. Picking up a language feature because a guru attacks PHP because they can write a feature X in Y lines is almost an immature.

The reusability and performance issues were genuine, but these were to be expected given version iterations and the fact PHP introduced namespaces a while back.

Re: The new PHP

#188
post #154

Earlier quoted context omitted.

There's a vast array of frameworks for just about any appetite available in PHP. Just looking for a simple MVC app? Silex ( http://silex.sensiolabs.org/ ) Want something that's beefier and more rails-inspired? Laravel ( http://laravel.com/ ) Want MVC but near native PHP performance? PhalconPHP ( http://phalconphp.com/en/ ) Building an enterprise application with a team of developers? Symfony ( http://symfony.com/ ),…

You mention performance... Is phps performance any good? I've always been under the impression that it is quite slow. Maybe I'm just buying the fud.

That question depends on what your trying to accomplish.

If you're operating on a massive enterprise scale, it's probably not going to be good enough for your hardware. The HipHop VM might be a saving grace if you're already built on PHP, but pragmatically it's probably a better idea to choose a more matured solution (probably something on the JVM).

If you're doing something that is algorithmically intensive (video encoding as an arbitrary example) PHP is going to be a bad fit.

However, if you, like the vast majority of developers, are working on a website that's main technical purpose is to store data of some sort to a back end and retrieve it later for display and you're not yet operating on a large scale (1M+ users) then PHP itself is probably not going to be your bottleneck for a long time.

If you're a fan of benchmarking, techempower does a good job of unbiased comparisons (although keep in mind these are just benchmarks. It doesn't account for how a particular language or framework is optimized for): http://www.techempower.com/benchmarks/

Re: The new PHP

#189
post #105

Earlier quoted context omitted.

" Not everyone wants them." And not every project needs them. PHP has been wildly successful precisely because it can fit in entirely small use cases, as well as big cases. Someone who needs to create a dynamic footer with a "copyright $year" in it... has no need for MVC, routing, templates, version control, etc. They just don't. It's precisely because PHP has a default content-type output of 'text/html' that this so…

Kind of like Perl CGI? Not many places using that these days.

perl/cgi was a thing for a few years, but even by the late 90s was losing ground to PHP. PHP's been gaining ground year on year for a decade. Will it remain in this position forever? Nope. Another several years? I think so.

It's far too entrenched in too many operations to be easily replaced. Perl didn't get that foothold, simply because there weren't as many developers or websites back then. Well... "simply" - there are myriad reasons why Perl didn't retain its early mindshare and install lead.

Re: The new PHP

#190
post #74

Earlier quoted context omitted.

Considering the fact that I can set up a development environment in docker using PHP with a makefile and it's built in webserver, I'd say you've missed the point of it. It's a great addition, and with Composer/Packagist (which does currently have an issue with replacement packages, that needs to be fixed) plus the new features in 5.5, I can comfortably say I like using PHP. Also, I've really got to stop reading the c…

you mean where anyone can submit a package, and it's replacements will be taken into consideration globally? Replace everyone's symfony security/auth module? what could possibly go wrong? :D

Yes that :( so stupid.
Post reply on HN