Live data from Hacker News

PHP – The Right Way

phptherightway.com

261–270 of 349 posts

Re: PHP – The Right Way

#261

Actually, that make me remember statements of Linus Torvalds on Git at Google Tech Talk Conference: But I did end up using CVS for seven years at a commercial company and I hated it with a passion. When I say I hate CVS with a passion, I have to also say that if there are any SVN users in Subversion, users in the audience, you might want to leave because my hatred of CVS has meant that I see Subversion as being the m…

There are a plethora of articles for "foo best practices" or "bar done right". I feel like you are stretching a quote to fit a premise that doesn't match the context of this thread or article.

I didn’t mean to stretch anything, that just the immediate thing that popped in my mind when I red "PHP – The Right Way".

Now, I don’t mean PHP is never the right way to go. Especially if you have to deal with a large existing code base, rewriting everything in whatever shiny bright language there is available currently on the shelve is probably a far worst option.

Re: PHP – The Right Way

#262
post #252
post #247

Earlier quoted context omitted.

> 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.

But in fact the semantics did not change within the minor revision boundary. This was an ordinary deprecation process, as it should be. Emitting a warning is not breaking anything!

> did not change within the minor revision boundary

I'm confused, are you saying it's fine to change core language semantics as long as it's across major version boundaries? How the hell is that better?

No other reasonable language does this.

Re: PHP – The Right Way

#263

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…

We use Asp.NET and it is a giant surprise how good it is. We are unix ppl, Linux & MacOS so not a MS shop at all. We deploy to on-prem and AWS so no Azure.

Do you deploy to Linux images on AWS?

I'm actually very interested in your dev setup. Do your devs use Linux machines? What IDE?

Re: PHP – The Right Way

#264
post #240

Earlier quoted context omitted.

* duct-tape style of arrays that Just Work(tm) as arrays, hash maps, etc. without having to use any boilerplate code. It's the main reason why I still prefer PHP for quick&dirty scripting and data processing.

I love PHP "arrays" but there is one tiny gotcha that becomes more important as we do type-safety stuff more and more. `$a['1'] = 'string';` becomes `$a[1] = 'string';`. This appears to be the case for any fully-fledged decimal number where `(string)(int)$key === $key` So if you are expecting `array_keys` to return all strings, you might get surprised

Some years ago I was appending underscores to key strings to avoid that. We're talking PHP 5 era. But even at that time stdClass was available. Today, I much prefer either using a stdClass object or actually making a real class when I reach for an associative array. They still have their use cases, though.

Re: PHP – The Right Way

#265

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…

> 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…

Some of the major criticisms most frequently leveled at PHP relate it's convoluted history, the random ad hoc nature of their built-in functions, the inability to enforce types, overly flexible/dynamic, etc all of which can contribute to, among other things, disorganized code.

But then when PHP does something positive to clean things up, we get threads like this. You're damned if you do and damned if you don't.

FWIW, how PHP handled `count` was very well done IMHO. The evolution from having `count` throw a warning on non-countable objects to having `count` throw a TypeError has occurred over several years! No one should have been caught off-guard by this very gradual change.

Re: PHP – The Right Way

#266

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.

Pretty sure they meant immutable in that quote.

Re: PHP – The Right Way

#267
post #262
post #252

Earlier quoted context omitted.

But in fact the semantics did not change within the minor revision boundary. This was an ordinary deprecation process, as it should be. Emitting a warning is not breaking anything!

> did not change within the minor revision boundary I'm confused, are you saying it's fine to change core language semantics as long as it's across major version boundaries? How the hell is that better? No other reasonable language does this.

Just wait until you upgrade to Python 3!

Re: PHP – The Right Way

#268

Earlier quoted context omitted.

And pulling ~67 dev dependencies just to be able to transpile TS to JS? No thanks. https://www.npmjs.com/package/typescript

This comment shows perfectly that people has no clue what they're talking about, these dev dependencies will never be pulled into your project, they're just for typescript's own development.

> these dev dependencies will never be pulled into your project,

Please, don't ruin "JS bad" thread with facts. It's rude.

Re: PHP – The Right Way

#269
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.

I'm more of a fan of PHP/Symfony rather than PHP/Laravel.

But you know what? I would expect I would like Ruby/Rails as well, as it follows the similar kind of philosophy, which is server-side rendered templates with Javascript sprinkles.

I think Rails and Symfony both have the benefit of being a fairly consolidated solution. You don't seem to have the same proliferation of packages, as with Javascript.

What I'm not a fan of, is Javascript SPAs where there is no reason for using them.

Re: PHP – The Right Way

#270
post #254

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 The fuck are you smoking? The JVM is one of the most mature, resource efficient, and fast language runtimes out there. See, this is why nobody can take you people seriously.

If you're conversing with someone who believes that the JVM is a resource hog, then you are likely conversing with someone with decades of experience. I would phrase my opposing viewpoint in a more respectable manner, as you might have a lot to learn from someone like that.
Post reply on HN