Live data from Hacker News

PHP – The Right Way

phptherightway.com

221–230 of 349 posts

Re: PHP – The Right Way

#221
post #80
post #48

Earlier quoted context omitted.

What tools? What server language today except PHP (and its forks) is actually designed for the web and works as the web was intended?

What server language today except PHP (and its forks) is actually designed for the web and works as the web was intended? The implication of the question is that there's something designed into PHP that makes it better for working with web things. Why does the language need to be designed to work with the web? That part of any language can be filled out with a framework quite easily, and arguably that means it's much…

> and Rust web projects use Poem

Isn't Poem just... several months old? Your examples of frameworks for other languages are mature and established. Is the Rust ecosystem moving that fast?

Re: PHP – The Right Way

#222
post #170

A language that changes the semantics of functions between minor versions has no "right way". "count()"less examples of crap. I have currently two weeks of code migration behind me because code running correctly on 7.0 fails on 7.3 -- while I see the reason for change was necessary I also see the hopelessness of rebuilding a flawed house with a fundament build on a pile of manure. And the good news given to me by a c…

I assume then that you disqualify Python for the same reason? Python 3.x has decided that breaking changes in minor releases is fine. My favourite: string prefixes (eg s'foo', u'foo') were legal in 2.x, removed in 3.0, added back in 3.3. There are other subtle breakages (eg open() flags). Hating on PHP is a tired cliche at this point.

>Python 3.x has decided that breaking changes in minor releases is fine. My favourite: string prefixes (eg s'foo', u'foo') were legal in 2.x, removed in 3.0, added back in 3.3.

Python 3.0 was very much not a minor release, so your example is invalid.

The general point that Python does breaking changes in minor releases stands, but they do typically go through a deprecation period first.

Re: PHP – The Right Way

#223
post #172

Earlier quoted context omitted.

#2: Strict Programming lang's. I often seen frustrate new programmers, specially young new programmers making them want to give up on programming all together so I don't know if I would call that beginner friendly, I certainly would not call rust beginner friendly I guess however we would need to define what a "beginner" target is, are we talking adults that want to learn programmed to change fields, or children want…

You are right of course. The thing that many people miss is that learning isn't just one thing from, say, Hello World to a fully fledged application but it involves learning diferent types of things in different orders. For example, going straight-to-web can be hard since it involves several different concepts HTML is not CSS is not JS is not backend code (mostly!). So it is sometimes better to teach the basics in a…

While I can understand that approach, I do wonder if my origin to programming is common or not. I did not get in to programming to become a programmer.

I learned programming to solve a problem I was having, in my case I did start out in web development in the 90's. I wanted a website that did something that I could not find premade software that did it in the way I wanted so I wrote my own. I also learned of open source and and other communities via this process.

Had I just stuck with the commercial software solution I bought, that was terrible, I would have missed out on on a skill I eventually learned to love.

The website (and company around it) I built was never successful, but from that experience I learned a skill that carried me to the career I now have

Re: PHP – The Right Way

#225
post #186

Earlier quoted context omitted.

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

There is one aspect where it wins hands down that trumps almost every other concern that you might have: availability of developers. This is a hard problem to solve.

Raw number of developers doesn't matter at all. The ratio of offers to developers out there determines how easy the hiring actually is. I've tried to hire some quality PHP developers and it's as hard as Ruby/Python if not harder. First thing is, that you always get all the Wordpress people, who fixed one plugin and claim to have 10 years of PHP experience. Then you have to filter out all the 10 YoE who actually have 1 YoE done 10 times. For some reason all this is less of a problem in less popular stacks.

Re: PHP – The Right Way

#226
post #185

Earlier quoted context omitted.

3. Executing code for a request is single-threaded. This is almost always what you want; And now with fibers you can launch "threads", which are not threads but work like them.

Aren’t fibers designed from the perspective of usage in underlying libraries, rather than something for everyday end users in the fashion of async/await?

Correct.

Re: PHP – The Right Way

#227
PHP is still full of awkward decisions.

One that baffles me is that 8.0 changed it so all scripts default to a "C" (i.e. english, ascii-only) locale. [0]

So this is now a scripting language that requires you to call `setlocale` for every script manually.

Contrast python, which tries to fix the locale so it's at least UTF-8 aware. [1]

[0]: From https://www.php.net/manual/en/migration80.incompatible.php "The default locale on startup is now always "C". No locales are inherited from the environment by default. Previously, LC_ALL was set to "C", while LC_CTYPE was inherited from the environment. However, some functions did not respect the inherited locale without an explicit setlocale() call. An explicit setlocale() call is now always required if a locale component should be changed from the default. "

[1]: https://www.python.org/dev/peps/pep-0538/

Re: PHP – The Right Way

#228
post #184

Earlier quoted context omitted.

So compared to JS and $DYNAMICALLY_TYPED_LANG, PHP is "decent these days". These languages all suffer from very similar problems. Compare to C#/MVC.net, Kotlin/whatever, Go, Rust to get something noteworthy.

At least for Go and Rust, they have a much steeper learning curve. If you are a startup with limited funds you are not able to target engineers workings with those languages. If it's just a matter of speed, PHP already is good enough for the great majority of cases. The bottleneck is the data layer, usually. If your problem is being faster than the latest versions of PHP can achieve, you can certainly look for Go/Kot…

> At least for Go and Rust, they have a much steeper learning curve.

Agree about Rust, but I should differ from Go, as a disclaimer I never used Go, but read a lot of people switching from JS to Go and they have a very easy time doing so, maybe not everyone find it easy, and also it might to happen that the architecture you are used to work with in NodeJS is similar than the one that Go uses?

> If you are a startup with limited funds you are not able to target engineers workings with those languages.

I think Ruby/Rails will help you to build your project much quicker than Php/[Laravel | Symfony].

> If it's just a matter of speed, PHP already is good enough for the great majority of cases.

Again also Ruby is pretty fast these days (if you want more speed you can use JRuby or TruffleRuby).

> If your problem is being faster than the latest versions of PHP can achieve, you can certainly look for Go/Kotlin/Rust.

Go: I should say yes, if PHP/Ruby isn't enough, this should your go to. Kotlin: I cannot speak about it, I'm not sure how popular is in this space. Rust: I love rust but I think this should be your last resort, if Go isn't enough anymore.

But I can agree that work with Php is pretty easy (I worked with Php since 4.2 till 5.3, then tried it with some projects here and there with 7.x and 8.x) but I cannot stress how bad the tooling around php feels if you compare with others (ruby is bad too IMHO), JS with vscode, rust with rust-analyzer, etc. The only way I found a decent tool was with PhpStorm, but you need to pay for it (even the Laravel plugin needs a subscription), while the RubyMine is almost the same at least Rails works out of the box without an extra subscription for the plugins.

Re: PHP – The Right Way

#229
post #198

Earlier quoted context omitted.

>> My hatred is based on failing projects, missed deadlines, burnouts, money stolen, severe downtime, and companies going bankrupt. One can find example of this in almost all the languages. Most of the time mismanaged requirements, bad project planing, bad financial management are the issues for most of the things you have listed rather than the choice of programming language.

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.

Re: PHP – The Right Way

#230
post #194

Earlier quoted context omitted.

> Same can be said (and to me is verrrry true) fro JavaScript. Not if you use JS like Scheme: https://www.crockford.com/little.html In fact JS is much more pleasant to write than PHP, the main reason to move way from PHP after using it for over 10 years.

JavaScript: the language that can barely understand itself is better than PHP! The language, where JetBrain's IDE (arguably one of the best IDEs when it comes to understanding languages, consistently better than any LSPs among other things) can barely understand it fully, is better than PHP! The language that has consistently added new features, but have yet to fix horrible messes of legacy design. The majority of Ga…

The linked talk is soo true and so hilarious.
Post reply on HN