recent

Is PHP a badly designed programming language?

Yes, it's a horribly designed language (read PHP: a fractal of bad design if there is any doubt in your mind), but by asking this question you're misunderstanding PHP.Let's try to understand where PHP is coming from and what it is. This interview with Rasmus Lerdorf, creator of PHP, shines a lot of light on what PHP is and what it isn't: Interview - PHP's Creator, Rasmus Lerdorf"Well, I didn’t plan PHP. I think in terms of solving problems, not in terms of software projects. I actually hate programming, but I love solving problems."One could argue that it's a bit misleading to even call PHP designed. Sure, in some sense it's designed, but the word designed, at least for me, conjures the image of someone with great experience that sat down for a year or two, and designed a language - this is how Clojure, C# and Haskell were created. That's not what happened with PHP. Instead, I'd say that PHP was grown.If you doubt this, check this out: Re: Flexible function namingRasmus: "htmlspecialchars was a very early function. Back when PHP had less than 100 functions and the function hashing mechanism was strlen(). In order to get a nice hash distribution of function names across the various function name lengths names were picked specifically to make them fit into a specific length bucket. This was circa late 1994 when PHP was a tool just for my own personal use and I wasn't too worried about not being able to remember the few function names."The sentence above would make many computer scientists start turning in their graves at 1200RPM.You need to understand that PHP was written by Rasmus Lerdorf more or less by accident as a constantly growing number of helper functions when doing web programming. If Haskell is a super-designed, well organized toolbox in titanium with lots of powerful but weird and arcane tools, PHP is three to four toolsheds in different color (one pink with green spots) filled with random but very useful and approachable tools that lacks cohesion.I think Lerdorf says it best himself:Rasmus: "In the end, what I think set PHP apart in the early days, and still does today, is that it always tries to find the shortest path to solving the Web problem. It does not try to be a general-purpose scripting language and anybody who’s looking to solve a Web problem will usually find a very direct solution through PHP. Many of the alternatives that claim to solve the Web problem are just too complex. When you need something up and working by Friday so you don’t have to spend all weekend leafing through 800-page manuals, PHP starts to look pretty good."Get it? Yes, from many points of view, PHP is a horrible language, but if you're in a situation where you need the shortest possible way to solve a web-related problem and long-term consequences are of little concern, then PHP starts making a lot more sense.
Powered by Blogger.