Re:My Favorite Language Has Changed to PHP
by midrus on Wednesday March 16, 2022 @05:07PM
(#30704110)
Any runtime that has the concept of "thread locals" or "thread safety" have this sharing problem, no need to exploit y anything. Of those you mention I've worked with Python and java and their runtimes do have this problem (or feature, depending how you look at it). In python for example if you import a module level variable or instance and you modify it's value on a request, you can read it from another request that lands on the same thread. Same with java. I don't know the others you mention but probably are the same as that's how most runtimes work.
You can't do that in PHP, you need to explicitly write to redis/memcached/file/database to be able to read values from another request.
Re:My Favorite Language Has Changed to PHP
by mikojan on Thursday March 17, 2022 @04:13AM
(#30708754)
For all intents and purposes there is only one instance of your business code. It is a single process. And you do whatever you want.
However, this is not a problem at all. In Go you would have to get out of your way to share information between user agents just like you would have to do in PHP.
Intentionally writing to and reading from a global variable is the exact same as intentionally writing to and reading from your MariaDB instance.
I have no clue why you would render this process problematic. Maybe in Python everything is a global?!
Or are you talking about exploring the OS primitives to share data between instances of your code? Because avoiding that shouldn't require a lot of care, and PHP has basically the same capacity.