Hacker News new | past | comments | ask | show | jobs | submit login
Ask HN: I am a PHP Newbie, Why do most developers hate it
5 points by frade33 on Mar 20, 2014 | hide | past | web | favorite | 16 comments
Could you please explain me in the terms that would make sense to me. :) that Why do most people prefer Ruby/Rails or Python over PHP.

I like PHP because it'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 'web applications' because it does not rely on frameworks etc (rails) and can develop web applications at its own.

I want to know in layman terms, why Ruby/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.




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.

If you are working with websites you will naturally learn HTML and CSS, then javascript, then jQuery.

Next you might move to wordpress based websites so PHP and MySQL would be the next things to learn.

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's going on behind the scenes when you move on to a framework. Before developing a web app from scratch it's harder to understand what Rails is doing and why it's valuable.

Once you do this then the next natural progression will be using a framework to create a web application. I recommend giving Rails and/or Laravel (PHP Framework) a try. Even though you will know more PHP than Ruby it's a good experience to see how Rails works and why it's so popular. Laravel is a good PHP framework similar to Rails if you want to stick with PHP.

I wouldn't limit yourself to PHP though. Once you have been creating web applications it should be pretty easy to learn any framework/language. I prefer Rails and Laravel but that's just a personal preference.

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's worth learning especially if you're involved with Wordpress.

Check out TeamTreehouse.com and you'll learn some good programming practices to get you on the right track. If you're just getting started the Oreilly Head First books are really good for learning HTML and CSS and their Head First PHP & MySQL is good as well.

After that you can check out railscast.com and laracast.com.

There is lots of tutorials and information out there for all languages.

Good luck.


@sauuki, Thanks for the in depth reply, and this exactly answers my question.

I am already member of both treehouse and T+ and they are both awesome places to learn quickly and making sure you follow the best practices.


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.

If you follow best practices and use modern frameworks like Laravel, then there should be nothing to complain about PHP.


The problem with PHP is its design, or lack of it to be precise. It's inconsistent and quite verbose. But it's made for the web, so it's very easy to deploy, and the workflow is straightforward, put file in a folder on a server and refresh the page. If you're new to web development but already have some programming experience, PHP is a good language to learn because it's ubiquitous and very easy to get started. If you're new to programming, I'd suggest you learn Python first; it's a beautifully designed general purpose language, and will guide you through the right path before diving into the PHP jungle.


Yes I am very much interested in learning Ruby/RoR and Python too. I had a brief look over the both of them, and my first impression was their syntax is very simple and easy to learn too, compared to the objective C, which literally gave me a heart attack ;)

Perhaps, I have not developed a lengthy web application myself yet, therefore I can not determine the inefficiencies of PHP over RoR or Python. And this was the reason I posted it here, to see, How PHP can be troublesome in complex web applications and how RoR or Python handle them more efficiently.


PHP can handle as well or better than Python and Ruby. The performance difference is not that important when choosing between these languages, because they are all slow anyway. If you compare PHP vs Java or Ruby vs NodeJS, then performance gain might be an important factor when choosing. Python is used more outside of webdev than PHP and Ruby, so that might be something to consider, because there are more libraries for making UIs, games, graphics, etc.


I'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.

PHP developers, in my experience, have their shit together. This is just my OWN personal experience. I would never hire a Python/Ruby guy again, I'm always going for PHP developers now.


Wow. Pretty broad generalization of Python and Ruby developers. Would love to get more details beyond "seemed like hacks".


Yeah, I admit it's a very broad generalization. I suspect it's because PHP developers are probably older developers with a bit more experience. Many python and ruby folks are new, and as a non-technical person, I can't really determine if they're good or not until they start working on a project.


Some of it is due to age. People like shiny, new things. PHP isn't shiny and new any more.

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 'unsafe' way is a lot easier and more obvious than the safe way.

Some of it is due to the early proliferation of beginner code. PHP was the 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.

Some of it is due to the switch from its procedural roots to its object oriented alternative (while maintaining backwards compatibility). This isn'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.

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).

PHP now has a fantastic culture of building fast, usable systems. Thanks to the big PHP CMSs and frameworks, there's also a lot of great interoperability (and extendability) patterns in PHP which don't really show up anywhere near as much as in other languages. It's extremely easy to deploy, it's well documented, and it's cheap to run.

If you like it, and it meets your requirements, then go for it.


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's impression or satisfaction?

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.


It all depends on what you want to do. If you search HN, you can find a presentation called "Taking PHP Seriously" 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.

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.

If you wish to find out why the HN crowd tends to look down on PHP, I'd suggest that you put some time into experimenting with other languages. But I'd suggest you put time into learning how to do PHP well first.


In my opinion php is really bad designed, and if you google just "why php is bad designed" you can find a lot of discussions and blog posts about it, very well documented.

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.

Personally I would never touch php code that is not in a form of mvc framework (also a personal one).

The advantage of other serverside languages like c#, ruby, python, javascript/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.

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.


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.


Just carry on learning it. Then when you get more experience in other languages you'll understand its short comings. But youll appreciate it for what it is.


It's because a lot of people are pretentious.




Applications are open for YC Summer 2019

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: