To be fair there is no perfect language ,especially in dynamic/weakly typed ones. PHP "grew organically", was successful because at the time it came , it was easy enough for hobbyists and non programmers.
It's still the cheapest way to develop web apps and for those who like java patterns they can still upgrade to these because of its class system.
While I wish Ruby or Python would be more popular, they are not as easy to use as PHP(while ironicaly it is easier to go further faster with rails for instance than bare bone PHP),they are not as cheap to deploy too.
There is a natural progression between learning HTML and then adding some server-side behavior , that wasn't met by other solutions (while java has JSP, forced OO makes it too complicated for beginners)
Nevertheless, PHP has excellent libraries , extensions that even some "hotter" languages do not have , I think when people start projects they don't just look at the language but also the ecosystem.
> they are not as easy to use as PHP(while ironically it is easier to go further faster with rails for instance than bare bone PHP)
PHP's frameworks (Laravel, Yii, etc), being based on previous frameworks, are more mature and frankly just better than Rails in most ways, though less integrated with the stack. Which also provides more choice and 'competition' in the PHP ecosystem.
To be generous; starting with plain PHP would be like starting with Ruby, not Rails.
The relation with Rails illustrates how lively the PHP community is. Rails was one big step ahead, PHP copied Rails in a hundred different ways, iterated through that for 3 generations of frameworks and is now well ahead of the simplistic RoR ecosystem.
Ruby is still a better language, but that really doesn't matter unless you project involves writing stuff from scratch.
Agreed on Ruby, and great point about Rails being the one to break new ground in frameworks. I experimented with switching from Laravel to Rails recently, but I was too late to see it as innovative. Like how classic art comes to be cliche by virtue of being the root of its genre.
Try Facebook's Hack if you want all the nice stuff of PHP and modern language features.
PHP still beats the pants out of just about any other language out there in the ease of use department if you want to build websites and is fairly simple to learn. Once people pick up PHP, then they usually start exploring other languages that are more involved and strict.
All this PHP hate is really discouraging to beginners.
>PHP still beats the pants out of just about any other language out there in the ease of use department..
This is not true. Why is it easier than, say, Ruby
>Once people pick up PHP, then they usually start exploring other languages..
But since they are already brainwashed from PHP use, it prevents them from seeing the value of doing thing the proper way, and might see the process as contrived. This is the most dangerous aspect of using PHP. It blocks your learning and understanding. It pulls you down and keep it there.
A good example is the use of PHP arrays. It is a combination of different data structures like list, dictionaries, sets etc. But because it is a combination, you wont be able to use it as a list, or a dictionary or as a set to the fullest extent. And you will be so used to using this for every situation that you might be put off by lack of similar data structures in other languages, and blocks you from seeing the value of using the right one for a particular situation.
So I request every one who is passionate about programming and wants a career in programming to keep away from the php language and community as much as possible.
> But since they are already brainwashed from PHP use, it prevents them from seeing the value of doing thing the proper way, and might see the process as contrived. This is the most dangerous aspect of using PHP. It blocks your learning and understanding. It pulls you down and keep it there.
After 10 years of writing PHP I took a look at Python. I was confused for about 10 minutes, until I read about lists and dictionaries and saw they were different things.
Who are these people who are just trying to write other languages without looking at the "getting started with data structures" page in the guide, or reading a single book?
And why is learning something flexible and easy before learning something more advanced a problem?
> So I request every one who is passionate about programming and wants a career in programming to keep away from the php language and community as much as possible.
I was writing PHP for a living for a decade. I did a bit of Ruby along the way because it's all the same and who cares. I was then invited to CTO at a tech startup in NY, giving me a visa and moving me from the UK.
I replaced their shittily built Rails API with a PHP one which was 3x faster, did 10x more and was actually tested properly. Very handy.
Now I work for another company, Ride.com. We're building an API in Rails and it feels just like the one I built in PHP using Laravel. Almost identical.
This comapny got me a visa known as "The Alien of Extraordinary Ability" in which my PHP code was used as the basis of my skills.
All of this leads me to think: What the fuck are you talking about.
1. Languages rarely matter.
2. PHP is just fine.
3. PHP will not fuck up your career.
4. PHP will not ruin your ability to learn new languages.
5. You are an actual idiot.
Stop preaching ignorance and get on with writing software.
"So I request every one who is passionate about programming and wants a career in programming to keep away from the php language and community as much as possible." <-- keep away from php and focus on (which language)??
"And you will be so used to using this for every situation that you might be put off by lack of similar data structures in other languages" <-- http://php.net/manual/en/spl.datastructures.php
"and blocks you from seeing the value of using the right one for a particular situation." <-- technically, i do think that the average coder who works in javascript/php/ruby/php/(insert other script languages here) fails in using the proper datastructure for the problem
The above code shows php silently converting numeric string keys into integer keys. This ends up breaking the concept of a dictionary and prevents it to be used as a proper dictionary.
Also, These are the following are the functions that are supposed to be used when you want to use an array as a set.
array_diff_assoc
array_diff_key
array_diff_uassoc
array_diff_ukey
array_diff
array_intersect_assoc
array_intersect_key
array_intersect_uassoc
array_intersect_ukey
array_intersect
Consider the fact that arrays can have mixed numeric and string keys, and consider the fact that php converts numeric string keys into integer keys, and consider php weak comparison rules (2=='2'), and how do you feel about using the above functions for set operations?
You see, the php philosophy is to compensate a lack of depth with a whole lot of breadth. Instead of demanding the user to understand different data structures in depth, it provides one data structure that requires very little understanding to get started, and cover the drawbacks of with a number of functions, edge case rules, and undocumented weird behaviors (resulting from different combinations of documented, but unintuitive behaviors).
So the end result is you got away with only having to learn one simple data structure. But if you want to use it reliably, with the provided library functions, you need to keep an encyclopedic knowledge of the aforementioned edge cases gotchas. This is true with a lot of aspects of PHP. PHP is like a cheap-shitty-dangerous car that you can acquire with very little down payment on a loan with a huge interest.
>Javascript work similarly with one combined array/dict type.
Javascript have combined array/dict? How come?
>Also the PHP SPL exists..
It does not matter, People starting with php won't be aware of these pitfalls to go looking into SPL objects.
Ha! Arrays in JS are just objects disguised as arrays, with a fancy prototype and some syntax sugar: no more, no less. There are no _real_ arrays in JS (in the traditional sense).
Keys in JS arrays are _strings_, weird as it is, because arrays are just objects, and objects use strings as keys. Try this yourself:
Numbers are coerced into strings, and not the other way around! (Note that I said 'number' on purpose, since integers are available but rarely used on the web, for BC. So it's usually floats coerced into strings every time you do ['a'][0]).
This weird coertions are not much unlike PHP's, which turns anything you give it as a key into a hash, internally. Though PHP arrays are far more complex, and even weirder (like how are they're not passed as a reference or as copy, but kinda both).
On the face of it you're technically correct, and i've been bitten by numeric string key coercion in the past. But another way of thinking about it is that PHP's combined array/dict implementation is a perfectly valid set/dict, just over a subset of values where 2 and "2" are not really distinct. And clearly this was intentional given all the other parts of the language that treat types weakly.
> This is not true. Why is it easier than, say, Ruby
I can set up hosting for a PHP website without thinking. With Ruby, unless something has changed in the last 6 months (I sure hope it has) it takes me a lot more effort.
Ease of use is the entire ecosystem, not just writing programs in it.
Ruby is just "gem install rails", but IMO this discussion is misguided: initial setup time doesn't make much difference in the long run. If we're talking "how easy can a user get started", JavaScript wins by far. But that doesn't mean I'd recommend people using it.
I disagree with you - "gem install rails" is setting up Rails, but not what I was talking about: hosting the result.
I wonder if PaaS providers like Heroku would have taken off so quickly if Rails apps had been easy to set up the hosting for? It would explain their popularity outside the PHP community.
"Ease of use" often leads to "impossible to maintain". Strictness is one of the best features of any language in the long term, and it rarely results in much more thinking or typing. If you don't know what type you want something to be, you're not designing your code right. Why not let the compiler know while you're at it?
The opposite is also true.I've seen my share of unmaintainable code in Java. The fact that a large number of PHP users aren't developpers but just want to add some code here and there explains why a lot of PHP code is ugly.But if PHP didn't exist and the same people were forced to use java you'd see a lot of horrible JSP code instead ...
Let me rephrase my comment in a more controversial way, but something I absolutely believe from 16 years of experience.
It is impossible to write maintainable code in a dynamic + weakly typed language. Instead, you have to rely on your IDE and unit tests to catch bugs.
That leads to a huge amount of extra surface area: assertions, type checking, error-throwing, etc. In many projects, unit tests become technical debt and no one ever has time to write them! Then you're really screwed.
Within my first 4 years of professional programming I'd already proved you wrong on pretty much all of your points. I'd maintained and extended a large application, written in PHP and Javascript, without the aid of an IDE or unit tests.
That doesn't mean you did it safely or efficiently. Most of the other people on here would be horrified that you didn't have any unit tests. In fact, if you had any sensitive user data in your database, you were doing something absolutely irresponsible.
A few months ago, I drove in NYC on a major, two-way road that had been repaved, but it didn't have white or yellow lines on it yet.
People were driving as fast as usual, and I didn't get into an accident. However, I (and the other drivers) were much less safe because we didn't have those lines.
What you're talking about is driving without the lines and without a seatbelt.
Based on your attitude, my guess is that your first 4 years of professional programming didn't end that long ago. That's fine, and you can believe you're super smart and doing everything right (like I did), but you're going to find out that unit tests are an industry standard for a reason.
Based on the fact that you've never met me, or seen a line of my code, I don't really give a toss.
You are the one who asserted that users of dynamically/weakly typed languages require unit tests, implying that users of staticly/strongly typed languages don't.
Of course some languages are safer than others, more expressive than others, faster than others, or whatever. You asserted that software written in dynamically typed languages is unmaintainable, an assertion that I strongly dispute.
You can write terrible code in any language. The problem is that code in dynamic languages, especially combined with weak typing and no tests, is tremendously harder to refactor without introducing regressions.
"and as long as the rotten core remains" <-- care to explain more on this ?? And while you are explaining that i would like to remind you that there are no perfect languages out there..