6 ms·
How is PHP pragmatic compared to other languages? Do tell.
by codesushi42 7y ago
How 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.