6 ms·
Ask HN: Any open problems in PHP that need solving?
I’ve have a decade of PHP development under my belt and have been reflecting on why PHP, despite recent improvements to language, is still problematic. One side of me says that the community should just let PHP be “PHP”; if a Typescript for PHP were made, would the community embrace it or lament it? The other side of me says that it’s not PHP, the language, that is problematic, it’s simply _how_ it is used; for example, PHP frameworks—although useful and serve a purpose—don’t really result in less debugging time nor do they make code more literate or smaller in scope.
So the question I pose is: A. Should PHP as a language be augmented, like TS does for JS, or B. Should the community focus on the methodology of PHP to make development simpler? What are some concrete propositions you can imagine that argue for either case?
I think any PHP developer can propose more than one new feature they would like to see. As for A, I personally would like to see an actual native module system. As for B, I would like to see less MVC frameworks and more macro systems within the ecosystem.
- ameyv 6y agoI used to write php apps and wordpress plugins. Php always felt messy and weird to me. But i think strength of php lies in its vast available free scripts and ability quickly stitch up server side rendering, but probably now, node would be better for that now. it feels like certain style which was popular a decade ago, now seems not so exciting or new. Probably that vibe is what lost with php. But then if you like to find try out other language like Kotlin, Haskell, Elixir or even Ruby. I think there are other language communities are much more vibrant than php. For example python, ruby, java. Also these language have expanded their beyond just web development that also kind of fueled that adoption.
- wolco 6y agoa) no b) yes I'm pretty happy with what php has become. Don't really understand the typescript benefit here. I would like to see a popular async framework.
- poletopole 6y agoCheck out ReactPHP.
- wolco 6y agoI like ReactPHP I've been using a really small project that has a good implementation of workman. https://github.com/walkor/phpsocket.io https://github.com/walkor/phpsocket.io
- skinner927 6y agoWhat problems does PHP as a language solve better than other languages?
- poletopole 6y agoGood question. Mostly html templating since that is how it began. So you could argue improving that aspect would be a good idea. The major challenge for most is debugging because it is hard to separate the server from the PHP. I may toy around with Lua and see if that can be fixed.
- godot 6y agoI agree with you on PHP doing html templating well, however it just seems not big enough of a strength, if you will. I also had a decade of PHP experience before transitioning to nodejs in the last few years. I first transitioned for my day job, and then also started using node for hobby projects. For hobby projects I like to keep things as simple and quick as possible (translation: so no React frontend and all that stuff), so I was trying to emulate how PHP does things and just have my node server render html from the server. I've found that almost any way I try to do it, it's a little bit more awkward in node and you end up having to choose from one of the dozen of templating libraries and learn their syntax (no-go for me). In PHP one of my favorite things is, say you pick up a super simple routing lib like ToroPHP. In your route handlers you could skip all templating libraries altogether and simply require() a .php file that is your view html. It would simply be a file that contains HTML where you could sprinkle php statements anywhere. It's just about the the best/easiest way to template HTML output from the server for hobby projects (and I argue even for larger projects too in many cases). What I end up doing for hobby projects in node now is usually going JAM stack. Build my frontend in Svelte (which is as close to no framework as possible), and build API server in node with Fastify. I guess where I'm going with that is that a setup like that isn't much more hassles than doing PHP and html templating for these small projects.
- adventured 6y agoAs a package deal it does CRUD / CMS better than any other languages and always has. This is why prominent giant CRUD / CMS services used it, including Wordpress, Wikipedia, Tumblr and Facebook. And it's an even better language now than it was when those services started using it.
- 02020202 6y agono. php is perfect as it is and always was. php got bad name because it was the first language most programmers started with..before javascript became the language of the web browser. so with larger user base you will get more bad programmers, hence the language will get bashed more. since php is not stirngly typed you can end up with really bacode, but it will work so the bad programmer syndrome is constantly fueled by bad code written by bad programmers :D .... to this day it is the most used and most performant interpreted languge and it is still de facto the languge of the web. in other words, php became a victim of its own success. remember before type script how people hated javascript, and still do to this day? well, php is not typed language so amateurs that cannot write a good code if their life would depend on it and the ivory tower armchair java/c#/.. warriors will be always bashing it. but php itself is great. absolutely nothing wrong with it. if you don't like it, don't use it. the language is not the problem, the people are, as usual. there is plenty of alternatives so instead of complaining, people should just stfu and move on. personally i have moved to GO some years ago after over a decade with php. not because i had enough of it. no, i love php. but there is no money in web development anymore. so i moved to a compiled languge and do purely backend and less web/front oriented stuff, which i always preferred anyway. though before i left php i remember that i was getting interested in parallel computing and Go had goriutines which served me well. php was getting the reactphp, swoole and other projects at that time but i decided to change the direction so even if it would work for me at that time, now i do more lower level stuff that php would not be suitable for anymore anyway.
- poletopole 6y agoThe thing I dislike about PHP these days is composer. It turned it to Java and I certainly had my Java days. OOP is great but I feel like a ES7 like module system or even Rust’s module system would be better suited in most cases. So I agree with most of what you said, bad programmers make bad code no matter what and most moved on to Golang.