andrewvy / HHVMCraft

:package: Minecraft Beta 1.7.3 Server implemented in PHP/HHVM, powered by ReactPHP.
Other
192 stars 10 forks source link

PHP Issues/Painpoints #2

Closed andrewvy closed 9 years ago

andrewvy commented 9 years ago

Some points to talk about in a post-mortem blog post:

Classes And Namespaces

This was a fun one to get my head wrapped around. PHP's namespacing isn't "bad". But it's also not good. Part of why it's not so great is probably due to "internal" PHP ideology, or perhaps wasn't well implemented.

You have to specify a file and require it one by one. (Or take the time to make an autoload script.) And then you have to also declare the namespace. It seems a bit redundant, but that may just be my "high-level programmer" spoiledness with having everything imported automatically. ;)

In some ways, I can understand why you would want to import each file one by one. It makes sure you know what namespaces you're importing. But also, I really just wish there was a wildcard import.. ):

C-style, C-libraries, but little C-positives?

What I find funny/awesome/strange is PHP's wrapping of C libraries. Reading the documentation, I can already see the comments that date back to 6+ years ago. Often times, I found it really helpful to just look at the C documentation itself. I would have really loved to see some primitive data types, like byte, short, int, etc.. but that's probably not possible. It's disappointing that they took these out. It makes handling binary/hex data so much harder due to the type of casting that PHP has.

And again with numbers, PHP's conversion is really lackluster and very questionable. hexdec()? dechex()? bin2unicorn()??? A strong foundation for these conversions would make lives so much easier.