6 ms·
If they pull this off I just might return to PHP for a lot of work. I love PHP's pragmatism, I love that it's batteries included, and most of all I love the de
by skrebbel 7y ago
If they pull this off I just might return to PHP for a lot of work.
I love PHP's pragmatism, I love that it's batteries included, and most of all I love the deployment story. It's basically zero-config AWS Lambda without vendor lockin. If they manage to split off a better language without splitting up the community like Python 2/3 or Perl 5/6 did, then that's a spectacular win in my book. Having a little header on top of each file is real nice (and it also opens the door for mixed PHP/P++ projects, another thing Perl and Python failed at).
I find it telling that the PHP community keeps getting this sort of stuff right (they also got the php4->5 migration right back in the days, through collective community action; they fixed the error that was PHP 6 before it was too late, and so on). Pragmatism to the max, things have to not just keep working, but also stay convenient (like Hack wasn't).
- codesushi42 7y agoHow is PHP pragmatic compared to other languages? Do tell.
- whatshisface 7y agoInstead of having a trillion build steps, you write PHP right in the HTML.
- monk_e_boy 7y agoIt’s so easy to teach. Learninh html css and php is such a win. Quick to bash out a simple site.
- echelon 7y ago> Quick to bash out a simple site. This is precisely why I don't think it's the appropriate tool for any substantial, serious, or long-lived projects. The language feels kludgey, and it attracts an ecosystem of beginners that don't necessarily have to learn much in the way of CS fundamentals or engineering to succeed. (Indeed, I've run into more than a few that don't know the difference between lists and dictionaries or the runtimes of the operations performed on them.) It's not that I think that a language should be a barrier, but I've wasted so much time reading confusing and poorly-written PHP code, and it feels like the language actively empowers code to be written this way. A tool should also teach. There are other languages that have this problem as well (C++ comes to mind), but I think they tend to be hard enough to use that practitioners already understand the do's and don't's. I know it's irrational of me to be so irate that this language is still active, but it bothers me that real engineering work and human productivity is spent on supporting one of so many scripting languages that are marginally different. I suppose I should be even more angry at all the cognitive effort being put into marketing and adtech, but PHP makes me sigh.
- muglug 7y ago>> Quick to bash out a simple site. > This is precisely why I don't think it's the appropriate tool for any substantial, serious, or long-lived projects This is precisely why it is an appropriate tool - those simple sites become more complicated, and eventually they're Tumblr or Etsy or Wikipedia or what-have-you. > it feels like the language actively empowers code to be written this way. I've felt the same thing, especially early on. I think there are two reasons: - a lack of a compile step means you're never forced to conform to someone else's idea of how your code should work (though running a static analysis tool fixes this). - additionally, PHP's interpreter is designed to soldier on in situations where other runtimes would exit (e.g. when it encounters an undefined variable or array offset). While I can imagine justifications for this behaviour, it allows for a lot of bad code.
- tylerchilds 7y ago> The language feels kludgey, and it attracts an ecosystem of beginners that don't necessarily have to learn much in the way of CS fundamentals or engineering to succeed. Reminds me of people complaining about JavaScript over the years, yet we pulled through, the language is better and most importantly, we're making money writing it.
- heavenlyblue 7y ago>> we’re making money writing it So did they in PHP.
- codesushi42 7y agoyou write PHP right in the HTML. I hope this comment was meant to be ironic. Because that mindset demonstrates everything that is wrong with PHP and its community regarding engineering practices and security.
- debaserab2 7y agoI think if you're going to make a statement like that you need to be prepared to provide an argument to back that up. Ten years ago if you had told me we'd be interpolating HTML into javascript I might have said the same thing, yet here we are with React/JSX. It's not only common, it's generally regarded as good engineering.
- codesushi42 7y agoA terrible and incorrect comparison. JSX is a templating language. Your logic still lives within a JS component. Op is proposing that PHP be embedded directly in HTML. That obviously has maintainability and security issues. WordPress is a good example.
- csande17 7y ago> [Embedding PHP in HTML] obviously has maintainability and security issues. Honestly, I'm not sure it does. The two main security issues in typical PHP software are cross-site scripting and SQL injection, and both of those could be solved with better API design. (For example, PHP could use something similar to Rails's `html_safe` to make it harder to accidentally include untrusted HTML in the page.) As far as maintainability goes, I'm not sure what makes PHP uniquely bad in this area. It seems like you could write a bad, unmaintainable React app in pretty much the same way you write a bad PHP app -- by eschewing MVC and sticking everything in the components/templates.
- codesushi42 7y agoHonestly, I'm not sure it does. Of course it does. Less maintainable code is always less secure. Embedding PHP business logic in HTML makes it much easier to accidentally dump confidential state into the response. Sticking everything into a component does not completely eschew MVC. You are still forced to bind values to a template. Mixing PHP and HTML without a template engine provides no guarantees. The responses here from PHP devs reaffirm my beliefs about how haphazard and sloppy PHP devs are.
- 72deluxe 7y agoI do not mean to be rude or offensive but are there plans to fix the half-baked type system? I am using PHP7 at work and the ability to annotate functions with types is a good idea until you get arrays which can take anything (so you can have an array of who-knows-what) so you can't assume further down the call stack that you're dealing with a known type so have to test what you're dealing with, or objects. It's a bit of a mess to me and makes reading the code very difficult without running it in a debugger to step through what you're dealing with. Generics or some form of strong typing (which seemed to be what the type annotations and return value types hinted at) would really help, particularly with large projects. I am coming from a C++ background. Any pointers or tips or documentation for me would be welcome. If P++ pushes some of this strictness further onto the language then great. It saves me having to do it in code.
- muglug 7y ago> until you get arrays which can take anything There's a widely-used PHPDoc standard for annotating arrays: `Foo[]`, and there are at least three PHP static analysis tools that can correctly interpret those annotations: Psalm (https://psalm.dev https://psalm.dev), Phan (https://github.com/phan/phan https://github.com/phan/phan) and PHPStan (https://github.com/phpstan/phpstan https://github.com/phpstan/phpstan). Phan and Psalm also support a docblock syntax for generics - I wrote about it here: https://medium.com/vimeo-engineering-blog/uncovering-php-bugs-with-template-a4ca46eb9aeb https://medium.com/vimeo-engineering-blog/uncovering-php-bug...
- 72deluxe 7y agoThanks for this! This is just what I was looking to know Thanks!