u/bkanber
In this archive from Dec 2010 to Oct 2024
- 5
- posts
- 213
- comments
- 2
- media
- 907
- score
Top posts
I wrote a raycasting A* pathfinder class. Sharing the source here. Should be applicable to most top-down 2d games. Enjoy!
thebotanistgame.com/blog/2020/05/01/raycasting-a...Not downloaded yet
I made a command line Slack client in PHP
github.com/TidalLabs/SlackerNot downloaded yet
What kind of data is this, and how can I decode it?
Hi, r/PHP! Hopefully you can help me. I just wrote a PHP WebSockets backend, and clients using WebSockets protocol version 8 are sending data that looks like this: <81><F7>z<A2 [spoiler]
As you would to a layperson:
PHP has a lot of quirks and inconsistencies in it that make many pieces of it confusing. Sometimes you have to look things up because they don't work the way you'd expect them to, and that slows you down. There's nothing that's really earth-shatteringly terrible about it, but people want things to be perfect. The truth is, no language is perfect, but perhaps PHP is less perfect than most others. (JavaScript has a ton of issues with it too, but for some reason people complain less about JS).
There are some issues around the PHP developer community as well. Other languages like Python and PERL have really good, reliable ways to import other peoples code and use them. PHP is trying to get better at this, but they're still a little behind the others. It's much easier to find, install, and use very powerful libraries in other languages like Python than it is in PHP. Therefore many people don't do hard-hitting math and statistics and machine learning in PHP because it's hard to find libraries to help them. This taints the image of PHP as well. PHP is perfectly capable of running neural networks, but since nobody does that (except my company), the perception of PHP is sometimes that it's a "weaker" language than, say, Python. It's not weaker; it's a "Turing-complete" language which means you can do just about anything with it.
PHP has some redeeming qualities as well. If you're in the business of making fast, reliable websites, PHP is an excellent choice. It's the most supported language there is and it powers some ridiculous percentage of websites on the internet. That's also part of its negative perception; it's easy to get up and running with PHP, and so there are a lot of beginner developers working in PHP and they kind of mess things up for future developers that take over their projects. This isn't the language's fault; it's just so easy to get started with PHP that there's a lot of bad code out there that other people end up having to maintain and get frustrated with.
Object-oriented PHP isn't all that bad. It's missing some features but to PHP's credit, they're working really hard to introduce great new features in upcoming versions. This is another issue for PHP -- they want to make sure it's fully backwards-compatible, which is why some things end up being sloppy ("mysql_real_escape_string" as opposed to the older "mysql_escape_string", the "needle,haystack" vs "haystack,needle" thing). Languages like Python are so nice because they're OK with breaking existing applications with an overhaul of the language; PHP doesn't want to do that and so you get some weird ancient artifacts messing things up.
Nginx and php-fpm work very well together and you should not encounter any real problems. The only situation where the switch would be difficult is if you're relying on a lot of htaccess stuff in Apache, which is an antipattern anyway
I've tried basically every IDE out there, and I've fallen in love with tmux+vim on a remote dev server. It gives me "dev anywhere" capability. As long as I can get an SSH connection, I can be productive. And having the remote server keeps your computer damn fast. In the past, my MacBook (pro) got damn slow from running mongo and elastic will all that data. Now every part of the process is smooth and easy. Of course, this is just a matter of taste.
More abstraction? Isn't that always the answer?
Well, even the apache docs discourage .htaccess.
First is performance: if allowoverride is on, apache must scan not just the current directory but also every parent directory above it for .htaccess. If you have a heavily nested directory structure you may be facing a handful of unnecessary disk reads per request. Especially bad for serving static files which should really not need more than one disk read per request.
Second is security: any directory in your application can now control server settings.
Third is maintainability: any directory in your application can now control server settings! This makes certain directories "magic", which is never good. It also makes your application less portable. If some mod doesn't exist on a new server you may get silent failures, changed behavior, or flat out errors, depending on how the .htaccess is written. It also couples your application to apache, whereas your application should really be server agnostic.
Fourth: it's not really necessary anymore. .htaccess was popular and useful during "shared host" server days, where you just uploaded html and php files and had no access to server settings. .htaccess allowed developers to customize aspects their server without having access to the server config. But these days, most people use VMs (or VPSs), and do have access to server config.
In general, and almost in all regards, it's better to centralize your server config and maintain a single source of truth of the behavior of the server.