DEV Community

Discussion on: Pitch me on PHP

Collapse
 
wesen profile image
Manuel Odendahl • Edited

I've been using PHP since PHP2 (!) days. I did a serious site with it back in 2010, and am back into it after a 10 year break on a wordpress site. (I don't want to toot my horn, but I want to put this a bit into perspective: I'm a huge functional programming fan, I've written web applications in Common Lisp, python, node, C (!), perl, java, scala, C# over the years).

Things I like about PHP:

  • cgi-bin lifetime model. No garbage accumulating over time, no weird runtime dependencies and side effects: easy to scale horizontally, easy to refactor individual routes or subsystems.
  • fast. you can easily compile your code using a code cache. I use that to compile down intermediate languages (say, mustache) to JIT code.
  • it has had all the tools necessary for clean programming since PHP5: classes, traits, closures, introspection. Hate about the standard library or the garbage code out there all you want, it actually doesn't really matter. You could always write nice fluent APIs and use the introspection capabilities to do metaprogramming. Out of this came frameworks like laravel and co.
  • tooling is decent: debugger, profiler, compile cache, modules for everything out there, unit testing frameworks, package manager. Not the funkiest, but they are all reliable and get the job done.
  • big community of competent programmers (in Europe especially). For some reason, PHP hate is turned up to 11 in the US. In germany, poland, ukraine, people use it and move on and have done so since 2000.

The main two for me are the speed and cgi-bin lifetime. Most of the reasons people hate on PHP are kind of non-sequiturs. I don't care that people find it easy to write bad code in PHP, I have all the tools I need to write good code, and bad code I can easily isolate, contain and replace.

I assume this is directed at someone with programming experience going into PHP. I would be quite wary giving PHP as a language to a beginner, without proper guidance. But what language is good for a beginner is a topic for another day!

Collapse
 
pierrewahlberg profile image
Pierre Vahlberg

This. It has been a really interesting journey to debug node memory leaks that could go on for weeks without crashing or crash four times an hour. This is rare (but ofc possible) with php by design being request scoped.

The typing issue is interesting. Its a script language with types added, to some extend. I see it as TS is for JS, more of a tool to impose clean code and better structure and self documentation than something that "makes you write bug free code".

Php can be really fast, but as with any tool you are the assembling man and feel free to mess it up here too. Its neither harder nor easier imo.

The most misunderstood thing is probably all the new devs who pick php up as first language and then they find something like Golang or C# and thinks that that solves all their issues and they bash on php. I'd say no language is better than the programmer and you should learn as much as you can about how to use the language properly.

Collapse
 
jeremyf profile image
Jeremy Friesen

For some reason, PHP hate is turned up to 11 in the US. In germany, poland, ukraine, people use it and move on and have done so since 2000.

I have to wonder how much of that was the massive flash-bang of Django and Rails showing up; and both of those coming not from the coast of the US but from the midwest. They also showed up at a time, if memory serves, of folks hitting the "time to upgrade PHP versions and I know where all the bodies are, maybe something fresh?"

But yeah, the hate on PHP is unreal. I mean it's not like it's Perl or something (just kidding; use the language you know and love).

Collapse
 
matthewbdaly profile image
Matthew Daly

I used to use Django and always wanted to work with it professionally, but reluctantly applied for PHP jobs earlier in my career because that's what there was where I live. At my second web dev job (not second overall as it's a second career for me) I was mostly working solo, and used CodeIgniter for some projects, but it became obvious quite quickly that it was a Fisher Price My First MVC Framework, so where I could I used Django instead - it was easier to manage dependencies, far easier to write tests, and had the killer feature of the built in admin.

Fast forward to 2015 and after years of wanting to drop CodeIgniter completely and move to a more modern PHP framework for new projects, we made the jump to Laravel, and it was the first PHP framework that was good enough that I felt comfortable using it for everything. I haven't used Django since.

Thread Thread
 
technicaljohn profile image
John Holcomb • Edited

I know Laravel is big and most people know it, but I had a similar experience with Yii. It has most of the comforts of Django, but PHP.