TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

What exactly do you dislike about PHP? and Why is your web language of choice better?

6 点作者 ACSparks大约 18 年前

12 条评论

SwellJoe大约 18 年前
PHP is pragmatic and pretty fast, but everything, everything, everything, beyond the "HTML template language" bits, are bolted on with whatever tools were handy at the moment. I'd be stunned if more than a couple hours of design work went into the object system, the type system (where == and === are used for evil rather than good), or even the standard library function names.<p>It has some strengths: Big library (not as big or as high quality as CPAN, so if library support is what you need, go for Perl), a lot of example code (but it's mostly horrible quality...even good examples are pretty bad in spots), and really easy deployment. So, if you're building an Open Source project that you want a lot of people to use, it's a great choice--PHP is available on every hosting server on the planet. Or, if you need a "blank-plus-this-widget" you can probably find the "blank" already written in PHP and then build your "widget" on top.<p>But, if you're starting from scratch, why commit yourself to working with a shoddy language for the months or years it'll take to finish? There are good imperative languages out there for web app development: Ruby and Python, in particular. Though the frameworks craze for these languages are partly to bridge the gap that they have with PHP (they're all missing a "view" layer for the web, because PHP is a reasonably powerful, if ugly, template system), and a lot of the other crap just makes things ugly...they get built for one particular application and then stretched for general-purpose use, and in the stretching they get a bit misshapen and hard to fit into any specific task.<p>Anyway, Ruby and Python are pretty and reasonably consistent languages that are nice to work with. PHP is neither. Perl...well, it ain't necessarily pretty, but CPAN is hard to beat when you just want to get the job done...and you can treat it as a functional language pretty effectively, which is all the rage around these parts (and you'll probably want to after you see the bolted on object system).
gyro_robo大约 18 年前
This is fairly well-trod territory:<p><a href="http://www.google.com/search?q=why+php+sucks">http://www.google.com/search?q=why+php+sucks</a><p>A good resource for comparing languages is the shootout:<p><a href="http://shootout.alioth.debian.org/gp4sandbox/benchmark.php?test=all&lang=all">http://shootout.alioth.debian.org/gp4sandbox/benchmark.php?test=all&lang=all</a><p>Most people just refer to the overall scores, but what's more interesting is seeing the same program done in different languages.<p>This one is pretty straightforward:<p><a href="http://shootout.alioth.debian.org/gp4sandbox/benchmark.php?test=nbody&lang=php&id=0">http://shootout.alioth.debian.org/gp4sandbox/benchmark.php?test=nbody&lang=php&id=0</a><p>Compare to the same thing in Python, Ruby, Scheme, Common Lisp, and Haskell:<p><a href="http://shootout.alioth.debian.org/gp4sandbox/benchmark.php?test=nbody&lang=python&id=0">http://shootout.alioth.debian.org/gp4sandbox/benchmark.php?test=nbody&lang=python&id=0</a><p><a href="http://shootout.alioth.debian.org/gp4sandbox/benchmark.php?test=nbody&lang=ruby">http://shootout.alioth.debian.org/gp4sandbox/benchmark.php?test=nbody&lang=ruby</a><p><a href="http://shootout.alioth.debian.org/gp4sandbox/benchmark.php?test=nbody&lang=chicken&id=3">http://shootout.alioth.debian.org/gp4sandbox/benchmark.php?test=nbody&lang=chicken&id=3</a><p><a href="http://shootout.alioth.debian.org/gp4sandbox/benchmark.php?test=nbody&lang=sbcl">http://shootout.alioth.debian.org/gp4sandbox/benchmark.php?test=nbody&lang=sbcl</a><p><a href="http://shootout.alioth.debian.org/gp4sandbox/benchmark.php?test=nbody&lang=ghc">http://shootout.alioth.debian.org/gp4sandbox/benchmark.php?test=nbody&lang=ghc</a>
ramen大约 18 年前
I often find myself defending PHP. It seems to be very unpopular lately, at least by some very vocal individuals on the web. I like PHP, and here's why:<p>It runs everywhere, has lots of libraries, and most of my friends know it.<p>That, for me, is huge. It's enough for me to forgive, tolerate, and even enjoy programming in the language.<p>Anyway, here's what I don't like:<p>The lack of a decent module system.<p>The lack of closures.<p>The weird reference semantics of objects in PHP4. PHP5 is way better in this regard, but now I have to worry about whether my code will still run on PHP4, and whether or not I will need it to.<p>The clumsy templating syntax. Short tags help, but I'm supposed to feel guilty if I use them.<p>The need to use unreliable third-party software to get bytecode precompilation, causing me to worry about the performance costs of modularity. (!)<p>Magic quotes. And the fact that I may need to undo them depending on the whims of system administrators.<p>Arrays. I wish dictionaries and lists were separate concepts like they are in Python and many other languages I want to interoperate with.<p>The name. I hate when I have to explain what PHP stands for. I feel like enough of a geek as it is.
jward大约 18 年前
PHP is ugly.<p>Really, I could go on a rant about speed and security, but it's just ugly. I do most of my coding in Python now days which spoils me. I look at php and it's a nasty mashup of code, data, and structure all rubbed into one nasty little steaming pile. Python is pretty and that's why I like it. It's easy to read, easy to understand, and does not explode into a visual cacophony like I've seen most php projects do.<p>I'd use php for a small simple one off thing because it is stupidly simple to get a page working with no fuss. I also have no issue using php products like Wordpress or PHPBB. My first web startup I wrote in php and it was a pain to maintain after a while. Anything large I'll stay away.<p>Just because it's ugly and I have to stare at it.
评论 #12410 未加载
aantix大约 18 年前
Have you seen the function list? <a href="http://www.php.net/quickref.php">http://www.php.net/quickref.php</a><p>It's a nightmare. How about some organization? How about a hierarchy? How about some terseness?
评论 #12374 未加载
mdakin大约 18 年前
"You can nest function declarations, but with limited effect. Nested declarations do not limit the visibility of the inner-defined function, which may be called from anywhere in your program. The inner function does not automatically get the outer function's arguments. And, finally, the inner function cannot be called until the outer function has been called."<p>That's from "Programming PHP" by Rasmus Lerdorf et al. <p>This sort of messiness, repeated dozens of times in various ways is why I try my best to avoid PHP.
walesmd大约 18 年前
I actually see the PHP bashing as dieing down quite a bit, Now that the Ruby on Rails craze is over with (the language is awesome, but I'm glad to see some of the hype go away).<p>I think people are finally understanding that there is room for both languages (and more) and each language has it's strengths and weaknesses than can only be leveraged (or overcome) by someone truly comfortable with that language.
评论 #12367 未加载
ACSparks大约 18 年前
There seems to be much talk thrashing the web language incumbent PHP. What exactly bums you out? and why is your language better?
评论 #12675 未加载
jaggederest大约 18 年前
Well, mostly just that PHP has been extended far beyond the simple templating language it was designed as.<p>My language of choice (ruby or haskell, take your pick) was designed for more general tasks, and so is simpler to write the more general web apps people are building now. I would still like to use PHP as my template language, though.<p>PHP is still very fast when it comes to templating, but it's not very fast at all when doing any sort of number crunching. Ruby suffers here, too, which is why I'm trying to use haskell for my current project.
brlewis大约 18 年前
Look through Chapter 4 of the BRL manual for paragraphs marked "Advocacy".<p><a href="http://brl.codesimply.net/">http://brl.codesimply.net/</a>
kogir大约 18 年前
Every time I have to type a '$' in front of a variable name I have BASIC flashbacks from my prepubescent years.<p>That did me in. Really.
Tichy大约 18 年前
It has an escape_mysql_sql method - that alone says everything for me. It's just a big, messy mess.