DEV Community

Discussion on: Pitch me on PHP

Collapse
 
dhravya profile image
Dhravya

lollllll is it not consistent? I'm not familiar with PHP, only ever wrote a few lines, I've heard that it's a "really bad language" (especially on tech youtube) and that i should stay away

Collapse
 
datmt profile image
Mạnh Đạt

Making decisions based on the opinions of so-called "expert" is risky

Thread Thread
 
simeg profile image
Simon Egersand 🎈 • Edited

Totally agree! See my response above. It was a joke. I'm not a PHP export by any means so don't listen to me. It was many years since I last used it :)

Collapse
 
joelbonetr profile image
JoelBonetR 🥇

People say the same about almost any language.

You can think on it as Python example, it was released in 1991 yet it was considered garbage by many people, something that you know it exists but don't even consider using.

Two decades after it became one of the top languages to consider.

Trends are trends and community hype is present as well, check your sources, search for information, try it yourself and take your own conclusions.

Remember that is better to say "I don't like Java because it's verbose" than saying "Java is a shit"

Thread Thread
 
dhravya profile image
Dhravya

Yep, I agree. I think I heard a saying on the lines of "If a language isn't hated, it's bad"

Collapse
 
arpple profile image
Arpple

example from built-in function of core php
array_map receive callback first, array second
array_reduce receive array first, callback second

there are quite a number of this kind of inconsistency around

Thread Thread
 
ltsochevdev profile image
Sk1ppeR

Well you just lack experience if this is your biggest pet peeve. I agree, it's not a perfect system, but if you only pass an array to array filter it will filter out falsey values without you having to specify a callback. There's benefit in that

Thread Thread
 
arpple profile image
Arpple

this is not the biggest but it's the context of what I replied to.
and if array_filter have benefit of using array first, why not all other functions do the same?

Thread Thread
 
ltsochevdev profile image
Sk1ppeR

Either way, if you are coding in anything other than Notepad, your IDE will most likely help you with the argument order so in that regard, it really is a moot point. Most frameworks have all of this abstracted already. They also abstract strings. I don't see it being much different than Java world. Nobody codes in plain Java nowadays. Everybody simply learns the spring framework and "the spring way of doing things" and that is it.

Collapse
 
wesen profile image
Manuel Odendahl

Don't take people's opinions on programming topics too seriously, form your own opinion. Not that you should look into PHP, but if you don't understand the reason why someone thinks a technology is bad, it often means the person stating that actually doesn't know either.

Thread Thread
 
simeg profile image
Simon Egersand 🎈

+100. Don't listen to me :D I made a joke. PHP is (was?) known for having inconsistent API but I am not an PHP expert by any means.

Thread Thread
 
pinotattari profile image
Riccardo Bernardini

I have some experience with PHP, although I wouldn't call myself an "expert." However, the inconsistency of the API is the first thing I noticed. Ruby has been designed with the principle of "minimal surprise," PHP seems designed to maximize the surprise.

Fortunately, there is a nice manual online, without that programming in PHP would be a nightmare.

Thread Thread
 
wesen profile image
Manuel Odendahl

There's also some good replacements, for example the laravel helpers. I very rarely use the standard library.

Thread Thread
 
jacekandrzejewski profile image
Jacek Andrzejewski • Edited

It does have inconsistent api for functions, however the reason is that function names are same as underlying libraries function names.
So there is strpos and str_replace (str meaning string), but they differ in naming because strpos is from one library and str_replace from other.
That is the short explanation at least.

Collapse
 
abhinav1217 profile image
Abhinav Kulshreshtha

@dhravya Don't trust simply on the basis on what you hear, There is a lot of hate going around for php, but there is a reason It is still going so strong. Also These hate comes from old php (php <=5). The php that you would learn today is completely different language, not just an incremental upgrade. From personal experience, PHP-8 is almost as good of experience as Java J2EE for large scale Application ( now known as Jakarta EE, not to be confused by similarly named Apache Jakarta).

About language inconsistencies, it will make sense when you learn that it was borrowed from underlying system (c or perl depending on module. ). And regarding the community inconsistencies like different framework had different coding guidelines ( mostly for those which existed before PSR), That is true for almost any language (except for Java, Those guys created strict coding guidelines from the day 1). ANSI-C is quite different Turbo-C, Comodor basic was quite different than atari-basic even though they are both based on MS Q-basic. Now, almost all frameworks are getting streamlined in coding guidelines by adopting PSR at some level.

I highly recommend you to watch 25 years of PHP from its creator Rasmus Lerdorf, During lunch on some weekend, as a casual watch recommendation.
Those who say "It's a really bad language" has never learned php properly enough. Sometimes not all book should be judge by its cover alone. PHP as a language might feel weird at first, But it is a very practical language. Going through the underlying c code, is also an awesome experience, you will learn a lot of micro-optimization tricks which can be translated into any language you work with.