Live data from Hacker News

A look at modern PHP

lwn.net

491–500 of 610 posts

Re: A look at modern PHP

#491
post #473

Earlier quoted context omitted.

I do functional programming in C# and used to do it in Java at university. C# makes it marginally more pleasant but in general it’s pretty feasible, people will just look at you funny.

Just to tease it out more. What do you mean by functional? I assume that you design your classes to be immutable (only getters with defensive copies when needed). Do you also keep most business logic as pure, static methods on non-data-holding classes? That's about as far as you can go with Java, I guess, but honestly, now that I type that out, I guess that does get you pretty far...

Yes, classes are just POCOs (sometimes with some sealed subclasses, to hack sum types) and business logic is static functions in separate classes. Like I said, C# makes this somewhat easier, with things like readonly fields, get-only auto-properties, System.Collections.Immutable, readonly structs, pattern matching, etc. With Java you have to take more care to encapsulate things properly, though I’m excited for records coming into the language.

The most salient problem is the fact that the languages do not distinguish between references and values (aka “mutability by default”) which means that the compiler will not maintain those invariants for you unless you annotate things specifically, and the authors of the libraries you use do the same.

My overall preference is for F#, which is ironically a better object oriented language than C#, by virtue of using ML-like syntax instead of C-like. Nonetheless, C# is a passable functional programming language these days, and the language designers keep adding more functional-inspired features with every release.

Re: A look at modern PHP

#492

Ah, it's like old times again. Nowadays all the language-snob threads are directed towards JavaScript, but I remember the days when PHP was the language of choice for what HN considers the inferior programmer. Fun memories, all this thread is missing is a link to the fractal of bad design rant.

It's not language quality and merits per se that are important. It's much about establishing status within a tribe that counts. PHP is seen as a low status language because many junior or moderately skilled programmers use it. Rust is a popular language among up and coming young programmers because they expect to over throw the dominance of older C++ programmers. Haskell is for the high priests if that is your path t…

I agree with your analysis.

Re: A look at modern PHP

#493

Earlier quoted context omitted.

Perhaps it was condescending, but it was, first of all, not intended to be malicious. I have had the luxury of having used a lot of programming languages for various projects. The first N years of my career, I used mostly C++ and Python. I didn't like Python much and was pretty convinced that C++ was the pinnacle of programming languages. Since then I've done (real, professional, for-profit) projects in PHP, Go, Java…

> Also, I'm not sure what Peter Norvig has to do with it. I bet he doesn't like PHP, either. Your comment wasn't about people who like PHP. Your comment was about people who defend JS or PHP to the minimal extent of saying their deficiencies are not deal-breakers. There are people with broad experience who are willing to accept deficiencies of a particular language if the context is right. (I don't actually know what…

I suppose you're right. I did not mean people who shrug and say "Yeah, PHP sucks, but I'll defend its use here for X reason."

I was more, in my head, describing people who say "Well, all languages have issues." or "You can write good/bad code in any language." or whatever other bottom-of-the-barrel defenses I often hear and read.

Re: A look at modern PHP

#494
post #112

The amount of misinformation, false claims and unsupported statements in this thread is mindblowing for the quality that I've been used to see on HN. Here are some facts: - Symfony was the backend framework with the most contributors in 2019 [1] (yes, out of any backend framework written in any language) - PHP has more active contributors than it ever had [2] - Laravel is one of the most used frameworks in the world…

I do not do PHP and only have done a bit a long time ago, but I chuckle at the statement that nobody starts any project in PHP, only to find that a huge amount of new sites are wordpress sites, and they are a gateway to PHP. And do not discard WordPress, because it is amazing in how you can have a productive web site with no programing knowledge. After your site actually generates value then you can hire programmers…

I was paid to build a Wordpress extension once. It was the most miserable programming experience of my life.

Wordpress is no doubt a powerful force on the web. As a no-code website-creation environment, it's fine. Maybe even good. But as a library, it is godawful.

Re: A look at modern PHP

#495

Earlier quoted context omitted.

You're entirely missing the point by focusing on why someone may or may not have used the wrong words - with an application written in many other languages, you have to do something special to be able to update some server-side code and have that new code be run when you next hit the server.

If pointing out that he's using the wrong technical term is 'missing the point', I'm not sure there was one to begin with. most examples of why php is so easy to deploy show it with hello world examples you'd never encounter in the wild. yes, you can edit the php code directly on the server that is executing it. just like with python, nodejs, ruby ... and even java if you're not worrying about scalability. there is r…

Not sure if you even understand what you're talking about.

As for node.js, I set up pm2 to watch for file changes and restart ts-node process and this takes a few seconds, which is slower than I can hit alt-tab back to the browser, which is annoying to see 'Bad Gateway' error page quite often, not to mention embarrassing to explain and help set it up to someone new to other languages than PHP.

PHP is instant and I'd like to know if there's a solution in node.js that can do the same.

Re: A look at modern PHP

#496
post #370
post #112

The amount of misinformation, false claims and unsupported statements in this thread is mindblowing for the quality that I've been used to see on HN. Here are some facts: - Symfony was the backend framework with the most contributors in 2019 [1] (yes, out of any backend framework written in any language) - PHP has more active contributors than it ever had [2] - Laravel is one of the most used frameworks in the world…

Here's some interesting facts about PHP I like to know and share. How many of them are now untrue? "foo" == TRUE, and "foo" == 0, but TRUE != 0 NULL PHP sez: Parse error: syntax error, unexpected (T_PAAMAYIM_NEKUDOTAYIM)

T_PAAMAYIM_NEKUDOTAYIM was changed to T_DOUBLE_COLON ages ago

Re: A look at modern PHP

#497
post #112

The amount of misinformation, false claims and unsupported statements in this thread is mindblowing for the quality that I've been used to see on HN. Here are some facts: - Symfony was the backend framework with the most contributors in 2019 [1] (yes, out of any backend framework written in any language) - PHP has more active contributors than it ever had [2] - Laravel is one of the most used frameworks in the world…

> The only other 2 stacks to which I can compare it are the Spring stack of Java or .NET core, and except for these two I wouldn't seriously consider any other competitor for starting a new project

Surely Django & Rails are also comparable to something like Laravel?

Re: A look at modern PHP

#498
post #200

Earlier quoted context omitted.

Most of the comments against PHP are from developers that wrote PHP There are still some issues but considering the current state of language, frameworks, libraries, and the ecosystem, it's very practical and productive environment to build any project. I've been doing Typescript, Scala, and recently also Go in last few years. Scala and Go have decent language design and I'm a fan of both of them. But, when it comes…

I think there is a huge difference between web sites and web applications. Most large applications today uses SPA and an api. The api can be done in any backend language and there is not many obvious benfits of using php but some clear drawbacks. If you just want to create a web site quickly then php works fine but on the other hand you can do it quickly with js, c# or Typescript also.

> Most large applications today uses SPA and an api.

I’ve been thinking a lot about this over the last year+. Is this true? Because the deployment model is 1000x more straightforward for CRA vs NextJS (nuxtjs, etc.).

Re: A look at modern PHP

#499
post #112

The amount of misinformation, false claims and unsupported statements in this thread is mindblowing for the quality that I've been used to see on HN. Here are some facts: - Symfony was the backend framework with the most contributors in 2019 [1] (yes, out of any backend framework written in any language) - PHP has more active contributors than it ever had [2] - Laravel is one of the most used frameworks in the world…

Where to begin? - No proper connection pooling with circuit breakers. - No proper multithreading (that works in web environment) or parallelism in general. - Almost everything blocks (even `new PDO('mysql:...')` can block for whatever the execution time limit is, if there is an issue with connection or MySQL server). - Most libraries are implemented in C instead of in PHP, whereas with other languages people try to a…

> - Most libraries are implemented in C instead of in PHP, whereas with other languages people try to avoid native code as much as possible. This means that code is not memory safe, and understanding or contributing is close to impossible.

You want this in any scripting language if you don’t want memory use and cycles to balloon out of control for simple tasks. Most any scripting language looking for performance is going “how can I GTFO of myself and into C (or assembly, or maybe these days Rust I guess, in some circles) as fast as possible”.

Re: A look at modern PHP

#500
post #95
post #61

Earlier quoted context omitted.

> But with fewer people self-hosting these days, that has become less an advantage. I don't think fewer people self-host. There are some going to big clouds, there are some using integrated offerings like squarespace, but there are still many hosting their website with a regular hoster. And probably in total many more than in the past. > And even for those who do self-host, the advantage is becoming narrower as other…

I'll concede that PHP focused hosting solutions such as your traditional shared webpage hosting environment is better at hosting PHP than any other language, and sure there are less services out there that lets you deploy code "as easy as PHP". I had to check and I'm paying about 4$ a month for a traditional PHP server host vs 5$ for a VPS which I can run whatever I want on. And if you want a barebones deployment for…

Unless you are running continuous load, the $4 PHP shared hoster is probably more powerful than $5 VPS.

I know some shared PHP host that cost $8/year and have larger memory_limit than the available RAM in $5 VPS.

Post reply on HN