4 ms·
I upvoted you and vouched u/rizky05 because I think they raised an important point. > It is powerful indeed. But PHP syntax feels unelegant and making me write
by dijit 3y ago
I upvoted you and vouched u/rizky05 because I think they raised an important point.
> It is powerful indeed. But PHP syntax feels unelegant and making me write unnecessary ceremony. It feels different when I write typescript code, every character I type fits like lego.
> Especially when my codebase grows so much. Navigating PHP project is like thrown in forest without a map, you can always look up the sun to find your way.
“Elegance” is something that gives people warm fuzzies, I think this is why there are so many Rust advocates (I am one), when pieces fit together nice or can be refactored cleanly and tests are first-party it is nice.
However there have always been “hacky” and “proper” languages, because doing something hacky that works also feels great.
Python is a hacky language, it’s easy to go to 0-100 very quickly. C++ however requires time and precision to make things proper, so people avoid it and few things are made comparatively in C++ unless it's infrastructure software that people spent a lot of time writing.
Maintainability be damned, sometimes you really just need to throw something together.
The curse of things that work is that they will be expanded upon and kept around for too long.
Unfortunately: PHP works, and is an excellent hack-language for the web. Which means there’s a lot of code that becomes “production grade” that should really have never been intended to live forever in the first place.
- smarkov 3y ago> when pieces fit together nice or can be refactored cleanly This is a trade-off that makes sense to embrace in some contexts, and I do believe that web is one of them. The more nicely your pieces fit together the harder it'll be to break them apart. You can only refactor cleanly once you are aware of all the requirements, but those requirements are usually constantly changing in the context of web and so your pieces fitting together a little too nicely means that you now have to refactor a lot more code.
- thinkindie 3y agoPHP can be super hacky and super structured, within the same file, and it's your choice. You can have tests, static analysis, etc etc, or not. Or you can start without and then adding it as the project mature, without having to necessarily switch to another language. I'm working on my own startup that started as a side project and it was super hacky at the beginning, but by sticking to PHP (and thanks to PHP continuous improvements) I was able to refactor little by little and make the codebase way more structured and easier to maintain.
- Shish2k 3y agoAs a vaguely-related anecdote, I wrote a super-hacky PHP script in highschool 20 years ago, it gained some popularity based on being open-source and easy-to-install (PHP’s #1 strength for sure) - and to this day I am still spending a significant chunk of development time refactoring based on ideas that eg Typescript and Rust have out of the box (eg using PHPStan to emulate a language with typed arrays) (I keep wishing that I could rewrite it in a “better” language, but there is no other language that is even in the same ballpark when it comes to “any random user can upload this .php file to any random web host and expect it to work”)
- lmm 3y agoYou can write any kind of code in any language, but going against the grain of that language tends to go badly. Even if your style works for you, if it's not what the ecosystem expects you'll have trouble using libraries, you'll have trouble onboarding new hires, ....
- mp05 3y agoZuck wrote a super hacky PHP script 20+ years ago and now he's a gazillionaire.