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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Ask HN: What makes PHP so difficult?

2 点作者 joshuahornby超过 12 年前
Having been awake now for roughly 30 hours coding my php project what makes it such a tough and confusing language? Does MVC complicate matters? Am I reading the wrong books/website and It is actually quite simple? In my humble opinion it's quite possible the worst server side language going.

7 条评论

onion2k超过 12 年前
Enough people get on well with it to make it the most popular language for web development, so the implication is that it's you not finding it easy rather than the language being especially hard. It doesn't fit with your mindset. Presumably, as you say it's "possibly the worst server side language going", you've tried a lot of them. Use what works for you.<p>Three other points though;<p>Firstly.. being awake for 30 hours is going to make you sleep deprived and confused, which will make it harder to code things. You'll probably find you're more productive coding for 10 hours, sleeping for 10 hours, and then coding for a further 10 hours than trying to code for 30 hours straight.<p>Secondly, the language you're using is a small part of app development. Tiny in fact. In my experience the "40/20/40" rule is right ... designing and building an app is 40% planning, 20% coding, and 40% testing. That's with about 15 years web development experience.<p>And lastly, if you think PHP is the worst server side language, you've obviously never written a large scale site in Perl. ;)
carloc超过 12 年前
PHP offers a lot of choice.<p>You can use it rather nicely, but it also allows you to write some really awful code. Admittedly, it does not do much to help you write good (=understandable, maintainable) code.<p>This post is rather interesting in terms of using the good parts of PHP:<p><a href="http://fabien.potencier.org/article/64/php-is-much-better-than-you-think" rel="nofollow">http://fabien.potencier.org/article/64/php-is-much-better-th...</a><p>I have been using the author's PHP framework for 2 years now and have experienced huge improvements in the quality of the code I write simply by being exposed to his example. He basically uses a lot of objects but very little inheritance. He also is religious about the DRY principle.
评论 #5021164 未加载
aleprok超过 12 年前
Go to sleep, it's not good to be awake for 30 hours. You are sleep deprived and this makes it tough and confusing. MVC does not complicate matters. MVC is just a standard way to structure your code. You probably are reading somewhat right books and websites, but every source is biased towards something. In my humble opinion you have not tried any other language for http server scripting.
评论 #5021005 未加载
评论 #5021006 未加载
fruchtose超过 12 年前
You've been awake for 30 hours. You are far from peak efficiency. Sleep.
kappaloris超过 12 年前
PHP is old. OO was added later, same for Funcional syntax and IMHO they feel a bit awkward compared to other languages that were created with these contructs from the beginning.<p>The only real difference I find is that you need more discipline than you would with django/ror because you can mess it up more easily. PHP feels like C for web programming.<p>If you feel your MVC framework complicates things it probably is for the former reason (more awkward syntax compared to dj/ror).
duiker101超过 12 年前
depends on what you mean with difficult. PHP was the first "real" language I learnt and back then I was like 13 years old. Maybe I wasn't working on amazing project but I had a decent knowledge. Now, after about 10 years and having tried many many other languages when I look at some PHP code I find it more confusing than other but still not the worst(which is Perl for readability IMHO). One thing that I think really add to much clutter to the PHP code is the $. It might be needed but if now find it kind of "hurts" my eyes. Another this is that is not object orientated(mostly, or at least the more used versions) and I think =&#62; adds as much noise as $. Personally I find much easier to read string.length than strlen($string). But in the end I think all of this things come end up being just personal preference.
评论 #5020894 未加载
xauronx超过 12 年前
What framework are you using? I found CodeIgniter to be pretty helpful. PHP as a language is kind of frustrating because there's so little consistency in it. I usually just keep a second window up to the PHP manual and search a lot. Just go to sleep and come back to it with fresh eyes.