Hacker News new | ask | show | jobs
by anon776 1856 days ago
PHP 7.x and Laravel really gave the language its big boy pants. Really fun to develop in and looks nothing like the PHP 3.x and 5.x grime.
1 comments

Sadly along with Laravel and Symfony came PSR culture where idiomatic PHP, with its fanfold docblock comments and double-spaced lines of code means you're lucky if you can see a dozen lines of code on a typical screen. I don't call that productive at all.
I agree, thats some bad practice and people think its good. I am part of the Uncle Bob clean code fan club. If you need comments and a doc bloc then there is something wrong with your code.
Double spaced lines of code? What do you mean?

FWIW, I no longer use DocBlocks because PHP's own type system is usually expressive enough.

> PHP's own type system is usually expressive enough.

I'd say it's one of the worst type systems. Expressive enough not to need docblocks, ok. Expressive as a type system: hell no.

I meant expressive enough that you don't need DocBlocks as often. We're nowhere near being done, PHP still lacks proper Generics and Algebraic Data Types. Recently we got Union Types (8.0) and will soon have Enums (8.1).

If you really needed generics today, you can do it with DocBlocks and static analyzers like PHPStan: <https://phpstan.org/blog/generics-in-php-using-phpdocs>. I'm hopeful that in the future, you won't need a DocBlock for that.

As for ADTs, there's some on going discussions here: <https://wiki.php.net/rfc/adts> which would build upon the existing support for Enums (8.1). I'm really looking forward to being able to have something resembling Optional/Maybe.

I'm by no means saying what PHP has is enough today, just that it's less limited than it was a few years ago. It'll be even less limited in the future.

You just said exactly what I said in my comment you reply on. More words, and more promo for future versions of PHP.

Seriously, try build something trivial with a strongly typed lang like Haskell or Elm (Elm is quite easy to get started with), and we can talk type systems after :)

Blank line above and below each line of code made even worse with opening brackets at column 1 of yet another new line. WTF!?