DEV Community

Discussion on: What's the deal with downing PHP development?

Collapse
 
tux0r profile image
tux0r

Being one of the people who did a good amount of PHP and still maintain existing projects (in my case, a couple of WordPress add-ons and a few websites), I think I can explain it:

When PHP arrived, it was grown into "a better Perl" for web developers. The first PHP versions were based on Perl and its syntax still reminds us of the time. That was before "web development" was a major thing - everyone wrote guestbooks and visitor counters, almost nobody wrote anything else. However, being one of few languages for that niche (that was long before some doofus thought that running JavaScript on a server would be a brilliant idea), it exploded - it transformed into a "business language for beginners" in an astoundingly short time. More and more features were packed into a "beginner-friendly" syntax, which, in turn, made more beginners (including me) choose PHP as their web language of choice. To please as many people as possible, abstractions were added, leading to incompatible varieties of the same feature. PHP 7 has, in fact, reduced the number of "official" MySQL bindings from 3 to 2 (mysqli and PDO) - which are still incompatible with each other. [But they improved the overall performance of the interpreter by a couple of magnitudes which is nice. Back to the topic!]

PHP itself is not a "bad language". PHP is forgiving though - it lets you mix HTML with PHP in the same file (similar to what ASP does), it is not strongly typed and you need to enforce strict syntax warnings if you want to have better code. At least two generations of beginners (the same people who probably would choose Python today) started their "career" with PHP code - that implicitly leads to a huge amount of bad PHP code available online, written by people who don't know better.

In my opinion, most people who talk badly about PHP should look into their own JavaScript projects. As if that would be a better language... :-)

what are the better alternatives for web development?

It depends. Generally, PHP is fine because (almost) every cheap web hoster lets you use it. If you absolutely want to avoid PHP because you are afraid of being beaten on the streets for that, here are my suggestions, based on personal experiences:

  1. Any language that can print stuff to the console is suitable for web development, you'll just have to compile your application and feed it to FastCGI. That includes C. Do you have a language you like for desktop development? Awesome. Use that!
  2. I generally recommend to use as few additional libraries as possible. But if you like third-party frameworks: Python has Flask (which is good enough for quick prototyping, at least), C++ has Crow (note: I have not tried that yet), Perl has Dancer. I'm sure that there are more.
  3. If you don't have an allergy against parentheses: Tried Lisp? Common Lisp has the Caveman2 and Radiance frameworks, Racket even comes with a built-in web framework.

I hope that inspires you a bit.