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.
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.
"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
Can you elaborate on this? Any specific examples?
Lua and Javascript work similarly with one combined array/dict type.
Also the PHP SPL exists, providing some other container objects like heaps and some traversal algorithms, analogous to the C++ STL.
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.
Now if you want to use it as a set. This wont work http://3v4l.org/NZYsj
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:
for (var x in ['a']) console.log(x, typeof(x));
Specification may (or may not) clear things up:http://www.ecma-international.org/ecma-262/5.1/#sec-15.4
Also you can try this out:
['a'][0] // = 'a'
['a']['0'] // = 'a'
['a']['00'] // = undefined
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).
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.
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.
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.
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.
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.
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.