Moving from Go to PHP Again
dannyvankooten.com
dannyvankooten.com
PHP files can be deployed independently, swapped out or updated live.
No building/compiling of the php files needed.
A single layer as opposed to 'modern architecture' where there's client side back/front end layers, api layer, logic, validator, data access, and ORM layers.
Can extend itself as it runs. For example Wordpress, running off of php files can download plugins to its own server (which are just more php files) to instantly extend itself. Without restarting or redeployment. (What other web platforms can do this?)
Intuitive, simple, powerful. Can be as easy as editing a php file in notepad and dropping it on a ftp server. Deployed.
Amazon lambda may have more in common with PHP in terms of discreet deployable units of functionality. What's old is new again.
Compiling/deploying an entire system to change a single endpoint feels backwards after using PHP.
php app/console cache:clear --env=prod --no-debug
php app/console assetic:dump
php app/console cache:warmup --env=prod --no-debug
chown -R apache:apache . # fix owner
chmod -R u=rwx,g=rwx,o=rx app/cache # fix cache perms
apachectl restart # bounce Apache, otherwise it can throw segfaultsuser: $sitename - the 'owner' of the whole hosted dir. rwX
user: $sitename-PHP - the user that php-fastcgi or whatever runs as, r-X permission on the dir, and write permission on the content uploads directory, but CANNOT write to any plugin install dirs, or upgrade php files.
user: nginx - can read all files except the wp-config.php file, which is limited to only the $sitename group reading it.
then use wp-cli to do automatic upgrades every few hours, and a localhost-only ftp server for wordpress to do plugin installs with. When you try to install a plugin, it asks for a ftp username, host as password. You put in the $sitename user, '127.0.0.1' and $sitename password, and you're set. Those login details are never saved anywhere, so the admin has to put them in each time (or their browser stores them).
Works pretty well for me.
check permissions there sometimes.
NB if anyone has ever run: chmod -R u+x . or equivalent and you run chmod -R u=rwX the files will stay executable...
You can always use find to set all files to +x and directories to -x but then what if some of files needed to be executable?
1. chown -R apache:apache . # Now the webserver will have write access over the whole application!
2. chmod -R u=rwx,g=rwx,o=rx app/cache # Now all files in cache are executable and writable by the webserver!
3. apachectl restart # graceful might be better here.
Securitywise 1 and 2 are not good things to do.
www.example.com/widgets.php
can be reached at: www.example.com/widgets
But here's the kicker: www.examples.com/widgets/123
will also route to widgets.php, with "/123" in the $_SERVER['PATH_INFO']. No mod_rewrite needed. www.example.com/widgets/you/can/have/multi-segment/paths
goes to widgets.php too, with its PATH_INFO set to "/you/can/have/multi-segment/paths", but I don't usually go that far. Usually the script name roughly corresponds to the name of a table (or database view), and the PATH_INFO corresponds to the primary key.[1] https://www.vdoo.com/blog/vdoo-discovers-significant-vulnera...
1. It doesn't sound like they were using MultiViews at all but some rewrite rule that rerouted all requests ending in .srv to a shell script in /bin. This isn't how MultiViews works. The file must exist, and it must be in the document root. A request to /foo won't work unless /foo.php (or foo.html, etc.) exists.
2. This rerouting was supposed to happen only for admins, but the authorization failed, due to a different bug, CVE-2018-10661.
3. The attack then depended on a bug in dbus, CVE-2018-10662
4. Finally it depended on a third flaw, CVE-2018-10660, having to do with shell-script injection.
So I don't think any of this should scare away a person from using MultiViews for .php scripts, which makes setting up clean, maintainable routes easier than any other technique I've seen.
The request to a.srv (in their example) was only authorized because a request to /index.html/a.srv looked like a request to /index.html to the auth module because the auth module did not check PATH_INFO. The request was then passed to the ssid daemon (not shell script) over a UNIX socket.
a.srv ended up in PATH_INFO because index.html existed.
The developer(s) of the auth module only checked SCRIPT_NAME and index.html was valid for unauthed users.
They could have done further configuration to let HTML files take PATH_INFO, but this Rube Goldberg machine of multiple mistakes bears no more connection to MultiViews than mod_rewrite. In fact, I see no mention in the article of MultiViews or its module, mod_negotiation. So how do we know they were using MultiViews and not mod_rewrite, which people use much more often for this amount of indirection?
Either way, this exploit is impossible in the original suggestion, to just use MultiViews with PHP files to remove the ".php"
Sometimes I'm in the middle of messing with the Lovecraftian horror that is the modern JS stack or screwing with extracting what I need from whatever awful request object someone cooked up or any number of other things that aren't accomplishing anything of business value and I wonder whether maybe somewhere we veered way in the wrong direction, as an industry.
> Intuitive, simple, powerful. Can be as easy as editing a php file in notepad and dropping it on a ftp server. Deployed.
This isn't really php specific, with cgi you can do that in any language, even compiled ones like c.
> Amazon lambda may have more in common with PHP in terms of discreet deployable units of functionality. What's old is new again.
Agreed. I must admit I'm guilty of this myself, there is a tendency to start with a framework when there are much simpler and quicker ways to get started, something the world seems to have largely forgotten.
Which becomes a security issue due to accidental endpoints or uploads becoming endpoints. Or becomes a mess of imports. Either way, PHP frameworks often end up with a central router anyway.
> PHP files can be deployed independently, swapped out or updated live.
Which means some people try to do that the naive way and end up breaking a few requests that happen during the deployment.
> Can be as easy as editing a php file in notepad and dropping it on a ftp server.
Which causes https://stackoverflow.com/search?q=headers+already+sent+bom&... because people don't realise they had an invisible character before all the code.
I really don't think any of those are a good thing.
Humans are fallible. That is an immutable truth.
There’s no great wisdom in relying on human discipline alone to produce reliable software.
Else we'd all be using assembly.
There's absolutely no pride or glory in doing things nicely and securely that the computer could have automated in the first place.
Anything the language allows that it could refuse while allowing devs to express the same features, and that results in bugs is a mistake in the language (e.g. the sorry state of strings in C).
I've seen an attitude that people think they can inoculate themselves from inept programming by using obtuse frameworks as if martin-fowler-speak acts as a drill sergeant making disciplined coders out of the herd.
But after 20 years of bouncing around startups I've never seen the intended results actually happen a single time. Not even close. Not once. Never.
Instead it leads to larger, less maintainable, more convoluted messes that have to be trashed quicker. Giant ceremonial cargo cult style monstrosities with huge circuitous logic - 4, 5, maybe 6 layers, a router calling a controller, calling a service, calling a provider, calling an event model, which runs a single if statement ... as if that's how we protect ourselves against incompetence.
These approaches just lead to wasteful projects where they end up rewriting the whole thing in whatever the framework/language de jour is instead of writing easily maintainable, quickly understandable code that's designed to work for the next 10 years. I've talked to many programmers who are embarrassed by the language they are using ... wtf is that?! They've turned programming into fast fashion.
Then people like to ask what someone's favorite language is, usually when they first meet them, as a social cue, as if we are a bunch of highschool kids following pop music. I mean what on earth... we're supposed to building the future here, not running around like a bunch of spastic fanboys from platform to platform, just to mess everything up all over again in bold new ways using slightly different syntax.
The best thing to do is give people the least abstract thing with the fewest conformity requirements ... essentially make it open ended and then the messes are easier to spot and easier to fix. You won't get 4 folders with 26 files handling simple tasks like uploading images to an S3 bucket (saw this huge mess just last week and guess what?! It's broken. I know, surprising right?)
Anyway, new shiny fancy tools with GoF buzzwords won't ever fix incompetence, it'll only make it worse.
Which is neither here nor there.
For one, it ignores the pragmatic issue, that very competent people (the very people that built the foundations we all work on even) will still make lots of mistakes, even trivial ones, but with severe consequences (e.g. buffer overflows) when the languages don't prevent them.
If only it was just "incompetent people" that made mistakes...
>But after 20 years of bouncing around startups I've never seen the intended results actually happen a single time. Not even close. Not once. Never.
You weren't looking hard enough. Every day millions of programmers don't make "buffer overflow" errors for example, that otherwise they'd have made, because they work in languages that don't allow them.
And they'd have made those mistakes regardless of their programming chops. The best programmers, people that run circles around you and me, still make those mistakes.
It's about giving code sunlight so that action at a distance and other kinds of magic don't hide errors making them harder to find, get in your way of fixing them, making reproducibility a mess and confirmation simply guesswork.
Its the restrictive design trend of crippling languages which needlessly prevents the sunlight effect from happening along with "information hiding principle" gone completely amuck with the information successfully hidden in dozens of innocently named files with listeners, observers, watchers, triggers and who knows what else being mysteriously called based on reflective programming so not even grep will help you.
Static code analysis and seamless navigation is totally a thing of the past.
Instead, the errors will have the stack of the error handler and that's it. The debugger is useless because stepping through the code is 98% scaffolding.
All these fancy tools bludgeoning any introspection or diagnostic system so the only remaining workable debug system is printing debug variables and rerunning the code like I'm programming on a TI-81 (only that had debug and release run modes...features I can usually only dream of these days) Progress! Welcome to 2019!
It's crazy. This isn't how maintainable code is written
The way I think about it is if you think through the entire software stack and all the instructions that get executed across all the machines and their operating systems and programs running underneath before things even get to your code and then all of the standard library and framework code plus your code. For just a simple loading a web page that is a trillion piece jigsaw puzzle and every single piece has to line up or the whole thing just doesn't work.
We do the humbling and the remarkable every day and trillion piece jigsaw puzzles are no joke. It's the exception that you get it right. Given all the pieces required that's a lot of sources of potential entropy and the more it increases the more the system destabilizes and/or becomes unworkable. Things like languages, libraries, frameworks etc make certain decisions on your behalf with the goal to contain some of that entropy within their given abstraction.
I think I'm justified in calling myself competent. Nevertheless, with the wrong tools, the things I build are definitely worse than the things I can build with proper tools.
I mean it's just a huge waste of time. These modern stacks (mostly js) are crap code all the way down.
It's made me want to return to Perl because honestly, it has everything and is somehow mostly idiot free. I probably should...
It's 4am, I should sleep.
The moment you convey that sort of attitude, two things happen. The person you called a flunkie will not learn a goddamned thing from you. And, if they happen to be right, you won't learn a damned thing either. Great choices.
However, you can pursue a culture of excellence without being rude and toxic. You can be kind and humble without coddling.
Edit - I should have added that if teenagers with computers have a good attitude, feel engaged and feel cared about, they can be extremely productive members of a team. And they have a tendency to grow into really amazing engineers (and fine people).
You can see right here on HN anytime a post comes up about using a cloud provider someone advocating putting a layer of abstraction over the provider’s SDK to prevent “lock-in”. As if the CTO is going to one day move their entire infrastructure because a developer promises them they’ve abstracted their code perfectly.
So instead of just being able to read the docs of the SDK, you have a custom QueueManagerFactory that gives you an AWSQueueManager that wraps the Boto3 AWS SDK just so one day if the company decides to move to GCP, someone can write a GCPQueueManager.
See also, developers who think they can effortlessly move from their company’s six figure Oracle installation to Postgres because they used the repository pattern.
This is despite the fact that if you do it it'll take 40 minutes manually versus 10 minutes if the Rube Goldberg abstraction machine works as planned (it won't).
Since there's only about a 5% chance (max) that going from say S3 to Azure will ever happen, the extra cathedral of abstraction saves an actuarial 1.5min of dev time.
All that only for 2-4 days of development to make it and the added runtime at every request for the convenience. Genius!
I'm not going to write raw HTTP requests to S3 in every place in my code that I need to read/write objects from there. What I'd rather have is a simple abstraction with methods like get(id) -> obj and put(obj) -> id.
Yeah I have been through that before where the architect of the company wrote his own bespoke ORM, logging framework, etc. and he was the only one who knew how it worked.
It's art, fashion and politics.
It's not binary. It's probabilities. Some environments make it harder to mess up, others make it easier. This is real.
Brands generally mean nothing to me, new consumer technology I'm generally not interested in, and I have no issues say, taking the bus and getting reading done instead of rolling around in say a Tesla (despite the fact that buying one is well within my financial reach). I honestly don't care in the slightest.
So yes, it's probably a larger personality disposition which manifests itself in this particular way moreso than it is a morsel of objective rational reality.
The people I lambast are the same ones with things like smart speakers and wifi connected refrigerators (I use an old minifridge and I prefer it). It's just a lifestyle; not some objectively poor use of money and time resources.
That's a nice perspective and it helps explain a lot, thanks.
It appears that we think about different terms when visualizing what "incompetent" means.
We create languages to tackle different sets of problems, and we want to minimize human error - that part, I believe, we can agree on.
However, if you perform "SELECT * FROM mytable" (table grows indefinitely) and then sort / limit in the language and not database - you're incompetent, you simply lack knowledge and you didn't even think abstractly what can happen by doing so. There's no language out there that can teach you "right tool for the job" or "keep it simple" or "should I do it, maybe there's another way, did someone else have this problem?", no matter what wizard creates it.
We will never weed out incompetent people by creating languages and a language shouldn't cater to a moron.
There is a reason most web sites don’t use C.
Invisible characters are a problem in every language, configuration file, file period, trying to suggest that its specific to php is just silly.
PHP does something different. It outputs it early and when you try to send a header it tells you that's too late. That error is in no way helpful to you at that point unless you already know about this issue, and it won't even help you figure out which file was affected. That part is specific to PHP.
I'm not familiar with Lua pages, but all I can find uses a http / fastcgi server with explicit routing. ASP classic has its own terrible ideas and it's close to death now - 2025 is the last year MS committed to support it, so I don't really think of it as an interesting language anymore.
And as a result also easier to achieve proficiency in.
Just because it works, doesn't mean it's good or secure. And while it's very easy to see if something works or not, it's very hard to see if something is secure.
I’d rather there be some learning curve so people understand what they’re doing (or not doing).
I'll be flask-ing
In a complex product (as in, most professional settings or large services/web sites) the PHP I've seen is grossly complex, and not intuitive—especially WordPress deployments.
Dev teams have to perform all kinds of gymnastics with the PHP code to get it to do what they want, and it's just a flat out nightmare that I've made sure my boss and colleagues know that I have no desire to work with it.
It always ends up a house of cards and full of vulnerabilities so that something is regularly getting exposed that allows at least editorial access. Security issues that should otherwise be no problem.
God knows how many other vulnerabilities exist. Every single server I've ever had has had bots and crawlers polling for common PHP files in an effort to exploit them, should they exist.
I just don't like having even the chance that my back-end source could, for want of a single character, spill out to a web page upon request.
And then there's performance...
Anyway for simple things, sure. For things that don't require much security, sure. For anything else... it's not for me.
I've done enough WP to certainly agree with you. However, I don't think it's fair to judge PHP by how WP has abused it.
WP problem is its desire to sacrifice code quality and best practices for market share. That is, many things don't get refactored (into something OOP based) because there might be backwards compatibility issues. Again, this isn't PHP's fault.
That said, I'll never go out of my way to use it for much else—let alone serving and routing something public-facing ever again.
I like that it's forward-thinking, but it moves so fast that it has negative impact on user (i.e., dev) experience.
Yes, but the holes and gotchas are worse when they are baked into the language. The thing that Golang gets right, is that the developers are willing to eschew features to avoid gotchas. It's like other languages are sports cars with sexy lines and fancy features that everyone wants, but have to spend more time "in the shop." (An analogy for in the debugger.) Golang is more like a base model Toyota Corolla with a manual transmission.
Not sure what PHP is like. Maybe some sort of modder car. Like Perl and Ruby, PHP grew by readily adding features in response to demand. In that way, it's the opposite of Golang.
PHP is much less complex than most.
That depends on what level you're looking at. PHP is one of those languages that has a lot of complexity baked into it in the form of language design warts. In order to make it a nimble language, you have to ignore/eschew parts of it, and stick to some "good parts."
https://news.ycombinator.com/item?id=2343351
It would have been possible for tumblr to avoid this with good development practices (don’t edit code live, don’t bake credentials into code, etc) but I imagine there was a culture of doing it at the time.
I don’t think it’s fair to tell developers “use our language, it’s super easy!” and then expect them to discard all of those bad habits as they start putting things in production.
This doesn’t seem to be a language choice problem, it seems to be a monolith problem, where PHP simply managed to avoid some of the traditional monolith issues by design. Your CD pipelines in any micro service architecture should solve these problems, whether it’s using FaaS or containers, or whether it’s using a compiled language or an interpreted one.
No - it didn't. PHP up to this day is a spaghetti mess it had always been.
What standards did Wordpress set a few years ago? Huge, disjoint sets of files spread throughout the themes folders. How much time does it take me to understand which of these files is causing the error?
Do you still upload your code via FTP directly to the web server? Do you still reset the code cache for the PHP in order for that new code to become live? Well, I am going to be happy when your skill set is made redundant, because you are getting paid to know all of these quirks and they are not making the industry any better.
You can write good code in _anything_. You could even write it on paper and then expense that to a person working for $0.01/hour to execute it. The question is whether the liability of your methods is lower than the liability of other methods.
PHP is essentially the dinosaur from the times when SEO consultants made loads of money. They are still using PHP because they never knew anything better and the scale of the industry is enormous, so it's slow to change.
It's pretty rare that this is even an option, since no one in their right mind would set up an FTP server with access to anything important.
SFTP? I don't see why not. No need to make things more complex than is necessary.
I don't remember any particular problems with code caching when I did PHP development, though maybe you use a different caching tool than I did. Also, Wordpress is its own beast, and is generally reviled by most everyone, expecially PHP programmers.
You are trying to argue definitions (SFTP vs FTP when FTP just means “any file transfer protocol”) instead of arguing that uploading any amount of files by any protocol that are immediately picked up by the interpreter introduces nondeterministic behaviour of the website where the users accessing your website only see a subset of the files you were trying to upload.
Doesn’t that just reinforce one’s confidence in the fact that PHP developers are generally quite amature in nature?
Do you not see the comments in this specific thread? The guy a bit higher up the chain thinks my issue is with "FTP vs SFTP", rather than "the version of the files at a particular moment in time".
He doesn't even understand why a partial view of the files could be an issue.
And the general sentiment in PHP is that "you can change any file separately, by editing in online on the server - and that is a good thing".
Except in reality once you want to use non /whatever/file.php as urls - you're back to implementing a router
> PHP files can be deployed independently, swapped out or updated live. Intuitive, simple, powerful. Can be as easy as editing a php file in notepad and dropping it on a ftp server. Deployed.
Except in reality, you don't want to deploy directly after editing a file since it's like deploying to production, you're gonna have a bad time.
> A single layer as opposed to 'modern architecture' where there's client side back/front end layers, api layer, logic, validator, data access, and ORM layers.
Except in reality, that just leads to a bunch of spaghetti code with no separation of concerns and impossible to maintain.
> Can extend itself as it runs. For example Wordpress, running off of php files can download plugins to its own server (which are just more php files) to instantly extend itself. Without restarting or redeployment. (What other web platforms can do this?)
Except in reality, this only works with php apps that have an integrated package manager and even then it leads to problems when a version is incompatible both in php or plugin dependency.
> Amazon lambda may have more in common with PHP in terms of discreet deployable units of functionality. What's old is new again.
Except in reality, serverless lambda is a terrible idea:
1. lock in to a specific platform with limited visibility tools and a dependency on a 3rd party when shit doesn't work
2. when functions change you run into function incompatibility chaos and no smart way to handle that mess
3. the "scalability" win is a lie, it's just deferred to whatever data storage service you are using - which ends up blowing up because while serverless scales, the db doesn't
4. addendum to 3, the statelessness of lambda means you can not use local caches to increase your throughput - increasing your hardware requirement
> Compiling/deploying an entire system to change a single endpoint feels backwards after using PHP.
Except in reality, you are notified of a bunch of potential bugs right there and then, instead of "maybe" finding out about them at runtime especially since PHP will by default consider a non defined variable just an empty string and display it as such on the page, and it's not until Joe User notices it that you'd ever find out.
The logging analysis tools are excellent and it’s quite easy to tie your lambda logging to whatever tool you are using.
As far as “lock-in”, there is an Amazon provided framework in every supported language to just add a proxy that allows you to use your standard framework (Node/Express C#/ASP.Net, etc) and you cab deploy to Lambda or your traditional web server with no code changes.
2. when functions change you run into function incompatibility chaos and no smart way to handle that mess
What???
3. the "scalability" win is a lie, it's just deferred to whatever data storage service you are using - which ends up blowing up because while serverless scales, the db doesn't
Serverless Aurora (Mysql) and DynamoDB both have autoscaling. You can also auto scale Read Replicas fast with traditional Aurora.
4. addendum to 3, the statelessness of lambda means you can not use local caches to increase your throughput - increasing your hardware requirement
Again not true, if you are calling an endpoint frequently, the instance stays warm for up to around 15 minutes and can maintain state.
I'm quite sure you can achieve this in golang with plugins[1]. That not as flexable as PHP, mainly because it involves a static type system and a compile phase (and more work in general).
I mean that's just how CGI works, most every HTTP server still supports CGI, nothing stops you from deploying that way. Unless you're using Java or the like of course, then it's not very convenient.
I mean, it's insane and you shouldn't, but it's eminently possible.
That's part of the inconvenience though, one of the advantages of CGI was the low tooling requirements.
> I think in this case, the fact that almost every language has migrated away from CGI-style routing is probably telling.
I mean sure, but beyond not being a very good protocol CGI needs to execute the handler script on every connection, Java is not known for that being cheap.
Try to deploy any self-hosted service like nextcloud, gitea. It was a nightmare to deploy nextcloud. Also it turned to be too slow for ONE USER.
Non-atomic deployments? Not using Composer to manage dependencies? No separation of concerns? Editing files directly on the production environment?
I get that it's nice for beginners, but they're not benefits for professionals. We have better ways of doing things than Notepad and FTP.
The vast majority of PHP frameworks, even micro-frameworks, don't work that way. They route all traffic (except static assets) to an `index.php`, which then forwards it to a regular router.
Perhaps end-users should not have the capacity to so easily add third party PHP code, even if it’s “simple.”
But that plugin system also is one of WordPress' greatest assets. And you can add PHP code to any part of a "theme" too. If you turned off the ability for themes and plugins to be "added live" then I don't think WordPress would be nearly as successful as it has become.
Wordpress is not PHP.
And I think you can definitely argue that a low barrier to entry means that it gives beginners a lot of power they don't quite understand.
Which is why I think most people steer towards common web frameworks, because not many people can know all the ways you can create security issues.
Then you get into the complexities of various common web frameworks (Zend, etc) and you have to really wonder if the original OPs argument about simplicity and ease-of-use are worth that trade-off from using something else.
You're trying to apply the problems of a framework/app to a language itself.
Java: Use a classloader to load a JAR and instantiate one of its classes: https://stackoverflow.com/questions/60764/how-should-i-load-...
.Net - use an AppDomain (or other methods): https://stackoverflow.com/questions/1137781/correct-way-to-l...
On the more general point, I am not sure scripting languages lend themselves better to lamdbas, as dependencies are usually external to the system. For instance PHP often relies on system json/xml libraries. Database access also needs to be precompiled and installed on the system, as would be crypto or internalionalization routines.
Compared to that, I'd expect compiled runtimes can have one single "fat" binary that has most of the risky dependencies and only rely on the bare minimum provided by the system.
PHP files can be swapped out live because many CGI wrappers don't cache anything in memory, which means at high strain you start dealing with disk load, file locks, etc.
There are many other languages which also don't require compilation, often at the trade off of less performance. Some really clever languages let compilation be an optional step.
A single layer means your frontend logic, data models, and database access all run the risk of being one giant mess. Sure other languages run that risk too, but it's especially prevalent in PHP.
PHP can extend itself - it can also be used to download attack vectors and execute them directly on the server with no concept of code signing. Other languages offer powerful facilities for remote updates if they're desired, but that's usually not the best approach for Web.
You can edit other languages with notepad too.
Being able to deploy a single endpoint to a live server and hoping it doesn't cause problems sounds like terror.
Since it's basically just doing eval(loadFile(...)), any language with eval() can do this, for better or worse. Which is like most of them. Perl, Python, Ruby, and Lua, to name the most common.
I think what this demonstrates is that Go isn't a better PHP. Rather, we're at the point where Go could be used to build a better PHP. The most likely paths for this, are to somehow come up with a big group of developers with a penchant for doing this, and/or have some big company fund this.
Not if you're using... literally any modern framework and deploying it properly. This hasn't been the case in years except for common legacy stuff like Wordpress.
Also since the release of PHP 7.0, core development seems to have really picked up with good stuff in every release (7.3 was just released a few months ago).
The only thing Laravel had going for it was that you could take more shortcuts, and it was a pain to integrate into any IDE if you wanted decent autocompletion.
Not an end-all be-all, but worth noting: https://github.com/topics/framework
It's still a horrible abomination of a language that invites bugs and requires A LOT of care to not produce buggy code, though.
* touching basically any standard library function negates a lot of the benefit
* silent coercion still happens everywhere inside a function body
Even if strict comparison, you have to spend a lot of code validating the input and it's really easy to forget an edge case.
Yes, which would make it behave exactly like probably every language with strong runtime typechecks. Very weird indeed. It's obviously much more preferable that the code sometimes does the wrong thing without warning.
And of course with static typing, it would be extremely weird since the code wouldn't even pass the compiler!
For people not using Intellij (or wanting a tool that can be used as part of commit/deploy setup there is phan which is well executed).
I've mocked PHP for a long time (been using it for various day jobs for over a decade) but they've made massive strides in the last 2-3 years to the extent where used properly it's approach 'not a bad' language status.
1. Generic typehints, for one. Typehinting half the methods as returning a generic `array` is not fun.
2. And that's before you even remember that PHP's array is both a vector and a hashmap, so you need to install a PECL extension or a third-party library to get proper Map/Sequence/etc.
One of the reasons PHP was appealing initially was that all this boilerplate and extra files were unnecessary, you just wrote something in the .php file (in Apache’s hierarchy) and could load the web page. As problematic as that was, it let you focus on getting stuff done instead of overwhelming you with ad hoc conventions and dozens of files with no immediate use.
Go is a language with sane defaults and little boilerplate. It would benefit from a web framework with similar principles.
Granted, we're talking about largely server side generated web pages and, haha, who does THAT still in 2019 : hangs head in shame :
But I am rewriting my personal site/blog in Go as a trial run/learning process. I've been critical of Go in the past so I thought I'd give it a... go.
So far I don't mind the experience. No server framework, either. The standard library is actually pretty good, at least for something simple like that.
The only [external] dependency I'm pulling in so far is `blackfriday` for parsing Markdown files (the posts) upon request— I'm much too lazy to write a Markdown parser myself for this purpose.
It's not finished yet, but it's on its way— https://github.com/robertfairley/rf-19-go
Configuring a service to monitor gunicorn, which itself took a bit to configure, before I begin configuring NGINX or Apache... it's really a pain in the butt.
LAMP/LEMP stacks just... are
Deploying is as simple as touching a reload.wsgi file.
Turns out, leveraging Dokku and having the right files, ie a Procfile to bind your app to Gunicorn and pushing the repo to the dokku instance was all it took.
Granted, it's for internal use so downtime isn't that big of an issue.
LEPP (nginx, PostgreSQL, Python) stack seems to me an all-around better stack for most of the deployments people use LAMP for.
Writing secure, readable, quality code in PHP is something I'm far more comfortable doing than deploying Flask or Django apps on a VPS. That's a function of my lived experiences.
YMMV, but I think declaring python/ruby on the backend is "the all-around better stack" for everyone is a bit short-sighted imho.
Citation needed. I’ve had a very nice time. It’s statically typed, has excellent templating support, and is generally very productive.
I'm glad it's working out for you, but I don't think it's a stretch to say it wasn't really designed for it. On its own, that doesn't mean it's a bad fit; but I agree with your parent and think it's awful for this type of stuff.
(1) - https://commandcenter.blogspot.com/2012/06/less-is-exponenti...
Credentials: Worked mainly in go for 4 years... 18+ years coding in about 9 languages.
Yes I realized this is opinion.
MySQLd in PHP is a mirror process, and in fact retains the C function names.
WRT ORMs - Go has ORMs, some of them look reasonable. I'm not a big fan of ORMs in general though. IMHO the only valid use cases for ORM's are for applications that need to support multiple database technologies, or where the application developers don't know SQL.
Or anything else for that matter, maybe aside from some command line tooling.
Facebook goes into this category then, I presume?
The community seems bent on the whole "all you need is net/http", but that just isn't practical in modern web development. People like ORMs, easy to handle html forms, security as a default, easy session/cookie handling etc. In the end, web developers want ease of life.
Go is a great language for many things, but if it's going to take on the web at large (outside of HTTP APIs), the community needs to grow out of this "net/http or nothing" approach.
There is some hope, some frameworks like https://gobuffalo.io/en are showing up, but the Go ecosystem is dying for a Rails/Django solution.
People always use this modern term as if it implies something significantly different or more "advanced". The web hasn't changed much. It's still data over tcp sockets to a contained runtime -- a web browser.
> People like ORMs
People in my experience are starting to dislike ORMs. If you have done this for long enough, you realize they are great for getting off the ground, but they inevitably get in your way, and start generating some really bad queries which you have to start one by one replacing with raw SQL statements, at which point you might have well started with raw SQL.
Having come from Rails, and PHP frameworks like Symphony and Laravel at my company, using Go I feel almost like I am more intimate with my code. I understand it better, the dependency chain only ever goes one or at most two levels deep. I will admit the the templating and routing is more "batteries included" in these frameworks, but the other parts that I have control of that I consider much more important (such as how my data actually gets stored and other network calls I have to make), I would much rather do those in Go than in PHP
That's what I see around me as well.
I greatly miss the nice, clean ORM experience. It's so much better for developer efficiency.
I use go for building websites and it was the first time web development really made any sense. All the other systems out there require tons of tools, and lock you into doing things their way.
So, what makes GO so much of a pain? Maybe ignorance is bliss for me?
Nothing is stopping you from writing everything yourself in any other language. You can do the same in Java or .NET. Then you start finding out you need routing, validation, security, DB access, etc. which golang lacks and ends up making it much more verbose than other mature frameworks.
Still did it in go because it was a very simple webapp and deployment is so easy with go, but for a more complex task I'm not sure I'd have used it.
I am not saying you need to write all your software but if your app is on the lines of declaring a few statements and running a command to generate the rest then I have to ask what you really are doing. On top of that you have to ask how you will approach changing your program using frameworks to the specs of the task at hand?
Also, can you go into what is "manual" about autentication, db management in go? Compared to other languages? Did you mean framework?
Trying both Laravel and Symfony I think there is no need for Laravel (anymore). Laravel just has too much magic that will bite you later on.
The only thing you should skip in both frameworks are 'annotations'. But this is easy to do.
Especially when that is not explained in the docs or just in a very vague way...
I tried improving the docs by pointing out where magic (e.g. fix naming conventions) is needed and where not, but the mantainer just turned that into vague mush again (after he had even agreed to the changes).
Also if you need any more details that are not in the docs, everyone points you to paid video courses that assume you have a Mac...
That honestly leaves me with a bad taste im my mouth after trying laravel :/
I don’t know. It’s odd.
I assume you're referring to laracasts.com... what does having a mac have to do with the videos there?
A controller should not know about routes.
A model should not know about database design.
For me Laravel was a nightmare to use with Vue. Both template engines (blade, vue) use moustache tags so everything has to be declared inside @vetbatim. Then mix doesn't even compare to ease of vue cli imo. Then the nested directory structure was so confusing (was it inside resource folder, or controller folder). I've never been happier since I ditched these opinionated frameworks
Routing
Templating
DB abstraction
Additionally, the PSR project has standardized a lot of APIs (HTTP request/response, logging, cache to name a few), which means if a package conforms to PSR, you get interop out of the box and can quickly swap implementations if needed.
With both PHP and JS this isn’t the case, which is why you see SO many frameworks for them: all of the parts are already there so the frameworks are mostly just rearranging things. Ruby, Python, Go, etc are general purpose so the frameworks provide a lot more support.
PHP’s biggest hang up for years was lack of name spacing for good module support so EVERY framework had their own version of every core feature you’d need abstracted around its framework naming schema. Can you imagine every framework writing their own database drivers...because that was happening.
As soon as Composer was released it was only going to be a matter of time before the ecosystem started to clean itself up from 9 different ways to install shared code.
Glad to see it’s happening.
composer require guzzlehttp/guzzle
Now you have GuzzleHttp available to your app. This way you include only what is needed. new Vue({ delimiters: ['${', '}']...If you are using Doctrine the only alternative to docblock annotations is XML because they are deprecating YAML support. I really hope they build support in the language itself. I can't understand their fierce opposition to a feature every other major object oriented language has. They are only forcing a large part of the ecosystem, everything that is Symfony or Doctrine based, to use the horrible docblock work around.
If you have that much time to spend on rewrites, I really envy you :-)
> They were a little surprised to hear our stack involved Golang and some flat out told us they’d prefer PHP, because that’s what most of our products rely upon.
I believe this is the real reason why, and everything else above it is pointless technical justification for a sound business decision. I also believe there's an unvoiced, even more powerful reason, in "I already know PHP and don't want to learn a whole new thing."
These are both sound reasons. The technical justifications are not.
Choosing Go for something like this was a bad decision. But choosing PHP is only slightly better. Opting for Django, Rails, or Phoenix would have better technical justification, but technical justification is rarely the real reason why we make decisions like these.
I think that if they choose to use a high-quality, modern php framework like Symfony, the technical decision would still make sense in the context of the alternatives you mentioned.
This isn't just technical; its baked deep into the culture of Go. And that's fine. Its designed for something different.
Check out Sylius for a really solid Symfony based application: https://sylius.com/
I came to Go from mainly C++, Java, and Python background, and I feel like it's the best of all 3 (to me). It's compiled and really fast (like C++), it has a great set of libraries and community interaction/support (like Java), and it has simple syntax that is clear and quick to understand (like Python).
It's not a perfect language (nothing can ever be), but it's become my favorite to use for back-end web services and even taken over some of my scripting workflow.
I can see it being painful if you're trying to render websites server-side though. That's a bit outside of what it's made for
Use https://github.com/kisielk/errcheck for that.
Or prefer https://staticcheck.io/ for a larger set of checks.
fmt.Println("foo")
I don't see errcheck complaining therehow about (taken from here: (https://www.reddit.com/r/programming/comments/ak305l/goodbye...):
r1, err := fn1()
r2, err = fn2()
if err != nil {
return err
}
err check doesn't complain eitherVSCode is also really good for Go, I was surprised. There are plugins that massively help with testing, syntax checking, error handling, etc. I think it actually catches more issues than GoLand!
I wish we could use more than channels - for me, I often feel like I'm shoehorning them in because there's no support for protected objects (native queues, conditional variables etc).
Perhaps I'm just using them wrong. Sometimes I have to use locks, and I don't think we should be forced to use locks in 2019. We've had better solutions since the 80s.
Absolutely not. Locks/spinlocks are found in pretty much every significantly parallel software project. It is pretty arrogant to criticize almost all software architectures on earth.
Almost all software is programmed with modern languages, which all (imo) have extremely lackluster support for concurrency. It's not a symptom of the programmers, but the tools they work with. Who uses Ada these days?
Locks should only be used when other protection mechanisms are too slow.
Semantically, the critical region protected by a lock is not connected to the lock in any way. This can make debugging races super difficult, and you have to rely on everyone to lock everything at the right point.
Juggling multiple locks in complex concurrent processes is difficult, and prone to bugs.
I struggle to think of where a lock is required, barring the extremely hyperoptimised hot paths within operating systems, or similar applications.
Writing code-generators for everything wasn't fun.
I'd flip what you said and say that most of the people arguing against generics in Go don't have much or any experience with them. Which makes sense because a large number of users came from dynamically typed languages.
Go is actually simpler than PHP as a language, once one understands "explicit" pointers (though PHP does expose pointers for a few things, arrays for instance since they are copied by default).
As for PHP, it's useful IN SPITE of itself, and that's the issue, the language works against the developer and only the tooling, frameworks and rigorous security practices can mitigate its flaws.
The whole integration in composer with the symfony flex component makes developing even easier than before: https://symfony.com/doc/current/setup/flex.html
“Just for fun, I compared apples and oranges again by benchmarking the login page (which doesn't hit any database) for both application versions using Siege.
The Symfony application (PHP 7.3, OPcache enabled, optimized autoloader) handles about 1470 req/s. The Go application (compiled using Go v1.11) averages about 18600 req/s.”
> it’s more maintainable for us to do it in PHP right now
If you're at that scale then probably symfony isn't for you.
You're not alone mind you, most of the new platforms are not very popular just because of how embedded WordPress is in its ecosystem. It just surprises me that both WordPress never moved on and that the PHP developer community never chose something different when it was clear WordPress had no intention of moving to more modern practices.
Imho the best CMS for PHP.
Have you ever tried it?
It was the only CMS I could find that had the level of simplicity I needed.
What are the amazing option do you suggests with batteries include in the language would be ideal.
Comparing Go ans PHP a few years ago would mean to compare Go and PHP/Apache or PHP/Nginx, because PHP could not run its own server.
It's like comparing Git and Subversion, where you have to explain concepts like staging.
Or IntelliJ and Eclipse, where you have to explain workspaces.
All talk of accessibility and ease for new users often comes off as posturing by some tech folks who then proceed to rubbish any efforts at achieving it and the compromises involved. It fits in nicely with the 'contempt culture' recently covered here.
The growing problem for the technical community and new users is the marketing by other languages, frameworks and those vested in these ecosystems which means using forums like this to belittle, rubbish and exaggerate any perceived fault in everything else. PHP's contemporaries like Python, Ruby, Javascript have their many downsides too but these efforts create false binary narratives. This is not a good basis for technical decisions or informed discussion.
I have a lot of discussions with friends in the startup scene about the topic of Laravel vs Symfony. So far it's a head to head race.
I have yet to find a good 'Laravel vs Symfony' comparison page. Yes, there are tons of 'SEO optimized articles' with this title. But I find them all rather uninformative and often even totally wrong and unfair.
The page I would love to see would have the same project coded twice. Once with each framework. And then display each file on the left for Laravel and the corresponding file on the right for Symfony.
But there are multiple reasons I choose Symfony 4 over Laravel.
And if you want a code comparison then this small example:
Laravel:
class User
{
}
Symfony: class User
{
private $id;
private $name;
public function getId():?int
{
return $this->id;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getName():?string
{
return $this->name;
}
}
Laravel looks a lot easier and quicker. And it is.
But good luck next month when you can't remember what properties User has. Your IDE can't autocomplete it. And also good luck working with a team. Your team members have to look up the database model for the User to see what properties are available.And this is happening in Laravel all the time. Very quick, very easy, a lot of magic but it will bite you in the end.
You could also hint these with / @var */ there are ways around it but yes it isn't ideal. I really liked doctrine, perhaps I was using it wrong, but having everything in annotations was pretty nice since migrations etc could run off of it.
With doctrine I ran into issues with performance, which you can alleviate with extra lazy etc, it also hydrated what appeared to be massive objects, which you had to use a custom debugger because print_r'ing one with the recursive references etc caused some crazy issues. I have since moved on from PHP, but if the project calls for it, I have no problem using laravel. While not ideal, it sure is productive to build an API in. I wrote a project in lumen, which is/was a subset of laravel built for APIs, and that was okay to work in. No clue if it still exists.
So you can respond to websocket messages or http requests asynchronously but you're not going to be able to implement anything like a parallel merge sort were you offload work to other threads. Things like general purpose file IO are not easy at the moment either.
Amphp might seem a heavy handed because they've taken the monorepo approach. ReactPHP on the other hand has broken everything up into individual components. For example, you can get started with ReactPHP by just pulling in the event loop https://github.com/reactphp/event-loop. All the heavy lifting for the native loop is <200 lines https://github.com/reactphp/event-loop/blob/master/src/Strea... and the API is tiny as well https://github.com/reactphp/event-loop/blob/master/src/LoopI...
There’s curl-multi[0] you can use for that purpose. Not as nice as promises/async/await, but it gets the job done for your example.
[0] https://secure.php.net/manual/en/function.curl-multi-exec.ph...
PHP 7.0 took a huge step forward by straight up removing old extensions that weren't maintained, focused a lot on performance and allowing more strict standards, and tons of new improvements. In addition, more modern frameworks like Symfony and Laravel started to pop up, which helped reduce the stigma of it just being a "scripting" language and made it very pleasant to work with.
I maintain a PHP app that was originally written in PHP 4, and one that was created in PHP 7 and the difference is night and day. I maintain a few Ruby and Python apps as well, but even having used these more often PHP still tends to be my go to for prototyping.
PHP's gotchas are syntactic/semantic but mostly on its huge standard library, which is an haphazard collection of functions from sending emails to parsing ID3 tags from MP3 files.
EDIT: JS, as the legend says, was written in 10 days, while PHP grew without much long term vision for years.
Someone wrote an article with a title like "php a language with terrible design" that got traction.
I like the language and with the right framework and templating engine its a pleasure. (I'm moving code from silex to symfony).
I've been to a fair number php meetups and frankly people there seem to be end result focused not so concerned with the language. Frankly I think PHP doesn't have as strong a fan club as ruby/python, which are decent languages but they too come with their own quirks.
Funny, that is React/JSX's biggest sell
{e = () => ajaxCallToMutateDatabase()}
Or something similar...
It's just people don't do it because it is a bad idea!
The reason quite possibly is that those are joy to use where PHP isn't. In my mind the developer happiness should be on top of the list, also the syntax is still ugly however you look at it. The versatility of Python is unmatched. Ruby allows me to do things I could only dream of in other languages, in PHP those dreams are nightmares.
This rant is almost seven years old now, but I imagine that some things still hold true.
Python in particular is indisputably more versatile than PHP.
PHP was one of my first languages, and it took a long time to break some bad habits it taught. I still can't get over the existence of PHP's "arrays." (Mentioned in the article.) The only data structure is one-size-fits-all. It's truly baffling when you approach it with basic CS knowledge, and the rabbit hole only gets worse...
However, let's prove once more that languages evolve: http://php.net/manual/en/book.ds.php
The "classic" you're referring to is far from something objective. There will always be problems with languages. That's why we have the human factor who is supposed to be intelligent and work around the apparent issues and make the computer do useful work despite apparent tool glitches.
Sadly, we're just creating better idiots who are only getting better at whining.
E.g., I've seen a payment management suite that was written using php traits, which then had a super class that everything descended from, meaning every service could do everything, completely breaking OOP. For example, a DirectDebitService has methods like processMandate(), processDd(), but then because of the traits it also has access to processCreditCardPayment(). As you can imagine this made unit testing literally anything require lines of set up code and just made things impossible to work with.
With the introduction of classes, and PHP 7's scalar type declarations as actual keywords rather than just PHP docs, as well as the option for strict comparison, plus the ridiculous speed improvement between 5.6 and 7.0.
Further, tools like composer (which I think was actually one of the first modern package managers (with lock files, version selectors), Behat for integration tests, plus the huge steps frameworks have made in removing in overhead have made PHP actually a very nice language to write these days.
Deployment in a micro service context is still annoying as PHP's built in web server is not great, requiring you to have an Ngninx pointing at a PHP-FPM which actually serves each of your microservices.
You may think you can get away with one Ngninx, but then as soon as micro services start requiring things like scaling it's a pain in the arse. E.g. you may wish to do rate limiting or rbac or something for a specific service, requiring an nginx->PHP-FPM in front of each PHP service.
I'm sure there are cleverer ways to get around this but this is the way I always go and the way I've seen other PHP deva go
The entry level language gets the reputation of the code written on the platform.
That's why basic, flash, php, Java, and JavaScript all had bad reputations at one time.
You can knock on any sufficiently complex language, it's actually really easy.
Python, for instance, gives different numerical results between 2 and 3 for the code "False - 3 * True / True / 2 + 3 * False" (-1 and -1.5)
Making things look absurd isn't hard.
I wonder which part is performance unmatched?
My opinion would be Crystal language for its simplicity and higher throughput but unmatched performance is behind Rust and C.
That, or it can be read as "in the family of web-friendly languages". The only other "fast" language widely used for the web is Java.
Yes it is hard to tune, but not so much different than playing with C or C++ compilation switches, across each compiler that is being used in production.
Go uses an order of magnitude less memory for most type of workloads though. Also you don't tune c++ binaries delivered to you. You have to tune the JVM's option to death for big apps. I can't count the number of incidents "solved" by raising the Xmx param.
The big question is how properly those big apps were coded.
Go doesn't run Fintech servers, while Java keeps replacing C++ servers. Yes, one needs to code Java with low level tricks like C++, but it is possible and there are many performance experts doing it.
How many Fintech servers are running on Go?
How many customers run self-compiled, say mysql binaries? Or mongodb? An tiny minority. Now how many tune cassandra or hadoop jvms? A big chunk.
You can use niche cases to make a point (fintech is almost the textbook definition of a niche software use case), however what you say is plain wrong most of the time.
Also, I've managed thousands of c++ and thousands of java processes. I'd take c++ ones over java any day.
Proper Cassandra and Hadoop deployments are as niche as Fintech, the large majority could solve their problems with UNIX command line tools.
On my world the team manages deployments, I rather take Java over C++ compilation times, and having tools like Mission Control to monitor cluster performance on production servers.
With (in my experience) go being a little faster than java and haskell, and o'caml being slightly faster than anyone, but nothing significative enough for me to expect an article titled "my Java webapp was too slow so I rewrote it in O'Caml" anytime soon.
Benchmarking is very relative, though. I'd be glad to read evidence showing go is significantly slower than any of those in some domain.
You know you can contribute what you consider to be better examples — https://salsa.debian.org/benchmarksgame-team/benchmarksgame/...
> …or even best algorithms…
Wouldn't that make the algorithm the difference ;-)
You seem to be saying that what you see on the benchmarks game matches your experience, which makes your "highly biased" claim kind-of strange.
Please show something on that website that is "highly biased".
It's pretty good with Python too, which we have a little bit of (mostly Flask apps).
I like the batteries included standard library and single binary deployment of Go.
PHP, like others have said, gives you a single endpoint and you can make rapid changes. Its ideal for internal web apps that do not require insane performance.
And there alternatives. The best known is probably Revel: https://revel.github.io
For a doctrine (ORM) alternative you have for example https://github.com/jinzhu/gorm
The point about Go; using those types of tools is generally frowned upon in the community. It's overkill for most (micro)services.
But few gophers build a full-stack website in a single application.
I'm a gopher; I wouldn't want to use Revel or Gorm. I feel I'd be using the wrong tool for the job. I'd more likely use Django or Symfony when I'd need to build a full-stack SSR.
If a backend API is used by different clients (mobile apps, SPA, servers, ...) using a full-stack SSR framework like Symfony or Django doesn't make much sense anymore. You wouldn't use 90% of the framework's features. It feels like bloat.
But many websites don't need to serve different clients.
The author's decision to go from Golang to PHP makes perfect sense if he's building SSR websites.
I'm getting old ;)
Obviously things will have matured since then.
Doctrine implements the Unit of Work pattern. From what you're saying GORM is more like an Active Record ORM.
You're right, that wouldn't make it a good direct alternative.
Other potentially useful tools:
- PHP_CodeSniffer (https://github.com/squizlabs/PHP_CodeSniffer)
- GrumPHP (https://github.com/phpro/grumphp)
- PHP Mess Detector (https://phpmd.org/)
> find . -name "*.php" -print0 | xargs -0 -n1 -P8 php -l | grep -v "No syntax errors detected"
The speed advantage of HHVM has also been largely erased. Some high-profile PHP sites migrated to HHVM before and up to ~2015, but I haven't heard of a single site doing that since PHP 7.0 came out.
How is Go any different?
Meanwhile, I can't think of any major online service that relies on Hack apart from Facebook and its subsidiaries.
But I agree with the original point about not fully relying on the whims of a major corporate promoter. Priorities can change within, without clear visibility on the outside.
I could go on a very long discussion about why I prefer Rails but at the end of day it's just up to you to compare.
When I started Rails I was building an app with Symfony, took me a week to get it to a good state and it was extra frustrating (I had been doing PHP for 5 years).
I started Rails, learned Ruby on Wikipedia and just general googling and got the same app in a few hours.
This has nothing to do with homomorphic encryption, unless I'm missing something.
composer require some/library
That's PHP's package management. What's so non-trivial about that?Unlike some other package managers...
Deadlocks and race conditions.
For node, the entire app is a single thread so this just doesn't happen. For python/php/ruby concurrency is abstracted away and handled above the framework layer so the programmer never has to deal with it. You can launch threads in a route handler for these languages but it's not often done and you have nothing like a context object that is basically this abstraction leak that explicitly forces the programmer to constantly be aware of concurrency issues.
After some years of development, both languages have evolved a lot and they both can be used for many other things, that they haven't been designed for.
PHP was a dynamically typed scripting language to build personal homepages (Personal Home Page Tools). Today it is an object oriented, type hinted language that supports functional and object oriented programming, many database management systems and has a package manager (composer). I really like PHP (see https://github.com/sandreas/m4b-tool for a proof), but some concerns about PHP have always been (and still are):
- backwards compatibility reaching too far
- way too big standard library (see levenshtein function)
- the "callable" concept - call_user_func_array([$obj, "method"])
- mixing up too many concepts (OOP, Traits, Functional style)
- the type system (which is getting better with php 7)
- unpredictable statements - empty($x), comparisons (== vs ===) and the "mixed" type
- the "array" type being array and dictionary and...
- the $ used for variable declaration
- $this-> is still needed for calling object methods
- "." for concatenation and "\" for namespace separation
Another bad thing about PHP is, that on most web servers it is meant to be stateless, which means that you are in trouble using technologies like websockets.
Some of these things unfortunately mean that PHP often is much slower than it could be - and this is where "go" can be a successor. Performance. If you really need FAST web apps and performance is the goal, go can be a nice choice. But for getting things done in a not too complex web page, i would always choose php.
For at nearly 10 years now PHP has had support for lambdas, meaning for most uses `$foo()` can be used instead and with the inclusion of the spread operator it's seldom used.
[$obj, "methodName"] => callable for $obj->methodName()
"str_replace" => callable for function "str_replace"
["ClassName", "staticMethod"] => callable for ClassName::staticMethod()
"ClassName::staticMethod" => callable for ClassName::staticMethod()
function() {} => callable for a lambda
I would prefer a "ClassMethod" and a "Function" type, instead of using strings.
$x = phpinfo; $x();
$y = $obj->method; $y();
But i don't think, this is possible, because PHP supports global constants and function names cannot be distinguished from constants, especially because PHP is not case sensitive regarding functions and classnames.
But I see, that my karma has decreased with this post, so it seems, that not many are in my opinion...
The above list is just an indeed subjective list of things i don't like about PHP, although i like PHP in general and it is NOT a PHP rant!