8 ms·
I recently started learning PHP as my first programming language and I love it so far. But the amount of negativity and hatred I see towards PHP on the internet
by pavs 13y ago
I recently started learning PHP as my first programming language and I love it so far. But the amount of negativity and hatred I see towards PHP on the internet (even among so-called PHP lovers) makes me question my decision of learning PHP.
My main purpose for learning PHP is for web-development. I have looked into java code and I felt like I am going to shit pants if I have to learn that.
2 questions.
- Am I wasting my time with PHP?
- What are some good alternative for web-development that preferably doesn't have a steep learning curve?
- circuiter 13y agoNo, you're not wasting your time.
- jaequery 13y agouse what you love. don't listen to what anyone else says.
- babby 13y ago- nodejs: Write in coffeescript or javascript on the server, two bird with one stone philosophy. Will let you build better programming techniques in respect to structure due to (1) it's async and (2) it's module based. Unlike php the global namespace should not be used. Additionally, JS is just better than PHP in every way I can think of. Node has a thriving user module community. Cons are that you have to deal with async, module dependencies and setting node up on a server (or really anything besides PHP) is far more complex. - GO: google's lang, seems to be trending lately. Lets you build potentially more elegant, higher performance web apps (if you believe the benchmarks) than node but will have a higher learning curve, less of a userbase. - Python: Someone else will have to comment on python (and probably GO). Afaik it's a useful language to use overall.
- Kiro 13y ago> Unlike php the global namespace should not be used What do you mean? What's the "global namespace" in PHP and why do you need to use it?
- venomsnake 13y agophp has the ability to have global keyword in a namespace to use something out of scope. And it is easy to use it ... and you don't want to maintain code written like that.
- thejosh 13y agodepends if you want to do it for a job, and what the local interest is in your choice of language. I learned PHP in 2003, and haven't regretted it since. There are quite a few PHP jobs here, and I like the culture that this language brings - unlike ASP.NET which is very corporate. So yeah, use what makes you happy, PHP is a great start into a lot of other languages as it isn't as intense as others.
- wpietri 13y agoWhether or not you stick with PHP, you should learn some other languages. At the very least, it will make you a much better PHP programmer. But maybe you'll find something you like better. Ruby, Python, and Node are all reasonable next things to try. Large communities, lots of resources, and plenty of example code to look at.
- progx 13y agoI leave PHP last year. The way PHP moves is not my way anymore. After so many years of using, it get boring too. PHP has a problem, the "old stuff" / compatibility, like all older projects have. They change things, but slowly and sometimes inconseqent. I hope the will really renew everything with a new version, even if that mean that they lose many users. In the last years so many new languages and styles were born, you feel really old with PHP ;-) ... that does not mean that the others were better.
- astrodust 13y agoYou're not a "PHP programmer" unless that's the only thing you know, and if that's the case, you're cheating yourself. Be a "programmer". Learn other languages. It makes you a better programmer in general.
- theolll 13y agoI second node.js as a learning tool, learning the one syntax will let you get a feel for both areas of web development.
- hadem 13y agoNo, you are not wasting your time. You will read people complain about PHP but in the end, it provides me with a great job that pays the bills and then some! When used properly, it doesn't have to be a bad language and can be fun. That, and if you are just starting to get into web development, it is a great place to start. You can always branch out into other web technologies down the road. Have fun and keep learning :-)
- eropple 13y ago> When used properly, it doesn't have to be a bad language > That, and if you are just starting to get into web development These two things don't square well, and is a major reason why I discourage PHP. It's pedagogically suboptimal to be encouraging the sorts of behavior that culturally accepted PHP often does. You can write good PHP. After many years I got to the point where I could say confidently that I can. But it took me most of a decade to get to that point of confidence.
- Kiro 13y agoWhat bad things are culturally accepted in PHP?
- richbradshaw 13y agoMost common thing that seems to come out is using string concat for sql queries.
- shakesbeard 13y agoYes, 8 years ago ... PDO and prepared statements is the quasi-standard since the release of PHP 5.1
- Killswitch 13y agoPlease. Stop using sense and UP TO DATE arguments. Everyone who talks negatively about PHP always talks about PHP4... These people are basing their opinions about a language they barely even used a decade ago.. This is annoying.
- sanderjd 13y agoYou definitely aren't wasting your time, but it would be great for you to also learn Python well enough to understand peoples' negativity toward PHP, even (especially?) if you decide you disagree with them.
- ing33k 13y ago- Don't even think that you are wasting your time ! - Ruby/Rails , Python/Django , Node.js
- venomsnake 13y agoYou are not wasting your time with learning PHP, but it also is not a good foundation - the language is a collection of tools that someone somewhere found useful. Employment wise it is a safe bet - there is a lot of legacy code for a person to maintain for a few lifetimes and then more. The hatred towards PHP is explainable - if you use Haskell or Clojure today it is because you chose it. If you use php it is because you were forced to use it. So every little and not so little gotcha in the language (and there are a lot of them) is causing a lot of pain. I have used python/(tornado/gevent)/flask/ stack with success. Disclaimer - PHP programming 4 years, python 1
- valisystem 13y agoLearning is never a waste of time, but would that time being better employed with another technology? I think, definitely, yes. Important point, whether you like php or not, you need to know why. If you like it because you are comfortable with it, make sure to know why. Being comfortable in a dev environment is great when you are learning, but very dangerous in the long run, since learning something new will be much (much) more painful. Also, what is your final goal ? If you just want to learn to build websites, regardless of top notch ways of doing things, just stick with what you are productive and comfortable with. The more reputable tech you use, the better, but it's not the point. If you want to learn websites because it looks like a good way to learn programming in general, don't stay in the comfortable zone, don't fear the steep learning curve, embrace it. Well, it's not masochism either, if it's too painful, just stop. You have been intimidated by Java, but don't let it divert you from all other techs. Django/Python, Ruby on Rails, NodeJS and some others are much more easier to step into, will teach you much more about programming in general.
- jafaku 13y agoPHP is fantastic, it's definitely the best web platform if you want to actually get things done. Having said that, learning a language's syntax is not the same as learning programming (or web development). If you are serious about what you are doing, learn OOP theory, design patterns, the internals of the web (TCP/IP, the HTTP protocol, etc.), security, and a bit of cryptography can't hurt. So you can use PHP while learning all those things, and you will be golden. Ignore all the FUD and hate around it, eg: "php is insecure", "php websites are a mess", "php is for noobs", "php is slow". Using a different language won't fix any of that, learning how to program will. And if you ever decide to switch to a different language within the same paradigm (procedural / OOP / semi functional, eg: ruby/python/javascript/java), it won't take longer than a few days, because you already know how to program, so you only have to learn the syntax.
- dreamfactory 13y agoIf I was starting today, I'd probably go with javascript coupled with node.js and a client-side framework like angular (and possibly ruby+rails), but php+symfony/laravel wouldn't be a bad way to go and should give good job security for the foreseeable.
- UweSchmidt 13y agoMost of the criticism you hear isn't very relevant for a beginner who's learning, and most people having those discussions have forgotten what it is like to be a beginner a long time ago. If you like the "accessibility" of PHP, if you like programming in it, if you like the learning resources you have and you like the forums you've found, then go for it. In due time you'll discover what the criticism about PHP was all about, form your own opinion and might check out other options (and Java won't be scary any more - just different syntax and a few concepts that you'll appreciate better when you have some experience).
- nnq 13y agoYES, you are wasting your time with PHP! (If by "wasting time" you mean that there are other better ways to use your time and learn much more in the same amount of time.) PHP is mostly ok as tool to get shit done with but it is one of the worst possible options for something to learn as a first programming language for many reasons, including: - you will not learn how most real programming languages are, as PHP was not designed or engineered as a programming language, instead it is a collection of tools and commands that mutated and evolved into a programming language - most code you will encounter written in PHP is very bad code (not all, but most), so you will find it very hard to learn from other people's code (this is the main reason to stay away from PHP imho!) - it either lacks or has weird variants of the constructs that permit certain very useful styles of programming: no real closures until 5.3 and the need for the `use (...)` syntax to have them behave like in other languages, it has two namespaces for functions and variables (not other common language has this - yeah, there's Perl and Common Lisp, but...), weird stuff when it comes to namespaces, weird rules and stuff like autoloading, more weird stuff around the OOP features... - so it leads to you learning all sorts of details that are basically untransferable skills - i.e. they won't make you a better programmer in general they will just make you a more effective PHP coder I seriously recommend you to learn Javascript as a first language, as it has all the important constructs needed to learn programming in a sane way and it will also help you on the front-end side. It's just as simple as PHP to learn (I'd say simpler, because it doesn't have all the weird stuff in PHP) and later it will allow you to learn the basic concepts of both OOP and functional programming without much pain. Whereas coming from PHP, lots of concepts will be difficult to learn because "your mind will be twisted the wrong way". Javascript just feels natural for a beginner with no preconceptions: you can just assign a function to a variable and pass it around as a variable to other functions, then slowly learn what objects are by using them as "arrays" at first, then as arrays that have a special "prototype" (and with this, boom, you will have learned the simplest way to implement what in OOP is fancily called "inheritance" and you are in OOP land now). Python is cool too, and it might be easier to find webhosts with python support than with Node (this is for Javascript running on the server, like PHP). Ruby too, but it too has "weird stuff" in it so I wouldn't recommend it as a first language, but it's still a better option than PHP. You can easily learn PHP in the future if your job will require, but don't start with it.
- 13y ago
- exDM69 13y agoI am taking a risk here and going against the popular opinion. Note that this is my opinion, not a hard fact. If you are learning PHP in 2013, yes, you are wasting your time. PHP's killer feature was (not any more) $5 web hosting, where you could upload your index.php with FTP and you're done with deployment. This is no longer the case. PHP stands for (at least used to) "Php is a Html Preprocessor", but at some point it turned into a general purpose programming language, largely as an afterthought. Yes, you can learn web programming using PHP and that skill won't be wasted. But a lot of the PHP specific issues you'll be dealing with is just going to be a waste of time. There is a lot of WTF issues in PHP that you'll inevitably stumble into. This will be a major factor in the time wasted. In addition, the world is full of bad PHP code. Yes, there is good PHP code too but the proportion of bad code is probably larger than in other languages. This will mislead you and make you learn bad practices more than you would perhaps do if you'd be learning another language. These are cultural, not technical issues. For a beginner, I would recommend Python or JavaScript. Neither of them is my favorite language, but Python is rather beginner friendly and JavaScript has a special role since it's the language that web browsers use. Ruby is popular too, but in my opinion it has more traps a beginner could stumble into (not so much for an experienced programmer). For learning purposes (not production code), I would perhaps even recommend staying out of big monolithic frameworks like Django and Rails and learn how things work internally. You'll get a better idea from HTTP and other web technologies if you build your own "framework" from building blocks like WSGI, SQL alchemy and a templating engine like Mako or Mustache (these are Python-specific, for another language, you'd pick other tools). This is my recommendation for a beginner looking into web programming and my motivation is to keep a beginner away from bad technologies that may teach bad practices.
- hash9 13y agoSo brave. Trust me, on hackernews you are not going against the popular opinion. Actually you'd be hard pressed to find any decent programmer community in 2013 that advocates PHP for beginners.
- Killswitch 13y agoOf course there are. There's many. You just gotta get out of the elitest groups.
- troels 13y agoSome people pour way too much emotions into the choice of programming languages. PHP is fine and no matter which language you start out with, switching to a new one later isn't a big deal - They are pretty much the same underneath the syntactic layer anyway.
- ulisesrmzroche 13y agoPHP internals are actually very different from Javascript internals, but the same could be said for a lot of languages. Point stands though, no language is the same as another and habits die hard.
- wpietri 13y agoWow, I strongly disagree with that. Different languages have different libraries, different communities, different philosophies, different purposes. Sure, a person who started in C can go and write C-ish code in many other languages. But that's bad code. Good code is idiomatic and takes advantage of the strengths of the language and platform it's written for.
- troels 13y agoDepends on your perspective, I guess. The difference between not knowing how to program and learning, say, ruby is a fair bit larger than the difference between knowing how to program in php and learning ruby. Take php and ruby (two languages I happen to have used a fair bit both). If you're writing your typical web app, you'd probably use mysql for a database. That's the same. You talk http to the client - same. You want to parse xml? Probably going to use libxml underneath the covers. And so on. So yes, there's different libraries for the two, but there's also a lot that is shared. As for different philosophies, they are both pretty much imperative languages. Php has a simpler object model than ruby and ruby has some fp features, such as co-routines, but by and large you write programs in the same style. And different purposes? I'll dispute that. You pretty much use both languages for more or less the same things. Mind you - I'm not saying they are exactly the same. Clearly they're not. But I'm saying the difference is in the nuances. And while I do agree that ruby is a nicer language than php, I think the trend of treating it as if it was toxic is completely out of proportions.
- wr0ng 13y agoThere's always lots of PHP hating going on from language snobs, mostly from people with toy projects in the latest language du jour (was Ruby, then Node, Scala, now Clojure and Go). Fact is PHP, for all its faults, still runs far more websites than all of those others combined and then some (http://w3techs.com/technologies/overview/programming_language/all http://w3techs.com/technologies/overview/programming_languag... - eg PHP 80%, Ruby 0.5%, Python 0.2%)
- canadiancreed 13y agoThe "it's popular, hence it's great" argument isn't a good one to use to evangelize though, at least not by itself. Case in point, what operating system is still the most popular by far? Popular doesn't always equate to best.
- wr0ng 13y agoYou're right, but it's a strawman argument as I never said that. "it's incredibly well used, but it has faults" is nearer the mark.