News for hackers. Stuff that matters.
Re:PHP Sucks by trebor on Thursday June 16, 2016 @10:21AM (#11916270)
I started freelancing in my area doing Ruby on Rails, and found it far harder to maintain a project. I also found it harder to acquire clients in my area for new RoR development.

More work was available locally with PHP. Clients were more willing to pay. I've done a ton of things in WordPress that shouldn't have been, "to save money". And I've done greenfield development with CodeIgniter, Laravel (v3 and v5), and a customized set of the Symfony components. I've also maintained and improved brownfield projects that were outsourced.

I'm very tired of hearing that PHP sucks. PHP is a good language. And in my opinion, it has fewer ways to sabotage your own project than any language with monkey patching. PHP7 looks really awesome, and the community has been upgrading quickly toward it. PHP has always had best-in-class documentation in my opinion.

More often it's the programmer who sucks, not the language.

Re:PHP Sucks by segmondy on Thursday June 16, 2016 @11:00AM (#11916572)
Give us a break, as a language PHP is a terrible language, and yes I do develop and get paid because of PHP, and I do so for the same exact reason you listed. It pays the bills and does so handsomely too.

I have 20 yrs of programming experience in various languages than I care to count, as much as 20! So I do know my languages. From an academic perspective, PHP blows! But from a practical standpoint, it's a tool. It get's the job done, so long as you know it's quirks, you can avoid them. It's much better now with the OOP support and with PHP7 supporting scalar type and return types declaration. It's going to even make it possible to develop more robust software.

I'm indifferent to hearing about PHP sucking. So people say it as a put down. Perhaps they groovy or scala. I really don't care. It pays and that's all I care about. When I engage in my own personal projects, I never use PHP. PHP's documenation is not bad, but best-in-class? Please! With that said, I agree with your last sentence, in the sense that a good programmer can get more done with a bad language like PHP than a bad programmer can get done with whatever the hell one chooses to consider a good language.

Re:PHP Sucks by vorg on Thursday June 16, 2016 @05:06PM (#11918861)
> Perhaps they groovy or scala

You're using Apache Groovy as a counter-example to PHP blowing? Groovy's the PHP equivalent in the JVM world, the sloppy partner to the more exacting Scala, Clojure, and Kotlin.

Since its first release in late 2003, Groovy's been extended and repurposed so many times it's not really one unified language anymore. The MOP stuff was added for Grails in 2006, the half-baked types when generics were added in v 1.5, the pluggable annotations in v 1.6, the command syntax in v 1.7 to appeal make Gradle builds look nicer, the static typing in 2.0, traits in 2.2, the unsuccessful switch to Android deliverables after that, with backwards incompatibilities between minor versions. And then there's the stuff that silently got dropped, like interceptors and empty try statements.

Groovy's OK for quick'n'dirties scripting Java classes and defining builds, but for actually building systems use a language built from the ground up for that purpose, e.g. Java, Scala, or Kotlin.

Re:PHP Sucks by ams6110 on Thursday June 16, 2016 @11:54AM (#11916949)
Is it any worse than Javascript, if we're honest?
Re:PHP Sucks by pdpi on Thursday June 16, 2016 @12:27PM (#11917150)
Yes it is, and I really don't like JS much to begin with.

There's seriously wonky things in there like the associativity on ?: being wrong, and == being even more broken than in js. There's order of arguments on array_map and array_filter being inconsistent. It's not that there's a massive flaw in there that kills it, it's death by a thousand paper cuts.

Re:PHP Sucks by mywittyname on Thursday June 16, 2016 @01:45PM (#11917678)
PHP's massive flaw is that it does one thing very well (web-dev), but does everything else rather poorly. It becomes the default choice for projects that start out as a web front-end, but then gets used in other situations where it's ill-suited. A lot of PHP projects have components that are hacked together and work, but are confusing and less-than-ideal from a design perspective.

Threading/asynchronicity comes to mind. I've worked on a few projects that started out as a web-front end, but then needed to do some background processing. Eventually the background process needs to be multi-threaded and the choices are: rewrite your code to support pthread's wrappers classes, use fork and shared memory segments, asynchronous web requests. All those solutions work, but they are much more complicated than the same task would be in most other languages with native threading support.

Re:PHP Sucks by qihqi on Thursday June 16, 2016 @01:38PM (#11917632)
PHP is like Javascript in that both languages are now being used to do what they were not designed for.
Re:PHP Sucks by spitcode on Monday June 20, 2016 @07:01PM (#11942292)
In my opinion JavaScript is being used exactly what it was intended for now more than ever. It was originally supposed to be based on Scheme (an elegant functional language) and after many years the trend of functional reactive programming has finally become mainstream.

I find it quite sad that most PHP developers seem to think that writing code that looks more like Java is the "correct" thing when its greatest features have always allowed loose types and first class functions. After all that's what makes it so easy to work with?

Perhaps PHP could have been more like Scala a few years back already.. the perfect combination of Objects and Functions...

Re:PHP Sucks by LoSboccacc on Thursday June 16, 2016 @12:30PM (#11917172)
Javascript ain't that bad, it's interacting with browser exposed api variants that sucks but there are many wrappers to solve that issue.

The real annoying part is that by nature it will never have the same amount of IDE niceties you'd get with more typed languages

Re:PHP Sucks by piva00 on Friday June 17, 2016 @03:14AM (#11921108)
No, JavaScript has a lot of quirks like the '==' vs '===', empty arrays equalling to false or this kind of stuff: http://stackoverflow.com/a/1995298/398142

I understand JS having its place as being ubiquitously supported in browsers but, just as PHP, it's bad and its problems are not about niceties from IDEs or static typing.

Re:PHP Sucks by kahnpro on Thursday June 16, 2016 @01:24PM (#11917538)
I like to call JavaScript "the PHP of the 2010's"
Re:PHP Sucks by segmondy on Thursday June 16, 2016 @07:55PM (#11919848)
No, they are both the same, where else can you evaluate '5' + 2?
Re:PHP Sucks by bduerst on Thursday June 16, 2016 @12:09PM (#11917051)
Both have their issues, but js is probably a little more advanced with prototyping.
Re:PHP Sucks by wtbob on Thursday June 16, 2016 @12:43PM (#11917254)
'Not worse than JavaScript' is a low bar to clear. JavaScript has exactly two advantages: it is deployed everywhere, and it is dynamic. The latter means that with sufficient pain one can accomplish whatever one needs to.

It's not quite bad enough to count as a Turing tarpit like INTERCAL or brainf*ck, but it's one of the closest mainstream languages to the tarpit.

Re:PHP Sucks by nuncanada on Thursday June 16, 2016 @01:35PM (#11917615)
I prefer PHP to Javascript... And PHP does sucks.
Re:PHP Sucks by frik on Thursday June 16, 2016 @03:18PM (#11918237)
PHP is more or less a dynamic typed C++ especially tailored for web development, that's how I see it. PHP originally borrowed a lot from C (syntax and function names) and later borrowed a lot from C++, Java and even JavaScript.

I like PHP and JavaScript a lot. They are not perfect but these organically grown languages tend to be better from my experience.

Re:PHP Sucks by VoidAgent on Thursday June 16, 2016 @06:40PM (#11919470)
WOW... i mean PHP is nothing like C++. It is closer to some sort of dynamically typed C with classes. C++ is not just C with classes it is much much deeper language. That being said, C with classes for web is not bad thing to be.

And yeah I HATE inclusion in PHP... it's a mess

Re:PHP Sucks by vesak on Thursday June 16, 2016 @11:20AM (#11916715)
>I'm very tired of hearing that PHP sucks. PHP is a good language

And I'm quite tired of hearing this silly, totally meritless defense in every single thread that discusses PHP. Can't we just agree that it's not a very good language, but people are still doing cool stuff and lots of money with it? So many pointless fights could be averted like this.

Re:PHP Sucks by novaleaf on Thursday June 16, 2016 @12:07PM (#11917036)
A personal anicdote, but I run a SaaS, and there is an extremely pronounced (negative) difference in the sophistication of technical support queries asked by PHP devs vs those in other languages. This may be because PHP is so ubiquitous and approachable, but these types of silly questions (how do I make a POST call to your API?) are why PHP gets it's reputation.
Re:PHP Sucks by caseysoftware on Thursday June 16, 2016 @12:28PM (#11917156)
Yes, the biggest strength of PHP is that anyone can pick it up quickly... which means anyone will. There are "best practices" but they're not necessary to get the job done.

I usually recommend that new developers start with Python. It teaches structure and consistency without as much variation or room to screw up.

Re:PHP Sucks by reitanqild on Thursday June 16, 2016 @12:52PM (#11917309)
Tell people to code it in Java or C, preferably in vim.

Advantage: they'll never create a mess that you'll have to maintain.

/s

Yes, I totally agree with you: the advantage of PHP is that anyone can pick ut up, and they have done.

The question was often never if it should be coded in PHP or Java but if it should be coded at all and, if so: if it should be an excel file on a file share or sent in email or a php script.

Disclaimer: PHP and Java coder. I can get stuff done quickly in Java, but it takes some practice.

Re:PHP Sucks by trebor on Thursday June 16, 2016 @11:54AM (#11916945)
I'll agree that what makes a good language is subjective, and that most all languages have their problems. There is a certain threshold where "good enough" is what matters.

Personally, I'd rather everyone just stop the good/bad language debates entirely.

Re:PHP Sucks by VeejayRampay on Thursday June 16, 2016 @12:17PM (#11917097)
Programming has to be the only environment where the voices of academia don't seem to matter because "my language gets shit done". Deep inside, what do you think those researchers in the PL community, the people that know the ins and outs, that theorize about languages, the people who spent years and years learning about the theory behind it all, who created the OCamls, the Haskells, the Coqs, the Idrises and so forth, what do you reckon their opinion of PHP is?

So really I don't think "good language" is subjective. PHP is not fast, it's not well-designed, it's not particularly terse, it doesn't have particularly great tooling (Facebook has made that better with their HHVM initiative in all fairness), it isn't consistent and easy to reason about and the worst offender of all, it doesn't offer a dramatically different or original model of thinking about programs.

What is has going for it has nothing to do with the language itself: jobs, ecosystem and easy hosting. I totally agree that a good language is whatever works for you, but in the meantime, "whatever is good enough" is a mindset that doesn't help us strive for something better, which does matter if we're going to collectively spend decades in this line of work.

Re:PHP Sucks by reitanqild on Thursday June 16, 2016 @12:56PM (#11917326)
> Programming has to be the only environment where the voices of academia don't seem to matter because "my language gets shit done".

Wrong, otherwise we would have this discussion in Esperanto.

Sometimes Real Life (TM) experience beats clever design. PHP was first, has iterated, always had a niche and is now better than ever. Not good but good enough to save people a lot of work.

Re:PHP Sucks by Shorel on Thursday June 16, 2016 @12:44PM (#11917262)
Re:PHP Sucks by VeejayRampay on Thursday June 16, 2016 @01:14PM (#11917455)
I don't quite grasp your logic. That comparison only means that PHP is faster than other slow languages. Being faster than slow doesn't mean you're fast.
Re:PHP Sucks by reitanqild on Thursday June 16, 2016 @12:54PM (#11917322)
> it doesn't offer a dramatically different or original model of thinking about programs.

In PHPs niche this should be in the advantages section.

Re:PHP Sucks by snorfonius on Thursday June 16, 2016 @06:22PM (#11919346)
Hi Veejay, I do not know for how long or just how intensely you have been in contact with the "academia" so far, but let me tell you this: however much a certain solution is promoted in academic circles has close to nothing to do with how useful it actually is to general (programming) society. The average academic bases his assumptions of what makes a language "good" or "bad" on 6-12 months of internship at a medium sized company (preferably in a mgmt/assistant position), some tutorials he went through and 5 years of theorizing with a professor who did his last serious programming work back in the 1980s. Granted, this approach sometimes yields exciting innovations that might someday be adopted by real world applications. But this does and will not make Haskell and OCaml appropriate for the other 95% of problems developers have to solve.
Re:PHP Sucks by Glyptodon on Thursday June 16, 2016 @12:34PM (#11917196)
PHP, as a language, particularly since somewhere in the 5.x series, is basically "flawed, but still more than adequate."

The real problem is that so many people who use it are utterly incompetent.

When someone says they work in/with PHP you immediately wonder if they're in the "let's duplicate a 900-line function across dozens of files just to give various pages a different icon" camp, the "I call myself a PHP Developer, but all I really do is Drupal Templates" camp, or in the "using Composer and everything is pretty much like you'd expect it to be in any web app built with Ruby or Python or Node" camp.

Until you know, you fear acknowledging them or associating with them. But you can't really ask them up front. So it's easier to just avoid them.

And I say this as someone who occasionally works in PHP.

Re:PHP Sucks by ransom1538 on Thursday June 16, 2016 @10:53AM (#11916520)
I graduated in 2003. I haven't been able to stop coding php. Why? Because of the amount of work. I know other languages, but the pay for php these days is totally astronomical. (I live in sf, pacific-heights / WELLL over 6 figs / wife doesn't work). Currently I feel like I have a massive technical advantage (I wont share). Right now I work on iphone/android backends - at massive scale, top 10 (PHP is fast). When people say PHP sucks, I actually encourage them. We can't even employ a new graduate these days because they are pre-programmed to like node.js (cool! let's rewrite everything!) and to hate php. So yeah! PHP SUCKS!!!
Re:PHP Sucks by kreeves on Thursday June 16, 2016 @11:04AM (#11916609)
I've mostly tried to fight the anti-PHP movement because I WANT new developers to come on board and create great things. I want new packages to pop-up as soon as some new tool/api/widget becomes available.

I've felt for quite some time that most of the anti-PHP sentiment is an effort of other developers to justify the language they've selected to focus on. "Yeah, I'm doing Javascript and Node.js and yeah it's got it's sharp edges, but at least it's not PHP!"

The problem is, if the negativity continues, the next step is that business WONT want PHP in their ecosystem... And not because it can't get the job done for them, but just because "ew PHP. I heard that was bad."

Re:PHP Sucks by vesak on Thursday June 16, 2016 @11:19AM (#11916711)
>I've felt for quite some time that most of the anti-PHP sentiment is an effort of other developers to justify the language they've selected to focus on.

Would you be surprised if I told you that pro-PHP sentiment looks exactly like that as well?

Re:PHP Sucks by kreeves on Thursday June 16, 2016 @11:48AM (#11916903)
I could see that, to a degree. But I agree with this article that most (if not all) of the "bad" of PHP has been completely papered over through best practices, documentation, fantastic tooling, or removal from the language. So the pro-PHP movement is more of a "guys, we're doing the same thing as you, why can't we all just get along?"

When was the last time we saw a "PHP is Great!" article make it to the front page of HN? Most of the time, PHP developers are on their heels because it seems others are constantly on the offense. I've not figured out what value this constant aggression provides to these developers making the arguments. My only conclusion is that they're just trying to make themselves seem more important. To that note, the pro-PHP camp becomes more of a "non-anti-PHP." :)

Re:PHP Sucks by imtringued on Friday June 17, 2016 @02:05AM (#11920948)
>the "bad" of PHP has been completely papered over through best practices, documentation, fantastic tooling, or removal from the language. I mean sure I could just reimplement a sane standard library from a different language in PHP and then live with the suboptimal syntax or maybe I don't waste my time and just use that language with the better standard library from the get go.
Re:PHP Sucks by ransom1538 on Thursday June 16, 2016 @11:14AM (#11916668)
I disagree. Wanting to get new grads into PHP is bizarre. They would be ostracized. They don't have the technical experience to know WHY it is a good language (CI/unit testing/years of libraries/API support in everything/bla bla). They should be working on things that are new and untested. That is what a twenty something should be working on. Check please?
Re:PHP Sucks by nikdaheratik on Friday June 17, 2016 @02:44AM (#11921038)
I think this criticism is missing the biggest problem most new grads have: how to work well with others.

Version control, documentation, checking their work before committing and sending to QA, documentation, and learning how little they actual know about development on a real timescale >> which language they use. I'd rather start out in a well run IT shop that uses PHP than a quirky single dev small shop (or god-forbid an academic ivory tower of babel) with the most cutting edge startup blessed tool set.

Re:PHP Sucks by Glyptodon on Thursday June 16, 2016 @12:42PM (#11917247)
I started in PHP but moved away from it because everyone always wanted to pay less than a CS grad should/would get using other languages "because PHP programmers are supposed to be cheap." Which meant not only did I get paid less, but that my coworkers frequently had very questionable ideas and no CS fundamentals. "No, you can not secure/maintain a session by base64 encoding a user name and id and putting them in a url" is a conversation that really shouldn't have needed to to take place.
Re:PHP Sucks by tajen on Thursday June 16, 2016 @11:42AM (#11916859)
Any advice on how to build our own technical advantage, apart from studying and applying a lot?
Re:PHP Sucks by pmontra on Thursday June 16, 2016 @11:42AM (#11916852)
What's beautiful and what pays our bills are unrelated.

If I have to do a beauty contest of the programming languages I used a lot, from uglier to most beautiful, I'd sort them like this: PHP, Perl and C (no ++), Java, JavaScript, Ruby.

I didn't use Python a lot and I'm undecided if it should be placed before or after JS. That silly method(self) looks as useless as PHP's silly $this->attribyte. They're just bad designs and other languages knew better. I'm starting to use Elixir and it goes between JS and Ruby so far. Java has its own way to make me feel like wanting to wash my hands at the end of the day (the language and the tooling) but not as much as PHP, even if I agree that PHP7 is somewhat more sane than it used to be. Why didn't they do it at version 2?

And if I have to sort them about what pays more... We could sort them by looking at the salary stats but eventually it's a matter of where we live and which opportunities we have. Any language will earn us money. No hard feelings.

Re:PHP Sucks by qihqi on Thursday June 16, 2016 @01:35PM (#11917614)
Python's method(self) is very useful. It gives the ability to call methods in the same way you use functions, which is what they really are. It allows you do things like map(str.strip, list_of_strings).
Re:PHP Sucks by pmontra on Thursday June 16, 2016 @01:59PM (#11917758)
But why can't the interpreter/compiler implicitly add that argument to each instance method definition? There is no need for the programmer to type it. I understand that self plays also a role in the declaration of class methods but other languages found ways to do without method(self) and still have class methods. Java's static (coming from K&R) or Ruby's def self.method

Anyway, that is the way of Python. A lot of people is happy with that and will never be changed. It's beauty contest matter :-)

Re:PHP Sucks by edavis on Thursday June 16, 2016 @11:23PM (#11920526)
> But why can't the interpreter/compiler implicitly...

"Explicit is better than implicit" -- PEP 20

Python was the first language I ever learned and I just took it for granted that you had to manually specify "self" like that. When I see code with implicit self, it reads strangely to me. Like, "Where does 'this' come from? Oh yeah."

Re:PHP Sucks by pmontra on Friday June 17, 2016 @02:53AM (#11921059)
Or to quote Matz "No language can be perfect for everyone. I tried to make Ruby perfect for me, but maybe it's not perfect for you. The perfect language for Guido van Rossum is probably Python."

My first serious language was C, which is way more lower level than Python. Still Python has something that reminds me of C. Those wierd __xyz__ methods, looking like what we used sometimes in #define; the useless : instead of some { (I know where the : comes from but it should be deprecated or made optional) and that self, which is the pointer to the C struct we were using to implement OOP in C. It's a strange mix of low and high level constructs, not fully OO and definitely not functional. Being at midway on many axis maybe it's the reason why it appeals so many people: it's a little bit familiar to everybody and this is important for the success of a language. Think of Elixir which was designed to look similar to Ruby, even if they have nothing in common.

Re:PHP Sucks by imtringued on Friday June 17, 2016 @02:10AM (#11920963)
In a statically typed language you would have to constantly enter the type of the class as the first parameter.
Re:PHP Sucks by smileysteve on Thursday June 16, 2016 @11:21AM (#11916723)
> More often it's the programmer who sucks, not the language.

In the context, it's also a common occurrence that I can tell when developers came from the php (non framework) world. When I see them move to Rails (or in javascript), I often see an obvious lack of understanding / adaptation of MVC, Single Responsibility, asynchronicity, testing, and variable scoping - I've seen Senior PHP Developers come out with less of these concepts than codeschool graduates.

That's not to say that PHP has this, or that every Rails/JS developer writes tests and understands these things (it still confounds me how companies choose rails and don't implement any tests, despite testing being a core idea)..

Re:PHP Sucks by nine_k on Thursday June 16, 2016 @10:53AM (#11916509)
I suspect that a decent amount of people saw PHP 10 years ago, decided that PHP4 sucked (it did), and do not pay close attention to further PHP development ever since. Newer PHP is a much nicer language than it used to be. Newer frameworks can be reasonable and elegant.

OTOH RoR has its own bunch of problems, and exploits a number of anti-patterns "in the name of simplicity", and Ruby as an ecosystem has its own set of pain points (e.g. deployment).

Re:PHP Sucks by arenaninja on Thursday June 16, 2016 @10:33AM (#11916356)
Currently working on a PHP7 project with Slim 3. I can confirm, it's the bee's knees
Re:PHP Sucks by edem on Thursday June 16, 2016 @11:22AM (#11916734)
Have you ever heard of the Blub paradox? [1]

[1][http://c2.com/cgi/wiki?BlubParadox]

Re:PHP Sucks by gear54rus on Thursday June 16, 2016 @10:59AM (#11916565)
> More often it's the programmer who sucks, not the language.

Catchphrase so ironic I laugh every time I hear it. The language also is written by a programmer, who sucked in PHP's case IMO.

Re:PHP Sucks by krapp on Thursday June 16, 2016 @11:14AM (#11916672)
>The language also is written by a programmer, who sucked in PHP's case IMO.

    Yes, I am a terrible coder, but I am probably still better than you :) 
    
    - Rasmus Lerdorf
Modern PHP is written and maintained by a team of programmers. It hasn't been the language Rasmus wrote (badly, as a hack he never intended anyone else to use) for years.
Re:PHP Sucks by ajsalminen on Thursday June 16, 2016 @12:04PM (#11917013)
I wonder about the origin and context of all these quotes. This one was apparently tweeted by him and the full version is:

    "For all the folks getting excited about my quotes. Here is another - Yes, I am a terrible coder, but I am probably still better than you :)"
That is, unless there is actually a prior instance of him saying it but there could well not be.
Re:PHP Sucks by krapp on Thursday June 16, 2016 @12:52PM (#11917307)
He's right, though. Most people who rant about how terrible PHP is and how incompetent a programmer Rasmus is couldn't come up with anything better themselves.
Re:PHP Sucks by willejs on Thursday June 16, 2016 @10:46AM (#11916450)
| More often it's the programmer who sucks, not the language. Whilst it is possible to write structured, elegant php, its very hard, and thats the languages fault. The barrier to entry to write bad PHP is very low, thats what makes people think it 'sucks', because 90% of PHP codebases do. :(
Re:PHP Sucks by segmondy on Thursday June 16, 2016 @11:06AM (#11916619)
It's not hard to write structured elegant php, that is horseshit. Please look at code for symfony or laravel. Hell, my annoyance with writing good code in PHP is that it ends up looking like Java, which begs the question, why not just do it in java.

https://github.com/symfony/symfony/tree/master/src/Symfony

or you can look at simpler sample codes I wrote for a class in design patterns with php

https://github.com/segmond/phpThingz

Re:PHP Sucks by pstadler on Thursday June 16, 2016 @12:17PM (#11917099)
Symfony is the worst thing that could've happened to PHP. Dependency injection with varying degrees of XML/YAML madness everywhere. It's terribly slow and pretty much unusable w/o several caching layers in front. I can honestly say that I hate this framework with a passion, and the language too. PHP's core and a big part of the community is copying features and methodologies from Java, but they will never get close to its performance, nor its functionalities. I left the ecosystem when PHP 5.1 was around... I left for good.
Re:PHP Sucks by stiGGG on Thursday June 16, 2016 @01:34PM (#11917611)
This! Symfony is so wrong, i actually can't believe it. First version was kind of rails, replacing all that ruby awesomeness with PHP madness. Newer Versions suddenly want to be like Java only 1000times slower.
Re:PHP Sucks by segmondy on Friday June 17, 2016 @11:08AM (#11923056)
I won't say it's the worse thing, it did bring some good and really help drive plenty of new projects towards being OOP. I'm no fan of it either! My point is that the code is structured! Now is the framework architecture good? Whoops, that's another discussion, and I can't likewise stand the layering upon layering of components and configuration nightmare.
Re:PHP Sucks by syzer on Friday June 17, 2016 @05:15AM (#11921509)
I think that Symfony is SpringMVC for poor, and slower, and crappier.
Re:PHP Sucks by willejs on Thursday June 16, 2016 @11:17AM (#11916701)
Your right, its not hard, but it is on the scale of how easy it is to write bad php.
Re:PHP Sucks by trebor on Thursday June 16, 2016 @10:52AM (#11916501)
I disagree. Namespaces help hugely, as do Traits, etc. It used to be difficult back in the pre 5.4 days, but we have come a long way since then.

Older projects will suffer till they're brought up to spec, true.

Re:PHP Sucks by ajmurmann on Thursday June 16, 2016 @11:01AM (#11916577)
I don't think what you say really invalidates his point though. Namespaces and traits might help a lot, but that still doesn't make them used wide spread or introduced them to the overwhelming amount of terrible legacy code bases that have no namespaces and untested functions that are hundreds of lines long. You can write bad code in any language, but PHP used to be a much worse language and many developers got socialized with that. When you are leaning PHP it's easy to pick up bad habits because the code base tut are using is likely full of them. You are likely to look at code examples using old versions of PHP that don't teach you good practices. That of course doesn't mean you can't error awesome code in PHP it just means it's easy to write bad code.
Re:PHP Sucks by adimitrov on Thursday June 16, 2016 @11:06AM (#11916623)
In which ways do Traits of all things help write good, disciplined code bases?

I think traits, and their Java equivalent, are OK to touch up legacy APIs (as they did with the Java collections API) but I have found no good place to stick them in a new project.

Not to say PHP hasn't been introducing functionality for writing good, stable code bases (type hinting in function signatures, namespaces, better garbage collection, an actual AST — as an aside: how ON EARTH did they do without an AST pre-PHP7?) but traits don't strike me as the feature to think of when designing a new code base.

They're not extendable, they're not overridable, they're monolithic, and classes expose their implementation details to them, which makes traits super fragile.

Re:PHP Sucks by ryanlm on Thursday June 16, 2016 @12:32PM (#11917185)
They emitted oplines to the opcode array directly from the parse production.
Re:PHP Sucks by spriggan3 on Thursday June 16, 2016 @10:34AM (#11916360)
> And in my opinion, it has fewer ways to sabotage your own project than any language with monkey patching.

It's not like rails is the only alternative.

Re:PHP Sucks by trebor on Thursday June 16, 2016 @10:48AM (#11916467)
Right, and who's paying me to work with one of those alternatives? No one.

My reference for what you quoted was a Rails project written by a Python dev who thought he needed to make Ruby more like Python. The resulting code was so horrendous that I literally cannot tell which of 2-3 parts that compose one feature (all heavily monkey-patched together) is responsible for what. It's like 2-3 complete implementations, but depending on load order any piece of the 2-3 implementations could be handling it. The client didn't have the time required for me to fix it.

... to quote myself:

> More often it's the programmer who sucks, not the language.

Re:PHP Sucks by spriggan3 on Thursday June 16, 2016 @12:26PM (#11917145)
> Right, and who's paying me to work with one of those alternatives? No one.

Give me a break, it's not like there are only PHP jobs out there. If you can't find anything else then it's because you're not capable of coding something that is outside PHP domain, IE basic CRUD apps ..

Re:PHP Sucks by burnstek on Thursday June 16, 2016 @02:47PM (#11918076)
A lot of software developers are are also business people. They focus and make decisions based on the needs of the organization, given the local job market, current staffing, past investments, the future roadmap of whatever product they are working on, etc. If PHP is the best route, then that's not something a business person is going to spend a lot of time worrying about.

In many ways, if a "coder" comes in and starts wanting to change a bunch of things purely because they are opinionated about languages, then that person is not going to go very far.

Re:PHP Sucks by nikdaheratik on Friday June 17, 2016 @02:27AM (#11921002)
Umm... outside of R&D or the valley, the breakdown is something like:

PHP: 30%; .NET for finance/enterprise: 25%; Java for finance/enterprise: 20%; Java for android: 10%; iOS: 10% (~5% overlap); Everything else: 10%.

And as far as payscales go, PHP is nearly always > the "Everything else" unless it's super specialized. But clearly everyone paying median or above for PHP is getting conned and they should convert their entire business to [flavor of the month] language.

[edit]And I'm leaving js off there on purpose as there are very few web devs who are expected to only work in PHP and never touch the js. And in those other orgs, you usually have a specific "front end" developer that probably doesn't deal with any other kind of code and makes less than the "full stack" devs.

Re:PHP Sucks by spriggan3 on Friday June 17, 2016 @05:53AM (#11921633)
> Umm... outside of R&D or the valley, the breakdown is something like:

citation needed, I don't believe one second these figures are accurate.

Re:PHP Sucks by trebor on Thursday June 16, 2016 @12:43PM (#11917252)
Ad hominem attacks won't get you anywhere.
Re:PHP Sucks by bluedino on Thursday June 16, 2016 @10:38AM (#11916404)
>> More often it's the programmer who sucks, not the language.

Or the client sucks.

Re:PHP Sucks by segmondy on Thursday June 16, 2016 @11:09AM (#11916644)
Nah, the client might not know how to explain what they want, but that's okay. Plenty of people go to the hospital and can't explain what is wrong with them. It's your job as a professional to extract what the client wants, just as it's a doctor's job to perform correct diagnosis and not blame you for poorly explaining your symptoms.
Re:PHP Sucks by pmarreck on Thursday June 16, 2016 @12:03PM (#11917011)
I will say this: I whipped out the backend of a site in 1 night that had most of eBay's functionality... in PHP.

But I quickly moved away from it and I'll explain why.

I think that many programmers are starting to realize that the less "cognitive load" your language demands of you as a programmer, the better (the fewer bugs, etc.) Simple example, the recently-maligned "==" comparison operator has a very complex table of possible outputs (note that Javascript is also implicated here): http://stackoverflow.com/questions/7615214/in-javascript-why...

I mean, as a PHP programmer debugging code that used ==, you'd have to basically have that table memorized in order to successfully debug it. Contrast this with, say, Ruby, where only nil and false evaluate to false and everything else evaluates to true.

While there are of course "PHP best practices" that suggest === (which has a MUCH more sensible truth table), I find that much of the language is still simply not well thought-out and therefore is unsuitable for any large codebase. Sure, you can "get by" (see: Facebook), but you'd "get by" a hell of a lot better in a different (possibly a functional) language.

If you can't grasp all the cognitive load mentally, then you are invariably going to introduce unexpected states into your code (read: "bugs").

Lastly, a language should be 100% deterministic. Last time I checked, PHP didn't even consistently pass its own test suite. It literally has so-called "flagging" and "known-fail" tests which are just marked as such (and not fixed). I cannot explain how bad this is to build something else on top of.

So, yeah. If you're a great programmer, you can code almost anything in PHP (since you can handle the cognitive loads it introduces), just like you could code almost anything in, say, Brainfuck, or assembly. But as a great programmer, you'd be far better served by another high-level language (speaking as someone who knows and has worked with dozens of computer languages) which demands less cognitive load and therefore naturally reduces the number of bugs you will introduce.

I'll also plug John Carmack's piece on functional programming in object-oriented languages, because it's relevant: http://www.gamasutra.com/view/news/169296/Indepth_Functional...

Re:PHP Sucks by pbreit on Thursday June 16, 2016 @12:40PM (#11917237)
"most of eBay's functionality"

Do you realize what a ridiculous statement that is?

Re:PHP Sucks by pmarreck on Thursday June 16, 2016 @12:54PM (#11917318)
No. It's actually not hard. It was for an art reseller in Greenwich, CT, they held an art auction that was simultaneously online and in-the-flesh. I had account registrations, search (with image results), anonymous bidding, outbid notifications (via email), winning-bid notifications. I implemented the whole "what's the highest bid you would accept" functionality (also not hard). I did not write the frontend (a friend did that) and I didn't handle payments nor shipping (winners were expected to go to the physical store). Hence "ALMOST" all of eBay's functionality. :P

Either that, or I'm just a really good programmer under pressure (I pulled an all-nighter for that one), which I would not disagree with, I've basically been coding since I was 12 in 1984, so I would HOPE that I'm somewhat of a force to be reckoned with at this point. ;)

Re:PHP Sucks by Moru on Thursday June 16, 2016 @10:28AM (#11916319)
Amen to the above
Re:PHP Sucks by yedpodtrzitko on Thursday June 16, 2016 @03:48PM (#11918401)
RoR is chronically known for having issues with a maintenance of projects in a long term, so using this comparison is a very weak defense of PHP.
Re:PHP Sucks by kentt on Friday June 17, 2016 @12:23AM (#11920676)
Citation please. Not at all disagreeing with you, I'm just interested.
Re:PHP Sucks by redmaverick on Thursday June 16, 2016 @11:36AM (#11916818)
Which area do you live in? How did you get your first 3 clients?