Live data from Hacker News

Learn PHP the Right Way

github.com

51–60 of 73 posts

Re: Learn PHP the Right Way

#51
post #35

Earlier quoted context omitted.

Is it really that good for backend? 1. You will still need to learn JS, and now it may even be embedded in PHP depending on the type of app you are working with! 2. It still has horrible conventions, arrays being sorted maps has to be one of the worst design decisions, IMO its worse than having null and undefined as types. Mutlibyte strings are still an afterthought in the core of PHP. Inconsistent function naming. I…

1. I am already very good with JavaScript, I like having the language separation between frontend and backend. 2. I much prefer using PHP arrays than JS arrays. All the other stuff you mentioned have never been a issue for me in the past 10 years. I don’t care about types (I don’t even remember when I had a real type bug). 3. The modern web is an over engineered mess, all the modern js frameworks have made the user e…

1) Okay, but in terms of getting shit done how is it helpful to people to learn two languages?

2) They aren't even arrays? How can you say that lol. If you haven't tripped over what I have listed I just cannot imagine how you have been using PHP. I ran into a multibyte encoding issue with Mongodb and Laravel last week for example. Just a few weeks ago the lovely json_encode a map was sometimes an array vs an object. Granted these are older laravel apps... I don't think a framework can fix these issues.

3) Great straw man! I am sure all PHP apps are beautiful things and their interactivity experience with the end user are perfect :)

Also speaking of over engineered, how is having to run a standalone web server along with PHP, and then having to have an entire JS stack as well not over engineered?

Re: Learn PHP the Right Way

#52
post #40

Earlier quoted context omitted.

> arrays being sorted maps has to be one of the worst design decisions. I'm curious, why is that so bad? It tends to be a useful property of PHP arrays. Also for webdevelopment, I/O is often the bottleneck. This code creates an array with 1 million items, each being 'a' and then loops over each value, changing them to 'b': $array = array_fill(0, 1000000, 'a'); foreach ($array as $key => $value) { $array[$key] = 'b';…

It is also funny to see a JS developer criticise the architecture of PHP arrays specifically. It does hint that perhaps bearjaws is (lucky for them!) too young to remember the mess that incomplete implementation of array/object duality got the JS world into.

Been programming both languages since 2008.

Re: Learn PHP the Right Way

#53

Earlier quoted context omitted.

Is it really that good for backend? 1. You will still need to learn JS, and now it may even be embedded in PHP depending on the type of app you are working with! 2. It still has horrible conventions, arrays being sorted maps has to be one of the worst design decisions, IMO its worse than having null and undefined as types. Mutlibyte strings are still an afterthought in the core of PHP. Inconsistent function naming. I…

If it wasn't that good for a backend it wouldn't have maintained complete domination of that market for decades, which it has. Incidentally the number of web development projects that have any objective use of async programming or fussy types is a rounding error. Perhaps your interests are pointing in another direction?

JavaScript is a terrible language and it still dominates front end :)

Re: Learn PHP the Right Way

#54
post #35

Earlier quoted context omitted.

1. I am already very good with JavaScript, I like having the language separation between frontend and backend. 2. I much prefer using PHP arrays than JS arrays. All the other stuff you mentioned have never been a issue for me in the past 10 years. I don’t care about types (I don’t even remember when I had a real type bug). 3. The modern web is an over engineered mess, all the modern js frameworks have made the user e…

1) Okay, but in terms of getting shit done how is it helpful to people to learn two languages? 2) They aren't even arrays? How can you say that lol. If you haven't tripped over what I have listed I just cannot imagine how you have been using PHP. I ran into a multibyte encoding issue with Mongodb and Laravel last week for example. Just a few weeks ago the lovely json_encode a map was sometimes an array vs an object.…

> 1) Okay, but in terms of getting shit done (one of your points) how is it helpful to people to learn two languages?

It's actually pretty clarifying. Two different perspectives on one single problem domain is almost always good for your brain. Like being bilingual.

Also I would dispute that there are not, fundamentally, two different environments in the browser and Node backend even now. One of those environments is a GUI which is naturally a good application for async. The other is not. Backend web development is still largely input -> process -> output. Node is just shoehorning JS in, and pretending that JavaScript's weaknesses are strengths.

> Also speaking of over engineered, how is having to run a standalone web server along with PHP, and then having to have an entire JS stack as well not over engineered?

Not sure what you mean. There are a bunch of ways to run PHP -- one is with a process manager (php-fpm, not unlike things like PM2). Another is to run Apache as a backend to something like Caddy or nginx or some other cacher; this is actually a highly robust way to do things, because Apache can be tuned in so many different ways. And yet another is to use FrankenPHP, which is Caddy with a PHP process manager.

I personally treat JS at the front end (Vue/Nuxt) as a client application development environment, and PHP as a backend development environment, as clean separate things defined by an interface. I don't believe that blurring the boundary between code running in the client and code running in the server has ever been a good idea, nor will it ever be. It just leads to edge cases where the code has to ask, and developer traps where developers don't realise they need to know.

Re: Learn PHP the Right Way

#55
post #37

It's disappointing that PHP still gets hate in 2024. PHP of 2024 isn't the PHP of 2004. As someone with a bunch of experience in Java, C, C++, Python, PHP, Hack, Javascript and a handful of others, PHP is (IMHO) almost a perfect language for serving HTTP requests because of these characteristics: 1. Essentially an HTML document is a valid PHP program. This is an excellent starting point for beginners; 2. PHP has a st…

Honestly speaking, the main thing that always made me dislike PHP was lots of things related to the syntax. Call it petty, but it's the truth.

I've always felt that PHP could greatly benefit from a Kotlin-esque interop language with a more modern syntax and QoL upgrades, but I'm not sure if the juice is really worth the squeeze.

Re: Learn PHP the Right Way

#56
post #3

The only reason to learn PHP in 2024 is if you are specifically targeting PHP jobs. Learning PHP is like learning Perl: suboptimal. Edit: Jesu X. Chris, I didn’t mean to start a language war. Learn PHP if you want, I won’t stop you lol

I think for probably more than half of all websites out there, something like LAMP is either the optimal, or very close to the optimal solution. It's absolutely bonkers to me what kinds of tech stacks people use to render what essentially amounts to a bunch of forms.

I'd say swap out MySQL but yeah, a CMS is 99% of what you need.

Re: Learn PHP the Right Way

#57

Earlier quoted context omitted.

It is also funny to see a JS developer criticise the architecture of PHP arrays specifically. It does hint that perhaps bearjaws is (lucky for them!) too young to remember the mess that incomplete implementation of array/object duality got the JS world into.

Been programming both languages since 2008.

Right. Then you are too young (as a developer at least!) to remember. Except that Object.entries() is there to remind you. And two different for() enumeration syntaxes (for...in and for...of).

JS has an enormous amount of bad-design scar tissue.

I find it interesting that JS developers will forgive it all (global variables, iterables confusion, broken this handling, insane implicit number and int conversions, not to mention simple stuff like semicolon handling) and think PHP developers doing the same for theirs are inferior.

It's a classic example of fundamental attribution error.

Re: Learn PHP the Right Way

#58
post #27

Earlier quoted context omitted.

> PHP is so much nicer to use on a webserver vs Python or JS. How?

One thing that I think is under-appreciated from the perspective of "getting shit done" is that the default model of PHP makes it really hard to have memory leaks that eventually crashes your app/server, as your PHP script has a defined "start" and "end" that are all within the request lifecycle. So even if you leak horribly, thanks to Apache/Nginx/Caddy/whatever only launching your script and then your script stops…

Basically, PHP was using arenas before arenas were cool :)

Re: Learn PHP the Right Way

#59
I like PHP, and guess what? I also like PowerShell for web apps. I don't really care what anybody says—I can build fast in PowerShell. My clients are happy, it's simple to debug, and I can tap into .NET classes when necessary. PowerShell + HTML + Alpine = productivity. I'm not building the next Netflix or Amazon and the end-user isn't going to notice or care that I haven't selected Node and React.

I just can't get behind the complexity of build steps and compiling, all just to get a website online. It's crazy. The simplicity that PowerShell (and PHP) bring to this process can't be overlooked... so I like to beat on this drum whenever I get the chance.

Choose the tool that is right for the job, and PHP can be that tool in a surprising number of cases.

Re: Learn PHP the Right Way

#60

I like PHP, and guess what? I also like PowerShell for web apps. I don't really care what anybody says—I can build fast in PowerShell. My clients are happy, it's simple to debug, and I can tap into .NET classes when necessary. PowerShell + HTML + Alpine = productivity. I'm not building the next Netflix or Amazon and the end-user isn't going to notice or care that I haven't selected Node and React. I just can't get be…

I really learned to appreciate what Powershell is after listening to @adamgordonbell CoRecursive episode with Jeffrey Snover (https://corecursive.com/building-powershell-with-jeffrey-sno...).

I really loved PHP, but now with go+templ (https://templ.guide) I personally don't have a use-case for PHP anymore, but that doesn't mean it's irrelevant for the world.

Post reply on HN