12 ms·
I started my career in PHP ~15 years ago trying to do OOP in PHP 4.x. That was "fun". In the meantime I switched to other stacks but I've been keeping a distan
by cntainer 5y ago
I started my career in PHP ~15 years ago trying to do OOP in PHP 4.x. That was "fun".
In the meantime I switched to other stacks but I've been keeping a distant eye on how PHP was evolving and I still am involved with PHP projects to a certain degree, though rarely at code level.
I really appreciate the effort put into fixing most of the things I hated about the language, though at times it felt like the language and some of the frameworks were trying too hard to copy the Java ecosystem, all while Java itself was starting to modernize.
I'm curious what is the value proposition of the latest PHP version(s). Why would I choose PHP when starting a greenfield project? I know one of the easiest answers is that there's a huge amount of developers worldwide that know PHP, but apart from this obvious reason is there anything else that would make someone choose PHP ahead of other stacks?
- kijin 5y agoThere are definitely parts of PHP and its ecosystem that have been trying to copy Java. On the flip side, PHP is quite similar to Java when it comes to its value proposition, so I can appreciate why the devs have chosen that path. Like Java, PHP is stable and slow-moving. It takes backward compatibility seriously, and it has a huge community. PHP is to small-time "webmasters" and lifestyle businesses what Java is to governments and large corporations. If you want to build something once and get passive income out of it for the better part of a decade, PHP has your back. Pinboard is a prime example of this business model. If you're a fast-moving startup who will replace your entire codebase every six months, you might be better served by JS.
- cies 5y agoWhy would one pick PHP over Java except because "you already know PHP"? > If you're a fast-moving startup who will replace your entire codebase every six months, you might be better served by JS. Noooooo... :)
- kijin 5y ago> Why would one pick PHP over Java except because "you already know PHP"? If it's a lifestyle business or hobby project, it usually costs less to host a PHP app somewhere than to find a place where you can get decent performance out of the JVM. Even a small droplet can be a lot of money and effort for some people in some parts of the world. I often see kids pick up PHP for this reason alone. Then they stick with what they know.
- cies 5y ago> Why would I choose PHP when starting a greenfield project? Because you don't know better. If all you have is a hammer, everything looks like a nail. Ruby + Rails is miles ahead of PHP + Laravel. If you want more static typing (which I currently believe is a good thing) I really like Kotlin (+ KTor or + Javalin). If you are okay without OO and like static typing Haskell + IHP is pretty complete. If you are okay with learning about low-level stuff, Rust + Actix is really nice. All of this may require learning new things, and coming from PHP that's a good thing. PHP and JavaScript are not languages that help you become a better programmer. They are messy and lack important features (sum-types).
- christophilus 5y agoYou can write JavaScript via Typescript, and you now have one of the best and most popular languages there is (including sum types). There are still a lot of warts, but it’s actually a really nice language IMO.
- cies 5y agoHave you seen ReScript and/or ReasonML? They are much nicer IHMO, but, yes, not as popular.
- christophilus 5y agoI've played with them quite a bit from the first time they were mentioned on HN. I really like OCaml. But the tooling and ergonomics are heavily in TypeScript's favor at this point, and at least for me, that makes a bit difference in day-to-day work. Anyway, my favorite of that variety of languages is PureScript. It's almost perfect.
- cies 5y agoI wholly agree about PureScript. Elm's also nice. I like the fact that it is a little dumb down (same could be said for early Java and Go), it creates code everyone can read. While it is still very Haskelly in day-to-day practice. In fact I'd say PureScript and Elm are stronger typed than Haskell (as e.g. `head` in Elm evals to a Maybe).
- ceejayoz 5y ago> Why would I choose PHP when starting a greenfield project? For me, the answer is Laravel.
- nerdponx 5y agoFor someone who has never used PHP: what is so good about it?
- ksec 5y agoBasically the Rails for PHP, but with an arguably bigger ecosystem.
- dotancohen 5y agoLaravel provides structure to PHP apps. It includes a terrific router (Symphony) and a slew of functions missing or clumsy in PHP.
- cntainer 5y agoIf I'm forced to choose PHP that's the choice I would also make in most cases, probably because it reminds me of some of the things I liked about Rails.
- heurisko 5y ago> I'm curious what is the value proposition of the latest PHP version(s). I think more and more people have started to realise that typed languages make better, more reliable software. The incremental additions to PHP's type system are just a move towards this, I think and can be seen in other languages such as Typescript. I'm just not a fan of dynamically typed languages anymore, even for small scripts. > Why would I choose PHP when starting a greenfield project? I think it depends on your greenfield project, but there are many domains where problems are just solved related to e-commerce or shuffling around content online. To this point, PHP benefits just from the fact that it has been around for so long, and will continue to be supported far into the future. Many PHP frameworks like Symfony have LTS releases that will ensure software is supported years into the future, with strong support from agencies.
- chefandy 5y agoI think that says more about your particular mental model of programming than about programming in general. In the couple of decades I’ve been coding, I’ve seen good use of both dynamically/weakly-typed and strongly typed languages. Sure— thinking you’re going to save time writing more complex applications by avoiding boilerplate is flatly wrong. However, if boilerplate would be a double-digit percentage of your code, you probably will save time avoiding it because any unlikely dynamic typing issues will be easily resolved. But if it’s small enough to be inconsequential and you’re in the typed-language zone, why not use your typed language, anyway? Avoid dogma and use the right tool for the job, I say.
- deleted 5y ago[deleted]
- heurisko 5y ago> I think that says more about your particular mental model of programming than about programming in general. Well, I originally started programming only using dynamic types. Then I moved to typed languages, and I could avoid whole categories of errors. I don't see it as dogma, I think typed languages are just qualitatively better at creating software. I also think this is starting to become industry experience, as efforts like Typescript, and the incremental additions to PHP's type-system show.
- Isinlor 5y agoShare-nothing architecture, good, stable ecosystem build around Composer, Laravel and Symfony and as you said a lot of devs. Otherwise, I think differences in syntax etc. are rather subjective and everyone has their preferences. For example, I really like PHP "arrays" because it removes cognitive load of choosing between different data structures. When writing business rules 90% of time I don't really care about optimization or memory, but about readability and communication. Overall, PHP is rather dumb language and I love it for being dumb. Python package management currently is a nightmare, but projects like Poetry seem on a good track to make it better. JavaScript is better than Python at package management, but it has issues with many small packages maintained by random people. Java ecosystem also seems quite a lot more complex, especially when you compare Composer and Maven. Compilation aspect also changes the way you work. I have no experience with Ruby, C#, .NET etc.
- agumonkey 5y agoI seems to me that php/js/python will have a large consolidation in the next decade.
- ducharmdev 5y agoWhat do you mean by a large consolidation? As in users will coalesce around one of these ecosystems, or something else?
- agumonkey 5y agoMore like a lot of their flaws will resolve around a similar set of ideas.
- cntainer 5y agoI can agree with the share-nothing architecture as a good selling point that keeps things simple but there are use cases where this is actually a limitation. Parts of the community seem to want to go over that limitation so things like Swoole and Roadrunner were developed. I guess it's interesting to have both options available even though much of the ecosystem won't readily function in both contexts. While the ecosystem seems a bit weaker that what I would expect considering the number of developers (comparing to Java, Ruby, Python) I don't have a strong opinion on package management. I feel like all major platforms have gotten into pretty good shape on this front. Like you mentioned, if I start a new Python project I can just choose Poetry and avoid most of the drama.
- elondaits 5y ago> Why would I choose PHP when starting a greenfield project? LAMP stacks are super ubiquitous, open source, cross-platform, and in many cases to deploy your app you don't need to configure anything, add any modules or dependencies... just copy your files in place. A small project (e.g. contact form with a CAPTCHA) could be just a small file named whatever you want, which you can place anywhere in the public directory, and it'll work. If you don't want to maintain the server you can get a managed VPS and things will probably run and continue to run for years without any intervention on your part, even through software updates. ... The exception is that PHP breaks backwards compatibility often, but even then most hosting services let you choose between different PHP versions which they'll maintain for a while. Installing older versions from package managers is very easy as well. That said, I don't think this is a strong reason to use PHP in most projects. I do think it could be one of the strongest ones to justify its use in some specific projects.
- cntainer 5y agoHaven't thought of this, I guess for some people it makes sense especially for small, personal projects. I'm more biased towards startups with a plan to grow or larger projects. In my case if the hosting provider doesn't have something like DigitalOcean's droplets I'll still rely on docker compose instead of the default stack deployed on the system whatever stack I'm choosing. But yeah that's raising the bar too much for most people especially for a couple of scripts or pages.
- phphphphp 5y agophp is my language of choice, I love modern php, but I struggle with the same question. As a language, I think php is great, and for a solo project it is an obvious choice for me because of my proficiency and the quality of the language... but would I start a greenfield project with php? No. I've worked across a variety of different companies and a consistent theme is the existence of "php developers" in these companies, and the bad quality software they produce. I'm currently working at a company (founded within the last 5 years) and their php codebase is AWFUL (no structure, 1k+ LOC methods, no tests, no ci, no documentation etc.)[1]. The problem is not php, it's that a lot of PHP developers are doing the same thing they did 10 years ago, despite the industry having moved on. As a Software Engineer, I think there's a very valid case for php over Ruby or Python or Node, however as a CTO or a team lead, I'd really, really struggle to justify it, which pains me to say. If you're trying to hire php developers, you'll be hiring a lot of people who haven't changed how they work since the late 2000s. I'd rather hire code school graduates to write Ruby than a php developer with a decade of experience. [1] People can write bad code anywhere, but pre-historic php is especially terrible. A company with bad golang is an order of magnitude more penetrable than a company with bad php.
- cntainer 5y agoI completely agree with this but I avoided mentioning it as I wanted to get some objective technical answers, decoupled from any of the usual operational concerns: number of people, mindset of people, seniority, etc. I think the main cause is the low barrier for entry. It's great that anyone can get started quickly and be successful but it also means that the resulting mess can be at a level that you rarely see in other stacks where the barrier for entry is a bit higher. I can clearly see that the PHP ecosystem is there (mature libraries for mocks, tests, etc) but like you said, there are people that just don't care. The language and ecosystem evolved faster than a big chunk of the developer community and I don't think everybody will catch-up anytime soon, as old PHP code bases can still generate a nice revenue doing maintenance.
- lordgroff 5y agoI mean value proposition specifically to the latest version? Some syntax improvements here and there, nothing big. The value proposition *is* the ecosystem. Do I prefer coding Python to PHP? Sure (although it's not night and day difference by any stretch of imagination). Do I prefer Laravel or Django? Laravel. Do I prefer WordPress or ....? Actually, there's no equivalent, it's the one ton gorilla in that space. When it comes to the 'classical' web (but also fun new toys like Laravel Livewire), there's very little that can compete with PHP as far as I'm concerned and the IMHO minor warts are certainly not worth losing the ecosystem for.
- lelanthran 5y ago> Why would I choose PHP when starting a greenfield project? Ease? I have not professionally used php since php4, and last set it up in php5.x. Last night I wanted to send some data to an http server, a small payload of json, that would be saved into a DB and queried later. Took me all of 5m to realise that my php test script that receives the file can be copied over to my el-cheapo webhost account unchanged and work fine. No extra "database" modules to download, then install on a host I've no shell access to, sending email worked out the box, etc. Php reduces the friction. I remember trying to use Python for something (with Django, I think) in 2011 and it was absolute hell to get deployed onto my webhost; fingers burned, I won't touch it again. Php is basically batteries included, and works everywhere. I'm sure the Python, Node or Ruby alternatives are elegant, and neat, etc ... but if I wanted that, it means the project is expected to be large-ish, and for anything more than a few thousand lines of code I'm switching to a compiled language.
- xigoi 5y agoIf you use CGI, you can have it just as easy with any language.