Live data from Hacker News

PHP in 2019

stitcher.io

451–460 of 489 posts

Re: PHP in 2019

#451
post #373

Earlier quoted context omitted.

What isn't fake is that Laravel uses magic methods everywhere, especially in the ORM layer. There are way too many magic things happening under the hood for my taste.

Magic methods in PHP are very commonly used to help reduce code verbosity - having come from working mostly in C++ I appreciate being able to express things succinctly.

Much more important for code, especially library code is readability

Re: PHP in 2019

#452
post #374

Earlier quoted context omitted.

I do. I was using it back in 2003... pear/DB. I still have some code from that era that uses it.

Would you use a pear dependency in a new project if you weren't pulling bits in from an older one? Personally, I wouldn't... I worked with pear and pecl and composer is just far more pleasant to interact with.

actively maintained pear packages can be installed also with composer

Re: PHP in 2019

#453

Earlier quoted context omitted.

Old PHP projects can be upgraded in the present because backwards compatibility exists, as i metnioend in other comment I done such a small upgrade and I hat to change only 1 deprecated function with a different one. If this would not have been possible the project would have still be running on an old version without security fixes and slower(eating more electricity so bad for environment)

If you say so. ~5 years ago I had to work a full week, 8h a day, to fully upgrade a medium-sized website from PHP 5.2 to 5.4, and eventually gave up. Most of the time was spent trying to cope with different datetime parsing idiosyncrasies.

I am sorry you had such a bad experience, can I ask you to give me some link or details about your issues with datetime , I want to learn about the problems I do not doubt you.

I had some problems with mysql updates though, new versions had different)better default behavior). we were using an ORM for the project but the initial setup and migrations were made in plain SQL and those needed to be updated. As an example in older mysql you could have a timestamp column NULL with no default value set and now we needed to fix to set a curenttime as default.

Re: PHP in 2019

#454
I just took a random sample from Spatie's PHP libraries - https://github.com/spatie/crawler/blob/master/src/Crawler.ph.... Most of the code consists of:

    public function getSomething(int $someParameter): SomeType {
        return $this->someParameter;
    }    
If this, along with the fanfold block comments you see in modern PHP, is considered "clean code" I'll take procedural PHP4 any day of the week. Why PHP5 had to be reborn as the scripting version of Java I'll never understand.

Re: PHP in 2019

#455

Earlier quoted context omitted.

Yep. Laravel is basically PHP on Rails. They do a great job with it too.

I dunno... Their home page looks like something out of the Panera Bread playbook looking at the homepage. 'Web artisans'? Why is it 'clean' because it has an absurd amount of whitespace and comments of platitudes for the code example?

Glad I'm not the only one who thinks "modern PHP" struggles to fit more than a couple of lines of real code on a screen surrounded, as it is, by space-wasting nonsense such as block comments, blank lines and K&R brace style. No wonder people prefer Ruby. Around the time of PHP5 the language ditched its own identity and sought to become the scripting version of Java. Give me back my procedural PHP4.

Re: PHP in 2019

#456
post #454

I just took a random sample from Spatie's PHP libraries - https://github.com/spatie/crawler/blob/master/src/Crawler.ph... . Most of the code consists of: public function getSomething(int $someParameter): SomeType { return $this->someParameter; } If this, along with the fanfold block comments you see in modern PHP, is considered "clean code" I'll take procedural PHP4 any day of the week. Why PHP5 had to be reborn as t…

It's been close to a decade since I did anything in PHP (PHP5), but since I know PHP5 had public (and private,and protected) accessors back then, but didn't have any real typing of parameters if I remember, I assume this is a design pattern to enforce typing on the object parameters. Also, a good amount of them have some other guard that throws an exception on specific problems. I think it's a valid design choice to decide that since some object variables may need special handling that is accomplished through accessor methods, just create them specifically for each item that needs public access, and while you're at it throw in a few sanity checks. That provides a consistent interface, where accessors are both named and act in the same manner (i.e. you don't have mixed method call and direct assignment).

Re: PHP in 2019

#457

Earlier quoted context omitted.

I've been coding in PHP for almost 20 years now. I think I can count on one hand the number of times where I have had an issue regarding inconsistent function signatures. It becomes second nature, and if I forget, the documentation is available online or in worst case built into my IDE. I can understand why people make this into such a pain point, but quite frankly it isn't for anyone who works day in day out with PH…

23 years here (php/fi in jan '96) and I probably hit the 'parameter order' issue more than you. I still need to look param order stuff multiple times per year. Normally I can get it in the IDE, but doing remote vim stuff, for example, I need to look it up. Yes, it's technically a non-zero problem. I get it. Having spent several years in the Java/Spring world, the classic ASP world, and the Perl world... they all have…

Since you mentioned Perl, I wonder if you've tried Mojolicious at all and what you think of it? I've found it pretty nice to work in, and easily scalable to small and large projects.

That said, I don't have is a lot of experience with other frameworks in other languages to compare it to, so I don't exactly know how it compares.

Re: PHP in 2019

#458
post #73
post #51

As far as I'm concerned the bridges have burned a long time ago and I definitely can't see myself giving PHP a second chance. That being said, if I'm wrong and PHP has really managed to become a decent language (or at least something that's not completely insane) its defenders should focus on actually showing what modern PHP code looks like. Is performance that much of a big deal for most people? In a world where Rub…

> Is performance that much of a big deal for most people? For most people outside VC-funded startups, yes it is. It is also an environmental concern, imagine if 80% of the web was running on ruby.

My main beef with PHP is performance at scale. Doing 100.000+ req/s, the memory footprint for PHP is ... annoying.

Re: PHP in 2019

#459
post #412
post #341

Earlier quoted context omitted.

Tokens are issued from within the Spark customer dashboard and the token is required in order to pull the repo during install. It’s basically the honor system.

Thanks. I noticed they have a public repo with a tool that manages a way to download the spark code base. I'm guessing without a token you can't access whatever code that public tool pulls down, meaning you need an active token to get future updates of the code base? Pretty cool system if that's the case (there's motivation to keep your purchase to receive updates). I'm not asking to try and rip him off. I was just c…

I believe so. Updates are handled through composer package manager and the process is no different than updating a normal Laravel installation. I've never seen any info about how Spark is protected, so I'm just going off of my personal experience using it.

Re: PHP in 2019

#460

Earlier quoted context omitted.

My issue with modern PHP is that it's essentially becoming Java. And with the JVM and the Java ecosystem, what is the compelling reason to not just pick Java at this point? With Java you are basically writing exactly what you would be writing with PHP, except with more language features and the ability to opt into other languages on the JVM like Kotlin and Scala. The modern additions are fantastic for projects and te…

Except PHP is not Java, and it never can be. What is PHP's multithreading model again? Hotspot VM? NIO? I'm sure someone will chime in and cite something similar in PHP, but the comparison will be laughable in reality.

>What is PHP's multithreading model again

Since it's inception, the PHP implementation hasn't been threadsafe and since, the way of doing paralellism has been process forking. Later iterations where released with support for long-lived processes and threads but it's still not officially "stable" since again, historically the model of process forking made the ecosystem take for granted non-memory safety.

On the other hand, at least since the last time I was doing Java, paralellism is done via multithreading. Sure, there must be someone doing some else out there, but relevant frameworks like Spring work by making 1 thread by http request.

IMHO the right way of dealing with concurrency is the Node way. But comparing the PHP vs Java y think the PHP way is better. In small-medium scale the Java way is obviously more performant. The problem is when you scale to more instances. The PHP way of immutable processes really makes vertical scalling easier.

Post reply on HN