Live data from Hacker News

PHP – The Right Way

phptherightway.com

241–250 of 349 posts

Re: PHP – The Right Way

#241

Earlier quoted context omitted.

> In the next major version, they turned the warning into an error. Pretty understandable way to improve the language I would say. Breaking changes (at runtime no less) are the worst way to improve any language. They should have created a new count method if they wanted to change behavior in a breaking way. Forcing millions of developers to comb through their code just because some designer doesn't like the way someo…

Does PHP say it follows SemVer? I don't know as I don't use it but Python doesn't.

[deleted]

Re: PHP – The Right Way

#242
post #198

Earlier quoted context omitted.

And don't forget the most important part - incompetent programmers. It is we, the programmers, who writes all that code that that ends up as steaming pile of garbage. We can't blame others on that one. We need to become better with the tools we have. Thus it is naive to believe that by switching language you somehow magically will write better code but without doing any effort to improve yourself first.

Better tools lead to better outcomes if all rest remains the same, so I don't think that holds true even if we ignore the fact that languages (and their communities!) incentivize different things and can certainly lead to better code. Its certainly a lot easier writing good Python than good C, for a quick example.

True, but they are somewhat different tools with different purposes, writing an operating system in Python is a bad idea and doing web in C is cumbersome.

Thus I wouldn't blame Python if I used it for something it wasn't designed for, similar I wouldn't blame the screwdriver if I used it for punching a nail into a board.

There seems to be a constant drive to have one language to rule them all, instead of using specialized languages that are designed for a specific domain.

That is why I think PHP is such a good fit for the web because it is actually designed with that in mind.

Re: PHP – The Right Way

#243

Earlier quoted context omitted.

> But, really, I suggest using other tools. We have nicer tools now. Debatable really. Within the web development space the options are rather limited in my opinion. Options: * Spring based apps - Downside JVM is a Resource hog * Python, Ruby, etc - The web frameworks are in my opinion not as full featured. Same with CMS systems. Also requires more resources. Also have limited OO features. * Go, Rust, etc - Really go…

> Downside JVM is a Resource hog I have to disagree. The JVM is one of the biggest pluses and might be one of the most battle-tested pieces of software out there. > The web frameworks are in my opinion not as full featured. Again, have to disagree here. Django is by far one of the most full-featured, well-documented web frameworks out there (IMO). > The tooling around PHP is really good and stable. The language itsel…

> I have to disagree. The JVM is one of the biggest pluses and might be one of the most battle-tested pieces of software out there.

Your points don't seem to conflict with the fact you need more resources to run a mimimal Spring Boot application than you would a Go application, a Python applicaton, a PHP application, etc. Because the JVM by default by the nature of how it operates needs more resources. I'm not saying anything other than that.

Re: PHP – The Right Way

#244
post #140

Earlier quoted context omitted.

We're saying the same thing :) Templating language (for the web) and handle forms (on the web) makes PHP a web-language first and foremost. That's also the impression I get from reading the following section from the Wikipedia page you linked: > PHP development began in 1994 when Rasmus Lerdorf wrote several Common Gateway Interface (CGI) programs in C,[16][17] which he used to maintain his personal homepage. He exte…

I think I focused too much on the word framework , which is a vague word, and probably means a lot of different things depending on perspective. My reply was more to explain why I think it is not a framework, but rather a language, to handle web-stuff. But looking at it from other perspectives, that can be "framework" just fine.

Yeah, that's true, my bad for being a bit ambiguous. I always saw PHP as a framework on top of C for writing web applications, which can also be called a language.

But no harm done, thanks for clarifying yourself :)

Re: PHP – The Right Way

#245
post #186

Earlier quoted context omitted.

The main comparisons I have are building sites with Ruby/Rails and doing JS front ends attached to REST APIs. All three types of project have their own pros and cons.

The fair comparison: PHP/Laravel to Ruby/Rails... How is PHP/Laravel better? I'm of the opinion it loses hard in every aspect.

Ruby allows you to do even more stupid things than PHP does. It's also slower.

Re: PHP – The Right Way

#246

Earlier quoted context omitted.

I will just leave these here: https://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/ https://software-gunslinger.tumblr.com/post/47131406821/php-...

That first article is a decade old.

The article has been updated over the decade. It mentions which things have been fixed — most of them haven't.

Re: PHP – The Right Way

#247
post #214

Earlier quoted context omitted.

I was curious about this rant since I'm maintaning a number of PHP projects and I haven't had any issues with "count". In the Changelog section of the "count" docs at https://www.php.net/manual/en/function.count.php we find: > 7.2.0 - count() will now yield a warning on invalid countable types passed to the value parameter. So in 7.2.0 they started raising a warning in cases where the application was doing a stupid t…

Quoted post unavailable.

> If you don't check what you pass to count() it's really not php's problem, it's your programming.

this is a horrible take, language semantics should never change in a backwards-incompatible way. This is API design 101.

Re: PHP – The Right Way

#248

Earlier quoted context omitted.

> not only integers and floats, but also strings, lists and dictionaries as mutable value types (copy-on-write) Lists and dictionaries are also mutable in Python. Strings are not. With CoW, are your referring to garbage collection? (value that is no longer assigned to a name will eventually be purged). That would be independent of (im)mutability, so I'm not sure I understand.

With copy-on-write: $a = ['a']; $b = $a; $a and $b both point to the exact same bit of memory. Thus passing an array between functions is zero-cost. When you do: $b[] = 'b'; // append 'b' a new array is allocated, the old data copied to it, and 'b' appended to it (basically, but IIRC, it is a bit more optimized than that).

So basically what FP languages do?

Re: PHP – The Right Way

#249

Earlier quoted context omitted.

> In the next major version, they turned the warning into an error. Pretty understandable way to improve the language I would say. Breaking changes (at runtime no less) are the worst way to improve any language. They should have created a new count method if they wanted to change behavior in a breaking way. Forcing millions of developers to comb through their code just because some designer doesn't like the way someo…

Does PHP say it follows SemVer? I don't know as I don't use it but Python doesn't.

For the most part. However one person's bug is another person's feature and given the huge number of PHP users, where many aren't formally trained developers the ways in which PHP is (ab-)used is manifold. Thus sometimes things slip through as Bugfix, which then annoy people. But over recent times PHP got a lot better (maybe since I'm not involved anymore)

Re: PHP – The Right Way

#250

PHP is a language with various features that might make it attractive to certain people: • CGI-like execution model when used for the web, making resource leaks very difficult and encouraging scalable design • not only integers and floats, but also strings, lists and dictionaries as mutable value types (copy-on-write) — this is a big difference from JavaScript and Python • unusually for a dynamic “scripting” language…

> not only integers and floats, but also strings, lists and dictionaries as mutable value types (copy-on-write) Lists and dictionaries are also mutable in Python. Strings are not. With CoW, are your referring to garbage collection? (value that is no longer assigned to a name will eventually be purged). That would be independent of (im)mutability, so I'm not sure I understand.

so is object(array,map,etc) in javascript, many scripting languages have non-primitives mutable, the OP seems wrong on this claim(e.g. only PHP does that)
Post reply on HN