Live data from Hacker News

25 Years of PHP

jetbrains.com

401–410 of 426 posts

Re: 25 Years of PHP

#401

Earlier quoted context omitted.

While I agree that PHP does have pros as well as cons, I find it disconcerting that I've read MANY assertions here on HN, that PHP detractors just haven't used it very much or are mostly complaining about things like bad standard library function names. I've used PHP in earnest. It and JavaScript are tied for worst programming languages I've used. JavaScript gets more of a "pass" from me because I'm just not a dynami…

No sir PHP is nothing like java ! PHP while not perfect gets out of your way and lets you code. Sure it's not perfect but start with one file and one tag , upload to server and you have have something. Java: the amount of files and java-knowledge and xml files crap one has to go through... No thanks.. PHP might not be perfect ! But it's NOTHING like java.

Java has gotten much better on the xml front.

A lot of the tooling can abstract you from the brunt of it.

Have you ever played around with Kotlin?

Never say never my friend, as someone who has used PHP in the past I prefer Java by far. The streams concept/interface they have in Java is really cool.

Re: 25 Years of PHP

#402
I taught myself PHP back in 2007 as it was the only language which had a single click installer (WAMP) & easy tutorial to learn (w3schools) to get started with programming. Since then I wrote a lot of PHP, initially for myself then professionally once I got a good handle on it, until 2012.

Now I'm again thinking of picking up PHP for my side projects because of Laravel.

Re: 25 Years of PHP

#403

Earlier quoted context omitted.

I'm firmly in the Lisp crowd. I loved to hate PHP until I was forced to dig into it to help a friend set up a Wordpress site. And now I don't hate it any more. It does the job it was designed to do in a reasonably non-horrible way. I don't think I'd ever try to build a Facebook-scale app with it ;-), but as the BASIC of web site creation, it doesn't completely suck.

facebook was built and grew in php tho

And then decided to ditch it for its own version: Hack!

Re: 25 Years of PHP

#404
post #379

Earlier quoted context omitted.

I consider Perl to be a “write-only” language. Damn good text processor, though. I wrote an entire CMS in Perl, back in the late 90s. I still wake up, screaming... Swift isn’t any worse than most modern languages, when it comes to text processing, but that’s not what I use it for. In fact, it has some very powerful string handling, built-in, but it’s kind of weird, if you are used to more traditional languages.

I never got the "write-only" criticism. If you understand a language thoroughly code is always readable. What's with the insane double param naming? And why do I have to escape and opening paren? No other language requires this.

It’s designed to allow functions to have “two faces.” One face is the one presented to the caller, and the other to the function, itself.

The idea is to maximize grokability. The function’s purpose and argument list is clear to the caller.

It’s an attempt at that old “philosophers’ stone” of “self-documentation.”

Almost all the code I encounter has little to no method interface documentation. This is supposed to address that.

My experience is that many people circumvent it by using the “wildcard” (_).

I use it to add “in” prefixes to my parameters, like so:

func churn(butter inButter: String) {...}

The “in” prefix means nothing, outside the function context, but is an indicator that it is a function parameter, inside the function.

However, outside the function, the parameter name makes it clear that what is to be churned, is butter, as this is the published signature:

func churn(butter: String)

It also allows us to use parameters that are published with the names of class properties, without name collisions.

For example:

init(butter inButter: String) { butter = inButter }

Where using just “butter” would mean we need to do this:

init(butter: String) { self.butter = butter }

Small stuff, but Swift has a lot of these types of considerations.

But what is really cool about function parameters, is that we can “skip” optional parameters, like so:

func add(numberOne inFirst: Int = 0, numberTwo inSecond: Int = 0, numberThree inThird: Int = 0, to inTarget: Int) { return inFirst + inSecond + inThird + inTarget }

We can call it like so:

let result = add(numberThree: 4, to: 5)

I write about that sort of thing, here: https://littlegreenviper.com/miscellany/swiftwater/swift_fun...

It’s an enormously flexible language, and can be used to write almost inscrutable code, if we choose.

However, it can also be used to write extremely readable code.

I think it’s a sisyphean exercise, trying to get programmers to write readable code, but we keep trying.

Like I said, Swift is a bit like C, where it can be used to write obfuscated junk, if the programmers want.

My experience is that “idiomatic Swift,” as prescribed by many authorities, is starting to look like that.

I’m not exactly sure what you mean by “escape an opening paren.”

Do you mean inside of strings? That’s a direct inline shorthand that is similar to `...` in other languages. Totally optional.

For example: print(“There are \(numberOfSheep) sheep.”) is direct, as opposed to print(“There are “ + numberOfSheep + “ sheep.”), or print(“There are “, numberOfSheep, “ sheep”).

Re: 25 Years of PHP

#405

I've written many languages (starting with ML –Machine Language). I'm currently developing in Swift, and loving it. I wrote PHP for about 20 of its 25 years. I never really got to love the language, but got fairly good with it. I don't miss it much. I have used it to write some industrial-scale systems, though. It's a perfectly good language, and is still under active development and improvement; with a vast user bas…

I enjoyed working with Swift, and I did enjoy working on Objective-C as well back when; my main gripe with Swift is that it's still a niche language for niche applications, unfortunately, and only really practical in a Mac environment. XCode is great though, I miss working with it. I miss the browser-like swipe-to-go-back operation. I did set up a theme similar to Midnight in IntelliJ though.

Yes, but it is the prescribed language for native applications (like C#). Java is really becoming a “niche” language for Android development (until it is replaced with something like Go or Dart). We are seeing less and less of it for server code, as Python and JS take over.

C++ is becoming “niche” for engine code. I’m glad it’s no longer really used for UI.

There’s a lot of specialized languages popping out of the woodwork, these days. I once worked with an image processing language called Halide, which I found to be quite painful (it’s basically an FP language with the good parts removed), but an interesting idea. Totally niche.

https://halide-lang.org/

Re: 25 Years of PHP

#407

Earlier quoted context omitted.

> Why are you building arrays with mixed key types? It happens on accident. All keys are converted to ints if they can be. So if you read a file that is called "123", it'll suddenly become an int key whereas all the rest will be strings. That's absolutely insane. > Why do you want type hints? The same reason anybody does. It is a contract and it makes your code more well-documented, more robust, and more correct. The…

“I liken starting one’s computing career with Unix, say as an undergraduate, to being born in East Africa. It is intolerably hot, your body is covered with lice and flies, you are malnourished and you suffer from numerous curable diseases. But, as far as young East Africans can tell, this is simply the natural condition and they live within it. By the time they find out differently, it is too late. They already think…

Not related to the discussion but as an East African and Ugandan( East Africa has five countries). I find this quote extremely offensive. I kindly request you to stop perpetuating such ignorant and degrading narratives even for the sake of comparison.

Re: 25 Years of PHP

#408
post #39

Earlier quoted context omitted.

> But neither the choice of language nor the lack of framework are to blame. This is partly true. It is possible to make something great with substandard tools. I suspect a master craftsman with a set of dull saws and blunt chisels using his shoe for a hammer will still have the skill to create something pretty good. But it will be frustrating, and most people aren't master craftsmen so what they will produce will be…

If PHP is a rusty saw, what isn't? There are hundreds maybe thousands of languages. And when you measure all things (expressiveness, stdlib, productivity, ability to build a team, etc.) PHP would come up in TOP10 for any webapp. Of course, it has its gotchas. So does Clojure, Ruby, Python, C#, etc. Honestly, once a person knows PHP very well, switching a language has almost no impact besides their "feeling". I have s…

> If PHP is a rusty saw, what isn't? There are hundreds maybe thousands of languages.

I was curious, there's about 9000 according to a cursory google search.

> And when you measure all things (expressiveness, stdlib, productivity, ability to build a team, etc.) PHP would come up in TOP10 for any webapp. > > Of course, it has its gotchas. So does Clojure, Ruby, Python, C#, etc. Honestly, once a person knows PHP very well, switching a language has almost no impact besides their "feeling".

Maybe PHP is in the top 10 for some of the things you mentioned, and you can definitely build a PHP team pretty easily, however:

Productivity:

I am sure that most people can get their PHP programs to a state where they at least seem to do what they want, the problem with PHP is the sheer number of gotchas and edge cases. Here's some I put together for another commenter: https://gist.github.com/wjessop/0923e0667d7dd53ae0503459894e.... It took me minutes to find these, there are many many more.

Sure, you might be able to get your e-commerce site off the ground really fast in PHP, but are you doing the job that you should be doing? Did you remember to check for every single edge case? Are you coding security flaws into your app? How sure are you that you didn't miss an edge case and you're tallying your basket wrong in some circumstances?

Unless you are very very good at PHP then you are going to miss this stuff and it's going to come back and bite you in the ass. There has even been a study into how bug-prone different languages are: https://www.i-programmer.info/news/98-languages/11184-which-...

A key phrase:

"The languages with the strongest positive coefficients - meaning associated with a greater number of defect fixes are C++, C, and Objective-C, also PHP and Python. On the other hand, Clojure, Haskell, Ruby and Scala all have significant negative coefficients implying that these languages are less likely than average to result in defect fixing commits."

All languages have flaws, but PHP has way more than most.

Building a team:

Most PHP developers are likely very average PHP programmers, just like most Ruby developers are likely very average Ruby developers. You would need to be a super-human to be able to program PHP correctly taking into account all the edge cases, and so yes, building a team is easy, but if you want to build a team that build software that isn't a liability, then you need to hire the absolute best PHP programmers, and that's going to be very hard.

So is it easy to build a PHP team? It depends.

Re: 25 Years of PHP

#409
post #52

Earlier quoted context omitted.

some of the function names make me want to stab people What would be an example? My only real gripe with PHP is the annotation syntax What do you mean? Afaik there is no "annotation syntax" in PHP. Could it be that you confuse what certain frameworks and IDEs do with PHP, the language?

Function names are rather inconsistent. get: gettype get_class str: str_ireplace str_pad str_repeat str_replace str_shuffle str_split str_word_count strcasecmp strchr strcmp strcoll strcspn encode: base64_encode quoted_printable_encode session_encode rawurlencode urlencode gzencode php: php_uname php_sapi_name php_logo_guid phpinfo phpcredits phpversion htmlentites: htmlentities html_entity_decode to: stream_copy_to_…

Not to mention array_reverse (or is it reverse_array, I forget) which returns a new array leaving the original intact, whereas the sort functions return 1 and operate on the original array in place.

Also, why is it array_reverse, but rsort? I dunno.

Re: 25 Years of PHP

#410
post #296

Earlier quoted context omitted.

>This strikes me as a strawman. PHP spent years being a generally loathed language for reasons that at this point aren't really worth reiterating. This story is called "25 years of PHP" and the parent starts their comment with "I wrote a lot of PHP from 1999-2008". In this context I think it's fair to remind people of the many... controversial choices the PHP developers have made (or, maybe more accurately, stumbled…

Really, though, who denies the language has a very bad reputation? A lot of these decisions were questionable, but explainable, like mysql_real_escape_string coming from the MySQL C code itself.[1] that doesn't excuse it, but it explains it. [1] https://dev.mysql.com/doc/refman/8.0/en/mysql-real-escape-st...

My point is that it's not an undeserved reputation, there were many real problems. That's what was being challenged.

And the idea that it was reasonable to ship paper thin wrappers around a C API in a high level scripting language is one of the many problems that used to plague PHP. You could even get it to segfault with certain APIs because they would basically just call C completely unchecked. You also have functions having "out parameters" because the underlying C function does, even though PHP has multiple ways to return multiple values. I could also point out how basically every PHP subsystem had its own set of functions for error handling instead of having any kind of unified error system.

MySQL itself having made very questionable choices around the same era (and PHP and MySQL walking hand in hand) definitely doesn't help either, I grant you that.

Post reply on HN