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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Ask HN: I am a PHP Newbie, Why do most developers hate it

5 点作者 frade33大约 11 年前
Could you please explain me in the terms that would make sense to me. :) that Why do most people prefer Ruby&#x2F;Rails or Python over PHP.<p>I like PHP because it&#x27;s quite easy to learn, moreover, all of the major open source CMS (wordpress) are based on PHP, since most of the websites I deal with run on wordpress so it makes my job easier too. Moreover, I am believing, PHP is the most suitable language for &#x27;web applications&#x27; because it does not rely on frameworks etc (rails) and can develop web applications at its own.<p>I want to know in layman terms, why Ruby&#x2F;Rails or Python are better than PHP. Since I can not figure this out, perhaps due to the fact, I do not have major experience in programming languages. I appreciate if you could explain it to me.

11 条评论

saluki大约 11 年前
I would keep an open mind. PHP is a stepping stone in the natural progression of a web developer and is a good skill to have.<p>If you are working with websites you will naturally learn HTML and CSS, then javascript, then jQuery.<p>Next you might move to wordpress based websites so PHP and MySQL would be the next things to learn.<p>Next step would be your own web application. PHP and MySQL will work for your own web application. And I would recommend developing a few from scratch with just PHP and MySQL. Creating a login system and CRUD features. Creating these without a framework will give you a good foundation to know what&#x27;s going on behind the scenes when you move on to a framework. Before developing a web app from scratch it&#x27;s harder to understand what Rails is doing and why it&#x27;s valuable.<p>Once you do this then the next natural progression will be using a framework to create a web application. I recommend giving Rails and&#x2F;or Laravel (PHP Framework) a try. Even though you will know more PHP than Ruby it&#x27;s a good experience to see how Rails works and why it&#x27;s so popular. Laravel is a good PHP framework similar to Rails if you want to stick with PHP.<p>I wouldn&#x27;t limit yourself to PHP though. Once you have been creating web applications it should be pretty easy to learn any framework&#x2F;language. I prefer Rails and Laravel but that&#x27;s just a personal preference.<p>Back to your question. Ruby and Python (and their frameworks) are more elegant than PHP. But those choices have positives and negatives of course and depends on your clients as well. PHP is easy to learn so you have lots of bad code and bad practices out there. And there are things inherently wrong with PHP compared to other languages. But I think it&#x27;s worth learning especially if you&#x27;re involved with Wordpress.<p>Check out TeamTreehouse.com and you&#x27;ll learn some good programming practices to get you on the right track. If you&#x27;re just getting started the Oreilly Head First books are really good for learning HTML and CSS and their Head First PHP &amp; MySQL is good as well.<p>After that you can check out railscast.com and laracast.com.<p>There is lots of tutorials and information out there for all languages.<p>Good luck.
评论 #7441776 未加载
amerkhalid大约 11 年前
PHP is not perfect but it gets the job done. The biggest problem with PHP is that too many developer write really bad code with it. PHP is just too easy to get into without understanding how to write clean code.<p>If you follow best practices and use modern frameworks like Laravel, then there should be nothing to complain about PHP.
devwebee大约 11 年前
The problem with PHP is its design, or lack of it to be precise. It&#x27;s inconsistent and quite verbose. But it&#x27;s made for the web, so it&#x27;s very easy to deploy, and the workflow is straightforward, put file in a folder on a server and refresh the page. If you&#x27;re new to web development but already have some programming experience, PHP is a good language to learn because it&#x27;s ubiquitous and very easy to get started. If you&#x27;re new to programming, I&#x27;d suggest you learn Python first; it&#x27;s a beautifully designed general purpose language, and will guide you through the right path before diving into the PHP jungle.
评论 #7437110 未加载
sixQuarks大约 11 年前
I&#x27;m a non-technical founder, so I have to outsource my development. I tried to work with Python and Ruby developers, but never had any luck, they seemed like hacks - and I tried to work with several of them.<p>PHP developers, in my experience, have their shit together. This is just my OWN personal experience. I would never hire a Python&#x2F;Ruby guy again, I&#x27;m always going for PHP developers now.
评论 #7437681 未加载
ericathegreat大约 11 年前
Some of it is due to age. People like shiny, new things. PHP isn&#x27;t shiny and new any more.<p>Some of it is due to security. Several of the things which made PHP very accessible to new developers also encourage poor security practices. For example, sending SQL queries to the database as a raw string, rather than a parameterized query, makes for injection vulnerabilities. There are ways to work around it, but often the &#x27;unsafe&#x27; way is a lot easier and more obvious than the safe way.<p>Some of it is due to the early proliferation of beginner code. PHP was <i>the</i> language of the web right when every man and his dog were learning just enough code to make something work, then selling themselves as experts. That resulted in a lot of people writing very hacky spaghetti code, which rapidly became legacy.<p>Some of it is due to the switch from its procedural roots to its object oriented alternative (while maintaining backwards compatibility). This isn&#x27;t really a great thing for a language to do, because it means that people who are less than completely clear as to how to solve problems in both procedural and OO versions of the language often end up writing a confusing mish-mash of code.<p>Most of this should not be a problem for a sensible, well learned and disciplined developer building a new system. (The security thing can still be a thing, but there are ways to handle it now).<p>PHP now has a fantastic culture of building fast, usable systems. Thanks to the big PHP CMSs and frameworks, there&#x27;s also a lot of great interoperability (and extendability) patterns in PHP which don&#x27;t really show up anywhere near as much as in other languages. It&#x27;s extremely easy to deploy, it&#x27;s well documented, and it&#x27;s cheap to run.<p>If you like it, and it meets your requirements, then go for it.
akg_67大约 11 年前
Whom are you providing service? Do your customers care about what language do you use? Will selection of a language make a difference in your customer&#x27;s impression or satisfaction?<p>If not, then ignore what others say! They are are not your target market or stakeholders in your projects. Listening to them will only detract you for your main goals of having customer and having them satisfied.
cafard大约 11 年前
It all depends on what you want to do. If you search HN, you can find a presentation called &quot;Taking PHP Seriously&quot; from one of the guys at Facebook, discussing the enhancements that Facebook has done with a PHP virtual machine, and making the case for PHP as a tool.<p>There are languages I prefer. Perl does a number of things better than PHP, so does Python. But it is possible to write cogent, maintainable PHP, and there can be sound reasons to do so.<p>If you wish to find out why the HN crowd tends to look down on PHP, I&#x27;d suggest that you put some time into experimenting with other languages. But I&#x27;d suggest you put time into learning how to do PHP well first.
yulaow大约 11 年前
In my opinion php is really bad designed, and if you google just &quot;why php is bad designed&quot; you can find a lot of discussions and blog posts about it, very well documented.<p>I can also tell you that there are a lot of really good php framework (laravel, yii, symphony, etc) that allow you to develop mvc sites very easily making php again fun and not a pain in the ass.<p>Personally I would never touch php code that is not in a form of mvc framework (also a personal one).<p>The advantage of other serverside languages like c#, ruby, python, javascript&#x2F;node.js is that they are also widely used for other purposes and not only serverside, so when you learn them you also have the chance to explore other solution in more different areas.<p>Basically any of them is good for what you want to do, just choose one, stick with it for some time and learn it well.
twunde大约 11 年前
An aspect not mentioned yet is that for a long time php and major projects had well known security problems. It also has a poor tooling culture, in part because writing CLI scripts feels awkward.
devb0x大约 11 年前
Just carry on learning it. Then when you get more experience in other languages you&#x27;ll understand its short comings. But youll appreciate it for what it is.
a3voices大约 11 年前
It&#x27;s because a lot of people are pretentious.